diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..5f282702bb03ef11d7184d19c80927b47f919764 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a7159db0c79f78d703b3f5cf7d076674391e12aa..f2cc662aad7fb987b99c0acad5311113dc766de9 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -56,9 +56,6 @@ workflow: # see https://docs.gitlab.com/ee/ci/yaml/workflow.html#switch-between-branch-pipelines-and-merge-request-pipelines - if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS && $CI_PIPELINE_SOURCE == "push" when: never - # do not spawn pipelines for Draft MRs, see https://docs.gitlab.com/ee/ci/yaml/workflow.html#skip-pipelines-for-draft-merge-requests - - if: $CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TITLE =~ /^(\[Draft\]|\(Draft\)|Draft:)/ - when: never - if: $CI_PIPELINE_SOURCE == 'merge_request_event' variables: IVAS_PIPELINE_NAME: 'MR pipeline: $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME' @@ -173,6 +170,7 @@ stages: ### build reference binaries - *disable-debugging-macro + - make clean - make -j - mv IVAS_cod IVAS_cod_ref - mv IVAS_dec IVAS_dec_ref @@ -191,6 +189,17 @@ stages: - if [ $exit_code -ne 0 ] && [ $non_be_flag != 0 ]; then echo "Non-bitexact cases with non-BE tag encountered"; exit $EXIT_CODE_NON_BE; fi - exit 0 +.mr-get-target-commit: &mr-get-target-commit # compare to last target branch commit before pipeline was created + - target_commit=$(git log $CI_MERGE_REQUEST_TARGET_BRANCH_NAME -1 --oneline --before=${CI_PIPELINE_CREATED_AT} --format=%H) + +.get-commits-behind-count: &get-commits-behind-count + - echo $CI_COMMIT_SHA + - echo $CI_MERGE_REQUEST_TARGET_BRANCH_NAME + - commits_behind_count=$(git rev-list --count $CI_COMMIT_SHA..origin/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME) + +.check-commits-behind-count-in-compare-jobs: &check-commits-behind-count-in-compare-jobs + - if [ $commits_behind_count -ne 0 ]; then echo "Your branch is not up-to-date with main -> Compare tests will not run as they can contain false negatives this way.\nMain might have changed during your pipeline run. Run 'git merge origin/main' to update."; exit 1; fi + .build-reference-binaries: &build-reference-binaries - current_commit_sha=$(git rev-parse HEAD) ### build reference binaries @@ -241,6 +250,13 @@ stages: - echo "Applying level scaling in scripts/testv using scale=$LEVEL_SCALING" - tests/scale_pcm.py ./scripts/testv/ $LEVEL_SCALING +.merge-request-comparison-check: &merge-request-comparison-check + - echo "--------------- Running merge-request-comparison-check anchor ---------------" + - if [ $zero_errors != 1 ]; then echo "Run errors encountered!"; exit $EXIT_CODE_FAIL; fi + - if [ $exit_code -eq 1 ] && [ $non_be_flag == 0 ]; then echo "Non-bitexact cases without non-BE tag encountered!"; exit $EXIT_CODE_FAIL; fi + - if [ $exit_code -eq 1 ] && [ $non_be_flag != 0 ]; then echo "Non-bitexact cases with non-BE tag encountered"; exit $EXIT_CODE_NON_BE; fi + - exit 0 + .update-ltv-repo: &update-ltv-repo - cd $LTV_DIR - git pull @@ -306,6 +322,44 @@ stages: - if [ $exit_code20 -ne 0 ] || [ $exit_code10 -ne 0 ] || [ $exit_code5 -ne 0 ]; then exit 1; fi +# --------------------------------------------------------------- +# Job templates +# --------------------------------------------------------------- + +# When designing templates, try not to use too much inheritance and +# if multiple templates and extended on, remember that on conflict, +# latest overwrites the parameter. + +# templates for rules +.rules-basis: + rules: + - if: $MIRROR_ACCESS_TOKEN # Don't run in the mirror update pipeline (only then MIRROR_ACCESS_TOKEN is defined) + when: never + - if: $CI_PIPELINE_SOURCE == 'schedule' # Don't run in any scheduled pipelines by default (use schedule templates below to enable again for certain conditions) + when: never + - if: $CI_PIPELINE_SOURCE == 'trigger' # Don't run triggered pipeline by default + when: never + - if: $MANUAL_PIPELINE_TYPE == 'test-be-release' # Skip all the normal jobs when testing manually against release codec + when: never + - if: $MANUAL_PIPELINE_TYPE == 'test-long-self-test' # Skip all the normal jobs when testing manually against release codec + when: never + - if: $MANUAL_PIPELINE_TYPE == 'ivas-conformance' + when: never + - if: $MANUAL_PIPELINE_TYPE == 'ivas-conformance-linux' + when: never + - if: $MANUAL_PIPELINE_TYPE == 'check-clipping' + when: never + - if: $MANUAL_PIPELINE_TYPE == 'test-branch-vs-input-passthrough' + when: never + - when: on_success + +.rules-merge-request: + extends: .rules-basis + rules: + - if: $CI_PIPELINE_SOURCE == 'merge_request_event' + - if: $CI_PIPELINE_SOURCE == 'push' + when: never + .rules-pytest-to-ref-short: rules: - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == "pytest-compare" @@ -404,9 +458,20 @@ stages: - if: $CI_PIPELINE_SOURCE == 'push' when: never +.rules-merge-request-no-draft: + extends: .rules-basis + rules: + - if: $CI_MERGE_REQUEST_TITLE =~ /^(\[Draft\]|\(Draft\)|Draft:)/ + when: never + - if: $CI_PIPELINE_SOURCE == 'merge_request_event' + - if: $CI_PIPELINE_SOURCE == 'push' + when: never + .rules-merge-request-to-float-pc: extends: .rules-basis rules: + - if: $CI_MERGE_REQUEST_TITLE =~ /^(\[Draft\]|\(Draft\)|Draft:)/ + when: never - if: $CI_PIPELINE_SOURCE == 'merge_request_event' && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "float-pc" - if: $CI_PIPELINE_SOURCE == 'push' when: never @@ -820,6 +885,19 @@ branch-is-up-to-date-with-target-post: exit 1 fi +# fail pipeline in the final stage for pipelines on Draft MRs +# this also only runs on Draft MRs, so should always fail +fail-pipeline-if-in-draft: + rules: + - if: $CI_PIPELINE_SOURCE == 'merge_request_event' && $CI_MERGE_REQUEST_TITLE =~ /^(\[Draft\]|\(Draft\)|Draft:)/ + - if: $CI_PIPELINE_SOURCE == 'push' + when: never + stage: postvalidate + tags: + - ivas-linux + script: + - echo "Your MR is still in Draft state, set it to ready to be mergable, then retrigger the pipeline." + - exit 1 # --------------------------------------------------------------- # verification jobs @@ -988,7 +1066,7 @@ build-codec-linux-instrumented-make: script: - *print-common-info - *update-scripts-repo - - bash scripts/prepare_instrumentation.sh -m MEM_ONLY -p BASOP + - bash scripts/prepare_instrumentation.sh -m MEM_ONLY - make -j -C $INSTR_DIR # make sure that the codec builds with msan, asan and usan @@ -1022,6 +1100,123 @@ build-codec-windows-msbuild: - *activate-WX-windows - MSBuild.exe -maxcpucount .\Workspace_msvc\Workspace_msvc.sln /property:Configuration=Debug +# --------------------------------------------------------------- +# Test jobs for merge requests +# --------------------------------------------------------------- + +split-rendering-smoke-test: + extends: + - .test-job-linux + - .rules-merge-request + needs: ["build-codec-linux-make"] + stage: test + script: + - *print-common-info + - *update-scripts-repo + + - make -j + - testcase_timeout=10 + - python3 -m pytest -q -n auto -rA --junit-xml=report-junit.xml tests/split_rendering/test_split_rendering.py --testcase_timeout=$testcase_timeout + artifacts: + name: "mr-$CI_MERGE_REQUEST_IID--sha-$CI_COMMIT_SHORT_SHA--job-$CI_JOB_NAME--results" + expire_in: 1 week + when: always + paths: + - report-junit.xml + expose_as: "split rendering smoke results" + reports: + junit: + - report-junit.xml + +lc3-wrapper-unit-test: + extends: + - .test-job-linux + - .rules-merge-request + needs: ["build-codec-linux-make"] + stage: test + script: + - *print-common-info + - *update-scripts-repo + + - cmake -B cmake-build -G "Unix Makefiles" -DCOPY_EXECUTABLES_FROM_BUILD_DIR=true + - cmake --build cmake-build -- -j + - scripts/split_rendering/lc3plus_float/ivas_lc3plus_unit_test + +# compare split-rendering bitexactness between target and source branch +.split-rendering-pytest-on-merge-request: + extends: + - .test-job-linux-needs-testv-dir + - .rules-merge-request + needs: ["build-codec-linux-make"] + # TODO: set reasonable timeout, will most likely take less + timeout: "30 minutes" + stage: compare + script: + - *print-common-info + - *update-scripts-repo + - *get-commits-behind-count + - *check-commits-behind-count-in-compare-jobs + + # some helper variables - "|| true" to prevent failures from grep not finding anything + # write to temporary file as workaround for failures observed with piping echo + - echo $CI_MERGE_REQUEST_TITLE > tmp.txt + - non_be_flag=$(grep -c --ignore-case "\[split*[ -]*non[ -]*be\]" tmp.txt) || true + # TODO: ref_using_target comes from float repo, but does not apply here - disable for now + # - ref_using_target=$(grep -c --ignore-case "\[ref[ -]*using[ -]*target\]" tmp.txt) || true + - ref_using_target=0 + + # store the current commit hash + - source_branch_commit_sha=$(git rev-parse HEAD) + + - *mr-fetch-target-branch + - *mr-get-target-commit + - git checkout $target_commit + - echo "Building reference codec at commit $target_commit" + + # build reference binaries + - make -j + - mv IVAS_cod IVAS_cod_ref + - mv IVAS_dec IVAS_dec_ref + - mv IVAS_rend IVAS_rend_ref + + ### If ref_using_target is not set, checkout the source branch to use scripts and input from there + - if [ $ref_using_target == 0 ]; then git restore lib_com/options.h; fi # Revert changes back before checking out another branch to avoid conflicts + - if [ $ref_using_target == 0 ]; then git checkout $source_branch_commit_sha; fi + - exit_code=0 + - testcase_timeout=60 + - python3 -m pytest -q --log-level ERROR -n auto -rA --html=report.html --self-contained-html --junit-xml=report-junit.xml tests/split_rendering/test_split_rendering.py --create_ref --testcase_timeout=$testcase_timeout || exit_code=$? + + # back to source branch + - git restore lib_com/options.h # Revert changes back before checking out another branch to avoid conflicts + - git checkout $source_branch_commit_sha + - make clean + - make -j + + ### Run test using scripts and input from main + - if [ $ref_using_target == 1 ]; then git restore lib_com/options.h; fi # Revert changes back before checking out another branch to avoid conflicts + - if [ $ref_using_target == 1 ]; then git checkout $source_branch_commit_sha; fi + + # run test + - python3 -m pytest -q --log-level ERROR -n auto -rA --html=report.html --self-contained-html --junit-xml=report-junit.xml tests/split_rendering/test_split_rendering.py --create_cut --testcase_timeout=$testcase_timeout || exit_code=$? + - zero_errors=$(cat report-junit.xml | grep -c 'errors="0"') || true + + - *merge-request-comparison-check + + allow_failure: + exit_codes: + - 123 + artifacts: + name: "mr-$CI_MERGE_REQUEST_IID--sha-$CI_COMMIT_SHORT_SHA--job-$CI_JOB_NAME--results" + expire_in: 2 week + when: always + paths: + - report-junit.xml + - report.html + expose_as: "pytest split rendering results" + reports: + junit: + - report-junit.xml + # --------------------------------------------------------------- # Short test jobs that run in merge request pipelines # --------------------------------------------------------------- @@ -1418,6 +1613,8 @@ be-2-evs-26444: extends: - .test-job-linux rules: + - if: $CI_MERGE_REQUEST_TITLE =~ /^(\[Draft\]|\(Draft\)|Draft:)/ + when: never - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == "evs-26444" - if: $CI_PIPELINE_SOURCE == 'merge_request_event' (&& $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main" || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main-pc" ) tags: @@ -1469,15 +1666,10 @@ ivas-pytest-renderer: # Various other tests # --------------------------------------------------------------- -# TODO: actually run on MR once main problems are fixed voip-be-on-merge-request: extends: - .test-job-linux-needs-testv-dir - rules: - - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == "voip-be-test" - - if: $CI_PIPELINE_SOURCE == 'merge_request_event' && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "float-pc" - - if: $CI_PIPELINE_SOURCE == 'push' - when: never + - .rules-merge-request-to-float-pc stage: test needs: ["build-codec-linux-make"] timeout: "10 minutes" @@ -1496,7 +1688,7 @@ voip-be-on-merge-request: codec-smoke-test: extends: - .test-job-linux-needs-testv-dir - - .rules-merge-request + - .rules-merge-request-no-draft timeout: "20 minutes" tags: - ivas-basop-linux @@ -1747,7 +1939,7 @@ renderer-usan: renderer-pytest-on-merge-request: extends: - .test-job-linux-needs-testv-dir - - .rules-merge-request + - .rules-merge-request-to-float-pc needs: ["build-codec-linux-make"] # TODO: set reasonable timeout, will most likely take less timeout: "20 minutes" @@ -1784,11 +1976,26 @@ renderer-pytest-on-merge-request: - *merge-request-comparison-check + allow_failure: + exit_codes: + - 123 + artifacts: + name: "mr-$CI_MERGE_REQUEST_IID--sha-$CI_COMMIT_SHORT_SHA--job-$CI_JOB_NAME--results" + expire_in: 1 week + when: always + paths: + - report-junit.xml + - report.html + expose_as: "pytest renderer results" + reports: + junit: + - report-junit.xml + # compare bit exactness between target and source branch ivas-pytest-on-merge-request: extends: - .test-job-linux-needs-testv-dir - - .rules-merge-request + - .rules-merge-request-to-float-pc stage: compare # note: this step doesn't really depend on codec-smoke-test # it's just pointless to run this step when the smoke test fails and the smoke test should be reasonably fast @@ -1968,7 +2175,7 @@ complexity-stereo-in-stereo-out: script: - in_format=stereo - out_format=stereo - - bash ci/complexity_measurements/getWmops.sh "$in_format" "$out_format" full basop || ret_val=$? + - bash ci/complexity_measurements/getWmops.sh "$in_format" "$out_format" full || ret_val=$? - *complexity-measurements-prepare-artifacts - exit $ret_val @@ -1983,7 +2190,7 @@ complexity-ism-in-binaural-out: - in_format=ISM - out_format=BINAURAL - ret_val=0 - - bash ci/complexity_measurements/getWmops.sh "ISM+1 ISM+2 ISM+3 ISM+4" "$out_format" full basop || ret_val=$? + - bash ci/complexity_measurements/getWmops.sh "ISM+1 ISM+2 ISM+3 ISM+4" "$out_format" full || ret_val=$? - *complexity-measurements-prepare-artifacts - exit $ret_val @@ -1998,7 +2205,7 @@ complexity-ism-in-binaural_room_ir-out: - in_format=ISM - out_format=BINAURAL_ROOM_IR - ret_val=0 - - bash ci/complexity_measurements/getWmops.sh "ISM+1 ISM+2 ISM+3 ISM+4" "$out_format" full basop || ret_val=$? + - bash ci/complexity_measurements/getWmops.sh "ISM+1 ISM+2 ISM+3 ISM+4" "$out_format" full || ret_val=$? - *complexity-measurements-prepare-artifacts - exit $ret_val @@ -2013,7 +2220,7 @@ complexity-ism-in-ext-out: - in_format=ISM - out_format=EXT - ret_val=0 - - bash ci/complexity_measurements/getWmops.sh "ISM+1 ISM+2 ISM+3 ISM+4" "$out_format" full basop || ret_val=$? + - bash ci/complexity_measurements/getWmops.sh "ISM+1 ISM+2 ISM+3 ISM+4" "$out_format" full || ret_val=$? - *complexity-measurements-prepare-artifacts - exit $ret_val @@ -2028,7 +2235,7 @@ complexity-sba-hoa3-in-hoa3-out: - in_format=HOA3 - out_format=HOA3 - ret_val=0 - - bash ci/complexity_measurements/getWmops.sh "$in_format" "$out_format" full basop || ret_val=$? + - bash ci/complexity_measurements/getWmops.sh "$in_format" "$out_format" full || ret_val=$? - *complexity-measurements-prepare-artifacts - exit $ret_val @@ -2043,7 +2250,7 @@ complexity-sba-hoa3-in-binaural-out: - in_format=HOA3 - out_format=BINAURAL - ret_val=0 - - bash ci/complexity_measurements/getWmops.sh "$in_format" "$out_format" full basop || ret_val=$? + - bash ci/complexity_measurements/getWmops.sh "$in_format" "$out_format" full || ret_val=$? - *complexity-measurements-prepare-artifacts - exit $ret_val @@ -2058,7 +2265,7 @@ complexity-sba-hoa3-in-binaural_room_ir-out: - in_format=HOA3 - out_format=BINAURAL_ROOM_IR - ret_val=0 - - bash ci/complexity_measurements/getWmops.sh "$in_format" "$out_format" full basop || ret_val=$? + - bash ci/complexity_measurements/getWmops.sh "$in_format" "$out_format" full || ret_val=$? - *complexity-measurements-prepare-artifacts - exit $ret_val @@ -2073,7 +2280,7 @@ complexity-mc-in-7_1_4-out: - in_format=MC - out_format=7_1_4 - ret_val=0 - - bash ci/complexity_measurements/getWmops.sh "$in_format" "$out_format" full basop || ret_val=$? + - bash ci/complexity_measurements/getWmops.sh "$in_format" "$out_format" full || ret_val=$? - *complexity-measurements-prepare-artifacts - exit $ret_val @@ -2088,7 +2295,7 @@ complexity-mc-in-binaural-out: - in_format=MC - out_format=BINAURAL - ret_val=0 - - bash ci/complexity_measurements/getWmops.sh "$in_format" "$out_format" full basop || ret_val=$? + - bash ci/complexity_measurements/getWmops.sh "$in_format" "$out_format" full || ret_val=$? - *complexity-measurements-prepare-artifacts - exit $ret_val @@ -2103,7 +2310,7 @@ complexity-mc-in-binaural_room_ir-out: - in_format=MC - out_format=BINAURAL_ROOM_IR - ret_val=0 - - bash ci/complexity_measurements/getWmops.sh "$in_format" "$out_format" full basop || ret_val=$? + - bash ci/complexity_measurements/getWmops.sh "$in_format" "$out_format" full || ret_val=$? - *complexity-measurements-prepare-artifacts - exit $ret_val @@ -2118,7 +2325,7 @@ complexity-masa-in-ext-out: - in_format=MASA - out_format=EXT - ret_val=0 - - bash ci/complexity_measurements/getWmops.sh "$in_format" "$out_format" full basop || ret_val=$? + - bash ci/complexity_measurements/getWmops.sh "$in_format" "$out_format" full || ret_val=$? - *complexity-measurements-prepare-artifacts - exit $ret_val @@ -2133,7 +2340,7 @@ complexity-masa-in-binaural-out: - in_format=MASA - out_format=BINAURAL - ret_val=0 - - bash ci/complexity_measurements/getWmops.sh "$in_format" "$out_format" full basop || ret_val=$? + - bash ci/complexity_measurements/getWmops.sh "$in_format" "$out_format" full || ret_val=$? - *complexity-measurements-prepare-artifacts - exit $ret_val @@ -2148,7 +2355,7 @@ complexity-masa-in-hoa3-out: - in_format=MASA - out_format=HOA3 - ret_val=0 - - bash ci/complexity_measurements/getWmops.sh "$in_format" "$out_format" full basop || ret_val=$? + - bash ci/complexity_measurements/getWmops.sh "$in_format" "$out_format" full || ret_val=$? - *complexity-measurements-prepare-artifacts - exit $ret_val @@ -2163,7 +2370,7 @@ complexity-masa-in-hoa3-out: # - in_format=OMASA # - out_format=EXT # - ret_val=0 -# - bash ci/complexity_measurements/getWmops.sh "$in_format" "$out_format" full basop || ret_val=$? +# - bash ci/complexity_measurements/getWmops.sh "$in_format" "$out_format" full || ret_val=$? # - *complexity-measurements-prepare-artifacts # - exit $ret_val @@ -2178,7 +2385,7 @@ complexity-omasa-in-binaural-out: - in_format=OMASA - out_format=BINAURAL - ret_val=0 - - bash ci/complexity_measurements/getWmops.sh "$in_format" "$out_format" full basop || ret_val=$? + - bash ci/complexity_measurements/getWmops.sh "$in_format" "$out_format" full || ret_val=$? - *complexity-measurements-prepare-artifacts - exit $ret_val @@ -2193,7 +2400,7 @@ complexity-omasa-in-hoa3-out: - in_format=OMASA - out_format=HOA3 - ret_val=0 - - bash ci/complexity_measurements/getWmops.sh "$in_format" "$out_format" full basop || ret_val=$? + - bash ci/complexity_measurements/getWmops.sh "$in_format" "$out_format" full || ret_val=$? - *complexity-measurements-prepare-artifacts - exit $ret_val @@ -2208,7 +2415,7 @@ complexity-StereoDmxEVS-stereo-in-mono-out: - in_format=StereoDmxEVS - out_format=mono - ret_val=0 - - bash ci/complexity_measurements/getWmops.sh "$in_format" "$out_format" full basop || ret_val=$? + - bash ci/complexity_measurements/getWmops.sh "$in_format" "$out_format" full || ret_val=$? - *complexity-measurements-prepare-artifacts - exit $ret_val diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..3e2d6972836490e1308c6a7ecbdc9386cf58c14f --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,221 @@ +# CMake file for IVAS +# +# Usage with Unix Makefiles (Linux, OS/X): +# # create build directory +# mkdir build ; cd build +# # call CMake to generate build system, e.g. one of the following: +# cmake -D CMAKE_BUILD_TYPE=Debug ../ +# cmake -D CMAKE_BUILD_TYPE=Release ../ +# cmake -D CMAKE_BUILD_TYPE=Debug -D TARGET_PLATFORM=x86_64 ../ +# # build project +# make -j8 +# +# Usage with Visual Studio +# 1) download CMake from https://cmake.org/download/, don't use the Cygwin version! +# 2.1) build project using IDE +# In CMake GUI select the source dir (root of stereo-evs) and a new binary directory +# and press "Configure" and "Generate". Then open the Visual Studio solution file generated +# in the build directory. +# 2.2) build project using command line +# # create build directory +# mkdir build ; cd build +# # call CMake to generate build system, e.g. one of the following: +# cmake ../ +# cmake -G "Visual Studio 12 2013" ../ +# cmake -G "Visual Studio 12 2013 Win64" ../ +# # open the Visual Studio solution file generated in the build directory +# # or build on command line, e.g.: +# cmake --build . --config Debug +# cmake --build . --config Release + + +cmake_minimum_required(VERSION 3.1) + +set(CMAKE_C_STANDARD 99) + +# configuration options for UNIX +if(UNIX) + set(TARGET_PLATFORM "" CACHE STRING "i686 / x86_64") + set(CLANG "" CACHE STRING "1=msan / 2=asan / 3=usan") + set(GCOV OFF CACHE BOOL "enable GCOV") + set(STRIP OFF CACHE BOOL "enable STRIP") + + if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "") + endif() + # TARGET_PLATFORM + if("${TARGET_PLATFORM}" MATCHES "i386" OR + "${TARGET_PLATFORM}" MATCHES "i586" OR + "${TARGET_PLATFORM}" MATCHES "i686" + ) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -m32") + elseif("${TARGET_PLATFORM}" MATCHES "x86_64") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m64") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -m64") + endif() + # C compiler flags + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ffp-contract=off") # disable floating point operation contraction + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pedantic -Wcast-qual -Wall -W -Wextra -Wno-long-long") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-parameter") + # to be uncommented in CI + # set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror") + + # CLANG + if(CLANG) + find_program(clangBin NAMES /home/amm-archiv/soft/Linux/clang/current/bin/clang clang REQUIRED) + set(CMAKE_C_COMPILER "${clangBin}" CACHE STRING "") + if("${CLANG}" MATCHES "1" OR "${CLANG}" MATCHES "msan") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=memory") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=memory") + elseif("${CLANG}" MATCHES "2" OR "${CLANG}" MATCHES "asan") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address") + elseif("${CLANG}" MATCHES "3" OR "${CLANG}" MATCHES "usan") + # NOTE: keep in sync with list in Makefile + set(USAN_CHECKS_ENABLE + undefined # Default checks + # Extra checks + float-divide-by-zero + implicit-conversion + local-bounds + ) + list(JOIN USAN_CHECKS_ENABLE "," USAN_CHECKS_ENABLE) + + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=${USAN_CHECKS_ENABLE} -fsanitize-recover=${USAN_CHECKS_ENABLE}") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=${USAN_CHECKS_ENABLE} -fsanitize-recover=${USAN_CHECKS_ENABLE}") + else() + message(FATAL_ERROR "Unknown CLANG setting: ${CLANG}") + endif() + endif() + # GCOV + if(GCOV) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-arcs -ftest-coverage -fprofile-update=atomic") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fprofile-arcs -ftest-coverage -fprofile-update=atomic") + endif() + # STRIP + if(STRIP) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fdata-sections -ffunction-sections") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-gc-sections -static") + endif() + + message("CMAKE_C_FLAGS: ${CMAKE_C_FLAGS}") + message("CMAKE_EXE_LINKER_FLAGS: ${CMAKE_EXE_LINKER_FLAGS}") + # write settings in CMake cache + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}" CACHE STRING "") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}" CACHE STRING "") + set(CMAKE_C_FLAGS_DEBUG "-O0 -g3" CACHE STRING "") + set(CMAKE_C_FLAGS_RELEASE "-O2 -DRELEASE" CACHE STRING "") # TODO should contain -DNDEBUG to disable assert() +elseif(WIN32) + # MSVC compiler flags + add_definitions( + -D_CRT_SECURE_NO_WARNINGS + /MP + ) +endif() + +# configuration options for all platforms +set(WMOPS OFF CACHE BOOL "enable WMOPS") +if(WMOPS) + add_definitions("-DWMOPS=1") +endif() + +project(stereo-evs) +set_property(GLOBAL PROPERTY USE_FOLDERS ON) # make Visual Studio projects look nicer +include(CTest) + +file(GLOB libComSrcs "lib_com/*.c") +file(GLOB libComHeaders "lib_com/*.h") +add_library(lib_com ${libComSrcs} ${libComHeaders}) +if(UNIX) + target_link_libraries(lib_com PRIVATE m) +endif() +target_include_directories(lib_com PUBLIC lib_com PRIVATE lib_enc lib_dec lib_rend lib_debug lib_isar) +target_include_directories(lib_com PRIVATE lib_lc3plus) + +file(GLOB libDebugSrcs "lib_debug/*.c") +file(GLOB libDebugHeaders "lib_debug/*.h") +add_library(lib_debug ${libDebugSrcs} ${libDebugHeaders}) +target_link_libraries(lib_debug lib_com) +target_include_directories(lib_debug PUBLIC lib_debug PRIVATE lib_enc lib_dec lib_rend lib_isar) + +file(GLOB libEncSrcs "lib_enc/*.c") +file(GLOB libEncHeaders "lib_enc/*.h") +add_library(lib_enc ${libEncSrcs} ${libEncHeaders}) +target_link_libraries(lib_enc lib_com lib_debug) +target_include_directories(lib_enc PUBLIC lib_enc PRIVATE lib_dec lib_rend lib_isar) +target_include_directories(lib_enc PRIVATE lib_lc3plus) + +file(GLOB libLC3plusSrcs "lib_lc3plus/*.c") +file(GLOB libLC3plusHeaders "lib_lc3plus/*.h") +add_library(lib_lc3plus ${libLC3plusSrcs} ${libLC3plusHeaders}) +target_include_directories(lib_lc3plus PUBLIC lib_lc3plus PRIVATE lib_com lib_debug) + +file(GLOB libRendSrcs "lib_rend/*.c") +file(GLOB libRendHeaders "lib_rend/*.h") + +add_library(lib_rend ${libRendSrcs} ${libRendHeaders}) +target_link_libraries(lib_rend lib_dec lib_com lib_debug) # Todo refactor: This dependency on lib_dec should be removed. +target_link_libraries(lib_rend lib_lc3plus lib_isar) +target_include_directories(lib_rend PUBLIC lib_rend PRIVATE lib_enc lib_isar) + + +file(GLOB libDecSrcs "lib_dec/*.c") +file(GLOB libDecHeaders "lib_dec/*.h") +add_library(lib_dec ${libDecSrcs} ${libDecHeaders}) +target_link_libraries(lib_dec lib_com lib_rend lib_debug lib_isar) +target_include_directories(lib_dec PUBLIC lib_dec lib_rend PRIVATE lib_enc lib_isar) + +file(GLOB libUtilSrcs "lib_util/*.c") +file(GLOB libUtilHeaders "lib_util/*.h") +add_library(lib_util ${libUtilSrcs} ${libUtilHeaders}) +target_include_directories(lib_util PUBLIC lib_util PRIVATE lib_com lib_enc lib_dec lib_rend lib_debug) +target_include_directories(lib_util PRIVATE lib_lc3plus lib_isar) + +if(NOT WMOPS) + add_executable(ivas_lc3plus_unit_test scripts/split_rendering/lc3plus_float/ivas_lc3plus_unit_test.c) + target_link_libraries(ivas_lc3plus_unit_test lib_rend lib_dec lib_util lib_com lib_debug lib_isar) +endif() + +file(GLOB libISARSrcs "lib_isar/*.c") +file(GLOB libISARHeaders "lib_isar/*.h") + +add_library(lib_isar ${libISARSrcs} ${libISARHeaders}) +target_link_libraries(lib_isar lib_com lib_debug lib_lc3plus) # Todo refactor: This dependency on lib_dec should be removed. +target_include_directories(lib_isar PUBLIC lib_isar PRIVATE lib_enc lib_dec lib_rend) + + +add_executable(IVAS_cod apps/encoder.c) +target_link_libraries(IVAS_cod lib_enc lib_util) +if(WIN32) + target_link_libraries(IVAS_cod Ws2_32) +endif() + +add_executable(IVAS_dec apps/decoder.c) +target_link_libraries(IVAS_dec lib_dec lib_util) +if(WIN32) + target_link_libraries(IVAS_dec Ws2_32) +endif() + +add_executable(IVAS_rend apps/renderer.c) +target_link_libraries(IVAS_rend lib_rend lib_util lib_isar) +target_include_directories(IVAS_rend PRIVATE lib_enc) + +add_executable(ISAR_post_rend apps/isar_post_rend.c) +target_link_libraries(ISAR_post_rend lib_isar lib_util) +target_include_directories(ISAR_post_rend PRIVATE lib_isar) + +if(COPY_EXECUTABLES_FROM_BUILD_DIR) + # Optionally copy executables to the same place where Make puts them (useful for tests that expect executables in specific places) + add_custom_command(TARGET IVAS_cod POST_BUILD VERBATIM COMMAND "${CMAKE_COMMAND}" -E copy "$" "${CMAKE_CURRENT_SOURCE_DIR}/") + add_custom_command(TARGET IVAS_dec POST_BUILD VERBATIM COMMAND "${CMAKE_COMMAND}" -E copy "$" "${CMAKE_CURRENT_SOURCE_DIR}/") + add_custom_command(TARGET IVAS_rend POST_BUILD VERBATIM COMMAND "${CMAKE_COMMAND}" -E copy "$" "${CMAKE_CURRENT_SOURCE_DIR}/") + add_custom_command(TARGET ISAR_post_rend POST_BUILD VERBATIM COMMAND "${CMAKE_COMMAND}" -E copy "$" "${CMAKE_CURRENT_SOURCE_DIR}/") + if (NOT WMOPS) + add_custom_command(TARGET ivas_lc3plus_unit_test POST_BUILD VERBATIM COMMAND "${CMAKE_COMMAND}" -E copy "$" "${CMAKE_CURRENT_SOURCE_DIR}/scripts/split_rendering/lc3plus_float") + endif() +endif() + +# Allow creating packages for CMake install +install(TARGETS lib_enc lib_dec lib_rend lib_com lib_util ARCHIVE DESTINATION lib) diff --git a/LICENSE.md b/LICENSE.md index aa9c35e4f9786f3321942cacb1f56d7d91840e20..ca74eaf483b6772614a49c5025aa865a357e063e 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/Makefile b/Makefile index bef5db44146bdc9983cafa6ff35ce6239827954f..63ac29842bb6109347cb23165b22538b037adb2d 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,3 @@ - # GNU Makefile # Paths @@ -7,23 +6,29 @@ SRC_LIBDEBUG = lib_debug SRC_LIBDEC = lib_dec SRC_LIBENC = lib_enc SRC_LIBREND = lib_rend +SRC_LIBISAR = lib_isar +SRC_LC3PLUS = lib_lc3plus lib_lc3plus/fft SRC_LIBUTIL = lib_util SRC_APP = apps BUILD = build OBJDIR = obj -SRC_DIRS = $(sort -u $(SRC_LIBCOM) $(SRC_LIBDEBUG) $(SRC_LIBDEC) $(SRC_LIBENC) $(SRC_LIBREND) $(SRC_LIBUTIL) $(SRC_APP)) +SRC_DIRS = $(sort -u $(SRC_LIBCOM) $(SRC_LIBDEBUG) $(SRC_LIBDEC) $(SRC_LIBENC) $(SRC_LIBREND) $(SRC_LIBISAR) $(SRC_LC3PLUS) $(SRC_LIBUTIL) $(SRC_APP)) # Name of CLI binaries -CLI_APIDEC ?= IVAS_dec -CLI_APIENC ?= IVAS_cod -CLI_APIREND ?= IVAS_rend -LIB_LIBCOM ?= libivascom.a -LIB_LIBDEBUG ?= libivasdebug.a -LIB_LIBDEC ?= libivasdec.a -LIB_LIBENC ?= libivasenc.a -LIB_LIBREND ?= libivasrend.a -LIB_LIBUTIL ?= libivasutil.a +CLI_APIDEC ?= IVAS_dec +CLI_APIENC ?= IVAS_cod +CLI_APIREND ?= IVAS_rend +CLI_APIPOSTREND ?= ISAR_post_rend +LIB_LIBCOM ?= libivascom.a +LIB_LIBDEBUG ?= libivasdebug.a +LIB_LIBDEC ?= libivasdec.a +LIB_LIBENC ?= libivasenc.a +LIB_LIBREND ?= libivasrend.a +LIB_LIBISAR ?= libisar.a +LIB_LC3PLUS ?= liblc3plus.a +LIB_LIBUTIL ?= libivasutil.a + # Default tool settings CC ?= gcc @@ -56,8 +61,9 @@ endif # C compiler flags CFLAGS += -std=c99 -pedantic -Wcast-qual -Wall -W -Wextra -Wno-long-long \ -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes \ - -Werror-implicit-function-declaration \ -Wno-implicit-fallthrough -ffp-contract=off +# to be uncommented in CI +# CFLAGS += -Werror # libs to link LDLIBS += -lm @@ -116,6 +122,15 @@ CFLAGS += $(foreach DIR,$(SRC_DIRS),-I$(DIR)) # Source file search paths VPATH = $(SRC_DIRS) +# Split rendering files +SRCS_SPLIT_REND = ivas_CQMFDecoder.c ivas_CQMFEncoder.c ivas_PerceptualModel.c ivas_PredDecoder.c \ + ivas_PredEncoder.c ivas_RMSEnvGrouping.c ivas_MSPred.c ivas_NoiseGen.c \ + ivas_splitRend_lcld_dec.c ivas_splitRend_lcld_enc.c \ + ivas_splitRendererPLC.c ivas_splitRendererPost.c ivas_splitRendererPre.c \ + ivas_splitRenderer_utils.c split_rend_bfi_file_reader.c split_render_file_read_write.c \ + ivas_lcld_tables.c + + ############################################################################### SRCS_LIBCOM = $(foreach DIR,$(SRC_LIBCOM),$(patsubst $(DIR)/%,%,$(wildcard $(DIR)/*.c))) @@ -124,25 +139,31 @@ SRCS_LIBDEC = $(foreach DIR,$(SRC_LIBDEC),$(patsubst $(DIR)/%,%,$(wildcard $(D SRCS_LIBENC = $(foreach DIR,$(SRC_LIBENC),$(patsubst $(DIR)/%,%,$(wildcard $(DIR)/*.c))) SRCS_LIBREND = $(foreach DIR,$(SRC_LIBREND),$(patsubst $(DIR)/%,%,$(wildcard $(DIR)/*.c))) SRCS_LIBUTIL = $(foreach DIR,$(SRC_LIBUTIL),$(patsubst $(DIR)/%,%,$(wildcard $(DIR)/*.c))) +SRCS_LIBISAR = $(foreach DIR,$(SRC_LIBISAR),$(patsubst $(DIR)/%,%,$(wildcard $(DIR)/*.c))) +SRCS_LC3PLUS = $(foreach DIR,$(SRC_LC3PLUS),$(patsubst $(DIR)/%,%,$(wildcard $(DIR)/*.c))) OBJS_LIBCOM = $(addprefix $(OBJDIR)/,$(SRCS_LIBCOM:.c=.o)) OBJS_LIBDEBUG = $(addprefix $(OBJDIR)/,$(SRCS_LIBDEBUG:.c=.o)) OBJS_LIBDEC = $(addprefix $(OBJDIR)/,$(SRCS_LIBDEC:.c=.o)) OBJS_LIBENC = $(addprefix $(OBJDIR)/,$(SRCS_LIBENC:.c=.o)) OBJS_LIBREND = $(addprefix $(OBJDIR)/,$(SRCS_LIBREND:.c=.o)) +OBJS_LIBISAR = $(addprefix $(OBJDIR)/,$(SRCS_LIBISAR:.c=.o)) +OBJS_LC3PLUS = $(addprefix $(OBJDIR)/,$(SRCS_LC3PLUS:.c=.o)) OBJS_LIBUTIL = $(addprefix $(OBJDIR)/,$(SRCS_LIBUTIL:.c=.o)) OBJS_CLI_APIDEC = $(OBJDIR)/decoder.o OBJS_CLI_APIENC = $(OBJDIR)/encoder.o OBJS_CLI_APPREND = $(OBJDIR)/renderer.o +OBJS_CLI_APPPOSTREND = $(OBJDIR)/isar_post_rend.o DEPS = $(addprefix $(OBJDIR)/,$(SRCS_LIBCOM:.c=.P) $(SRCS_LIBDEBUG:.c=.P) $(SRCS_LIBDEC:.c=.P) \ - $(SRCS_LIBENC:.c=.P) $(SRCS_LIBUTIL:.c=.P) $(SRCS_LIBREND:.c=.P)) + $(SRCS_LIBENC:.c=.P) $(SRCS_LIBUTIL:.c=.P) $(SRCS_LIBREND:.c=.P) $(SRCS_LIBISAR:.c=.P) \ + $(SRCS_LC3PLUS:.c=.P)) ############################################################################### .PHONY: all clean -all: $(CLI_APIENC) $(CLI_APIDEC) $(CLI_APIREND) +all: $(CLI_APIENC) $(CLI_APIDEC) $(CLI_APIREND) $(CLI_APIPOSTREND) $(OBJDIR): $(QUIET)mkdir -p $(OBJDIR) @@ -150,37 +171,46 @@ $(OBJDIR): $(LIB_LIBCOM): $(OBJS_LIBCOM) $(QUIET_AR)$(AR) rcs $@ $^ -$(LIB_LIBDEC): $(OBJS_LIBDEC) $(OBJS_LIBREND) +$(LIB_LIBDEC): $(OBJS_LIBDEC) $(OBJS_LIBREND) $(OBJS_LIBISAR) $(QUIET_AR)$(AR) rcs $@ $^ $(LIB_LIBDEBUG): $(OBJS_LIBDEBUG) $(QUIET_AR)$(AR) rcs $@ $^ +$(LIB_LIBISAR): $(OBJS_LIBISAR) + $(QUIET_AR)$(AR) rcs $@ $^ + $(LIB_LIBENC): $(OBJS_LIBENC) $(QUIET_AR)$(AR) rcs $@ $^ -$(LIB_LIBREND): $(OBJS_LIBREND) +$(LIB_LIBREND): $(OBJS_LIBREND) $(OBJS_LIBISAR) + $(QUIET_AR)$(AR) rcs $@ $^ + +$(LIB_LC3PLUS): $(OBJS_LC3PLUS) $(QUIET_AR)$(AR) rcs $@ $^ $(LIB_LIBUTIL): $(OBJS_LIBUTIL) $(QUIET_AR)$(AR) rcs $@ $^ -$(CLI_APIENC): $(OBJS_CLI_APIENC) $(LIB_LIBENC) $(LIB_LIBCOM) $(LIB_LIBUTIL) $(LIB_LIBDEBUG) +$(CLI_APIENC): $(OBJS_CLI_APIENC) $(LIB_LIBENC) $(LIB_LIBCOM) $(LIB_LIBUTIL) $(LIB_LIBDEBUG) $(LIB_LC3PLUS) $(QUIET_LINK)$(CC) $(LDFLAGS) $(OBJS_CLI_APIENC) -L. -livasenc -livascom -livasutil -livasdebug $(LDLIBS) -o $(CLI_APIENC) -$(CLI_APIDEC): $(OBJS_CLI_APIDEC) $(LIB_LIBDEC) $(LIB_LIBCOM) $(LIB_LIBUTIL) $(LIB_LIBDEBUG) - $(QUIET_LINK)$(CC) $(LDFLAGS) $(OBJS_CLI_APIDEC) -L. -livasdec -livascom -livasutil -livasdebug $(LDLIBS) -o $(CLI_APIDEC) +$(CLI_APIDEC): $(OBJS_CLI_APIDEC) $(LIB_LIBDEC) $(LIB_LIBCOM) $(LIB_LIBUTIL) $(LIB_LIBDEBUG) $(LIB_LC3PLUS) $(LIB_LIBISAR) + $(QUIET_LINK)$(CC) $(LDFLAGS) $(OBJS_CLI_APIDEC) -L. -livasdec -livascom -livasutil -livasdebug -llc3plus $(LDLIBS) -o $(CLI_APIDEC) + +$(CLI_APIREND): $(OBJS_CLI_APPREND) $(LIB_LIBREND) $(LIB_LIBCOM) $(LIB_LIBUTIL) $(LIB_LIBDEBUG) $(LIB_LIBDEC) $(LIB_LC3PLUS) $(LIB_LIBISAR) + $(QUIET_LINK)$(CC) $(LDFLAGS) $(OBJS_CLI_APPREND) -L. -livasrend -lisar -livasdec -livasutil -livasdebug -livascom -llc3plus $(LDLIBS) -o $(CLI_APIREND) -$(CLI_APIREND): $(OBJS_CLI_APPREND) $(LIB_LIBREND) $(LIB_LIBCOM) $(LIB_LIBUTIL) $(LIB_LIBDEBUG) $(LIB_LIBDEC) - $(QUIET_LINK)$(CC) $(LDFLAGS) $(OBJS_CLI_APPREND) -L. -livasrend -livasdec -livasutil -livasdebug -livascom $(LDLIBS) -o $(CLI_APIREND) +$(CLI_APIPOSTREND): $(OBJS_CLI_APPPOSTREND) $(LIB_LIBISAR) $(LIB_LIBCOM) $(LIB_LIBUTIL) $(LIB_LIBDEBUG) $(LIB_LC3PLUS) + $(QUIET_LINK)$(CC) $(LDFLAGS) $(OBJS_CLI_APPPOSTREND) -L. -lisar -livasutil -livasdebug -livascom -llc3plus $(LDLIBS) -o $(CLI_APIPOSTREND) -libs: $(LIB_LIBENC) $(LIB_LIBDEBUG) $(LIB_LIBCOM) $(LIB_LIBDEC) $(LIB_LIBREND) $(LIB_LIBUTIL) +libs: $(LIB_LIBENC) $(LIB_LIBDEBUG) $(LIB_LIBCOM) $(LIB_LIBDEC) $(LIB_LIBREND) $(LIB_LIBISAR) $(LIB_LC3PLUS) $(LIB_LIBUTIL) clean: $(QUIET)$(RM) $(OBJS_LIBENC) $(OBJS_LIBDEC) $(DEPS) $(QUIET)$(RM) $(DEPS:.P=.d) $(QUIET)test ! -d $(OBJDIR) || rm -rf $(OBJDIR) - $(QUIET)$(RM) $(CLI_APIENC) $(CLI_APIDEC) $(CLI_APIREND) $(LIB_LIBENC) $(LIB_LIBDEBUG) $(LIB_LIBCOM) $(LIB_LIBDEC) $(LIB_LIBUTIL) $(LIB_LIBREND) + $(QUIET)$(RM) $(CLI_APIENC) $(CLI_APIDEC) $(CLI_APIREND) $(CLI_APIPOSTREND) $(LIB_LIBENC) $(LIB_LIBDEBUG) $(LIB_LIBCOM) $(LIB_LIBDEC) $(LIB_LIBUTIL) $(LIB_LIBREND) $(LIB_LIBISAR) $(LIB_LC3PLUS) $(OBJDIR)/%.o : %.c | $(OBJDIR) $(QUIET_CC)$(CC) $(CFLAGS) -c -MD -o $@ $< diff --git a/Workspace_msvc/Workspace_msvc.sln b/Workspace_msvc/Workspace_msvc.sln index a0783ddbf435ddeb6f09907e51620302fac68237..ac2e76b52f0224eefb2fb6c56cbd2a41be66812c 100644 --- a/Workspace_msvc/Workspace_msvc.sln +++ b/Workspace_msvc/Workspace_msvc.sln @@ -20,11 +20,17 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "encoder", "encoder.vcxproj" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "renderer", "renderer.vcxproj", "{12B4C8A5-1E06-4E30-B443-D1F916F52B47}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lib_lc3plus", "lib_lc3plus.vcxproj", "{95030B82-70CD-4C6B-84D4-61096035BEA2}" +EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{51160D4C-55C9-4C16-A792-D94507225746}" ProjectSection(SolutionItems) = preProject ..\.clang-format = ..\.clang-format EndProjectSection EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lib_isar", "lib_isar.vcxproj", "{869A305E-D99E-4C3A-BDB3-AA57ABCCE619}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "isar_post_rend", "isar_post_rend.vcxproj", "{12374ADC-0E5C-4FDD-B903-71D572413831}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -93,6 +99,18 @@ Global {95030B82-70CD-4C6B-84D4-61096035BEA2}.Release|Win32.ActiveCfg = Release|Win32 {95030B82-70CD-4C6B-84D4-61096035BEA2}.Release|Win32.Build.0 = Release|Win32 {95030B82-70CD-4C6B-84D4-61096035BEA2}.Release|x64.ActiveCfg = Release|Win32 + {869A305E-D99E-4C3A-BDB3-AA57ABCCE619}.Debug|Win32.ActiveCfg = Debug|Win32 + {869A305E-D99E-4C3A-BDB3-AA57ABCCE619}.Debug|Win32.Build.0 = Debug|Win32 + {869A305E-D99E-4C3A-BDB3-AA57ABCCE619}.Debug|x64.ActiveCfg = Debug|Win32 + {869A305E-D99E-4C3A-BDB3-AA57ABCCE619}.Release|Win32.ActiveCfg = Release|Win32 + {869A305E-D99E-4C3A-BDB3-AA57ABCCE619}.Release|Win32.Build.0 = Release|Win32 + {869A305E-D99E-4C3A-BDB3-AA57ABCCE619}.Release|x64.ActiveCfg = Release|Win32 + {12374ADC-0E5C-4FDD-B903-71D572413831}.Debug|Win32.ActiveCfg = Debug|Win32 + {12374ADC-0E5C-4FDD-B903-71D572413831}.Debug|Win32.Build.0 = Debug|Win32 + {12374ADC-0E5C-4FDD-B903-71D572413831}.Debug|x64.ActiveCfg = Debug|Win32 + {12374ADC-0E5C-4FDD-B903-71D572413831}.Release|Win32.ActiveCfg = Release|Win32 + {12374ADC-0E5C-4FDD-B903-71D572413831}.Release|Win32.Build.0 = Release|Win32 + {12374ADC-0E5C-4FDD-B903-71D572413831}.Release|x64.ActiveCfg = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Workspace_msvc/decoder.vcxproj b/Workspace_msvc/decoder.vcxproj index e59992847c71b085235a5232aad1afa7d710d17f..648f01e825991e67574540307da58a2884ee2e5c 100644 --- a/Workspace_msvc/decoder.vcxproj +++ b/Workspace_msvc/decoder.vcxproj @@ -68,7 +68,7 @@ Disabled - ..\lib_dec;..\lib_com;..\lib_util;..\lib_debug;%(AdditionalIncludeDirectories) + ..\lib_dec;..\lib_com;..\lib_util;..\lib_debug;..\lib_isar;%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;WIN32;$(Macros);%(PreprocessorDefinitions) EnableFastChecks @@ -112,7 +112,7 @@ Neither false false - ..\lib_dec;..\lib_com;..\lib_util;..\lib_debug;%(AdditionalIncludeDirectories) + ..\lib_dec;..\lib_com;..\lib_util;..\lib_debug;..\lib_isar;%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;$(Macros);%(PreprocessorDefinitions) true @@ -155,6 +155,9 @@ {e822ddaf-0f5f-4cd0-a694-38ae69de74d3} false + + {869a305e-d99e-4c3a-bdb3-aa57abcce619} + {2fa8f384-0775-f3b7-f8c3-85209222fc70} false diff --git a/Workspace_msvc/isar_post_rend.vcxproj b/Workspace_msvc/isar_post_rend.vcxproj new file mode 100644 index 0000000000000000000000000000000000000000..170ff20545a4ac5c7d610daac49ba963ad4d88b4 --- /dev/null +++ b/Workspace_msvc/isar_post_rend.vcxproj @@ -0,0 +1,177 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + isar_post_rend + {12374ADC-0E5C-4FDD-B903-71D572413831} + isar_post_rend + 10.0.17763.0 + + + + Application + v141 + false + MultiByte + + + Application + v141 + false + MultiByte + + + + + + + + + + + + + + + <_ProjectFileVersion>15.0.27428.2015 + + + ..\ + .\Debug_$(ProjectName)\ + false + false + ISAR_post_rend + + + ..\ + .\Release_$(ProjectName)\ + false + false + ISAR_post_rend + + + + $(IntDir)$(ProjectName).tlb + + + + Disabled + ..\lib_com;..\lib_debug;..\lib_util;..\lib_isar;..\lib_lc3plus;%(AdditionalIncludeDirectories) + _CRT_SECURE_NO_WARNINGS;WIN32;$(Macros);%(PreprocessorDefinitions) + + EnableFastChecks + MultiThreadedDebug + false + + + $(IntDir)$(ProjectName).pdb + Level4 + true + OldStyle + Default + %(DisableSpecificWarnings) + false + + + _DEBUG;%(PreprocessorDefinitions) + 0x0c0c + + + + $(OutDir)$(TargetName).exe + true + + true + $(IntDir)$(ProjectName).pdb + Console + false + + MachineX86 + + + + + $(IntDir)$(ProjectName).tlb + + + + MaxSpeed + AnySuitable + false + Neither + false + false + ..\lib_com;..\lib_debug;..\lib_util;..\lib_isar;..\lib_lc3plus;%(AdditionalIncludeDirectories) + _CRT_SECURE_NO_WARNINGS;$(Macros);%(PreprocessorDefinitions) + true + + Default + MultiThreaded + true + Precise + false + + + $(IntDir)$(ProjectName).pdb + Level4 + true + + Default + %(DisableSpecificWarnings) + false + + + NDEBUG;%(PreprocessorDefinitions) + 0x0c0c + + + $(OutDir)$(TargetName).exe + true + + false + $(IntDir)$(ProjectName).pdb + Console + false + + MachineX86 + libcmtd.lib + + + + + + + + {54509728-928B-44D9-A118-A6F92F08B34F} + false + + + {869a305e-d99e-4c3a-bdb3-aa57abcce619} + + + {2FA8F384-0775-F3B7-F8C3-85209222FC70} + false + + + {39ec200d-7795-4ff8-b214-b24eda5526ae} + false + + + + + + + + + + + \ No newline at end of file diff --git a/Workspace_msvc/lib_com.vcxproj b/Workspace_msvc/lib_com.vcxproj index 0c5d4dcca148e611dcc785870de328d75de0f883..9eb1af512e5af4a474e88a0acc1b45ceaa8cf22f 100644 --- a/Workspace_msvc/lib_com.vcxproj +++ b/Workspace_msvc/lib_com.vcxproj @@ -59,7 +59,7 @@ Disabled - ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;.%(AdditionalIncludeDirectories) + ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;..\lib_isar;..\lib_lc3plus;%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;$(Macros);WIN32;%(PreprocessorDefinitions) EnableFastChecks @@ -94,7 +94,7 @@ Neither false false - ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;.%(AdditionalIncludeDirectories) + ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_isar;..\lib_rend;..\lib_lc3plus;%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;$(Macros);%(PreprocessorDefinitions) true @@ -219,6 +219,8 @@ + + diff --git a/Workspace_msvc/lib_dec.vcxproj b/Workspace_msvc/lib_dec.vcxproj index 0266955ab03aaa249114eb68e33e92abcd3a028f..59758d289656a5485c8e286232ad91dd68731289 100644 --- a/Workspace_msvc/lib_dec.vcxproj +++ b/Workspace_msvc/lib_dec.vcxproj @@ -68,7 +68,7 @@ Disabled - ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;.%(AdditionalIncludeDirectories) + ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_isar;..\lib_rend;..\lib_lc3plus;%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;$(Macros);WIN32;%(PreprocessorDefinitions) EnableFastChecks @@ -108,7 +108,7 @@ Neither false false - ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;.%(AdditionalIncludeDirectories) + ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_isar;..\lib_rend;..\lib_lc3plus;%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;$(Macros);WIN32;%(PreprocessorDefinitions) true diff --git a/Workspace_msvc/lib_enc.vcxproj b/Workspace_msvc/lib_enc.vcxproj index e2db02d61cba7d8946f927a8e97cbe8797bef5b8..c5ddc83be90e01b89265b99ada165eaa93878d71 100644 --- a/Workspace_msvc/lib_enc.vcxproj +++ b/Workspace_msvc/lib_enc.vcxproj @@ -68,7 +68,7 @@ Disabled - ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;.%(AdditionalIncludeDirectories) + ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;..\lib_isar;..\lib_lc3plus;%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;$(Macros);WIN32;%(PreprocessorDefinitions) EnableFastChecks @@ -111,7 +111,7 @@ Neither false false - ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;.%(AdditionalIncludeDirectories) + ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;..\lib_isar;..\lib_lc3plus;%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;$(Macros);%(PreprocessorDefinitions) true diff --git a/Workspace_msvc/lib_isar.vcxproj b/Workspace_msvc/lib_isar.vcxproj new file mode 100644 index 0000000000000000000000000000000000000000..fceeb731ced2445a5434805d422d30654718782a --- /dev/null +++ b/Workspace_msvc/lib_isar.vcxproj @@ -0,0 +1,200 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + lib_isar + {869A305E-D99E-4C3A-BDB3-AA57ABCCE619} + evs_dec + 10.0.17763.0 + + + StaticLibrary + v141 + false + MultiByte + + + + StaticLibrary + v141 + false + MultiByte + + + + + + + + + + + + + + + <_ProjectFileVersion>15.0.27428.2015 + + + .\Debug_$(ProjectName)\ + .\Debug_$(ProjectName)\ + false + false + libivasrend + + + .\Release_$(ProjectName)\ + .\Release_$(ProjectName)\ + false + false + libivasrend + + + + + + + .\Debug\$(ProjectName).tlb + + + + Disabled + ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;..\lib_isar;..\lib_lc3plus;%(AdditionalIncludeDirectories) + _CRT_SECURE_NO_WARNINGS;$(Macros);WIN32;%(PreprocessorDefinitions) + + EnableFastChecks + MultiThreadedDebug + false + + + $(IntDir)$(ProjectName).pdb + Level4 + true + OldStyle + Default + %(DisableSpecificWarnings) + false + + + _DEBUG;%(PreprocessorDefinitions) + 0x0c0c + + + WS2_32.lib; %(AdditionalDependencies) + $(OutDir)$(TargetName).lib + true + + + + + + + + $(IntDir)$(ProjectName).tlb + + + + MaxSpeed + AnySuitable + false + Neither + false + false + ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;..\lib_isar;..\lib_lc3plus;%(AdditionalIncludeDirectories) + _CRT_SECURE_NO_WARNINGS;$(Macros);WIN32;%(PreprocessorDefinitions) + true + + Default + MultiThreaded + true + false + + + $(IntDir)$(ProjectName).pdb + Level4 + true + + Default + %(DisableSpecificWarnings) + false + + + NDEBUG;%(PreprocessorDefinitions) + 0x0c0c + + + WS2_32.lib; %(AdditionalDependencies) + $(OutDir)$(TargetName).lib + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {39ec200d-7795-4ff8-b214-b24eda5526ae} + false + + + {54509728-928b-44d9-a118-a6f92f08b34f} + false + + + {95030B82-70CD-4C6B-84D4-61096035BEA2} + false + + + + + + + + + + + diff --git a/Workspace_msvc/lib_lc3plus.vcxproj b/Workspace_msvc/lib_lc3plus.vcxproj new file mode 100644 index 0000000000000000000000000000000000000000..eb2a91d36d82a5c4e5b6e59875c7ace8ea8d03db --- /dev/null +++ b/Workspace_msvc/lib_lc3plus.vcxproj @@ -0,0 +1,183 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {95030B82-70CD-4C6B-84D4-61096035BEA2} + Win32Proj + LC3_FL + 10.0.17763.0 + + + + StaticLibrary + true + v141 + Unicode + + + StaticLibrary + false + v141 + true + Unicode + + + + + + + + + + + + + + + liblc3plus + .\Debug_$(ProjectName)\ + .\Debug_$(ProjectName)\ + + + LC3plus + $(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\Obj\ + + + + + + Level3 + ..\lib_com;..\lib_debug;%(AdditionalIncludeDirectories) + Disabled + MultiThreadedDebug + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + 4305;4244;4996 + OldStyle + false + + + Console + true + + + + + Level3 + + + ..\lib_com;..\lib_debug;%(AdditionalIncludeDirectories) + MaxSpeed + MultiThreaded + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + 4244;4305;4996 + + + Console + true + true + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Workspace_msvc/lib_rend.vcxproj b/Workspace_msvc/lib_rend.vcxproj index ee40123a861f97fced652d22109eb10b3238a185..3e90febe0af0b948205db451ec9982faa9b2f760 100644 --- a/Workspace_msvc/lib_rend.vcxproj +++ b/Workspace_msvc/lib_rend.vcxproj @@ -68,7 +68,7 @@ Disabled - ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;.%(AdditionalIncludeDirectories) + ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_isar;..\lib_lc3plus;%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;$(Macros);WIN32;%(PreprocessorDefinitions) EnableFastChecks @@ -108,7 +108,7 @@ Neither false false - ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;.%(AdditionalIncludeDirectories) + ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_isar;..\lib_lc3plus;%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;$(Macros);WIN32;%(PreprocessorDefinitions) true @@ -147,7 +147,6 @@ - @@ -195,6 +194,10 @@ {54509728-928b-44d9-a118-a6f92f08b34f} false + + {95030B82-70CD-4C6B-84D4-61096035BEA2} + false + diff --git a/Workspace_msvc/lib_util.vcxproj b/Workspace_msvc/lib_util.vcxproj index 6696ee00a8f723137553a0491a1e7842a7bfa965..190ed5026cf32b6bc5d078b60d9c7e9bd20eacbd 100644 --- a/Workspace_msvc/lib_util.vcxproj +++ b/Workspace_msvc/lib_util.vcxproj @@ -55,7 +55,7 @@ Disabled - ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;..\lib_util;.%(AdditionalIncludeDirectories) + ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_isar;..\lib_rend;..\lib_util;..\lib_lc3plus;%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;$(Macros);ZLIB_WINAPI;%(PreprocessorDefinitions) false @@ -78,7 +78,7 @@ AnySuitable false false - ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;..\lib_util;.%(AdditionalIncludeDirectories) + ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_isar;..\lib_rend;..\lib_util;..\lib_lc3plus;%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;$(Macros);ZLIB_WINAPI;%(PreprocessorDefinitions) true @@ -119,6 +119,9 @@ + + + @@ -142,8 +145,11 @@ + + + diff --git a/Workspace_msvc/renderer.vcxproj b/Workspace_msvc/renderer.vcxproj index c62874ec0afbfb789e4d8814ab3938b3e33f3410..324c7137373149d204f2c5395efe6111b56554e0 100644 --- a/Workspace_msvc/renderer.vcxproj +++ b/Workspace_msvc/renderer.vcxproj @@ -65,7 +65,7 @@ Disabled - ..\lib_com;..\lib_debug;..\lib_util;..\lib_rend;.%(AdditionalIncludeDirectories) + ..\lib_com;..\lib_debug;..\lib_util;..\lib_isar;..\lib_rend;..\lib_lc3plus;%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;WIN32;$(Macros);%(PreprocessorDefinitions) EnableFastChecks @@ -109,7 +109,7 @@ Neither false false - ..\lib_com;..\lib_debug;..\lib_util;..\lib_rend;.%(AdditionalIncludeDirectories) + ..\lib_com;..\lib_debug;..\lib_util;..\lib_isar;..\lib_rend;..\lib_lc3plus;%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;$(Macros);%(PreprocessorDefinitions) true @@ -156,6 +156,9 @@ {E822DDAF-0F5F-4CD0-A694-38AE69DE74D3} false + + {869a305e-d99e-4c3a-bdb3-aa57abcce619} + {2FA8F384-0775-F3B7-F8C3-85209222FC70} false diff --git a/apps/decoder.c b/apps/decoder.c index 08d4f7a5317f8a9d27dda9308c3e12c3344891de..bd95ddd597671f2de8a1e636d77f5b8ff04f8eba 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other @@ -43,6 +43,9 @@ #include "masa_file_writer.h" #include "render_config_reader.h" #include "rotation_file_reader.h" +#ifdef SPLIT_REND_WITH_HEAD_ROT +#include "split_render_file_read_write.h" +#endif #ifdef VARIABLE_SPEED_DECODING #include "tsm_scale_file_reader.h" #include @@ -121,6 +124,9 @@ typedef struct float non_diegetic_pan_gain; bool renderConfigEnabled; char *renderConfigFilename; +#ifdef SPLIT_REND_WITH_HEAD_ROT + char *outputMdFilename; +#endif IVAS_DEC_COMPLEXITY_LEVEL complexityLevel; bool tsmEnabled; IVAS_RENDER_FRAMESIZE renderFramesize; @@ -148,7 +154,11 @@ typedef struct static bool parseCmdlIVAS_dec( int16_t argc, char **argv, DecArguments *arg ); static void usage_dec( void ); +#ifdef SPLIT_REND_WITH_HEAD_ROT +static ivas_error decodeG192( DecArguments arg, BS_READER_HANDLE hBsReader, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, ISAR_SPLIT_REND_BITS_DATA *splitRendBits, IVAS_DEC_HANDLE hIvasDec, int16_t *pcmBuf ); +#else static ivas_error decodeG192( DecArguments arg, BS_READER_HANDLE hBsReader, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, IVAS_DEC_HANDLE hIvasDec, int16_t *pcmBuf ); +#endif static ivas_error decodeVoIP( DecArguments arg, BS_READER_HANDLE hBsReader, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, IVAS_DEC_HANDLE hIvasDec ); #ifdef DEBUGGING @@ -170,6 +180,10 @@ int main( bool mainFailed = true; /* Assume main failed until cleanup is reached without errors */ DecArguments arg; ivas_error error = IVAS_ERR_UNKNOWN; +#ifdef SPLIT_REND_WITH_HEAD_ROT + ISAR_SPLIT_REND_BITS_DATA splitRendBits; + uint8_t splitRendBitsBuf[ISAR_MAX_SPLIT_REND_BITS_BUFFER_SIZE_IN_BYTES]; +#endif /* Any handles that require cleanup must be declared here and initialized to NULL */ IVAS_DEC_HANDLE hIvasDec = NULL; @@ -199,6 +213,10 @@ int main( reset_mem( USE_BYTES ); #endif +#ifdef SPLIT_REND_WITH_HEAD_ROT + splitRendBits.bits_buf = splitRendBitsBuf; +#endif + /*------------------------------------------------------------------------------------------* * Parse command-line arguments *------------------------------------------------------------------------------------------*/ @@ -245,6 +263,18 @@ int main( } } +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) + { + fprintf( stdout, "Output metadata file: %s\n", arg.outputWavFilename ); + } + else if ( arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + { + fprintf( stdout, "Output synthesis file: %s\n", arg.outputWavFilename ); + fprintf( stdout, "Output metadata file: %s\n", arg.outputMdFilename ); + } + else +#endif { fprintf( stdout, "Output synthesis file: %s\n", arg.outputWavFilename ); } @@ -278,7 +308,11 @@ int main( if ( arg.enableHeadRotation ) { /* sanity check */ - if ( arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) + if ( arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB +#ifdef SPLIT_REND_WITH_HEAD_ROT + && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM +#endif + ) { fprintf( stderr, "\nError: Head-rotation file file cannot be used in this output configuration.\n\n" ); goto cleanup; @@ -378,7 +412,12 @@ int main( if ( arg.renderConfigEnabled ) { /* sanity check */ - if ( arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) + if ( arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB +#ifdef SPLIT_REND_WITH_HEAD_ROT + && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM && + arg.Opt_non_diegetic_pan == 0 +#endif + ) { fprintf( stderr, "\nError: Renderer configuration file cannot be used in this output configuration.\n\n" ); goto cleanup; @@ -414,10 +453,29 @@ int main( fprintf( stderr, "\nChanged render framesize, only 20ms are allowed for decoding to EXT!\n" ); } +#ifdef SPLIT_REND_WITH_HEAD_ROT /*------------------------------------------------------------------------------------------* * Configure Split rendering *------------------------------------------------------------------------------------------*/ + asked_frame_size = arg.renderFramesize; + if ( arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + { + if ( ( error = IVAS_DEC_EnableSplitRendering( hIvasDec ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nConfigure failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; + } + + if ( ( error = IVAS_DEC_GetRenderFramesize( hIvasDec, &arg.renderFramesize ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nConfigure failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; + } + + arg.enableHeadRotation = true; + } +#endif /*------------------------------------------------------------------------------------------* * Configure VoIP mode @@ -546,11 +604,21 @@ int main( IVAS_RENDER_CONFIG_DATA renderConfig; /* sanity check */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB && + arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM && + arg.Opt_non_diegetic_pan == 0 ) + { + fprintf( stderr, "\nExternal Renderer Config is supported only when binaural output configurations is used as output OR when Split rendering mode is enabled. Exiting. \n" ); + goto cleanup; + } +#else if ( arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) { fprintf( stderr, "\nExternal Renderer Config is supported only for binaural output configurations. Exiting. \n\n" ); goto cleanup; } +#endif if ( ( error = IVAS_DEC_GetRenderConfig( hIvasDec, &renderConfig ) ) != IVAS_ERR_OK ) { @@ -558,7 +626,6 @@ int main( goto cleanup; } - if ( RenderConfigReader_read( renderConfigReader, arg.renderConfigFilename, &renderConfig ) != IVAS_ERR_OK ) { fprintf( stderr, "Failed to read renderer configuration from file %s\n\n", arg.renderConfigFilename ); @@ -570,6 +637,32 @@ int main( fprintf( stderr, "Failed to get directivity patterns for one or more of IDs: %d %d %d %d\n\n", arg.directivityPatternId[0], arg.directivityPatternId[1], arg.directivityPatternId[2], arg.directivityPatternId[3] ); goto cleanup; } +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || + arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + { + if ( asked_frame_size != IVAS_RENDER_FRAMESIZE_20MS && + ( renderConfig.split_rend_config.poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE || + renderConfig.split_rend_config.dof == 0 ) ) + { + arg.renderFramesize = asked_frame_size; + } + else + { + arg.renderFramesize = IVAS_RENDER_FRAMESIZE_20MS; + } + + if ( ( error = IVAS_DEC_SetRenderFramesize( hIvasDec, arg.renderFramesize ) ) != IVAS_ERR_OK ) + { + return error; + } + + if ( arg.renderFramesize != asked_frame_size ) + { + fprintf( stderr, "\nChanged render framesize, only 20ms are allowed for non-0dof split rendering!\n" ); + } + } +#endif if ( arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) { @@ -588,6 +681,13 @@ int main( } renderConfig.roomAcoustics.override = true; } +#ifdef SPLIT_REND_WITH_HEAD_ROT +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + /* ISAR frame size is set from command line, not renderer config file. + * This will be ignored if output format is not split rendering. */ + renderConfig.split_rend_config.isar_frame_size_ms = (int16_t) arg.renderFramesize /* given in number of 5ms subframes */ * 5; +#endif +#endif if ( ( error = IVAS_DEC_FeedRenderConfig( hIvasDec, renderConfig ) ) != IVAS_ERR_OK ) { @@ -701,7 +801,11 @@ int main( } else { +#ifdef SPLIT_REND_WITH_HEAD_ROT + error = decodeG192( arg, hBsReader, headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, &splitRendBits, hIvasDec, pcmBuf ); +#else error = decodeG192( arg, hBsReader, headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, hIvasDec, pcmBuf ); +#endif } if ( error == IVAS_ERR_OK || error == IVAS_ERR_END_OF_FILE ) @@ -854,6 +958,16 @@ static IVAS_AUDIO_CONFIG cmdline2config( { output_config = IVAS_AUDIO_CONFIG_BINAURAL; } +#ifdef SPLIT_REND_WITH_HEAD_ROT + else if ( strcmp( argv_to_upper, "BINAURAL_SPLIT_CODED" ) == 0 ) + { + output_config = IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED; + } + else if ( strcmp( argv_to_upper, "BINAURAL_SPLIT_PCM" ) == 0 ) + { + output_config = IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM; + } +#endif else if ( strcmp( argv_to_upper, "BINAURAL_ROOM_IR" ) == 0 ) { output_config = IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR; @@ -929,6 +1043,9 @@ static bool parseCmdlIVAS_dec( arg->renderConfigFilename = NULL; arg->Opt_dpid_on = 0; +#ifdef SPLIT_REND_WITH_HEAD_ROT + arg->outputMdFilename = NULL; +#endif arg->inputFormat = IVAS_DEC_INPUT_FORMAT_G192; arg->Opt_non_diegetic_pan = 0; @@ -1252,6 +1369,19 @@ static bool parseCmdlIVAS_dec( } i += 2; } +#ifdef SPLIT_REND_WITH_HEAD_ROT + else if ( strcmp( argv_to_upper, "-OM" ) == 0 ) + { + arg->outputMdFilename = argv[i + 1]; + if ( arg->outputMdFilename[0] == '\0' ) + { + fprintf( stderr, "Error: output metadata file path not specified\n\n" ); + usage_dec(); + return false; + } + i += 2; + } +#endif else if ( strcmp( argv_to_upper, "-NON_DIEGETIC_PAN" ) == 0 ) { i++; @@ -1393,6 +1523,14 @@ static bool parseCmdlIVAS_dec( usage_dec(); return false; } +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( arg->outputMdFilename != NULL && arg->outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + { + fprintf( stderr, "Error: Output split rendering metadata file is supported for BINAURAL_SPLIT_PCM output config. only\n\n" ); + usage_dec(); + return false; + } +#endif } else { @@ -1469,8 +1607,13 @@ static void usage_dec( void ) fprintf( stdout, "Mandatory parameters:\n" ); fprintf( stdout, "---------------------\n" ); +#ifdef SPLIT_REND_WITH_HEAD_ROT + fprintf( stdout, "OutputConf : Output configuration: MONO, STEREO, 5_1, 7_1, 5_1_2, 5_1_4, 7_1_4, FOA,\n" ); + fprintf( stdout, " HOA2, HOA3, BINAURAL, BINAURAL_ROOM_IR, BINAURAL_ROOM_REVERB, BINAURAL_SPLIT_CODED, BINAURAL_SPLIT_PCM, EXT\n" ); +#else fprintf( stdout, "OutputConf : Output configuration: MONO, STEREO, 5_1, 7_1, 5_1_2, 5_1_4, 7_1_4, FOA,\n" ); fprintf( stdout, " HOA2, HOA3, BINAURAL, BINAURAL_ROOM_IR, BINAURAL_ROOM_REVERB, EXT\n" ); +#endif fprintf( stdout, " By default, channel order and loudspeaker positions are equal to the\n" ); fprintf( stdout, " encoder. For loudspeaker outputs, OutputConf can be a custom loudspeaker\n" ); fprintf( stdout, " layout file. See readme.txt for details.\n" ); @@ -1516,6 +1659,9 @@ static void usage_dec( void ) fprintf( stdout, "-rvf File : Reference vector specified by external trajectory File\n" ); fprintf( stdout, " works only in combination with '-otr ref_vec' and 'ref_vec_lev' modes\n" ); fprintf( stdout, "-render_config File : Renderer configuration File\n" ); +#ifdef SPLIT_REND_WITH_HEAD_ROT + fprintf( stdout, "-om File : Metadata output File for BINAURAL_SPLIT_PCM OutputConf (only for Fs = 48 kHz)\n" ); +#endif fprintf( stdout, "-non_diegetic_pan P : panning mono non-diegetic sound to stereo with paning P, -90<= P <=90,\n" ); fprintf( stdout, " left or l or 90->left, right or r or -90->right, center or c or 0->middle\n" ); #ifdef DEBUGGING @@ -1570,10 +1716,15 @@ static int16_t app_own_random( int16_t *seed ) *---------------------------------------------------------------------*/ static ivas_error initOnFirstGoodFrame( - IVAS_DEC_HANDLE hIvasDec, /* i/o: */ - const DecArguments arg, /* i : */ - const int16_t numInitialBadFrames, /* i : */ - const uint16_t numOutSamples, /* i : */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: */ + const DecArguments arg, /* i : */ + const int16_t numInitialBadFrames, /* i : */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + int16_t *numOutSamples, /* i/o: */ + int16_t *vec_pos_len, /* i/o: */ +#else + const uint16_t numOutSamples, /* i : */ +#endif int16_t *pFullDelayNumSamples, /* o : */ int16_t *pRemainingDelayNumSamples, /* o : */ int32_t *delayTimeScale, /* o : */ @@ -1582,7 +1733,12 @@ static ivas_error initOnFirstGoodFrame( MasaFileWriter **ppMasaWriter, /* o : */ IsmFileWriter *ismWriters[IVAS_MAX_NUM_OBJECTS], /* o : */ int16_t *pNumOutChannels, /* o : */ - uint16_t *pNumObj /* o : */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + uint16_t *pNumObj, /* o : */ + SplitFileReadWrite **splitRendWriter +#else + uint16_t *pNumObj /* o : */ +#endif ) { ivas_error error = IVAS_ERR_UNKNOWN; @@ -1594,6 +1750,12 @@ static ivas_error initOnFirstGoodFrame( return error; } +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( IVAS_DEC_is_split_rendering_enabled( hIvasDec ) ) + { + pFullDelayNumSamples[0] = 0; + } +#endif if ( !arg.delayCompensationEnabled ) { @@ -1615,32 +1777,166 @@ static ivas_error initOnFirstGoodFrame( return error; } - /* Open audio writer and write all previously skipped bad frames now that frame size is known */ - if ( ( error = AudioFileWriter_open( ppAfWriter, arg.outputWavFilename, arg.output_Fs, *pNumOutChannels ) ) != IVAS_ERR_OK ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( IVAS_DEC_is_split_rendering_enabled( hIvasDec ) ) { - fprintf( stderr, "\nUnable to open output file %s\n", arg.outputWavFilename ); - return error; + /* Open split rendering metadata writer */ + int16_t delayNumSamples_temp[3]; + int32_t delayTimeScale_temp; + ISAR_SPLIT_REND_CODEC splitRendCodec; + int16_t splitRendCodecFrameSizeMs; + ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrection; +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + int16_t splitRendIsarFrameSizeMs; + int16_t lc3plusHighRes; +#endif + + if ( ( error = IVAS_DEC_GetDelay( hIvasDec, delayNumSamples_temp, &delayTimeScale_temp ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nUnable to get delay of decoder: %s\n", ivas_error_to_string( error ) ); + return error; + } + + if ( ( error = IVAS_DEC_GetSplitRendBitstreamHeader( hIvasDec, + &splitRendCodec, + &poseCorrection, +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + &splitRendIsarFrameSizeMs, +#endif + &splitRendCodecFrameSizeMs +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + , + &lc3plusHighRes +#endif + ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nUnable to get split renderer bitstream header: %s\n", ivas_error_to_string( error ) ); + return error; + } + + if ( IVAS_DEC_is_split_rendering_coded_out( hIvasDec ) ) + { + if ( ( error = split_rend_writer_open( splitRendWriter, + arg.outputWavFilename, + delayNumSamples_temp[0], + delayTimeScale_temp, + splitRendCodec, + poseCorrection, + splitRendCodecFrameSizeMs +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + , + splitRendIsarFrameSizeMs, + arg.output_Fs, + lc3plusHighRes +#endif + ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nUnable to open output split rendering metadata file %s\n", arg.outputWavFilename ); + return error; + } + } + else + { + if ( arg.outputMdFilename == NULL ) + { + fprintf( stderr, "\nOutput split rendering metadata file not specified\n" ); + return IVAS_ERR_INVALID_SPLIT_REND_CONFIG; + } + + if ( ( error = split_rend_writer_open( splitRendWriter, + arg.outputMdFilename, + delayNumSamples_temp[0], + delayTimeScale_temp, + splitRendCodec, + poseCorrection, + splitRendCodecFrameSizeMs +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + , + splitRendIsarFrameSizeMs, + arg.output_Fs, + lc3plusHighRes +#endif + ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nUnable to open output split rendering metadata file %s\n", arg.outputWavFilename ); + return error; + } + } } + if ( IVAS_DEC_is_split_rendering_coded_out( hIvasDec ) == 0 ) + { +#endif + /* Open audio writer and write all previously skipped bad frames now that frame size is known */ + if ( ( error = AudioFileWriter_open( ppAfWriter, arg.outputWavFilename, arg.output_Fs, *pNumOutChannels ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nUnable to open output file %s\n", arg.outputWavFilename ); + return error; + } +#ifdef SPLIT_REND_WITH_HEAD_ROT + } +#endif + int16_t *zeroBuf = malloc( pcmFrameSize * sizeof( int16_t ) ); memset( zeroBuf, 0, pcmFrameSize * sizeof( int16_t ) ); for ( int16_t i = 0; i < numInitialBadFrames; ++i ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( *splitRendWriter != NULL ) + { + ISAR_SPLIT_REND_BITS_DATA splitRendBitsZero; + splitRendBitsZero.bits_buf = NULL; + splitRendBitsZero.bits_read = 0; + splitRendBitsZero.bits_written = 0; + splitRendBitsZero.buf_len = 0; + splitRendBitsZero.codec = ISAR_SPLIT_REND_CODEC_DEFAULT; + splitRendBitsZero.pose_correction = ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE; +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + splitRendBitsZero.codec_frame_size_ms = 0; + splitRendBitsZero.isar_frame_size_ms = 20; +#else + splitRendBitsZero.codec_frame_size_ms = 20; +#endif - if ( *pRemainingDelayNumSamples < numOutSamples ) - { - if ( ( error = AudioFileWriter_write( *ppAfWriter, zeroBuf, numOutSamples * *pNumOutChannels - ( *pRemainingDelayNumSamples * *pNumOutChannels ) ) ) != IVAS_ERR_OK ) + if ( split_rend_write_bitstream_to_file( *splitRendWriter, splitRendBitsZero.bits_buf, &splitRendBitsZero.bits_read, &splitRendBitsZero.bits_written ) != IVAS_ERR_OK ) { - fprintf( stderr, "\nOutput audio file writer error\n" ); + fprintf( stderr, "\nUnable to write to bitstream file!\n" ); return error; } - *pRemainingDelayNumSamples = 0; } else { +#endif + +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( *pRemainingDelayNumSamples < *numOutSamples ) +#else + if ( *pRemainingDelayNumSamples < numOutSamples ) +#endif + { +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( error = AudioFileWriter_write( *ppAfWriter, zeroBuf, *numOutSamples * *pNumOutChannels - ( *pRemainingDelayNumSamples * *pNumOutChannels ) ) ) != IVAS_ERR_OK ) +#else + if ( ( error = AudioFileWriter_write( *ppAfWriter, zeroBuf, numOutSamples * *pNumOutChannels - ( *pRemainingDelayNumSamples * *pNumOutChannels ) ) ) != IVAS_ERR_OK ) +#endif + { + fprintf( stderr, "\nOutput audio file writer error\n" ); + return error; + } + *pRemainingDelayNumSamples = 0; + } + else + { +#ifdef SPLIT_REND_WITH_HEAD_ROT + *pRemainingDelayNumSamples -= *numOutSamples; +#else *pRemainingDelayNumSamples -= numOutSamples; +#endif + } +#ifdef SPLIT_REND_WITH_HEAD_ROT } +#endif } free( zeroBuf ); @@ -1707,6 +2003,7 @@ static ivas_error initOnFirstGoodFrame( { /* Duplicate good first frame metadata to fill the beginning of stream. */ IVAS_MASA_DECODER_EXT_OUT_META_HANDLE hMasaExtOutMeta = NULL; + if ( ( error = IVAS_DEC_GetMasaMetadata( hIvasDec, &hMasaExtOutMeta, 0 ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError in IVAS_DEC_GetMasaMetadata: %s\n", IVAS_DEC_GetErrorMessage( error ) ); @@ -1725,6 +2022,27 @@ static ivas_error initOnFirstGoodFrame( } } +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( *splitRendWriter != NULL ) + { + if ( numOutSamples == NULL || vec_pos_len == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + /* real setting of the 5ms mode for split rendering is only known after the decoded first good frame, reset the variables needed in the main decoding loop accordingly here*/ + if ( ( error = IVAS_DEC_GetRenderFramesizeSamples( hIvasDec, numOutSamples ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError getting render frame size in samples\n" ); + return error; + } + if ( ( error = IVAS_DEC_GetReferencesUpdateFrequency( hIvasDec, vec_pos_len ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError getting render frame size in samples\n" ); + return error; + } + } +#endif return IVAS_ERR_OK; } @@ -1743,6 +2061,9 @@ static ivas_error decodeG192( RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, +#ifdef SPLIT_REND_WITH_HEAD_ROT + ISAR_SPLIT_REND_BITS_DATA *splitRendBits, +#endif IVAS_DEC_HANDLE hIvasDec, int16_t *pcmBuf ) @@ -1778,6 +2099,9 @@ static ivas_error decodeG192( IsmFileWriter *ismWriters[IVAS_MAX_NUM_OBJECTS]; IVAS_VECTOR3 Pos[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES] = { { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 } }; int16_t vec_pos_update, vec_pos_len; +#ifdef SPLIT_REND_WITH_HEAD_ROT + SplitFileReadWrite *splitRendWriter = NULL; +#endif for ( i = 0; i < IVAS_MAX_NUM_OBJECTS; ++i ) { @@ -1912,18 +2236,42 @@ static ivas_error decodeG192( { IVAS_QUATERNION Quaternions[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES]; - for ( i = 0; i < num_subframes; i++ ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( headRotReader == NULL ) { - if ( ( error = HeadRotationFileReading( headRotReader, &Quaternions[i], &Pos[i] ) ) != IVAS_ERR_OK ) + for ( i = 0; i < num_subframes; i++ ) { - fprintf( stderr, "\nError %s while reading head orientation from %s\n", IVAS_DEC_GetErrorMessage( error ), RotationFileReader_getFilePath( headRotReader ) ); - goto cleanup; + Quaternions[i].w = -3.0f; + Quaternions[i].x = 0.0f; + Quaternions[i].y = 0.0f; + Quaternions[i].z = 0.0f; + Pos[i].x = 0.0f; + Pos[i].y = 0.0f; + Pos[i].z = 0.0f; } } + else + { +#endif + for ( i = 0; i < num_subframes; i++ ) + { + if ( ( error = HeadRotationFileReading( headRotReader, &Quaternions[i], &Pos[i] ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError %s while reading head orientation from %s\n", IVAS_DEC_GetErrorMessage( error ), RotationFileReader_getFilePath( headRotReader ) ); + goto cleanup; + } + } +#ifdef SPLIT_REND_WITH_HEAD_ROT + } +#endif for ( i = 0; i < num_subframes; i++ ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( error = IVAS_DEC_FeedHeadTrackData( hIvasDec, Quaternions[i], Pos[i], i, DEFAULT_AXIS ) ) != IVAS_ERR_OK ) +#else if ( ( error = IVAS_DEC_FeedHeadTrackData( hIvasDec, Quaternions[i], Pos[i], i ) ) != IVAS_ERR_OK ) +#endif { fprintf( stderr, "\nIVAS_DEC_FeedHeadTrackData failed: %s\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; @@ -2017,14 +2365,35 @@ static ivas_error decodeG192( } } - if ( ( error = IVAS_DEC_GetSamples( hIvasDec, nSamplesToRender, ( pcmBuf + nOutChannels * nSamplesRendered ), &nSamplesRendered_loop, &needNewFrame ) ) != IVAS_ERR_OK ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( IVAS_DEC_is_split_rendering_enabled( hIvasDec ) ) + { + if ( ( error = IVAS_DEC_GetSplitBinauralBitstream( hIvasDec, (void *) ( pcmBuf + nOutChannels * nSamplesRendered ), splitRendBits, &nSamplesRendered_loop, &needNewFrame ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError in IVAS_DEC_GetSplitBinauralBitstream: %s\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; + } + nSamplesRendered += nSamplesRendered_loop; + nSamplesToRender -= nSamplesRendered_loop; + } + else { - fprintf( stderr, "\nError in IVAS_DEC_GetSamples: %s\n", IVAS_DEC_GetErrorMessage( error ) ); - goto cleanup; +#endif +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( error = IVAS_DEC_GetSamples( hIvasDec, nSamplesToRender, IVAS_DEC_PCM_INT16, (void *) ( pcmBuf + nOutChannels * nSamplesRendered ), &nSamplesRendered_loop, &needNewFrame ) ) != IVAS_ERR_OK ) +#else + if ( ( error = IVAS_DEC_GetSamples( hIvasDec, nSamplesToRender, ( pcmBuf + nOutChannels * nSamplesRendered ), &nSamplesRendered_loop, &needNewFrame ) ) != IVAS_ERR_OK ) +#endif + { + fprintf( stderr, "\nError in IVAS_DEC_GetSamples: %s\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; + } + nSamplesRendered += nSamplesRendered_loop; + nSamplesToRender -= nSamplesRendered_loop; +#ifdef SPLIT_REND_WITH_HEAD_ROT } - nSamplesRendered += nSamplesRendered_loop; - nSamplesToRender -= nSamplesRendered_loop; +#endif if ( needNewFrame ) { frame++; @@ -2039,7 +2408,6 @@ static ivas_error decodeG192( #endif } } - } while ( nSamplesRendered < nOutSamples && error == IVAS_ERR_OK ); if ( error == IVAS_ERR_END_OF_FILE ) @@ -2059,7 +2427,11 @@ static ivas_error decodeG192( /* Once good frame decoded, catch up */ if ( decodedGoodFrame ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( error = initOnFirstGoodFrame( hIvasDec, arg, numInitialBadFrames, &nOutSamples, &vec_pos_len, delayNumSamples_orig, &delayNumSamples, &delayTimeScale, &bsFormat, &afWriter, &masaWriter, ismWriters, &nOutChannels, &numObj, &splitRendWriter ) ) != IVAS_ERR_OK ) +#else if ( ( error = initOnFirstGoodFrame( hIvasDec, arg, numInitialBadFrames, nOutSamples, delayNumSamples_orig, &delayNumSamples, &delayTimeScale, &bsFormat, &afWriter, &masaWriter, ismWriters, &nOutChannels, &numObj ) ) != IVAS_ERR_OK ) +#endif { goto cleanup; } @@ -2073,21 +2445,38 @@ static ivas_error decodeG192( /* Write current frame */ if ( decodedGoodFrame ) { - if ( delayNumSamples < nOutSamples ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( IVAS_DEC_is_split_rendering_enabled( hIvasDec ) ) { - if ( ( error = AudioFileWriter_write( afWriter, &pcmBuf[delayNumSamples * nOutChannels], nOutSamples * nOutChannels - ( delayNumSamples * nOutChannels ) ) ) != IVAS_ERR_OK ) + if ( split_rend_write_bitstream_to_file( splitRendWriter, splitRendBits->bits_buf, &splitRendBits->bits_read, &splitRendBits->bits_written ) != IVAS_ERR_OK ) { - fprintf( stderr, "\nOutput audio file writer error\n" ); + fprintf( stderr, "\nUnable to write to bitstream file!\n" ); goto cleanup; } - delayNumSamples = 0; } - else + + if ( IVAS_DEC_is_split_rendering_coded_out( hIvasDec ) == 0 ) { - delayNumSamples -= nOutSamples; +#endif + if ( delayNumSamples < nOutSamples ) + { + if ( ( error = AudioFileWriter_write( afWriter, &pcmBuf[delayNumSamples * nOutChannels], nOutSamples * nOutChannels - ( delayNumSamples * nOutChannels ) ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nOutput audio file writer error\n" ); + goto cleanup; + } + delayNumSamples = 0; + } + else + { + delayNumSamples -= nOutSamples; + } +#ifdef SPLIT_REND_WITH_HEAD_ROT } +#endif } + /* Write ISm metadata to external file(s) */ if ( decodedGoodFrame && arg.outputConfig == IVAS_AUDIO_CONFIG_EXTERNAL ) { @@ -2200,7 +2589,11 @@ static ivas_error decodeG192( goto cleanup; } +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( error = IVAS_DEC_FeedHeadTrackData( hIvasDec, Quaternion, Pos[0], 0, DEFAULT_AXIS ) ) != IVAS_ERR_OK ) +#else if ( ( error = IVAS_DEC_FeedHeadTrackData( hIvasDec, Quaternion, Pos[0], 0 ) ) != IVAS_ERR_OK ) +#endif { fprintf( stderr, "\nIVAS_DEC_FeedHeadTrackData failed: %s\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; @@ -2208,7 +2601,11 @@ static ivas_error decodeG192( } /* decode and get samples */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( error = IVAS_DEC_Flush( hIvasDec, nOutSamples, IVAS_DEC_PCM_INT16, (void *) pcmBuf, &nSamplesFlushed ) ) != IVAS_ERR_OK ) +#else if ( ( error = IVAS_DEC_Flush( hIvasDec, nOutSamples, pcmBuf, &nSamplesFlushed ) ) != IVAS_ERR_OK ) +#endif { fprintf( stderr, "\nError in IVAS_DEC_VoIP_Flush: %s\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; @@ -2318,11 +2715,18 @@ static ivas_error decodeG192( *------------------------------------------------------------------------------------------*/ memset( pcmBuf, 0, delayNumSamples_orig[0] * nOutChannels * sizeof( int16_t ) ); - if ( ( error = AudioFileWriter_write( afWriter, pcmBuf, delayNumSamples_orig[0] * nOutChannels ) ) != IVAS_ERR_OK ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( afWriter != NULL ) { - fprintf( stderr, "\nError writing output file: %s\n", ivas_error_to_string( error ) ); - goto cleanup; +#endif + if ( ( error = AudioFileWriter_write( afWriter, pcmBuf, delayNumSamples_orig[0] * nOutChannels ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError writing output file: %s\n", ivas_error_to_string( error ) ); + goto cleanup; + } +#ifdef SPLIT_REND_WITH_HEAD_ROT } +#endif /*------------------------------------------------------------------------------------------* * Close files and deallocate resources @@ -2332,6 +2736,9 @@ static ivas_error decodeG192( cleanup: +#ifdef SPLIT_REND_WITH_HEAD_ROT + split_rend_reader_writer_close( &splitRendWriter ); +#endif AudioFileWriter_close( &afWriter ); MasaFileWriter_close( &masaWriter ); #ifdef DEBUGGING @@ -2683,19 +3090,44 @@ static ivas_error decodeVoIP( { IVAS_QUATERNION Quaternions[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES]; - for ( i = 0; i < num_subframes; i++ ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( headRotReader == NULL ) { - if ( ( error = HeadRotationFileReading( headRotReader, &Quaternions[i], &Pos[i] ) ) != IVAS_ERR_OK ) + for ( i = 0; i < num_subframes; i++ ) { - fprintf( stderr, "\nError %s while reading head orientation from %s\n", IVAS_DEC_GetErrorMessage( error ), - RotationFileReader_getFilePath( headRotReader ) ); - goto cleanup; + Quaternions[i].w = -3.0f; + Quaternions[i].x = 0.0f; + Quaternions[i].y = 0.0f; + Quaternions[i].z = 0.0f; + Pos[i].x = 0.0f; + Pos[i].y = 0.0f; + Pos[i].z = 0.0f; } } + else + { +#endif + for ( i = 0; i < num_subframes; i++ ) + { + if ( ( error = HeadRotationFileReading( headRotReader, &Quaternions[i], &Pos[i] ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError %s while reading head orientation from %s\n", IVAS_DEC_GetErrorMessage( error ), + RotationFileReader_getFilePath( headRotReader ) ); + goto cleanup; + } + } +#ifdef SPLIT_REND_WITH_HEAD_ROT + } +#endif for ( i = 0; i < num_subframes; i++ ) { - if ( ( error = IVAS_DEC_FeedHeadTrackData( hIvasDec, Quaternions[i], Pos[i], i ) ) != IVAS_ERR_OK ) + if ( ( error = IVAS_DEC_FeedHeadTrackData( hIvasDec, Quaternions[i], Pos[i], i +#ifdef SPLIT_REND_WITH_HEAD_ROT + , + DEFAULT_AXIS +#endif + ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nIVAS_DEC_FeedHeadTrackData failed: %s\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; @@ -2783,10 +3215,18 @@ static ivas_error decodeVoIP( /* decode and get samples */ +#ifdef SPLIT_REND_WITH_HEAD_ROT +#ifdef SUPPORT_JBM_TRACEFILE + if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, IVAS_DEC_PCM_INT16, (void *) pcmBuf, systemTime_ms, writeJbmTraceFileFrameWrapper, jbmTraceWriter ) ) != IVAS_ERR_OK ) +#else + if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, IVAS_DEC_PCM_INT16, (void *) pcmBuf, systemTime_ms ) ) != IVAS_ERR_OK ) +#endif +#else #ifdef SUPPORT_JBM_TRACEFILE if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, pcmBuf, systemTime_ms, writeJbmTraceFileFrameWrapper, jbmTraceWriter ) ) != IVAS_ERR_OK ) #else if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, pcmBuf, systemTime_ms ) ) != IVAS_ERR_OK ) +#endif #endif { fprintf( stderr, "\nError in IVAS_DEC_VoIP_GetSamples: %s\n", IVAS_DEC_GetErrorMessage( error ) ); @@ -2823,8 +3263,15 @@ static ivas_error decodeVoIP( /* Once good frame decoded, catch up */ if ( decodedGoodFrame ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT + SplitFileReadWrite *splitRendWriter = NULL; + + if ( ( error = initOnFirstGoodFrame( hIvasDec, arg, numInitialBadFrames, &nOutSamples, NULL, delayNumSamples_orig, &delayNumSamples, &delayTimeScale, + &bsFormat, &afWriter, &masaWriter, ismWriters, &nOutChannels, &numObj, &splitRendWriter ) ) != IVAS_ERR_OK ) +#else if ( ( error = initOnFirstGoodFrame( hIvasDec, arg, numInitialBadFrames, nOutSamples, delayNumSamples_orig, &delayNumSamples, &delayTimeScale, &bsFormat, &afWriter, &masaWriter, ismWriters, &nOutChannels, &numObj ) ) != IVAS_ERR_OK ) +#endif { goto cleanup; } diff --git a/apps/encoder.c b/apps/encoder.c index 037cf903b229fb9326e9c81c7495c00790338d58..ec69fd443dd5a3e8026ee90b87ec1fa018b2ffa9 100644 --- a/apps/encoder.c +++ b/apps/encoder.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other @@ -43,6 +43,19 @@ #endif #include "wmc_auto.h" +#ifdef DEBUG_FORCE_DIR +/* Windows does not define the S_ISREG and S_ISDIR macros in stat.h, so we do. + We have to define _CRT_INTERNAL_NONSTDC_NAMES 1 before #including sys/stat.h + in order for Microsoft's stat.h to define names like S_IFMT, S_IFREG, and S_IFDIR, + rather than just defining _S_IFMT, _S_IFREG, and _S_IFDIR as it normally does. */ +#include +#if !defined( S_ISREG ) && defined( S_IFMT ) && defined( S_IFREG ) +#define S_ISREG( m ) ( ( (m) &S_IFMT ) == S_IFREG ) +#endif +#if !defined( S_ISDIR ) && defined( S_IFMT ) && defined( S_IFDIR ) +#define S_ISDIR( m ) ( ( (m) &S_IFMT ) == S_IFDIR ) +#endif +#endif #define WMC_TOOL_SKIP @@ -134,6 +147,9 @@ typedef struct #ifdef DEBUGGING IVAS_ENC_FORCED_MODE forcedMode; const char *forcedModeFile; +#ifdef DEBUG_FORCE_DIR + const char *forcedModeDir; +#endif #ifdef DEBUG_AGC_ENCODER_CMD_OPTION IVAS_ENC_AGC agc; #endif @@ -719,7 +735,12 @@ int main( /* Force mode not set when configuring, set in first frame even if not reading from file */ if ( f_forcedModeProfile || frame == 0 ) { - if ( ( error = IVAS_ENC_SetForcedMode( hIvasEnc, forcedMode ) ) != IVAS_ERR_OK ) + if ( ( error = IVAS_ENC_SetForcedMode( hIvasEnc, forcedMode +#ifdef DEBUG_FORCE_DIR + , + arg.forcedModeDir +#endif + ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nIVAS_ENC_SetForcedMode failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) ); goto cleanup; @@ -908,6 +929,9 @@ static void initArgStruct( EncArguments *arg ) #ifdef DEBUGGING arg->forcedMode = IVAS_ENC_FORCE_UNFORCED; arg->forcedModeFile = NULL; +#ifdef DEBUG_FORCE_DIR + arg->forcedModeDir = NULL; +#endif #ifdef DEBUG_AGC_ENCODER_CMD_OPTION arg->agc = IVAS_ENC_AGC_UNDEFINED; #endif @@ -1058,6 +1082,28 @@ static bool parseCmdlIVAS_enc( arg->forcedMode = parseForcedMode( stmp ); +#ifdef DEBUG_FORCE_DIR + if ( arg->forcedMode < IVAS_ENC_FORCE_FILE ) + { + fprintf( stdout, "Forcing codec to: %s\n", argv[i + 1] ); + } + else if ( arg->forcedMode == IVAS_ENC_FORCE_FILE ) + { + arg->forcedModeFile = argv[i + 1]; + fprintf( stdout, "Force switching file: %s\n", argv[i + 1] ); + } + else if ( arg->forcedMode == IVAS_ENC_FORCE_DIR ) + { + arg->forcedModeDir = argv[i + 1]; + fprintf( stdout, "Forcing switching directory: %s\n", argv[i + 1] ); + } + else + { + fprintf( stderr, "\nError: The force switching profile file/dir %s does not exist or could not be opened!\n\n", argv[i + 1] ); + usage_enc(); + return false; + } +#else if ( arg->forcedMode == IVAS_ENC_FORCE_UNDEFINED ) { arg->forcedModeFile = argv[i + 1]; @@ -1084,6 +1130,7 @@ static bool parseCmdlIVAS_enc( fprintf( stdout, "Forcing codec to: %s\n", argv[i + 1] ); #endif } +#endif i += 2; } @@ -1923,6 +1970,9 @@ static void usage_enc( void ) #ifdef DEBUGGING fprintf( stdout, "-force T : Force specific mode, T = (speech, music, ACELP, GSC, TCX, HQ),\n" ); fprintf( stdout, " alternatively, T can be a text file where each line contains \"nb_frames T\"\n" ); +#ifdef DEBUG_FORCE_DIR + fprintf( stdout, " or T can be a directory containing external binary files for modes/parameters enforcement\n" ); +#endif #ifdef DEBUG_SBA fprintf( stdout, "-tag : Tag name for intermediate debug files\n" ); #endif @@ -2040,8 +2090,73 @@ static bool readBitrate( static IVAS_ENC_FORCED_MODE parseForcedMode( char *forcedModeChar ) { +#ifdef DEBUG_FORCE_DIR + struct stat path_stat; +#endif + to_upper( forcedModeChar ); +#ifdef DEBUG_FORCE_DIR + if ( ( strcmp( forcedModeChar, "SPEECH" ) == 0 ) || ( strcmp( forcedModeChar, "'SPEECH'" ) == 0 ) || + ( strcmp( forcedModeChar, "0" ) == 0 ) ) + { + return IVAS_ENC_FORCE_SPEECH; + } + else if ( ( strcmp( forcedModeChar, "MUSIC" ) == 0 ) || ( strcmp( forcedModeChar, "'MUSIC'" ) == 0 ) || ( strcmp( forcedModeChar, "AUDIO" ) == 0 ) || ( strcmp( forcedModeChar, "'AUDIO'" ) == 0 ) || ( strcmp( forcedModeChar, "1" ) == 0 ) ) + { + return IVAS_ENC_FORCE_MUSIC; + } + else if ( ( strcmp( forcedModeChar, "ACELP" ) == 0 ) || ( strcmp( forcedModeChar, "'ACELP'" ) == 0 ) ) + { + return IVAS_ENC_FORCE_ACELP; + } + else if ( ( strcmp( forcedModeChar, "GSC" ) == 0 ) || ( strcmp( forcedModeChar, "'GSC'" ) == 0 ) ) + { + return IVAS_ENC_FORCE_GSC; + } + if ( ( strcmp( forcedModeChar, "TCX" ) == 0 ) || ( strcmp( forcedModeChar, "'TCX'" ) == 0 ) +#ifdef SUPPORT_FORCE_TCX10_TCX20 + || ( strcmp( forcedModeChar, "TCX20" ) == 0 ) || ( strcmp( forcedModeChar, "'TCX20'" ) == 0 ) +#endif + ) + { +#ifdef SUPPORT_FORCE_TCX10_TCX20 + return IVAS_ENC_FORCE_TCX20; +#else + return IVAS_ENC_FORCE_TCX; +#endif + } +#ifdef SUPPORT_FORCE_TCX10_TCX20 + if ( ( strcmp( forcedModeChar, "TCX10" ) == 0 ) || ( strcmp( forcedModeChar, "'TCX10'" ) == 0 ) ) + { + return IVAS_ENC_FORCE_TCX10; + } +#endif + else if ( ( strcmp( forcedModeChar, "HQ" ) == 0 ) || ( strcmp( forcedModeChar, "'HQ'" ) == 0 ) ) + { + return IVAS_ENC_FORCE_HQ; + } + else + { + if ( stat( forcedModeChar, &path_stat ) != 0 ) + { + return IVAS_ENC_FORCE_UNDEFINED; + } + + /* check if the argument represents an existing file or directory */ + if ( S_ISDIR( path_stat.st_mode ) ) + { + /* it's a directory */ + return IVAS_ENC_FORCE_DIR; + } + else + { + /* it's a file */ + return IVAS_ENC_FORCE_FILE; + } + } + +#else if ( ( strcmp( forcedModeChar, "SPEECH" ) == 0 ) || ( strcmp( forcedModeChar, "'SPEECH'" ) == 0 ) || ( strcmp( forcedModeChar, "0" ) == 0 ) ) { @@ -2083,6 +2198,7 @@ static IVAS_ENC_FORCED_MODE parseForcedMode( } return IVAS_ENC_FORCE_UNDEFINED; +#endif } diff --git a/apps/isar_post_rend.c b/apps/isar_post_rend.c new file mode 100644 index 0000000000000000000000000000000000000000..210b8933c6762824a6a8417befabf63e0cd5871b --- /dev/null +++ b/apps/isar_post_rend.c @@ -0,0 +1,1253 @@ +/****************************************************************************************************** + + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#include "lib_isar_post_rend.h" + +#ifndef SPLIT_REND_WITH_HEAD_ROT + +int main( int argc, char **argv ) +{ + (void) argc; + (void) argv; + ISAR_POST_REND_void_func(); + return 0; +} + +#else + +#include +#include +#include +#include "audio_file_reader.h" +#include "audio_file_writer.h" +#include "cmdl_tools.h" +#include "cmdln_parser.h" +#include "render_config_reader.h" +#include "rotation_file_reader.h" +#include "split_render_file_read_write.h" +#include "split_rend_bfi_file_reader.h" +#ifdef DEBUGGING +#include "debug.h" +#endif +#include "wmc_auto.h" + + +#define WMC_TOOL_SKIP + +/*------------------------------------------------------------------------------------------* + * Local constants + *------------------------------------------------------------------------------------------*/ + +#define POST_REND_MAX_CLI_ARG_LENGTH ( FILENAME_MAX ) + +#define ISAR_MAX16B_FLT 32767.0f +#define ISAR_MIN16B_FLT ( -32768.0f ) + +#if !defined( DEBUGGING ) && !defined( WMOPS ) +static +#endif + int32_t frame = 0; + +#ifdef _WIN32 +#define SEP_FOLDER '\\' +#else +#define SEP_FOLDER '/' +#endif + +/*------------------------------------------------------------------------------------------* + * Local structures + *------------------------------------------------------------------------------------------*/ + +typedef struct +{ + IVAS_AUDIO_CONFIG audioConfig; + int32_t inputChannelIndex; + float gain_dB; +} RendererInput; + +typedef struct +{ + RendererInput binBuses[RENDERER_MAX_BIN_INPUTS]; + uint16_t numBinBuses; +} InputConfig; + +typedef struct +{ + IVAS_AUDIO_CONFIG audioConfig; +} OutputConfig; + +typedef struct +{ + char executableName[POST_REND_MAX_CLI_ARG_LENGTH]; + char inputFilePath[POST_REND_MAX_CLI_ARG_LENGTH]; + char outputFilePath[POST_REND_MAX_CLI_ARG_LENGTH]; + int32_t sampleRate; + InputConfig inConfig; + OutputConfig outConfig; + char inMetadataFilePaths[RENDERER_MAX_ISAR_MD_INPUTS][POST_REND_MAX_CLI_ARG_LENGTH]; + int16_t numInMetadataFiles; + char headRotationFilePath[POST_REND_MAX_CLI_ARG_LENGTH]; + char splitRendBFIFilePath[POST_REND_MAX_CLI_ARG_LENGTH]; + ISAR_POST_REND_COMPLEXITY_LEVEL complexityLevel; + bool delayCompensationEnabled; + bool quietModeEnabled; + bool sceneDescriptionInput; + IVAS_RENDER_FRAMESIZE render_framesize; +} CmdlnArgs; + +typedef enum +{ + CmdLnOptionId_inputFile = 1, + CmdLnOptionId_inputFormat, + CmdLnOptionId_outputFile, + CmdLnOptionId_sampleRate, + CmdLnOptionId_trajFile, + CmdLnOptionId_orientationTracking, + CmdLnOptionId_complexityLevel, + CmdLnOptionId_noDelayCmp, + CmdLnOptionId_quietModeEnabled, + CmdLnOptionId_inputMetadata, + CmdLnOptionId_listFormats, + CmdLnOptionId_SplitRendBFIFile, + CmdLnOptionId_framing, +} CmdLnOptionId; + +static const CmdLnParser_Option cliOptions[] = { + { + .id = CmdLnOptionId_inputFile, + .match = "input_file", + .matchShort = "i", + .description = "Path to the input file (WAV, raw PCM or scene description file)", + }, + { + .id = CmdLnOptionId_inputFormat, + .match = "input_format", + .matchShort = "if", + .description = "Audio format of input file (e.g. BINAURAL_SPLIT_PCM, use -l for a list)", + }, + { + .id = CmdLnOptionId_inputMetadata, + .match = "input_metadata", + .matchShort = "im", + .description = "Space-separated list of path to metadata files for BINAURAL_SPLIT_PCM input mode", + }, + { + .id = CmdLnOptionId_outputFile, + .match = "output_file", + .matchShort = "o", + .description = "Path to the output file", + }, + { + .id = CmdLnOptionId_sampleRate, + .match = "sample_rate", + .matchShort = "fs", + .description = "Input sampling rate in kHz (16, 32, 48) - required only with raw PCM inputs", + }, + { + .id = CmdLnOptionId_trajFile, + .match = "trajectory_file", + .matchShort = "T", + .description = "Head rotation trajectory file for simulation of head tracking", + }, + { + .id = CmdLnOptionId_SplitRendBFIFile, + .match = "post_rend_bfi_file", + .matchShort = "prbfi", + .description = "Split rendering option: bfi file", + }, + { + .id = CmdLnOptionId_noDelayCmp, + .match = "no_delay_compensation", + .matchShort = "no_delay_cmp", + .description = "[flag] Turn off delay compensation", + }, + { + .id = CmdLnOptionId_complexityLevel, + .match = "complexity_level", + .matchShort = "level", + .description = "Complexity level, level = (1, 2, 3), will be defined after characterisation.", + }, + { + .id = CmdLnOptionId_quietModeEnabled, + .match = "quiet", + .matchShort = "q", + .description = "[flag] Limit printouts to terminal", + }, + { + .id = CmdLnOptionId_listFormats, + .match = "list", + .matchShort = "l", + .description = "List supported audio formats", + }, + { + .id = CmdLnOptionId_framing, + .match = "framing", + .matchShort = "fr", + .description = "Set Render audio framing.", + }, +}; + + +/*------------------------------------------------------------------------------------------* + * Local function prototypes + *------------------------------------------------------------------------------------------*/ + +static const int32_t numCliOptions = sizeof( cliOptions ) / sizeof( CmdLnParser_Option ); + +static void printSupportedAudioConfigs( void ); + +static IVAS_AUDIO_CONFIG parseAudioConfig( const char *configString ); + +static void convertOutputBuffer( const float *floatBuffer, const int16_t numSamplesPerChannel, const int16_t numChannels, int16_t *intBuffer ); + +/*------------------------------------------------------------------------------------------* + * Local functions + *------------------------------------------------------------------------------------------*/ + +static ISAR_POST_REND_ReadOnlyAudioBuffer getReadOnlySubBuffer( + IVAS_REND_AudioBuffer buffer, + const int16_t chBeginIdx, + const int16_t numChannels ) +{ + ISAR_POST_REND_ReadOnlyAudioBuffer subBuffer; + + subBuffer.config = buffer.config; + subBuffer.config.numChannels = numChannels; + subBuffer.data = buffer.data + subBuffer.config.numSamplesPerChannel * chBeginIdx; + + return subBuffer; +} + + +static int16_t getTotalNumInChannels( + ISAR_POST_REND_HANDLE hIsarPostRend, + ISAR_POST_REND_InputId splitBinIds[RENDERER_MAX_BIN_INPUTS] ) +{ + int16_t totalNumInChannels = 0; + int16_t i, numInputChannels; + ivas_error error; + + for ( i = 0; i < RENDERER_MAX_BIN_INPUTS; ++i ) + { + if ( splitBinIds[i] == 0 ) + { + /* Skip inactive inputs */ + continue; + } + + if ( ( error = ISAR_POST_REND_GetInputNumChannels( hIsarPostRend, splitBinIds[i], &numInputChannels ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) ); + exit( -1 ); + } + totalNumInChannels += numInputChannels; + } + + return totalNumInChannels; +} + +/*------------------------------------------------------------------------------------------* + * Local functions + *------------------------------------------------------------------------------------------*/ + +static const CmdLnParser_Option *findOptionById( + const int32_t id ) +{ + for ( int32_t i = 0; i < numCliOptions; ++i ) + { + if ( cliOptions[i].id == id ) + { + return &cliOptions[i]; + } + } + + return NULL; +} + +static bool parseInConfig( + const char *inFormatStr, + InputConfig *inConfig, + bool *sceneDescriptionInput ) +{ + char charBuf[FILENAME_MAX]; + + /* Initialize input config struct */ + inConfig->numBinBuses = 0; + + /* First check if input is being set to scene description file - this is not covered by parseAudioConfig(). */ + strncpy( charBuf, inFormatStr, sizeof( charBuf ) - 1 ); + charBuf[sizeof( charBuf ) - 1] = '\0'; + to_upper( charBuf ); + if ( strcmp( charBuf, "META" ) == 0 ) + { + *sceneDescriptionInput = true; + /* Parsing the file will be done later. At this point the actual file path + * may not be known as command line parameters are still being parsed. */ + return true; + } + + /* Check for single-format inputs. The given string should map to a member of AUDIO_CONFIG enum. */ + IVAS_AUDIO_CONFIG audioConfig = parseAudioConfig( inFormatStr ); + switch ( audioConfig ) + { + case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED: + case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM: + inConfig->numBinBuses = 1; + inConfig->binBuses[0].audioConfig = audioConfig; + inConfig->binBuses[0].inputChannelIndex = 0; + inConfig->binBuses[0].gain_dB = 0.0f; + break; + default: + { + /* Default case covers formats that are defined in the AUDIO_CONFIG enum, + * but cannot be used at input, e.g. BINAURAL */ + const CmdLnParser_Option *listOption = findOptionById( CmdLnOptionId_listFormats ); + fprintf( stderr, "Unsupported input format: %s. To list valid formats, use option --%s.\n", inFormatStr, listOption->match ); + return false; + } + } + + return true; +} + + +static bool parseRenderFramesize( + char *value, + IVAS_RENDER_FRAMESIZE *render_framesize ) +{ + int32_t tmp; + + *render_framesize = IVAS_RENDER_FRAMESIZE_UNKNOWN; + if ( !is_digits_only( value ) ) + { + return false; + } + tmp = (int32_t) strtol( value, NULL, 0 ); + switch ( (int16_t) tmp ) + { + case 5: + *render_framesize = IVAS_RENDER_FRAMESIZE_5MS; + break; + case 10: + *render_framesize = IVAS_RENDER_FRAMESIZE_10MS; + break; + case 20: + *render_framesize = IVAS_RENDER_FRAMESIZE_20MS; + break; + default: + return false; + } + + return true; +} + + +static IVAS_AUDIO_CONFIG parseAudioConfig( + const char *configString ) +{ + char charBuf[25]; + charBuf[24] = '\0'; + + strncpy( charBuf, configString, sizeof( charBuf ) - 1 ); + charBuf[sizeof( charBuf ) - 1] = '\0'; + to_upper( charBuf ); + + if ( strcmp( charBuf, "BINAURAL" ) == 0 ) + { + return IVAS_AUDIO_CONFIG_BINAURAL; + } + if ( strcmp( charBuf, "BINAURAL_SPLIT_PCM" ) == 0 ) + { + return IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM; + } + if ( strcmp( charBuf, "BINAURAL_SPLIT_CODED" ) == 0 ) + { + return IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED; + } + return IVAS_AUDIO_CONFIG_INVALID; +} + + +static bool checkRequiredArgs( + CmdlnArgs args ) +{ + const CmdLnParser_Option *tmpOption; + + /* Check required arguments */ + bool missingRequiredArg = false; + if ( isEmptyString( args.inputFilePath ) ) + { + tmpOption = findOptionById( CmdLnOptionId_inputFile ); + fprintf( stderr, "Missing required argument: %s (%s)\n", tmpOption->match, tmpOption->matchShort ); + missingRequiredArg = true; + } + + const bool singleInputSpecified = ( args.inConfig.numBinBuses != 0 ); + + if ( !args.sceneDescriptionInput && !singleInputSpecified ) + { + /* Neither scene description input nor single-type input was specified on command line */ + tmpOption = findOptionById( CmdLnOptionId_inputFormat ); + fprintf( stderr, "Missing required argument: %s (%s)\n", tmpOption->match, tmpOption->matchShort ); + missingRequiredArg = true; + } + if ( isEmptyString( args.outputFilePath ) ) + { + tmpOption = findOptionById( CmdLnOptionId_outputFile ); + fprintf( stderr, "Missing required argument: %s (%s)\n", tmpOption->match, tmpOption->matchShort ); + missingRequiredArg = true; + } + if ( args.sampleRate == 0 ) + { + tmpOption = findOptionById( CmdLnOptionId_sampleRate ); + fprintf( stderr, "Missing required argument: %s (%s)\n", tmpOption->match, tmpOption->matchShort ); + missingRequiredArg = true; + } + if ( missingRequiredArg ) + { + CmdLnParser_printUsage( args.executableName, cliOptions, numCliOptions ); + } + + return !missingRequiredArg; +} + +static CmdlnArgs defaultArgs( + const char *executableName ) +{ + CmdlnArgs args; + + strncpy( args.executableName, executableName, POST_REND_MAX_CLI_ARG_LENGTH ); + clearString( args.inputFilePath ); + clearString( args.outputFilePath ); + args.sampleRate = 0; + + args.outConfig.audioConfig = IVAS_AUDIO_CONFIG_INVALID; + + for ( int32_t i = 0; i < RENDERER_MAX_ISAR_MD_INPUTS; ++i ) + { + clearString( args.inMetadataFilePaths[i] ); + } + args.numInMetadataFiles = 0; + + clearString( args.headRotationFilePath ); + clearString( args.splitRendBFIFilePath ); + + args.delayCompensationEnabled = true; + args.quietModeEnabled = false; + args.sceneDescriptionInput = false; + + args.render_framesize = IVAS_RENDER_FRAMESIZE_20MS; + + return args; +} + +static void parseOption( + const int32_t optionId, + char **optionValues, + const int16_t numOptionValues, + void *pOutputStruct ) +{ + CmdlnArgs *args = pOutputStruct; + + switch ( optionId ) + { + case CmdLnOptionId_listFormats: + assert( numOptionValues == 0 ); + printSupportedAudioConfigs(); + exit( 0 ); + case CmdLnOptionId_inputFile: + assert( numOptionValues == 1 ); + strncpy( args->inputFilePath, optionValues[0], POST_REND_MAX_CLI_ARG_LENGTH - 1 ); + break; + case CmdLnOptionId_inputFormat: + assert( numOptionValues == 1 ); + if ( !parseInConfig( optionValues[0], &args->inConfig, &args->sceneDescriptionInput ) ) + { + exit( -1 ); /* Error printout handled by failing function */ + } + break; + case CmdLnOptionId_inputMetadata: + assert( numOptionValues <= RENDERER_MAX_ISAR_MD_INPUTS ); + for ( int16_t i = 0; i < numOptionValues; ++i ) + { + strncpy( args->inMetadataFilePaths[i], optionValues[i], POST_REND_MAX_CLI_ARG_LENGTH - 1 ); + } + args->numInMetadataFiles = numOptionValues; + break; + case CmdLnOptionId_outputFile: + assert( numOptionValues == 1 ); + strncpy( args->outputFilePath, optionValues[0], POST_REND_MAX_CLI_ARG_LENGTH - 1 ); + break; + case CmdLnOptionId_sampleRate: + assert( numOptionValues == 1 ); + args->sampleRate = (int32_t) ( strtol( optionValues[0], NULL, 10 ) * 1000 ); + if ( args->sampleRate == 0 ) + { + fprintf( stderr, "Invalid sampling rate specified\n" ); + exit( -1 ); + } + break; + case CmdLnOptionId_trajFile: + assert( numOptionValues == 1 ); + strncpy( args->headRotationFilePath, optionValues[0], POST_REND_MAX_CLI_ARG_LENGTH - 1 ); + break; + case CmdLnOptionId_SplitRendBFIFile: + assert( numOptionValues == 1 ); + strncpy( args->splitRendBFIFilePath, optionValues[0], POST_REND_MAX_CLI_ARG_LENGTH - 1 ); + break; + case CmdLnOptionId_complexityLevel: + assert( numOptionValues == 1 ); + args->complexityLevel = (int32_t) ( strtol( optionValues[0], NULL, 10 ) ); + if ( args->complexityLevel < ISAR_POST_REND_COMPLEXITY_LEVEL_ONE || args->complexityLevel > ISAR_POST_REND_COMPLEXITY_LEVEL_THREE ) + { + fprintf( stdout, "Invalid complexity level specified.\n" ); + exit( -1 ); + } + else if ( args->complexityLevel == ISAR_POST_REND_COMPLEXITY_LEVEL_ONE || args->complexityLevel == ISAR_POST_REND_COMPLEXITY_LEVEL_TWO ) + { + fprintf( stdout, "Complexity levels 1 and 2 will be defined after characterisation - default to level 3 (full functionality).\n" ); + } + break; + case CmdLnOptionId_noDelayCmp: + assert( numOptionValues == 0 ); + args->delayCompensationEnabled = false; + break; + case CmdLnOptionId_quietModeEnabled: + assert( numOptionValues == 0 ); + args->quietModeEnabled = true; + break; + case CmdLnOptionId_framing: + assert( numOptionValues == 1 ); + if ( !parseRenderFramesize( optionValues[0], &args->render_framesize ) ) + { + fprintf( stderr, "Unknown or invalid option for frame size: %s\n", optionValues[0] ); + exit( -1 ); + } + + break; + default: + assert( 0 && "This should be unreachable - all command line options should be explicitly handled." ); + break; + } + + return; +} + +static CmdlnArgs parseCmdlnArgs( + const int argc, + char **argv ) +{ + CmdlnArgs args = defaultArgs( argv[0] ); + + if ( CmdLnParser_parseArgs( argc, argv, cliOptions, numCliOptions, &args, parseOption ) != 0 ) + { + exit( -1 ); /* Error printout handled by failing function */ + } + + if ( !checkRequiredArgs( args ) ) + { + exit( -1 ); /* Error printout handled by failing function */ + } + + return args; +} + + +static void printSupportedAudioConfigs( void ) +{ + uint16_t i; + const char *supportedFormats[] = { + "BINAURAL (output only)", + "BINAURAL_SPLIT_PCM", + "BINAURAL_SPLIT_CODED", + }; + + fprintf( stdout, "Supported audio formats:\n" ); + for ( i = 0; i < sizeof( supportedFormats ) / sizeof( *supportedFormats ); i++ ) + { + fprintf( stdout, "%s\n", supportedFormats[i] ); + } + + return; +} + +/*--------------------------------------------------------------------------* + * convertInputBuffer() + * + * Convert input buffer from WAV/PCM file (int16_t, interleaved) to a format + * accepted by the renderer (float, packed) + *--------------------------------------------------------------------------*/ + +static void convertInputBuffer( + const int16_t *intBuffer, + const int16_t numIntSamplesPerChannel, + const int16_t numFloatSamplesPerChannel, + const int16_t numChannels, + float *floatBuffer ) +{ + int16_t chnl, smpl, i; + + i = 0; + + for ( smpl = 0; smpl < numFloatSamplesPerChannel; ++smpl ) + { + for ( chnl = 0; chnl < numChannels; ++chnl ) + { + if ( i < numIntSamplesPerChannel ) + { + floatBuffer[chnl * numFloatSamplesPerChannel + smpl] = (float) intBuffer[i]; + } + else + { + floatBuffer[chnl * numFloatSamplesPerChannel + smpl] = 0.f; + } + + ++i; + } + } + + return; +} + +/*--------------------------------------------------------------------------* + * convertOutputBuffer() + * + * Convert output buffer from the renderer (float, packed) to a format ready + * for writing to a WAV/PCM file (int16_t, interleaved) + *--------------------------------------------------------------------------*/ + +static void convertOutputBuffer( + const float *floatBuffer, + const int16_t numSamplesPerChannel, + const int16_t numChannels, + int16_t *intBuffer ) +{ + int16_t chnl, smpl, i; + float temp; + + i = 0; + + for ( smpl = 0; smpl < numSamplesPerChannel; ++smpl ) + { + for ( chnl = 0; chnl < numChannels; ++chnl ) + { + temp = floatBuffer[chnl * numSamplesPerChannel + smpl]; + temp = (float) floor( temp + 0.5f ); + if ( temp > ISAR_MAX16B_FLT ) + { + temp = ISAR_MAX16B_FLT; + } + else if ( temp < ISAR_MIN16B_FLT ) + { + temp = ISAR_MIN16B_FLT; + } + intBuffer[i] = (int16_t) temp; + + ++i; + } + } + + return; +} + +/*------------------------------------------------------------------------------------------* + * main() + * + * Main ISAR post renderer function for command-line interface + *------------------------------------------------------------------------------------------*/ + +int main( + int argc, + char **argv ) +{ + ISAR_POST_REND_HANDLE hIsarPostRend; + RotFileReader *headRotReader = NULL; + RotFileReader *externalOrientationFileReader = NULL; + SplitRendBFIFileReader *splitRendBFIReader = NULL; + AudioFileReader *audioReader = NULL; + AudioFileWriter *audioWriter; + int32_t inBufferSize; + int32_t outBufferSize; + int32_t bitsBufferSize; + int16_t *inpInt16Buffer; + float *inFloatBuffer; + int16_t *outInt16Buffer; + float *outFloatBuffer; + uint8_t *bitsBufferData = NULL; + IVAS_REND_AudioBuffer inBuffer; + IVAS_REND_AudioBuffer outBuffer; + ISAR_POST_REND_BitstreamBuffer bitsBuffer; + SplitFileReadWrite *hSplitRendFileReadWrite; + char audioFilePath[FILENAME_MAX]; + int16_t numSamplesRead; + int16_t delayNumSamples = -1; + int16_t delayNumSamples_orig = 0; + int16_t zeroPad = 0; + int16_t zeroPadToWrite = 0; + int32_t delayTimeScale = 0; + int16_t i, numChannels; + ivas_error error = IVAS_ERR_OK; + bool splitBinNeedsNewFrame = true; + +#ifdef WMOPS + reset_wmops(); + reset_mem( USE_BYTES ); +#endif + + hSplitRendFileReadWrite = NULL; + bitsBuffer.bits = NULL; + bitsBuffer.config.bitsRead = 0; + bitsBuffer.config.bitsWritten = 0; + bitsBuffer.config.bufLenInBytes = 0; + bitsBuffer.config.codec = ISAR_SPLIT_REND_CODEC_DEFAULT; + bitsBuffer.config.poseCorrection = ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE; +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + bitsBuffer.config.codec_frame_size_ms = 5; + bitsBuffer.config.isar_frame_size_ms = 20; + bitsBuffer.config.lc3plusHighRes = 0; +#else + bitsBuffer.config.codec_frame_size_ms = 20; +#endif + + + CmdlnArgs args = parseCmdlnArgs( argc, argv ); + + convert_backslash( args.inputFilePath ); + convert_backslash( args.outputFilePath ); + convert_backslash( args.headRotationFilePath ); + + if ( !isEmptyString( args.headRotationFilePath ) ) + { + if ( RotationFileReader_open( args.headRotationFilePath, &headRotReader ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Error opening file: %s\n", args.headRotationFilePath ); + exit( -1 ); + } + } + + if ( !isEmptyString( args.splitRendBFIFilePath ) ) + { + convert_backslash( args.splitRendBFIFilePath ); + SplitRendBFIFileReader_open( args.splitRendBFIFilePath, &splitRendBFIReader ); + } + +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + int32_t inFileSampleRate = 0; +#endif + strncpy( audioFilePath, args.inputFilePath, FILENAME_MAX - 1 ); + hSplitRendFileReadWrite = NULL; + if ( ( args.inConfig.numBinBuses > 0 ) && ( args.inConfig.binBuses[0].audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + { + error = split_rend_reader_open( &hSplitRendFileReadWrite, + args.inMetadataFilePaths[0], + &bitsBuffer.config.codec, + &bitsBuffer.config.poseCorrection, + &bitsBuffer.config.codec_frame_size_ms +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + , + &bitsBuffer.config.isar_frame_size_ms, + &inFileSampleRate, + &bitsBuffer.config.lc3plusHighRes +#endif + ); + if ( error != IVAS_ERR_OK ) + { + fprintf( stderr, "Could not open split rend metadata file %s\n", args.inMetadataFilePaths[0] ); + exit( -1 ); + } + + if ( AudioFileReader_open( &audioReader, audioFilePath ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Error opening file: %s\n", audioFilePath ); + exit( -1 ); + } + } + + /*if split renderer is running in post renderer mode*/ + if ( ( args.inConfig.numBinBuses > 0 ) && ( args.inConfig.binBuses[0].audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) ) + { + error = split_rend_reader_open( &hSplitRendFileReadWrite, + args.inputFilePath, + &bitsBuffer.config.codec, + &bitsBuffer.config.poseCorrection, + &bitsBuffer.config.codec_frame_size_ms +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + , + &bitsBuffer.config.isar_frame_size_ms, + &inFileSampleRate, + &bitsBuffer.config.lc3plusHighRes +#endif + ); + if ( error != IVAS_ERR_OK ) + { + fprintf( stderr, "Could not open split rend metadata file %s\n", args.inputFilePath ); + exit( -1 ); + } + audioReader = NULL; + } + +#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS + int32_t inFileSampleRate = 0; +#endif + if ( audioReader != NULL ) + { + error = AudioFileReader_getSamplingRate( audioReader, &inFileSampleRate ); + } + else +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + if ( hSplitRendFileReadWrite == NULL ) +#endif + { + inFileSampleRate = args.sampleRate; + } + + switch ( error ) + { + case IVAS_ERR_OK: + /* If sampling rate not given on command line, use the one from SR file */ + if ( args.sampleRate == 0 ) + { + args.sampleRate = inFileSampleRate; + } + /* else if sampling rate given on command line, compare with wav file */ + else if ( inFileSampleRate != args.sampleRate ) + { + fprintf( stderr, "Sampling rate mismatch: %d Hz requested, but %d Hz found in file %s\n", args.sampleRate, inFileSampleRate, args.inputFilePath ); + exit( -1 ); + } + break; + case IVAS_ERR_SAMPLING_RATE_UNKNOWN: /* Returned when input is raw PCM */ + if ( args.sampleRate == 0 ) + { + fprintf( stderr, "Sampling rate must be specified on command line when using raw PCM input\n" ); + exit( -1 ); + } + break; + default: + fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) ); + exit( -1 ); + } + + int16_t inFileNumChannels = 0; + if ( audioReader != NULL ) + { + error = AudioFileReader_getNumChannels( audioReader, &inFileNumChannels ); + if ( error != IVAS_ERR_OK && error != IVAS_ERR_NUM_CHANNELS_UNKNOWN ) + { + fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) ); + exit( -1 ); + } + } + const int16_t frameSize_smpls = (int16_t) ( ( args.render_framesize ) * args.sampleRate * 5 / ( 1000 ) ); + args.outConfig.audioConfig = IVAS_AUDIO_CONFIG_BINAURAL; + if ( ( error = ISAR_POST_REND_open( &hIsarPostRend, args.sampleRate, args.outConfig.audioConfig, true, 0, 0.0, (int16_t) args.render_framesize ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Error opening renderer handle: %s\n", ivas_error_to_string( error ) ); + exit( -1 ); + } + + /* === Configure === */ + if ( ( error = ISAR_POST_REND_InitConfig( hIsarPostRend, args.outConfig.audioConfig ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Error in Renderer Config Init: %s\n", ivas_error_to_string( error ) ); + exit( -1 ); + } + + if ( args.inConfig.numBinBuses > 0 ) + { + if ( ( error = ISAR_REND_SetSplitRendBitstreamHeader( hIsarPostRend, + bitsBuffer.config.codec, + bitsBuffer.config.poseCorrection, + bitsBuffer.config.codec_frame_size_ms +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + , + bitsBuffer.config.isar_frame_size_ms, + bitsBuffer.config.lc3plusHighRes +#endif + ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Error in getting split renderer bitstream header: %s\n", ivas_error_to_string( error ) ); + exit( -1 ); + } + } + + + ISAR_POST_REND_InputId splitBinIds[RENDERER_MAX_BIN_INPUTS]; + + for ( i = 0; i < RENDERER_MAX_BIN_INPUTS; i++ ) + { + splitBinIds[i] = 0u; + } + + for ( i = 0; i < args.inConfig.numBinBuses; ++i ) + { + if ( ( error = ISAR_POST_REND_AddInput( hIsarPostRend, args.inConfig.binBuses[i].audioConfig, &splitBinIds[i] ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) ); + exit( -1 ); + } + } + + const int16_t totalNumInChannels = getTotalNumInChannels( hIsarPostRend, splitBinIds ); + + if ( inFileNumChannels != 0 /* inFileNumChannels is 0 with raw PCM input */ && totalNumInChannels != inFileNumChannels ) + { + fprintf( stderr, "Number of channels in input file does not match selected configuration\n" ); + exit( -1 ); + } + + int16_t numOutChannels = 2; + + if ( AudioFileWriter_open( &audioWriter, args.outputFilePath, args.sampleRate, numOutChannels ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Failed to open file: %s\n", args.outputFilePath ); + exit( -1 ); + } + + inBufferSize = frameSize_smpls * totalNumInChannels; + outBufferSize = frameSize_smpls * numOutChannels; + inpInt16Buffer = malloc( inBufferSize * sizeof( int16_t ) ); + + inFloatBuffer = malloc( inBufferSize * sizeof( float ) ); + inBuffer.config.numSamplesPerChannel = (int16_t) frameSize_smpls; + outFloatBuffer = malloc( outBufferSize * sizeof( float ) ); + outBuffer.config.numSamplesPerChannel = (int16_t) frameSize_smpls; + + outInt16Buffer = malloc( outBufferSize * sizeof( int16_t ) ); + + inBuffer.config.is_cldfb = 0; + inBuffer.config.numChannels = (int16_t) totalNumInChannels; + inBuffer.data = inFloatBuffer; + + outBuffer.config.is_cldfb = 0; + outBuffer.config.numChannels = (int16_t) numOutChannels; + outBuffer.data = outFloatBuffer; + + memset( outBuffer.data, 0, outBuffer.config.numSamplesPerChannel * outBuffer.config.numChannels * sizeof( float ) ); + + bitsBufferSize = SPLIT_REND_BITS_BUFF_SIZE; + + if ( bitsBufferSize > 0 ) + { + bitsBufferData = malloc( bitsBufferSize * sizeof( uint8_t ) ); + } + else + { + bitsBufferData = NULL; + } + + bitsBuffer.bits = bitsBufferData; + bitsBuffer.config.bitsRead = 0; + bitsBuffer.config.bitsWritten = 0; + bitsBuffer.config.bufLenInBytes = bitsBufferSize; + +#ifdef WMOPS + reset_stack(); + reset_wmops(); +#endif + + if ( !args.quietModeEnabled ) + { + fprintf( stdout, "\n------ Running the ISAR post renderer ------\n\n" ); + fprintf( stdout, "Frames processed: " ); + } + else + { + fprintf( stdout, "\n\n-- Start the ISAR post renderer (quiet mode) --\n\n" ); + } + + while ( 1 ) + { + int16_t num_in_channels; + num_in_channels = inBuffer.config.numChannels; + + numSamplesRead = 0; + if ( ( hSplitRendFileReadWrite != NULL ) && splitBinNeedsNewFrame ) + { + ivas_error error_tmp; + numSamplesRead = (int16_t) inBufferSize; + error_tmp = split_rend_read_bits_from_file( hSplitRendFileReadWrite, bitsBuffer.bits, &bitsBuffer.config.bitsRead, &bitsBuffer.config.bitsWritten ); + if ( error_tmp != IVAS_ERR_OK ) + { + if ( error_tmp == IVAS_ERR_END_OF_FILE ) + { + numSamplesRead = 0; + } + else + { + fprintf( stderr, "\nUnable to read from bitstream file!\n" ); + exit( -1 ); + } + } + } + + if ( audioReader != NULL ) + { + /* Read the input data */ + if ( ( error = AudioFileReader_read( audioReader, inpInt16Buffer, (int16_t) inBufferSize, &numSamplesRead ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError reading from file %s\n", audioFilePath ); + exit( -1 ); + } + } + + if ( numSamplesRead == 0 && splitBinNeedsNewFrame ) + { + /* end of input data */ + break; + } + + /* Convert from int to float and from interleaved to packed */ + convertInputBuffer( inpInt16Buffer, numSamplesRead, inBuffer.config.numSamplesPerChannel, num_in_channels, inFloatBuffer ); + + int16_t num_subframes, sf_idx; + num_subframes = (int16_t) args.render_framesize; + + /* Read from head rotation trajectory file if specified */ + if ( headRotReader != NULL ) + { + for ( sf_idx = 0; sf_idx < num_subframes; sf_idx++ ) + { + IVAS_QUATERNION headRot; + IVAS_VECTOR3 Pos; + + if ( ( error = HeadRotationFileReading( headRotReader, &headRot, &Pos ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Error in Head Rotation File Reading: %s\n", ivas_error_to_string( error ) ); + exit( -1 ); + } + + if ( ( error = ISAR_POST_REND_SetHeadRotation( hIsarPostRend, headRot, Pos, DEFAULT_AXIS, sf_idx ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Error setting Head Rotation: %s\n", ivas_error_to_string( error ) ); + exit( -1 ); + } + } + } + else + { + fprintf( stderr, "Head Rotation should be enabled in post renderer\n" ); + exit( -1 ); + } + + /* Read from split renderer bfi file if specified */ + if ( splitRendBFIReader != NULL && splitBinNeedsNewFrame ) + { + int16_t bfi; + if ( ( error = SplitRendBFIFileReading( splitRendBFIReader, &bfi ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Error in SplitRendBFIFileReading(): %s\n", ivas_error_to_string( error ) ); + exit( -1 ); + } + + if ( ( error = ISAR_POST_REND_SetSplitRendBFI( hIsarPostRend, bfi ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Error in ISAR_POST_REND_SetSplitRendBFI(): %s\n", ivas_error_to_string( error ) ); + exit( -1 ); + } + } + + for ( i = 0; i < args.inConfig.numBinBuses; ++i ) + { + if ( numSamplesRead > 0 ) + { + if ( ( error = ISAR_POST_REND_GetInputNumChannels( hIsarPostRend, splitBinIds[i], &numChannels ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) ); + exit( -1 ); + } + ISAR_POST_REND_ReadOnlyAudioBuffer tmpBuffer = getReadOnlySubBuffer( inBuffer, (int16_t) args.inConfig.binBuses[i].inputChannelIndex, numChannels ); + + if ( ( error = ISAR_POST_REND_FeedInputAudio( hIsarPostRend, splitBinIds[i], tmpBuffer ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) ); + exit( -1 ); + } + } + if ( splitBinNeedsNewFrame ) + { + if ( ( error = ISAR_POST_REND_FeedSplitBinauralBitstream( hIsarPostRend, splitBinIds[i], &bitsBuffer ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) ); + exit( -1 ); + } + } + } + + if ( ( error = ISAR_POST_REND_GetSplitBinauralSamples( hIsarPostRend, outBuffer, &splitBinNeedsNewFrame ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) ); + exit( -1 ); + } + + int16_t num_out_channels; + num_out_channels = outBuffer.config.numChannels; + + /* Convert from float to int and from packed to interleaved. + * Values in outFloatBuffer are guaranteed to be within range INT16_MIN:INT16_MAX */ + convertOutputBuffer( outFloatBuffer, outBuffer.config.numSamplesPerChannel, num_out_channels, outInt16Buffer ); + + if ( delayNumSamples == -1 ) + { + if ( args.delayCompensationEnabled ) + { + if ( ISAR_POST_REND_GetDelay( hIsarPostRend, &delayNumSamples, &delayTimeScale ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nUnable to get delay of renderer!\n" ); + exit( -1 ); + } + + if ( hSplitRendFileReadWrite != NULL ) + { + uint32_t pre_rend_delay_ns; + split_rend_read_pre_rend_delay_ns( hSplitRendFileReadWrite, &pre_rend_delay_ns ); + delayNumSamples += (int16_t) roundf( (float) pre_rend_delay_ns * delayTimeScale / 1000000000.f ); + } + + delayNumSamples_orig = delayNumSamples; + } + else + { + delayNumSamples = 0; + } + zeroPad = delayNumSamples; + } + + if ( audioWriter != NULL ) + { + if ( delayNumSamples * num_out_channels < outBufferSize ) + { + if ( AudioFileWriter_write( audioWriter, &outInt16Buffer[delayNumSamples * num_out_channels], outBufferSize - ( delayNumSamples * num_out_channels ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Error writing audio file %s\n", args.outputFilePath ); + exit( -1 ); + } + delayNumSamples = 0; + } + else + { + delayNumSamples -= (int16_t) ( outBufferSize / num_out_channels ); + } + } + + bitsBuffer.config.bitsRead = 0; + bitsBuffer.config.bitsWritten = 0; + + frame++; + if ( !args.quietModeEnabled ) + { + fprintf( stdout, "%-8d\b\b\b\b\b\b\b\b", frame ); + } + +#ifdef WMOPS + update_mem(); + update_wmops(); +#endif + } + + /* add zeros at the end to have equal length of synthesized signals */ + if ( audioWriter != NULL ) + { + for ( zeroPadToWrite = zeroPad; zeroPadToWrite > frameSize_smpls; zeroPadToWrite -= frameSize_smpls ) + { + memset( outInt16Buffer, 0, outBufferSize * sizeof( int16_t ) ); + if ( ( error = AudioFileWriter_write( audioWriter, outInt16Buffer, outBufferSize ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nOutput audio file writer error\n" ); + exit( -1 ); + } + } + + memset( outInt16Buffer, 0, zeroPadToWrite * outBuffer.config.numChannels * sizeof( int16_t ) ); + if ( ( error = AudioFileWriter_write( audioWriter, outInt16Buffer, zeroPadToWrite * outBuffer.config.numChannels ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nOutput audio file writer error\n" ); + exit( -1 ); + } + zeroPadToWrite = 0; + } + + if ( !args.quietModeEnabled && args.delayCompensationEnabled ) + { + fprintf( stdout, "\nRenderer delay: %-5u [samples] - Timescale: %5u\n", delayNumSamples_orig, delayTimeScale ); + } + + fprintf( stdout, "\n\nRendering of %d frames finished\n\n", frame ); + +#ifdef DEBUGGING + int32_t cnt_frames_limited, noClipping; + if ( ( cnt_frames_limited = ISAR_POST_REND_GetCntFramesLimited( hIsarPostRend ) ) > 0 ) + { + fprintf( stdout, "Limiter applied in %d frames.\n\n", cnt_frames_limited ); + } + if ( ( noClipping = ISAR_POST_REND_GetNoCLipping( hIsarPostRend ) ) > 0 ) + { + fprintf( stdout, "Clipping (saturation) detected: %d samples clipped!!!\n\n", noClipping ); + } +#endif + + /* === Close === */ + free( inpInt16Buffer ); + free( inFloatBuffer ); + free( outInt16Buffer ); + free( outFloatBuffer ); + + if ( bitsBufferData != NULL ) + { + free( bitsBufferData ); + } + + split_rend_reader_writer_close( &hSplitRendFileReadWrite ); + SplitRendBFIFileReader_close( &splitRendBFIReader ); + + AudioFileReader_close( &audioReader ); + AudioFileWriter_close( &audioWriter ); + RotationFileReader_close( &headRotReader ); + RotationFileReader_close( &externalOrientationFileReader ); + + ISAR_POST_REND_Close( &hIsarPostRend ); + +#ifdef DEBUGGING + dbgclose(); +#endif +#ifdef WMOPS + print_wmops(); + print_mem( NULL ); +#endif + + return 0; +} + + +#undef WMC_TOOL_SKIP + +#endif /* SPLIT_REND_WITH_HEAD_ROT */ diff --git a/apps/renderer.c b/apps/renderer.c index c3b62b2ef1dc9b4205a98629432bbd979b624547..e95977a7f7944e0c8d7dfac8d61e27244e0a37e3 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other @@ -45,6 +45,10 @@ #include "masa_file_writer.h" #include "render_config_reader.h" #include "rotation_file_reader.h" +#ifdef SPLIT_REND_WITH_HEAD_ROT +#include "split_render_file_read_write.h" +#include "split_rend_bfi_file_reader.h" +#endif #include "vector3_pair_file_reader.h" #ifdef DEBUGGING #include "debug.h" @@ -62,7 +66,6 @@ #define RENDERER_MAX_METADATA_LENGTH 8192 #define RENDERER_MAX_METADATA_LINE_LENGTH 1024 - #define IVAS_MAX16B_FLT 32767.0f #define IVAS_MIN16B_FLT ( -32768.0f ) @@ -149,7 +152,13 @@ typedef struct OutputConfig outConfig; char inMetadataFilePaths[RENDERER_MAX_ISM_INPUTS][RENDERER_MAX_CLI_ARG_LENGTH]; int16_t numInMetadataFiles; +#ifdef SPLIT_REND_WITH_HEAD_ROT + char outMetadataFilePath[RENDERER_MAX_CLI_ARG_LENGTH]; +#endif char headRotationFilePath[RENDERER_MAX_CLI_ARG_LENGTH]; +#ifdef SPLIT_REND_WITH_HEAD_ROT + char splitRendBFIFilePath[RENDERER_MAX_CLI_ARG_LENGTH]; +#endif char referenceVectorFilePath[RENDERER_MAX_CLI_ARG_LENGTH]; char referenceRotationFilePath[RENDERER_MAX_CLI_ARG_LENGTH]; char externalOrientationFilePath[RENDERER_MAX_CLI_ARG_LENGTH]; @@ -196,6 +205,10 @@ typedef enum CmdLnOptionId_inputMetadata, CmdLnOptionId_listFormats, CmdLnOptionId_inputGain, +#ifdef SPLIT_REND_WITH_HEAD_ROT + CmdLnOptionId_outputMetadata, + CmdLnOptionId_SplitRendBFIFile, +#endif CmdLnOptionId_referenceVectorFile, CmdLnOptionId_exteriorOrientationFile, CmdLnOptionId_framing, @@ -221,7 +234,11 @@ static const CmdLnParser_Option cliOptions[] = { .id = CmdLnOptionId_inputMetadata, .match = "input_metadata", .matchShort = "im", +#ifdef SPLIT_REND_WITH_HEAD_ROT + .description = "Space-separated list of path to metadata files for ISM or MASA inputs or BINAURAL_SPLIT_PCM input mode", +#else .description = "Space-separated list of path to metadata files for ISM or MASA inputs", +#endif }, { .id = CmdLnOptionId_outputFile, @@ -247,6 +264,20 @@ static const CmdLnParser_Option cliOptions[] = { .matchShort = "T", .description = "Head rotation trajectory file for simulation of head tracking (only for binaural outputs)", }, +#ifdef SPLIT_REND_WITH_HEAD_ROT + { + .id = CmdLnOptionId_outputMetadata, + .match = "output_metadata", + .matchShort = "om", + .description = "coded metadata file for BINAURAL_SPLIT_PCM output mode", + }, + { + .id = CmdLnOptionId_SplitRendBFIFile, + .match = "post_rend_bfi_file", + .matchShort = "prbfi", + .description = "Split rendering option: bfi file", + }, +#endif { .id = CmdLnOptionId_refRotFile, .match = "reference_rotation_file", @@ -408,9 +439,15 @@ static void printSupportedAudioConfigs( void ); static IVAS_AUDIO_CONFIG parseAudioConfig( const char *configString ); +#ifdef SPLIT_REND_WITH_HEAD_ROT +static void convertInputBuffer( const int16_t *intBuffer, const int16_t numIntSamplesPerChannel, const int16_t numFloatSamplesPerChannel, const int16_t numChannels, float *floatBuffer, const int16_t cldfb_in, IVAS_CLDFB_FILTER_BANK_HANDLE *cldfbAna ); + +static void convertOutputBuffer( const float *floatBuffer, const int16_t numSamplesPerChannel, const int16_t numChannels, int16_t *intBuffer, const int16_t cldfb_in, IVAS_CLDFB_FILTER_BANK_HANDLE *cldfbSyn ); +#else static void convertInputBuffer( const int16_t *intBuffer, const int16_t numIntSamplesPerChannel, const int16_t numFloatSamplesPerChannel, const int16_t numChannels, float *floatBuffer ); static void convertOutputBuffer( const float *floatBuffer, const int16_t numSamplesPerChannel, const int16_t numChannels, int16_t *intBuffer ); +#endif /*------------------------------------------------------------------------------------------* @@ -514,7 +551,6 @@ static int16_t getTotalNumInChannels( totalNumInChannels += numInputChannels; } - return totalNumInChannels; } @@ -582,6 +618,43 @@ static float dBToLin( } +#ifdef SPLIT_REND_WITH_HEAD_ROT +static int16_t get_cldfb_in_flag( + const IVAS_AUDIO_CONFIG audioConfig, + const IVAS_RENDER_CONFIG_DATA *renderConfig ) +{ + int16_t cldfb_in_flag; + + cldfb_in_flag = 0; + if ( renderConfig->split_rend_config.rendererSelection == ISAR_SPLIT_REND_RENDERER_SELECTION_FASTCONV ) + { +#ifdef DEBUGGING + cldfb_in_flag = 1; +#endif + if ( audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) + { + cldfb_in_flag = 1; + } + } + + return cldfb_in_flag; +} + +static int16_t is_split_pre_rend_mode( + CmdlnArgs *args ) +{ + int16_t flag; + + flag = 0; + if ( args->outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || args->outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + { + flag = 1; + } + + return flag; +} +#endif + /*------------------------------------------------------------------------------------------* * main() * @@ -596,6 +669,12 @@ int main( RotFileReader *headRotReader = NULL; RotFileReader *externalOrientationFileReader = NULL; RotFileReader *referenceRotReader = NULL; +#ifdef SPLIT_REND_WITH_HEAD_ROT + IVAS_CLDFB_FILTER_BANK_HANDLE cldfbAna[IVAS_MAX_INPUT_CHANNELS]; + IVAS_CLDFB_FILTER_BANK_HANDLE cldfbSyn[IVAS_MAX_INPUT_CHANNELS]; + int16_t cldfb_in_flag, CLDFBframeSize_smpls; + SplitRendBFIFileReader *splitRendBFIReader = NULL; +#endif Vector3PairFileReader *referenceVectorReader = NULL; hrtfFileReader *hrtfFileReader = NULL; IsmPositionProvider *positionProvider; @@ -609,12 +688,24 @@ int main( AudioFileWriter *audioWriter; int32_t inBufferSize; int32_t outBufferSize; +#ifdef SPLIT_REND_WITH_HEAD_ROT + int32_t bitsBufferSize; +#endif int16_t *inpInt16Buffer; float *inFloatBuffer; int16_t *outInt16Buffer; float *outFloatBuffer; +#ifdef SPLIT_REND_WITH_HEAD_ROT + uint8_t *bitsBufferData = NULL; +#endif IVAS_REND_AudioBuffer inBuffer; IVAS_REND_AudioBuffer outBuffer; +#ifdef SPLIT_REND_WITH_HEAD_ROT + IVAS_REND_BitstreamBuffer bitsBuffer; + SplitFileReadWrite *hSplitRendFileReadWrite; + int16_t delayNumSamples_temp; + int32_t delayTimeScale_temp; +#endif int16_t numSamplesRead; int16_t delayNumSamples = -1; int16_t delayNumSamples_orig = 0; @@ -623,7 +714,6 @@ int main( int32_t delayTimeScale = 0; int16_t i, numChannels; ivas_error error = IVAS_ERR_OK; - bool splitBinNeedsNewFrame = true; #ifdef WMOPS reset_wmops(); @@ -636,6 +726,24 @@ int main( hMasaMetadata[i] = NULL; } +#ifdef SPLIT_REND_WITH_HEAD_ROT + hSplitRendFileReadWrite = NULL; + CLDFBframeSize_smpls = 0; + cldfb_in_flag = 0; + bitsBuffer.bits = NULL; + bitsBuffer.config.bitsRead = 0; + bitsBuffer.config.bitsWritten = 0; + bitsBuffer.config.bufLenInBytes = 0; + bitsBuffer.config.codec = ISAR_SPLIT_REND_CODEC_DEFAULT; + bitsBuffer.config.poseCorrection = ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE; +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + bitsBuffer.config.codec_frame_size_ms = 5; + bitsBuffer.config.isar_frame_size_ms = 20; + bitsBuffer.config.lc3plus_highres = 0; +#else + bitsBuffer.config.codec_frame_size_ms = 20; +#endif +#endif for ( i = 0; i < RENDERER_MAX_MC_INPUTS; ++i ) { lfeRoutingConfigs[i] = NULL; @@ -694,6 +802,13 @@ int main( } } +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( !isEmptyString( args.splitRendBFIFilePath ) ) + { + convert_backslash( args.splitRendBFIFilePath ); + SplitRendBFIFileReader_open( args.splitRendBFIFilePath, &splitRendBFIReader ); + } +#endif if ( !isEmptyString( args.externalOrientationFilePath ) ) { if ( RotationFileReader_open( args.externalOrientationFilePath, &externalOrientationFileReader ) != IVAS_ERR_OK ) @@ -794,6 +909,7 @@ int main( fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) ); exit( -1 ); } + const int16_t frameSize_smpls = (int16_t) ( ( args.render_framesize ) * args.sampleRate * 5 / ( 1000 ) ); if ( ( error = IVAS_REND_Open( &hIvasRend, args.sampleRate, args.outConfig.audioConfig, args.nonDiegeticPan, args.nonDiegeticPanGain, (int16_t) args.render_framesize ) ) != IVAS_ERR_OK ) @@ -851,22 +967,33 @@ int main( exit( -1 ); } - if ( args.renderConfigFilePath[0] != '\0' ) { IVAS_RENDER_CONFIG_DATA renderConfig; /* sanity check */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( args.outConfig.audioConfig != IVAS_AUDIO_CONFIG_BINAURAL ) && ( args.outConfig.audioConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) && ( args.outConfig.audioConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) && !is_split_pre_rend_mode( &args ) ) + { + fprintf( stderr, "\nExternal Renderer Config is supported only when binaural output configurations is used as output OR when Split pre-rendering mode is enabled. Exiting. \n" ); + exit( -1 ); + } +#else if ( ( args.outConfig.audioConfig != IVAS_AUDIO_CONFIG_BINAURAL ) && ( args.outConfig.audioConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) && ( args.outConfig.audioConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) { fprintf( stderr, "\nExternal Renderer Config is only supported for binaural output configurations. Exiting. \n" ); exit( -1 ); } +#endif if ( ( error = IVAS_REND_GetRenderConfig( hIvasRend, &renderConfig ) ) != IVAS_ERR_OK ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT + fprintf( stderr, "\nIVAS_DEC_GetRenderConfig failed: %s\n", ivas_error_to_string( error ) ); +#else fprintf( stderr, "\nIVAS_DEC_GetRenderConfig failed\n" ); +#endif exit( -1 ); } @@ -894,11 +1021,28 @@ int main( renderConfig.roomAcoustics.override = 1; } +#ifdef SPLIT_REND_WITH_HEAD_ROT +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + /* ISAR frame size is set from command line, not renderer config file. + * This will be ignored if output format is not split rendering. */ + renderConfig.split_rend_config.isar_frame_size_ms = (int16_t) args.render_framesize /* given in number of 5ms subframes */ * 5; +#endif +#endif + if ( ( error = IVAS_REND_FeedRenderConfig( hIvasRend, renderConfig ) ) != IVAS_ERR_OK ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT + fprintf( stderr, "\nIVAS_REND_FeedRenderConfig failed: %s\n", ivas_error_to_string( error ) ); +#else fprintf( stderr, "\nIVAS_DEC_FeedRenderConfig failed\n" ); +#endif exit( -1 ); } + +#ifdef SPLIT_REND_WITH_HEAD_ROT + CLDFBframeSize_smpls = frameSize_smpls * 2; + cldfb_in_flag = get_cldfb_in_flag( args.outConfig.audioConfig, &renderConfig ); +#endif } if ( ( error = IVAS_REND_SetOrientationTrackingMode( hIvasRend, args.orientation_tracking ) ) != IVAS_ERR_OK ) @@ -1094,7 +1238,6 @@ int main( } } - for ( i = 0; i < args.inConfig.numMasaBuses; ++i ) { if ( ( error = IVAS_REND_AddInput( hIvasRend, args.inConfig.masaBuses[i].audioConfig, &masaIds[i] ) ) != IVAS_ERR_OK ) @@ -1133,17 +1276,160 @@ int main( exit( -1 ); } +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( cldfb_in_flag ) + { + if ( ( error = IVAS_REND_openCldfb( cldfbAna, cldfbSyn, totalNumInChannels, numOutChannels, args.sampleRate ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Error in IVAS_REND_openCldfb(): %s\n", ivas_error_to_string( error ) ); + exit( -1 ); + } + } + + if ( args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) + { - if ( AudioFileWriter_open( &audioWriter, args.outputFilePath, args.sampleRate, numOutChannels ) != IVAS_ERR_OK ) + IVAS_REND_GetSplitRendBitstreamHeader( hIvasRend, + &bitsBuffer.config.codec, + &bitsBuffer.config.poseCorrection, + &bitsBuffer.config.codec_frame_size_ms +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + , + &bitsBuffer.config.isar_frame_size_ms +#endif + ); + + if ( IVAS_REND_GetDelay( hIvasRend, &delayNumSamples_temp, &delayTimeScale_temp ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nUnable to get delay of renderer!\n" ); + exit( -1 ); + } + + if ( ( error = split_rend_writer_open( &hSplitRendFileReadWrite, + args.outputFilePath, + delayNumSamples_temp, + delayTimeScale_temp, + bitsBuffer.config.codec, + bitsBuffer.config.poseCorrection, + bitsBuffer.config.codec_frame_size_ms +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + , + bitsBuffer.config.isar_frame_size_ms, + args.sampleRate, + bitsBuffer.config.lc3plus_highres +#endif + ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Could not open split rend metadata file %s\n", args.outputFilePath ); + exit( -1 ); + } + audioWriter = NULL; + } + else { - fprintf( stderr, "Failed to open file: %s\n", args.outputFilePath ); - exit( -1 ); + if ( args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + { + + IVAS_REND_GetSplitRendBitstreamHeader( hIvasRend, + &bitsBuffer.config.codec, + &bitsBuffer.config.poseCorrection, + &bitsBuffer.config.codec_frame_size_ms +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + , + &bitsBuffer.config.isar_frame_size_ms +#endif + ); + + if ( IVAS_REND_GetDelay( hIvasRend, &delayNumSamples_temp, &delayTimeScale_temp ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nUnable to get delay of renderer!\n" ); + exit( -1 ); + } + + if ( ( error = split_rend_writer_open( &hSplitRendFileReadWrite, + args.outMetadataFilePath, + delayNumSamples_temp, + delayTimeScale_temp, + bitsBuffer.config.codec, + bitsBuffer.config.poseCorrection, + bitsBuffer.config.codec_frame_size_ms +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + , + bitsBuffer.config.isar_frame_size_ms, + args.sampleRate, + bitsBuffer.config.lc3plus_highres +#endif + ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Could not open split rend metadata file %s\n", args.outMetadataFilePath ); + exit( -1 ); + } + } +#endif + + if ( AudioFileWriter_open( &audioWriter, args.outputFilePath, args.sampleRate, numOutChannels ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Failed to open file: %s\n", args.outputFilePath ); + exit( -1 ); + } +#ifdef SPLIT_REND_WITH_HEAD_ROT } +#endif inBufferSize = frameSize_smpls * totalNumInChannels; outBufferSize = frameSize_smpls * numOutChannels; inpInt16Buffer = malloc( inBufferSize * sizeof( int16_t ) ); +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( cldfb_in_flag == 0 ) + { + inFloatBuffer = malloc( inBufferSize * sizeof( float ) ); + inBuffer.config.numSamplesPerChannel = (int16_t) frameSize_smpls; + outFloatBuffer = malloc( outBufferSize * sizeof( float ) ); + outBuffer.config.numSamplesPerChannel = (int16_t) frameSize_smpls; + } + else + { + inFloatBuffer = malloc( CLDFBframeSize_smpls * totalNumInChannels * sizeof( float ) ); + inBuffer.config.numSamplesPerChannel = (int16_t) CLDFBframeSize_smpls; + outFloatBuffer = malloc( CLDFBframeSize_smpls * totalNumInChannels * sizeof( float ) ); + outBuffer.config.numSamplesPerChannel = (int16_t) CLDFBframeSize_smpls; + } + outInt16Buffer = malloc( outBufferSize * sizeof( int16_t ) ); + + inBuffer.config.is_cldfb = cldfb_in_flag; + inBuffer.config.numChannels = (int16_t) totalNumInChannels; + inBuffer.data = inFloatBuffer; + + outBuffer.config.is_cldfb = cldfb_in_flag; + outBuffer.config.numChannels = (int16_t) numOutChannels; + outBuffer.data = outFloatBuffer; + + memset( outBuffer.data, 0, outBuffer.config.numSamplesPerChannel * outBuffer.config.numChannels * sizeof( float ) ); + + if ( is_split_pre_rend_mode( &args ) ) + { + bitsBufferSize = SPLIT_REND_BITS_BUFF_SIZE; + } + else + { + bitsBufferSize = 0; + } + + if ( bitsBufferSize > 0 ) + { + bitsBufferData = malloc( bitsBufferSize * sizeof( uint8_t ) ); + } + else + { + bitsBufferData = NULL; + } + + bitsBuffer.bits = bitsBufferData; + bitsBuffer.config.bitsRead = 0; + bitsBuffer.config.bitsWritten = 0; + bitsBuffer.config.bufLenInBytes = bitsBufferSize; +#else inFloatBuffer = malloc( inBufferSize * sizeof( float ) ); outInt16Buffer = malloc( outBufferSize * sizeof( int16_t ) ); outFloatBuffer = malloc( outBufferSize * sizeof( float ) ); @@ -1155,6 +1441,7 @@ int main( outBuffer.config.numSamplesPerChannel = (int16_t) frameSize_smpls; outBuffer.config.numChannels = (int16_t) numOutChannels; outBuffer.data = outFloatBuffer; +#endif #ifdef WMOPS reset_stack(); @@ -1179,6 +1466,8 @@ int main( num_in_channels = inBuffer.config.numChannels; const bool isCurrentFrameMultipleOf20ms = frame % ( 4 / args.render_framesize ) == 0; + numSamplesRead = 0; + /* Read the input data */ if ( ( error = AudioFileReader_read( audioReader, inpInt16Buffer, (int16_t) inBufferSize, &numSamplesRead ) ) != IVAS_ERR_OK ) { @@ -1186,14 +1475,18 @@ int main( exit( -1 ); } - if ( numSamplesRead == 0 && splitBinNeedsNewFrame ) + if ( numSamplesRead == 0 ) { /* end of input data */ break; } /* Convert from int to float and from interleaved to packed */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + convertInputBuffer( inpInt16Buffer, numSamplesRead, inBuffer.config.numSamplesPerChannel, num_in_channels, inFloatBuffer, inBuffer.config.is_cldfb, cldfbAna ); +#else convertInputBuffer( inpInt16Buffer, numSamplesRead, inBuffer.config.numSamplesPerChannel, num_in_channels, inFloatBuffer ); +#endif int16_t num_subframes, sf_idx; num_subframes = (int16_t) args.render_framesize; @@ -1251,7 +1544,11 @@ int main( exit( -1 ); } +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( error = IVAS_REND_SetHeadRotation( hIvasRend, headRot, Pos, DEFAULT_AXIS, sf_idx ) ) != IVAS_ERR_OK ) +#else if ( ( error = IVAS_REND_SetHeadRotation( hIvasRend, headRot, Pos, sf_idx ) ) != IVAS_ERR_OK ) +#endif { fprintf( stderr, "Error setting Head Rotation: %s\n", ivas_error_to_string( error ) ); exit( -1 ); @@ -1267,7 +1564,6 @@ int main( } } - /* Read from external orientation file if specified */ if ( externalOrientationFileReader != NULL ) { @@ -1408,23 +1704,49 @@ int main( } } - - if ( ( error = IVAS_REND_GetSamples( hIvasRend, outBuffer ) ) != IVAS_ERR_OK ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + { + if ( ( error = IVAS_REND_GetSplitBinauralBitstream( hIvasRend, outBuffer, &bitsBuffer ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) ); + exit( -1 ); + } + } + else { +#endif + if ( ( error = IVAS_REND_GetSamples( hIvasRend, outBuffer ) ) != IVAS_ERR_OK ) + { +#ifdef SPLIT_REND_WITH_HEAD_ROT + fprintf( stderr, "Error %s\n", ivas_error_to_string( error ) ); +#else fprintf( stderr, "Error in getting samples\n" ); - exit( -1 ); +#endif + exit( -1 ); + } +#ifdef SPLIT_REND_WITH_HEAD_ROT } +#endif int16_t num_out_channels; num_out_channels = outBuffer.config.numChannels; /* Convert from float to int and from packed to interleaved. * Values in outFloatBuffer are guaranteed to be within range INT16_MIN:INT16_MAX */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + convertOutputBuffer( outFloatBuffer, outBuffer.config.numSamplesPerChannel, num_out_channels, outInt16Buffer, cldfb_in_flag, cldfbSyn ); +#else convertOutputBuffer( outFloatBuffer, outBuffer.config.numSamplesPerChannel, num_out_channels, outInt16Buffer ); +#endif if ( delayNumSamples == -1 ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( args.delayCompensationEnabled && !is_split_pre_rend_mode( &args ) ) +#else if ( args.delayCompensationEnabled ) +#endif { if ( IVAS_REND_GetDelay( hIvasRend, &delayNumSamples, &delayTimeScale ) != IVAS_ERR_OK ) { @@ -1432,7 +1754,6 @@ int main( exit( -1 ); } - delayNumSamples_orig = delayNumSamples; } else @@ -1442,20 +1763,42 @@ int main( zeroPad = delayNumSamples; } - if ( delayNumSamples * num_out_channels < outBufferSize ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( is_split_pre_rend_mode( &args ) ) { - if ( AudioFileWriter_write( audioWriter, &outInt16Buffer[delayNumSamples * num_out_channels], outBufferSize - ( delayNumSamples * num_out_channels ) ) != IVAS_ERR_OK ) + if ( split_rend_write_bitstream_to_file( hSplitRendFileReadWrite, bitsBuffer.bits, &bitsBuffer.config.bitsRead, + &bitsBuffer.config.bitsWritten ) != IVAS_ERR_OK ) { - fprintf( stderr, "Error writing audio file %s\n", args.outputFilePath ); + fprintf( stderr, "\nUnable to write to bitstream file!\n" ); exit( -1 ); } - delayNumSamples = 0; } - else + + if ( audioWriter != NULL ) { - delayNumSamples -= (int16_t) ( outBufferSize / num_out_channels ); +#endif + if ( delayNumSamples * num_out_channels < outBufferSize ) + { + if ( AudioFileWriter_write( audioWriter, &outInt16Buffer[delayNumSamples * num_out_channels], outBufferSize - ( delayNumSamples * num_out_channels ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Error writing audio file %s\n", args.outputFilePath ); + exit( -1 ); + } + delayNumSamples = 0; + } + else + { + delayNumSamples -= (int16_t) ( outBufferSize / num_out_channels ); + } + +#ifdef SPLIT_REND_WITH_HEAD_ROT } + bitsBuffer.config.bitsRead = 0; + bitsBuffer.config.bitsWritten = 0; +#endif + + /* Write MASA metadata for MASA outputs */ if ( args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_MASA1 || args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_MASA2 ) { @@ -1559,23 +1902,30 @@ int main( } /* add zeros at the end to have equal length of synthesized signals */ - for ( zeroPadToWrite = zeroPad; zeroPadToWrite > frameSize_smpls; zeroPadToWrite -= frameSize_smpls ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( audioWriter != NULL ) { - memset( outInt16Buffer, 0, outBufferSize * sizeof( int16_t ) ); - if ( ( error = AudioFileWriter_write( audioWriter, outInt16Buffer, outBufferSize ) ) != IVAS_ERR_OK ) +#endif + for ( zeroPadToWrite = zeroPad; zeroPadToWrite > frameSize_smpls; zeroPadToWrite -= frameSize_smpls ) + { + memset( outInt16Buffer, 0, outBufferSize * sizeof( int16_t ) ); + if ( ( error = AudioFileWriter_write( audioWriter, outInt16Buffer, outBufferSize ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nOutput audio file writer error\n" ); + exit( -1 ); + } + } + + memset( outInt16Buffer, 0, zeroPadToWrite * outBuffer.config.numChannels * sizeof( int16_t ) ); + if ( ( error = AudioFileWriter_write( audioWriter, outInt16Buffer, zeroPadToWrite * outBuffer.config.numChannels ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nOutput audio file writer error\n" ); exit( -1 ); } + zeroPadToWrite = 0; +#ifdef SPLIT_REND_WITH_HEAD_ROT } - - memset( outInt16Buffer, 0, zeroPadToWrite * outBuffer.config.numChannels * sizeof( int16_t ) ); - if ( ( error = AudioFileWriter_write( audioWriter, outInt16Buffer, zeroPadToWrite * outBuffer.config.numChannels ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nOutput audio file writer error\n" ); - exit( -1 ); - } - zeroPadToWrite = 0; +#endif if ( args.inConfig.numAudioObjects != 0 && ( args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL || args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) @@ -1607,11 +1957,28 @@ int main( free( inFloatBuffer ); free( outInt16Buffer ); free( outFloatBuffer ); + + +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( bitsBufferData != NULL ) + { + free( bitsBufferData ); + } +#endif for ( i = 0; i < RENDERER_MAX_MASA_INPUTS; ++i ) { MasaFileReader_close( &masaReaders[i] ); } +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( cldfb_in_flag ) + { + IVAS_REND_closeCldfb( cldfbAna, cldfbSyn ); + } + + split_rend_reader_writer_close( &hSplitRendFileReadWrite ); + SplitRendBFIFileReader_close( &splitRendBFIReader ); +#endif for ( i = 0; i < RENDERER_MAX_MC_INPUTS; ++i ) { @@ -1623,6 +1990,7 @@ int main( RotationFileReader_close( &headRotReader ); RotationFileReader_close( &externalOrientationFileReader ); RotationFileReader_close( &referenceRotReader ); + Vector3PairFileReader_close( &referenceVectorReader ); hrtfFileReader_close( &hrtfFileReader ); IVAS_REND_Close( &hIvasRend ); @@ -1914,8 +2282,13 @@ static bool parseOrientationTracking( static IVAS_AUDIO_CONFIG parseAudioConfig( const char *configString ) { +#ifndef SPLIT_REND_WITH_HEAD_ROT char charBuf[21]; charBuf[20] = '\0'; +#else + char charBuf[25]; + charBuf[24] = '\0'; +#endif strncpy( charBuf, configString, sizeof( charBuf ) - 1 ); charBuf[sizeof( charBuf ) - 1] = '\0'; @@ -1990,6 +2363,16 @@ static IVAS_AUDIO_CONFIG parseAudioConfig( { return IVAS_AUDIO_CONFIG_BINAURAL; } +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( strcmp( charBuf, "BINAURAL_SPLIT_PCM" ) == 0 ) + { + return IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM; + } + if ( strcmp( charBuf, "BINAURAL_SPLIT_CODED" ) == 0 ) + { + return IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED; + } +#endif if ( strcmp( charBuf, "BINAURAL_ROOM_IR" ) == 0 ) { return IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR; @@ -2122,6 +2505,10 @@ static CmdlnArgs defaultArgs( args.numInMetadataFiles = 0; clearString( args.headRotationFilePath ); +#ifdef SPLIT_REND_WITH_HEAD_ROT + clearString( args.outMetadataFilePath ); + clearString( args.splitRendBFIFilePath ); +#endif clearString( args.referenceVectorFilePath ); clearString( args.referenceRotationFilePath ); clearString( args.customHrtfFilePath ); @@ -2214,6 +2601,16 @@ static void parseOption( assert( numOptionValues == 1 ); strncpy( args->headRotationFilePath, optionValues[0], RENDERER_MAX_CLI_ARG_LENGTH - 1 ); break; +#ifdef SPLIT_REND_WITH_HEAD_ROT + case CmdLnOptionId_outputMetadata: + assert( numOptionValues == 1 ); + strncpy( args->outMetadataFilePath, optionValues[0], RENDERER_MAX_CLI_ARG_LENGTH - 1 ); + break; + case CmdLnOptionId_SplitRendBFIFile: + assert( numOptionValues == 1 ); + strncpy( args->splitRendBFIFilePath, optionValues[0], RENDERER_MAX_CLI_ARG_LENGTH - 1 ); + break; +#endif case CmdLnOptionId_referenceVectorFile: assert( numOptionValues == 1 ); strncpy( args->referenceVectorFilePath, optionValues[0], RENDERER_MAX_CLI_ARG_LENGTH - 1 ); @@ -3216,6 +3613,10 @@ static void printSupportedAudioConfigs( void ) "ISMx (input only)", "MASAx", "BINAURAL (output only)", +#ifdef SPLIT_REND_WITH_HEAD_ROT + "BINAURAL_SPLIT_PCM", + "BINAURAL_SPLIT_CODED", +#endif "BINAURAL_ROOM_IR (output only)", "BINAURAL_ROOM_REVERB (output only)", }; @@ -3312,28 +3713,80 @@ static void convertInputBuffer( const int16_t numIntSamplesPerChannel, const int16_t numFloatSamplesPerChannel, const int16_t numChannels, - float *floatBuffer ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + float *floatBuffer, + const int16_t cldfb_in_flag, + IVAS_CLDFB_FILTER_BANK_HANDLE *cldfbAna +#else + float *floatBuffer +#endif +) { int16_t chnl, smpl, i; i = 0; - for ( smpl = 0; smpl < numFloatSamplesPerChannel; ++smpl ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( cldfb_in_flag ) { - for ( chnl = 0; chnl < numChannels; ++chnl ) + int16_t slotIdx, numCldfbBands, numFloatPcmSamples; + float fIn[IVAS_MAX_OUTPUT_CHANNELS][IVAS_MAX_FRAME_SIZE]; + + numFloatPcmSamples = numFloatSamplesPerChannel >> 1; + numCldfbBands = numFloatPcmSamples / IVAS_CLDFB_NO_COL_MAX; + + /* CLDFB Analysis*/ + assert( numIntSamplesPerChannel <= IVAS_MAX_OUTPUT_CHANNELS * IVAS_MAX_FRAME_SIZE ); + for ( smpl = 0; smpl < numFloatPcmSamples; ++smpl ) { - if ( i < numIntSamplesPerChannel ) + for ( chnl = 0; chnl < numChannels; ++chnl ) { - floatBuffer[chnl * numFloatSamplesPerChannel + smpl] = (float) intBuffer[i]; + if ( i < numIntSamplesPerChannel ) + { + fIn[chnl][smpl] = (float) intBuffer[i]; + } + else + { + fIn[chnl][smpl] = 0.f; + } + + ++i; } - else + } + + for ( chnl = 0; chnl < numChannels; ++chnl ) + { + for ( slotIdx = 0; slotIdx < IVAS_CLDFB_NO_COL_MAX; slotIdx++ ) { - floatBuffer[chnl * numFloatSamplesPerChannel + smpl] = 0.f; + IVAS_REND_cldfbAnalysis_ts_wrapper( &fIn[chnl][numCldfbBands * slotIdx], + &floatBuffer[( chnl * numFloatSamplesPerChannel ) + ( 2 * slotIdx * numCldfbBands )], + &floatBuffer[numCldfbBands + ( chnl * numFloatSamplesPerChannel ) + ( 2 * slotIdx * numCldfbBands )], + numCldfbBands, cldfbAna[chnl] ); } + } + } + else + { +#endif + for ( smpl = 0; smpl < numFloatSamplesPerChannel; ++smpl ) + { + for ( chnl = 0; chnl < numChannels; ++chnl ) + { + if ( i < numIntSamplesPerChannel ) + { + floatBuffer[chnl * numFloatSamplesPerChannel + smpl] = (float) intBuffer[i]; + } + else + { + floatBuffer[chnl * numFloatSamplesPerChannel + smpl] = 0.f; + } - ++i; + ++i; + } } +#ifdef SPLIT_REND_WITH_HEAD_ROT } +#endif return; } @@ -3349,32 +3802,92 @@ static void convertOutputBuffer( const float *floatBuffer, const int16_t numSamplesPerChannel, const int16_t numChannels, - int16_t *intBuffer ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + int16_t *intBuffer, + const int16_t cldfb_in_flag, + IVAS_CLDFB_FILTER_BANK_HANDLE *cldfbSyn +#else + int16_t *intBuffer +#endif +) { int16_t chnl, smpl, i; float temp; i = 0; - for ( smpl = 0; smpl < numSamplesPerChannel; ++smpl ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( cldfb_in_flag ) { + int16_t slotIdx, numCldfbBands, numPcmSamples, b; + float fIn[IVAS_MAX_OUTPUT_CHANNELS][IVAS_MAX_FRAME_SIZE]; + float re[IVAS_MAX_OUTPUT_CHANNELS][IVAS_CLDFB_NO_COL_MAX][IVAS_CLDFB_NO_CHANNELS_MAX]; + float im[IVAS_MAX_OUTPUT_CHANNELS][IVAS_CLDFB_NO_COL_MAX][IVAS_CLDFB_NO_CHANNELS_MAX]; + + numPcmSamples = numSamplesPerChannel >> 1; + numCldfbBands = numPcmSamples / IVAS_CLDFB_NO_COL_MAX; + + /* CLDFB Synthesis*/ for ( chnl = 0; chnl < numChannels; ++chnl ) { - temp = floatBuffer[chnl * numSamplesPerChannel + smpl]; - temp = (float) floor( temp + 0.5f ); - if ( temp > IVAS_MAX16B_FLT ) + for ( slotIdx = 0; slotIdx < IVAS_CLDFB_NO_COL_MAX; slotIdx++ ) { - temp = IVAS_MAX16B_FLT; + for ( b = 0; b < numCldfbBands; b++ ) + { + re[chnl][slotIdx][b] = floatBuffer[( chnl * numSamplesPerChannel ) + ( 2 * slotIdx * numCldfbBands ) + b]; + im[chnl][slotIdx][b] = floatBuffer[numCldfbBands + ( chnl * numSamplesPerChannel ) + ( 2 * slotIdx * numCldfbBands ) + b]; + } } - else if ( temp < IVAS_MIN16B_FLT ) + } + + /* Implement CLDFB synthesis */ + for ( chnl = 0; chnl < numChannels; ++chnl ) + { + float *RealBuffer[IVAS_CLDFB_NO_COL_MAX]; + float *ImagBuffer[IVAS_CLDFB_NO_COL_MAX]; + + for ( slotIdx = 0; slotIdx < IVAS_CLDFB_NO_COL_MAX; slotIdx++ ) { - temp = IVAS_MIN16B_FLT; + RealBuffer[slotIdx] = re[chnl][slotIdx]; + ImagBuffer[slotIdx] = im[chnl][slotIdx]; } - intBuffer[i] = (int16_t) temp; - ++i; + IVAS_REND_cldfbSynthesis_wrapper( RealBuffer, ImagBuffer, &( fIn[chnl][0] ), numCldfbBands * IVAS_CLDFB_NO_COL_MAX, cldfbSyn[chnl] ); } + for ( smpl = 0; smpl < numPcmSamples; ++smpl ) + { + for ( chnl = 0; chnl < numChannels; ++chnl ) + { + intBuffer[i] = (int16_t) roundf( fIn[chnl][smpl] ); + ++i; + } + } + } + else + { +#endif + for ( smpl = 0; smpl < numSamplesPerChannel; ++smpl ) + { + for ( chnl = 0; chnl < numChannels; ++chnl ) + { + temp = floatBuffer[chnl * numSamplesPerChannel + smpl]; + temp = (float) floor( temp + 0.5f ); + if ( temp > IVAS_MAX16B_FLT ) + { + temp = IVAS_MAX16B_FLT; + } + else if ( temp < IVAS_MIN16B_FLT ) + { + temp = IVAS_MIN16B_FLT; + } + intBuffer[i] = (int16_t) temp; + + ++i; + } + } +#ifdef SPLIT_REND_WITH_HEAD_ROT } +#endif return; } diff --git a/lib_com/ACcontextMapping.c b/lib_com/ACcontextMapping.c index 1705a3f7d353a66d075e8aedba7e096bbf8e241f..f9bdeaaee7b2805cca61fced5ca99f91aa2fd9d6 100644 --- a/lib_com/ACcontextMapping.c +++ b/lib_com/ACcontextMapping.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ari.c b/lib_com/ari.c index 2ee0be62310edc98d315593d6f269ca2529a6423..2aea344e50a42d4291b50cced5deaa4576305dff 100644 --- a/lib_com/ari.c +++ b/lib_com/ari.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ari_hm.c b/lib_com/ari_hm.c index 3995913c43f7bfefb31276a0787aa0200b20ff6b..0bd7b144fdd821f5ec74e19843c64ec410406dc3 100644 --- a/lib_com/ari_hm.c +++ b/lib_com/ari_hm.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/arith_coder.c b/lib_com/arith_coder.c index cc29c97477c0092860be5ea30582d716097fe805..e71a40749e81ffff546e77fe4159e8e0969a3401 100644 --- a/lib_com/arith_coder.c +++ b/lib_com/arith_coder.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/basop32.c b/lib_com/basop32.c index a407ff72d40b0fcd774572f770b764b254fa88e0..5a5a434846333bbcc752cf8e1e0dbcfa5ab08241 100644 --- a/lib_com/basop32.c +++ b/lib_com/basop32.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/basop32.h b/lib_com/basop32.h index f1a7e1b8646ffb8d13fa33090acc23f218575732..a8a72aed04825925a8ce418730d929c571b70203 100644 --- a/lib_com/basop32.h +++ b/lib_com/basop32.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/basop_com_lpc.c b/lib_com/basop_com_lpc.c index 442afe554c1e02eeaa23c7b5e5370018c806ce8f..68376669b6072ba5c509a371b94e25194dde1b70 100644 --- a/lib_com/basop_com_lpc.c +++ b/lib_com/basop_com_lpc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/basop_lsf_tools.c b/lib_com/basop_lsf_tools.c index 103fe7000207e24f8ef78003bfb965b32a55b9ed..498018c1eea64571bcf8eecbcf8c694a197b55ab 100644 --- a/lib_com/basop_lsf_tools.c +++ b/lib_com/basop_lsf_tools.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/basop_mpy.c b/lib_com/basop_mpy.c index db2a14c0b08d33792d79ebb389e3f6ac468c54e5..c3acce57376cd7343503dcf159d0314e8661c7bd 100644 --- a/lib_com/basop_mpy.c +++ b/lib_com/basop_mpy.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/basop_mpy.h b/lib_com/basop_mpy.h index 4a8d4473c65b7d2df22393ac2f75de4c1479101f..dd9a3ec31312893b8daf2bdf4f05d39b05054a53 100644 --- a/lib_com/basop_mpy.h +++ b/lib_com/basop_mpy.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/basop_proto_func.h b/lib_com/basop_proto_func.h index 0c514475f324d6a587142fb07f75d6648a816986..69e76fec90ffed560c9bb60f31dd4f46925658ea 100644 --- a/lib_com/basop_proto_func.h +++ b/lib_com/basop_proto_func.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/basop_settings.h b/lib_com/basop_settings.h index 758a99650cea4a0a7c0fc7ca59c4bab70953dbf0..bcbe6fdf1a98d4e4fcaa16f6524919b82825fc90 100644 --- a/lib_com/basop_settings.h +++ b/lib_com/basop_settings.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/basop_tcx_utils.c b/lib_com/basop_tcx_utils.c index 6d2c80f6b74c3cc635e40226eeb756e676faee0c..f684f07ee5ef4a2241db0d985766c2c3508a239d 100644 --- a/lib_com/basop_tcx_utils.c +++ b/lib_com/basop_tcx_utils.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/basop_util.c b/lib_com/basop_util.c index 0a168852b0a95b8cbc243a9563d19e9bf06a9907..197fe884082c1c57d3a8b56b9da51875bc1002a9 100644 --- a/lib_com/basop_util.c +++ b/lib_com/basop_util.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/basop_util.h b/lib_com/basop_util.h index c09b8ea62ca4e8321ef2227978afb9df7aac680d..b76d5982f23fec7be3bd0b8ac7680b283dd75da1 100644 --- a/lib_com/basop_util.h +++ b/lib_com/basop_util.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/bitalloc.c b/lib_com/bitalloc.c index e560e300a1c7e9a94dd990010905be6f2f500a45..28715d184c0e24c403a492f31424a18160df7fd2 100644 --- a/lib_com/bitalloc.c +++ b/lib_com/bitalloc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/bitallocsum.c b/lib_com/bitallocsum.c index d3f880752d9bb05ef5a823cd574835946bdf5b42..583383896eb45fb3f41815827a0873e76faadbd2 100644 --- a/lib_com/bitallocsum.c +++ b/lib_com/bitallocsum.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/bits_alloc.c b/lib_com/bits_alloc.c index cb3945a6ce41d683081b5c60a8eb523438f7b39c..7a1832bffb7c2d8b2c3a00d0da7626a78e00b3dc 100644 --- a/lib_com/bits_alloc.c +++ b/lib_com/bits_alloc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other @@ -531,17 +531,20 @@ static ivas_error acelp_FCB_allocator( *--------------------------------------------------------------------*/ ivas_error config_acelp1( - const int16_t enc_dec, /* i : encoder/decoder flag */ - const int32_t total_brate, /* i : total bitrate */ - const int32_t core_brate_inp, /* i : core bitrate */ - const int16_t core, /* i : core */ - const int16_t extl, /* i : extension layer */ - const int32_t extl_brate, /* i : extension layer bitrate */ - const int16_t L_frame, /* i : frame length at internal Fs */ - const int16_t GSC_noisy_speech, /* i : GSC on SWB noisy speech flag */ - ACELP_config *acelp_cfg, /* i : ACELP bit-allocation */ - const int16_t signaling_bits, /* i : number of signaling bits */ - const int16_t coder_type, /* i : coder type */ + const int16_t enc_dec, /* i : encoder/decoder flag */ + const int32_t total_brate, /* i : total bitrate */ + const int32_t core_brate_inp, /* i : core bitrate */ + const int16_t core, /* i : core */ + const int16_t extl, /* i : extension layer */ + const int32_t extl_brate, /* i : extension layer bitrate */ + const int16_t L_frame, /* i : frame length at internal Fs */ + const int16_t GSC_noisy_speech, /* i : GSC on SWB noisy speech flag */ + ACELP_config *acelp_cfg, /* i : ACELP bit-allocation */ + const int16_t signaling_bits, /* i : number of signaling bits */ + const int16_t coder_type, /* i : coder type */ +#ifdef NONBE_FIX_GSC_BSTR + const int16_t inactive_coder_type_flag, /* i : AVQ (0) or GSC (1) IC flag */ +#endif const int16_t tc_subfr, /* i : TC subfr ID */ const int16_t tc_call, /* i : TC call number (0,1,2,3,5(DEC)) */ int16_t *nBits_es_Pred, /* o : number of bits for Es_pred Q */ @@ -775,7 +778,13 @@ ivas_error config_acelp1( } /* gain Q bit-budget - part 1 */ +#ifdef NONBE_FIX_GSC_BSTR + if ( ( coder_type != UNVOICED && coder_type != AUDIO && coder_type != INACTIVE && !( core_brate <= ACELP_8k00 && coder_type != TRANSITION ) ) /* mid bitrates in GC and VC, low+mid bitrates in TC */ || + ( coder_type == INACTIVE && !inactive_coder_type_flag ) /* AVQ inactive */ + ) +#else if ( ( coder_type != UNVOICED && coder_type != AUDIO && coder_type != INACTIVE && !( core_brate <= ACELP_8k00 && coder_type != TRANSITION ) ) || ( coder_type == INACTIVE && total_brate > MAX_GSC_INACTIVE_BRATE ) ) +#endif { *nBits_es_Pred = Es_pred_bits_tbl[BIT_ALLOC_IDX( core_brate, coder_type, -1, -1 )]; bits -= *nBits_es_Pred; @@ -868,7 +877,11 @@ ivas_error config_acelp1( } else if ( core_brate >= ACELP_11k60 && ( coder_type != AUDIO && !( coder_type == INACTIVE && L_frame == L_FRAME ) ) ) { +#ifdef NONBE_FIX_GSC_BSTR + if ( coder_type == INACTIVE && L_frame == L_FRAME16k && inactive_coder_type_flag ) /* GSC Inactive @16kHz */ +#else if ( coder_type == INACTIVE && L_frame == L_FRAME16k && total_brate <= MAX_GSC_INACTIVE_BRATE ) /* GSC Inactive @16kHz */ +#endif { acelp_cfg->ltf_mode = FULL_BAND; } @@ -1052,7 +1065,13 @@ ivas_error config_acelp1( acelp_cfg->fixed_cdk_index[2] = -1; acelp_cfg->fixed_cdk_index[3] = -1; } +#ifdef NONBE_FIX_GSC_BSTR + else if ( ( coder_type != INACTIVE && nb_subfr == NB_SUBFR && coder_type != AUDIO ) || /* @12.8kHz core except of GSC */ + ( nb_subfr == NB_SUBFR16k && ( !inactive_coder_type_flag || coder_type != INACTIVE ) ) /* @16kHz core GC, TC, AVQ inactive */ + || core == HQ_CORE /* ACELP -> HQ switching in EVS */ ) +#else else if ( ( coder_type != INACTIVE && nb_subfr == NB_SUBFR && coder_type != AUDIO ) || ( nb_subfr == NB_SUBFR16k && ( total_brate > MAX_GSC_INACTIVE_BRATE || coder_type != INACTIVE ) ) || core == HQ_CORE ) +#endif { /* pitch Q & gain Q bit-budget - part 2*/ for ( i = 0; i < nb_subfr; i++ ) @@ -1100,7 +1119,13 @@ ivas_error config_acelp1( } /* algebraic codebook bit-budget */ +#ifdef NONBE_FIX_GSC_BSTR + if ( flag_hardcoded || /* EVS */ + ( core_brate_inp >= MIN_BRATE_AVQ_EXC && coder_type != INACTIVE ) /* high-birate ACELP except IC */ || + ( !inactive_coder_type_flag && coder_type == INACTIVE ) /* AVQ inactive */ ) +#else if ( flag_hardcoded || ( core_brate_inp >= MIN_BRATE_AVQ_EXC && coder_type != INACTIVE ) || ( total_brate > MAX_GSC_INACTIVE_BRATE && coder_type == INACTIVE ) ) +#endif { for ( i = 0; i < nb_subfr; i++ ) { @@ -1187,7 +1212,12 @@ ivas_error config_acelp1( } /* AVQ codebook */ +#ifdef NONBE_FIX_GSC_BSTR + if ( ( core_brate_inp >= MIN_BRATE_AVQ_EXC && coder_type != INACTIVE ) /* high-birate ACELP except IC */ || + ( !inactive_coder_type_flag && coder_type == INACTIVE ) /* AVQ inactive */ ) +#else if ( ( core_brate_inp >= MIN_BRATE_AVQ_EXC && coder_type != INACTIVE ) || ( total_brate > MAX_GSC_INACTIVE_BRATE && coder_type == INACTIVE ) ) +#endif { for ( i = 0; i < nb_subfr; i++ ) { @@ -1222,7 +1252,13 @@ ivas_error config_acelp1( } } } +#ifdef NONBE_FIX_GSC_BSTR + else if ( ( coder_type == UNVOICED && tdm_low_rate_mode == 1 && element_mode == IVAS_CPE_TD ) /* LBR secondary channel in TD stereo */ || + ( ( coder_type == INACTIVE || coder_type == AUDIO ) && nb_subfr == NB_SUBFR ) /* GSC @12.8kHz */ || + ( coder_type == INACTIVE && inactive_coder_type_flag ) /* AVQ inactive */ ) +#else else if ( ( coder_type == UNVOICED && tdm_low_rate_mode == 1 && element_mode == IVAS_CPE_TD ) || ( ( coder_type == INACTIVE || coder_type == AUDIO ) && nb_subfr == NB_SUBFR ) || ( coder_type == INACTIVE && total_brate <= MAX_GSC_INACTIVE_BRATE ) ) +#endif { int32_t Local_BR, Pitch_BR; int16_t Pitch_CT; @@ -1315,7 +1351,12 @@ ivas_error config_acelp1( /* sanity check */ if ( ( coder_type != INACTIVE && nb_subfr == NB_SUBFR && coder_type != AUDIO ) || nb_subfr == NB_SUBFR16k ) { +#ifdef NONBE_FIX_GSC_BSTR + if ( ( L_frame == L_FRAME16k && coder_type == INACTIVE && inactive_coder_type_flag ) /* GSC Inactive @16kHz */ || + ( GSC_IVAS_mode > 0 && L_frame == L_FRAME16k ) ) /* IVAS GSC @16kHz */ +#else if ( ( L_frame == L_FRAME16k && coder_type == INACTIVE && total_brate <= MAX_GSC_INACTIVE_BRATE ) || ( GSC_IVAS_mode > 0 && L_frame == L_FRAME16k ) ) /* GSC Inactive @16kHz */ +#endif { acelp_cfg->ubits = 0; } diff --git a/lib_com/bitstream.c b/lib_com/bitstream.c index 4a24d905a89923cc381917f38b919cc9c1260d84..2231dfd10ffa41e65f0037abb29048800fcbb200 100644 --- a/lib_com/bitstream.c +++ b/lib_com/bitstream.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/calc_st_com.c b/lib_com/calc_st_com.c index 2f2cc56333ef7799daa532fc45d58fa77711878e..bfe954af39a6703992e98c3f4095bea43c9b9634 100644 --- a/lib_com/calc_st_com.c +++ b/lib_com/calc_st_com.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/cb_shape.c b/lib_com/cb_shape.c index 364ed639f323b294b764f924d7c69f572d1695f1..45c88b1e98b5b5a886be1050cee4c17e00f534a4 100644 --- a/lib_com/cb_shape.c +++ b/lib_com/cb_shape.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/cldfb.c b/lib_com/cldfb.c index 1490703aeed53e88f6c690fa27b9118425d87ca0..649e5ba5229d57b27cfa9dd3ff1fc29226725963 100644 --- a/lib_com/cldfb.c +++ b/lib_com/cldfb.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/cng_exc.c b/lib_com/cng_exc.c index 9f0a22320e8732322a1d2580499534d0dbca8544..c631d8d11641d52868381b65910d9c737fe4ee42 100644 --- a/lib_com/cng_exc.c +++ b/lib_com/cng_exc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/cnst.h b/lib_com/cnst.h index 556da0d14196131be5b7eb2fb21dde24c2a7236d..c7fb691fa2bb1bff08be971ca84720a37be48485 100644 --- a/lib_com/cnst.h +++ b/lib_com/cnst.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other @@ -750,6 +750,10 @@ typedef enum #define GAIN_PRED_ORDER 4 /* Gain quantization - prediction order for gain quantizer (only for AMR-WB IO mode) */ #define MEAN_ENER 30 /* Gain quantization - average innovation energy */ +#ifdef NONBE_FIX_1277_EVS_DTX_HIGH_RATE_THRESHOLD +#define DTX_THR 5 /* DTX - lp_noise threshold for DTX at higher bitrates */ +#endif + #define DTX_HIST_SIZE 8 /* CNG & DTX - number of last signal frames used for CNG averaging */ #define CNG_ISF_FACT 0.9f /* CNG & DTX - CNG spectral envelope smoothing factor */ #define STEP_AMR_WB_SID 2.625f /* CNG & DTX - CNG energy quantization step */ diff --git a/lib_com/codec_tcx_common.c b/lib_com/codec_tcx_common.c index 7bb6dac40bb4b5d40bc869e53047fbcbc55e5db9..d4822e166e6c649dbeeada776453e34da1cf4dac 100644 --- a/lib_com/codec_tcx_common.c +++ b/lib_com/codec_tcx_common.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/common_api_types.h b/lib_com/common_api_types.h index 2152ca30a509aca2c29c445e46d6e929fe8cf36b..49d0c64d6c328bcbb3eff4f2fc998a90c336ca92 100644 --- a/lib_com/common_api_types.h +++ b/lib_com/common_api_types.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other @@ -57,6 +57,12 @@ #define IVAS_MAX_PARAM_SPATIAL_SUBFRAMES 4 #define IVAS_ROOM_ABS_COEFF 6 +/* Maximum buffer length (per channel) in samples */ +#define MAX_BUFFER_LENGTH_PER_CHANNEL ( L_FRAME48k ) + +/* Frame size required when rendering to binaural */ +#define BINAURAL_RENDERING_FRAME_SIZE_MS 5 + /*----------------------------------------------------------------------------------* * Common API enum for output audio configurations *----------------------------------------------------------------------------------*/ @@ -195,6 +201,96 @@ typedef struct _IVAS_JBM_TRACE_DATA } IVAS_JBM_TRACE_DATA; +#ifdef SPLIT_REND_WITH_HEAD_ROT +/*----------------------------------------------------------------------------------* + * Split rendering API constants, structures, and enums + *----------------------------------------------------------------------------------*/ + +#define ISAR_MAX_SPLIT_REND_BITRATE 768000 +#define ISAR_MAX_SPLIT_REND_BITS_BUFFER_SIZE_IN_BYTES ( ( ( (int32_t) ISAR_MAX_SPLIT_REND_BITRATE / IVAS_NUM_FRAMES_PER_SEC ) + 7 ) >> 3 ) +#define ISAR_SPLIT_REND_ADDITIONAL_BYTES_TO_READ 1 +#define SPLIT_REND_BITS_BUFF_SIZE ( ISAR_MAX_SPLIT_REND_BITS_BUFFER_SIZE_IN_BYTES + ISAR_SPLIT_REND_ADDITIONAL_BYTES_TO_READ ) + +typedef enum +{ + DEFAULT_AXIS, + YAW, + PITCH, + ROLL, + YAW_PITCH, + YAW_ROLL, + PITCH_ROLL + +} ISAR_SPLIT_REND_ROT_AXIS; + +typedef enum +{ + ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE, + ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB, + +} ISAR_SPLIT_REND_POSE_CORRECTION_MODE; + +typedef enum +{ + ISAR_SPLIT_REND_CODEC_LCLD, + ISAR_SPLIT_REND_CODEC_LC3PLUS, + ISAR_SPLIT_REND_CODEC_DEFAULT, /* Will use LCLD for CLDFB rendering paths and LC3plus for TD rendering paths */ + ISAR_SPLIT_REND_CODEC_NONE + +} ISAR_SPLIT_REND_CODEC; + +typedef enum +{ + ISAR_SPLIT_REND_RENDERER_SELECTION_CREND, + ISAR_SPLIT_REND_RENDERER_SELECTION_FASTCONV, + ISAR_SPLIT_REND_RENDERER_SELECTION_PARAMBIN, + ISAR_SPLIT_REND_RENDERER_SELECTION_TDREND, + ISAR_SPLIT_REND_RENDERER_SELECTION_DEFAULT, + +} ISAR_SPLIT_REND_RENDERER_SELECTION; + +typedef struct _ISAR_SPLIT_REND_BITS_DATA +{ + uint8_t *bits_buf; + int32_t buf_len; /*size of bits_buf in bytes. This field should be set by allocator of bits_buf*/ + int32_t bits_written; + int32_t bits_read; + int16_t codec_frame_size_ms; + ISAR_SPLIT_REND_CODEC codec; + ISAR_SPLIT_REND_POSE_CORRECTION_MODE pose_correction; +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + int16_t isar_frame_size_ms; + int16_t lc3plus_highres; +#endif + +} ISAR_SPLIT_REND_BITS_DATA, *ISAR_SPLIT_REND_BITS_HANDLE; + +typedef struct _ISAR_SPLIT_REND_CONFIG +{ + int32_t splitRendBitRate; /*Bit rate for split rendering mode, if "pcm_out" is set then "splitRendBitRate" is used as a limit for MD bitrate */ + int16_t hq_mode; /*High quality 3DOF mode with additional side information. Requires more pre-renditions. */ + int16_t dof; /*flag to specify if pose correction is needed for 1, 2 or 3 degree of freedoms*/ + /*The axis can be set dynamically per frame based on a file input */ + /*possible values: + 1 - (1dof correction. By default YAW correction) + 2 - (2dof correction. By default YAW and PITCH correction) + 3 - (3dof correction. By default YAW, PITCH and ROLL correction) + */ + int16_t codec_delay_ms; /*PLACEHOLDER (currently being ignored) : look ahead delay of the codec that is used to code BIN signal output of pre-renderer*/ +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + int16_t isar_frame_size_ms; /* ISAR bit stream frame size in milliseconds */ +#endif + int16_t codec_frame_size_ms; /* Codec frame size in milliseconds, only relevant with LC3plus */ + ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrectionMode; + ISAR_SPLIT_REND_CODEC codec; + ISAR_SPLIT_REND_RENDERER_SELECTION rendererSelection; +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + int16_t lc3plus_highres; +#endif + +} ISAR_SPLIT_REND_CONFIG_DATA, *ISAR_SPLIT_REND_CONFIG_HANDLE; +#endif + /*----------------------------------------------------------------------------------* * Renderer API structures and enums *----------------------------------------------------------------------------------*/ @@ -234,8 +330,26 @@ typedef struct _IVAS_RENDER_CONFIG IVAS_RENDER_TYPE_OVERRIDE renderer_type_override; #endif IVAS_ROOM_ACOUSTICS_CONFIG_DATA roomAcoustics; +#ifdef SPLIT_REND_WITH_HEAD_ROT + ISAR_SPLIT_REND_CONFIG_DATA split_rend_config; +#endif float directivity[IVAS_MAX_NUM_OBJECTS * 3]; } IVAS_RENDER_CONFIG_DATA, *IVAS_RENDER_CONFIG_HANDLE; +typedef struct +{ + int16_t numSamplesPerChannel; + int16_t numChannels; +#ifdef SPLIT_REND_WITH_HEAD_ROT + int16_t is_cldfb; +#endif +} IVAS_REND_AudioBufferConfig; + +typedef struct +{ + IVAS_REND_AudioBufferConfig config; + float *data; +} IVAS_REND_AudioBuffer; + #endif /* COMMON_API_TYPES_H */ diff --git a/lib_com/core_com_config.c b/lib_com/core_com_config.c index 0ee9b40ae09e458616a1d87ab84898f087ca08e4..a5158b0b37bf81d9790c7473e9a5cb0fca9e7911 100644 --- a/lib_com/core_com_config.c +++ b/lib_com/core_com_config.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/deemph.c b/lib_com/deemph.c index 9f4463d6a820cb6ebeb4a170b3e7ab56008c20c6..ea6145813cff83f4759600f0ec72d62337fd37f3 100644 --- a/lib_com/deemph.c +++ b/lib_com/deemph.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/delay_comp.c b/lib_com/delay_comp.c index 0075e5106ea2828918114ca8bbeb8ad129cf5a58..1ab401c3ab2056c0d1ee8b0c0614d455d6ef1dde 100644 --- a/lib_com/delay_comp.c +++ b/lib_com/delay_comp.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other @@ -51,10 +51,15 @@ /*! r: delay value in ns */ int32_t get_delay( - const int16_t enc_dec, /* i : encoder/decoder flag */ - const int32_t io_fs, /* i : input/output sampling frequency */ - const IVAS_FORMAT ivas_format, /* i : IVAS format */ + const int16_t enc_dec, /* i : encoder/decoder flag */ + const int32_t io_fs, /* i : input/output sampling frequency */ + const IVAS_FORMAT ivas_format, /* i : IVAS format */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + HANDLE_CLDFB_FILTER_BANK hCldfb, /* i : Handle of Cldfb analysis */ + const AUDIO_CONFIG output_config /* i : decoder output config */ +#else HANDLE_CLDFB_FILTER_BANK hCldfb /* i : Handle of Cldfb analysis */ +#endif ) { int32_t delay = 0; @@ -97,11 +102,18 @@ int32_t get_delay( { delay = IVAS_DEC_DELAY_NS; - if ( hCldfb != NULL ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( output_config != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) { - /* compensate for filterbank delay */ - delay += IVAS_FB_DEC_DELAY_NS; +#endif + if ( hCldfb != NULL ) + { + /* compensate for filterbank delay */ + delay += IVAS_FB_DEC_DELAY_NS; + } +#ifdef SPLIT_REND_WITH_HEAD_ROT } +#endif if ( ivas_format == MASA_FORMAT || ivas_format == MASA_ISM_FORMAT ) { diff --git a/lib_com/disclaimer.c b/lib_com/disclaimer.c index 5587bdd090f72b558a14d5356b3e027ab168f98f..451dd43e898dbe6d364ad47e2853ba2daebf0d77 100644 --- a/lib_com/disclaimer.c +++ b/lib_com/disclaimer.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/dlpc_bfi.c b/lib_com/dlpc_bfi.c index b894b845f803c57392987fba058d2d1b74d74b68..b5ea583003f1b4ffb0f8b50c4d7f9b28bf769d36 100644 --- a/lib_com/dlpc_bfi.c +++ b/lib_com/dlpc_bfi.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/edct.c b/lib_com/edct.c index 6f6d6c32b65d0d7c5c671865cf8aeb419852676b..d7af669c6598d25ec74b5d5d05af7d5fe667f7a5 100644 --- a/lib_com/edct.c +++ b/lib_com/edct.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/enh1632.c b/lib_com/enh1632.c index 4e53ba695ef8685f163abaa25869a35cfb4edc5c..33b2662c6f71e5c8d27313a8b6633ecda0d67993 100644 --- a/lib_com/enh1632.c +++ b/lib_com/enh1632.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/enh1632.h b/lib_com/enh1632.h index 8e943d42f07c872a607517aa3b202a4985486831..f0062dada483d293ea02f283edf75aa519a90f49 100644 --- a/lib_com/enh1632.h +++ b/lib_com/enh1632.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/enh40.c b/lib_com/enh40.c index d77e23b23c679532cd66bdafde845f4b9f258f5b..80ff285cece358464a7b4da491ced951553340b3 100644 --- a/lib_com/enh40.c +++ b/lib_com/enh40.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/enh40.h b/lib_com/enh40.h index 8c34ec36ac7a3a76f120cbbcb9a453bf250be752..a258a4869353f5bfcf078e38cf47959b7f5f26f2 100644 --- a/lib_com/enh40.h +++ b/lib_com/enh40.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/enhancer.c b/lib_com/enhancer.c index d0eeeb76c73ca4e185eafd8b6edd34006d66ee69..e4991be384cb948c1e405ca1f126040bc2c890b2 100644 --- a/lib_com/enhancer.c +++ b/lib_com/enhancer.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/enr_1_az.c b/lib_com/enr_1_az.c index 2b66a14d726bc263dd8feea5a484faeb81c1efe1..9c04a16f29933f4bc9fc391da4c0de755fa78a1b 100644 --- a/lib_com/enr_1_az.c +++ b/lib_com/enr_1_az.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/env_adj.c b/lib_com/env_adj.c index 03b7d6cef61c1c070a52ec6141ba51ca3d0f2b6c..5c85de76b9f902b8cae34763ebf49ca29b049b36 100644 --- a/lib_com/env_adj.c +++ b/lib_com/env_adj.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/env_stab.c b/lib_com/env_stab.c index a1957566b0f6dd21bc58b9b5a64c512617dfa977..0908ce3377dea71fe7fb952c4cbaf3f242bbc6d7 100644 --- a/lib_com/env_stab.c +++ b/lib_com/env_stab.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/env_stab_trans.c b/lib_com/env_stab_trans.c index a2d4492b3f4288ed3d707b824092d26b19fad166..7d18fad77dc07bf6942306d581117e2a4acf476b 100644 --- a/lib_com/env_stab_trans.c +++ b/lib_com/env_stab_trans.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/est_tilt.c b/lib_com/est_tilt.c index 8073e39dfb19833c1ae9d6e7fe1db21f6e38b029..c68ea0c5b3bbbe719314a87d1bd26828c1a9da88 100644 --- a/lib_com/est_tilt.c +++ b/lib_com/est_tilt.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/fd_cng_com.c b/lib_com/fd_cng_com.c index dd82c4f06b11ae4a06c0286b3c0c22351abd14da..4f57ceaed93781138cb7dc673e6ba5c3790c6397 100644 --- a/lib_com/fd_cng_com.c +++ b/lib_com/fd_cng_com.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/fft.c b/lib_com/fft.c index a36712b8e0ab60cb277bb7f1b1fc90149fcf76eb..bfd1cb5d0b72fc0e8160fe93268f15ff7723d9b0 100644 --- a/lib_com/fft.c +++ b/lib_com/fft.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/fft_cldfb.c b/lib_com/fft_cldfb.c index 0ea848abdbba069cd73569df5054e417386a65fa..081f34aa038dc7f661890dcf74a6a19fe587f6b2 100644 --- a/lib_com/fft_cldfb.c +++ b/lib_com/fft_cldfb.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/fft_rel.c b/lib_com/fft_rel.c index 46ee5e9434de472f4f967ecb2e8049e37c9ea617..b5c89d8063772c19d79cdd09e0abce2622949c3e 100644 --- a/lib_com/fft_rel.c +++ b/lib_com/fft_rel.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/fill_spectrum.c b/lib_com/fill_spectrum.c index 6694824879aa5bcc6060d3cd6cb9d88a5479447d..883e944311619d065b0eeb21b47a4954e6ef9fe1 100644 --- a/lib_com/fill_spectrum.c +++ b/lib_com/fill_spectrum.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/findpulse.c b/lib_com/findpulse.c index 3383397bcf939edd9426f6a5446c768c3e7e840a..d08ae2fee90db6f6de8f3ab7c5ca43356bd8954c 100644 --- a/lib_com/findpulse.c +++ b/lib_com/findpulse.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/fine_gain_bits.c b/lib_com/fine_gain_bits.c index 9f10bcd7065bcb43129bbde11205fc352e6bb286..db9ec56789f1177b1f6d239fc73e3474c56b946f 100644 --- a/lib_com/fine_gain_bits.c +++ b/lib_com/fine_gain_bits.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/frame_ener.c b/lib_com/frame_ener.c index f44cb099ce8c2e66a70d680c3488ab9b401b1517..123999f879aec97b43623649e2b3787f8cf0864e 100644 --- a/lib_com/frame_ener.c +++ b/lib_com/frame_ener.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/get_gain.c b/lib_com/get_gain.c index e3457128fe5c314636d81380d742a9d5a67e1595..3d61918619fc9cdffc1a0994b1594eb9bf666d0f 100644 --- a/lib_com/get_gain.c +++ b/lib_com/get_gain.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/gs_bitallocation.c b/lib_com/gs_bitallocation.c index 7af7c1eb8fff26046b513e58624aef59d2b41245..6097e4ef7d180d507d2eebce22c697970e04be34 100644 --- a/lib_com/gs_bitallocation.c +++ b/lib_com/gs_bitallocation.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/gs_gains.c b/lib_com/gs_gains.c index 40626468b65089c0eb8a84e209615bd55464a31b..4c49983bc50a6195a51f7ae1e07cbe91ad7a53bd 100644 --- a/lib_com/gs_gains.c +++ b/lib_com/gs_gains.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/gs_inact_switching.c b/lib_com/gs_inact_switching.c index cd380e86e01e4776259663a806c235b331b60bfc..e7cb216da42671427f60f7b21b3d6b08f2a5fc0b 100644 --- a/lib_com/gs_inact_switching.c +++ b/lib_com/gs_inact_switching.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other @@ -59,12 +59,17 @@ *-------------------------------------------------------------------*/ void inact_switch_ematch( - float exc2[], /* i/o: CELP/GSC excitation buffer */ - float dct_exc_tmp[], /* i : GSC excitation in DCT domain */ - float lt_ener_per_band[], /* i/o: Long term energy per band */ - const int16_t coder_type, /* i : Coder type */ - const int16_t L_frame, /* i : Frame length */ - const int32_t total_brate, /* i : Total bitrate */ + float exc2[], /* i/o: CELP/GSC excitation buffer */ + float dct_exc_tmp[], /* i : GSC excitation in DCT domain */ + float lt_ener_per_band[], /* i/o: Long term energy per band */ + const int16_t coder_type, /* i : Coder type */ +#ifdef NONBE_FIX_GSC_BSTR + const int16_t inactive_coder_type_flag, /* i : AVQ (0) or GSC (1) IC flag */ +#endif + const int16_t L_frame, /* i : Frame length */ +#ifndef NONBE_FIX_GSC_BSTR + const int32_t total_brate, /* i : Total bitrate */ +#endif const int16_t bfi, /* i : frame lost indicator */ const int16_t last_core, /* i : Last core used */ const int16_t last_codec_mode, /* i : Last codec mode */ @@ -105,7 +110,11 @@ void inact_switch_ematch( lt_ener_per_band[i] = Ener_per_bd[i]; } } +#ifdef NONBE_FIX_GSC_BSTR + else if ( coder_type == INACTIVE && inactive_coder_type_flag ) +#else else if ( coder_type == INACTIVE && total_brate <= MAX_GSC_INACTIVE_BRATE ) +#endif { /* Find spectrum and energy per band for inactive frames */ edct( exc2, dct_exc_tmp, L_frame, element_mode ); diff --git a/lib_com/gs_noisefill.c b/lib_com/gs_noisefill.c index a92aec07515888a5f48888eb667fe210c7496297..8e0231e0362d927d513b134cc2f9e77cbe80c3cb 100644 --- a/lib_com/gs_noisefill.c +++ b/lib_com/gs_noisefill.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/gs_preech.c b/lib_com/gs_preech.c index 5a98f409369c0a19f0983496d8963323c09e294d..7d12a9ddb88e46c6423b267e94b600380ef44c93 100644 --- a/lib_com/gs_preech.c +++ b/lib_com/gs_preech.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/guided_plc_util.c b/lib_com/guided_plc_util.c index 884c2beeb860104d820e9dedadd5d0ef742ae43b..9a5ef808de39651f5cfa027d0a7f2deb7a2051cf 100644 --- a/lib_com/guided_plc_util.c +++ b/lib_com/guided_plc_util.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/hp50.c b/lib_com/hp50.c index 3624fabb449fd153e55b2c3ed0fb44b00e19bbc1..034627c482919a4f2e5b2ed6d0edfe97793632a3 100644 --- a/lib_com/hp50.c +++ b/lib_com/hp50.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/hq2_bit_alloc.c b/lib_com/hq2_bit_alloc.c index 34c37babd3481d74a4d8a06fd97905517b456659..b2a65ba469aa185f2d67b5da5f99ff3b5116e99f 100644 --- a/lib_com/hq2_bit_alloc.c +++ b/lib_com/hq2_bit_alloc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/hq2_core_com.c b/lib_com/hq2_core_com.c index 22a596a75fad2822ae3ff4a6e19c2991a3a665dd..364e35c0c775eab4a8d58aecb2fd0eae7ee844c0 100644 --- a/lib_com/hq2_core_com.c +++ b/lib_com/hq2_core_com.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/hq2_noise_inject.c b/lib_com/hq2_noise_inject.c index 0404056dd1ff41587e88825f5ead51872e9ad0d3..143223765367195e2cf653d23a33f6fd7f70f960 100644 --- a/lib_com/hq2_noise_inject.c +++ b/lib_com/hq2_noise_inject.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/hq_bit_allocation.c b/lib_com/hq_bit_allocation.c index faba9f8da9ac3e180010436fc99ae163b5f1ad36..6a8b82067f734e2ca7bd83bff19bb25805b7533c 100644 --- a/lib_com/hq_bit_allocation.c +++ b/lib_com/hq_bit_allocation.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/hq_conf.c b/lib_com/hq_conf.c index ac9298159358bd297456c9fbee4046a305e83250..a59feff917a34e27284f4a9535089fbcaff52ca5 100644 --- a/lib_com/hq_conf.c +++ b/lib_com/hq_conf.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/hq_tools.c b/lib_com/hq_tools.c index 4ad78fc904bb097a3def5e4d8d1373e4ad712794..c2553d2af18f52b1d3793e5299155865912fd8e7 100644 --- a/lib_com/hq_tools.c +++ b/lib_com/hq_tools.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/hvq_pvq_bitalloc.c b/lib_com/hvq_pvq_bitalloc.c index 2808030ae6715e74a318805fa8aaea01a603f2f3..2c9429a32d60738f0dc77d7af942ca046d161b5e 100644 --- a/lib_com/hvq_pvq_bitalloc.c +++ b/lib_com/hvq_pvq_bitalloc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ifft_rel.c b/lib_com/ifft_rel.c index 28334b06db85cba527d725e8b48b75065f4ca566..bda95ec0b11cbf961a39b49b7d1e4d3c54e64c83 100644 --- a/lib_com/ifft_rel.c +++ b/lib_com/ifft_rel.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/igf_base.c b/lib_com/igf_base.c index ac196510091b86a46c00022395b6520d55d93e48..a63318c5efdd6568a2949147a0c8e4a8af09cf46 100644 --- a/lib_com/igf_base.c +++ b/lib_com/igf_base.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/index_pvq_opt.c b/lib_com/index_pvq_opt.c index 097732442b6dd081701f5db2facb856415925507..bf46a9409ff357be25ec05d1fdcd705838273230 100644 --- a/lib_com/index_pvq_opt.c +++ b/lib_com/index_pvq_opt.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/int_lsp.c b/lib_com/int_lsp.c index ff1c9cace4f66b4bcfca0ccb00ef672fec98b867..698de4c18a63c84a39937ab7d506872222efc79b 100644 --- a/lib_com/int_lsp.c +++ b/lib_com/int_lsp.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/interleave_spectrum.c b/lib_com/interleave_spectrum.c index 6046bf8f20959d616b33498e6c37edb6a48ca2c3..cd3aa6c7f68d0f6272b12b80869119887590a2d6 100644 --- a/lib_com/interleave_spectrum.c +++ b/lib_com/interleave_spectrum.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/interpol.c b/lib_com/interpol.c index 4172c4acf7367433db573ef0d1d3c615bdc920b3..b69b2498e1cf1591ab82605af417d20a8f10a3e5 100644 --- a/lib_com/interpol.c +++ b/lib_com/interpol.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/isf_dec_amr_wb.c b/lib_com/isf_dec_amr_wb.c index d51731d1c005195f68a932df57fce09dd2d4e4dc..7822a31b5f7811bda44ba7ce0aa3d19aa91982ed 100644 --- a/lib_com/isf_dec_amr_wb.c +++ b/lib_com/isf_dec_amr_wb.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_agc_com.c b/lib_com/ivas_agc_com.c index e39b8df82d38b2e87b7b046e4b1dd9d5db121265..ee4976788aa36b83a8a84e48087c9fb2dcb8e7a5 100644 --- a/lib_com/ivas_agc_com.c +++ b/lib_com/ivas_agc_com.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_arith.c b/lib_com/ivas_arith.c index 0957d4ae5063e7641ce22503dc51f49738e60e88..d3bc6773391890c583fe79bbe513a0e21672ab72 100644 --- a/lib_com/ivas_arith.c +++ b/lib_com/ivas_arith.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_avq_pos_reorder_com.c b/lib_com/ivas_avq_pos_reorder_com.c index c75d20533b4dcf37357fbf252d19ccfb0e8500e3..aa9885ba51f862792546f1174fd47db416d1e5f1 100644 --- a/lib_com/ivas_avq_pos_reorder_com.c +++ b/lib_com/ivas_avq_pos_reorder_com.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index e88f540752a0cd5888c57ca4cb4f0b61f841b7ad..4389d6fb58e0c6d94acdcebbc7d83c0a86a9bb4e 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other @@ -1147,6 +1147,9 @@ enum #endif #define BITS_MASA2TOTTAL_DCT0 6 #define STEP_M2T 0.1f +#ifdef NONBE_1319_M2R_PRECISION_ALIGN +#define STEP_M2T_FX 214748365 // Q31 +#endif #define MASA_HEADER_BITS 2 #define MASA_SUBFRAME_BITS 1 #define MASA_LOWBITRATE_MODE_BITS 1 @@ -1382,9 +1385,9 @@ typedef enum #define PARAM_MC_ICC_ERROR_BIAS_FAC (1.15f) /* factor for favouring past ICC maps in the adaptive ICC map decision */ #define PARAM_MC_TRANSIENT_BAND_STEP 2 /* Number of parameter bands combined in case of a transient frame*/ #define PARAM_MC_MAX_DECORR_CLDFB_BANDS 20 /* Maximum number of CLDFB bands with decorrelation */ -#define PARAM_MC_MAX_TRANSPORT_CHANS 4 /* Number of down mix channels */ +#define PARAM_MC_MAX_TRANSPORT_CHANS 3 /* Number of down mix channels */ #define PARAM_MC_MAX_ILD_REF_CHANNELS 2 /* Maximum number of reference channels for a coded ILD */ -#define PARAM_MC_NUM_CONFIGS 15 /* Number of available Parametric MC configurations */ +#define PARAM_MC_NUM_CONFIGS 14 /* Number of available Parametric MC configurations */ #define PARAM_MC_MAX_BAND_LFE 1 /* Number of parameter bands for LFE coding */ #define PARAM_MC_SZ_ICC_MAP 11 /* Maximum number of transmitted ICCs per parameter band */ #define PARAM_MC_SZ_ILD_MAP 12 /* Maximum number of transmitted channel energies per band*/ @@ -1521,8 +1524,6 @@ typedef enum #define HEADROT_SHMAT_DIM2 ( HEADROT_SHMAT_DIM * HEADROT_SHMAT_DIM ) - - /*----------------------------------------------------------------------------------* * TD Binaural Object renderer *----------------------------------------------------------------------------------*/ diff --git a/lib_com/ivas_cov_smooth.c b/lib_com/ivas_cov_smooth.c index 54d0d5f8dabac2d0948abe985e577eaf77f53686..8c309af676f5ed464e2d5b2930475aa441b421c4 100644 --- a/lib_com/ivas_cov_smooth.c +++ b/lib_com/ivas_cov_smooth.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_dirac_com.c b/lib_com/ivas_dirac_com.c index 35d514f9b0af1f349fb132394991221c36e97baa..cc0b2de7b354c695c4b0f1490bb6d91cb3375c81 100644 --- a/lib_com/ivas_dirac_com.c +++ b/lib_com/ivas_dirac_com.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_entropy_coder_common.c b/lib_com/ivas_entropy_coder_common.c index a2fa26cad9f53c6a8f50eaf139331277e3f95f8a..015fab85e9dbeae9b10b0084e8a5e385bb8baac3 100644 --- a/lib_com/ivas_entropy_coder_common.c +++ b/lib_com/ivas_entropy_coder_common.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_error.h b/lib_com/ivas_error.h index b61819ea3d9500e14ad6e1ab8098c84d29b4b0f8..388f89d46f7ed1e44cd398add393d9c63b75f232 100644 --- a/lib_com/ivas_error.h +++ b/lib_com/ivas_error.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other @@ -103,6 +103,12 @@ typedef enum * input data errors * *----------------------------------------*/ IVAS_ERR_INVALID_BITSTREAM = 0x2000, +#ifdef SPLIT_REND_WITH_HEAD_ROT +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + IVAS_ERR_UNEXPECTED_LC3PLUS_BITSTREAM, + IVAS_ERR_UNEXPECTED_LC3PLUS_BITSTREAM_CONFIG, +#endif +#endif /*----------------------------------------* * hardware errors * @@ -141,6 +147,10 @@ typedef enum IVAS_ERR_ACOUSTIC_ENVIRONMENT_MISSING, IVAS_ERR_INVALID_ER_PARAM, IVAS_ERR_DIRECTIVITY_PATTERN_ID_MISSING, +#ifdef SPLIT_REND_WITH_HEAD_ROT + IVAS_ERR_LC3PLUS_INVALID_BITRATE, + IVAS_ERR_INVALID_SPLIT_REND_CONFIG, +#endif /*----------------------------------------* * unknown error * @@ -239,6 +249,12 @@ static inline const char *ivas_error_to_string( ivas_error error_code ) return "Wrong mode"; case IVAS_ERR_HEAD_ROTATION_NOT_SUPPORTED: return "Head rotation not supported"; +#ifdef SPLIT_REND_WITH_HEAD_ROT + case IVAS_ERR_LC3PLUS_INVALID_BITRATE: + return "Specified split rendering bit rate is not supported"; + case IVAS_ERR_INVALID_SPLIT_REND_CONFIG: + return "Specified split rendering configuration is invalid"; +#endif case IVAS_ERR_EXT_ORIENTATION_NOT_SUPPORTED: return "External orientation not supported"; case IVAS_ERR_DIRECTIVITY_NOT_SUPPORTED: diff --git a/lib_com/ivas_error_utils.h b/lib_com/ivas_error_utils.h index b9a6b3f872443e35368c4d802054d6f47eaafc42..27bb18990b3dc4c07916da83c16911f4721fc5ac 100644 --- a/lib_com/ivas_error_utils.h +++ b/lib_com/ivas_error_utils.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_fb_mixer.c b/lib_com/ivas_fb_mixer.c index 9772f2e8dd81ccb15f8ae034d6b8ff7eecf36a62..4ff4e7206595220ec74061dcf2a32c7367e96f45 100644 --- a/lib_com/ivas_fb_mixer.c +++ b/lib_com/ivas_fb_mixer.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_filters.c b/lib_com/ivas_filters.c index 579e9d17c6f3dfd444407559bb1d39d593fe4272..46f878a2dae7ca41682f4be74a50bb2e6c0bce20 100644 --- a/lib_com/ivas_filters.c +++ b/lib_com/ivas_filters.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_ism_com.c b/lib_com/ivas_ism_com.c index 3ec4656a9e7e922abfc43db2b6a0365745205447..146d9b3a446e524e21d2c0090e14f0483795306a 100644 --- a/lib_com/ivas_ism_com.c +++ b/lib_com/ivas_ism_com.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_lfe_com.c b/lib_com/ivas_lfe_com.c index 45dcae7c07a16f87259decd40f4bc1886422fe11..4a44ceadffd2ad6be3db808b87b6e7edf60d41f7 100644 --- a/lib_com/ivas_lfe_com.c +++ b/lib_com/ivas_lfe_com.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_limiter.c b/lib_com/ivas_limiter.c similarity index 99% rename from lib_rend/ivas_limiter.c rename to lib_com/ivas_limiter.c index 0953e8a825dc3aecfe8a51b004da4a2400884199..97922af9c6ccab527bd94e6a5ecc0dabac1471c1 100644 --- a/lib_rend/ivas_limiter.c +++ b/lib_com/ivas_limiter.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other @@ -34,7 +34,7 @@ #include "options.h" #include #include "prot.h" -#include "ivas_prot_rend.h" +#include "ivas_prot.h" #include "wmc_auto.h" #include diff --git a/lib_com/ivas_masa_com.c b/lib_com/ivas_masa_com.c index 17e4b477314b3023a41dac3b0755fe9fd38347a2..7e6aba8645aa81a0ef07bb3bceb90e67559c6a67 100644 --- a/lib_com/ivas_masa_com.c +++ b/lib_com/ivas_masa_com.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_mc_com.c b/lib_com/ivas_mc_com.c index 966fd21a57ce0b2aed9bfbf31f74b9d4daddc724..8534ef0e7091e145416ded1d0ea265f3b23e2069 100644 --- a/lib_com/ivas_mc_com.c +++ b/lib_com/ivas_mc_com.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_mc_param_com.c b/lib_com/ivas_mc_param_com.c index 44efdebe2e96b2dde1a05432811eda965bd8c867..7029851d88d059fc1a088b03296f01a1e0f28b2c 100644 --- a/lib_com/ivas_mc_param_com.c +++ b/lib_com/ivas_mc_param_com.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other @@ -87,16 +87,11 @@ uint16_t ivas_param_mc_get_configuration_index( void ivas_param_mc_metadata_open( const MC_LS_SETUP mc_ls_setup, /* i : MC ls setup */ - const int16_t lfe_index, /* i : channel index of LFE */ const int32_t ivas_total_brate, /* i : IVAS total bitrate */ HANDLE_IVAS_PARAM_MC_METADATA hMetadataPMC /* o : handle for the Parametric MC parameter coding state */ ) { - int16_t i; uint16_t config_index; - int16_t nchan_setup; - - nchan_setup = ivas_mc_ls_setup_get_num_channels( mc_ls_setup ); /* get coding band mappings */ set_s( hMetadataPMC->coding_band_mapping, 0, PARAM_MC_MAX_PARAMETER_BANDS ); @@ -129,21 +124,13 @@ void ivas_param_mc_metadata_open( assert( 0 && "nbands must be 20 or 14!" ); } - /* create map of all possible ICCs */ - ivas_param_mc_create_full_icc_mapping( nchan_setup, lfe_index, hMetadataPMC->icc_map_full, &hMetadataPMC->icc_map_size_full ); hMetadataPMC->icc_mapping_conf = ivas_param_mc_conf[config_index].icc_mapping_conf; hMetadataPMC->ild_mapping_conf = ivas_param_mc_conf[config_index].ild_mapping_conf; hMetadataPMC->ild_factors = ivas_param_mc_conf[config_index].ild_factors; - /* set default ICC maps */ - for ( i = 0; i < PARAM_MC_PARAMETER_FRAMES; i++ ) - { - ivas_param_mc_default_icc_map( hMetadataPMC->icc_mapping_conf, hMetadataPMC->icc_mapping[i] ); - } /* init remaining flags and indices */ hMetadataPMC->param_frame_idx = 0; - hMetadataPMC->flag_use_adaptive_icc_map = 0; hMetadataPMC->bAttackPresent = 0; hMetadataPMC->attackIndex = 0; hMetadataPMC->lfe_on = 1; @@ -199,32 +186,6 @@ void ivas_param_mc_set_coded_bands( } -/*------------------------------------------------------------------------- - * ivas_param_mc_metadata_close() - * - * Parametric MC parameter coding state close function - *------------------------------------------------------------------------*/ - -void ivas_param_mc_metadata_close( - HANDLE_IVAS_PARAM_MC_METADATA hMetadataPMC /* i/o: handle for the Parametric MC parameter coding state */ -) -{ - uint16_t i; - - /* adaptive ICC mapping */ - for ( i = 0; i < 2; i++ ) - { - if ( hMetadataPMC->icc_map_full[i] ) - { - free( hMetadataPMC->icc_map_full[i] ); - hMetadataPMC->icc_map_full[i] = NULL; - } - } - - return; -} - - /*------------------------------------------------------------------------- * ivas_param_mc_getNumTransportChannels() * @@ -248,86 +209,6 @@ int16_t ivas_param_mc_getNumTransportChannels( } -/*------------------------------------------------------------------------- - * ivas_param_mc_create_full_icc_mapping() - * - * create the map of all possible ICCs for a certain internal setup - * indicated by the number of channels and LFE index - *------------------------------------------------------------------------*/ - -void ivas_param_mc_create_full_icc_mapping( - const int16_t n_channels, /* i : number of channels with LFE for the internal setup */ - const int16_t lfe_index, /* i : channel index of the LFE */ - int16_t *icc_map[2], /* o : map of all possible ICCs */ - int16_t *icc_map_size_full /* o : number of all possible ICCs */ -) -{ - int16_t i, k, l; - - l = 0; - - /* number of all possible ICCs is the number of non-diagonal upper elements of a - * ICC matrix for all channels not including the LFE plus one static ICC for the - * combination (LFE/center) */ - *icc_map_size_full = ( n_channels - 2 ) * ( n_channels - 1 ) / 2 + 1; - - /* allocate memory for the map */ - for ( i = 0; i < 2; i++ ) - { - icc_map[i] = (int16_t *) malloc( *icc_map_size_full * sizeof( int16_t ) ); - } - - /* create map (non-LFE ICCs) */ - for ( i = 0; i < n_channels; i++ ) - { - if ( i != lfe_index ) - { - for ( k = i + 1; k < n_channels; k++ ) - { - if ( k != lfe_index ) - { - icc_map[0][l] = i; - icc_map[1][l] = k; - l++; - } - } - } - } - - /* last one is the fixed mapping center -> LFE */ - assert( l == *icc_map_size_full - 1 ); - - icc_map[0][l] = 2; - icc_map[1][l] = lfe_index; - - return; -} - - -/*------------------------------------------------------------------------- - * ivas_param_mc_default_icc_map() - * - * get the default ICC map for a certain internal setup - * indicated by the number of channels from the table ROM - *------------------------------------------------------------------------*/ - -void ivas_param_mc_default_icc_map( - const PARAM_MC_ICC_MAPPING *hIccMapping, /* i : ICC mapping table */ - int16_t icc_map[PARAM_MC_SZ_ICC_MAP][2] /* o : copy of map from ROM table */ -) -{ - int16_t i; - - for ( i = 0; i < hIccMapping->icc_map_size_lfe; i++ ) - { - icc_map[i][0] = hIccMapping->icc_mapping[i][0]; - icc_map[i][1] = hIccMapping->icc_mapping[i][1]; - } - - return; -} - - /*------------------------------------------------------------------------- * ivas_param_mc_get_num_param_bands() * @@ -408,9 +289,6 @@ static int16_t ivas_param_mc_get_num_param_bands( case IVAS_128k: num_parameter_bands = 14; break; - case IVAS_160k: - num_parameter_bands = 20; - break; } break; default: diff --git a/lib_com/ivas_mcmasa_com.c b/lib_com/ivas_mcmasa_com.c index 7e81e1fd1cd8317beeb8c359c34433a113896e02..26f95da2666df8402bbc82f0aa55d1bfcef1b609 100644 --- a/lib_com/ivas_mcmasa_com.c +++ b/lib_com/ivas_mcmasa_com.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_mct_com.c b/lib_com/ivas_mct_com.c index 97c5f5dd8c982fda7ff0b57fc6507869fb957d94..ee83db3d9558ee905f6d81d683a65d3e94890799 100644 --- a/lib_com/ivas_mct_com.c +++ b/lib_com/ivas_mct_com.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_mdct_core_com.c b/lib_com/ivas_mdct_core_com.c index afb5303a7aa82c774655b53c89546ef91656433a..b3c4e312058b0d819d366cd5b651519bdb40fe31 100644 --- a/lib_com/ivas_mdct_core_com.c +++ b/lib_com/ivas_mdct_core_com.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_mdct_imdct.c b/lib_com/ivas_mdct_imdct.c index 5dcd850c2ee1bbc4a42b48e252c9248c5e9b93a0..6198b0110036515e88a4e738986fb290a8ec9102 100644 --- a/lib_com/ivas_mdct_imdct.c +++ b/lib_com/ivas_mdct_imdct.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_mdft_imdft.c b/lib_com/ivas_mdft_imdft.c index 0b03f63d90cb7cec236bc42b69d92eeae430b5ef..0954ead0d35e12c7a4279d8a7ad2889f9a69e3f8 100644 --- a/lib_com/ivas_mdft_imdft.c +++ b/lib_com/ivas_mdft_imdft.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_omasa_com.c b/lib_com/ivas_omasa_com.c index 7416dad119d0a016ea35f669e9e2e94ed77ca5f1..4042dd959b6e5a5e0ce4c18ca96f9685c118933e 100644 --- a/lib_com/ivas_omasa_com.c +++ b/lib_com/ivas_omasa_com.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_pca_tools.c b/lib_com/ivas_pca_tools.c index a1f8efd6298aeb66beab96d8f1a289a7cb060cda..0c54551bee4be7927efdfd136b8f11bf4b32c039 100644 --- a/lib_com/ivas_pca_tools.c +++ b/lib_com/ivas_pca_tools.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index e39433fece03bb7fbc3bc5d59d3e88289dd97d47..217d3cb6cf9ce24556871a13e2423c74b3babdab 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other @@ -42,6 +42,7 @@ #include "stat_com.h" #include "ivas_stat_enc.h" #include "ivas_stat_dec.h" +#include "ivas_stat_rend.h" #include "ivas_stat_com.h" #include "ivas_error_utils.h" @@ -199,7 +200,10 @@ ivas_error pre_proc_front_ivas( const int16_t force_front_vad, /* i : flag to force VAD decision */ const int16_t front_vad_dtx_flag, /* i : front-VAD DTX flag to overwrite VAD decision*/ const IVAS_FORMAT ivas_format, /* i : IVAS format */ - const int16_t MCT_flag, /* i : hMCT handle allocated (1) or not (0) */ + const int16_t MCT_flag, /* i : hMCT handle allocated (1) or not (0) */ +#ifdef NONBE_1211_DTX_BR_SWITCHING + const int32_t last_ivas_total_brate, /* i : last IVAS total bitrate */ +#endif const int32_t ivas_total_brate /* i : IVAS total bitrate */ #ifdef DEBUG_MODE_INFO , const int16_t ch_idx @@ -304,6 +308,11 @@ ivas_error ivas_output_buff_dec( const int16_t nchan_out_buff /* i : number of output channels */ ); + +ivas_error get_channel_config( + const AUDIO_CONFIG config, + char *str ); + ivas_error stereo_dmx_evs_init_encoder( STEREO_DMX_EVS_ENC_HANDLE *hStereoDmxEVS, /* o : Stereo downmix for EVS encoder handle */ const int32_t input_Fs /* i : input sampling rate */ @@ -321,7 +330,12 @@ ivas_error ivas_dec( ivas_error ivas_dec_setup( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ uint16_t *nSamplesRendered, /* o : number of samples flushed from the previous frame (JBM) */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ + void *data /* o : output synthesis signal */ +#else int16_t *data /* o : output synthesis signal */ +#endif ); ivas_error create_sce_dec( @@ -661,7 +675,12 @@ ivas_error ivas_mc_dec_config( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const int16_t idx, /* i : LS config. index */ uint16_t *nSamplesRendered, /* o : samples flushed from last frame (JBM) */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ + void *data /* o : output synthesis signal */ +#else int16_t *data /* o : output synthesis signal */ +#endif ); /*! r: MC format mode (MCT, McMASA, ParamMC) */ @@ -756,6 +775,32 @@ int16_t get_igf_startline( float rand_triangular_signed( int16_t *seed ); +#ifdef NONBE_1319_M2R_PRECISION_ALIGN +Word16 matrix_product_fx( + const Word32 *X_fx, /* i : left hand matrix Qx*/ + const Word16 rowsX, /* i : number of rows of the left hand matrix Q0*/ + const Word16 colsX, /* i : number of columns of the left hand matrix Q0*/ + const Word16 transpX, /* i : flag indicating the transposition of the left hand matrix prior to the multiplication Q0*/ + const Word32 *Y_fx, /* i : right hand matrix Qy*/ + const Word16 rowsY, /* i : number of rows of the right hand matrix Q0*/ + const Word16 colsY, /* i : number of columns of the right hand matrix Q0*/ + const Word16 transpY, /* i : flag indicating the transposition of the right hand matrix prior to the multiplication Q0*/ + Word32 *Z_fx /* o : resulting matrix after the matrix multiplication Qx + Qy - 31*/ +); + +Word16 matrix_product_q30_fx( + const Word32 *X_fx, /* i : left hand matrix Q31*/ + const Word16 rowsX, /* i : number of rows of the left hand matrix Q0*/ + const Word16 colsX, /* i : number of columns of the left hand matrix Q0*/ + const Word16 transpX, /* i : flag indicating the transposition of the left hand matrix prior to the multiplication Q0*/ + const Word32 *Y_fx, /* i : right hand matrix Q25*/ + const Word16 rowsY, /* i : number of rows of the right hand matrix Q0*/ + const Word16 colsY, /* i : number of columns of the right hand matrix Q0*/ + const Word16 transpY, /* i : flag indicating the transposition of the right hand matrix prior to the multiplication Q0*/ + Word32 *Z_fx /* o : resulting matrix after the matrix multiplication Q30*/ +); +#endif + void dtx_read_padding_bits( DEC_CORE_HANDLE st, const int16_t num_bits @@ -782,7 +827,12 @@ ivas_error ivas_jbm_dec_render( const uint16_t nSamplesAsked, /* i : number of samples wanted */ uint16_t *nSamplesRendered, /* o : number of samples rendered */ uint16_t *nSamplesAvailableNext, /* o : number of samples still available in the rendering pipeline */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ + void *data /* o : output synthesis signal */ +#else int16_t *data /* o : output synthesis signal */ +#endif ); ivas_error ivas_jbm_dec_flush_renderer( @@ -794,7 +844,12 @@ ivas_error ivas_jbm_dec_flush_renderer( const MC_MODE mc_mode_old, /* i : old MC mode */ const ISM_MODE ism_mode_old, /* i : old ISM mode */ uint16_t *nSamplesRendered, /* o : number of samples flushed */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ + void *data /* o : output synthesis signal */ +#else int16_t *data /* o : output synthesis signal */ +#endif ); void ivas_jbm_dec_feed_tc_to_renderer( @@ -1059,7 +1114,12 @@ ivas_error ivas_ism_dec_config( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const ISM_MODE last_ism_mode, /* i/o: last ISM mode */ uint16_t *nSamplesRendered, /* o : number of samples flushed on renderer change*/ +#ifdef SPLIT_REND_WITH_HEAD_ROT + const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ + void *data /* o : output synthesis signal */ +#else int16_t *data /* o : output synthesis signal */ +#endif ); ivas_error ivas_param_ism_dec_open( @@ -3440,7 +3500,12 @@ void ivas_sba_set_cna_cng_flag( ivas_error ivas_sba_dec_reconfigure( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ uint16_t *nSamplesFlushed, /* o : number of samples flushed */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ + void *data /* o : output synthesis signal */ +#else int16_t *data /* o : output synthesis signal */ +#endif ); ivas_error ivas_sba_digest_tc( @@ -3773,7 +3838,6 @@ void ivas_mc_paramupmix_dec_render( void ivas_param_mc_metadata_open( const MC_LS_SETUP mc_ls_setup, /* i : MC ls setup */ - const int16_t lfe_index, /* i : channel index of LFE */ const int32_t ivas_total_brate, /* i : IVAS total bitrate */ HANDLE_IVAS_PARAM_MC_METADATA hMetadataPMC /* o : handle for the Parametric MC parameter coding state */ ); @@ -3782,17 +3846,6 @@ void ivas_param_mc_set_coded_bands( HANDLE_IVAS_PARAM_MC_METADATA hMetadataPMC /* i/o: handle for the Parametric MC parameter coding state */ ); -void ivas_param_mc_metadata_close( - HANDLE_IVAS_PARAM_MC_METADATA hMetadataPMC /* i/o: handle for the Parametric MC parameter coding state */ -); - -void ivas_param_mc_create_full_icc_mapping( - const int16_t n_channels, /* i : number of channels with LFE for the internal setup */ - const int16_t lfe_index, /* i : channel index of the LFE */ - int16_t *icc_map[2], /* o : map of all possible ICCs */ - int16_t *icc_map_size_full /* o : number of all possible ICCs */ -); - /*! r: number of IVAS transport channels */ int16_t ivas_param_mc_getNumTransportChannels( const int32_t ivas_total_bitrate, /* i : IVAS total bitrate */ @@ -3857,11 +3910,6 @@ void ivas_param_mc_dec( float *output_f[] /* i/o: synthesized core-coder transport channels/DirAC output */ ); -void ivas_param_mc_default_icc_map( - const PARAM_MC_ICC_MAPPING * hIccMapping, /* i : handle to ICC mapping configuration */ - int16_t icc_map[PARAM_MC_SZ_ICC_MAP][2] /* o : copy of map from the configuration */ -); - /*! r: number of cldfb synthesis instances */ int16_t param_mc_get_num_cldfb_syntheses( Decoder_Struct *st_ivas /* i : IVAS decoder structure */ @@ -4927,7 +4975,12 @@ void ivas_masa_enc_reconfigure( ivas_error ivas_masa_dec_reconfigure( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ uint16_t *nSamplesRendered, /* o : number of samples flushed from the previous frame (JBM) */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ + void *data /* o : output synthesis signal */ +#else int16_t *data /* o : output synthesis signal */ +#endif ); ivas_error ivas_masa_encode( @@ -5175,13 +5228,21 @@ void ivas_binaural_cldfb_sf( void ivas_binRenderer( BINAURAL_RENDERER_HANDLE hBinRenderer, /* i/o: binaural renderer handle */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, +#endif COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined head and external orientation handle */ const int16_t numTimeSlots, /* i : number of time slots to process */ #ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG HEAD_TRACK_DATA_HANDLE hPostRendHeadTrackData, #endif +#ifdef SPLIT_REND_WITH_HEAD_ROT + float Cldfb_RealBuffer_Binaural[][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Rotated Binaural signals */ + float Cldfb_ImagBuffer_Binaural[][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Rotated Binaural signals */ +#else float Cldfb_RealBuffer_Binaural[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Binaural signals */ float Cldfb_ImagBuffer_Binaural[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Binaural signals */ +#endif float RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i : LS signals */ float ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX] /* i : LS signals */ ); @@ -5630,7 +5691,12 @@ ivas_error ivas_omasa_enc_config( ivas_error ivas_omasa_dec_config( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ uint16_t *nSamplesRendered, /* o : number of samples flushed from the previous frame (JBM) */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ + void *data /* o : output synthesis signal */ +#else int16_t *data /* o : output synthesis signal */ +#endif ); void ivas_omasa_set_config( @@ -5909,6 +5975,56 @@ int16_t ivas_get_num_bands_from_bw_idx( const int16_t bwidth /* i : audio bandwidth */ ); +void Euler2Quat( + const float yaw, /* i : yaw (x) */ + const float pitch, /* i : pitch (y) */ + const float roll, /* i : roll (z) */ + IVAS_QUATERNION *quat /* o : quaternion describing the rotation */ +); + +float deg2rad( + float degrees +); + +#ifdef SPLIT_REND_WITH_HEAD_ROT +void Quat2EulerDegree( + const IVAS_QUATERNION quat, /* i : quaternion describing the rotation */ + float *yaw, /* o : yaw */ + float *pitch, /* o : pitch */ + float *roll /* o : roll */ +); +#endif + +/*----------------------------------------------------------------------------------* + * Limiter prototypes + *----------------------------------------------------------------------------------*/ + +ivas_error ivas_limiter_open( + IVAS_LIMITER_HANDLE *hLimiter_out, /* o : limiter struct handle */ + const int16_t num_channels, /* i : number of I/O channels */ + const int32_t sampling_rate /* i : sampling rate for processing */ +); + +void ivas_limiter_close( + IVAS_LIMITER_HANDLE* phLimiter /* i/o: pointer to limiter handle, can be NULL */ +); + +void ivas_limiter_dec +( + IVAS_LIMITER_HANDLE hLimiter, /* i/o: limiter struct handle */ + float *output[MAX_OUTPUT_CHANNELS], /* i/o: input/output buffer */ + const int16_t num_channels, /* i : number of channels to be processed */ + const int16_t output_frame, /* i : number of samples per channel in the buffer */ + const int16_t BER_detect /* i : BER detect flag */ +); + +void limiter_process( + IVAS_LIMITER_HANDLE hLimiter, /* i/o: limiter struct handle */ + const int16_t output_frame, /* i : number of samples to be processed per channel in the I/O buffer */ + const float threshold, /* i : signal amplitude above which limiting starts to be applied */ + const int16_t BER_detect, /* i : BER detect flag */ + int16_t *strong_saturation_cnt /* i/o: counter of strong saturations (can be NULL) */ +); /* clang-format on */ diff --git a/lib_com/ivas_qmetadata_com.c b/lib_com/ivas_qmetadata_com.c index d3b11da6d86ec630c2d3efb0d90712c8d91e301c..e29964ab2997d40c1b35e7be6e1e41eca9ad9ebf 100644 --- a/lib_com/ivas_qmetadata_com.c +++ b/lib_com/ivas_qmetadata_com.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_qspherical_com.c b/lib_com/ivas_qspherical_com.c index 874f66d05910606c7197034c36e8aef9491c628b..8e34e3f805fd22caf0a8cfa8f10846dcbbd331ab 100644 --- a/lib_com/ivas_qspherical_com.c +++ b/lib_com/ivas_qspherical_com.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_rom_com.c b/lib_com/ivas_rom_com.c index 58dc6dc974063e216325393cf6d9a68149c5e306..00ebff8da5fb25966af8cb9f7843bc48c5680ab5 100644 --- a/lib_com/ivas_rom_com.c +++ b/lib_com/ivas_rom_com.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other @@ -1973,22 +1973,6 @@ const float ivas_param_mc_ild_fac_CICP19_3tc[12] = 0.5f }; -const float ivas_param_mc_ild_fac_CICP19_4tc[12] = -{ - 0.35f, - 0.35f, - 0.17f, - 0.22f, - 0.2f, - 0.2f, - 0.2f, - 0.5f, - 0.5f, - 0.5f, - 0.5f, - 0.2f, -}; - const PARAM_MC_ILD_MAPPING ivas_param_mc_ild_mapping_CICP6_2tc = { 5, @@ -2052,15 +2036,6 @@ const PARAM_MC_ILD_MAPPING ivas_param_mc_ild_mapping_CICP19_3tc = {{0},{1},{0},{1},{0},{1},{0},{1},{0},{1},{2},{2}} }; -const PARAM_MC_ILD_MAPPING ivas_param_mc_ild_mapping_CICP19_4tc = -{ - 11, - 12, - {0,1,2,4,5,6,7,8,9,10,11,3}, - {1,1,2,1,1,1,1,1,1,1,1,2}, - {{0},{1},{0,1},{0},{1},{0},{1},{2},{3},{2},{3},{0,1}} -}; - const PARAM_MC_ICC_MAPPING ivas_param_mc_icc_mapping_CICP6_2tc = { 4, @@ -2161,22 +2136,6 @@ const PARAM_MC_ICC_MAPPING ivas_param_mc_icc_mapping_CICP19_3tc = } }; -const PARAM_MC_ICC_MAPPING ivas_param_mc_icc_mapping_CICP19_4tc = -{ - 8, - 9, - { { 0, 4 }, /* L/LS */ - { 1, 5 }, /* R/RS */ - { 0, 2 }, /* L/C */ - { 1, 2 }, /* R/C */ - { 0, 6 }, /* L/LBS */ - { 1, 7 }, /* R/RBS */ - { 8, 10 }, /*UFL/UBL */ - { 9, 11 }, /*UFR/UBR */ - { 2, 3 } /* C/LFE */ - } -}; - const PARAM_MC_CONF ivas_param_mc_conf[PARAM_MC_NUM_CONFIGS] = { /* CICP6 48000 */ @@ -2332,17 +2291,6 @@ const PARAM_MC_CONF ivas_param_mc_conf[PARAM_MC_NUM_CONFIGS] = &ivas_param_mc_icc_mapping_CICP19_3tc, &ivas_param_mc_dmx_fac_CICP19_3tc[0], &ivas_param_mc_ild_fac_CICP19_3tc[0] - }, - /* CICP19 160000 */ - { - MC_LS_SETUP_7_1_4, - 12, - 4, - IVAS_160k, - &ivas_param_mc_ild_mapping_CICP19_4tc, - &ivas_param_mc_icc_mapping_CICP19_4tc, - &ivas_param_mc_dmx_fac_CICP19_4tc[0], - &ivas_param_mc_ild_fac_CICP19_4tc[0] } }; @@ -2833,6 +2781,48 @@ const int32_t sep_object_brate[][MAX_NUM_OBJECTS] = }; /* column wise DCT matrices for 4 5, and 8 dim */ +#ifdef NONBE_1319_M2R_PRECISION_ALIGN +const Word32 dct4_fx[4 * 4] = { // Q31 + 1073741824, 1402951040, 1073741824, 581109056, + 1073741824, 581109056, -1073741824, -1402951040, + 1073741824, -581109056, -1073741824, 1402951040, + 1073741824, -1402951040, 1073741824, -581109056 +}; + +const Word32 dct5_fx[5 * 5] = { // Q31 + 960354688, 1291711360, 1098867328, 798219648, 419618304, + 960354688, 798219648, -419618304, -1291711360, -1098867328, + 960354688, 0, -1358283392, 0, 1358283392, + 960354688, -798219648, -419618304, 1291711360, -1098867328, + 960354688, -1291711360, 1098867328, -798219648, 419618304 +}; + +const Word32 dct8_fx[8 * 8] = { // Q31 + 759350208, 1053125952, 991922688, 892708928, 759350208, 596570944, 410813632, 209379648, + 759350208, 892708928, 410813632, -209379648, -759350208, -1053125952, -991922688, -596570944, + 759350208, 596570944, -410813632, -1053125952, -759350208, 209379648, 991922688, 892708928, + 759350208, 209379648, -991922688, -596570944, 759350208, 892708928, -410813632, -1053125952, + 759350208, -209379648, -991922688, 596570944, 759350208, -892708928, -410813632, 1053125952, + 759350208, -596570944, -410813632, 1053125952, -759350208, -209379648, 991922688, -892708928, + 759350208, -892708928, 410813632, 209379648, -759350208, 1053125952, -991922688, 596570944, + 759350208, -1053125952, 991922688, -892708928, 759350208, -596570944, 410813632, -209379648 +}; + +const Word32 dct12_fx[12 * 12] = { // Q31 + 619978560, 869301376, 846752832, 810030848, 759350208, 695569984, 619978560, 533649696, 438301408, 335436960, 226989024, 114460880, + 619978560, 810030848, 619978560, 335436960, 0, -335436960, -619978560, -810030848, -876602816, -810030848, -619978560, -335436960, + 619978560, 695569984, 226989024, -335436960, -759350208, -869301376, -619978560, -114460880, 438301408, 810030848, 846752832, 533649696, + 619978560, 533649696, -226989024, -810030848, -759350208, -114460880, 619978560, 869301376, 438301408, -335436960, -846752832, -695569984, + 619978560, 335436960, -619978560, -810030848, 0, 810030848, 619978560, -335436960, -876602816, -335436960, 619978560, 810030848, 619978560, + 114460880, -846752832, -335436960, 759350208, 533649696, -619978560, -695569984, 438301408, 810030848, -226989024, -869301376, 619978560, + -114460880, -846752832, 335436960, 759350208, -533649696, -619978560, 695569984, 438301408, -810030848, -226989024, 869301376, 619978560, + -335436960, -619978560, 810030848, 0, -810030848, 619978560, 335436960, -876602816, 335436960, 619978560, -810030848, 619978560, -533649696, + -226989024, 810030848, -759350208, 114460880, 619978560, -869301376, 438301408, 335436960, -846752832, 695569984, 619978560, -695569984, + 226989024, 335436960, -759350208, 869301376, -619978560, 114460880, 438301408, -810030848, 846752832, -533649696, 619978560, -810030848, + 619978560, -335436960, 0, 335436960, -619978560, 810030848, -876602816, 810030848, -619978560, 335436960, 619978560, -869301376, 846752832, + -810030848, 759350208, -695569984, 619978560, -533649696, 438301408, -335436960, 226989024, -114460880 +}; +#endif const float dct4[4*4] = { 0.5000f, 0.6533f, 0.5000f, 0.2706f, diff --git a/lib_com/ivas_rom_com.h b/lib_com/ivas_rom_com.h index f597fe8b90efcd7d98788e61c8840f90a1a192af..4cfd08b73c87be0cad69f0848a363a1015604736 100644 --- a/lib_com/ivas_rom_com.h +++ b/lib_com/ivas_rom_com.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other @@ -327,6 +327,12 @@ extern const float dct4[]; extern const float dct5[]; extern const float dct8[]; extern const float dct12[]; +#ifdef NONBE_1319_M2R_PRECISION_ALIGN +extern const Word32 dct4_fx[]; +extern const Word32 dct5_fx[]; +extern const Word32 dct8_fx[]; +extern const Word32 dct12_fx[]; +#endif /*----------------------------------------------------------------------------------* * ISM ROM tables diff --git a/lib_com/ivas_rotation_com.c b/lib_com/ivas_rotation_com.c new file mode 100644 index 0000000000000000000000000000000000000000..8aaa04e7b1bba407009b6cfde3c37e89b4336194 --- /dev/null +++ b/lib_com/ivas_rotation_com.c @@ -0,0 +1,137 @@ +/****************************************************************************************************** + + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#include "ivas_cnst.h" +#include +#include +#include "options.h" +#include +#include "cnst.h" +#include "prot.h" +#include "ivas_prot.h" +#ifdef DEBUGGING +#include "debug.h" +#endif +#include "wmc_auto.h" + +/*------------------------------------------------------------------------- + * Euler2Quat() + * + * Calculate corresponding Quaternion from Euler angles in radians + *------------------------------------------------------------------------*/ + +void Euler2Quat( + const float yaw, /* i : yaw (x) */ + const float pitch, /* i : pitch (y) */ + const float roll, /* i : roll (z) */ + IVAS_QUATERNION *quat /* o : quaternion describing the rotation */ +) +{ + float cr = cosf( roll * 0.5f ); + float sr = sinf( roll * 0.5f ); + float cp = cosf( pitch * 0.5f ); + float sp = sinf( pitch * 0.5f ); + float cy = cosf( yaw * 0.5f ); + float sy = sinf( yaw * 0.5f ); + quat->w = cr * cp * cy + sr * sp * sy; + quat->x = sr * cp * cy - cr * sp * sy; + quat->y = sr * cp * sy + cr * sp * cy; + quat->z = cr * cp * sy - sr * sp * cy; + + return; +} + + +#ifdef SPLIT_REND_WITH_HEAD_ROT +/*------------------------------------------------------------------------- + * Quat2EulerDegree() + * + * Quaternion handling: calculate corresponding Euler angles in degrees + *------------------------------------------------------------------------*/ + +void Quat2EulerDegree( + const IVAS_QUATERNION quat, /* i : quaternion describing the rotation */ + float *yaw, /* o : yaw */ + float *pitch, /* o : pitch */ + float *roll /* o : roll */ +) +{ + if ( quat.w != -3.0 ) + { + float p; + *yaw = atan2f( 2 * ( quat.w * quat.x + quat.y * quat.z ), 1 - 2 * ( quat.x * quat.x + quat.y * quat.y ) ); + p = 2 * ( quat.w * quat.y - quat.z * quat.x ); + p = max( -1.0f, min( 1.0f, p ) ); + *pitch = asinf( p ); + *roll = atan2f( 2 * ( quat.w * quat.z + quat.x * quat.y ), 1 - 2 * ( quat.y * quat.y + quat.z * quat.z ) ); + *yaw *= _180_OVER_PI; + *pitch *= _180_OVER_PI; + *roll *= _180_OVER_PI; + } + else + { + /* Euler angles in R_X(roll)*R_Y(pitch)*R_Z(yaw) convention + * + * yaw: rotate scene counter-clockwise in the horizontal plane + * pitch: rotate scene in the median plane, increase elevation with positive values + * roll: rotate scene from the right ear to the top + */ + *yaw = quat.z; + *pitch = quat.y; + *roll = quat.x; + } + + return; +} +#endif + + +/*------------------------------------------------------------------------- + * deg2rad() + * + * Converts degrees to normalized radians + *------------------------------------------------------------------------*/ + +float deg2rad( + float degrees ) +{ + while ( degrees >= 180.0f ) + { + degrees = degrees - 360.0f; + } + while ( degrees <= -180.0f ) + { + degrees = degrees + 360.0f; + } + + return PI_OVER_180 * degrees; +} diff --git a/lib_com/ivas_sba_config.c b/lib_com/ivas_sba_config.c index 778a7bb90dff68229e7fc15b099e5e0ae9063f86..64edc48f2708a29536a8a08f0f0048a771a2579a 100644 --- a/lib_com/ivas_sba_config.c +++ b/lib_com/ivas_sba_config.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_sns_com.c b/lib_com/ivas_sns_com.c index da7b37e8c55f2ecfecc5f0439968cf315b39772e..f7ca67fa77149a11fe91a5f6a7994ca320e5dcad 100644 --- a/lib_com/ivas_sns_com.c +++ b/lib_com/ivas_sns_com.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_spar_com.c b/lib_com/ivas_spar_com.c index 096a2955ee99196d3d33da424c47ad4e61acdd07..b960d3bb5129b6d86619086b3b6e56c366587079 100644 --- a/lib_com/ivas_spar_com.c +++ b/lib_com/ivas_spar_com.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_spar_com_quant_util.c b/lib_com/ivas_spar_com_quant_util.c index 977f36e37458e2c1aa267c703815fc344db53092..ca3001a4218bc7d00168b062267bf7d81e740a24 100644 --- a/lib_com/ivas_spar_com_quant_util.c +++ b/lib_com/ivas_spar_com_quant_util.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_stat_com.h b/lib_com/ivas_stat_com.h index 566abcb443e1a588b4592db94fdbe7e939c04cc2..db13dd84c376aec1c82790da9bee14289a91395f 100644 --- a/lib_com/ivas_stat_com.h +++ b/lib_com/ivas_stat_com.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other @@ -595,11 +595,8 @@ typedef struct ivas_parametric_mc_metadata_struct { const PARAM_MC_ILD_MAPPING *ild_mapping_conf; const PARAM_MC_ICC_MAPPING *icc_mapping_conf; - int16_t icc_mapping[PARAM_MC_PARAMETER_FRAMES][PARAM_MC_SZ_ICC_MAP][2]; - int16_t *icc_map_full[2]; int16_t icc_map_size_full; int16_t param_frame_idx; - int16_t flag_use_adaptive_icc_map; const float *ild_factors; int16_t coding_band_mapping[PARAM_MC_MAX_PARAMETER_BANDS]; int16_t nbands_in_param_frame[PARAM_MC_PARAMETER_FRAMES]; diff --git a/lib_com/ivas_stereo_dft_com.c b/lib_com/ivas_stereo_dft_com.c index ae6b772a30f99050ce1311d5c45a52c92e4a41a2..9c073b74f5ffa8ddedd0a63ef1bc3e8767459967 100644 --- a/lib_com/ivas_stereo_dft_com.c +++ b/lib_com/ivas_stereo_dft_com.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_stereo_eclvq_com.c b/lib_com/ivas_stereo_eclvq_com.c index ff78a66eba27d9972f2a72ddb29ed072418d6d3f..168dd1d1a66a411519e11dbf02617c5568b79490 100644 --- a/lib_com/ivas_stereo_eclvq_com.c +++ b/lib_com/ivas_stereo_eclvq_com.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_stereo_ica_com.c b/lib_com/ivas_stereo_ica_com.c index a68a9a709acc072f801cc669b1e33eae02617a42..9902bb30ef60de6adf2cd8407aa17dd932377897 100644 --- a/lib_com/ivas_stereo_ica_com.c +++ b/lib_com/ivas_stereo_ica_com.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_stereo_mdct_bands_com.c b/lib_com/ivas_stereo_mdct_bands_com.c index 19a1295f2de1c68ac3819f9a031e474b97218f6f..51b541ab2cf0ce201daf0b0ab85a05a009d045db 100644 --- a/lib_com/ivas_stereo_mdct_bands_com.c +++ b/lib_com/ivas_stereo_mdct_bands_com.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_stereo_mdct_stereo_com.c b/lib_com/ivas_stereo_mdct_stereo_com.c index c9151b72df87f1e9d08b63734f7177c668f85579..fddd61d3ae551d7477b0104601ba3f0181b8e7ef 100644 --- a/lib_com/ivas_stereo_mdct_stereo_com.c +++ b/lib_com/ivas_stereo_mdct_stereo_com.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_stereo_psychlpc_com.c b/lib_com/ivas_stereo_psychlpc_com.c index ac94d56b0224fe07d8e896dcb5197622559e663b..d60f63580b802df62f5bdca858efda89c81a7cd5 100644 --- a/lib_com/ivas_stereo_psychlpc_com.c +++ b/lib_com/ivas_stereo_psychlpc_com.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_stereo_td_bit_alloc.c b/lib_com/ivas_stereo_td_bit_alloc.c index ce3a5f20feaa61a683c779e1405aeeb32c02e9ca..fd712b5097ba6ce05ca9164c663cbbcc88874110 100644 --- a/lib_com/ivas_stereo_td_bit_alloc.c +++ b/lib_com/ivas_stereo_td_bit_alloc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ivas_tools.c b/lib_com/ivas_tools.c index ee7a06ca7d9b7300b7fd00eff316ef8ccf6ed775..c2183e0e061d86a39f51bd747a053e5fcdf0d431 100644 --- a/lib_com/ivas_tools.c +++ b/lib_com/ivas_tools.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other @@ -41,7 +41,9 @@ #include "ivas_prot.h" #include "wmc_auto.h" #include "ivas_rom_com.h" - +#ifdef NONBE_1319_M2R_PRECISION_ALIGN +#include "basop_settings.h" +#endif /*--------------------------------------------------------------- * sumAbs() * @@ -1252,3 +1254,243 @@ float rand_triangular_signed( return 0.5f - 0.5f * sqrtf( 1.0f - rand_val ); } } + +#ifdef NONBE_1319_M2R_PRECISION_ALIGN +Word16 matrix_product_fx( + const Word32 *X_fx, /* i : left hand matrix Qx*/ + const Word16 rowsX, /* i : number of rows of the left hand matrix Q0*/ + const Word16 colsX, /* i : number of columns of the left hand matrix Q0*/ + const Word16 transpX, /* i : flag indicating the transposition of the left hand matrix prior to the multiplication Q0*/ + const Word32 *Y_fx, /* i : right hand matrix Qy*/ + const Word16 rowsY, /* i : number of rows of the right hand matrix Q0*/ + const Word16 colsY, /* i : number of columns of the right hand matrix Q0*/ + const Word16 transpY, /* i : flag indicating the transposition of the right hand matrix prior to the multiplication Q0*/ + Word32 *Z_fx /* o : resulting matrix after the matrix multiplication Qx + Qy - 31*/ +) +{ + Word16 i, j, k; + Word16 x_idx, y_idx; + Word32 *Zp_fx = Z_fx; + + /* Processing */ + + if ( transpX == 1 && transpY == 0 ) /* We use X transpose */ + { + if ( rowsX != rowsY ) + { + return EXIT_FAILURE; + } + for ( j = 0; j < colsY; ++j ) + { + for ( i = 0; i < colsX; ++i ) + { + ( *Zp_fx ) = 0; + + for ( k = 0; k < rowsX; ++k ) + { + x_idx = k + i * rowsX; /*Q0*/ + y_idx = k + j * rowsY; /*Q0*/ + ( *Zp_fx ) = *Zp_fx + Mpy_32_32( X_fx[x_idx], Y_fx[y_idx] ); /*Qx + Qy - 31*/ + } + Zp_fx++; + } + } + } + else if ( transpX == 0 && transpY == 1 ) /* We use Y transpose */ + { + if ( colsX != colsY ) + { + return EXIT_FAILURE; + } + for ( j = 0; j < rowsY; ++j ) + { + for ( i = 0; i < rowsX; ++i ) + { + ( *Zp_fx ) = 0; + for ( k = 0; k < colsX; ++k ) + { + x_idx = i + k * rowsX; /*Q0*/ + y_idx = j + k * rowsY; /*Q0*/ + ( *Zp_fx ) = ( *Zp_fx ) + Mpy_32_32( X_fx[x_idx], Y_fx[y_idx] ); /*Qx + Qy - 31*/ + } + Zp_fx++; + } + } + } + else if ( transpX == 1 && transpY == 1 ) /* We use both transpose */ + { + if ( rowsX != colsY ) + { + return EXIT_FAILURE; + } + for ( j = 0; j < rowsY; ++j ) + { + for ( i = 0; i < colsX; ++i ) + { + ( *Zp_fx ) = 0; + + for ( k = 0; k < colsX; ++k ) + { + x_idx = k + i * rowsX; /*Q0*/ + y_idx = j + k * rowsY; /*Q0*/ + ( *Zp_fx ) = ( *Zp_fx ) + Mpy_32_32( X_fx[x_idx], Y_fx[y_idx] ); /*Qx + Qy - 31*/ + } + + Zp_fx++; + } + } + } + else /* Regular case */ + { + if ( colsX != rowsY ) + { + return EXIT_FAILURE; + } + + for ( j = 0; j < colsY; ++j ) + { + for ( i = 0; i < rowsX; ++i ) + { + ( *Zp_fx ) = 0; + + for ( k = 0; k < colsX; ++k ) + { + x_idx = i + k * rowsX; /*Q0*/ + y_idx = k + j * rowsY; /*Q0*/ + ( *Zp_fx ) = ( *Zp_fx ) + Mpy_32_32( X_fx[x_idx], Y_fx[y_idx] ); /*Qx + Qy - 31 L_sat_add() */ + /* TODO: overflow of Z_fx to be checked */ + move32(); + } + Zp_fx++; + } + } + } + + return EXIT_SUCCESS; +} + +Word16 matrix_product_q30_fx( + const Word32 *X_fx, /* i : left hand matrix Q31*/ + const Word16 rowsX, /* i : number of rows of the left hand matrix Q0*/ + const Word16 colsX, /* i : number of columns of the left hand matrix Q0*/ + const Word16 transpX, /* i : flag indicating the transposition of the left hand matrix prior to the multiplication Q0*/ + const Word32 *Y_fx, /* i : right hand matrix Q25*/ + const Word16 rowsY, /* i : number of rows of the right hand matrix Q0*/ + const Word16 colsY, /* i : number of columns of the right hand matrix Q0*/ + const Word16 transpY, /* i : flag indicating the transposition of the right hand matrix prior to the multiplication Q0*/ + Word32 *Z_fx /* o : resulting matrix after the matrix multiplication Q30*/ +) +{ + Word16 i, j, k; + Word16 x_idx, y_idx; + Word32 *Zp_fx = Z_fx; + int64_t W_tmp; + + /* Processing */ + test(); + test(); + test(); + if ( transpX == 1 && transpY == 0 ) /* We use X transpose */ + { + if ( rowsX != rowsY ) + { + return EXIT_FAILURE; + } + for ( j = 0; j < colsY; ++j ) + { + for ( i = 0; i < colsX; ++i ) + { + W_tmp = 0; + for ( k = 0; k < rowsX; ++k ) + { + /*( *Zp_fx ) = L_add( *Zp_fx, Mpy_32_32( X_fx[k + i * rowsX], Y_fx[k + j * rowsY] ) ); */ + x_idx = k + i * rowsX; /* Q0 */ + y_idx = k + j * rowsY; /* Q0 */ + W_tmp += ( (int64_t) X_fx[x_idx] * (int64_t) Y_fx[y_idx] ); /* Q56 */ + } + W_tmp = W_tmp * 64; /* W_shl( W_tmp, 6 ); */ /*Q62*/ + ( *Zp_fx ) = ( W_tmp + 0x80000000 ) >> 32; /* W_round64_L( W_tmp ); */ /*Q30*/ + Zp_fx++; + } + } + } + else if ( transpX == 0 && transpY == 1 ) /* We use Y transpose */ + { + if ( colsX != colsY ) + { + return EXIT_FAILURE; + } + for ( j = 0; j < rowsY; ++j ) + { + for ( i = 0; i < rowsX; ++i ) + { + W_tmp = 0; + for ( k = 0; k < colsX; ++k ) + { + /* ( *Zp_fx ) = L_add( *Zp_fx, Mpy_32_32( X_fx[i + k * rowsX], Y_fx[j + k * rowsY] ) ); */ + x_idx = i + k * rowsX; /*Q0*/ + y_idx = j + k * rowsY; /*Q0*/ + W_tmp += ( (int64_t) X_fx[x_idx] * (int64_t) Y_fx[y_idx] ); /* Q56 */ + } + W_tmp = W_tmp * 64; /*Q62*/ + ( *Zp_fx ) = ( W_tmp + 0x80000000 ) >> 32; /*Q30*/ + Zp_fx++; + } + } + } + else if ( transpX == 1 && transpY == 1 ) /* We use both transpose */ + { + if ( rowsX != colsY ) + { + return EXIT_FAILURE; + } + for ( j = 0; j < rowsY; ++j ) + { + for ( i = 0; i < colsX; ++i ) + { + W_tmp = 0; + for ( k = 0; k < colsX; ++k ) + { + /* ( *Zp_fx ) = L_add( *Zp_fx, Mpy_32_32( X_fx[k + i * rowsX], Y_fx[j + k * rowsY] ) ); */ + x_idx = k + i * rowsX; /*Q0*/ + y_idx = j + k * rowsY; /*Q0*/ + W_tmp += ( (int64_t) X_fx[x_idx] * (int64_t) Y_fx[y_idx] ); /* Q56*/ + } + W_tmp = W_tmp * 64; /*Q62*/ + ( *Zp_fx ) = ( W_tmp + 0x80000000 ) >> 32; /*Q30*/ + + Zp_fx++; + } + } + } + else /* Regular case */ + { + if ( colsX != rowsY ) + { + return EXIT_FAILURE; + } + + for ( j = 0; j < colsY; ++j ) + { + for ( i = 0; i < rowsX; ++i ) + { + W_tmp = 0; + + for ( k = 0; k < colsX; ++k ) + { + /* ( *Zp_fx ) = L_add( *Zp_fx, Mpy_32_32( X_fx[i + k * rowsX], Y_fx[k + j * rowsY] ) ); */ + x_idx = i + k * rowsX; /*Q0*/ + y_idx = k + j * rowsY; /*Q0*/ + W_tmp += ( (int64_t) X_fx[x_idx] * (int64_t) Y_fx[y_idx] ); /* Q56*/ + } + W_tmp = W_tmp * 64; /*Q62*/ + ( *Zp_fx ) = ( W_tmp + 0x80000000 ) >> 32; /*Q30*/ + + Zp_fx++; + } + } + } + + return EXIT_SUCCESS; +} +#endif diff --git a/lib_com/ivas_transient_det.c b/lib_com/ivas_transient_det.c index 54c12e916f97a49fda4a5a70eba6617000eaa2b3..477e2090f218c9a0d521fde8f1a2c1f791098fa1 100644 --- a/lib_com/ivas_transient_det.c +++ b/lib_com/ivas_transient_det.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/lag_wind.c b/lib_com/lag_wind.c index c4c5e803beedaf2433793bce428f329326f7978e..af1ea8a1e7ca33b3f9f2964377da228ebd565242 100644 --- a/lib_com/lag_wind.c +++ b/lib_com/lag_wind.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/lerp.c b/lib_com/lerp.c index 60e7bf628e415ed8bef6c440aaee372eb04f9dbb..177b1fdaceed88ce13c6d8ceebafc26a87365925 100644 --- a/lib_com/lerp.c +++ b/lib_com/lerp.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/limit_t0.c b/lib_com/limit_t0.c index 0a844bbc5d72755f841126249cc52eeb5bb78682..d24dada8a5dc86312bff384581aa58e0cab25632 100644 --- a/lib_com/limit_t0.c +++ b/lib_com/limit_t0.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/logqnorm.c b/lib_com/logqnorm.c index c8185dd5a20322a4be7941cecf359a6e91d647b8..b86a0e41bec0c6f6deaa92670795181127b60348 100644 --- a/lib_com/logqnorm.c +++ b/lib_com/logqnorm.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/longarith.c b/lib_com/longarith.c index 01a20c8417ea0091294f13b06829e567afcba36f..2f31a80a4ea6b056450218941c04ecef247c397b 100644 --- a/lib_com/longarith.c +++ b/lib_com/longarith.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/low_rate_band_att.c b/lib_com/low_rate_band_att.c index 393cae5ff24ba1eab58e016dc99736ad53d2e87b..1dcfa683193473690ec7a6730ef076c1030ace5c 100644 --- a/lib_com/low_rate_band_att.c +++ b/lib_com/low_rate_band_att.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/lpc_tools.c b/lib_com/lpc_tools.c index df36ad2b0ee4d025d4080b39d135bbd2441d831c..e6880efbbe7cb3e0c5754b4b9ff5a0809a661cd2 100644 --- a/lib_com/lpc_tools.c +++ b/lib_com/lpc_tools.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/lsf_dec_bfi.c b/lib_com/lsf_dec_bfi.c index 70506b293c18856de3fad6c631b25648dc8fb9d5..86a0b080e5baf0a107a97d2070b8ca1b0e4d4a68 100644 --- a/lib_com/lsf_dec_bfi.c +++ b/lib_com/lsf_dec_bfi.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/lsf_msvq_ma.c b/lib_com/lsf_msvq_ma.c index 3396e9fde2ea604d13600ab510207d73dd1ebe71..b805f27d098e99380dfe5975692fb109747dcb50 100644 --- a/lib_com/lsf_msvq_ma.c +++ b/lib_com/lsf_msvq_ma.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/lsf_tools.c b/lib_com/lsf_tools.c index b99f72d27a237743a8a23733a64180abb4ef4874..4277fa20b762a227b3bc2a4a66ed823f57baf345 100644 --- a/lib_com/lsf_tools.c +++ b/lib_com/lsf_tools.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/lsp_conv_poly.c b/lib_com/lsp_conv_poly.c index d43d74fb5a8c73e6520a0a48fe1f6b34daa0d118..9bbc585252afe76b3eb9a856421461ae3192bcc2 100644 --- a/lib_com/lsp_conv_poly.c +++ b/lib_com/lsp_conv_poly.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/mime.h b/lib_com/mime.h index 56f2fb4db96c6281ff0f0c57484480e56be8dd02..6e9e5fc87f48c20b650b2872fcf0401ec05bcbfa 100644 --- a/lib_com/mime.h +++ b/lib_com/mime.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/modif_fs.c b/lib_com/modif_fs.c index f1ae7c61d4571334e597980e53ff09970f80db54..c3567d61f44124062c99aebb5fa197f11d946969 100644 --- a/lib_com/modif_fs.c +++ b/lib_com/modif_fs.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/move.h b/lib_com/move.h index becc9314d2c42a205771aa236b0d6d3536b17ac8..6fc39c966018f884c56940eff5111f8caa36ea8b 100644 --- a/lib_com/move.h +++ b/lib_com/move.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/mslvq_com.c b/lib_com/mslvq_com.c index 840866222e73cc31315af1f97e056ab6b919c5b5..d07dd8076320902cd07ccc75b624d2eeb1043579 100644 --- a/lib_com/mslvq_com.c +++ b/lib_com/mslvq_com.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/nelp.c b/lib_com/nelp.c index 768b92f915f96879b0a2288a93a529db235d7a8e..887f412c386e35235f03711fc08cce0262c4c750 100644 --- a/lib_com/nelp.c +++ b/lib_com/nelp.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/options.h b/lib_com/options.h index 96fc0ec76d765a1642ed2ab41a0e50e84398025b..514ac42b0e4381360a6c637ed271beaf08fcace1 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other @@ -73,6 +73,7 @@ /*#define DEBUG_MODE_INFO_PLC */ /* define to output PLC related parameters */ /*#define DEBUG_MODE_INFO_ALLRAD*/ /* define to output generated HOA decoding mtx */ /*#define DEBUG_MODE_LFE */ /* define to output LFE relevant parameters */ +/*#define DEBUG_FORCE_DIR*/ /* Force modes/parameters by reading from external binary files */ #endif #define SUPPORT_FORCE_TCX10_TCX20 /* VA: Enable -force tcx10|tcx20 command-line option */ @@ -133,6 +134,7 @@ /*Split Rendering Debug switches*/ /*#define DBG_WAV_WRITER*/ /* add debugging function dbgwrite_wav() */ +/*#define SPLIT_REND_WITH_HEAD_ROT_DEBUG*/ /* debugging switch for split rendering */ /*#define SPLIT_POSE_CORRECTION_DEBUG*/ /* debugging switch for split rendering pose correction */ /*#define SPLIT_MD_CODING_DEBUG*/ /* debugging switch for split rendering metadata coding */ @@ -174,12 +176,36 @@ #define NONBE_1233_HQ_CLASSIFIER_DIV_BY_ZERO /* Eri: issue 1233: Address possible division by zero in hf_spectrum_sparseness() */ #define NONE_BE_FIX_BASOP_1044_OSBA_PRERENDER_MIX_GAINS /* DLB: adjust prerendering and mixing gain in OSBA encoder. This is fix to float codes*/ -#define FIX_929_RENDERER_CMDL /* Nokia: issue #929: renderer command line option */ +#define NONBE_1211_DTX_BR_SWITCHING /* VA: port float issue 1211: fix crash in MASA DTX bitrate switching */ +#define NONBE_FIX_1189_GSC_IVAS_OMASA /* VA: Fix for issue 1189: Bitstream desynchornization due to reading/writing of the GSC_IVAS_mode parameter */ +#define NONBE_FIX_1087_OOB_SBA_DTX_RS /* VA: issue 1087: Extend the length of the buffer for MCT decoding to avoid out-of-bound writing in SBA SID bitrate switching decoding */ +#define FIX_920_IGF_INIT_ERROR /* FhG: issue 920: fix bitrate mismatch in initial IGF config to avoid error message in same cases */ +#define NONBE_1273_ISM_METADATA_COUNTER /* VA: FLP issue 1273: fix counter overflow in ISM metadata encoder */ +#define NONBE_FIX_GSC_BSTR /* VA: issue 1264 FLP (1189 BASOP): Fix bitstream synchronization between encoder and decoder in ACELP GSC in OMASA */ +#define NONBE_FIX_1277_EVS_DTX_HIGH_RATE_THRESHOLD /* VA/Eri: FLP issue 1277: Fix Mismatch in DTX high-rate threshold between EVS float and BASOP */ +#define NONBE_FIX_708_OSBA_BR_SWITCHING_CRASH /* FhG: issue 708: fix crash in OSBA BR switching with long test vectors */ + + +#define NONBE_1319_M2R_PRECISION_ALIGN /* Nokia: bring updates from PC code related to OMASA masa2total ratios */ /* #################### End FIXES switches ############################ */ #define BASOP_NOGLOB /* Disable global symbols in BASOPs, Overflow/Carry in BASOPs disabled, additional BASOPs in case of Overflow */ +/* #################### Start BASOP porting switches ############################ */ + +#define SPLIT_REND_WITH_HEAD_ROT /* Dlb,FhG: Split Rendering contributions 21 and 35 */ +#ifdef SPLIT_REND_WITH_HEAD_ROT +#define SPLIT_REND_POSE_CORRECTION_UNUSED_BITS +#define ISAR_BITSTREAM_UPDATE_LC3PLUS /* FhG: Multiple improvements to the ISAR bitstream when LC3plus is used. See MR 1456 for details. */ +#endif +#define NONBE_FIX_855_JBM_FLUSH_OFFSET /* FhG: issue #855: add missing switch here for the code in JBM flushing */ +#define FIX_923_EXTERNAL_REND_COMMAND_LINE /* VA: issue 923: enable external renderer command-line options in UPPER case letters */ +#define FIX_921_OMASA_DELAY_PRINTOUT /* VA: issue 921: correct OMASA decoder delay printout */ +#define NONBE_FIX_926_OSBA_DECODER_CRASH_PLANAR_SBA /* FhG: issue 926: crash in OSBA decoding with planar FOA */ +#define FIX_929_RENDERER_CMDL /* Nokia: issue #929: renderer command line option */ + +/* #################### End BASOP porting switches ############################ */ /* clang-format on */ diff --git a/lib_com/parameter_bitmaping.c b/lib_com/parameter_bitmaping.c index d722c8a3b326deedd3cde800baf021908ecb55f5..5b9c89862bc6b875390650a55e1fd5c47ff6b79a 100644 --- a/lib_com/parameter_bitmaping.c +++ b/lib_com/parameter_bitmaping.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/phase_dispersion.c b/lib_com/phase_dispersion.c index a89b98c152e7c2abc13d180b4377189b25c4a60c..c9926de16bc216340151cf796543df2a28a4f80c 100644 --- a/lib_com/phase_dispersion.c +++ b/lib_com/phase_dispersion.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/ppp.c b/lib_com/ppp.c index 882c94b6964bbb67b53875a5f8d0ac2502ac44ac..cb63ef78b1d1cd18e9cc8865c9891000a8782a94 100644 --- a/lib_com/ppp.c +++ b/lib_com/ppp.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/pred_lt4.c b/lib_com/pred_lt4.c index 832c7d0dc5353604cdb85bf97c7613020ec18ea1..abee4b097089e975f34f667956e44ce0467c600b 100644 --- a/lib_com/pred_lt4.c +++ b/lib_com/pred_lt4.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/preemph.c b/lib_com/preemph.c index 5e5eb23416f8c62988a2b24d22c6e3c138f305e1..80405af568885765489f17c910589a36c864ba52 100644 --- a/lib_com/preemph.c +++ b/lib_com/preemph.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/prot.h b/lib_com/prot.h index 8a674e9827e7672501885f8dbdfdc7cc88b77529..57f477420184a530e4100490ce5e4d087c14a9a7 100644 --- a/lib_com/prot.h +++ b/lib_com/prot.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other @@ -721,6 +721,10 @@ int32_t get_delay( const int32_t io_fs, /* i : input/output sampling frequency */ const IVAS_FORMAT ivas_format, /* i : IVAS format */ HANDLE_CLDFB_FILTER_BANK hCldfb /* i : Handle of Cldfb analysis */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + , + const AUDIO_CONFIG output_config /* i : decoder output config */ +#endif ); void decision_matrix_enc( @@ -3548,12 +3552,17 @@ void highband_exc_dct_in( ); void inact_switch_ematch( - float exc2[], /* i/o: CELP/GSC excitation buffer */ - float dct_exc_tmp[], /* i : GSC excitation in DCT domain */ - float lt_ener_per_band[], /* i/o: long-term energy per band */ - const int16_t coder_type, /* i : coder type */ - const int16_t L_frame, /* i : frame length */ - const int32_t total_brate, /* i : Total bitrate */ + float exc2[], /* i/o: CELP/GSC excitation buffer */ + float dct_exc_tmp[], /* i : GSC excitation in DCT domain */ + float lt_ener_per_band[], /* i/o: long-term energy per band */ + const int16_t coder_type, /* i : coder type */ +#ifdef NONBE_FIX_GSC_BSTR + const int16_t inactive_coder_type_flag, /* i : AVQ (0) or GSC (1) IC flag */ +#endif + const int16_t L_frame, /* i : frame length */ +#ifndef NONBE_FIX_GSC_BSTR + const int32_t total_brate, /* i : Total bitrate */ +#endif const int16_t bfi, /* i : frame lost indicator */ const int16_t last_core, /* i : Last core used */ const int16_t last_codec_mode, /* i : Last codec mode */ @@ -3902,8 +3911,11 @@ void td_cng_enc_init( ); void dtx( - Encoder_State *st, /* i/o: encoder state structure */ - const int32_t ivas_total_brate, /* i : IVAS total bitrate */ + Encoder_State *st, /* i/o: encoder state structure */ +#ifdef NONBE_1211_DTX_BR_SWITCHING + const int32_t last_ivas_total_brate, /* i : last IVAS total bitrate */ +#endif + const int32_t ivas_total_brate, /* i : IVAS total bitrate */ const int16_t vad, /* i : VAD flag for DTX */ const float speech[] /* i : Pointer to the speech frame */ ); @@ -6759,7 +6771,10 @@ float correlation_shift( void init_coder_ace_plus( Encoder_State *st, /* i : Encoder state handle */ const int32_t last_total_brate, /* i : last total bitrate */ - const int16_t MCT_flag /* i : hMCT handle allocated (1) or not (0)*/ +#ifdef FIX_920_IGF_INIT_ERROR + const int32_t igf_brate, /* i : IGF configuration bitrate */ +#endif + const int16_t MCT_flag /* i : hMCT handle allocated (1) or not (0)*/ ); void core_coder_reconfig( @@ -9081,17 +9096,20 @@ int16_t BITS_ALLOC_config_acelp( ); ivas_error config_acelp1( - const int16_t enc_dec, /* i : encoder/decoder flag */ - const int32_t total_brate, /* i : total bitrate */ - const int32_t core_brate_inp, /* i : core bitrate */ - const int16_t core, /* i : core */ - const int16_t extl, /* i : extension layer */ - const int32_t extl_brate, /* i : extension layer bitrate */ - const int16_t L_frame, /* i : frame length at internal Fs */ - const int16_t GSC_noisy_speech, /* i : GSC on SWB noisy speech flag */ - ACELP_config *acelp_cfg, /* i : ACELP bit-allocation */ - const int16_t signaling_bits, /* i : number of signaling bits */ - const int16_t coder_type, /* i : coder type */ + const int16_t enc_dec, /* i : encoder/decoder flag */ + const int32_t total_brate, /* i : total bitrate */ + const int32_t core_brate_inp, /* i : core bitrate */ + const int16_t core, /* i : core */ + const int16_t extl, /* i : extension layer */ + const int32_t extl_brate, /* i : extension layer bitrate */ + const int16_t L_frame, /* i : frame length at internal Fs */ + const int16_t GSC_noisy_speech, /* i : GSC on SWB noisy speech flag */ + ACELP_config *acelp_cfg, /* i : ACELP bit-allocation */ + const int16_t signaling_bits, /* i : number of signaling bits */ + const int16_t coder_type, /* i : coder type */ +#ifdef NONBE_FIX_GSC_BSTR + const int16_t inactive_coder_type_flag, /* i : AVQ (0) or GSC (1) IC flag */ +#endif const int16_t tc_subfr, /* i : TC subfr ID */ const int16_t tc_call, /* i : TC call number (0,1,2) */ int16_t *nBits_es_Pred, /* o : number of bits for Es_pred Q */ diff --git a/lib_com/pvq_com.c b/lib_com/pvq_com.c index 2368f8436830d2e36068170df8ddc47c5d2e9d38..ca3f2d6c4478d2b6fb2a724d01b030bd05a27f9a 100644 --- a/lib_com/pvq_com.c +++ b/lib_com/pvq_com.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/range_com.c b/lib_com/range_com.c index b01dc7156e972acaeed28c5dc20c8092f9f1b82c..bd719724c1f6b4ed2be8a388dc5becf043d320df 100644 --- a/lib_com/range_com.c +++ b/lib_com/range_com.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/re8_ppv.c b/lib_com/re8_ppv.c index f6c5ab6814fd7adb4791161132f666ee2b9b3e55..bff83be7f9e367bdf36f2955b07ea2b56e65349c 100644 --- a/lib_com/re8_ppv.c +++ b/lib_com/re8_ppv.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/re8_util.c b/lib_com/re8_util.c index d23ae1c0cd7848b92fb9cbc928d4e51296690aa2..fd895ba8a98815313298394ed9c28f469cd7cbfe 100644 --- a/lib_com/re8_util.c +++ b/lib_com/re8_util.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/realft.c b/lib_com/realft.c index b7a3fef0d9db4561a1456b336c79522ef99b9457..186b336722a8d4390ea4af0801981d56aba7042a 100644 --- a/lib_com/realft.c +++ b/lib_com/realft.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/recovernorm.c b/lib_com/recovernorm.c index 52e9edcd2a0c02c9249a8139441eb6791582d446..05ea13f1a717663a9c43c60dee4d3ab485accc09 100644 --- a/lib_com/recovernorm.c +++ b/lib_com/recovernorm.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/reordvct.c b/lib_com/reordvct.c index 182050bfb65a2449045a887e88171454d5d8181a..6fb169314ed08d1b7112e42bcc0729a164c7b6c1 100644 --- a/lib_com/reordvct.c +++ b/lib_com/reordvct.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/residu.c b/lib_com/residu.c index e220d81c01d2b60118d0b0186a47d6a6104ebe17..96503988ed0d9b2ad33a5fb29bd55a410bcc422e 100644 --- a/lib_com/residu.c +++ b/lib_com/residu.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/rom_com.c b/lib_com/rom_com.c index f08f41a1df98eeb46a454f40d21a09ed61aad5e3..754e1b21e9c6391c8a58846b0785c65edffbfe3c 100644 --- a/lib_com/rom_com.c +++ b/lib_com/rom_com.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/rom_com.h b/lib_com/rom_com.h index ad234e26d437c082c9cc11e0625220f0aa2a5275..3a6db136fa0b406eac772d24f1eaf4ee66e9d3d3 100644 --- a/lib_com/rom_com.h +++ b/lib_com/rom_com.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/stab_est.c b/lib_com/stab_est.c index 63466220c68c882d71e6834c3b3e749a62166c39..5b9ab0c07917f741e58daaba7cd7f4d3956b13de 100644 --- a/lib_com/stab_est.c +++ b/lib_com/stab_est.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/stat_com.h b/lib_com/stat_com.h index 90203dc4700abd848353e13423f3ab42c2386895..622a07eb1f84f4effef66fd4f09ded4af332e43c 100644 --- a/lib_com/stat_com.h +++ b/lib_com/stat_com.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/stat_noise_uv_mod.c b/lib_com/stat_noise_uv_mod.c index 83c2d321cc584155851be33d275dc97ab459eb33..e6cb199935e259726ce92b5db562468774fc62e0 100644 --- a/lib_com/stat_noise_uv_mod.c +++ b/lib_com/stat_noise_uv_mod.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/stl.h b/lib_com/stl.h index be5722630e76b3c12ba828d6ec9b149c7e4702e7..5389c3c3a27da2664f2c0b94297376002025733e 100644 --- a/lib_com/stl.h +++ b/lib_com/stl.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/swb_bwe_com.c b/lib_com/swb_bwe_com.c index 4efbaa735d22eaa1acb8748e6c77c154c380e68f..00de3a838c3d9d069bf2c9fa741d4d34bf4178f0 100644 --- a/lib_com/swb_bwe_com.c +++ b/lib_com/swb_bwe_com.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/swb_bwe_com_hr.c b/lib_com/swb_bwe_com_hr.c index fbdcf70b93b600faa5e949ec6e0776375d2d1337..ddf1cc1341d6ede89ba8fbb24b4392bcc5bfeaf9 100644 --- a/lib_com/swb_bwe_com_hr.c +++ b/lib_com/swb_bwe_com_hr.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/swb_bwe_com_lr.c b/lib_com/swb_bwe_com_lr.c index daa7d167376ba9e5c2ef88de1601d8448af83935..048e02456e7a37e04e00632f7c58fcab87e39992 100644 --- a/lib_com/swb_bwe_com_lr.c +++ b/lib_com/swb_bwe_com_lr.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/swb_tbe_com.c b/lib_com/swb_tbe_com.c index 768078e27ff0795b792bf88d8ff96c4b091be9af..13541d7c32b7764919ada696a5c00b04d069bb0a 100644 --- a/lib_com/swb_tbe_com.c +++ b/lib_com/swb_tbe_com.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/syn_12k8.c b/lib_com/syn_12k8.c index 15892f62c615bcdae800ca87e2ee9960a0d2293e..7a91626bb776e4e08afe98b1e58ad3c6c96beb5d 100644 --- a/lib_com/syn_12k8.c +++ b/lib_com/syn_12k8.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/syn_filt.c b/lib_com/syn_filt.c index 08e687c12cdbe5fa7084314b2a387b856a213d99..d0d2adb49d5c47ce2c1d3384535c59a26eaaaf59 100644 --- a/lib_com/syn_filt.c +++ b/lib_com/syn_filt.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/tcq_position_arith.c b/lib_com/tcq_position_arith.c index 306f29a60b6cecbe071f6bc9a22d9c7389bd5517..1c46ea4e8379d7afffa8bb659f5d9fbb6408dab7 100644 --- a/lib_com/tcq_position_arith.c +++ b/lib_com/tcq_position_arith.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/tcx_ltp.c b/lib_com/tcx_ltp.c index 1711ad24b35e3219360d3ef0cce3e602aeb5d3ce..f36af601304c28cfb06ceb518b7a21f5be8f71aa 100644 --- a/lib_com/tcx_ltp.c +++ b/lib_com/tcx_ltp.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/tcx_mdct.c b/lib_com/tcx_mdct.c index e8ac35d07aa1c67f1cc385de95ad4330e8d38464..f66b508e68fae0bcb62eaf2e8025e4cca65e1341 100644 --- a/lib_com/tcx_mdct.c +++ b/lib_com/tcx_mdct.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/tcx_mdct_window.c b/lib_com/tcx_mdct_window.c index 0ef69587a8a690b4ee5917a5f6e12bace8317394..61163fe8ab138355bcce1a10fbbb99ae8b58a3de 100644 --- a/lib_com/tcx_mdct_window.c +++ b/lib_com/tcx_mdct_window.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/tcx_utils.c b/lib_com/tcx_utils.c index ec219456b089e0c7a44d09f42e2f1a6a8498f980..458a43d72bf7b49254959d4897d88f997ce6e922 100644 --- a/lib_com/tcx_utils.c +++ b/lib_com/tcx_utils.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/tec_com.c b/lib_com/tec_com.c index 346d38292b237a1271c2d12d84dd9dbedfed14a6..e343cee5baf7bd782d407c245ef38ec31e2d41e1 100644 --- a/lib_com/tec_com.c +++ b/lib_com/tec_com.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/tns_base.c b/lib_com/tns_base.c index 20e679c3167406981d5131f6f325e9defa87e545..9f34bdfc3ed70e8f67bc34dab751418f7be3a853 100644 --- a/lib_com/tns_base.c +++ b/lib_com/tns_base.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/tools.c b/lib_com/tools.c index ecd2fdbfa4335d846d5eba766498779445adb374..3225cefc5b8a27e378a8eb46d99ed0f5b3f3b7aa 100644 --- a/lib_com/tools.c +++ b/lib_com/tools.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/trans_direct.c b/lib_com/trans_direct.c index 964ba36f76cb531d2dee5a5b7e750a42374f38c4..ece693492915d911b213e6ef01176be9b2483ac0 100644 --- a/lib_com/trans_direct.c +++ b/lib_com/trans_direct.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/trans_inv.c b/lib_com/trans_inv.c index 1eea807b2ffe951fcb9df0598f8135a5a333ccc4..620be7a1786a04740b45f3a00645da1971fe67bd 100644 --- a/lib_com/trans_inv.c +++ b/lib_com/trans_inv.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/typedef.h b/lib_com/typedef.h index 9b1ed7bc9327f535c43c82018a4ee7d6e3a5e031..9bc5ad1c7ee2d85f388d2ac58c7b5b8ec8ab5389 100644 --- a/lib_com/typedef.h +++ b/lib_com/typedef.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/vlpc_2st_com.c b/lib_com/vlpc_2st_com.c index e180454c3e412fbba0de5970fdc6ae0173705531..ccbfeda230de7cbfb47cbcfef99dee1725420871 100644 --- a/lib_com/vlpc_2st_com.c +++ b/lib_com/vlpc_2st_com.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/weight.c b/lib_com/weight.c index 6c2e1c291af10340e0883d603fbb559fc1b5b309..48741d88bc14dc251bbd974c716405bad67d1ca0 100644 --- a/lib_com/weight.c +++ b/lib_com/weight.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/weight_a.c b/lib_com/weight_a.c index 96b8014e41ceb31bed1edbd4067e1fe2f628d509..169e98573bd5ca9a007114ef2b44f1d94ae947dd 100644 --- a/lib_com/weight_a.c +++ b/lib_com/weight_a.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/wi.c b/lib_com/wi.c index 7ec30010fe0365b2eb6a84cc8a295790afd98ca8..d5e75d251f42178fc3a84a0bbf9bae0397d27f31 100644 --- a/lib_com/wi.c +++ b/lib_com/wi.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/window.c b/lib_com/window.c index 093dbd4fc62342b2d96d2706ef31a04c1a36a201..a3fcaf6e142fc9335dd4a19745cb259fc1bc5963 100644 --- a/lib_com/window.c +++ b/lib_com/window.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/window_ola.c b/lib_com/window_ola.c index 07798af16ed4fcdadbe7dfbfb90251c0c9235d04..93a0412e25e1fc84c8f6c66fec42258a12b1765b 100644 --- a/lib_com/window_ola.c +++ b/lib_com/window_ola.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_com/wtda.c b/lib_com/wtda.c index 3bd839e5ac4f9b28121f77ad819a2f59cc7ef316..4d051661a0ea0d6dd203bf181b91f221c41601b4 100644 --- a/lib_com/wtda.c +++ b/lib_com/wtda.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_debug/debug.c b/lib_debug/debug.c index c6a5f8c5efa24502f2b76d2e4d33c4b937ec49eb..440d1f7a06589e6951fb78c88d0faec227338328 100644 --- a/lib_debug/debug.c +++ b/lib_debug/debug.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other @@ -364,6 +364,13 @@ int16_t dbgread( { index = in_count; in_fileptr[index] = fopen( filename, "rb" ); +#ifdef DEBUG_FORCE_DIR + if ( in_fileptr[index] == NULL ) + { + /* file does not exist or could not be opened -> just return */ + return -1; + } +#endif in_filename[index] = malloc( sizeof( char ) * ( strlen( filename ) + 1 ) ); strcpy( in_filename[index], filename ); in_count++; @@ -752,7 +759,7 @@ int16_t tweakdbgfolder( const char *filename, char *filename_mod, int16_t *textm #endif -#ifdef DEBUG_MODE_INFO +#ifdef DEBUGGING /*-------------------------------------------------------------------* * fname() * @@ -772,12 +779,21 @@ char *fname( const int16_t id, const int16_t enc_dec ) { - char idd[6]; - - assert( id < 100 ); - sprintf( idd, ".id%d", id ); + char idd[5] = ".idX"; + idd[3] = (char) ( id + '0' ); +#ifdef DEBUG_FORCE_DIR + size_t len; +#endif strcpy( tmp_fname, dir ); +#ifdef DEBUG_FORCE_DIR + len = strlen( tmp_fname ); + if ( tmp_fname[len - 1] != '/' && tmp_fname[len - 1] != '\\' ) + { + /* add trailing '/' slash */ + strcat( tmp_fname, "/" ); + } +#endif strcat( tmp_fname, file ); if ( enc_dec == DEC ) diff --git a/lib_debug/debug.h b/lib_debug/debug.h index ac2ac689b8a5fe768b5629c07239f41364995761..62102e95ec107efeca8065afb72bb72c2ab20489 100644 --- a/lib_debug/debug.h +++ b/lib_debug/debug.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other @@ -60,12 +60,16 @@ extern int16_t debug_level; #define DEBUG_LINE( level ) if ( 0 ) #endif -#ifdef DEBUG_MODE_INFO +#ifdef DEBUGGING extern char tmp_fname[]; extern char debug_dir[6]; char *fname( char *dir, char *file, const int16_t n, const int16_t id, const int16_t enc_dec ); #endif +#ifdef DEBUG_FORCE_DIR +#define FORCE_DIR_MAX_LENGTH 255 /* maximum length of the directory for modes/parameters enforcement */ +#endif + /*------------------------------------------------------------------------------------------* * Read/write I/O tool *------------------------------------------------------------------------------------------*/ diff --git a/lib_debug/sba_debug.c b/lib_debug/sba_debug.c index de4b549aacb5150c0010871700add2d0f9245043..14ab0a16ed8c54257cdcc613ce8d0523b000a5e1 100644 --- a/lib_debug/sba_debug.c +++ b/lib_debug/sba_debug.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_debug/sba_debug.h b/lib_debug/sba_debug.h index a314d1568cc2df74be82d26610a30b00e78b6866..2be427d524e82f92deec2ab9e8c0964374474dab 100644 --- a/lib_debug/sba_debug.h +++ b/lib_debug/sba_debug.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_debug/snr.c b/lib_debug/snr.c index 3e817287c744ee5f32d41744bd1300e0885c204c..cf15a2907b50dec0580121c2773f91191c8b4afc 100644 --- a/lib_debug/snr.c +++ b/lib_debug/snr.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ACcontextMapping_dec.c b/lib_dec/ACcontextMapping_dec.c index 5139106d9fe8834d8fed53536ae2a244c34fd936..9b2ea07e817e83816ef7fc3c34666085455007c5 100644 --- a/lib_dec/ACcontextMapping_dec.c +++ b/lib_dec/ACcontextMapping_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other @@ -348,9 +348,11 @@ int16_t RCcontextMapping_decode2_no_mem_s17_LCS( int16_t lastnz, n; uint16_t r; int16_t resQBits; +#ifdef DEBUGGING + int16_t nbbits_m2; int16_t rest_bits; +#endif int16_t nt_half; - int16_t nbbits_m2; int16_t bits_tups; /* No. of bits for coding the no. of tuples */ set_s( x, 0, nt ); @@ -424,8 +426,10 @@ int16_t RCcontextMapping_decode2_no_mem_s17_LCS( /* Initialize range decoder */ rc_uni_dec_init( &rc_st_dec, &st->bit_stream[st->next_bit_pos], nbbits ); /* (nbbits + 30) entries are read by the decoder */ +#ifdef DEBUGGING nbbits_m2 = nbbits; rest_bits = -nbbits_m2; +#endif /* Main Loop through the 2-tuples */ for ( k = 0; k < lastnz; k += 2 ) @@ -484,11 +488,13 @@ int16_t RCcontextMapping_decode2_no_mem_s17_LCS( a += a1 << lev; b += b1 << lev; +#ifdef DEBUGGING /* Add 2 LSB bits per bit-plane */ rest_bits += 2 * lev; /* Sign bits */ rest_bits += min( a, 1 ); rest_bits += min( b, 1 ); +#endif /* Update bitstream pointer */ st->next_bit_pos = start_bit_pos + bits_tups + rc_uni_dec_virtual_finish( &rc_st_dec ); @@ -570,8 +576,10 @@ int16_t RCcontextMapping_decode2_no_mem_s17_LCS( /* Initialize range decoder */ rc_uni_dec_init( &rc_st_dec, &st->bit_stream[st->next_bit_pos], nbbits ); /* (nbbits + 30) entries are read by the decoder */ +#ifdef DEBUGGING nbbits_m2 = nbbits; rest_bits = -nbbits_m2; +#endif t = 0; s = 0; @@ -624,11 +632,13 @@ int16_t RCcontextMapping_decode2_no_mem_s17_LCS( a += a1 << lev; b += b1 << lev; +#ifdef DEBUGGING /* Add 2 LSB bits per bit-plane */ rest_bits += 2 * lev; /* Sign bits */ rest_bits += min( a, 1 ); rest_bits += min( b, 1 ); +#endif /* Update bitstream pointer */ st->next_bit_pos = start_bit_pos + bits_tups + rc_uni_dec_virtual_finish( &rc_st_dec ); diff --git a/lib_dec/FEC.c b/lib_dec/FEC.c index c0db9325f504d743f2416272dc16a8e2859f7552..b4742e576504bdd94b4b8037d47d4a5cc740585c 100644 --- a/lib_dec/FEC.c +++ b/lib_dec/FEC.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other @@ -332,7 +332,11 @@ void FEC_exc_estim( * Replicate the last spectrum in case the last good frame was coded by GSC *-----------------------------------------------------------------*/ +#ifdef NONBE_FIX_GSC_BSTR + if ( ( st->last_coder_type == AUDIO || st->last_good == INACTIVE_CLAS ) && st->inactive_coder_type_flag && !st->Opt_AMR_WB ) +#else if ( ( st->last_coder_type == AUDIO || st->last_good == INACTIVE_CLAS ) && st->total_brate <= MAX_GSC_INACTIVE_BRATE && !st->Opt_AMR_WB ) +#endif { /* Replication of the last spectrum, with a slight downscaling of its dynamic */ st->GSC_noisy_speech = st->Last_GSC_noisy_speech_flag; @@ -405,7 +409,11 @@ void FEC_exc_estim( * Total excitation *-----------------------------------------------------------------*/ +#ifdef NONBE_FIX_GSC_BSTR + if ( ( st->last_coder_type == AUDIO || st->last_good == INACTIVE_CLAS ) && st->inactive_coder_type_flag && !st->Opt_AMR_WB ) +#else if ( ( st->last_coder_type == AUDIO || st->last_good == INACTIVE_CLAS ) && st->total_brate <= MAX_GSC_INACTIVE_BRATE && !st->Opt_AMR_WB ) +#endif { /* For GSC - the excitation is already computed */ mvr2r( exc, exc2, st->L_frame ); diff --git a/lib_dec/FEC_HQ_core.c b/lib_dec/FEC_HQ_core.c index 988689b76d63f5af2b859298ad8dacbc110441b5..0a6b376d3a422a7939bd7df59c42373ef10b7d9d 100644 --- a/lib_dec/FEC_HQ_core.c +++ b/lib_dec/FEC_HQ_core.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/FEC_HQ_phase_ecu.c b/lib_dec/FEC_HQ_phase_ecu.c index 28cafd4732873ca9a7a07ef576ad50954287bac7..9f1a928e27e0cd20d0c3c6661a5e5e30fdb11ae1 100644 --- a/lib_dec/FEC_HQ_phase_ecu.c +++ b/lib_dec/FEC_HQ_phase_ecu.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/FEC_adapt_codebook.c b/lib_dec/FEC_adapt_codebook.c index 1200e2651cf52f30ff9fb82be8440dc076e960c5..66a4841c30184a169ba3f1290fac2ff1a858bfce 100644 --- a/lib_dec/FEC_adapt_codebook.c +++ b/lib_dec/FEC_adapt_codebook.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/FEC_clas_estim.c b/lib_dec/FEC_clas_estim.c index d20760ddbfa2983b8037ed583657cc3f369b40d7..576b87100f1c00fd09c4fa2f7d7487a7dbbf897c 100644 --- a/lib_dec/FEC_clas_estim.c +++ b/lib_dec/FEC_clas_estim.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/FEC_lsf_estim.c b/lib_dec/FEC_lsf_estim.c index dce8b8351583c298dcd5ed8f41b0807d7ac32f0c..631f594092d7445d0a4bbf47bf78759cdf5eae72 100644 --- a/lib_dec/FEC_lsf_estim.c +++ b/lib_dec/FEC_lsf_estim.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/FEC_pitch_estim.c b/lib_dec/FEC_pitch_estim.c index 3076f7bcaaccd78c0e92566c68669bc56eed653e..918c0bacce25c199ea7b2813565a77e52a2b3e0f 100644 --- a/lib_dec/FEC_pitch_estim.c +++ b/lib_dec/FEC_pitch_estim.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/FEC_scale_syn.c b/lib_dec/FEC_scale_syn.c index 7d43ad3a9ae7840dd49894d6a796169878894861..574dd44144bfa147f379deb4fa827a25993b4629 100644 --- a/lib_dec/FEC_scale_syn.c +++ b/lib_dec/FEC_scale_syn.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/LD_music_post_filter.c b/lib_dec/LD_music_post_filter.c index b7885d35b4cb8d04a771a46d7f11e8fa7cf04c1c..291b45e4975d70d79fdccd4483bc766c9c187224 100644 --- a/lib_dec/LD_music_post_filter.c +++ b/lib_dec/LD_music_post_filter.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/TonalComponentDetection.c b/lib_dec/TonalComponentDetection.c index fedfe0c2e6be69c18d76ad5576922432a2408f21..6d528ad9024d0bdc58ffd0060af0eb2a41f98a90 100644 --- a/lib_dec/TonalComponentDetection.c +++ b/lib_dec/TonalComponentDetection.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/acelp_core_dec.c b/lib_dec/acelp_core_dec.c index 8233e26376bf2c4347a0f3750068b41b9cb3b3d6..4b563556f27634949308e1af1b57e47ce6c57b8e 100644 --- a/lib_dec/acelp_core_dec.c +++ b/lib_dec/acelp_core_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other @@ -487,7 +487,11 @@ ivas_error acelp_core_dec( if ( st->element_mode > EVS_MONO && st->idchan == 0 && !( st->core_brate == FRAME_NO_DATA || st->core_brate == SID_2k40 ) && !tdm_low_rate_mode ) { +#ifdef NONBE_FIX_1189_GSC_IVAS_OMASA + if ( st->coder_type == AUDIO || ( st->coder_type == INACTIVE && st->inactive_coder_type_flag ) ) +#else if ( st->coder_type == AUDIO || ( st->coder_type == INACTIVE && st->total_brate <= MAX_GSC_INACTIVE_BRATE ) ) +#endif { st->GSC_IVAS_mode = get_next_indice( st, 2 ); } @@ -617,11 +621,19 @@ ivas_error acelp_core_dec( nb_bits = -1; } +#ifdef NONBE_FIX_GSC_BSTR + config_acelp1( DEC, st->total_brate, st->core_brate, st->core, st->extl_orig, st->extl_brate_orig, st->L_frame, st->GSC_noisy_speech, &( st->acelp_cfg ), st->next_bit_pos, st->coder_type, st->inactive_coder_type_flag, tc_subfr_tmp, 1, &nb_bits, unbits, st->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st->idchan, st->active_cnt, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode ); +#else config_acelp1( DEC, st->total_brate, st->core_brate, st->core, st->extl_orig, st->extl_brate_orig, st->L_frame, st->GSC_noisy_speech, &( st->acelp_cfg ), st->next_bit_pos, st->coder_type, tc_subfr_tmp, 1, &nb_bits, unbits, st->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st->idchan, st->active_cnt, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode ); +#endif if ( st->coder_type == TRANSITION && tc_subfr < L_SUBFR && st->L_frame == L_FRAME ) { +#ifdef NONBE_FIX_GSC_BSTR + config_acelp1( DEC, st->total_brate, st->core_brate, st->core, st->extl_orig, st->extl_brate_orig, st->L_frame, -1, &( st->acelp_cfg ), st->next_bit_pos, TRANSITION, -1, tc_subfr, 2, &nb_bits, unbits, st->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st->idchan, st->active_cnt, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode ); +#else config_acelp1( DEC, st->total_brate, st->core_brate, st->core, st->extl_orig, st->extl_brate_orig, st->L_frame, -1, &( st->acelp_cfg ), st->next_bit_pos, st->coder_type, tc_subfr, 2, &nb_bits, unbits, st->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st->idchan, st->active_cnt, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode ); +#endif } } @@ -843,7 +855,11 @@ ivas_error acelp_core_dec( * Apply energy matching when switching to inactive frames *-----------------------------------------------------------------*/ +#ifdef NONBE_FIX_GSC_BSTR + inact_switch_ematch( exc2, dct_exc_tmp, st->hGSCDec->lt_ener_per_band, st->coder_type, st->inactive_coder_type_flag, st->L_frame, st->bfi, st->last_core, st->last_codec_mode, tdm_low_rate_mode, st->element_mode ); +#else inact_switch_ematch( exc2, dct_exc_tmp, st->hGSCDec->lt_ener_per_band, st->coder_type, st->L_frame, st->total_brate, st->bfi, st->last_core, st->last_codec_mode, tdm_low_rate_mode, st->element_mode ); +#endif /*------------------------------------------------------------* * Decode information and modify the excitation signal of stationary unvoiced frames @@ -979,7 +995,11 @@ ivas_error acelp_core_dec( } /* Apply energy matching when switching to inactive frames */ +#ifdef NONBE_FIX_GSC_BSTR + inact_switch_ematch( exc2, dct_exc_tmp, st->hGSCDec->lt_ener_per_band, st->coder_type, st->inactive_coder_type_flag, st->L_frame, st->bfi, st->last_core, st->last_codec_mode, tdm_low_rate_mode, st->element_mode ); +#else inact_switch_ematch( exc2, dct_exc_tmp, st->hGSCDec->lt_ener_per_band, st->coder_type, st->L_frame, st->total_brate, st->bfi, st->last_core, st->last_codec_mode, tdm_low_rate_mode, st->element_mode ); +#endif /* update past excitation signals for LD music post-filter */ if ( st->hMusicPF != NULL ) diff --git a/lib_dec/acelp_core_switch_dec.c b/lib_dec/acelp_core_switch_dec.c index 51d459b205e980505dd12a2d5c87795b95244c8b..16a3c5be2e82c67fefeceb43e10965a732818f94 100644 --- a/lib_dec/acelp_core_switch_dec.c +++ b/lib_dec/acelp_core_switch_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other @@ -158,7 +158,11 @@ ivas_error acelp_core_switch_dec( * Excitation decoding *----------------------------------------------------------------*/ +#ifdef NONBE_FIX_GSC_BSTR + config_acelp1( DEC, st->total_brate, cbrate, st->core, -1, -1, st->last_L_frame, -1, &( st->acelp_cfg ), st->next_bit_pos, GENERIC, st->inactive_coder_type_flag, -1, -1, &decode_bwe /* dummy */, &i, st->element_mode, &i /*dummy*/, 0, 0, st->idchan, st->active_cnt, 0, 0, 0 /*st->GSC_IVAS_mode*/ ); +#else config_acelp1( DEC, st->total_brate, cbrate, st->core, -1, -1, st->last_L_frame, -1, &( st->acelp_cfg ), st->next_bit_pos, GENERIC, -1, -1, &decode_bwe /* dummy */, &i, st->element_mode, &i /*dummy*/, 0, 0, st->idchan, st->active_cnt, 0, 0, 0 /*st->GSC_IVAS_mode*/ ); +#endif decod_gen_voic_core_switch( st, L_frame_for_cs, 0, Aq, exc, cbrate ); diff --git a/lib_dec/amr_wb_dec.c b/lib_dec/amr_wb_dec.c index 5252b265647b1efd2581b816d7b72f2cad8a7f97..1b4712da1100fe3c9bc9de5538c19e16dde1ffc1 100644 --- a/lib_dec/amr_wb_dec.c +++ b/lib_dec/amr_wb_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ari_dec.c b/lib_dec/ari_dec.c index 31df466f009d2106ae5d5356b9e2351c26af812f..71533d983c74e4d5f3b533ba8b63f8bf31f3fb57 100644 --- a/lib_dec/ari_dec.c +++ b/lib_dec/ari_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ari_hm_dec.c b/lib_dec/ari_hm_dec.c index 3ba6a886fb4468278c9b4809bdcb585c2f50070f..a1e43ae97c978da56369be9c6a7ff05813ac459c 100644 --- a/lib_dec/ari_hm_dec.c +++ b/lib_dec/ari_hm_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/arith_coder_dec.c b/lib_dec/arith_coder_dec.c index 09f1698133aabf410b5ff434b1b5a4cbffb8e4f6..e8776f57eca928daf120494acb4acd4a9dd5f0dd 100644 --- a/lib_dec/arith_coder_dec.c +++ b/lib_dec/arith_coder_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/avq_dec.c b/lib_dec/avq_dec.c index ec74ea53896dbb1cc3939b47c83cfc10f68da315..cdfeee4d0d884d27260e0c47858494294da07ed7 100644 --- a/lib_dec/avq_dec.c +++ b/lib_dec/avq_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/bass_psfilter.c b/lib_dec/bass_psfilter.c index cd63806c647002cf9fc289bdb0fa21c30a1e11a1..ab6bf60f1937274e84a40a793ef6816d2c1627f5 100644 --- a/lib_dec/bass_psfilter.c +++ b/lib_dec/bass_psfilter.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/cng_dec.c b/lib_dec/cng_dec.c index b7f462aa9d0f0ec28f322c3d46613504bdf911c9..28ff34a5ad8d87d897b8297f1e46a0d90dcfd9b1 100644 --- a/lib_dec/cng_dec.c +++ b/lib_dec/cng_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/core_dec_init.c b/lib_dec/core_dec_init.c index 3ceee9a2f46d465d13864514de93c0d733e3b466..af1080de03b7658596faf11e7648dc03577e059d 100644 --- a/lib_dec/core_dec_init.c +++ b/lib_dec/core_dec_init.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/core_dec_reconf.c b/lib_dec/core_dec_reconf.c index 7734d131773c06eacedaae8cb2be72806e7e73a8..4de0831e2b976d7c62fb828e80457851fa8bb866 100644 --- a/lib_dec/core_dec_reconf.c +++ b/lib_dec/core_dec_reconf.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/core_dec_switch.c b/lib_dec/core_dec_switch.c index 16519aec47c268d53c8771c4389a43846d20a805..34c7c6b0f6026f751ec5497878b7ddf120b00bc0 100644 --- a/lib_dec/core_dec_switch.c +++ b/lib_dec/core_dec_switch.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/core_switching_dec.c b/lib_dec/core_switching_dec.c index e70b1d59d7bed6fc4f19a37cc37dfcbc97726c14..7ed7cc5298710a0ec25ee366751300d8ac313a2c 100644 --- a/lib_dec/core_switching_dec.c +++ b/lib_dec/core_switching_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/d_gain2p.c b/lib_dec/d_gain2p.c index d2fe3e8757f6d0d2ed5443615b6318a80a2f8180..a33a92b8d3a16f251b3203d3246ce51c2de237c9 100644 --- a/lib_dec/d_gain2p.c +++ b/lib_dec/d_gain2p.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/dec2t32.c b/lib_dec/dec2t32.c index 258e36da41e88431f002ec4ad80f67483ebc5113..19e451915934769343d92276035383e833e417db 100644 --- a/lib_dec/dec2t32.c +++ b/lib_dec/dec2t32.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/dec4t64.c b/lib_dec/dec4t64.c index 9f2ab5d1c222f7185bc122d32fc115625c6adbca..cbea71e07dad8ff6690f3549b8043301400b38e4 100644 --- a/lib_dec/dec4t64.c +++ b/lib_dec/dec4t64.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/dec_LPD.c b/lib_dec/dec_LPD.c index af6a937e11ee56cbe2abbb5ef47ba76ac50cd565..9bc22f4b5e4e493411b05338131022e0744077af 100644 --- a/lib_dec/dec_LPD.c +++ b/lib_dec/dec_LPD.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/dec_ace.c b/lib_dec/dec_ace.c index ee32d67146fdaeaf9719afad027018ca3d766609..de3745c44eeb717761b8e0edd914d31c10b5b423 100644 --- a/lib_dec/dec_ace.c +++ b/lib_dec/dec_ace.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/dec_acelp.c b/lib_dec/dec_acelp.c index 615fa8eae1a0e14a0e2788a2cc61e897b3ca9178..6c2c1ba6c8358de2a7803da91d4695f51b539773 100644 --- a/lib_dec/dec_acelp.c +++ b/lib_dec/dec_acelp.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/dec_acelp_tcx_main.c b/lib_dec/dec_acelp_tcx_main.c index 1ab6b5265945b7f5d7c1b51350c7c0844858e56a..4689bdb7950e4df3c69452c5a114fc57a5070053 100644 --- a/lib_dec/dec_acelp_tcx_main.c +++ b/lib_dec/dec_acelp_tcx_main.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/dec_amr_wb.c b/lib_dec/dec_amr_wb.c index 29fe0a253eb2d65ae1ab650a5efe4730181f7961..ad76073070487d873be1c6dee1238d0ade8a5988 100644 --- a/lib_dec/dec_amr_wb.c +++ b/lib_dec/dec_amr_wb.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/dec_gen_voic.c b/lib_dec/dec_gen_voic.c index c8220be8611da8f6014840912da1be0402ad74d5..978b7c036a58a82559c88d97ecd057fcc5f40fa0 100644 --- a/lib_dec/dec_gen_voic.c +++ b/lib_dec/dec_gen_voic.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other @@ -174,7 +174,11 @@ ivas_error decod_gen_voic( * Transform-domain contribution decoding (inactive frames) *-----------------------------------------------------------------*/ +#ifdef NONBE_FIX_GSC_BSTR + if ( !st->inactive_coder_type_flag && st->coder_type == INACTIVE ) +#else if ( st->total_brate >= MAX_GSC_INACTIVE_BRATE && st->coder_type == INACTIVE ) +#endif { transf_cdbk_dec( st, 0, i_subfr, Es_pred, gain_code, &gain_preQ, &norm_gain_preQ, code_preQ, unbits ); } @@ -196,7 +200,6 @@ ivas_error decod_gen_voic( * Add the ACELP pre-quantizer contribution *-----------------------------------------------------------------*/ - /* if( (coder_type == GENERIC && st->core_brate >= MIN_BRATE_AVQ_EXC) || (coder_type == INACTIVE && st->total_brate > MAX_GSC_INACTIVE_BRATE) ) */ if ( gain_preQ != 0 ) { for ( i = 0; i < L_SUBFR; i++ ) diff --git a/lib_dec/dec_higher_acelp.c b/lib_dec/dec_higher_acelp.c index 1990de936324fd044c1a0e27d1bb8de532a8560c..e2ca117dc49023bb9775af46eeaf5e7881d67ac6 100644 --- a/lib_dec/dec_higher_acelp.c +++ b/lib_dec/dec_higher_acelp.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/dec_nelp.c b/lib_dec/dec_nelp.c index 8516f4cfd1c7b4589342d13fd1e5395d625db340..4e139004ea67657384fbd3048cea07227f7358df 100644 --- a/lib_dec/dec_nelp.c +++ b/lib_dec/dec_nelp.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/dec_pit_exc.c b/lib_dec/dec_pit_exc.c index 2b67a6042f4a0f06042fa9da9cc21679230f9eb7..511064da860aaedda2dfc731d10cd43933bf3042 100644 --- a/lib_dec/dec_pit_exc.c +++ b/lib_dec/dec_pit_exc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/dec_post.c b/lib_dec/dec_post.c index 6c5cd0423be8199e2cd6f4f5186fdd96a84046a7..e8588886e9d437c85fd949cf4d9b7a07fcfc2d5e 100644 --- a/lib_dec/dec_post.c +++ b/lib_dec/dec_post.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/dec_ppp.c b/lib_dec/dec_ppp.c index b36f9190a1cbb2e2d3dbdb0783f007c08407fc8f..9748fb9baac8abed60d7bb8b01a9679c55f0f7e3 100644 --- a/lib_dec/dec_ppp.c +++ b/lib_dec/dec_ppp.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/dec_prm.c b/lib_dec/dec_prm.c index d2e9aa26efb77b2a557d314e6de50096565940ff..42f38afaf668400072c95f706738a7c337cb7fd2 100644 --- a/lib_dec/dec_prm.c +++ b/lib_dec/dec_prm.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/dec_tcx.c b/lib_dec/dec_tcx.c index cffb6a1092ccf09839e6d7393126cb89a7ee3604..f68ba522bb0f2bab761e3d9abb5f2cddf46e8d17 100644 --- a/lib_dec/dec_tcx.c +++ b/lib_dec/dec_tcx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/dec_tran.c b/lib_dec/dec_tran.c index 875ce5eabf3449bcd087dffd7b81e08556d4270b..13de911a4f15356cb575609422bc80a446153e24 100644 --- a/lib_dec/dec_tran.c +++ b/lib_dec/dec_tran.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/dec_uv.c b/lib_dec/dec_uv.c index 63c4b1d3bdcffbb529c280865e84b629e68a5399..a158e9cb9449adfbcb5f970f5494b67556b7351f 100644 --- a/lib_dec/dec_uv.c +++ b/lib_dec/dec_uv.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/decision_matrix_dec.c b/lib_dec/decision_matrix_dec.c index f3b1194b0669573e88795957de40ef2b536d3bf9..0cc8b6e57ce58663048f31b02b572a7a4cc93cb8 100644 --- a/lib_dec/decision_matrix_dec.c +++ b/lib_dec/decision_matrix_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/dlpc_avq.c b/lib_dec/dlpc_avq.c index b4a95fd74d5369d449c1386a2fa889a9cf95d3a9..390eac8bf53eb3c0f3d9de69fc6763bc7a806842 100644 --- a/lib_dec/dlpc_avq.c +++ b/lib_dec/dlpc_avq.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/dlpc_stoch.c b/lib_dec/dlpc_stoch.c index 22a1cda26cef68a9207dd93e0a80742a8304283d..8cf0e4234d9e4f914f0dc19a5f059e2b637402b9 100644 --- a/lib_dec/dlpc_stoch.c +++ b/lib_dec/dlpc_stoch.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/er_dec_acelp.c b/lib_dec/er_dec_acelp.c index 7024cfb3f848a0557fb1f826062091ec7ac7b805..8c4da7d4bb269e0b53198720a6c821a2c4669575 100644 --- a/lib_dec/er_dec_acelp.c +++ b/lib_dec/er_dec_acelp.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/er_dec_tcx.c b/lib_dec/er_dec_tcx.c index 24a4817052c6054e54169a07699aa5e5f7a7c91e..ab69fe810e8a93cf91eaa3ce995a375e98186b9e 100644 --- a/lib_dec/er_dec_tcx.c +++ b/lib_dec/er_dec_tcx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/er_scale_syn.c b/lib_dec/er_scale_syn.c index d6d048b234a115a4ddf10b64725d5e6bd44ce045..1bfeb22ef7ba4fec414f012a9538e3af8a479645 100644 --- a/lib_dec/er_scale_syn.c +++ b/lib_dec/er_scale_syn.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/er_sync_exc.c b/lib_dec/er_sync_exc.c index b28a172715875c93696b27547bbf4e2efd86bd6a..83f22e34609929e9424b19281fcd7cff968c81e3 100644 --- a/lib_dec/er_sync_exc.c +++ b/lib_dec/er_sync_exc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/er_util.c b/lib_dec/er_util.c index 5326f28e904ef627af30b8f7a4aa926f4a857320..df338cf80904b893b2c928c4d554fafa4ce3212a 100644 --- a/lib_dec/er_util.c +++ b/lib_dec/er_util.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/evs_dec.c b/lib_dec/evs_dec.c index 39815e6333f63d26649f33fdf03aefed826ee2e6..cbd50dd1e48a4c24fbffbe2795d12c1ba56ac8a4 100644 --- a/lib_dec/evs_dec.c +++ b/lib_dec/evs_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/fd_cng_dec.c b/lib_dec/fd_cng_dec.c index 69d007825caed9dd17a7b9194eecbe406f4032ce..57b4096b3f384120949678e5b3f612d4e9ec467e 100644 --- a/lib_dec/fd_cng_dec.c +++ b/lib_dec/fd_cng_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/gain_dec.c b/lib_dec/gain_dec.c index 6f769dd6eacc3d86850f8b8b69220d86f79801db..cf1dee4c310c4ac7933f92d7713f3fced05d65da 100644 --- a/lib_dec/gain_dec.c +++ b/lib_dec/gain_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/gaus_dec.c b/lib_dec/gaus_dec.c index a053597722528bb13536f2380e84c90c3d55f63d..25b401581710d17de1f29eebb9f3ece259ddde0f 100644 --- a/lib_dec/gaus_dec.c +++ b/lib_dec/gaus_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/gs_dec.c b/lib_dec/gs_dec.c index 30f6d17143c20e63054e0e873a468eb1bdf49d98..9482eb494e7c8b93cfffe7ab67ac17e4a4e40057 100644 --- a/lib_dec/gs_dec.c +++ b/lib_dec/gs_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other @@ -111,7 +111,11 @@ void decod_audio( } /* set bit-allocation */ +#ifdef NONBE_FIX_GSC_BSTR + config_acelp1( DEC, st->total_brate, st->core_brate, st->core, st->extl_orig, st->extl_brate_orig, st->L_frame, st->GSC_noisy_speech, &( st->acelp_cfg ), st->next_bit_pos, st->coder_type, st->inactive_coder_type_flag, -1, 1, &nb_bits, NULL, st->element_mode, &nbits /*dummy*/, tdm_lp_reuse_flag, tdm_low_rate_mode, st->idchan, st->active_cnt, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode ); +#else config_acelp1( DEC, st->total_brate, st->core_brate, st->core, st->extl_orig, st->extl_brate_orig, st->L_frame, st->GSC_noisy_speech, &( st->acelp_cfg ), st->next_bit_pos, st->coder_type, -1, 1, &nb_bits, NULL, st->element_mode, &nbits /*dummy*/, tdm_lp_reuse_flag, tdm_low_rate_mode, st->idchan, st->active_cnt, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode ); +#endif /*---------------------------------------------------------------* * Decode energy dynamics diff --git a/lib_dec/gs_dec_amr_wb.c b/lib_dec/gs_dec_amr_wb.c index 1d41f367f4ff2497d0b56e8ad624f681141a797f..91cf4cf5851b556c2dace9d8512cc774b8612f83 100644 --- a/lib_dec/gs_dec_amr_wb.c +++ b/lib_dec/gs_dec_amr_wb.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/hdecnrm.c b/lib_dec/hdecnrm.c index 1f247ef1f0e1a1e9e87a6d0a24d171d0e9ba54b4..5e1adeec0c86ebdbbb839c15e85120af63661aeb 100644 --- a/lib_dec/hdecnrm.c +++ b/lib_dec/hdecnrm.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/hf_synth.c b/lib_dec/hf_synth.c index a4d75b4e9af5118eef7c49a1cc5fecc4450b0e9e..99adb1cfa16c29888af2b3d41e371ec0fd322160 100644 --- a/lib_dec/hf_synth.c +++ b/lib_dec/hf_synth.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/hq_classifier_dec.c b/lib_dec/hq_classifier_dec.c index 10a1a783fcddeac2b0bf93a14e6306c98e24ca33..e2e1bbcc4b8f2a8a0a2d2d4a70311ff92e43707a 100644 --- a/lib_dec/hq_classifier_dec.c +++ b/lib_dec/hq_classifier_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/hq_conf_fec.c b/lib_dec/hq_conf_fec.c index 7d3c79fcf2367dc699d50eadd5faef31a689d998..2fbdeae092cd9e023c777e7a4ad5df98696b4198 100644 --- a/lib_dec/hq_conf_fec.c +++ b/lib_dec/hq_conf_fec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/hq_core_dec.c b/lib_dec/hq_core_dec.c index cdb9601679549187e6e5dae354e0e8e2314e6f71..a0e81755d3b7a98f7fd74ab6c684b7f171853333 100644 --- a/lib_dec/hq_core_dec.c +++ b/lib_dec/hq_core_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/hq_env_dec.c b/lib_dec/hq_env_dec.c index e584bfa8276c44c19fe394a3ad35557a9d83d5d9..8983124ccca3a496b353e495879fa0385b00f8e0 100644 --- a/lib_dec/hq_env_dec.c +++ b/lib_dec/hq_env_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/hq_hr_dec.c b/lib_dec/hq_hr_dec.c index 5153af07ead81341863f7c98377ac69a65d53609..165d52f6b0d7a080c91a864f2611b0cc7972fe46 100644 --- a/lib_dec/hq_hr_dec.c +++ b/lib_dec/hq_hr_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/hq_lr_dec.c b/lib_dec/hq_lr_dec.c index 3b9ae0c6fc00a0f530047829b526349bd9c1f7da..b2389c53e698b09a6b255b92ed5b5510613c126a 100644 --- a/lib_dec/hq_lr_dec.c +++ b/lib_dec/hq_lr_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/igf_dec.c b/lib_dec/igf_dec.c index 8095f6da41a89fe26f89272563e2f3345d22db25..de7450c97e415bf460090c05db3431cf3dcb85cf 100644 --- a/lib_dec/igf_dec.c +++ b/lib_dec/igf_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/igf_scf_dec.c b/lib_dec/igf_scf_dec.c index f152f637a0d83b6e78684766f44a215874793eb0..67c4fe0a192e9deeba0baae5d915f41ca62a0944 100644 --- a/lib_dec/igf_scf_dec.c +++ b/lib_dec/igf_scf_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/init_dec.c b/lib_dec/init_dec.c index ba18a8e85ee4b53e43709ab6fe60844d0536ce11..1a37f7e02ce893548d60c2b050c6decddd9616c3 100644 --- a/lib_dec/init_dec.c +++ b/lib_dec/init_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/inov_dec.c b/lib_dec/inov_dec.c index 43c7eb2c7be0eac7303258db6eb26c51761f0a87..c9edb835a584e28acf51ac7dfb121a25cea220b1 100644 --- a/lib_dec/inov_dec.c +++ b/lib_dec/inov_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_agc_dec.c b/lib_dec/ivas_agc_dec.c index 9722514dbfb84702d8570da44297b667920c4a65..cec0a48783dc94d65de0dac2e220e8445ccb7589 100644 --- a/lib_dec/ivas_agc_dec.c +++ b/lib_dec/ivas_agc_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_binRenderer_internal.c b/lib_dec/ivas_binRenderer_internal.c index c6dfce0f5c29df783325880e44852222a55c0a40..253b20833d44e60936398beff3118e13dcb614ba 100644 --- a/lib_dec/ivas_binRenderer_internal.c +++ b/lib_dec/ivas_binRenderer_internal.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other @@ -60,7 +60,12 @@ static void ivas_binRenderer_filterModule( float CLDFB_real[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i : real part of LS signals */ float CLDFB_imag[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i : imag part of LS signals */ const int16_t numTimeSlots, /* i : number of time slots to process */ - BINAURAL_RENDERER_HANDLE hBinRenderer /* i/o: fastconv binaural renderer handle */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + BINAURAL_RENDERER_HANDLE hBinRenderer, /* i/o: fastconv binaural renderer handle */ + const int16_t pos_idx /* i : pose index */ +#else + BINAURAL_RENDERER_HANDLE hBinRenderer /* i/o: fastconv binaural renderer handle */ +#endif ) { int16_t bandIdx, k, chIdx, tapIdx; @@ -71,8 +76,13 @@ static void ivas_binRenderer_filterModule( { for ( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT + filterStatesLeftRealPtr = (float *) &( hBinRenderer->hBinRenConvModule->filterStatesLeftReal[pos_idx][bandIdx][chIdx][0] ); + filterStatesLeftImagPtr = (float *) &( hBinRenderer->hBinRenConvModule->filterStatesLeftImag[pos_idx][bandIdx][chIdx][0] ); +#else filterStatesLeftRealPtr = (float *) &( hBinRenderer->hBinRenConvModule->filterStatesLeftReal[bandIdx][chIdx][0] ); filterStatesLeftImagPtr = (float *) &( hBinRenderer->hBinRenConvModule->filterStatesLeftImag[bandIdx][chIdx][0] ); +#endif filterTapsLeftRealPtr = hBinRenderer->hBinRenConvModule->filterTapsLeftReal[bandIdx][chIdx]; filterTapsLeftImagPtr = hBinRenderer->hBinRenConvModule->filterTapsLeftImag[bandIdx][chIdx]; @@ -127,10 +137,19 @@ static ivas_error ivas_binRenderer_convModuleOpen( const int16_t renderer_type, const int16_t isLoudspeaker, const AUDIO_CONFIG input_config, - const HRTFS_FASTCONV_HANDLE hHrtf ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + const HRTFS_FASTCONV_HANDLE hHrtf, + const int16_t num_poses +#else + const HRTFS_FASTCONV_HANDLE hHrtf +#endif +) { int16_t bandIdx, chIdx; BINRENDERER_CONV_MODULE_HANDLE hBinRenConvModule; +#ifdef SPLIT_REND_WITH_HEAD_ROT + int16_t pos_idx; +#endif /*-----------------------------------------------------------------* * prepare library opening @@ -241,6 +260,56 @@ static ivas_error ivas_binRenderer_convModuleOpen( } } +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( hBinRenConvModule->filterStatesLeftReal = (float ****) malloc( num_poses * sizeof( float *** ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); + } + + if ( ( hBinRenConvModule->filterStatesLeftImag = (float ****) malloc( num_poses * sizeof( float *** ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); + } + + for ( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) + { + if ( ( hBinRenConvModule->filterStatesLeftReal[pos_idx] = (float ***) malloc( hBinRenderer->conv_band * sizeof( float ** ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); + } + + if ( ( hBinRenConvModule->filterStatesLeftImag[pos_idx] = (float ***) malloc( hBinRenderer->conv_band * sizeof( float ** ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); + } + + for ( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) + { + if ( ( hBinRenConvModule->filterStatesLeftReal[pos_idx][bandIdx] = (float **) malloc( hBinRenderer->nInChannels * sizeof( float * ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); + } + + if ( ( hBinRenConvModule->filterStatesLeftImag[pos_idx][bandIdx] = (float **) malloc( hBinRenderer->nInChannels * sizeof( float * ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); + } + + for ( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) + { + if ( ( hBinRenConvModule->filterStatesLeftReal[pos_idx][bandIdx][chIdx] = (float *) malloc( hBinRenConvModule->numTapsArray[bandIdx] * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); + } + + if ( ( hBinRenConvModule->filterStatesLeftImag[pos_idx][bandIdx][chIdx] = (float *) malloc( hBinRenConvModule->numTapsArray[bandIdx] * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); + } + } + } + } +#else if ( ( hBinRenConvModule->filterStatesLeftReal = (float ***) malloc( hBinRenderer->conv_band * sizeof( float ** ) ) ) == NULL ) { @@ -277,6 +346,7 @@ static ivas_error ivas_binRenderer_convModuleOpen( } } } +#endif /* SPLIT_REND_WITH_HEAD_ROT */ /* set memories */ for ( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) @@ -317,9 +387,11 @@ static ivas_error ivas_binRenderer_convModuleOpen( if ( renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) { +#ifndef SPLIT_REND_WITH_HEAD_ROT /* set the memories to zero */ set_zero( hBinRenConvModule->filterStatesLeftReal[bandIdx][chIdx], hBinRenConvModule->numTapsArray[bandIdx] ); set_zero( hBinRenConvModule->filterStatesLeftImag[bandIdx][chIdx], hBinRenConvModule->numTapsArray[bandIdx] ); +#endif if ( isLoudspeaker ) { hBinRenConvModule->filterTapsLeftReal[bandIdx][chIdx] = hHrtf->leftBRIRReal[bandIdx][tmp]; @@ -337,9 +409,11 @@ static ivas_error ivas_binRenderer_convModuleOpen( } else { +#ifndef SPLIT_REND_WITH_HEAD_ROT /* set the memories to zero */ set_zero( hBinRenConvModule->filterStatesLeftReal[bandIdx][chIdx], hBinRenConvModule->numTaps ); set_zero( hBinRenConvModule->filterStatesLeftImag[bandIdx][chIdx], hBinRenConvModule->numTaps ); +#endif if ( isLoudspeaker ) { hBinRenConvModule->filterTapsLeftReal[bandIdx][chIdx] = hHrtf->leftHRIRReal[bandIdx][tmp]; @@ -382,6 +456,20 @@ static ivas_error ivas_binRenderer_convModuleOpen( } } +#ifdef SPLIT_REND_WITH_HEAD_ROT + for ( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) + { + for ( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) + { + for ( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) + { + /* set the memories to zero */ + set_zero( hBinRenConvModule->filterStatesLeftReal[pos_idx][bandIdx][chIdx], hBinRenConvModule->numTapsArray[bandIdx] ); + set_zero( hBinRenConvModule->filterStatesLeftImag[pos_idx][bandIdx][chIdx], hBinRenConvModule->numTapsArray[bandIdx] ); + } + } + } +#endif hBinRenderer->hBinRenConvModule = hBinRenConvModule; @@ -883,6 +971,100 @@ static void ivas_binaural_obtain_DMX( } +#ifdef SPLIT_REND_WITH_HEAD_ROT +/*------------------------------------------------------------------------- + * ivas_rend_openCldfbRend() + * + * Allocate and initialize CLDFB fast conv renderer handle + *------------------------------------------------------------------------*/ + +ivas_error +ivas_rend_openCldfbRend( + CLDFB_REND_WRAPPER *pCldfbRend, + const AUDIO_CONFIG inConfig, + const AUDIO_CONFIG outConfig, + const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + const int32_t output_Fs ) +{ + BINAURAL_RENDERER_HANDLE hBinRenderer; + int16_t convBand; + ivas_error error; + + error = IVAS_ERR_OK; + + /*-----------------------------------------------------------------* + * prepare library opening + *-----------------------------------------------------------------*/ + + if ( ( hBinRenderer = (BINAURAL_RENDERER_HANDLE) malloc( sizeof( BINAURAL_RENDERER ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural Renderer\n" ) ); + } + + if ( ( hBinRenderer->hInputSetup = (IVAS_OUTPUT_SETUP_HANDLE) malloc( sizeof( IVAS_OUTPUT_SETUP ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for output setup Binaural Renderer\n" ) ); + } + + hBinRenderer->rotInCldfb = 1; + hBinRenderer->ivas_format = SBA_FORMAT; + + hBinRenderer->max_band = (int16_t) ( ( BINAURAL_MAXBANDS * output_Fs ) / 48000 ); + convBand = hBinRenderer->max_band; + + hBinRenderer->timeSlots = MAX_PARAM_SPATIAL_SUBFRAMES; /* Corresponds to 5 msec sound to motion latency */ + + if ( convBand > BINAURAL_CONVBANDS ) + { + hBinRenderer->conv_band = BINAURAL_CONVBANDS; + } + else + { + hBinRenderer->conv_band = convBand; + } + + hBinRenderer->hInputSetup->is_loudspeaker_setup = 0; + hBinRenderer->hInputSetup->output_config = inConfig; + if ( ( error = getAudioConfigNumChannels( inConfig, &hBinRenderer->hInputSetup->nchan_out_woLFE ) ) != IVAS_ERR_OK ) + { + return error; + } + + if ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + { +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG + hBinRenderer->numPoses = pMultiBinPoseData->num_poses + 1; +#else + hBinRenderer->numPoses = pMultiBinPoseData->num_poses; +#endif + } + else + { + hBinRenderer->numPoses = 1; + } + + /* Load HRTF tables */ + if ( ( error = ivas_binaural_hrtf_open( &pCldfbRend->hHrtfFastConv, hBinRenderer->hInputSetup->output_config, RENDERER_BINAURAL_FASTCONV ) ) != IVAS_ERR_OK ) + { + return error; + } + + /* Allocate memories and buffers needed for convolutional module */ + if ( ( error = ivas_binRenderer_convModuleOpen( hBinRenderer, RENDERER_BINAURAL_FASTCONV, hBinRenderer->hInputSetup->is_loudspeaker_setup, inConfig, pCldfbRend->hHrtfFastConv, hBinRenderer->numPoses ) ) != IVAS_ERR_OK ) + { + return error; + } + + pCldfbRend->binaural_latency_ns = (int32_t) ( FASTCONV_HOA3_latency_s * 1000000000.f ); + hBinRenderer->hReverb = NULL; + hBinRenderer->hEFAPdata = NULL; + + pCldfbRend->hCldfbRend = hBinRenderer; + + return error; +} +#endif + /*------------------------------------------------------------------------- * ivas_binRenderer_open() * @@ -917,6 +1099,20 @@ ivas_error ivas_binRenderer_open( hBinRenderer->rotInCldfb = 1; } +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + { +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG + hBinRenderer->numPoses = st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses + 1; +#else + hBinRenderer->numPoses = st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses; +#endif + } + else + { + hBinRenderer->numPoses = 1; + } +#endif /* Declare some common variables needed for renderer */ /* Which format used for binaural rendering (needed for late reverb) ? MC or SBA */ @@ -961,7 +1157,11 @@ ivas_error ivas_binRenderer_open( IVAS_OUTPUT_SETUP out_setup; /* Allocate memories and buffers needed for convolutional module in CICP19 */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( error = ivas_binRenderer_convModuleOpen( hBinRenderer, st_ivas->renderer_type, 1, IVAS_AUDIO_CONFIG_7_1_4, st_ivas->hHrtfFastConv, hBinRenderer->numPoses ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_binRenderer_convModuleOpen( hBinRenderer, st_ivas->renderer_type, 1, IVAS_AUDIO_CONFIG_7_1_4, st_ivas->hHrtfFastConv ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -982,7 +1182,11 @@ ivas_error ivas_binRenderer_open( else { /* Allocate memories and buffers needed for convolutional module */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( error = ivas_binRenderer_convModuleOpen( hBinRenderer, st_ivas->renderer_type, st_ivas->hIntSetup.is_loudspeaker_setup, st_ivas->hIntSetup.output_config, st_ivas->hHrtfFastConv, hBinRenderer->numPoses ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_binRenderer_convModuleOpen( hBinRenderer, st_ivas->renderer_type, st_ivas->hIntSetup.is_loudspeaker_setup, st_ivas->hIntSetup.output_config, st_ivas->hHrtfFastConv ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -1079,10 +1283,18 @@ ivas_error ivas_binRenderer_open( *------------------------------------------------------------------------*/ static void ivas_binRenderer_convModuleClose( +#ifdef SPLIT_REND_WITH_HEAD_ROT + BINAURAL_RENDERER_HANDLE *hBinRenderer, /* i/o: fastconv binaural renderer handle */ + const int16_t num_poses /* i : number of poses */ +#else BINAURAL_RENDERER_HANDLE *hBinRenderer /* i/o: fastconv binaural renderer handle */ +#endif ) { int16_t bandIdx, chIdx; +#ifdef SPLIT_REND_WITH_HEAD_ROT + int16_t posIdx; +#endif BINRENDERER_CONV_MODULE_HANDLE hBinRenConvModule; hBinRenConvModule = ( *hBinRenderer )->hBinRenConvModule; @@ -1119,6 +1331,39 @@ static void ivas_binRenderer_convModuleClose( free( hBinRenConvModule->filterTapsRightImag ); hBinRenConvModule->filterTapsRightImag = NULL; +#ifdef SPLIT_REND_WITH_HEAD_ROT + for ( posIdx = 0; posIdx < num_poses; posIdx++ ) + { + for ( bandIdx = 0; bandIdx < ( *hBinRenderer )->conv_band; bandIdx++ ) + { + for ( chIdx = 0; chIdx < ( *hBinRenderer )->nInChannels; chIdx++ ) + { + free( hBinRenConvModule->filterStatesLeftReal[posIdx][bandIdx][chIdx] ); + hBinRenConvModule->filterStatesLeftReal[posIdx][bandIdx][chIdx] = NULL; + + free( hBinRenConvModule->filterStatesLeftImag[posIdx][bandIdx][chIdx] ); + hBinRenConvModule->filterStatesLeftImag[posIdx][bandIdx][chIdx] = NULL; + } + + free( hBinRenConvModule->filterStatesLeftReal[posIdx][bandIdx] ); + hBinRenConvModule->filterStatesLeftReal[posIdx][bandIdx] = NULL; + + free( hBinRenConvModule->filterStatesLeftImag[posIdx][bandIdx] ); + hBinRenConvModule->filterStatesLeftImag[posIdx][bandIdx] = NULL; + } + + free( hBinRenConvModule->filterStatesLeftReal[posIdx] ); + hBinRenConvModule->filterStatesLeftReal[posIdx] = NULL; + + free( hBinRenConvModule->filterStatesLeftImag[posIdx] ); + hBinRenConvModule->filterStatesLeftImag[posIdx] = NULL; + } + free( hBinRenConvModule->filterStatesLeftReal ); + hBinRenConvModule->filterStatesLeftReal = NULL; + + free( hBinRenConvModule->filterStatesLeftImag ); + hBinRenConvModule->filterStatesLeftImag = NULL; +#else for ( bandIdx = 0; bandIdx < ( *hBinRenderer )->conv_band; bandIdx++ ) { for ( chIdx = 0; chIdx < ( *hBinRenderer )->nInChannels; chIdx++ ) @@ -1142,6 +1387,7 @@ static void ivas_binRenderer_convModuleClose( free( hBinRenConvModule->filterStatesLeftImag ); hBinRenConvModule->filterStatesLeftImag = NULL; +#endif free( ( *hBinRenderer )->hBinRenConvModule ); ( *hBinRenderer )->hBinRenConvModule = NULL; @@ -1167,7 +1413,11 @@ void ivas_binRenderer_close( if ( ( *hBinRenderer )->hBinRenConvModule != NULL ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT + ivas_binRenderer_convModuleClose( hBinRenderer, ( *hBinRenderer )->numPoses ); +#else ivas_binRenderer_convModuleClose( hBinRenderer ); +#endif } if ( ( *hBinRenderer )->hReverb != NULL ) @@ -1281,6 +1531,7 @@ void ivas_binaural_add_LFE( { int16_t render_lfe, idx_lfe; float gain; + float lfe_tc[L_FRAME48k]; if ( st_ivas->hBinRenderer != NULL ) { @@ -1304,10 +1555,10 @@ void ivas_binaural_add_LFE( for ( idx_lfe = 0; idx_lfe < st_ivas->hIntSetup.num_lfe; idx_lfe++ ) { - v_multc( input_f[st_ivas->hIntSetup.index_lfe[idx_lfe]], gain, input_f[st_ivas->hIntSetup.index_lfe[idx_lfe]], output_frame ); + v_multc( input_f[st_ivas->hIntSetup.index_lfe[idx_lfe]], gain, lfe_tc, output_frame ); /* copy LFE to left and right channels */ - v_add( output_f[0], input_f[st_ivas->hIntSetup.index_lfe[idx_lfe]], output_f[0], output_frame ); - v_add( output_f[1], input_f[st_ivas->hIntSetup.index_lfe[idx_lfe]], output_f[1], output_frame ); + v_add( output_f[0], lfe_tc, output_f[0], output_frame ); + v_add( output_f[1], lfe_tc, output_f[1], output_frame ); } } @@ -1329,8 +1580,13 @@ void ivas_binaural_cldfb( { float Cldfb_RealBuffer[MAX_INTERN_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; float Cldfb_ImagBuffer[MAX_INTERN_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; +#ifdef SPLIT_REND_WITH_HEAD_ROT + float Cldfb_RealBuffer_Binaural[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; + float Cldfb_ImagBuffer_Binaural[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; +#else float Cldfb_RealBuffer_Binaural[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; float Cldfb_ImagBuffer_Binaural[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; +#endif int16_t slot_idx, subframeIdx, index_slot, idx_in, idx_lfe, maxBand, ch; /* Implement a 5 msec loops */ @@ -1361,11 +1617,36 @@ void ivas_binaural_cldfb( idx_in++; } } +#ifdef SPLIT_REND_WITH_HEAD_ROT + /*LFE handling for split rendering cases*/ + if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + { + for ( idx_lfe = 0; idx_lfe < st_ivas->hIntSetup.num_lfe; idx_lfe++ ) + { + ch = st_ivas->hIntSetup.index_lfe[idx_lfe]; + cldfbAnalysis_ts( &( output_f[ch][maxBand * index_slot] ), Cldfb_RealBuffer[idx_in][slot_idx], Cldfb_ImagBuffer[idx_in][slot_idx], maxBand, st_ivas->cldfbAnaDec[idx_in] ); + idx_in++; + } + + if ( st_ivas->hSplitBinRend.hCldfbDataOut != NULL ) + { + for ( ch = 0; ch < ( st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe ); ch++ ) + { + mvr2r( Cldfb_RealBuffer[ch][slot_idx], st_ivas->hSplitBinRend.hCldfbDataOut->Cldfb_RealBuffer[ch][( subframeIdx * JBM_CLDFB_SLOTS_IN_SUBFRAME ) + slot_idx], maxBand ); + mvr2r( Cldfb_ImagBuffer[ch][slot_idx], st_ivas->hSplitBinRend.hCldfbDataOut->Cldfb_ImagBuffer[ch][( subframeIdx * JBM_CLDFB_SLOTS_IN_SUBFRAME ) + slot_idx], maxBand ); + } + st_ivas->hSplitBinRend.hCldfbDataOut->config = st_ivas->hIntSetup.output_config; + } + } +#endif } /* Implement binaural rendering */ ivas_binRenderer( st_ivas->hBinRenderer, +#ifdef SPLIT_REND_WITH_HEAD_ROT + &st_ivas->hSplitBinRend.splitrend.multiBinPoseData, +#endif st_ivas->hCombinedOrientationData, JBM_CLDFB_SLOTS_IN_SUBFRAME, #ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG @@ -1374,7 +1655,45 @@ void ivas_binaural_cldfb( Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer, Cldfb_ImagBuffer ); +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + { + int16_t pos_idx; + for ( slot_idx = 0; slot_idx < JBM_CLDFB_SLOTS_IN_SUBFRAME; slot_idx++ ) + { + if ( st_ivas->hIntSetup.num_lfe > 0 ) + { + v_multc( Cldfb_RealBuffer[st_ivas->hIntSetup.nchan_out_woLFE][slot_idx], GAIN_LFE, Cldfb_RealBuffer[st_ivas->hIntSetup.nchan_out_woLFE][slot_idx], maxBand ); + v_multc( Cldfb_ImagBuffer[st_ivas->hIntSetup.nchan_out_woLFE][slot_idx], GAIN_LFE, Cldfb_ImagBuffer[st_ivas->hIntSetup.nchan_out_woLFE][slot_idx], maxBand ); + } + } + for ( pos_idx = 0; pos_idx < st_ivas->hBinRenderer->numPoses; pos_idx++ ) + { + for ( slot_idx = 0; slot_idx < JBM_CLDFB_SLOTS_IN_SUBFRAME; slot_idx++ ) + { + for ( ch = 0; ch < st_ivas->hDecoderConfig->nchan_out; ch++ ) + { + if ( st_ivas->hIntSetup.num_lfe > 0 ) + { + v_add( Cldfb_RealBuffer_Binaural[pos_idx][ch][slot_idx], + Cldfb_RealBuffer[st_ivas->hIntSetup.nchan_out_woLFE][slot_idx], + Cldfb_RealBuffer_Binaural[pos_idx][ch][slot_idx], + maxBand ); + + v_add( Cldfb_ImagBuffer_Binaural[pos_idx][ch][slot_idx], + Cldfb_ImagBuffer[st_ivas->hIntSetup.nchan_out_woLFE][slot_idx], + Cldfb_ImagBuffer_Binaural[pos_idx][ch][slot_idx], + maxBand ); + } + + mvr2r( Cldfb_RealBuffer_Binaural[pos_idx][ch][slot_idx], st_ivas->hSplitBinRend.hMultiBinCldfbData->Cldfb_RealBuffer_Binaural[( pos_idx * BINAURAL_CHANNELS ) + ch][( subframeIdx * JBM_CLDFB_SLOTS_IN_SUBFRAME ) + slot_idx], maxBand ); + mvr2r( Cldfb_ImagBuffer_Binaural[pos_idx][ch][slot_idx], st_ivas->hSplitBinRend.hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural[( pos_idx * BINAURAL_CHANNELS ) + ch][( subframeIdx * JBM_CLDFB_SLOTS_IN_SUBFRAME ) + slot_idx], maxBand ); + } + } + } + } +#endif /* update combined orientation access index */ ivas_combined_orientation_update_index( st_ivas->hCombinedOrientationData, maxBand * MAX_PARAM_SPATIAL_SUBFRAMES ); @@ -1388,8 +1707,13 @@ void ivas_binaural_cldfb( for ( slot_idx = 0; slot_idx < MAX_PARAM_SPATIAL_SUBFRAMES; slot_idx++ ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT + RealBuffer[slot_idx] = Cldfb_RealBuffer_Binaural[0][ch][slot_idx]; + ImagBuffer[slot_idx] = Cldfb_ImagBuffer_Binaural[0][ch][slot_idx]; +#else RealBuffer[slot_idx] = Cldfb_RealBuffer_Binaural[ch][slot_idx]; ImagBuffer[slot_idx] = Cldfb_ImagBuffer_Binaural[ch][slot_idx]; +#endif } cldfbSynthesis( RealBuffer, ImagBuffer, &( output_f[ch][index_slot * maxBand] ), maxBand * MAX_PARAM_SPATIAL_SUBFRAMES, st_ivas->cldfbSynDec[ch] ); @@ -1415,8 +1739,13 @@ void ivas_binaural_cldfb_sf( { float Cldfb_RealBuffer[MAX_INTERN_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; float Cldfb_ImagBuffer[MAX_INTERN_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; +#ifdef SPLIT_REND_WITH_HEAD_ROT + float Cldfb_RealBuffer_Binaural[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; + float Cldfb_ImagBuffer_Binaural[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; +#else float Cldfb_RealBuffer_Binaural[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; float Cldfb_ImagBuffer_Binaural[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; +#endif int16_t slot_idx, subframeIdx, index_slot, idx_in, idx_lfe, maxBand, ch; int16_t slots_to_render, first_sf, last_sf; int16_t slot_index_start, slot_index_start_cldfb; @@ -1462,11 +1791,43 @@ void ivas_binaural_cldfb_sf( idx_in++; } } +<<<<<<< HEAD + +#ifdef SPLIT_REND_WITH_HEAD_ROT + /*LFE handling for split rendering cases*/ + if ( ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || + ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + { + for ( idx_lfe = 0; idx_lfe < st_ivas->hIntSetup.num_lfe; idx_lfe++ ) + { + ch = st_ivas->hIntSetup.index_lfe[idx_lfe]; + cldfbAnalysis_ts( &( output_f[ch][maxBand * index_slot] ), Cldfb_RealBuffer[idx_in][slot_idx], Cldfb_ImagBuffer[idx_in][slot_idx], maxBand, st_ivas->cldfbAnaDec[idx_in] ); + idx_in++; + } + +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( st_ivas->hSplitBinRend.hCldfbDataOut != NULL ) + { + for ( ch = 0; ch < ( st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe ); ch++ ) + { + mvr2r( Cldfb_RealBuffer[ch][slot_idx], st_ivas->hSplitBinRend.hCldfbDataOut->Cldfb_RealBuffer[ch][slot_index_start + slot_idx], maxBand ); + mvr2r( Cldfb_ImagBuffer[ch][slot_idx], st_ivas->hSplitBinRend.hCldfbDataOut->Cldfb_ImagBuffer[ch][slot_index_start + slot_idx], maxBand ); + } + st_ivas->hSplitBinRend.hCldfbDataOut->config = st_ivas->hIntSetup.output_config; + } +#endif + } +#endif + == == == = +>>>>>>> float-pc } /* Implement binaural rendering */ ivas_binRenderer( st_ivas->hBinRenderer, +#ifdef SPLIT_REND_WITH_HEAD_ROT + &st_ivas->hSplitBinRend.splitrend.multiBinPoseData, +#endif st_ivas->hCombinedOrientationData, st_ivas->hTcBuffer->subframe_nbslots[subframeIdx], #ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG @@ -1477,6 +1838,23 @@ void ivas_binaural_cldfb_sf( Cldfb_RealBuffer, Cldfb_ImagBuffer ); +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + { + int16_t pos_idx; + for ( pos_idx = 0; pos_idx < st_ivas->hBinRenderer->numPoses; pos_idx++ ) + { + for ( slot_idx = 0; slot_idx < st_ivas->hTcBuffer->subframe_nbslots[subframeIdx]; slot_idx++ ) + { + for ( ch = 0; ch < st_ivas->hDecoderConfig->nchan_out; ch++ ) + { + mvr2r( Cldfb_RealBuffer_Binaural[pos_idx][ch][slot_idx], st_ivas->hSplitBinRend.hMultiBinCldfbData->Cldfb_RealBuffer_Binaural[( pos_idx * BINAURAL_CHANNELS ) + ch][slot_index_start + slot_idx], maxBand ); + mvr2r( Cldfb_ImagBuffer_Binaural[pos_idx][ch][slot_idx], st_ivas->hSplitBinRend.hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural[( pos_idx * BINAURAL_CHANNELS ) + ch][slot_index_start + slot_idx], maxBand ); + } + } + } + } +#endif /* update combined orientation access index */ ivas_combined_orientation_update_index( st_ivas->hCombinedOrientationData, maxBand * st_ivas->hTcBuffer->subframe_nbslots[subframeIdx] ); @@ -1489,8 +1867,13 @@ void ivas_binaural_cldfb_sf( for ( slot_idx = 0; slot_idx < st_ivas->hTcBuffer->subframe_nbslots[subframeIdx]; slot_idx++ ) { - RealBuffer[slot_idx] = Cldfb_RealBuffer_Binaural[ch][slot_idx]; - ImagBuffer[slot_idx] = Cldfb_ImagBuffer_Binaural[ch][slot_idx]; +#ifdef SPLIT_REND_WITH_HEAD_ROT + RealBuffer[slot_idx] = Cldfb_RealBuffer_Binaural[0][ch][slot_idx]; + ImagBuffer[slot_idx] = Cldfb_ImagBuffer_Binaural[0][ch][slot_idx]; +#else + RealBuffer[slot_idx] = Cldfb_RealBuffer_Binaural[ch][slot_idx]; + ImagBuffer[slot_idx] = Cldfb_ImagBuffer_Binaural[ch][slot_idx]; +#endif } cldfbSynthesis( RealBuffer, ImagBuffer, &( output_f[ch][slot_index_start_cldfb * maxBand] ), maxBand * st_ivas->hTcBuffer->subframe_nbslots[subframeIdx], st_ivas->cldfbSynDec[ch] ); @@ -1513,24 +1896,62 @@ void ivas_binaural_cldfb_sf( *-------------------------------------------------------------------------*/ void ivas_binRenderer( - BINAURAL_RENDERER_HANDLE hBinRenderer, /* i/o: binaural renderer handle */ + BINAURAL_RENDERER_HANDLE hBinRenderer, /* i/o: binaural renderer handle */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, +#endif COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined head and external orientation handle*/ const int16_t numTimeSlots, /* i : number of time slots to render */ #ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG HEAD_TRACK_DATA_HANDLE hPostRendHeadTrackData, #endif +#ifdef SPLIT_REND_WITH_HEAD_ROT + float Cldfb_RealBuffer_Binaural[][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Rotated Binaural signals */ + float Cldfb_ImagBuffer_Binaural[][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Rotated Binaural signals */ +#else float Cldfb_RealBuffer_Binaural[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Binaural signals */ float Cldfb_ImagBuffer_Binaural[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Binaural signals */ - float RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i : LS signals */ - float ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX] /* i : LS signals */ +#endif + float RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i : LS signals */ + float ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX] /* i : LS signals */ ) { int16_t chIdx, k; +#ifdef SPLIT_REND_WITH_HEAD_ROT + int16_t pos_idx, num_poses; + float RealBuffer_local[MAX_OUTPUT_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; + float ImagBuffer_local[MAX_OUTPUT_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; +#endif push_wmops( "fastconv_binaural_rendering" ); +#ifdef SPLIT_REND_WITH_HEAD_ROT + num_poses = hBinRenderer->numPoses; +#endif /* Compute Convolution */ /* memory reset for the binaural output */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + for ( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) + { + for ( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ ) + { + for ( k = 0; k < numTimeSlots; k++ ) + { + set_zero( Cldfb_RealBuffer_Binaural[pos_idx][chIdx][k], CLDFB_NO_CHANNELS_MAX ); + set_zero( Cldfb_ImagBuffer_Binaural[pos_idx][chIdx][k], CLDFB_NO_CHANNELS_MAX ); + } + } + } + + for ( chIdx = 0; chIdx < hBinRenderer->hInputSetup->nchan_out_woLFE; chIdx++ ) + { + for ( k = 0; k < numTimeSlots; k++ ) + { + mvr2r( RealBuffer[chIdx][k], RealBuffer_local[chIdx][k], CLDFB_NO_CHANNELS_MAX ); + mvr2r( ImagBuffer[chIdx][k], ImagBuffer_local[chIdx][k], CLDFB_NO_CHANNELS_MAX ); + } + } +#else for ( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ ) { for ( k = 0; k < numTimeSlots; k++ ) @@ -1539,6 +1960,7 @@ void ivas_binRenderer( set_zero( Cldfb_ImagBuffer_Binaural[chIdx][k], CLDFB_NO_CHANNELS_MAX ); } } +#endif /* Head rotation in HOA3 or CICPx */ if ( hCombinedOrientationData != NULL && hCombinedOrientationData->enableCombinedOrientation[hCombinedOrientationData->subframe_idx] && hBinRenderer->rotInCldfb ) @@ -1568,8 +1990,73 @@ void ivas_binRenderer( ivas_sba2mc_cldfb( *( hBinRenderer->hInputSetup ), RealBuffer, ImagBuffer, hBinRenderer->nInChannels, hBinRenderer->conv_band, numTimeSlots, hBinRenderer->hoa_dec_mtx ); } +#ifdef SPLIT_REND_WITH_HEAD_ROT + ivas_binRenderer_filterModule( Cldfb_RealBuffer_Binaural[0], Cldfb_ImagBuffer_Binaural[0], RealBuffer, ImagBuffer, numTimeSlots, hBinRenderer, 0 ); +#else ivas_binRenderer_filterModule( Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, RealBuffer, ImagBuffer, numTimeSlots, hBinRenderer ); +#endif +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( pMultiBinPoseData != NULL ) + { + if ( pMultiBinPoseData->num_poses > 1 ) + { + IVAS_QUATERNION Quaternions_rel, Quaternions_abs, *Quaternions_ref; + float Rmat_local[3][3]; + + if ( hCombinedOrientationData && hBinRenderer->rotInCldfb ) + { + Quaternions_ref = &hCombinedOrientationData->Quaternions[0]; + Quaternions_rel.w = -3.0f; /*euler*/ + Quaternions_abs.w = -3.0f; + + if ( hCombinedOrientationData->shd_rot_max_order == 0 ) + { + /*HOA signal already rotated by DirAC*/ + Quaternions_abs.x = 0.0f; + Quaternions_abs.y = 0.0f; + Quaternions_abs.z = 0.0f; + } + else + { + /*euler*/ + Quat2EulerDegree( *Quaternions_ref, &Quaternions_abs.z, &Quaternions_abs.y, &Quaternions_abs.x ); /*order in Quat2Euler seems to be reversed ?*/ + } + + for ( pos_idx = 1; pos_idx < pMultiBinPoseData->num_poses; pos_idx++ ) + { + for ( chIdx = 0; chIdx < hBinRenderer->hInputSetup->nchan_out_woLFE; chIdx++ ) + { + for ( k = 0; k < numTimeSlots; k++ ) + { + mvr2r( RealBuffer_local[chIdx][k], RealBuffer[chIdx][k], CLDFB_NO_CHANNELS_MAX ); + mvr2r( ImagBuffer_local[chIdx][k], ImagBuffer[chIdx][k], CLDFB_NO_CHANNELS_MAX ); + } + } + Quaternions_rel.x = pMultiBinPoseData->relative_head_poses[pos_idx][0] - pMultiBinPoseData->relative_head_poses[pos_idx - 1][0]; + Quaternions_rel.y = pMultiBinPoseData->relative_head_poses[pos_idx][1] - pMultiBinPoseData->relative_head_poses[pos_idx - 1][1]; + Quaternions_rel.z = pMultiBinPoseData->relative_head_poses[pos_idx][2] - pMultiBinPoseData->relative_head_poses[pos_idx - 1][2]; + Quaternions_abs.x = Quaternions_abs.x + Quaternions_rel.x; + Quaternions_abs.y = Quaternions_abs.y + Quaternions_rel.y; + Quaternions_abs.z = Quaternions_abs.z + Quaternions_rel.z; + + QuatToRotMat( Quaternions_abs, Rmat_local ); + + if ( hBinRenderer->hInputSetup->is_loudspeaker_setup ) + { + rotateFrame_sd_cldfb( Rmat_local, RealBuffer, ImagBuffer, hBinRenderer->hInputSetup, hBinRenderer->hEFAPdata, numTimeSlots, hBinRenderer->conv_band ); + } + else + { + rotateFrame_shd_cldfb( RealBuffer, ImagBuffer, Rmat_local, hBinRenderer->hInputSetup->nchan_out_woLFE, numTimeSlots, 3 ); + } + + ivas_binRenderer_filterModule( Cldfb_RealBuffer_Binaural[pos_idx], Cldfb_ImagBuffer_Binaural[pos_idx], RealBuffer, ImagBuffer, numTimeSlots, hBinRenderer, pos_idx ); + } + } + } + } +#endif /* Obtain the binaural dmx and compute the reverb */ if ( hBinRenderer->hReverb != NULL ) @@ -1597,9 +2084,18 @@ void ivas_binRenderer( { for ( k = 0; k < numTimeSlots; k++ ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT + for ( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) + { + /* Combine first and second parts to generate binaural output signal with room effect */ + v_add( Cldfb_RealBuffer_Binaural[pos_idx][chIdx][k], reverbRe[chIdx][k], Cldfb_RealBuffer_Binaural[pos_idx][chIdx][k], hBinRenderer->conv_band ); + v_add( Cldfb_ImagBuffer_Binaural[pos_idx][chIdx][k], reverbIm[chIdx][k], Cldfb_ImagBuffer_Binaural[pos_idx][chIdx][k], hBinRenderer->conv_band ); + } +#else /* Combine first and second parts to generate binaural output signal with room effect */ v_add( Cldfb_RealBuffer_Binaural[chIdx][k], reverbRe[chIdx][k], Cldfb_RealBuffer_Binaural[chIdx][k], hBinRenderer->conv_band ); v_add( Cldfb_ImagBuffer_Binaural[chIdx][k], reverbIm[chIdx][k], Cldfb_ImagBuffer_Binaural[chIdx][k], hBinRenderer->conv_band ); +#endif } } } @@ -1607,3 +2103,92 @@ void ivas_binRenderer( pop_wmops(); return; } + + +#ifdef SPLIT_REND_WITH_HEAD_ROT +/*------------------------------------------------------------------------- + * ivas_rend_CldfbMultiBinRendProcess() + * + * + *-------------------------------------------------------------------------*/ + +void ivas_rend_CldfbMultiBinRendProcess( + const BINAURAL_RENDERER_HANDLE hCldfbRend, + const COMBINED_ORIENTATION_HANDLE *pCombinedOrientationData, + const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + float Cldfb_In_Real[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + float Cldfb_In_Imag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + float Cldfb_Out_Real[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* o : Binaural signals */ + float Cldfb_Out_Imag[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + const int16_t low_res_pre_rend_rot, + const int16_t num_subframes ) +{ + int16_t slot_idx, ch_idx, idx, pose_idx, i, j; + int16_t sf_idx; + float Cldfb_RealBuffer_sfIn[MAX_INPUT_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; + float Cldfb_ImagBuffer_sfIn[MAX_INPUT_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG + HEAD_TRACK_DATA head_track_post; + float Cldfb_RealBuffer_Binaural[MAX_HEAD_ROT_POSES + 1][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; + float Cldfb_ImagBuffer_Binaural[MAX_HEAD_ROT_POSES + 1][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; +#else + float Cldfb_RealBuffer_Binaural[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; + float Cldfb_ImagBuffer_Binaural[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; +#endif + + for ( sf_idx = 0; sf_idx < num_subframes; sf_idx++ ) + { + for ( slot_idx = 0; slot_idx < MAX_PARAM_SPATIAL_SUBFRAMES; slot_idx++ ) + { + idx = sf_idx * MAX_PARAM_SPATIAL_SUBFRAMES + slot_idx; + for ( ch_idx = 0; ch_idx < hCldfbRend->nInChannels; ch_idx++ ) + { + mvr2r( &Cldfb_In_Real[ch_idx][idx][0], &Cldfb_RealBuffer_sfIn[ch_idx][slot_idx][0], hCldfbRend->max_band ); + mvr2r( &Cldfb_In_Imag[ch_idx][idx][0], &Cldfb_ImagBuffer_sfIn[ch_idx][slot_idx][0], hCldfbRend->max_band ); + } + } + + if ( ( *pCombinedOrientationData ) != NULL ) + { + if ( ( low_res_pre_rend_rot ) && ( pMultiBinPoseData->poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) ) + { + ( *pCombinedOrientationData )->Quaternions[sf_idx] = ( *pCombinedOrientationData )->Quaternions[0]; + for ( i = 0; i < 3; i++ ) + { + for ( j = 0; j < 3; j++ ) + { + ( *pCombinedOrientationData )->Rmat[sf_idx][i][j] = ( *pCombinedOrientationData )->Rmat[0][i][j]; + } + } + } + ( *pCombinedOrientationData )->shd_rot_max_order = -1; + } + +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG + head_track_post.num_quaternions = 0; + head_track_post.shd_rot_max_order = -1; + head_track_post.Quaternions[0] = ivas_split_rend_get_sf_rot_data( pHeadRotData->headPositionsPostRend, sf_idx ); +#endif + +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG + ivas_binRenderer( hCldfbRend, pMultiBinPoseData, *pCombinedOrientationData, MAX_PARAM_SPATIAL_SUBFRAMES, &head_track_post, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer_sfIn, Cldfb_ImagBuffer_sfIn ); +#else + ivas_binRenderer( hCldfbRend, pMultiBinPoseData, *pCombinedOrientationData, MAX_PARAM_SPATIAL_SUBFRAMES, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer_sfIn, Cldfb_ImagBuffer_sfIn ); +#endif + for ( pose_idx = 0; pose_idx < hCldfbRend->numPoses; pose_idx++ ) + { + for ( slot_idx = 0; slot_idx < MAX_PARAM_SPATIAL_SUBFRAMES; slot_idx++ ) + { + idx = sf_idx * MAX_PARAM_SPATIAL_SUBFRAMES + slot_idx; + for ( ch_idx = 0; ch_idx < BINAURAL_CHANNELS; ch_idx++ ) + { + mvr2r( &Cldfb_RealBuffer_Binaural[pose_idx][ch_idx][slot_idx][0], &Cldfb_Out_Real[( pose_idx * BINAURAL_CHANNELS ) + ch_idx][idx][0], hCldfbRend->max_band ); + mvr2r( &Cldfb_ImagBuffer_Binaural[pose_idx][ch_idx][slot_idx][0], &Cldfb_Out_Imag[( pose_idx * BINAURAL_CHANNELS ) + ch_idx][idx][0], hCldfbRend->max_band ); + } + } + } + } + + return; +} +#endif diff --git a/lib_dec/ivas_core_dec.c b/lib_dec/ivas_core_dec.c index 639a7b636559d3fbfb7fe8f826dfe877998ef890..9d6270e947bf7cd9dabee5643fc12da3c3ee70b0 100644 --- a/lib_dec/ivas_core_dec.c +++ b/lib_dec/ivas_core_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_corecoder_dec_reconfig.c b/lib_dec/ivas_corecoder_dec_reconfig.c index aaff963d5fadfd15a0c4954b192003d056ebd8ba..be20a65d1c1db18252cd29419320dc41ac431825 100644 --- a/lib_dec/ivas_corecoder_dec_reconfig.c +++ b/lib_dec/ivas_corecoder_dec_reconfig.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_cpe_dec.c b/lib_dec/ivas_cpe_dec.c index 1972c326273cd52de743a8ea9f8adafa21775ef7..97b59b1bad1e8dcb734d4b91c6500e432d81cac9 100644 --- a/lib_dec/ivas_cpe_dec.c +++ b/lib_dec/ivas_cpe_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index aeb2b1d06c6c995b54b67c48fe80b4e0b7936707..dc5a821671a90214b6b21d99843ed51cb899160b 100644 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_decision_matrix_dec.c b/lib_dec/ivas_decision_matrix_dec.c index ba53de1da1e63f5ce0e385bfc33e660ba8539f9b..eaa404da974b4a7e38137c8c62ac0ae064bac418 100644 --- a/lib_dec/ivas_decision_matrix_dec.c +++ b/lib_dec/ivas_decision_matrix_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index 725ea879bb4b8762e8eabaff5fdbc34ca65eb65e..c429686f7bf685d79e4a0862e2739c6f2dae4b86 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other @@ -765,6 +765,9 @@ ivas_error ivas_dirac_dec_config( int16_t need_parambin; int16_t dec_param_estim_old; int16_t dec_param_estim_new; +#ifdef SPLIT_REND_WITH_HEAD_ROT + int16_t num_poses, pos_idx; +#endif error = IVAS_ERR_OK; @@ -775,6 +778,14 @@ ivas_error ivas_dirac_dec_config( hodirac_flag = ivas_get_hodirac_flag( st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->sba_analysis_order ); dec_param_estim_old = ( dec_config_flag == DIRAC_RECONFIGURE ) ? st_ivas->hDirAC->hConfig->dec_param_estim : FALSE; +#ifdef SPLIT_REND_WITH_HEAD_ROT + num_poses = 1; + if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + { + num_poses = st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses; + } +#endif + sparfoa_flag = 0; if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_FOA && st_ivas->ivas_format == SBA_FORMAT && !hodirac_flag ) { @@ -810,7 +821,11 @@ ivas_error ivas_dirac_dec_config( if ( !need_parambin ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT + ivas_dirac_dec_close_binaural_data( st_ivas->hDiracDecBin ); +#else ivas_dirac_dec_close_binaural_data( &st_ivas->hDiracDecBin ); +#endif } need_dirac_rend = 0; @@ -862,7 +877,11 @@ ivas_error ivas_dirac_dec_config( } } +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( st_ivas->hDiracDecBin[0] == NULL ) +#else if ( st_ivas->hDiracDecBin == NULL ) +#endif { if ( ( error = ivas_dirac_dec_init_binaural_data( st_ivas, st_ivas->hHrtfParambin ) ) != IVAS_ERR_OK ) { @@ -872,34 +891,72 @@ ivas_error ivas_dirac_dec_config( else { /* This is required to keep BE in rate switching. This probably means that 1TC and 2TC MASA perform differently. */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( st_ivas->hDiracDecBin[0]->h_freq_domain_decorr_ap_params != NULL && !( st_ivas->ivas_format == MASA_FORMAT && st_ivas->nSCE > 0 ) ) +#else if ( st_ivas->hDiracDecBin->h_freq_domain_decorr_ap_params != NULL && !( st_ivas->ivas_format == MASA_FORMAT && st_ivas->nSCE > 0 ) ) +#endif { +#ifdef SPLIT_REND_WITH_HEAD_ROT + ivas_dirac_dec_decorr_close( &st_ivas->hDiracDecBin[0]->h_freq_domain_decorr_ap_params, &st_ivas->hDiracDecBin[0]->h_freq_domain_decorr_ap_state ); +#else ivas_dirac_dec_decorr_close( &st_ivas->hDiracDecBin->h_freq_domain_decorr_ap_params, &st_ivas->hDiracDecBin->h_freq_domain_decorr_ap_state ); +#endif } +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( error = ivas_td_decorr_reconfig_dec( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hDecoderConfig->output_Fs, &( st_ivas->hDiracDecBin[0]->hTdDecorr ), &( st_ivas->hDiracDecBin[0]->useTdDecorr ) ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_td_decorr_reconfig_dec( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hDecoderConfig->output_Fs, &( st_ivas->hDiracDecBin->hTdDecorr ), &( st_ivas->hDiracDecBin->useTdDecorr ) ) ) != IVAS_ERR_OK ) +#endif { return error; } +#ifdef SPLIT_REND_WITH_HEAD_ROT + /* copy td-decorr flag to split renderer side rendereres */ + for ( pos_idx = 1; pos_idx < num_poses; pos_idx++ ) + { + st_ivas->hDiracDecBin[pos_idx]->useTdDecorr = st_ivas->hDiracDecBin[0]->useTdDecorr; + } + + if ( !st_ivas->hDiracDecBin[0]->useTdDecorr ) +#else if ( !st_ivas->hDiracDecBin->useTdDecorr ) +#endif { +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( st_ivas->hDiracDecBin[0]->h_freq_domain_decorr_ap_params == NULL ) +#else if ( st_ivas->hDiracDecBin->h_freq_domain_decorr_ap_params == NULL ) +#endif { float frequency_axis[CLDFB_NO_CHANNELS_MAX]; ivas_dirac_dec_get_frequency_axis( frequency_axis, st_ivas->hDecoderConfig->output_Fs, st_ivas->hSpatParamRendCom->num_freq_bands ); - if ( ( error = ivas_dirac_dec_decorr_open( &( st_ivas->hDiracDecBin->h_freq_domain_decorr_ap_params ), &( st_ivas->hDiracDecBin->h_freq_domain_decorr_ap_state ), st_ivas->hSpatParamRendCom->num_freq_bands, BINAURAL_CHANNELS, BINAURAL_CHANNELS, - DIRAC_SYNTHESIS_PSD_LS, frequency_axis, BINAURAL_CHANNELS, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_dirac_dec_decorr_open( +#ifdef SPLIT_REND_WITH_HEAD_ROT + &( st_ivas->hDiracDecBin[0]->h_freq_domain_decorr_ap_params ), &( st_ivas->hDiracDecBin[0]->h_freq_domain_decorr_ap_state ), st_ivas->hSpatParamRendCom->num_freq_bands, BINAURAL_CHANNELS, BINAURAL_CHANNELS, +#else + &( st_ivas->hDiracDecBin->h_freq_domain_decorr_ap_params ), &( st_ivas->hDiracDecBin->h_freq_domain_decorr_ap_state ), st_ivas->hSpatParamRendCom->num_freq_bands, BINAURAL_CHANNELS, BINAURAL_CHANNELS, +#endif + DIRAC_SYNTHESIS_PSD_LS, frequency_axis, BINAURAL_CHANNELS, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) { return error; } } } +#ifdef SPLIT_REND_WITH_HEAD_ROT + for ( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) + { + st_ivas->hDiracDecBin[pos_idx]->reqularizationFactor = configure_reqularization_factor( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate ); + } +#else st_ivas->hDiracDecBin->reqularizationFactor = configure_reqularization_factor( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate ); +#endif } } } @@ -1628,8 +1685,13 @@ void ivas_dirac_dec_render_sf( /*CLDFB: last output channels reserved to LFT for CICPx*/ float Cldfb_RealBuffer[MAX_OUTPUT_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; float Cldfb_ImagBuffer[MAX_OUTPUT_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; +#ifdef SPLIT_REND_WITH_HEAD_ROT + float Cldfb_RealBuffer_Binaural[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; + float Cldfb_ImagBuffer_Binaural[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; +#else float Cldfb_RealBuffer_Binaural[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; float Cldfb_ImagBuffer_Binaural[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; +#endif float Cldfb_RealBuffer_Temp[2][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; float Cldfb_ImagBuffer_Temp[2][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; int16_t index, num_freq_bands; @@ -2325,9 +2387,29 @@ void ivas_dirac_dec_render_sf( } } +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + { + if ( st_ivas->hSplitBinRend->hCldfbDataOut != NULL ) + { + for ( slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[subframe_idx]; slot_idx++ ) + { + for ( ch = 0; ch < st_ivas->hBinRenderer->nInChannels; ch++ ) + { + mvr2r( Cldfb_RealBuffer[ch][slot_idx], st_ivas->hSplitBinRend->hCldfbDataOut->Cldfb_RealBuffer[ch][slot_idx_start + slot_idx], hSpatParamRendCom->num_freq_bands ); + mvr2r( Cldfb_ImagBuffer[ch][slot_idx], st_ivas->hSplitBinRend->hCldfbDataOut->Cldfb_ImagBuffer[ch][slot_idx_start + slot_idx], hSpatParamRendCom->num_freq_bands ); + } + } + st_ivas->hSplitBinRend->hCldfbDataOut->config = st_ivas->hIntSetup.output_config; + } + } +#endif /* Perform binaural rendering */ ivas_binRenderer( st_ivas->hBinRenderer, +#ifdef SPLIT_REND_WITH_HEAD_ROT + ( st_ivas->hSplitBinRend == NULL ) ? NULL : &st_ivas->hSplitBinRend->splitrend.multiBinPoseData, +#endif st_ivas->hCombinedOrientationData, hSpatParamRendCom->subframe_nbslots[subframe_idx], @@ -2335,6 +2417,23 @@ void ivas_dirac_dec_render_sf( NULL, #endif Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer, Cldfb_ImagBuffer ); +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + { + int16_t pos_idx; + for ( pos_idx = 0; pos_idx < st_ivas->hBinRenderer->numPoses; pos_idx++ ) + { + for ( slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[subframe_idx]; slot_idx++ ) + { + for ( ch = 0; ch < st_ivas->hDecoderConfig->nchan_out; ch++ ) + { + mvr2r( Cldfb_RealBuffer_Binaural[pos_idx][ch][slot_idx], st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_RealBuffer_Binaural[( pos_idx * BINAURAL_CHANNELS ) + ch][slot_idx_start + slot_idx], hSpatParamRendCom->num_freq_bands ); + mvr2r( Cldfb_ImagBuffer_Binaural[pos_idx][ch][slot_idx], st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural[( pos_idx * BINAURAL_CHANNELS ) + ch][slot_idx_start + slot_idx], hSpatParamRendCom->num_freq_bands ); + } + } + } + } +#endif /* Inverse CLDFB*/ for ( ch = 0; ch < st_ivas->hDecoderConfig->nchan_out; ch++ ) @@ -2345,8 +2444,13 @@ void ivas_dirac_dec_render_sf( for ( i = 0; i < hSpatParamRendCom->subframe_nbslots[subframe_idx]; i++ ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT + RealBuffer[i] = Cldfb_RealBuffer_Binaural[0][ch][i]; + ImagBuffer[i] = Cldfb_ImagBuffer_Binaural[0][ch][i]; +#else RealBuffer[i] = Cldfb_RealBuffer_Binaural[ch][i]; ImagBuffer[i] = Cldfb_ImagBuffer_Binaural[ch][i]; +#endif } cldfbSynthesis( RealBuffer, ImagBuffer, &( output_f[ch][index_slot * hSpatParamRendCom->num_freq_bands] ), hSpatParamRendCom->num_freq_bands * hSpatParamRendCom->subframe_nbslots[subframe_idx], st_ivas->cldfbSynDec[ch] ); diff --git a/lib_dec/ivas_dirac_output_synthesis_cov.c b/lib_dec/ivas_dirac_output_synthesis_cov.c index 82119db1c64129c0b824915f229f8e2a261adee4..ca98600a79cdda65ab4eae98e8c0f879a79cadc9 100644 --- a/lib_dec/ivas_dirac_output_synthesis_cov.c +++ b/lib_dec/ivas_dirac_output_synthesis_cov.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_entropy_decoder.c b/lib_dec/ivas_entropy_decoder.c index bf91f3e695eb22d40715f4f545b77211756fa2f1..664ecbf232230f092d6e78cf96aa0f0d807ab0d4 100644 --- a/lib_dec/ivas_entropy_decoder.c +++ b/lib_dec/ivas_entropy_decoder.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index c91aecdb7c2ca9e0d8bfa3e37b94c5b80e7a58d6..839a16a69b12619ef9eb803cf6d5a17d949d176d 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other @@ -37,6 +37,11 @@ #include "ivas_rom_com.h" #include "ivas_stat_enc.h" #include "prot.h" +#ifdef SPLIT_REND_WITH_HEAD_ROT +#include "lib_isar_pre_rend.h" +#include "isar_prot.h" +#include "isar_stat.h" +#endif #include #include #include @@ -54,6 +59,186 @@ static ivas_error ivas_read_format( Decoder_Struct *st_ivas, int16_t *num_bits_r static ivas_error doSanityChecks_IVAS( Decoder_Struct *st_ivas ); +#ifdef SPLIT_REND_WITH_HEAD_ROT +static ivas_error ivas_dec_reconfig_split_rend( Decoder_Struct *st_ivas ); + + +/*-------------------------------------------------------------------* + * ivas_dec_reconfig_split_rend() + * + * IVAS decoder split rend reconfig + *-------------------------------------------------------------------*/ + +static ivas_error ivas_dec_reconfig_split_rend( + Decoder_Struct *st_ivas /* i : IVAS decoder structure */ +) +{ + ivas_error error; + int16_t cldfb_in_flag, num_ch, ch, isCldfbNeeded, i, pcm_out_flag; + SPLIT_REND_WRAPPER *hSplitRendWrapper; + + hSplitRendWrapper = &st_ivas->hSplitBinRend->splitrend; + pcm_out_flag = ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0; + cldfb_in_flag = 0; + + if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || + st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || + st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || + st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) + { + cldfb_in_flag = 1; + } + + ISAR_PRE_REND_GetMultiBinPoseData( &st_ivas->hRenderConfig->split_rend_config, &hSplitRendWrapper->multiBinPoseData, ( st_ivas->hHeadTrackData != NULL ) ? st_ivas->hHeadTrackData->sr_pose_pred_axis : DEFAULT_AXIS ); + + isCldfbNeeded = 0; + + if ( ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV && st_ivas->ivas_format == SBA_ISM_FORMAT ) || + ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) ) + { + cldfb_in_flag = 0; + } + + if ( st_ivas->renderer_type != RENDERER_DISABLE ) + { + if ( cldfb_in_flag == 0 ) + { + isCldfbNeeded = 1; + } + else if ( st_ivas->hRenderConfig->split_rend_config.codec == ISAR_SPLIT_REND_CODEC_LC3PLUS && cldfb_in_flag ) + { + isCldfbNeeded = 1; + } + else if ( pcm_out_flag && cldfb_in_flag ) + { + isCldfbNeeded = 1; + } + } + else if ( st_ivas->hDecoderConfig->Opt_non_diegetic_pan ) + { + isCldfbNeeded = 1; + } + + if ( isCldfbNeeded == 1 && hSplitRendWrapper->hCldfbHandles == NULL ) + { + if ( ( hSplitRendWrapper->hCldfbHandles = (CLDFB_HANDLES_WRAPPER_HANDLE) malloc( sizeof( CLDFB_HANDLES_WRAPPER ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for CLDFB handles\n" ) ); + } + + num_ch = MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS; + for ( ch = 0; ch < num_ch; ch++ ) + { + hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] = NULL; + } + + num_ch = hSplitRendWrapper->multiBinPoseData.num_poses * BINAURAL_CHANNELS; + + for ( ch = 0; ch < num_ch; ch++ ) + { + if ( ( error = openCldfb( &( hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] ), CLDFB_ANALYSIS, st_ivas->hDecoderConfig->output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not open CLDFB handles\n" ) ); + } + } + + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + if ( ( error = openCldfb( &( hSplitRendWrapper->hCldfbHandles->cldfbSyn[ch] ), CLDFB_SYNTHESIS, st_ivas->hDecoderConfig->output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) + { + return error; + } + } + } + else if ( isCldfbNeeded == 0 && hSplitRendWrapper->hCldfbHandles != NULL ) + { + num_ch = MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS; + for ( ch = 0; ch < num_ch; ch++ ) + { + if ( hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] != NULL ) + { + deleteCldfb( &hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] ); + hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] = NULL; + } + } + + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + if ( hSplitRendWrapper->hCldfbHandles->cldfbSyn[ch] != NULL ) + { + deleteCldfb( &hSplitRendWrapper->hCldfbHandles->cldfbSyn[ch] ); + hSplitRendWrapper->hCldfbHandles->cldfbSyn[ch] = NULL; + } + } + + free( hSplitRendWrapper->hCldfbHandles ); + hSplitRendWrapper->hCldfbHandles = NULL; + } + + if ( ( st_ivas->renderer_type != RENDERER_BINAURAL_OBJECTS_TD ) && + ( st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV || st_ivas->ivas_format != SBA_ISM_FORMAT ) && + !( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) ) /* td-rend not needed? */ + { + for ( i = 0; i < MAX_HEAD_ROT_POSES - 1; ++i ) + { + if ( st_ivas->hTdRendHandles[i] != NULL ) + { + st_ivas->hTdRendHandles[i]->HrFiltSet_p = NULL; + ivas_td_binaural_close( &st_ivas->hTdRendHandles[i] ); + } + } + } + + return IVAS_ERR_OK; +} + + +/*-------------------------------------------------------------------* + * ivas_dec_init_split_rend() + * + * IVAS decoder split rend init + *-------------------------------------------------------------------*/ + +static ivas_error ivas_dec_init_split_rend( + Decoder_Struct *st_ivas /* i : IVAS decoder structure */ +) +{ + ivas_error error; + int16_t cldfb_in_flag, pcm_out_flag; + int16_t mixed_td_cldfb_flag; + + pcm_out_flag = ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0; + cldfb_in_flag = 0; + + if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || + st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || + st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || + st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) + { + cldfb_in_flag = 1; + } + + ISAR_PRE_REND_GetMultiBinPoseData( &st_ivas->hRenderConfig->split_rend_config, &st_ivas->hSplitBinRend->splitrend.multiBinPoseData, ( st_ivas->hHeadTrackData != NULL ) ? st_ivas->hHeadTrackData->sr_pose_pred_axis : DEFAULT_AXIS ); + + if ( cldfb_in_flag == 1 && ( st_ivas->hSplitBinRend->splitrend.multiBinPoseData.poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE ) ) + { + if ( ( st_ivas->hSplitBinRend->hCldfbDataOut = (ISAR_DEC_SPLIT_REND_CLDFB_OUT_DATA_HANDLE) malloc( sizeof( ISAR_DEC_SPLIT_REND_CLDFB_OUT_DATA ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for cldfb data out buffer\n" ) ); + } + } + + mixed_td_cldfb_flag = 0; + if ( ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV && st_ivas->ivas_format == SBA_ISM_FORMAT ) || + ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) ) + { + mixed_td_cldfb_flag = 1; + } + + error = ISAR_PRE_REND_open( &st_ivas->hSplitBinRend->splitrend, &st_ivas->hRenderConfig->split_rend_config, st_ivas->hDecoderConfig->output_Fs, cldfb_in_flag, pcm_out_flag, (int16_t) st_ivas->hDecoderConfig->render_framesize, mixed_td_cldfb_flag ); + return error; +} +#endif /*-------------------------------------------------------------------* * ivas_dec_setup() @@ -64,7 +249,12 @@ static ivas_error doSanityChecks_IVAS( Decoder_Struct *st_ivas ); ivas_error ivas_dec_setup( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ uint16_t *nSamplesRendered, /* o : number of samples flushed from the previous frame (JBM) */ - int16_t *data /* o : output synthesis signal */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ + void *data /* o : output synthesis signal */ +#else + int16_t *data /* o : output synthesis signal */ +#endif ) { int16_t k, idx, num_bits_read; @@ -118,7 +308,11 @@ ivas_error ivas_dec_setup( st_ivas->nchan_ism = nchan_ism; +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( error = ivas_ism_dec_config( st_ivas, st_ivas->ism_mode, nSamplesRendered, pcm_resolution, data ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_ism_dec_config( st_ivas, st_ivas->ism_mode, nSamplesRendered, data ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -136,7 +330,11 @@ ivas_error ivas_dec_setup( num_bits_read += SBA_ORDER_BITS; if ( st_ivas->ini_frame > 0 && ivas_total_brate != st_ivas->last_active_ivas_total_brate && ivas_total_brate > IVAS_SID_5k2 ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( error = ivas_sba_dec_reconfigure( st_ivas, nSamplesRendered, pcm_resolution, data ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_sba_dec_reconfigure( st_ivas, nSamplesRendered, data ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -176,7 +374,11 @@ ivas_error ivas_dec_setup( else { +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( error = ivas_masa_dec_reconfigure( st_ivas, nSamplesRendered, pcm_resolution, data ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_masa_dec_reconfigure( st_ivas, nSamplesRendered, data ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -184,7 +386,11 @@ ivas_error ivas_dec_setup( } else { +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( error = ivas_omasa_dec_config( st_ivas, nSamplesRendered, pcm_resolution, data ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_omasa_dec_config( st_ivas, nSamplesRendered, data ) ) != IVAS_ERR_OK ) +#endif { return error; @@ -206,7 +412,11 @@ ivas_error ivas_dec_setup( /* reconfigure in case a change of operation mode is detected */ if ( ( ivas_total_brate > IVAS_SID_5k2 && ivas_total_brate != st_ivas->hDecoderConfig->last_ivas_total_brate ) || ( st_ivas->ini_active_frame == 0 ) ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( error = ivas_omasa_dec_config( st_ivas, nSamplesRendered, pcm_resolution, data ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_omasa_dec_config( st_ivas, nSamplesRendered, data ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -237,7 +447,11 @@ ivas_error ivas_dec_setup( if ( st_ivas->ini_frame > 0 && ivas_total_brate != st_ivas->last_active_ivas_total_brate ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( error = ivas_sba_dec_reconfigure( st_ivas, nSamplesRendered, pcm_resolution, data ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_sba_dec_reconfigure( st_ivas, nSamplesRendered, data ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -279,10 +493,17 @@ ivas_error ivas_dec_setup( num_bits_read += MC_LS_SETUP_BITS; /* select MC format mode; reconfigure the MC format decoder */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( error = ivas_mc_dec_config( st_ivas, idx, nSamplesRendered, pcm_resolution, data ) ) != IVAS_ERR_OK ) + { + return error; + } +#else if ( ( error = ivas_mc_dec_config( st_ivas, idx, nSamplesRendered, data ) ) != IVAS_ERR_OK ) { return error; } +#endif } /*-------------------------------------------------------------------* @@ -364,7 +585,11 @@ ivas_error ivas_dec_setup( st_ivas->hDecoderConfig->ivas_total_brate = IVAS_24k4; } +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( error = ivas_sba_dec_reconfigure( st_ivas, nSamplesRendered, pcm_resolution, data ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_sba_dec_reconfigure( st_ivas, nSamplesRendered, data ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -410,7 +635,11 @@ ivas_error ivas_dec_setup( last_ism_mode = st_ivas->ism_mode; } +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( error = ivas_ism_dec_config( st_ivas, last_ism_mode, nSamplesRendered, pcm_resolution, data ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_ism_dec_config( st_ivas, last_ism_mode, nSamplesRendered, data ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -435,6 +664,19 @@ ivas_error ivas_dec_setup( } } +#ifdef SPLIT_REND_WITH_HEAD_ROT + /*-----------------------------------------------------------------* + * reconfig split rendering as renderer might change after bitrate switching + *-----------------------------------------------------------------*/ + + if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + { + if ( ( error = ivas_dec_reconfig_split_rend( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } + } +#endif /*----------------------------------------------------------------* * Reset bitstream pointers @@ -804,7 +1046,12 @@ ivas_error ivas_init_decoder_front( * Allocate and initialize Binaural Renderer configuration handle *--------------------------------------------------------------------*/ - if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) + if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB +#ifdef SPLIT_REND_WITH_HEAD_ROT + || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM || + ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_STEREO && st_ivas->hDecoderConfig->Opt_non_diegetic_pan ) +#endif + ) { if ( ( error = ivas_render_config_open( &( st_ivas->hRenderConfig ) ) ) != IVAS_ERR_OK ) { @@ -947,6 +1194,20 @@ ivas_error ivas_init_decoder( } } +#ifdef SPLIT_REND_WITH_HEAD_ROT + /*-----------------------------------------------------------------* + * Initialize binuaral split rendering + *-----------------------------------------------------------------*/ + + if ( st_ivas->hSplitBinRend != NULL && ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM || + ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_STEREO && st_ivas->hDecoderConfig->Opt_non_diegetic_pan && st_ivas->hRenderConfig->split_rend_config.dof == 0 ) ) ) + { + if ( ( error = ivas_dec_init_split_rend( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } + } +#endif /*-----------------------------------------------------------------* * Allocate and initialize SCE/CPE and other handles @@ -1719,8 +1980,13 @@ ivas_error ivas_init_decoder( } } +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, + st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs, ( st_ivas->hSplitBinRend == NULL ) ? 1 : st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -1819,6 +2085,9 @@ ivas_error ivas_init_decoder( { if ( st_ivas->hBinRenderer->render_lfe ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) +#endif { /* Account for filterbank delay */ binauralization_delay_ns += IVAS_FB_DEC_DELAY_NS; @@ -2142,7 +2411,14 @@ void ivas_initialize_handles_dec( /* rendering handles */ st_ivas->hBinRenderer = NULL; +#ifdef SPLIT_REND_WITH_HEAD_ROT + for ( i = 0; i < MAX_HEAD_ROT_POSES; i++ ) + { + st_ivas->hDiracDecBin[i] = NULL; + } +#else st_ivas->hDiracDecBin = NULL; +#endif st_ivas->hDirACRend = NULL; st_ivas->hSpatParamRendCom = NULL; st_ivas->hLsSetUpConversion = NULL; @@ -2167,6 +2443,13 @@ void ivas_initialize_handles_dec( st_ivas->hExtOrientationData = NULL; st_ivas->hCombinedOrientationData = NULL; +#ifdef SPLIT_REND_WITH_HEAD_ROT + st_ivas->hSplitBinRend = NULL; + for ( i = 0; i < MAX_HEAD_ROT_POSES - 1; ++i ) + { + st_ivas->hTdRendHandles[i] = NULL; + } +#endif /* JBM handles */ st_ivas->hTcBuffer = NULL; @@ -2304,13 +2587,32 @@ void ivas_destroy_dec( /* Fastconv binaural renderer handle */ ivas_binRenderer_close( &st_ivas->hBinRenderer ); +#ifdef SPLIT_REND_WITH_HEAD_ROT + /* TD binaural renderer handles */ + for ( i = 0; i < MAX_HEAD_ROT_POSES - 1; ++i ) + { + if ( st_ivas->hTdRendHandles[i] != NULL ) + { + st_ivas->hTdRendHandles[i]->HrFiltSet_p = NULL; + ivas_td_binaural_close( &st_ivas->hTdRendHandles[i] ); + } + } +#endif /* Parametric binaural renderer handle */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + ivas_dirac_dec_close_binaural_data( st_ivas->hDiracDecBin ); +#else ivas_dirac_dec_close_binaural_data( &st_ivas->hDiracDecBin ); +#endif /* Crend handle */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + ivas_rend_closeCrend( &( st_ivas->hCrendWrapper ), ( st_ivas->hSplitBinRend == NULL ) ? 1 : st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ); +#else ivas_rend_closeCrend( &( st_ivas->hCrendWrapper ) ); +#endif /* Reverb handle */ ivas_reverb_close( &st_ivas->hReverb ); @@ -2457,7 +2759,11 @@ void ivas_init_dec_get_num_cldfb_instances( *numCldfbAnalyses = st_ivas->nchan_transport + 1; } } +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( st_ivas->hDiracDecBin[0]->useTdDecorr ) +#else if ( st_ivas->hDiracDecBin->useTdDecorr ) +#endif { *numCldfbAnalyses += 2; } @@ -2691,10 +2997,20 @@ static ivas_error doSanityChecks_IVAS( } } +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) && output_Fs != 48000 ) + { + return IVAS_ERROR( IVAS_ERR_INVALID_SAMPLING_RATE, "Error: Only 48kHz output sampling rate is supported for split rendering." ); + } +#endif if ( st_ivas->hDecoderConfig->Opt_Headrotation ) { - if ( !( output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) + if ( !( output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB +#ifdef SPLIT_REND_WITH_HEAD_ROT + || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM +#endif + ) ) { return IVAS_ERROR( IVAS_ERR_HEAD_ROTATION_NOT_SUPPORTED, "Wrong set-up: Head-rotation not supported in this configuration" ); } diff --git a/lib_dec/ivas_ism_dec.c b/lib_dec/ivas_ism_dec.c index 8f0291056339f1579dd74fa844aca4edae12837d..0a424c24cd4246f849a617f237252e57a4854e5f 100644 --- a/lib_dec/ivas_ism_dec.c +++ b/lib_dec/ivas_ism_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other @@ -51,7 +51,12 @@ static ivas_error ivas_ism_bitrate_switching_dec( const int16_t nchan_transport_old, /* i : last number of transport channels */ const ISM_MODE last_ism_mode, /* i : last ISM mode */ uint16_t *nSamplesRendered, /* o : number of samples rendered */ - int16_t *data /* o : output synthesis signal */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ + void *data /* o : output synthesis signal */ +#else + int16_t *data /* o : output synthesis signal */ +#endif ) { ivas_error error; @@ -140,7 +145,11 @@ static ivas_error ivas_ism_bitrate_switching_dec( if ( tc_granularity_new < st_ivas->hTcBuffer->n_samples_granularity ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( error = ivas_jbm_dec_flush_renderer( st_ivas, tc_granularity_new, renderer_type_old, intern_config_old, &hIntSetupOld, MC_MODE_NONE, last_ism_mode, nSamplesRendered, pcm_resolution, data ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_jbm_dec_flush_renderer( st_ivas, tc_granularity_new, renderer_type_old, intern_config_old, &hIntSetupOld, MC_MODE_NONE, last_ism_mode, nSamplesRendered, data ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -171,10 +180,18 @@ static ivas_error ivas_ism_bitrate_switching_dec( /* Deallocate the ParamISM struct */ ivas_param_ism_dec_close( &( st_ivas->hParamIsmDec ), &( st_ivas->hSpatParamRendCom ), st_ivas->hDecoderConfig->output_config ); - if ( st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL || st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) + if ( st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL || st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB +#ifdef SPLIT_REND_WITH_HEAD_ROT + || st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM +#endif + ) { /* close the parametric binaural renderer */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + ivas_dirac_dec_close_binaural_data( st_ivas->hDiracDecBin ); +#else ivas_dirac_dec_close_binaural_data( &st_ivas->hDiracDecBin ); +#endif /* Open the TD Binaural renderer */ if ( st_ivas->hHrtfTD == NULL || st_ivas->hBinRendererTd == NULL ) { @@ -205,10 +222,18 @@ static ivas_error ivas_ism_bitrate_switching_dec( if ( st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) { /* close the parametric binaural renderer */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + ivas_dirac_dec_close_binaural_data( st_ivas->hDiracDecBin ); +#else ivas_dirac_dec_close_binaural_data( &st_ivas->hDiracDecBin ); +#endif /* Open Crend Binaural renderer */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs, ( st_ivas->hSplitBinRend == NULL ) ? 1 : st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -226,7 +251,11 @@ static ivas_error ivas_ism_bitrate_switching_dec( return error; } - if ( st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL || st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) + if ( st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL || st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB +#ifdef SPLIT_REND_WITH_HEAD_ROT + || st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM +#endif + ) { /* open the parametric binaural renderer */ if ( ( error = ivas_dirac_dec_binaural_copy_hrtfs( &st_ivas->hHrtfParambin ) ) != IVAS_ERR_OK ) @@ -271,7 +300,11 @@ static ivas_error ivas_ism_bitrate_switching_dec( } /* close the crend binaural renderer */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + ivas_rend_closeCrend( &( st_ivas->hCrendWrapper ), ( st_ivas->hSplitBinRend == NULL ) ? 1 : st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ); +#else ivas_rend_closeCrend( &( st_ivas->hCrendWrapper ) ); +#endif } } @@ -358,7 +391,12 @@ ivas_error ivas_ism_dec_config( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const ISM_MODE last_ism_mode, /* i/o: last ISM mode */ uint16_t *nSamplesRendered, /* o : number of samples flushed when the renderer granularity changes */ - int16_t *data /* o : output synthesis signal */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ + void *data /* o : output synthesis signal */ +#else + int16_t *data /* o : output synthesis signal */ +#endif ) { int32_t ivas_total_brate; @@ -398,6 +436,9 @@ ivas_error ivas_ism_dec_config( if ( ( st_ivas->ism_mode != last_ism_mode ) || ( st_ivas->hDecoderConfig->ivas_total_brate != st_ivas->hDecoderConfig->last_ivas_total_brate ) ) { if ( ( error = ivas_ism_bitrate_switching_dec( st_ivas, nchan_transport_old, last_ism_mode, nSamplesRendered, +#ifdef SPLIT_REND_WITH_HEAD_ROT + pcm_resolution, +#endif data ) ) != IVAS_ERR_OK ) { return error; @@ -422,6 +463,9 @@ ivas_error ivas_ism_dec_config( if ( st_ivas->ism_mode != last_ism_mode ) { if ( ( error = ivas_ism_bitrate_switching_dec( st_ivas, nchan_transport_old, last_ism_mode, nSamplesRendered, +#ifdef SPLIT_REND_WITH_HEAD_ROT + pcm_resolution, +#endif data ) ) != IVAS_ERR_OK ) { return error; diff --git a/lib_dec/ivas_ism_dtx_dec.c b/lib_dec/ivas_ism_dtx_dec.c index 523002e746f43aab898a16c3c72b44b258e68739..3164218b41bd57525569775acd208ae842e39088 100644 --- a/lib_dec/ivas_ism_dtx_dec.c +++ b/lib_dec/ivas_ism_dtx_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_ism_metadata_dec.c b/lib_dec/ivas_ism_metadata_dec.c index bde79fcb5f43cf8fc8790db25ab4b3b46b8f5316..fd2d630299e34c10274e72d11562718d9e609c89 100644 --- a/lib_dec/ivas_ism_metadata_dec.c +++ b/lib_dec/ivas_ism_metadata_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index 485cd7e3d2c07bac032c13ad57bbf69969949ccf..74ab2ba8a0dee2c9dd95d4ea754f4e54b5fc3ec4 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other @@ -388,7 +388,11 @@ static ivas_error ivas_param_ism_rendering_init( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for interpolator\n" ) ); } +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( !( output_config == IVAS_AUDIO_CONFIG_EXTERNAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) +#else if ( !( output_config == IVAS_AUDIO_CONFIG_EXTERNAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) +#endif { /* computation of proto matrix */ ivas_ism_get_proto_matrix( hOutSetup, nchan_transport, hParamIsmRendering->proto_matrix ); @@ -541,8 +545,13 @@ ivas_error ivas_param_ism_dec_open( } } +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( !( output_config == IVAS_AUDIO_CONFIG_EXTERNAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB || + output_config == IVAS_AUDIO_CONFIG_MONO || output_config == IVAS_AUDIO_CONFIG_STEREO || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) +#else if ( !( output_config == IVAS_AUDIO_CONFIG_EXTERNAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB || output_config == IVAS_AUDIO_CONFIG_MONO || output_config == IVAS_AUDIO_CONFIG_STEREO ) ) +#endif { /* Initialize efap handle */ if ( ( error = efap_init_data( &( st_ivas->hEFAPdata ), hOutSetup.ls_azimuth, hOutSetup.ls_elevation, hOutSetup.nchan_out_woLFE, EFAP_MODE_EFAP ) ) != IVAS_ERR_OK ) @@ -559,7 +568,11 @@ ivas_error ivas_param_ism_dec_open( hSpatParamRendCom->dirac_bs_md_write_idx = 0; hSpatParamRendCom->dirac_read_idx = 0; +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) +#else if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) +#endif { if ( ( error = ivas_dirac_allocate_parameters( hSpatParamRendCom, 1 ) ) != IVAS_ERR_OK ) { diff --git a/lib_dec/ivas_ism_renderer.c b/lib_dec/ivas_ism_renderer.c index 018727ba250bb720fa5ed5eb7f808e8cd3db151e..e60e17608ece168e1d3a03464f0762391dfe0d0c 100644 --- a/lib_dec/ivas_ism_renderer.c +++ b/lib_dec/ivas_ism_renderer.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 884ebd0fcb475c1e9101a4726e8f163634bb684e..73eb0117e6bc49b7535f148dbe93effb84f83d2f 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other @@ -842,11 +842,19 @@ void ivas_jbm_dec_feed_tc_to_renderer( /* delay the objects here for all renderers where it is needed */ if ( - st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || - st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || - st_ivas->renderer_type == RENDERER_OSBA_AMBI || - st_ivas->renderer_type == RENDERER_OSBA_LS || - st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + ( +#endif + st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || + st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || + st_ivas->renderer_type == RENDERER_OSBA_AMBI || + st_ivas->renderer_type == RENDERER_OSBA_LS || + st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL +#ifdef SPLIT_REND_WITH_HEAD_ROT + ) && + ( st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) +#endif + ) { for ( n = 0; n < st_ivas->nchan_ism; n++ ) { @@ -921,7 +929,12 @@ ivas_error ivas_jbm_dec_render( const uint16_t nSamplesAsked, /* i : number of samples wanted */ uint16_t *nSamplesRendered, /* o : number of samples rendered */ uint16_t *nSamplesAvailableNext, /* o : number of samples still available in the rendering pipeline */ - int16_t *data /* o : output synthesis signal */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ + void *data /* o : output synthesis signal */ +#else + int16_t *data /* o : output synthesis signal */ +#endif ) { int16_t n, nchan_out; @@ -934,6 +947,9 @@ ivas_error ivas_jbm_dec_render( float *p_output[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS]; float *p_tc[MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS]; SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; +#ifdef SPLIT_REND_WITH_HEAD_ROT + int16_t nchan_out_syn_output; +#endif push_wmops( "ivas_dec_render" ); /*----------------------------------------------------------------* @@ -1053,14 +1069,33 @@ ivas_error ivas_jbm_dec_render( /* Binaural rendering */ if ( st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD ) { - if ( ( error = ivas_td_binaural_renderer_sf( st_ivas, p_output, *nSamplesRendered ) ) != IVAS_ERR_OK ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { - return error; + if ( ( error = ivas_td_binaural_renderer_sf_splitBinaural( st_ivas, p_output, *nSamplesRendered ) ) != IVAS_ERR_OK ) + { + return error; + } + } + else + { +#endif + if ( ( error = ivas_td_binaural_renderer_sf( st_ivas, p_output, *nSamplesRendered ) ) != IVAS_ERR_OK ) + { + return error; + } +#ifdef SPLIT_REND_WITH_HEAD_ROT } +#endif } else if ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) { +#if defined SPLIT_REND_WITH_HEAD_ROT + if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, st_ivas->hDecoderConfig, NULL, + NULL, NULL, st_ivas->hTcBuffer, p_output, p_output, *nSamplesRendered, output_Fs, 0 ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, st_ivas->hDecoderConfig, NULL, NULL, NULL, st_ivas->hTcBuffer, p_output, p_output, *nSamplesRendered, output_Fs ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -1241,16 +1276,36 @@ ivas_error ivas_jbm_dec_render( /* Rendering */ if ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + { + if ( ( error = ivas_rend_crendProcessSubframesSplitBin( st_ivas->hCrendWrapper, st_ivas->intern_config, st_ivas->hOutSetup.output_config, ( st_ivas->hSplitBinRend == NULL ) ? NULL : &st_ivas->hSplitBinRend->splitrend.multiBinPoseData, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, + &st_ivas->hIntSetup, st_ivas->hEFAPdata, st_ivas->hTcBuffer, crendInPlaceRotation ? p_output : p_tc, p_output, *nSamplesRendered, output_Fs ) ) != IVAS_ERR_OK ) + { + return error; + } + } + else + { +#endif +#if defined SPLIT_REND_WITH_HEAD_ROT + if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, + &st_ivas->hIntSetup, st_ivas->hEFAPdata, st_ivas->hTcBuffer, crendInPlaceRotation ? p_output : p_tc, p_output, *nSamplesRendered, output_Fs, 0 ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, &st_ivas->hIntSetup, st_ivas->hEFAPdata, st_ivas->hTcBuffer, crendInPlaceRotation ? p_output : p_tc, p_output, *nSamplesRendered, output_Fs ) ) != IVAS_ERR_OK ) +#endif - { - return error; - } + { + return error; + } - ivas_binaural_add_LFE( st_ivas, *nSamplesRendered, p_tc, p_output ); + ivas_binaural_add_LFE( st_ivas, *nSamplesRendered, p_tc, p_output ); +#ifdef SPLIT_REND_WITH_HEAD_ROT + } +#endif } else if ( st_ivas->renderer_type == RENDERER_MC ) { @@ -1263,12 +1318,27 @@ ivas_error ivas_jbm_dec_render( } else if ( st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD ) { - if ( ( error = ivas_td_binaural_renderer_sf( st_ivas, p_output, *nSamplesRendered ) ) != IVAS_ERR_OK ) + +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { - return error; + if ( ( error = ivas_td_binaural_renderer_sf_splitBinaural( st_ivas, p_output, *nSamplesRendered ) ) != IVAS_ERR_OK ) + { + return error; + } } + else + { +#endif + if ( ( error = ivas_td_binaural_renderer_sf( st_ivas, p_output, *nSamplesRendered ) ) != IVAS_ERR_OK ) + { + return error; + } - ivas_binaural_add_LFE( st_ivas, *nSamplesRendered, p_tc, p_output ); + ivas_binaural_add_LFE( st_ivas, *nSamplesRendered, p_tc, p_output ); +#ifdef SPLIT_REND_WITH_HEAD_ROT + } +#endif } } else if ( st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) @@ -1279,6 +1349,10 @@ ivas_error ivas_jbm_dec_render( /* Rendering */ if ( ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) && !st_ivas->hDecoderConfig->Opt_Headrotation ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT + /*handled in CLDFB domain already*/ + if ( output_config != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && output_config != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) +#endif { ivas_binaural_add_LFE( st_ivas, *nSamplesRendered, p_output, p_output ); } @@ -1378,6 +1452,18 @@ ivas_error ivas_jbm_dec_render( st_ivas->hTcBuffer->n_samples_discard = 0; } +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + { + nchan_out_syn_output = BINAURAL_CHANNELS * st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses; + } + else + { + nchan_out_syn_output = nchan_out; + } + + if ( st_ivas->hDecoderConfig->Opt_Limiter ) +#endif { if ( st_ivas->ivas_format != MONO_FORMAT ) { @@ -1387,11 +1473,30 @@ ivas_error ivas_jbm_dec_render( } } +#ifdef SPLIT_REND_WITH_HEAD_ROT + switch ( pcm_resolution ) + { + case PCM_INT16: +#endif #ifdef DEBUGGING - st_ivas->noClipping += + st_ivas->noClipping += +#endif +#ifdef SPLIT_REND_WITH_HEAD_ROT + ivas_syn_output( p_output, *nSamplesRendered, nchan_out_syn_output, (int16_t *) data ); +#else + ivas_syn_output( p_output, *nSamplesRendered, nchan_out, data ); #endif - ivas_syn_output( p_output, *nSamplesRendered, nchan_out, data ); +#ifdef SPLIT_REND_WITH_HEAD_ROT + break; + case PCM_FLOAT32: + ivas_syn_output_f( p_output, *nSamplesRendered, nchan_out_syn_output, (float *) data ); + break; + default: + error = IVAS_ERR_UNKNOWN; + break; + } +#endif *nSamplesAvailableNext = st_ivas->hTcBuffer->n_samples_available; @@ -1415,7 +1520,12 @@ ivas_error ivas_jbm_dec_flush_renderer( const MC_MODE mc_mode_old, /* i : old MC mode */ const ISM_MODE ism_mode_old, /* i : old ISM mode */ uint16_t *nSamplesRendered, /* o : number of samples flushed */ - int16_t *data /* o : output synthesis signal */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ + void *data /* o : output synthesis signal */ +#else + int16_t *data /* o : output synthesis signal */ +#endif ) { ivas_error error; @@ -1467,7 +1577,7 @@ ivas_error ivas_jbm_dec_flush_renderer( hTcBuffer->n_samples_buffered = hTcBuffer->n_samples_granularity + n_samples_still_available; hTcBuffer->n_samples_available = 0; hTcBuffer->n_samples_flushed = n_samples_to_render; -#ifdef CR_FIX_JBM_FLUSH_OFFSET +#ifdef NONBE_FIX_855_JBM_FLUSH_OFFSET hTcBuffer->n_samples_rendered = 0; #else hTcBuffer->n_samples_rendered = hTcBuffer->n_samples_granularity; @@ -1497,8 +1607,13 @@ ivas_error ivas_jbm_dec_flush_renderer( ivas_ism_render_sf( st_ivas, p_output, hTcBuffer->n_samples_granularity ); +#if defined SPLIT_REND_WITH_HEAD_ROT + if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, st_ivas->hDecoderConfig, NULL, + NULL, NULL, st_ivas->hTcBuffer, p_output, p_output, hTcBuffer->n_samples_granularity, st_ivas->hDecoderConfig->output_Fs, 0 ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, st_ivas->hDecoderConfig, NULL, NULL, NULL, st_ivas->hTcBuffer, p_output, p_output, hTcBuffer->n_samples_granularity, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -1515,8 +1630,13 @@ ivas_error ivas_jbm_dec_flush_renderer( { if ( renderer_type_old == RENDERER_BINAURAL_MIXER_CONV || renderer_type_old == RENDERER_BINAURAL_MIXER_CONV_ROOM ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, intern_config_old, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, + hIntSetupOld, st_ivas->hEFAPdata, st_ivas->hTcBuffer, hTcBuffer->tc, p_output, hTcBuffer->n_samples_granularity, st_ivas->hDecoderConfig->output_Fs, 0 ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, intern_config_old, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, hIntSetupOld, st_ivas->hEFAPdata, st_ivas->hTcBuffer, hTcBuffer->tc, p_output, hTcBuffer->n_samples_granularity, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -1613,7 +1733,7 @@ ivas_error ivas_jbm_dec_flush_renderer( { return IVAS_ERROR( IVAS_ERR_WRONG_MODE, "Wrong IVAS format in VoIP renderer flushing!" ); } -#ifdef CR_FIX_JBM_FLUSH_OFFSET +#ifdef NONBE_FIX_855_JBM_FLUSH_OFFSET hTcBuffer->n_samples_rendered = hTcBuffer->n_samples_granularity; #endif } @@ -1624,6 +1744,9 @@ ivas_error ivas_jbm_dec_flush_renderer( *nSamplesRendered = n_samples_to_render; /* Only write out the valid data*/ +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( st_ivas->hDecoderConfig->Opt_Limiter ) +#endif { if ( st_ivas->ivas_format != MONO_FORMAT ) { @@ -1633,12 +1756,30 @@ ivas_error ivas_jbm_dec_flush_renderer( } } +#ifdef SPLIT_REND_WITH_HEAD_ROT + switch ( pcm_resolution ) + { + case PCM_INT16: +#endif #ifdef DEBUGGING - st_ivas->noClipping += + st_ivas->noClipping += +#endif + ivas_syn_output( p_output, *nSamplesRendered, st_ivas->hDecoderConfig->nchan_out, +#ifdef SPLIT_REND_WITH_HEAD_ROT + (int16_t *) #endif - ivas_syn_output( p_output, *nSamplesRendered, st_ivas->hDecoderConfig->nchan_out, - data ); + data ); +#ifdef SPLIT_REND_WITH_HEAD_ROT + break; + case PCM_FLOAT32: + ivas_syn_output_f( p_output, *nSamplesRendered, st_ivas->hDecoderConfig->nchan_out, (float *) data ); + break; + default: + error = IVAS_ERR_UNKNOWN; + break; + } +#endif return IVAS_ERR_OK; } @@ -1960,7 +2101,11 @@ int16_t ivas_jbm_dec_get_num_tc_channels( { num_tc = CPE_CHANNELS; } +#ifdef NONBE_FIX_926_OSBA_DECODER_CRASH_PLANAR_SBA + if ( num_tc == 3 ) +#else if ( ( st_ivas->sba_planar && num_tc >= 3 ) || ( num_tc == 3 ) ) +#endif { num_tc++; } diff --git a/lib_dec/ivas_lfe_dec.c b/lib_dec/ivas_lfe_dec.c index 63899b1074193ad54dfad87b2c244a533cd73512..2f0f79f5e9c9c0d2de146646aafba36dd6f18a61 100644 --- a/lib_dec/ivas_lfe_dec.c +++ b/lib_dec/ivas_lfe_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_lfe_plc.c b/lib_dec/ivas_lfe_plc.c index cd96467109a52714907928ca3a4d7eef3d186675..39637f33b91a0fe4e0b5e98d189a6ed60cc60b75 100644 --- a/lib_dec/ivas_lfe_plc.c +++ b/lib_dec/ivas_lfe_plc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_ls_custom_dec.c b/lib_dec/ivas_ls_custom_dec.c index 71e8bd22970bd5acdceab5d816d67fae42bf6f76..54548fdff993d187fbb2328a2915c3e9c2c49d41 100644 --- a/lib_dec/ivas_ls_custom_dec.c +++ b/lib_dec/ivas_ls_custom_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index f6b98a37fc6fc56e2afaaa9157eb9ef48521f0f8..d539b8b3f56ecc5e22aa8196cbea3dd90474a816 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other @@ -1233,7 +1233,12 @@ static int16_t decode_lfe_to_total_energy_ratio( ivas_error ivas_masa_dec_reconfigure( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ uint16_t *nSamplesRendered, /* o : number of samples flushed from the previous frame (JBM) */ - int16_t *data /* o : output synthesis signal */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ + void *data /* o : output synthesis signal */ +#else + int16_t *data /* o : output synthesis signal */ +#endif ) { int16_t n, tmp, num_bits; @@ -1243,6 +1248,9 @@ ivas_error ivas_masa_dec_reconfigure( int32_t ivas_total_brate, last_ivas_total_brate; int16_t numCldfbAnalyses_old, numCldfbSyntheses_old; ivas_error error; +#ifdef SPLIT_REND_WITH_HEAD_ROT + int16_t pos_idx; +#endif int32_t ism_total_brate; error = IVAS_ERR_OK; @@ -1262,8 +1270,13 @@ ivas_error ivas_masa_dec_reconfigure( /* renderer might have changed, reselect */ ivas_renderer_select( st_ivas ); +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( st_ivas->renderer_type == RENDERER_DIRAC && st_ivas->hDirACRend == NULL ) || + ( ( st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) && st_ivas->hDiracDecBin[0] == NULL ) ) +#else if ( ( st_ivas->renderer_type == RENDERER_DIRAC && st_ivas->hDirACRend == NULL ) || ( ( st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) && st_ivas->hDiracDecBin == NULL ) ) +#endif { /* init a new DirAC dec */ if ( ( error = ivas_dirac_dec_config( st_ivas, DIRAC_OPEN ) ) != IVAS_ERR_OK ) @@ -1276,7 +1289,11 @@ ivas_error ivas_masa_dec_reconfigure( if ( st_ivas->hDirAC != NULL ) { /* close all unnecessary parametric decoding and rendering */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + ivas_dirac_dec_close_binaural_data( st_ivas->hDiracDecBin ); +#else ivas_dirac_dec_close_binaural_data( &st_ivas->hDiracDecBin ); +#endif ivas_dirac_rend_close( &( st_ivas->hDirACRend ) ); ivas_spat_hSpatParamRendCom_close( &( st_ivas->hSpatParamRendCom ) ); ivas_dirac_dec_close( &( st_ivas->hDirAC ) ); @@ -1300,7 +1317,11 @@ ivas_error ivas_masa_dec_reconfigure( sts[0]->bit_stream = bit_stream + num_bits; num_bits += (int16_t) ( st_ivas->hSCE[sce_id]->element_brate / FRAMES_PER_SEC ); +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) && st_ivas->hDiracDecBin[0] != NULL ) +#else if ( ( st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) && st_ivas->hDiracDecBin != NULL ) +#endif { if ( ( error = ivas_dirac_dec_config( st_ivas, DIRAC_RECONFIGURE ) ) != IVAS_ERR_OK ) { @@ -1326,7 +1347,11 @@ ivas_error ivas_masa_dec_reconfigure( { st_ivas->hCPE[cpe_id]->nchan_out = 1; +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( st_ivas->renderer_type == RENDERER_DIRAC && st_ivas->hDirACRend != NULL ) || ( ( st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) && st_ivas->hDiracDecBin[0] != NULL ) ) +#else if ( ( st_ivas->renderer_type == RENDERER_DIRAC && st_ivas->hDirACRend != NULL ) || ( ( st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) && st_ivas->hDiracDecBin != NULL ) ) +#endif { if ( ( error = ivas_dirac_dec_config( st_ivas, DIRAC_RECONFIGURE ) ) != IVAS_ERR_OK ) { @@ -1338,7 +1363,11 @@ ivas_error ivas_masa_dec_reconfigure( { st_ivas->hCPE[cpe_id]->nchan_out = CPE_CHANNELS; +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( st_ivas->renderer_type == RENDERER_DIRAC && st_ivas->hDirACRend != NULL ) || ( ( st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) && st_ivas->hDiracDecBin[0] != NULL ) ) +#else if ( ( st_ivas->renderer_type == RENDERER_DIRAC && st_ivas->hDirACRend != NULL ) || ( ( st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) && st_ivas->hDiracDecBin != NULL ) ) +#endif { if ( ( error = ivas_dirac_dec_config( st_ivas, DIRAC_RECONFIGURE ) ) != IVAS_ERR_OK ) { @@ -1348,20 +1377,39 @@ ivas_error ivas_masa_dec_reconfigure( } } +#ifdef SPLIT_REND_WITH_HEAD_ROT + for ( pos_idx = 0; pos_idx < MAX_HEAD_ROT_POSES; pos_idx++ ) + { + if ( st_ivas->hDiracDecBin[pos_idx] != NULL ) + { + /* regularization factor is bitrate-dependent */ + st_ivas->hDiracDecBin[pos_idx]->reqularizationFactor = configure_reqularization_factor( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate ); + } + } +#else if ( st_ivas->hDiracDecBin != NULL ) { /* regularization factor is bitrate-dependent */ st_ivas->hDiracDecBin->reqularizationFactor = configure_reqularization_factor( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate ); } +#endif if ( st_ivas->ivas_format == MASA_FORMAT && st_ivas->last_ivas_format == MASA_FORMAT ) /* note: switching within OMASA is handled in ivas_omasa_dec_config() */ { /*-----------------------------------------------------------------* * TD Decorrelator *-----------------------------------------------------------------*/ +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( st_ivas->hDiracDecBin[0] != NULL ) +#else if ( st_ivas->hDiracDecBin != NULL ) +#endif { +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( error = ivas_td_decorr_reconfig_dec( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hDecoderConfig->output_Fs, &( st_ivas->hDiracDecBin[0]->hTdDecorr ), &( st_ivas->hDiracDecBin[0]->useTdDecorr ) ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_td_decorr_reconfig_dec( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hDecoderConfig->output_Fs, &( st_ivas->hDiracDecBin->hTdDecorr ), &( st_ivas->hDiracDecBin->useTdDecorr ) ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -1434,7 +1482,11 @@ ivas_error ivas_masa_dec_reconfigure( { if ( n_samples_granularity < st_ivas->hTcBuffer->n_samples_granularity ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( error = ivas_jbm_dec_flush_renderer( st_ivas, n_samples_granularity, st_ivas->renderer_type, st_ivas->intern_config, &st_ivas->hIntSetup, MC_MODE_NONE, ISM_MASA_MODE_DISC, nSamplesRendered, pcm_resolution, data ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_jbm_dec_flush_renderer( st_ivas, n_samples_granularity, st_ivas->renderer_type, st_ivas->intern_config, &st_ivas->hIntSetup, MC_MODE_NONE, ISM_MASA_MODE_DISC, nSamplesRendered, data ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -1517,7 +1569,11 @@ void ivas_spar_param_to_masa_param_mapping( hSpatParamRendCom = st_ivas->hSpatParamRendCom; hSpatParamRendCom->numParametricDirections = 1; hSpatParamRendCom->numSimultaneousDirections = 1; +#ifdef SPLIT_REND_WITH_HEAD_ROT + hDiffuseDist = st_ivas->hDiracDecBin[0]->hDiffuseDist; +#else hDiffuseDist = st_ivas->hDiracDecBin->hDiffuseDist; +#endif nchan_transport = st_ivas->nchan_transport; band_grouping = hDirAC->band_grouping; hSpar = st_ivas->hSpar; diff --git a/lib_dec/ivas_mc_param_dec.c b/lib_dec/ivas_mc_param_dec.c index 5a321314ba1089ee3e839162149eaff764793301..2aa16e61a8a6479818290374e1a8ad01c3e261c0 100644 --- a/lib_dec/ivas_mc_param_dec.c +++ b/lib_dec/ivas_mc_param_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other @@ -122,7 +122,6 @@ ivas_error ivas_param_mc_dec_open( { int16_t k, nchan_transport; PARAM_MC_DEC_HANDLE hParamMC; - IVAS_OUTPUT_SETUP hTransportSetup; int16_t nchan_out_transport; int16_t nchan_out_cov; float proto_matrix[MAX_CICP_CHANNELS * PARAM_MC_MAX_TRANSPORT_CHANS]; @@ -154,8 +153,6 @@ ivas_error ivas_param_mc_dec_open( output_Fs = st_ivas->hDecoderConfig->output_Fs; output_config = st_ivas->hDecoderConfig->output_config; ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; - - hTransportSetup = st_ivas->hTransSetup; mc_ls_setup = ivas_mc_map_output_config_to_mc_ls_setup( st_ivas->transport_config ); nchan_out_transport = st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe; hParamMC->hoa_encoder = NULL; @@ -236,7 +233,7 @@ ivas_error ivas_param_mc_dec_open( hParamMC->num_freq_bands = (int16_t) ( output_Fs * INV_CLDFB_BANDWIDTH + 0.5f ); hParamMC->max_band_energy_compensation = hParamMC->num_freq_bands; - ivas_param_mc_metadata_open( mc_ls_setup, hTransportSetup.index_lfe[0], ivas_total_brate, hParamMC->hMetadataPMC ); + ivas_param_mc_metadata_open( mc_ls_setup, ivas_total_brate, hParamMC->hMetadataPMC ); /* init arrays for quantized parameters */ if ( ( hParamMC->icc_q = (float *) malloc( hParamMC->hMetadataPMC->num_parameter_bands * hParamMC->hMetadataPMC->icc_mapping_conf->icc_map_size_lfe * sizeof( float ) ) ) == NULL ) @@ -559,7 +556,6 @@ ivas_error ivas_param_mc_dec_reconfig( { int16_t k, nchan_transport; PARAM_MC_DEC_HANDLE hParamMC; - IVAS_OUTPUT_SETUP hTransportSetup; int16_t nchan_out_transport; int16_t nchan_out_cov; float proto_matrix[MAX_CICP_CHANNELS * PARAM_MC_MAX_TRANSPORT_CHANS]; @@ -588,8 +584,6 @@ ivas_error ivas_param_mc_dec_reconfig( output_Fs = st_ivas->hDecoderConfig->output_Fs; ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; - - hTransportSetup = st_ivas->hTransSetup; mc_ls_setup = ivas_mc_map_output_config_to_mc_ls_setup( st_ivas->transport_config ); nchan_out_transport = st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe; @@ -633,23 +627,9 @@ ivas_error ivas_param_mc_dec_reconfig( hParamMC->num_freq_bands = (int16_t) ( output_Fs * INV_CLDFB_BANDWIDTH + 0.5f ); hParamMC->max_band_energy_compensation = hParamMC->num_freq_bands; - /* deallocate the full icc map, gets newly allocated in the metadata open function */ - - for ( k = 0; k < 2; k++ ) - { -#ifdef DEBUGGING - assert( hParamMC->hMetadataPMC->icc_map_full[k] != NULL ); -#endif - if ( hParamMC->hMetadataPMC->icc_map_full[k] != NULL ) - { - free( hParamMC->hMetadataPMC->icc_map_full[k] ); - hParamMC->hMetadataPMC->icc_map_full[k] = NULL; - } - } - mvs2s( hParamMC->band_grouping, band_grouping_old, hParamMC->hMetadataPMC->num_parameter_bands + 1 ); - ivas_param_mc_metadata_open( mc_ls_setup, hTransportSetup.index_lfe[0], ivas_total_brate, hParamMC->hMetadataPMC ); + ivas_param_mc_metadata_open( mc_ls_setup, ivas_total_brate, hParamMC->hMetadataPMC ); /* Band Grouping */ if ( hParamMC->hMetadataPMC->num_parameter_bands == 20 ) @@ -1106,8 +1086,6 @@ void ivas_param_mc_dec_close( /* parameter decoding */ if ( hParamMC->hMetadataPMC != NULL ) { - ivas_param_mc_metadata_close( hParamMC->hMetadataPMC ); - free( hParamMC->hMetadataPMC ); hParamMC->hMetadataPMC = NULL; } @@ -1223,7 +1201,7 @@ void ivas_param_mc_dec_read_BS( int16_t num_lfe_bands; int16_t num_param_bands; int16_t metadata_bit_pos; - int16_t i, j, k, l; + int16_t i, j, k; int16_t icc_map_size; int16_t icc_map_size_wo_lfe; int16_t ild_map_size; @@ -1312,65 +1290,6 @@ void ivas_param_mc_dec_read_BS( num_lfe_bands = 0; } - if ( hMetadataPMC->flag_use_adaptive_icc_map == 1 ) - { - int16_t icc_mapping_index[PARAM_MC_SZ_ICC_MAP]; - - k = 0; - for ( i = 0; i < hMetadataPMC->icc_map_size_full - 1; i++ ) - { - if ( bit_buffer[bit_pos++] == 1 ) - { - icc_mapping_index[k++] = i; - } - } - - /* last one is always C/LFE */ - icc_mapping_index[k] = hMetadataPMC->icc_map_size_full - 1; - - /* save icc mapping of the previous frame*/ - /* build icc map for the current frame */ - for ( k = 0; k < icc_map_size; k++ ) - { - hMetadataPMC->icc_mapping[param_frame_idx][k][0] = hMetadataPMC->icc_map_full[0][icc_mapping_index[k]]; - hMetadataPMC->icc_mapping[param_frame_idx][k][1] = hMetadataPMC->icc_map_full[1][icc_mapping_index[k]]; - } - - if ( hMetadataPMC->bAttackPresent ) - { - for ( k = 0; k < icc_map_size; k++ ) - { - for ( l = 0; l < PARAM_MC_PARAMETER_FRAMES; l++ ) - { - hMetadataPMC->icc_mapping[l][k][0] = hMetadataPMC->icc_map_full[0][icc_mapping_index[k]]; - hMetadataPMC->icc_mapping[l][k][1] = hMetadataPMC->icc_map_full[1][icc_mapping_index[k]]; - } - } - } - else - { - for ( k = 0; k < icc_map_size; k++ ) - { - hMetadataPMC->icc_mapping[hMetadataPMC->param_frame_idx][k][0] = hMetadataPMC->icc_map_full[0][icc_mapping_index[k]]; - hMetadataPMC->icc_mapping[hMetadataPMC->param_frame_idx][k][1] = hMetadataPMC->icc_map_full[1][icc_mapping_index[k]]; - } - } - } - else - { - if ( hMetadataPMC->bAttackPresent ) - { - for ( l = 0; l < PARAM_MC_PARAMETER_FRAMES; l++ ) - { - ivas_param_mc_default_icc_map( hMetadataPMC->icc_mapping_conf, hMetadataPMC->icc_mapping[param_frame_idx] ); - } - } - else - { - ivas_param_mc_default_icc_map( hMetadataPMC->icc_mapping_conf, hMetadataPMC->icc_mapping[hMetadataPMC->param_frame_idx] ); - } - } - ivas_param_mc_bs_decode_parameter_values( bit_buffer, &bit_pos, bits_to_copy, &st->BER_detect, hMetadataPMC, &hMetadataPMC->icc_coding, icc_map_size_wo_lfe, icc_map_size, num_lfe_bands, band_step, num_param_bands, hParamMC->icc_q ); if ( !st->BER_detect ) @@ -1739,8 +1658,13 @@ void ivas_param_mc_dec_render( /*CLDFB*/ float Cldfb_RealBuffer[MAX_INTERN_CHANNELS][PARAM_MC_MAX_NSLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; float Cldfb_ImagBuffer[MAX_INTERN_CHANNELS][PARAM_MC_MAX_NSLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; +#ifdef SPLIT_REND_WITH_HEAD_ROT + float Cldfb_RealBuffer_Binaural[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][PARAM_MC_MAX_NSLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; + float Cldfb_ImagBuffer_Binaural[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][PARAM_MC_MAX_NSLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; +#else float Cldfb_RealBuffer_Binaural[BINAURAL_CHANNELS][PARAM_MC_MAX_NSLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; float Cldfb_ImagBuffer_Binaural[BINAURAL_CHANNELS][PARAM_MC_MAX_NSLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; +#endif /*Decorrelator*/ float onset_filter[MAX_CICP_CHANNELS * CLDFB_NO_CHANNELS_MAX]; /* format converter */ @@ -1936,12 +1860,52 @@ void ivas_param_mc_dec_render( if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + { + if ( st_ivas->hSplitBinRend->hCldfbDataOut != NULL ) + { + for ( slot_idx = 0; slot_idx < MAX_PARAM_SPATIAL_SUBFRAMES; slot_idx++ ) + { + for ( ch = 0; ch < ( st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe ); ch++ ) + { + mvr2r( Cldfb_RealBuffer[ch][slot_idx], st_ivas->hSplitBinRend->hCldfbDataOut->Cldfb_RealBuffer[ch][slot_idx_start + slot_idx], hParamMC->num_freq_bands ); + mvr2r( Cldfb_ImagBuffer[ch][slot_idx], st_ivas->hSplitBinRend->hCldfbDataOut->Cldfb_ImagBuffer[ch][slot_idx_start + slot_idx], hParamMC->num_freq_bands ); + } + } + st_ivas->hSplitBinRend->hCldfbDataOut->config = st_ivas->hIntSetup.output_config; + } + } +#endif ivas_binRenderer( st_ivas->hBinRenderer, +#ifdef SPLIT_REND_WITH_HEAD_ROT + ( st_ivas->hSplitBinRend == NULL ) ? NULL : &st_ivas->hSplitBinRend->splitrend.multiBinPoseData, +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG + NULL, +#endif +#endif st_ivas->hCombinedOrientationData, hParamMC->subframe_nbslots[subframe_idx], Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer, Cldfb_ImagBuffer ); +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + { + int16_t pos_idx; + for ( pos_idx = 0; pos_idx < st_ivas->hBinRenderer->numPoses; pos_idx++ ) + { + for ( slot_idx = 0; slot_idx < hParamMC->subframe_nbslots[subframe_idx]; slot_idx++ ) + { + for ( ch = 0; ch < nchan_out_cldfb; ch++ ) + { + mvr2r( Cldfb_RealBuffer_Binaural[pos_idx][ch][slot_idx], st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_RealBuffer_Binaural[( pos_idx * BINAURAL_CHANNELS ) + ch][slot_idx_start + slot_idx], hParamMC->num_freq_bands ); + mvr2r( Cldfb_ImagBuffer_Binaural[pos_idx][ch][slot_idx], st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural[( pos_idx * BINAURAL_CHANNELS ) + ch][slot_idx_start + slot_idx], hParamMC->num_freq_bands ); + } + } + } + } +#endif /* update combined orientation access index */ ivas_combined_orientation_update_index( st_ivas->hCombinedOrientationData, hParamMC->num_freq_bands * hParamMC->subframe_nbslots[subframe_idx] ); @@ -1965,8 +1929,13 @@ void ivas_param_mc_dec_render( { if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT + RealBuffer[i] = Cldfb_RealBuffer_Binaural[0][ch][i]; + ImagBuffer[i] = Cldfb_ImagBuffer_Binaural[0][ch][i]; +#else RealBuffer[i] = Cldfb_RealBuffer_Binaural[ch][i]; ImagBuffer[i] = Cldfb_ImagBuffer_Binaural[ch][i]; +#endif } else { @@ -2939,11 +2908,9 @@ static void ivas_param_mc_dequantize_cov( int16_t l; float *Cyp; float ap; - int16_t param_frame_idx; const PARAM_MC_ILD_MAPPING *h_ild_mapping; float Cy_state_int[MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS]; - param_frame_idx = hParamMC->hMetadataPMC->param_frame_idx; set_zero( Nrqq, MAX_OUTPUT_CHANNELS ); h_ild_mapping = hParamMC->hMetadataPMC->ild_mapping_conf; @@ -2984,8 +2951,8 @@ static void ivas_param_mc_dequantize_cov( /* replace some estimated ICCs with transmitted values */ for ( k = 0; k < hParamMC->hMetadataPMC->icc_mapping_conf->icc_map_size_lfe; k++ ) { - Cy_state_int[hParamMC->hMetadataPMC->icc_mapping[param_frame_idx][k][0] + nY_int * hParamMC->hMetadataPMC->icc_mapping[param_frame_idx][k][1]] = icc_q[k]; - Cy_state_int[hParamMC->hMetadataPMC->icc_mapping[param_frame_idx][k][1] + nY_int * hParamMC->hMetadataPMC->icc_mapping[param_frame_idx][k][0]] = icc_q[k]; + Cy_state_int[hParamMC->hMetadataPMC->icc_mapping_conf->icc_mapping[k][0] + nY_int * hParamMC->hMetadataPMC->icc_mapping_conf->icc_mapping[k][1]] = icc_q[k]; + Cy_state_int[hParamMC->hMetadataPMC->icc_mapping_conf->icc_mapping[k][1] + nY_int * hParamMC->hMetadataPMC->icc_mapping_conf->icc_mapping[k][0]] = icc_q[k]; } if ( param_band_index >= PARAM_MC_MAX_BAND_LFE || !hParamMC->hMetadataPMC->lfe_on ) diff --git a/lib_dec/ivas_mc_paramupmix_dec.c b/lib_dec/ivas_mc_paramupmix_dec.c index b91f88425e6bc4f26135975ba14eb6004ffe8f41..e5f3fe87d18493ad27d856d013a73e66d6ae07da 100644 --- a/lib_dec/ivas_mc_paramupmix_dec.c +++ b/lib_dec/ivas_mc_paramupmix_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other @@ -245,10 +245,10 @@ void ivas_mc_paramupmix_dec_render( mvr2r( hMCParamUpmix->beta_prev[ch], hMCParamUpmix->beta_sf[ch], IVAS_MAX_NUM_BANDS ); } + for ( subframe_idx = first_sf; subframe_idx < last_sf; subframe_idx++ ) { int16_t n_samples_sf = slot_size * st_ivas->hTcBuffer->subframe_nbslots[subframe_idx]; - ivas_mc_paramupmix_dec_sf( st_ivas, output_f_local ); for ( ch = 0; ch < min( MAX_OUTPUT_CHANNELS, ivas_get_nchan_buffers_dec( st_ivas, -1, -1 ) ); ch++ ) @@ -628,7 +628,6 @@ static void ps_pred_process_sf( return; } - static void ivas_mc_paramupmix_dec_sf( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ float *output_f[MAX_OUTPUT_CHANNELS] /* i/o: synthesized core-coder transport channels */ @@ -644,13 +643,22 @@ static void ivas_mc_paramupmix_dec_sf( int16_t subframeIdx, idx_in, maxBand; float Cldfb_RealBuffer_subfr[MAX_INTERN_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; float Cldfb_ImagBuffer_subfr[MAX_INTERN_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; +#ifdef SPLIT_REND_WITH_HEAD_ROT + float Cldfb_RealBuffer_Binaural[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; + float Cldfb_ImagBuffer_Binaural[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; + int16_t slot_index_start; +#else float Cldfb_RealBuffer_Binaural[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; float Cldfb_ImagBuffer_Binaural[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; +#endif hMCParamUpmix = st_ivas->hMCParamUpmix; assert( hMCParamUpmix ); push_wmops( "ivas_mc_paramupmix_dec_sf" ); +#ifdef SPLIT_REND_WITH_HEAD_ROT + slot_index_start = st_ivas->hTcBuffer->slots_rendered; +#endif for ( i = 0; i < MC_PARAMUPMIX_COMBINATIONS; i++ ) { pPcm_temp[2 * i] = output_f[i + 4]; /* un-decorrelated */ @@ -741,15 +749,54 @@ static void ivas_mc_paramupmix_dec_sf( } } +#ifdef SPLIT_REND_WITH_HEAD_ROT + /*LFE handling for split rendering cases*/ + if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + { + if ( st_ivas->hSplitBinRend->hCldfbDataOut != NULL ) + { + for ( slot_idx = 0; slot_idx < st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->subframes_rendered]; slot_idx++ ) + { + for ( ch = 0; ch < ( st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe ); ch++ ) + { + mvr2r( Cldfb_RealBuffer_subfr[ch][slot_idx], st_ivas->hSplitBinRend->hCldfbDataOut->Cldfb_RealBuffer[ch][slot_index_start + slot_idx], maxBand ); + mvr2r( Cldfb_ImagBuffer_subfr[ch][slot_idx], st_ivas->hSplitBinRend->hCldfbDataOut->Cldfb_ImagBuffer[ch][slot_index_start + slot_idx], maxBand ); + } + } + + st_ivas->hSplitBinRend->hCldfbDataOut->config = st_ivas->hIntSetup.output_config; + } + } +#endif /* Implement binaural rendering */ ivas_binRenderer( st_ivas->hBinRenderer, +#ifdef SPLIT_REND_WITH_HEAD_ROT + ( st_ivas->hSplitBinRend == NULL ) ? NULL : &st_ivas->hSplitBinRend->splitrend.multiBinPoseData, +#endif st_ivas->hCombinedOrientationData, st_ivas->hTcBuffer->subframe_nbslots[subframeIdx], Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer_subfr, Cldfb_ImagBuffer_subfr ); +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + { + int16_t pos_idx; + for ( pos_idx = 0; pos_idx < st_ivas->hBinRenderer->numPoses; pos_idx++ ) + { + for ( slot_idx = 0; slot_idx < st_ivas->hTcBuffer->subframe_nbslots[subframeIdx]; slot_idx++ ) + { + for ( ch = 0; ch < st_ivas->hDecoderConfig->nchan_out; ch++ ) + { + mvr2r( Cldfb_RealBuffer_Binaural[pos_idx][ch][slot_idx], st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_RealBuffer_Binaural[( pos_idx * BINAURAL_CHANNELS ) + ch][slot_index_start + slot_idx], maxBand ); + mvr2r( Cldfb_ImagBuffer_Binaural[pos_idx][ch][slot_idx], st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural[( pos_idx * BINAURAL_CHANNELS ) + ch][slot_index_start + slot_idx], maxBand ); + } + } + } + } +#endif /* Implement CLDFB synthesis */ for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) @@ -759,8 +806,13 @@ static void ivas_mc_paramupmix_dec_sf( for ( slot_idx = 0; slot_idx < st_ivas->hTcBuffer->subframe_nbslots[subframeIdx]; slot_idx++ ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT + RealBuffer[slot_idx] = Cldfb_RealBuffer_Binaural[0][ch][slot_idx]; + ImagBuffer[slot_idx] = Cldfb_ImagBuffer_Binaural[0][ch][slot_idx]; +#else RealBuffer[slot_idx] = Cldfb_RealBuffer_Binaural[ch][slot_idx]; ImagBuffer[slot_idx] = Cldfb_ImagBuffer_Binaural[ch][slot_idx]; +#endif } cldfbSynthesis( RealBuffer, ImagBuffer, &( output_f[ch][0] ), maxBand * st_ivas->hTcBuffer->subframe_nbslots[subframeIdx], st_ivas->cldfbSynDec[ch] ); diff --git a/lib_dec/ivas_mcmasa_dec.c b/lib_dec/ivas_mcmasa_dec.c index 14db85a0005de148502925f36ae1ea99b0fb8200..7b200bd2210e156bb72e6de49f9a2d36b5d9796a 100644 --- a/lib_dec/ivas_mcmasa_dec.c +++ b/lib_dec/ivas_mcmasa_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_mct_core_dec.c b/lib_dec/ivas_mct_core_dec.c index faffe1a1b4b92b4209a4e48436deb69a5aa22f12..47d519a1be7a4757694240378b4d04256cb56090 100644 --- a/lib_dec/ivas_mct_core_dec.c +++ b/lib_dec/ivas_mct_core_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index 55750ed95da209cc83804cd2f34866826c97c3e1..4028b7f44ae56a65939b380f54b36d0267cd8a52 100644 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other @@ -54,7 +54,11 @@ * Local function prototypes *-----------------------------------------------------------------------*/ +#ifdef SPLIT_REND_WITH_HEAD_ROT +static ivas_error ivas_mc_dec_reconfig( Decoder_Struct *st_ivas, uint16_t *nSamplesRendered, const PCM_RESOLUTION pcm_resolution, void *data ); +#else static ivas_error ivas_mc_dec_reconfig( Decoder_Struct *st_ivas, uint16_t *nSamplesRendered, int16_t *data ); +#endif /*--------------------------------------------------------------------------* @@ -83,6 +87,9 @@ ivas_error ivas_mct_dec( STnsData tnsData[MCT_MAX_BLOCKS][CPE_CHANNELS][NB_DIV]; Decoder_State **sts; float synth[CPE_CHANNELS][L_FRAME_PLUS]; +#ifdef NONBE_FIX_1087_OOB_SBA_DTX_RS + float *p_output_orig[2]; +#endif float output_lfe_ch[L_FRAME48k]; int32_t ivas_total_brate; ivas_error error; @@ -144,6 +151,18 @@ ivas_error ivas_mct_dec( /* MCT side bits decoder */ ivas_mct_side_bits( hMCT, st_ivas->hCPE, nCPE, st_ivas->hCPE[0]->hCoreCoder[0], st_ivas->bfi, st_ivas->hCPE[0]->hCoreCoder[0]->bit_stream, ivas_total_brate, nb_bits_metadata ); +#ifdef NONBE_FIX_1087_OOB_SBA_DTX_RS + /* in case of switching from an SID frame (with ACELP core) to MCT, buffer of L_FRAME_PLUS samples is needed -> use synth[] as a temporary buffer */ + if ( st_ivas->hCPE[0]->hCoreCoder[0]->last_core == ACELP_CORE ) + { + for ( n = 0; n < CPE_CHANNELS; n++ ) + { + p_output_orig[n] = output[n]; + output[n] = synth[n]; + } + } +#endif + for ( cpe_id = 0; cpe_id < nCPE; cpe_id++ ) { st_ivas->hCPE[cpe_id]->hCoreCoder[0]->BER_detect |= st_ivas->BER_detect; @@ -228,6 +247,17 @@ ivas_error ivas_mct_dec( ivas_mdct_core_reconstruct( hCPE, x, synth, fUseTns[cpe_id], 1 ); +#ifdef NONBE_FIX_1087_OOB_SBA_DTX_RS + /* set pointers back */ + if ( cpe_id == 0 && st_ivas->hCPE[0]->hCoreCoder[0]->last_core == ACELP_CORE ) + { + for ( n = 0; n < CPE_CHANNELS; n++ ) + { + output[n] = p_output_orig[n]; + } + } + +#endif /*----------------------------------------------------------------* * CoreCoder Post-processing and updates *----------------------------------------------------------------*/ @@ -645,7 +675,12 @@ ivas_error ivas_mc_dec_config( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const int16_t idx, /* i : LS config. index */ uint16_t *nSamplesRendered, /* o : samples flushed from last frame (JBM) */ - int16_t *data /* o : output synthesis signal */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ + void *data /* o : output synthesis signal */ +#else + int16_t *data /* o : output synthesis signal */ +#endif ) { AUDIO_CONFIG signaled_config; @@ -673,7 +708,11 @@ ivas_error ivas_mc_dec_config( { if ( st_ivas->hDecoderConfig->last_ivas_total_brate != st_ivas->hDecoderConfig->ivas_total_brate || st_ivas->transport_config != signaled_config || last_mc_mode != st_ivas->mc_mode ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( error = ivas_mc_dec_reconfig( st_ivas, nSamplesRendered, pcm_resolution, data ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_mc_dec_reconfig( st_ivas, nSamplesRendered, data ) ) != IVAS_ERR_OK ) +#endif { return error; @@ -697,7 +736,12 @@ ivas_error ivas_mc_dec_config( static ivas_error ivas_mc_dec_reconfig( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ uint16_t *nSamplesRendered, /* o : number of samples flushed from the last frame (JBM) */ - int16_t *data /* o : output synthesis signal */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ + void *data /* o : output synthesis signal */ +#else + int16_t *data /* o : output synthesis signal */ +#endif ) { int16_t nchan_transport_old, nSCE_old, nCPE_old, sba_dirac_stereo_flag_old, nchan_hp20_old; @@ -778,7 +822,11 @@ static ivas_error ivas_mc_dec_reconfig( tc_granularity_new = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, st_ivas->ivas_format, st_ivas->mc_mode, st_ivas->hDecoderConfig->output_Fs ); if ( tc_granularity_new < st_ivas->hTcBuffer->n_samples_granularity ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( error = ivas_jbm_dec_flush_renderer( st_ivas, tc_granularity_new, renderer_type_old, intern_config_old, &hIntSetupOld, last_mc_mode, ISM_MODE_NONE, nSamplesRendered, pcm_resolution, data ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_jbm_dec_flush_renderer( st_ivas, tc_granularity_new, renderer_type_old, intern_config_old, &hIntSetupOld, last_mc_mode, ISM_MODE_NONE, nSamplesRendered, data ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -1157,7 +1205,11 @@ static ivas_error ivas_mc_dec_reconfig( output_config = st_ivas->hDecoderConfig->output_config; /* binaural renderers*/ - if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) + if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB +#ifdef SPLIT_REND_WITH_HEAD_ROT + || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM +#endif + ) { /* remove unneeded binaural renderers */ if ( st_ivas->hBinRenderer != NULL && ( st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV && st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV_ROOM ) ) @@ -1165,10 +1217,18 @@ static ivas_error ivas_mc_dec_reconfig( ivas_binRenderer_close( &st_ivas->hBinRenderer ); } +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( st_ivas->hCrendWrapper != NULL ) && ( st_ivas->hCrendWrapper->hCrend[0] != NULL ) && ( st_ivas->renderer_type != RENDERER_BINAURAL_MIXER_CONV && st_ivas->renderer_type != RENDERER_BINAURAL_MIXER_CONV_ROOM && ( st_ivas->renderer_type != RENDERER_BINAURAL_OBJECTS_TD || st_ivas->hIntSetup.output_config != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) ) +#else if ( ( st_ivas->hCrendWrapper != NULL ) && ( st_ivas->hCrendWrapper->hCrend != NULL ) && ( st_ivas->renderer_type != RENDERER_BINAURAL_MIXER_CONV && st_ivas->renderer_type != RENDERER_BINAURAL_MIXER_CONV_ROOM && ( st_ivas->renderer_type != RENDERER_BINAURAL_OBJECTS_TD || st_ivas->hIntSetup.output_config != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) ) +#endif { +#ifdef SPLIT_REND_WITH_HEAD_ROT + ivas_rend_closeCrend( &( st_ivas->hCrendWrapper ), ( st_ivas->hSplitBinRend == NULL ) ? 1 : st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ); +#else ivas_rend_closeCrend( &( st_ivas->hCrendWrapper ) ); +#endif } if ( st_ivas->hBinRendererTd != NULL && ( st_ivas->renderer_type != RENDERER_BINAURAL_OBJECTS_TD ) ) @@ -1184,11 +1244,19 @@ static ivas_error ivas_mc_dec_reconfig( #endif } +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( st_ivas->hDiracDecBin[0] != NULL ) +#else if ( st_ivas->hDiracDecBin != NULL ) +#endif { if ( st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC && st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC_ROOM && st_ivas->renderer_type != RENDERER_STEREO_PARAMETRIC ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT + ivas_dirac_dec_close_binaural_data( st_ivas->hDiracDecBin ); +#else ivas_dirac_dec_close_binaural_data( &st_ivas->hDiracDecBin ); +#endif } } @@ -1209,22 +1277,39 @@ static ivas_error ivas_mc_dec_reconfig( if ( st_ivas->hIntSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( error = ivas_rend_initCrendWrapper( &st_ivas->hCrendWrapper, 1 ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_rend_initCrendWrapper( &st_ivas->hCrendWrapper ) ) != IVAS_ERR_OK ) +#endif { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend Wrapper\n" ); } +#ifdef SPLIT_REND_WITH_HEAD_ROT + st_ivas->hCrendWrapper->hCrend[0] = NULL; + st_ivas->hCrendWrapper->hHrtfCrend = NULL; + if ( ( st_ivas->hCrendWrapper->hCrend[0] = (CREND_HANDLE) malloc( sizeof( CREND_DATA ) ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend\n" ); + } +#else st_ivas->hCrendWrapper->hCrend = NULL; st_ivas->hCrendWrapper->hHrtfCrend = NULL; if ( ( st_ivas->hCrendWrapper->hCrend = (CREND_HANDLE) malloc( sizeof( CREND_DATA ) ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend\n" ); } +#endif } } else if ( st_ivas->hCrendWrapper == NULL && ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs, ( st_ivas->hSplitBinRend == NULL ) ? 1 : st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) +#endif { return error; } diff --git a/lib_dec/ivas_mct_dec_mct.c b/lib_dec/ivas_mct_dec_mct.c index 881c35119cdbaef891ac4f8adde4cef504241a95..07f7a9cc3643b76c4b621dc19d1bd90441fc3e62 100644 --- a/lib_dec/ivas_mct_dec_mct.c +++ b/lib_dec/ivas_mct_dec_mct.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_mdct_core_dec.c b/lib_dec/ivas_mdct_core_dec.c index 36ff917fa23f32fb17ef2aa392617e45211731ed..27d468a21bdd624360299638507eede940c4bd0a 100644 --- a/lib_dec/ivas_mdct_core_dec.c +++ b/lib_dec/ivas_mdct_core_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_mono_dmx_renderer.c b/lib_dec/ivas_mono_dmx_renderer.c index 0936209639d9388e7910919011740336be89bf28..6610e4620fe88398592d3cc0eacbde14d0389b37 100644 --- a/lib_dec/ivas_mono_dmx_renderer.c +++ b/lib_dec/ivas_mono_dmx_renderer.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_objectRenderer_internal.c b/lib_dec/ivas_objectRenderer_internal.c index 6e25ef7e5357d940162fc1a3e4e02f10ff23ddab..fc3e420ac4c47880cb443d09a30246bffd4a7f79 100644 --- a/lib_dec/ivas_objectRenderer_internal.c +++ b/lib_dec/ivas_objectRenderer_internal.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other @@ -266,3 +266,145 @@ ivas_error ivas_td_binaural_renderer_sf( return IVAS_ERR_OK; } + + +#ifdef SPLIT_REND_WITH_HEAD_ROT +/*---------------------------------------------------------------------* + * ivas_td_binaural_renderer_sf_splitBinaural() + * + * Render to multiple binaural pairs based on relative head positions for split rendering. + *---------------------------------------------------------------------*/ + +ivas_error ivas_td_binaural_renderer_sf_splitBinaural( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + float *output[], /* i/o: SCE channels / Binaural synthesis */ + const int16_t nSamplesRendered /* i : number of samples to render */ +) +{ + int16_t i; + int16_t pos_idx; + IVAS_QUATERNION originalHeadRot[MAX_PARAM_SPATIAL_SUBFRAMES]; + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData; + BINAURAL_TD_OBJECT_RENDERER_HANDLE origTdRendHandle; + ivas_error error; + int16_t original_subframes_rendered; + int16_t original_slots_rendered; + float *p_bin_output[BINAURAL_CHANNELS]; + float output_local[MAX_OUTPUT_CHANNELS][L_FRAME48k]; + + push_wmops( "ivas_td_binaural_renderer_sf_splitBinaural" ); + pMultiBinPoseData = &st_ivas->hSplitBinRend->splitrend.multiBinPoseData; + + /* If not yet allocated, open additional instances of TD renderer */ + for ( i = 0; i < pMultiBinPoseData->num_poses - 1; ++i ) + { + if ( st_ivas->hTdRendHandles[i] != NULL ) + { + continue; + } + + if ( ( error = ivas_td_binaural_open_unwrap( &st_ivas->hHrtfTD, + st_ivas->hDecoderConfig->output_Fs, + st_ivas->nchan_transport, + st_ivas->ivas_format, + st_ivas->transport_config, + st_ivas->hRenderConfig->directivity, + st_ivas->hTransSetup, + &st_ivas->hTdRendHandles[i], + &st_ivas->binaural_latency_ns ) ) != IVAS_ERR_OK ) + { + return error; + } + } + + /* Save current head positions */ + for ( i = 0; i < st_ivas->hCombinedOrientationData->num_subframes; ++i ) + { + originalHeadRot[i] = st_ivas->hCombinedOrientationData->Quaternions[i]; + } + + original_subframes_rendered = st_ivas->hTcBuffer->subframes_rendered; + original_slots_rendered = st_ivas->hTcBuffer->slots_rendered; + origTdRendHandle = st_ivas->hBinRendererTd; + + for ( pos_idx = 0; pos_idx < pMultiBinPoseData->num_poses; pos_idx++ ) + { + /* Update head positions */ + if ( pos_idx != 0 ) + { + for ( i = 0; i < st_ivas->hCombinedOrientationData->num_subframes; ++i ) + { + if ( originalHeadRot[i].w == -3.0f ) + { + st_ivas->hCombinedOrientationData->Quaternions[i].w = -3.0f; + st_ivas->hCombinedOrientationData->Quaternions[i].x = originalHeadRot[i].x + pMultiBinPoseData->relative_head_poses[pos_idx][0]; + st_ivas->hCombinedOrientationData->Quaternions[i].y = originalHeadRot[i].y + pMultiBinPoseData->relative_head_poses[pos_idx][1]; + st_ivas->hCombinedOrientationData->Quaternions[i].z = originalHeadRot[i].z + pMultiBinPoseData->relative_head_poses[pos_idx][2]; + } + else + { + st_ivas->hCombinedOrientationData->Quaternions[i].w = -3.0f; + + Quat2EulerDegree( originalHeadRot[i], /* TODO tmu : fix bug with ordering*/ + &st_ivas->hCombinedOrientationData->Quaternions[i].z, + &st_ivas->hCombinedOrientationData->Quaternions[i].y, + &st_ivas->hCombinedOrientationData->Quaternions[i].x ); + + st_ivas->hCombinedOrientationData->Quaternions[i].x += pMultiBinPoseData->relative_head_poses[pos_idx][0]; + st_ivas->hCombinedOrientationData->Quaternions[i].y += pMultiBinPoseData->relative_head_poses[pos_idx][1]; + st_ivas->hCombinedOrientationData->Quaternions[i].z += pMultiBinPoseData->relative_head_poses[pos_idx][2]; + } + } + } + + /* set output channels */ + for ( i = 0; i < BINAURAL_CHANNELS; i++ ) + { + p_bin_output[i] = output_local[pos_idx * BINAURAL_CHANNELS + i]; + } + st_ivas->hTcBuffer->subframes_rendered = original_subframes_rendered; + st_ivas->hTcBuffer->slots_rendered = original_slots_rendered; + + /* update combined orientation access index */ + ivas_combined_orientation_set_to_start_index( st_ivas->hCombinedOrientationData ); + + /* Render */ + if ( pos_idx != 0 ) + { + st_ivas->hBinRendererTd = st_ivas->hTdRendHandles[pos_idx - 1]; + } + + if ( ( error = ivas_td_binaural_renderer_sf( st_ivas, p_bin_output, nSamplesRendered ) ) != IVAS_ERR_OK ) + { + return error; + } + + if ( st_ivas->ivas_format == MC_FORMAT ) + { + float *p_tc[MAX_TRANSPORT_CHANNELS]; + for ( i = 0; i < st_ivas->nchan_transport; i++ ) + { + p_tc[i] = st_ivas->hTcBuffer->tc[i] + st_ivas->hTcBuffer->n_samples_rendered; + } + ivas_binaural_add_LFE( st_ivas, nSamplesRendered, p_tc, p_bin_output ); + } + } + + for ( i = 0; i < pMultiBinPoseData->num_poses * BINAURAL_CHANNELS; i++ ) + { + mvr2r( output_local[i], output[i], nSamplesRendered ); + } + + /* Restore original head rotation */ + for ( i = 0; i < st_ivas->hCombinedOrientationData->num_subframes; ++i ) + { + st_ivas->hCombinedOrientationData->Quaternions[i] = originalHeadRot[i]; + } + + /* restore original td renderer handle */ + st_ivas->hBinRendererTd = origTdRendHandle; + + pop_wmops(); + return IVAS_ERR_OK; +} +#endif diff --git a/lib_dec/ivas_omasa_dec.c b/lib_dec/ivas_omasa_dec.c index 0c26dc605b5af0d277c2e10c2ded8a4d5021ebc7..f56944a0798d220906c34e5989c2c21220a7a6dd 100644 --- a/lib_dec/ivas_omasa_dec.c +++ b/lib_dec/ivas_omasa_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other @@ -152,7 +152,12 @@ void ivas_omasa_data_close( ivas_error ivas_omasa_dec_config( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ uint16_t *nSamplesRendered, /* o : number of samples flushed from the previous frame (JBM) */ - int16_t *data /* o : output synthesis signal */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ + void *data /* o : output synthesis signal */ +#else + int16_t *data /* o : output synthesis signal */ +#endif ) { int16_t k, sce_id, nSCE_old, nchan_hp20_old, numCldfbAnalyses_old, numCldfbSyntheses_old, n_MD; @@ -196,7 +201,11 @@ ivas_error ivas_omasa_dec_config( { st_ivas->hCPE[0]->nchan_out = 1; } +#ifdef SPLIT_REND_WITH_HEAD_ROT + else if ( ( error = ivas_masa_dec_reconfigure( st_ivas, nSamplesRendered, pcm_resolution, data ) ) != IVAS_ERR_OK ) +#else else if ( ( error = ivas_masa_dec_reconfigure( st_ivas, nSamplesRendered, data ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -376,9 +385,17 @@ ivas_error ivas_omasa_dec_config( * TD Decorrelator *-----------------------------------------------------------------*/ +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( st_ivas->hDiracDecBin[0] != NULL ) +#else if ( st_ivas->hDiracDecBin != NULL ) +#endif { +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( error = ivas_td_decorr_reconfig_dec( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hDecoderConfig->output_Fs, &( st_ivas->hDiracDecBin[0]->hTdDecorr ), &( st_ivas->hDiracDecBin[0]->useTdDecorr ) ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_td_decorr_reconfig_dec( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hDecoderConfig->output_Fs, &( st_ivas->hDiracDecBin->hTdDecorr ), &( st_ivas->hDiracDecBin->useTdDecorr ) ) ) != IVAS_ERR_OK ) +#endif { return error; @@ -635,6 +652,11 @@ ivas_error ivas_omasa_dirac_td_binaural_jbm( ivas_error error; float *p_sepobj[MAX_NUM_OBJECTS]; float *tc_local[MAX_TRANSPORT_CHANNELS]; +#ifdef SPLIT_REND_WITH_HEAD_ROT + int16_t slot_idx_start; + + slot_idx_start = st_ivas->hSpatParamRendCom->slots_rendered; +#endif for ( n = 0; n < MAX_NUM_OBJECTS; n++ ) { @@ -661,15 +683,56 @@ ivas_error ivas_omasa_dirac_td_binaural_jbm( /* reset combined orientation access index before calling the td renderer */ ivas_combined_orientation_set_to_start_index( st_ivas->hCombinedOrientationData ); - if ( ( error = ivas_td_binaural_renderer_sf( st_ivas, p_sepobj, *nSamplesRendered ) ) != IVAS_ERR_OK ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { - return error; + int16_t slot_idx, num_cldfb_bands, nchan_transport_orig, cldfb_slots; + float Cldfb_RealBuffer[CLDFB_NO_CHANNELS_MAX]; + float Cldfb_ImagBuffer[CLDFB_NO_CHANNELS_MAX]; + float *p_rend_obj[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS]; /* [8 * 2] */ + + for ( n = 0; n < st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses * BINAURAL_CHANNELS; n++ ) + { + p_rend_obj[n] = &output_f[n][0]; + } + + num_cldfb_bands = st_ivas->hSplitBinRend->splitrend.hCldfbHandles->cldfbAna[0]->no_channels; + nchan_transport_orig = st_ivas->nchan_transport; + st_ivas->nchan_transport = st_ivas->nchan_ism; + + if ( ( error = ivas_td_binaural_renderer_sf_splitBinaural( st_ivas, p_rend_obj, *nSamplesRendered ) ) != IVAS_ERR_OK ) /* objects are read from st_ivas->hTcBuffer->tc[2..(1+n_isms)] */ + { + return error; + } + st_ivas->nchan_transport = nchan_transport_orig; + cldfb_slots = *nSamplesRendered / num_cldfb_bands; + + for ( n = 0; n < st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses * BINAURAL_CHANNELS; ++n ) + { + for ( slot_idx = 0; slot_idx < cldfb_slots; slot_idx++ ) + { + cldfbAnalysis_ts( &( p_rend_obj[n][num_cldfb_bands * slot_idx] ), Cldfb_RealBuffer, Cldfb_ImagBuffer, num_cldfb_bands, st_ivas->hSplitBinRend->splitrend.hCldfbHandles->cldfbAna[n] ); + + /* note: this intentionally differs from OSBA by: no scaling by 0.5 */ + v_add( st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_RealBuffer_Binaural[n][slot_idx_start + slot_idx], Cldfb_RealBuffer, st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_RealBuffer_Binaural[n][slot_idx_start + slot_idx], num_cldfb_bands ); + v_add( st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural[n][slot_idx_start + slot_idx], Cldfb_ImagBuffer, st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural[n][slot_idx_start + slot_idx], num_cldfb_bands ); + } + } } - for ( n = 0; n < BINAURAL_CHANNELS; n++ ) + else { - v_add( output_f[n], p_sepobj[n], output_f[n], *nSamplesRendered ); +#endif + if ( ( error = ivas_td_binaural_renderer_sf( st_ivas, p_sepobj, *nSamplesRendered ) ) != IVAS_ERR_OK ) + { + return error; + } + for ( n = 0; n < BINAURAL_CHANNELS; n++ ) + { + v_add( output_f[n], p_sepobj[n], output_f[n], *nSamplesRendered ); + } +#ifdef SPLIT_REND_WITH_HEAD_ROT } - +#endif return IVAS_ERR_OK; } diff --git a/lib_dec/ivas_osba_dec.c b/lib_dec/ivas_osba_dec.c index e88f68b0d6bc58aecf6d03551b975e2cbe985c68..2800aedd849a0ff115c417b23010c648b07dfdd9 100644 --- a/lib_dec/ivas_osba_dec.c +++ b/lib_dec/ivas_osba_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other @@ -137,6 +137,11 @@ ivas_error ivas_osba_dirac_td_binaural_jbm( float output_separated_objects[BINAURAL_CHANNELS][L_FRAME48k]; // VE2SB: TBV float *p_sepobj[BINAURAL_CHANNELS]; int16_t channel_offset; +#ifdef SPLIT_REND_WITH_HEAD_ROT + int16_t slot_idx_start; + + slot_idx_start = st_ivas->hSpatParamRendCom->slots_rendered; +#endif for ( n = 0; n < BINAURAL_CHANNELS; n++ ) { @@ -151,19 +156,63 @@ ivas_error ivas_osba_dirac_td_binaural_jbm( } - if ( ( error = ivas_td_binaural_renderer_sf( st_ivas, p_sepobj, *nSamplesRendered ) ) != IVAS_ERR_OK ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { - return error; - } + int16_t slot_idx, num_cldfb_bands, b, nchan_transport_orig; + int16_t cldfb_slots; + float Cldfb_RealBuffer[CLDFB_NO_CHANNELS_MAX]; + float Cldfb_ImagBuffer[CLDFB_NO_CHANNELS_MAX]; + + num_cldfb_bands = st_ivas->hSplitBinRend->splitrend.hCldfbHandles->cldfbAna[0]->no_channels; + nchan_transport_orig = st_ivas->nchan_transport; + st_ivas->nchan_transport = st_ivas->nchan_ism; + if ( ( error = ivas_td_binaural_renderer_sf_splitBinaural( st_ivas, output_f, *nSamplesRendered ) ) != IVAS_ERR_OK ) + { + return error; + } + st_ivas->nchan_transport = nchan_transport_orig; + cldfb_slots = *nSamplesRendered / num_cldfb_bands; - for ( n = 0; n < BINAURAL_CHANNELS; n++ ) + for ( n = 0; n < st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses * BINAURAL_CHANNELS; ++n ) + { + for ( slot_idx = 0; slot_idx < cldfb_slots; slot_idx++ ) + { + cldfbAnalysis_ts( &( output_f[n][num_cldfb_bands * slot_idx] ), Cldfb_RealBuffer, Cldfb_ImagBuffer, num_cldfb_bands, st_ivas->hSplitBinRend->splitrend.hCldfbHandles->cldfbAna[n] ); + + for ( b = 0; b < num_cldfb_bands; b++ ) + { + st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_RealBuffer_Binaural[n][slot_idx_start + slot_idx][b] = + ( 0.5f * st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_RealBuffer_Binaural[n][slot_idx_start + slot_idx][b] ) + + ( 0.5f * Cldfb_RealBuffer[b] ); + + st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural[n][slot_idx_start + slot_idx][b] = + ( 0.5f * st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural[n][slot_idx_start + slot_idx][b] ) + + ( 0.5f * Cldfb_ImagBuffer[b] ); + } + } + } + } + else { - int16_t i; - for ( i = 0; i < nSamplesAsked; i++ ) +#endif + if ( ( error = ivas_td_binaural_renderer_sf( st_ivas, p_sepobj, *nSamplesRendered ) ) != IVAS_ERR_OK ) + { + return error; + } + + for ( n = 0; n < BINAURAL_CHANNELS; n++ ) { - output_f[n][i] = 0.5f * output_f[channel_offset + n][i] + 0.5f * p_sepobj[n][i]; + int16_t i; + for ( i = 0; i < nSamplesAsked; i++ ) + { + output_f[n][i] = 0.5f * output_f[channel_offset + n][i] + 0.5f * p_sepobj[n][i]; + } } + +#ifdef SPLIT_REND_WITH_HEAD_ROT } +#endif return IVAS_ERR_OK; } diff --git a/lib_dec/ivas_out_setup_conversion.c b/lib_dec/ivas_out_setup_conversion.c index d622e4cf1e94152282f096692b2bf1371810b1b8..fd0ebfb3613c97f5408a7cfbd4ccd0fb79f3cd92 100644 --- a/lib_dec/ivas_out_setup_conversion.c +++ b/lib_dec/ivas_out_setup_conversion.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_output_config.c b/lib_dec/ivas_output_config.c index dcca65963accc47cbf92440eab4917820d93ab32..5b86725b14f997dc174547f340f381f8089a0689 100644 --- a/lib_dec/ivas_output_config.c +++ b/lib_dec/ivas_output_config.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other @@ -76,13 +76,21 @@ void ivas_renderer_select( st_ivas->hCombinedOrientationData->shd_rot_max_order = -1; } - if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) + if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB +#ifdef SPLIT_REND_WITH_HEAD_ROT + || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM +#endif + ) { if ( st_ivas->ivas_format == ISM_FORMAT ) { if ( st_ivas->ism_mode == ISM_MODE_PARAM ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) +#else if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL ) +#endif { *renderer_type = RENDERER_BINAURAL_PARAMETRIC; } @@ -93,7 +101,11 @@ void ivas_renderer_select( } else /* ISM_MODE_DISC */ { - if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) + if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB +#ifdef SPLIT_REND_WITH_HEAD_ROT + || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM +#endif + ) { #ifdef DEBUGGING if ( st_ivas->hDecoderConfig->force_rend == FORCE_CLDFB_RENDERER ) @@ -128,7 +140,11 @@ void ivas_renderer_select( { *internal_config = output_config; +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) +#else if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL ) +#endif { *renderer_type = RENDERER_BINAURAL_PARAMETRIC; } @@ -141,7 +157,11 @@ void ivas_renderer_select( { *internal_config = IVAS_AUDIO_CONFIG_HOA3; - if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) + if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB +#ifdef SPLIT_REND_WITH_HEAD_ROT + || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM +#endif + ) { *renderer_type = RENDERER_BINAURAL_FASTCONV; } @@ -183,7 +203,11 @@ void ivas_renderer_select( { *internal_config = output_config; +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) +#else if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL ) +#endif { *renderer_type = RENDERER_BINAURAL_PARAMETRIC; } @@ -196,7 +220,11 @@ void ivas_renderer_select( { *internal_config = transport_config; +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) +#else if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) +#endif { #ifdef DEBUGGING if ( ( ( ( st_ivas->transport_config == IVAS_AUDIO_CONFIG_5_1 || st_ivas->transport_config == IVAS_AUDIO_CONFIG_7_1 ) && ( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation ) ) || ( st_ivas->hDecoderConfig->force_rend == FORCE_TD_RENDERER ) ) && ( st_ivas->mc_mode == MC_MODE_MCT || st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) && !( st_ivas->hDecoderConfig->force_rend == FORCE_CLDFB_RENDERER ) ) diff --git a/lib_dec/ivas_pca_dec.c b/lib_dec/ivas_pca_dec.c index fc7c214b11a3e36a82b16203ac0e4b3d7dcee2fd..aed3c10aa67571ec4446cab5efdac4b894d1b70c 100644 --- a/lib_dec/ivas_pca_dec.c +++ b/lib_dec/ivas_pca_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_post_proc.c b/lib_dec/ivas_post_proc.c index 0ec2fa24a2b39c945287bb5648fad7f504d9f8a7..6cb6e3ec22505ae4f7dc851c87c6567913399f82 100644 --- a/lib_dec/ivas_post_proc.c +++ b/lib_dec/ivas_post_proc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_qmetadata_dec.c b/lib_dec/ivas_qmetadata_dec.c index 414bef715a83e6d808cddf389f7037988b89b124..9e66d0ace83e4d1ba3fb0871486c833e2623062e 100644 --- a/lib_dec/ivas_qmetadata_dec.c +++ b/lib_dec/ivas_qmetadata_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other @@ -40,6 +40,9 @@ #include "ivas_rom_dec.h" #include "wmc_auto.h" #include "prot.h" +#ifdef NONBE_1319_M2R_PRECISION_ALIGN +#include "basop_settings.h" +#endif /*-----------------------------------------------------------------------* * Local function prototypes @@ -97,8 +100,11 @@ static int16_t read_surround_coherence_hr( uint16_t *bitstream, int16_t *p_bit_p static int16_t read_coherence_data_hr_512( uint16_t *bitstream, int16_t *p_bit_pos, IVAS_QMETADATA *hQMetaData, const int16_t idx_dir, const int16_t nbits_coh ); +#ifdef NONBE_1319_M2R_PRECISION_ALIGN +static void read_stream_dct_coeffs_omasa( int16_t *q_idx, Word32 *q_dct_data_fx, const int16_t len_stream, uint16_t *bit_stream, int16_t *index, const int16_t first_line ); +#else static void read_stream_dct_coeffs_omasa( int16_t *q_idx, float *q_dct_data, const int16_t len_stream, uint16_t *bit_stream, int16_t *index, const int16_t first_line ); - +#endif /*-----------------------------------------------------------------------* * Global function definitions @@ -4247,7 +4253,11 @@ static void decode_combined_index( static void read_stream_dct_coeffs_omasa( int16_t *q_idx, +#ifdef NONBE_1319_M2R_PRECISION_ALIGN + Word32 *q_dct_data_fx, +#else float *q_dct_data, +#endif const int16_t len_stream, uint16_t *bit_stream, int16_t *index, @@ -4255,11 +4265,16 @@ static void read_stream_dct_coeffs_omasa( { int16_t sign, nbits; int16_t i, j, i_min; - +#ifndef NONBE_1319_M2R_PRECISION_ALIGN float step; +#endif int16_t GR1, GR2; - +#ifdef NONBE_1319_M2R_PRECISION_ALIGN + int64_t step_fx; + step_fx = STEP_M2T_FX; +#else step = STEP_M2T; +#endif nbits = 0; sign = 1; if ( first_line == 0 ) @@ -4326,6 +4341,20 @@ static void read_stream_dct_coeffs_omasa( } /* deindex */ +#ifdef NONBE_1319_M2R_PRECISION_ALIGN + q_dct_data_fx[0] = (Word32) ( ( step_fx * q_idx[0] ) >> 6 ); /* Q25 */ + for ( i = 1; i < len_stream; i++ ) + { + if ( ( q_idx[i] & 1 ) == 0 ) + { + q_dct_data_fx[i] = (Word32) ( ( step_fx * ( -q_idx[i] ) ) >> 7 ); /* Q25 */ + } + ELSE + { + q_dct_data_fx[i] = (Word32) ( ( step_fx * ( q_idx[i] + 1 ) ) >> 7 ); /* Q25 */ + } + } +#else q_dct_data[0] = q_idx[0] * step; for ( i = 1; i < len_stream; i++ ) { @@ -4338,7 +4367,7 @@ static void read_stream_dct_coeffs_omasa( q_dct_data[i] = ( ( q_idx[i] + 1 ) >> 1 ) * step; } } - +#endif return; } @@ -4357,11 +4386,18 @@ void ivas_omasa_decode_masa_to_total( { int16_t i, j, k; int16_t q_idx[MAX_PARAM_SPATIAL_SUBFRAMES * MASA_FREQUENCY_BANDS]; +#ifdef NONBE_1319_M2R_PRECISION_ALIGN + Word32 q_dct_data_fx[MAX_PARAM_SPATIAL_SUBFRAMES * MASA_FREQUENCY_BANDS], + dct_data_tmp_fx[MAX_PARAM_SPATIAL_SUBFRAMES * MASA_FREQUENCY_BANDS]; +#else float q_dct_data[MAX_PARAM_SPATIAL_SUBFRAMES * MASA_FREQUENCY_BANDS], dct_data_tmp[MAX_PARAM_SPATIAL_SUBFRAMES * MASA_FREQUENCY_BANDS]; +#endif int16_t n_streams, len_stream; +#ifndef NONBE_1319_M2R_PRECISION_ALIGN #ifdef NON_BE_FIX_BASOP_819_THRESHOLD_MASA2TOTAL int32_t int_tmp; +#endif #endif /* Setup coding parameters */ n_streams = 1; @@ -4375,10 +4411,95 @@ void ivas_omasa_decode_masa_to_total( set_s( q_idx, 0, nbands * nblocks ); for ( i = 0; i < n_streams; i++ ) { - read_stream_dct_coeffs_omasa( &q_idx[i * len_stream], &q_dct_data[i * len_stream], len_stream, bit_stream, index, i == 0 ); + read_stream_dct_coeffs_omasa( &q_idx[i * len_stream], +#ifdef NONBE_1319_M2R_PRECISION_ALIGN + &q_dct_data_fx[i * len_stream], +#else + &q_dct_data[i * len_stream], +#endif + len_stream, bit_stream, index, i == 0 ); } /* inverse DCT2 transform */ +#ifdef NONBE_1319_M2R_PRECISION_ALIGN + SWITCH( len_stream ) + { + case 4: + matrix_product_q30_fx( dct4_fx, nblocks, nblocks, 1, q_dct_data_fx, nblocks, 1, 0, dct_data_tmp_fx ); + mvl2l( dct_data_tmp_fx, q_dct_data_fx, nblocks ); /*Q30*/ + BREAK; + case 5: + matrix_product_q30_fx( dct5_fx, nbands, nbands, 1, q_dct_data_fx, nbands, 1, 0, dct_data_tmp_fx ); + mvl2l( dct_data_tmp_fx, q_dct_data_fx, nbands ); /*Q30*/ + BREAK; + case 8: + matrix_product_q30_fx( dct8_fx, nbands, nbands, 1, q_dct_data_fx, nbands, 1, 0, dct_data_tmp_fx ); + mvl2l( dct_data_tmp_fx, q_dct_data_fx, nbands ); /*Q30*/ + BREAK; + case 12: + matrix_product_q30_fx( dct12_fx, nbands, nbands, 1, q_dct_data_fx, nbands, 1, 0, dct_data_tmp_fx ); + mvl2l( dct_data_tmp_fx, q_dct_data_fx, nbands ); /*Q30*/ + BREAK; + case 20: + matrix_product_fx( dct5_fx, nbands, nbands, 1, q_dct_data_fx, nbands, nblocks, 0, dct_data_tmp_fx ); + matrix_product_q30_fx( dct_data_tmp_fx, nbands, nblocks, 0, dct4_fx, nblocks, nblocks, 0, q_dct_data_fx ); /* reuse of variable*/ + BREAK; + case 32: + matrix_product_fx( dct8_fx, nbands, nbands, 1, q_dct_data_fx, nbands, nblocks, 0, dct_data_tmp_fx ); + matrix_product_q30_fx( dct_data_tmp_fx, nbands, nblocks, 0, dct4_fx, nblocks, nblocks, 0, q_dct_data_fx ); + BREAK; + default: + printf( "Incorrect number of coefficients for OMASA.\n" ); + BREAK; + } + + /* this is to make sure the comparison to the threshold 0.98 will go the same way in */ + /* fixed point and floating point without having to drag the fixed point values to the */ + /* comparison place in the code; 1052266987 is 0.98 in Q30 it is not needed in the fixed point*/ + + for ( i = 0; i < nblocks * nbands; i++ ) + { + if ( q_dct_data_fx[i] >= 1052266987 && q_dct_data_fx[i] < 1052400000 ) + { + q_dct_data_fx[i] = 1052400000; + } + } + + k = 0; + for ( i = 0; i < nblocks; i++ ) + { + for ( j = 0; j < nbands; j++ ) + { + masa_to_total_energy_ratio[i][j] = q_dct_data_fx[k] / (float) ( 1 << 30 ); + masa_to_total_energy_ratio[i][j] = max( 0.0f, masa_to_total_energy_ratio[i][j] ); + masa_to_total_energy_ratio[i][j] = min( 1.0f, masa_to_total_energy_ratio[i][j] ); + k++; + } + } + + if ( nblocks == 1 ) + { + for ( i = 1; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) + { + for ( j = 0; j < nbands; j++ ) + { + masa_to_total_energy_ratio[i][j] = masa_to_total_energy_ratio[0][j]; + } + } + } + + if ( nbands == 1 ) + { + for ( j = 1; j < 5; j++ ) + { + for ( i = 0; i < nblocks; i++ ) + { + masa_to_total_energy_ratio[i][j] = masa_to_total_energy_ratio[i][0]; + } + } + } + +#else switch ( len_stream ) { case 4: @@ -4454,6 +4575,6 @@ void ivas_omasa_decode_masa_to_total( } } } - +#endif return; } diff --git a/lib_dec/ivas_qspherical_dec.c b/lib_dec/ivas_qspherical_dec.c index a3dc21f0c3c12666c62a917f5f80c896c6433c42..0ad09a33d42c53896c8963a553d15b496a53402b 100644 --- a/lib_dec/ivas_qspherical_dec.c +++ b/lib_dec/ivas_qspherical_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_range_uni_dec.c b/lib_dec/ivas_range_uni_dec.c index 6fbbaa5636d4a0c6f38be7afcf589afff04f2640..3b14e03075f566a1cb257a475d73924aabf18448 100644 --- a/lib_dec/ivas_range_uni_dec.c +++ b/lib_dec/ivas_range_uni_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_rom_dec.c b/lib_dec/ivas_rom_dec.c index a48df1ad92d84db51b67dce5f600fb4cfaa4163a..35e5c46876e637321d4e42f0954bed77567ea369 100644 --- a/lib_dec/ivas_rom_dec.c +++ b/lib_dec/ivas_rom_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other @@ -401,8 +401,6 @@ const float dmxmtx_table[BINAURAL_CHANNELS][11] = }; - - /*----------------------------------------------------------------------* * MC ParamUpmix ROM tables *-----------------------------------------------------------------------*/ diff --git a/lib_dec/ivas_rom_dec.h b/lib_dec/ivas_rom_dec.h index 16655db6cd76095380ed403d1abce011b0127e57..82f8ee3cf69a150d8eee86d58650b8530002f69f 100644 --- a/lib_dec/ivas_rom_dec.h +++ b/lib_dec/ivas_rom_dec.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index a0ec2a8880d4b029aa58ece790247a6f54d77345..da3f566beafed3acfac423d7885008a93d517d87 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other @@ -103,7 +103,12 @@ void ivas_sba_set_cna_cng_flag( ivas_error ivas_sba_dec_reconfigure( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ uint16_t *nSamplesFlushed, /* o : number of samples flushed */ - int16_t *data /* o : output synthesis signal */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ + void *data /* o : output synthesis signal */ +#else + int16_t *data /* o : output synthesis signal */ +#endif ) { int16_t nchan_transport_old, nSCE_old, nCPE_old, nchan_hp20_old; @@ -174,7 +179,11 @@ ivas_error ivas_sba_dec_reconfigure( /* copy the logic from ivas_renderer_select(), because calling this function has too many side effects that would affect the flushing */ if ( ivas_get_sba_num_TCs( ivas_total_brate, sba_order_internal ) <= 2 ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) +#else if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL ) +#endif { renderer_type_new = RENDERER_BINAURAL_PARAMETRIC; } @@ -185,7 +194,11 @@ ivas_error ivas_sba_dec_reconfigure( } else { - if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) + if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB +#ifdef SPLIT_REND_WITH_HEAD_ROT + || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM +#endif + ) { renderer_type_new = RENDERER_BINAURAL_FASTCONV; } @@ -211,7 +224,11 @@ ivas_error ivas_sba_dec_reconfigure( st_ivas->sba_analysis_order = sba_analysis_order_old_flush; st_ivas->hDecoderConfig->ivas_total_brate = last_ivas_total_brate; +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( error = ivas_jbm_dec_flush_renderer( st_ivas, granularity_new, st_ivas->renderer_type, st_ivas->intern_config, &st_ivas->hIntSetup, st_ivas->mc_mode, ism_mode_old, nSamplesFlushed, pcm_resolution, data ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_jbm_dec_flush_renderer( st_ivas, granularity_new, st_ivas->renderer_type, st_ivas->intern_config, &st_ivas->hIntSetup, st_ivas->mc_mode, ism_mode_old, nSamplesFlushed, data ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -296,7 +313,11 @@ ivas_error ivas_sba_dec_reconfigure( } } +#ifdef NONBE_FIX_708_OSBA_BR_SWITCHING_CRASH + if ( hSpar->hPCA == NULL && st_ivas->hDecoderConfig->ivas_total_brate == PCA_BRATE && st_ivas->sba_order == 1 && ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) ) +#else if ( hSpar->hPCA == NULL && st_ivas->hDecoderConfig->ivas_total_brate == PCA_BRATE && st_ivas->sba_order == 1 && st_ivas->ivas_format == SBA_FORMAT ) +#endif { if ( ( hSpar->hPCA = (PCA_DEC_STATE *) malloc( sizeof( PCA_DEC_STATE ) ) ) == NULL ) { @@ -541,12 +562,21 @@ ivas_error ivas_sba_dec_reconfigure( * TD Decorrelator *-----------------------------------------------------------------*/ +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( st_ivas->hDiracDecBin[0] != NULL ) + { + if ( ( error = ivas_td_decorr_reconfig_dec( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hDecoderConfig->output_Fs, &( st_ivas->hDiracDecBin[0]->hTdDecorr ), &( st_ivas->hDiracDecBin[0]->useTdDecorr ) ) ) != IVAS_ERR_OK ) + { + return error; + } +#else if ( st_ivas->hDiracDecBin != NULL ) { if ( ( error = ivas_td_decorr_reconfig_dec( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hDecoderConfig->output_Fs, &( st_ivas->hDiracDecBin->hTdDecorr ), &( st_ivas->hDiracDecBin->useTdDecorr ) ) ) != IVAS_ERR_OK ) { return error; } +#endif } /*-----------------------------------------------------------------* @@ -676,7 +706,11 @@ void ivas_sba_dec_digest_tc( ivas_spar_dec_digest_tc( st_ivas, st_ivas->nchan_transport, nCldfbSlots, nSamplesForRendering ); } +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( st_ivas->hDiracDecBin[0] != NULL && st_ivas->hDiracDecBin[0]->useTdDecorr ) +#else if ( st_ivas->hDiracDecBin != NULL && ( st_ivas->hDiracDecBin->useTdDecorr ) ) +#endif { int16_t nSamplesLeftForTD, default_frame; float *decorr_signal[BINAURAL_CHANNELS]; @@ -695,9 +729,17 @@ void ivas_sba_dec_digest_tc( { int16_t nSamplesToDecorr = min( nSamplesLeftForTD, default_frame ); +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( st_ivas->hDiracDecBin[0]->hTdDecorr ) +#else if ( st_ivas->hDiracDecBin->hTdDecorr ) +#endif { +#ifdef SPLIT_REND_WITH_HEAD_ROT + ivas_td_decorr_process( st_ivas->hDiracDecBin[0]->hTdDecorr, p_tc, decorr_signal, nSamplesToDecorr ); +#else ivas_td_decorr_process( st_ivas->hDiracDecBin->hTdDecorr, p_tc, decorr_signal, nSamplesToDecorr ); +#endif } for ( ch_idx = 0; ch_idx < BINAURAL_CHANNELS; ch_idx++ ) diff --git a/lib_dec/ivas_sba_dirac_stereo_dec.c b/lib_dec/ivas_sba_dirac_stereo_dec.c index ae1a2df0c02da95ea3af27629f7a5e9234e49a48..933a16d6a916ab635b294806e2f6304d13c227da 100644 --- a/lib_dec/ivas_sba_dirac_stereo_dec.c +++ b/lib_dec/ivas_sba_dirac_stereo_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_sba_rendering_internal.c b/lib_dec/ivas_sba_rendering_internal.c index 9bb16732d06077c41343683b6faafdbeaceb9147..06410aa54227f90f8d5e241de96b96e8ae22bf14 100644 --- a/lib_dec/ivas_sba_rendering_internal.c +++ b/lib_dec/ivas_sba_rendering_internal.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_sce_dec.c b/lib_dec/ivas_sce_dec.c index 36ec1386ab585b95d6f1855655f2083d093e3b31..148b58487224f538e1ac1b1c4290d4f027233db1 100644 --- a/lib_dec/ivas_sce_dec.c +++ b/lib_dec/ivas_sce_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_sns_dec.c b/lib_dec/ivas_sns_dec.c index 18eb18e788590827fad1eb6f9d71d541d688b962..51dea1afbb45b33e2ce52754c3da78df1889da2e 100644 --- a/lib_dec/ivas_sns_dec.c +++ b/lib_dec/ivas_sns_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index ac64325602698acf246c8db015c4c45ee03ad6af..52ab62eafbcf3d58f8f32e79b10a4be97d4cb785 100644 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other @@ -1804,7 +1804,11 @@ void ivas_spar_dec_upmixer_sf( } else { - if ( ( hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_FOA || !( st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL || st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) && + if ( ( hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_FOA || !( st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL || st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB +#ifdef SPLIT_REND_WITH_HEAD_ROT + || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM +#endif + ) ) && !( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_SBA_MODE_DISC && st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) ) { for ( ts = 0; ts < hSpar->subframe_nbslots[hSpar->subframes_rendered]; ts++ ) diff --git a/lib_dec/ivas_spar_md_dec.c b/lib_dec/ivas_spar_md_dec.c index 8c955660587ac227ad9eb1eac83d2f3e8a386de6..8ea6e8db119aab084d6173a9079cfdf848e2e4d6 100644 --- a/lib_dec/ivas_spar_md_dec.c +++ b/lib_dec/ivas_spar_md_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 9babba30395a22cf0b8ff776e337c1381c80064b..663525161af55f25bbe904ba51d8cb2cd8e4b444 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other @@ -40,6 +40,7 @@ #include "stat_dec.h" #include "ivas_stat_com.h" #include "ivas_stat_rend.h" +#include "isar_stat.h" /*----------------------------------------------------------------------------------* @@ -811,6 +812,7 @@ typedef struct renderer_struct } ISM_RENDERER_DATA, *ISM_RENDERER_HANDLE; +#ifndef SPLIT_REND_WITH_HEAD_ROT /* Fastconv binaural data structure */ typedef struct ivas_binaural_rendering_struct { @@ -834,7 +836,38 @@ typedef struct ivas_binaural_rendering_struct REVERB_STRUCT_HANDLE hReverb; } BINAURAL_RENDERER, *BINAURAL_RENDERER_HANDLE; +#endif + +#ifdef SPLIT_REND_WITH_HEAD_ROT +/*----------------------------------------------------------------------------------* + * IVAS decoder specific ISAR wrapper structures + *----------------------------------------------------------------------------------*/ + +typedef struct +{ + float Cldfb_RealBuffer_Binaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + float Cldfb_ImagBuffer_Binaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + +} ISAR_DEC_SPLIT_REND_MULTI_BIN_CLDFB_DATA, *ISAR_DEC_SPLIT_REND_MULTI_BIN_CLDFB_DATA_HANDLE; +typedef struct +{ + float Cldfb_RealBuffer[MAX_OUTPUT_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + float Cldfb_ImagBuffer[MAX_OUTPUT_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + IVAS_AUDIO_CONFIG config; + +} ISAR_DEC_SPLIT_REND_CLDFB_OUT_DATA, *ISAR_DEC_SPLIT_REND_CLDFB_OUT_DATA_HANDLE; + +typedef struct +{ + ISAR_DEC_SPLIT_REND_MULTI_BIN_CLDFB_DATA_HANDLE hMultiBinCldfbData; /*scratch buffer for frame by frame processing*/ + ISAR_SPLIT_REND_BITS_HANDLE hSplitRendBits; /*scratch buffer for frame by frame processing*/ + SPLIT_REND_WRAPPER splitrend; + ISAR_DEC_SPLIT_REND_CLDFB_OUT_DATA_HANDLE hCldfbDataOut; /*buffer to store cldfb data before binauralization*/ + int16_t numTdSamplesPerChannelCached; + +} ISAR_DEC_SPLIT_REND_WRAPPER, *ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE; +#endif /*----------------------------------------------------------------------------------* * MASA decoder structures @@ -978,6 +1011,9 @@ typedef struct decoder_config_structure int16_t force_rend; /* forced TD/CLDFB binaural renderer (for ISM and MC) */ #endif int16_t Opt_tsm; /* indicates whether time scaling modification is activated */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + int16_t Opt_Limiter; +#endif IVAS_RENDER_FRAMESIZE render_framesize; int16_t Opt_delay_comp; /* flag indicating delay compensation active */ @@ -1058,7 +1094,11 @@ typedef struct Decoder_Struct BINAURAL_RENDERER_HANDLE hBinRenderer; /* fastconv binaural renderer handle */ BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd; /* Time domain binaural object renderer handle */ TDREND_HRFILT_FiltSet_t *hHrtfTD; /* pointer to HRTF data for TD renderer */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + DIRAC_DEC_BIN_HANDLE hDiracDecBin[MAX_HEAD_ROT_POSES]; /* parametric binaural renderer handle */ +#else DIRAC_DEC_BIN_HANDLE hDiracDecBin; /* parametric binaural renderer handle */ +#endif LSSETUP_CONVERSION_HANDLE hLsSetUpConversion; /* MC LS configuration convertion handle */ EFAP_HANDLE hEFAPdata; /* EFAP structure */ VBAP_HANDLE hVBAPdata; /* VBAP structure */ @@ -1082,6 +1122,10 @@ typedef struct Decoder_Struct int16_t flag_omasa_brate; +#ifdef SPLIT_REND_WITH_HEAD_ROT + ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE hSplitBinRend; /* ISAR split binaural rendering handle */ + BINAURAL_TD_OBJECT_RENDERER_HANDLE hTdRendHandles[MAX_HEAD_ROT_POSES - 1]; +#endif /* JBM module */ DECODER_TC_BUFFER_HANDLE hTcBuffer; /* JBM structure */ diff --git a/lib_dec/ivas_stereo_adapt_GR_dec.c b/lib_dec/ivas_stereo_adapt_GR_dec.c index 7e698f6169b94aeb6dc749d1173a614f9456ae27..959dac41f1cb4b3753f7abdd82ac593b579b5de3 100644 --- a/lib_dec/ivas_stereo_adapt_GR_dec.c +++ b/lib_dec/ivas_stereo_adapt_GR_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_stereo_cng_dec.c b/lib_dec/ivas_stereo_cng_dec.c index 5953e93ed3001161c8a0bc8650278c531cdda391..c0d7c02a36c84ea82dd074f7545a6beeb0e0d0c8 100644 --- a/lib_dec/ivas_stereo_cng_dec.c +++ b/lib_dec/ivas_stereo_cng_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_stereo_dft_dec.c b/lib_dec/ivas_stereo_dft_dec.c index d187220da7e0a1a960432f2b201cf156e5421038..4189adec7003d12cd1b979b8d3dab66e8e4202bd 100644 --- a/lib_dec/ivas_stereo_dft_dec.c +++ b/lib_dec/ivas_stereo_dft_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_stereo_dft_dec_dmx.c b/lib_dec/ivas_stereo_dft_dec_dmx.c index e9bb3bc49a0b62f9fd71004b6c3a2fe33c4f5d05..640206ad21063c8aaab3534a7c49260169197a52 100644 --- a/lib_dec/ivas_stereo_dft_dec_dmx.c +++ b/lib_dec/ivas_stereo_dft_dec_dmx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_stereo_dft_plc.c b/lib_dec/ivas_stereo_dft_plc.c index d9a96e73993d8bf88164c0bd166f0310233a1d4b..f7c482763eeef00d63a32d483dc9fd3388701f71 100644 --- a/lib_dec/ivas_stereo_dft_plc.c +++ b/lib_dec/ivas_stereo_dft_plc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_stereo_eclvq_dec.c b/lib_dec/ivas_stereo_eclvq_dec.c index b47c3d219ca768a924ae5590e48882da1a802219..8d07247eb495ed0b74218663453dac1947519dfb 100644 --- a/lib_dec/ivas_stereo_eclvq_dec.c +++ b/lib_dec/ivas_stereo_eclvq_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_stereo_esf_dec.c b/lib_dec/ivas_stereo_esf_dec.c index ff7e810e88e9993e2c374fb4237cd2f4b06878fb..8ebd94025cd9ab074699fe405a4a1948b733fe55 100644 --- a/lib_dec/ivas_stereo_esf_dec.c +++ b/lib_dec/ivas_stereo_esf_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_stereo_ica_dec.c b/lib_dec/ivas_stereo_ica_dec.c index b400dee72cc98b68ee74dc8daa02bf423125f543..38bf9f3b9d0c441b546ffbccc76a988154d18eec 100644 --- a/lib_dec/ivas_stereo_ica_dec.c +++ b/lib_dec/ivas_stereo_ica_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_stereo_icbwe_dec.c b/lib_dec/ivas_stereo_icbwe_dec.c index aad34a87515f5410acb2d2e6b539cf187c2a8d0e..4b4c3f5706a4a8a4e6da4d9468ba05c00292d88e 100644 --- a/lib_dec/ivas_stereo_icbwe_dec.c +++ b/lib_dec/ivas_stereo_icbwe_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_stereo_mdct_core_dec.c b/lib_dec/ivas_stereo_mdct_core_dec.c index 60430fd22f8561d6f48ee7968b986a61e8314243..50aabafeb881d8d3a0b33b2daf299ab2ec63b33b 100644 --- a/lib_dec/ivas_stereo_mdct_core_dec.c +++ b/lib_dec/ivas_stereo_mdct_core_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_stereo_mdct_stereo_dec.c b/lib_dec/ivas_stereo_mdct_stereo_dec.c index 0eda835d87c9cff41107f66bd29aabe1ffe1065f..f41ffb495d13b6c780fbae7e3bb2faf2b37caed5 100644 --- a/lib_dec/ivas_stereo_mdct_stereo_dec.c +++ b/lib_dec/ivas_stereo_mdct_stereo_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_stereo_switching_dec.c b/lib_dec/ivas_stereo_switching_dec.c index d311d7b419eecee299313c9adeabb52f138f60e1..89630fcfa11d1925d2522c3b613897de4c249a7f 100644 --- a/lib_dec/ivas_stereo_switching_dec.c +++ b/lib_dec/ivas_stereo_switching_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_stereo_td_dec.c b/lib_dec/ivas_stereo_td_dec.c index 545d2b0697a7322cbbdf2edc69508842b938f6fc..6d1f8a246bc0298eefd6ad05ef2dece52a5a4e57 100644 --- a/lib_dec/ivas_stereo_td_dec.c +++ b/lib_dec/ivas_stereo_td_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_svd_dec.c b/lib_dec/ivas_svd_dec.c index 459393e3b5eb60f10cafb36eee3e1b8254b47543..85dadbac409c0c3a58d676cfa882dd99e9fae997 100644 --- a/lib_dec/ivas_svd_dec.c +++ b/lib_dec/ivas_svd_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_tcx_core_dec.c b/lib_dec/ivas_tcx_core_dec.c index 71e20a5df75453183d18dbcc4f1613aad8f2a04a..22080cb64ae88646f68151e33f16dbb383cd7fb0 100644 --- a/lib_dec/ivas_tcx_core_dec.c +++ b/lib_dec/ivas_tcx_core_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ivas_td_low_rate_dec.c b/lib_dec/ivas_td_low_rate_dec.c index 8ab266345a45fd3a95ff2820122502f6c87ddaac..8d7af615df4356ba57dd355da1c89fa110f264d2 100644 --- a/lib_dec/ivas_td_low_rate_dec.c +++ b/lib_dec/ivas_td_low_rate_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/jbm_jb4_circularbuffer.c b/lib_dec/jbm_jb4_circularbuffer.c index b1067f96e296c7db3d8ee40a4d4d303ec14f679d..817dcd639accfcecea931416946a8dd4b7cab3eb 100644 --- a/lib_dec/jbm_jb4_circularbuffer.c +++ b/lib_dec/jbm_jb4_circularbuffer.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/jbm_jb4_circularbuffer.h b/lib_dec/jbm_jb4_circularbuffer.h index e14144b329e0984730809384e565db6c9b42b6ae..ea7ef31dc9b8223070e4bcb04a67e2dccf78eb95 100644 --- a/lib_dec/jbm_jb4_circularbuffer.h +++ b/lib_dec/jbm_jb4_circularbuffer.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/jbm_jb4_inputbuffer.c b/lib_dec/jbm_jb4_inputbuffer.c index 32c870bfa577972e36a8233115c7e11908231698..926114c02cff7922fc1dbf55e2e50dd228ef9e1e 100644 --- a/lib_dec/jbm_jb4_inputbuffer.c +++ b/lib_dec/jbm_jb4_inputbuffer.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/jbm_jb4_inputbuffer.h b/lib_dec/jbm_jb4_inputbuffer.h index 6087ecb20717b76c316e2349ca79a0e95131629e..432f9289443f731ee0b55e4d8ba87bb90c93bd97 100644 --- a/lib_dec/jbm_jb4_inputbuffer.h +++ b/lib_dec/jbm_jb4_inputbuffer.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/jbm_jb4_jmf.c b/lib_dec/jbm_jb4_jmf.c index 5d7dfa2e6c055fa2cf284ab88943672e484ddde3..721a6937d0113ef4d7b2d2cf216a4f3843badb22 100644 --- a/lib_dec/jbm_jb4_jmf.c +++ b/lib_dec/jbm_jb4_jmf.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/jbm_jb4_jmf.h b/lib_dec/jbm_jb4_jmf.h index 5efff7cd5ee36c4a91bf2f4cf0dc3b400161f590..28218149a9747a05f05b44749a7f6c92cd4c6ad6 100644 --- a/lib_dec/jbm_jb4_jmf.h +++ b/lib_dec/jbm_jb4_jmf.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/jbm_jb4sb.c b/lib_dec/jbm_jb4sb.c index 755187b640347bd9d61a94b0fdb75342e636c13b..1c6fdf0fcc713df65338fe309531e8d9e734a2ab 100644 --- a/lib_dec/jbm_jb4sb.c +++ b/lib_dec/jbm_jb4sb.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/jbm_jb4sb.h b/lib_dec/jbm_jb4sb.h index b64805f342b62fe26bcaa7d60b28c164c5414894..3d48723495cbf32fe3b37a358acda235a2a6d1af 100644 --- a/lib_dec/jbm_jb4sb.h +++ b/lib_dec/jbm_jb4sb.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/jbm_pcmdsp_apa.c b/lib_dec/jbm_pcmdsp_apa.c index 1242004fc89ac7e41c349e85c29bfe3d237144f0..3305a1e48d6601bb5489d3f38a23c27e0ba00f66 100644 --- a/lib_dec/jbm_pcmdsp_apa.c +++ b/lib_dec/jbm_pcmdsp_apa.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/jbm_pcmdsp_apa.h b/lib_dec/jbm_pcmdsp_apa.h index 74e6b59c6b6c06940d47a3a105ab91bcb792aac5..26c380e38a16e5230fc773e090514e64042d1d92 100644 --- a/lib_dec/jbm_pcmdsp_apa.h +++ b/lib_dec/jbm_pcmdsp_apa.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/jbm_pcmdsp_fifo.c b/lib_dec/jbm_pcmdsp_fifo.c index 7fa6a9f95338e26e4de98824489cf1a3b4464a05..00e5ce7f09635ac1f1205ed34cf8e663e5ec4580 100644 --- a/lib_dec/jbm_pcmdsp_fifo.c +++ b/lib_dec/jbm_pcmdsp_fifo.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/jbm_pcmdsp_fifo.h b/lib_dec/jbm_pcmdsp_fifo.h index 25591ac83eae9bfa5c8dfbcd3d9676f38b0c62e4..1375c5713eba5c5cb67d29f43bfb546d59bc3527 100644 --- a/lib_dec/jbm_pcmdsp_fifo.h +++ b/lib_dec/jbm_pcmdsp_fifo.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/jbm_pcmdsp_similarityestimation.c b/lib_dec/jbm_pcmdsp_similarityestimation.c index c67e71d5919c5dac58f0286a1b320188cb91511a..f4a8a0cb075a648484962c0cefc1b2d0cfbd84c6 100644 --- a/lib_dec/jbm_pcmdsp_similarityestimation.c +++ b/lib_dec/jbm_pcmdsp_similarityestimation.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/jbm_pcmdsp_similarityestimation.h b/lib_dec/jbm_pcmdsp_similarityestimation.h index c944bc1f7be47a64780ec0f1eb8cc0e5527e0659..f300788e0334eb445e4d9f9fe3de8224ddb69eda 100644 --- a/lib_dec/jbm_pcmdsp_similarityestimation.h +++ b/lib_dec/jbm_pcmdsp_similarityestimation.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/jbm_pcmdsp_window.c b/lib_dec/jbm_pcmdsp_window.c index 15f692fb8a1900a5bf15b44a1a3f78d5ef36ebf4..88089bc4b1aaa65d08a539a35944f6eb42743ad5 100644 --- a/lib_dec/jbm_pcmdsp_window.c +++ b/lib_dec/jbm_pcmdsp_window.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/jbm_pcmdsp_window.h b/lib_dec/jbm_pcmdsp_window.h index b11decf11df74c99f9b411a2ad240938f94958f4..c9e3821bd12411988127044af773e98b0e91f447 100644 --- a/lib_dec/jbm_pcmdsp_window.h +++ b/lib_dec/jbm_pcmdsp_window.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/lead_deindexing.c b/lib_dec/lead_deindexing.c index 830daa81207796655b42c6f8125b61e450f42d39..86f96b461d2a8c6b3c932b3d245cd03c698ee697 100644 --- a/lib_dec/lead_deindexing.c +++ b/lib_dec/lead_deindexing.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 059e3b60ff7a587d4a8761f4025ea2f0d1ba66a9..cd44341d9c83e6b4b41236575955ffe2e4a9d40c 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other @@ -37,6 +37,8 @@ #include "ivas_cnst.h" #include "ivas_prot.h" #include "ivas_prot_rend.h" +#include "isar_prot.h" +#include "lib_isar_pre_rend.h" #include "prot.h" #include "jbm_jb4sb.h" #include "jbm_pcmdsp_apa.h" @@ -106,11 +108,27 @@ static ivas_error evs_dec_main( Decoder_Struct *st_ivas, const int16_t nOutSampl static ivas_error input_format_API_to_internal( IVAS_DEC_INPUT_FORMAT input_format, int16_t *bitstream_format_internal, int16_t *sdp_hf_only, const bool is_voip_enabled ); static void init_decoder_config( DECODER_CONFIG_HANDLE hDecoderConfig ); static ivas_error IVAS_DEC_VoIP_reconfigure( IVAS_DEC_HANDLE hIvasDec, const uint16_t nTransportChannels, const uint16_t l_ts ); +#ifdef SPLIT_REND_WITH_HEAD_ROT +static ivas_error IVAS_DEC_Setup( IVAS_DEC_HANDLE hIvasDec, uint16_t *nTcBufferGranularity, uint8_t *nTransportChannels, uint8_t *nOutChannels, uint16_t *nSamplesRendered, const IVAS_DEC_PCM_TYPE pcmType, void *data ); +#else static ivas_error IVAS_DEC_Setup( IVAS_DEC_HANDLE hIvasDec, uint16_t *nTcBufferGranularity, uint8_t *nTransportChannels, uint8_t *nOutChannels, uint16_t *nSamplesRendered, int16_t *data ); +#endif static ivas_error IVAS_DEC_GetTcSamples( IVAS_DEC_HANDLE hIvasDec, float *pcmBuf, int16_t *nOutSamples ); static ivas_error IVAS_DEC_RendererFeedTcSamples( IVAS_DEC_HANDLE hIvasDec, const int16_t nSamplesForRendering, int16_t *nSamplesResidual, float *pcmBuf ); +#ifdef SPLIT_REND_WITH_HEAD_ROT +static ivas_error IVAS_DEC_GetRenderedSamples( IVAS_DEC_HANDLE hIvasDec, const uint16_t nSamplesForRendering, uint16_t *nSamplesRendered, uint16_t *nSamplesAvailableNext, const IVAS_DEC_PCM_TYPE pcmType, void *pcmBuf ); +#else static ivas_error IVAS_DEC_GetRenderedSamples( IVAS_DEC_HANDLE hIvasDec, const uint16_t nSamplesForRendering, uint16_t *nSamplesRendered, uint16_t *nSamplesAvailableNext, int16_t *pcmBuf ); +#endif static ivas_error IVAS_DEC_GetBufferedNumberOfSamples( IVAS_DEC_HANDLE hIvasDec, int16_t *nSamplesBuffered ); +#ifdef SPLIT_REND_WITH_HEAD_ROT +static PCM_RESOLUTION pcm_type_API_to_internal( const IVAS_DEC_PCM_TYPE pcmType ); +static void *pcm_buffer_offset( void *buffer, const IVAS_DEC_PCM_TYPE pcmType, const int32_t offset ); +static ivas_error set_pcm_buffer_to_zero( void *buffer, const IVAS_DEC_PCM_TYPE pcmType, const int16_t nZeroSamples ); +static ivas_error isar_set_split_rend_setup( ISAR_DEC_SPLIT_REND_WRAPPER *hSplitBinRend, const ISAR_SPLIT_REND_CONFIG_DATA *hSplitBinConfig, const COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, ISAR_SPLIT_REND_BITS_DATA *splitRendBits ); +static ivas_error ivas_create_handle_isar( ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE *hSplitBinRend_out ); +static void ivas_destroy_handle_isar( ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE *hSplitBinRend_out ); +#endif static int16_t get_render_frame_size_ms( IVAS_RENDER_FRAMESIZE render_framesize ); @@ -231,6 +249,46 @@ ivas_error IVAS_DEC_Open( return IVAS_ERR_WRONG_PARAMS; } +#ifdef SPLIT_REND_WITH_HEAD_ROT +/*-------------------------------------------------------------------------* + * isar_set_split_rend_setup() + * + * Setup IVAS split rendering + *-------------------------------------------------------------------------*/ + +static ivas_error isar_set_split_rend_setup( + ISAR_DEC_SPLIT_REND_WRAPPER *hSplitBinRend, + const ISAR_SPLIT_REND_CONFIG_DATA *hSplitBinConfig, + const COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, + ISAR_SPLIT_REND_BITS_DATA *splitRendBits /* o : output split rendering bits */ +) +{ + splitRendBits->bits_read = 0; + splitRendBits->bits_written = 0; + splitRendBits->buf_len = ISAR_MAX_SPLIT_REND_BITS_BUFFER_SIZE_IN_BYTES; + splitRendBits->codec = ISAR_SPLIT_REND_CODEC_DEFAULT; + splitRendBits->pose_correction = ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE; + splitRendBits->codec_frame_size_ms = 0; +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + splitRendBits->isar_frame_size_ms = 0; + splitRendBits->lc3plus_highres = 0; +#endif + + if ( ( hSplitBinRend->hMultiBinCldfbData = (ISAR_DEC_SPLIT_REND_MULTI_BIN_CLDFB_DATA_HANDLE) malloc( sizeof( ISAR_DEC_SPLIT_REND_MULTI_BIN_CLDFB_DATA ) ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for split rendering structure" ); + } + + ISAR_PRE_REND_GetMultiBinPoseData( hSplitBinConfig, &hSplitBinRend->splitrend.multiBinPoseData, ( hCombinedOrientationData != NULL ) ? hCombinedOrientationData->sr_pose_pred_axis : DEFAULT_AXIS ); + + if ( hCombinedOrientationData != NULL ) + { + isar_set_split_rend_ht_setup( &hSplitBinRend->splitrend, hCombinedOrientationData->Quaternions, hCombinedOrientationData->Rmat ); + } + + return IVAS_ERR_OK; +} +#endif /*---------------------------------------------------------------------* * init_decoder_config() @@ -253,6 +311,9 @@ static void init_decoder_config( hDecoderConfig->Opt_non_diegetic_pan = 0; hDecoderConfig->non_diegetic_pan_gain = 0; hDecoderConfig->Opt_tsm = 0; +#ifdef SPLIT_REND_WITH_HEAD_ROT + hDecoderConfig->Opt_Limiter = 1; +#endif hDecoderConfig->Opt_delay_comp = 0; hDecoderConfig->Opt_ExternalOrientation = 0; hDecoderConfig->Opt_dpid_on = 0; @@ -284,6 +345,11 @@ void IVAS_DEC_Close( ( *phIvasDec )->hVoIP = NULL; } +#ifdef SPLIT_REND_WITH_HEAD_ROT + /* destroy Split binaural renderer (ISAR) handle */ + ivas_destroy_handle_isar( &( *phIvasDec )->st_ivas->hSplitBinRend ); +#endif + if ( ( *phIvasDec )->st_ivas ) { ivas_destroy_dec( ( *phIvasDec )->st_ivas ); @@ -435,6 +501,12 @@ ivas_error IVAS_DEC_Configure( hDecoderConfig->render_framesize = renderFramesize; } +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + { + hDecoderConfig->Opt_Headrotation = TRUE; + } +#endif /* Set decoder parameters to initial values */ if ( ( error = ivas_init_decoder_front( st_ivas ) ) != IVAS_ERR_OK ) @@ -442,6 +514,17 @@ ivas_error IVAS_DEC_Configure( return error; } +#ifdef SPLIT_REND_WITH_HEAD_ROT + /* create ISAR handle */ + if ( hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + { + if ( ( error = ivas_create_handle_isar( &st_ivas->hSplitBinRend ) ) != IVAS_ERR_OK ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for ISAR handle" ); + } + } +#endif + if ( hIvasDec->mode == IVAS_DEC_MODE_EVS ) { hIvasDec->st_ivas->ivas_format = MONO_FORMAT; @@ -458,6 +541,40 @@ ivas_error IVAS_DEC_Configure( } +#ifdef SPLIT_REND_WITH_HEAD_ROT +/*---------------------------------------------------------------------* + * IVAS_DEC_EnableSplitRendering( ) + * + * Intitialize Split rendering + *---------------------------------------------------------------------*/ + +ivas_error IVAS_DEC_EnableSplitRendering( + IVAS_DEC_HANDLE hIvasDec /* i/o: IVAS decoder handle */ +) +{ + DECODER_CONFIG_HANDLE hDecoderConfig; + ivas_error error; + + error = IVAS_ERR_OK; + + + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + hDecoderConfig = hIvasDec->st_ivas->hDecoderConfig; + + hDecoderConfig->Opt_Headrotation = 1; + hDecoderConfig->render_framesize = IVAS_RENDER_FRAMESIZE_20MS; + + hDecoderConfig->Opt_Limiter = 0; + + return error; +} +#endif + + /*---------------------------------------------------------------------* * get_render_framesize_ms( ) * @@ -489,6 +606,15 @@ ivas_error IVAS_DEC_SetRenderFramesize( hIvasDec->st_ivas->hDecoderConfig->render_framesize = render_framesize; + if ( hIvasDec->st_ivas->hExtOrientationData != NULL ) + { + hIvasDec->st_ivas->hExtOrientationData->num_subframes = (int16_t) render_framesize; + } + if ( hIvasDec->st_ivas->hCombinedOrientationData != NULL ) + { + hIvasDec->st_ivas->hCombinedOrientationData->num_subframes = (int16_t) render_framesize; + } + return IVAS_ERR_OK; } @@ -779,9 +905,14 @@ ivas_error IVAS_DEC_FeedFrame_Serial( ivas_error IVAS_DEC_GetSamples( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ const int16_t nSamplesAsked, /* i : number of samples wanted by the caller */ - int16_t *pcmBuf, /* i/o: buffer for decoded PCM output. The memory must already be allocated and be able to hold the expected number of output samples, based on frame size and number of output channels */ - int16_t *nOutSamples, /* o : number of samples per channel written to output buffer */ - bool *needNewFrame /* o :indication that the decoder needs a new frame */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + const IVAS_DEC_PCM_TYPE pcmType, /* i : type for the decoded PCM resolution */ + void *pcmBuf, /* o : output synthesis signal */ +#else + int16_t *pcmBuf, /* i/o: buffer for decoded PCM output. The memory must already be allocated and be able to hold the expected number of output samples, based on frame size and number of output channels */ +#endif + int16_t *nOutSamples, /* o : number of samples per channel written to output buffer */ + bool *needNewFrame /* o :indication that the decoder needs a new frame */ ) { ivas_error error; @@ -811,6 +942,16 @@ ivas_error IVAS_DEC_GetSamples( return error; } +#ifdef SPLIT_REND_WITH_HEAD_ROT + /*----------------------------------------------------------------* + * Binaural split rendering setup + *----------------------------------------------------------------*/ + + if ( hIvasDec->st_ivas->hCombinedOrientationData != NULL && ( hIvasDec->st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || hIvasDec->st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + { + isar_set_split_rend_ht_setup( &hIvasDec->st_ivas->hSplitBinRend->splitrend, hIvasDec->st_ivas->hCombinedOrientationData->Quaternions, hIvasDec->st_ivas->hCombinedOrientationData->Rmat ); + } +#endif hIvasDec->updateOrientation = false; } @@ -845,7 +986,11 @@ ivas_error IVAS_DEC_GetSamples( { /* setup */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( error = IVAS_DEC_Setup( hIvasDec, &l_ts, &nTransportChannels, &nOutChannels, &nSamplesRendered_loop, pcmType, pcm_buffer_offset( pcmBuf, pcmType, nSamplesRendered * nOutChannels ) ) ) != IVAS_ERR_OK ) +#else if ( ( error = IVAS_DEC_Setup( hIvasDec, &l_ts, &nTransportChannels, &nOutChannels, &nSamplesRendered_loop, pcmBuf + nSamplesRendered * nOutChannels ) ) != IVAS_ERR_OK ) +#endif { return error; @@ -912,7 +1057,11 @@ ivas_error IVAS_DEC_GetSamples( /* render IVAS frames directly to the output buffer */ nSamplesToRender = nSamplesAsked - nSamplesRendered; +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( error = IVAS_DEC_GetRenderedSamples( hIvasDec, nSamplesToRender, &nSamplesRendered_loop, &hIvasDec->nSamplesAvailableNext, pcmType, pcm_buffer_offset( pcmBuf, pcmType, nSamplesRendered * nOutChannels ) ) ) != IVAS_ERR_OK ) +#else if ( ( error = IVAS_DEC_GetRenderedSamples( hIvasDec, nSamplesToRender, &nSamplesRendered_loop, &hIvasDec->nSamplesAvailableNext, pcmBuf + nSamplesRendered * nOutChannels ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -937,6 +1086,202 @@ ivas_error IVAS_DEC_GetSamples( } +#ifdef SPLIT_REND_WITH_HEAD_ROT +/*---------------------------------------------------------------------* + * IVAS_DEC_GetSplitBinauralBitstream( ) + * + * + *---------------------------------------------------------------------*/ + +ivas_error +IVAS_DEC_GetSplitBinauralBitstream( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + void *pcmBuf_out, /* o : output synthesis signal for BINAURAL_SPLIT_PCM */ + ISAR_SPLIT_REND_BITS_DATA *splitRendBits, /* o : output split rendering bits */ + int16_t *nOutSamples, /* o : number of samples per channel written to output buffer */ + bool *needNewFrame /* o : indication that the decoder needs a new frame */ +) +{ + Decoder_Struct *st_ivas; + AUDIO_CONFIG output_config; + int32_t output_Fs; + float *pOutput[BINAURAL_CHANNELS * MAX_HEAD_ROT_POSES]; + float output[BINAURAL_CHANNELS * MAX_HEAD_ROT_POSES][L_FRAME48k]; + float pcmBuf[BINAURAL_CHANNELS * MAX_HEAD_ROT_POSES * L_FRAME48k]; + float Cldfb_RealBuffer_Binaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + float Cldfb_ImagBuffer_Binaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + int16_t numSamplesPerChannelToDecode; + int16_t i, j; + ivas_error error; + ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE hSplitBinRend; + int16_t max_band; + int16_t pcm_out_flag; + int16_t td_input; + int16_t numPoses; + int16_t slots_rendered, slots_rendered_new; + int16_t ro_md_flag; + IVAS_QUATERNION Quaternion; + + error = IVAS_ERR_OK; + st_ivas = hIvasDec->st_ivas; + output_config = st_ivas->hDecoderConfig->output_config; + output_Fs = st_ivas->hDecoderConfig->output_Fs; + numSamplesPerChannelToDecode = (int16_t) ( output_Fs / FRAMES_PER_SEC ); + + *needNewFrame = false; + hSplitBinRend = st_ivas->hSplitBinRend; + + if ( ( error = isar_set_split_rend_setup( hSplitBinRend, &st_ivas->hRenderConfig->split_rend_config, st_ivas->hCombinedOrientationData, splitRendBits ) ) != IVAS_ERR_OK ) + { + return error; + } + + numPoses = hSplitBinRend->splitrend.multiBinPoseData.num_poses; + + if ( st_ivas->hDecoderConfig->render_framesize != IVAS_RENDER_FRAMESIZE_20MS && + ( hIvasDec->st_ivas->hRenderConfig->split_rend_config.poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE || + hIvasDec->st_ivas->hRenderConfig->split_rend_config.dof == 0 ) ) + { + numSamplesPerChannelToDecode = (int16_t) ( output_Fs / FRAMES_PER_SEC / MAX_PARAM_SPATIAL_SUBFRAMES ); + numSamplesPerChannelToDecode *= (int16_t) st_ivas->hDecoderConfig->render_framesize; + } + + if ( IVAS_DEC_is_split_rendering_enabled( hIvasDec ) == 0 ) + { + return IVAS_ERR_WRONG_PARAMS; + } + + if ( st_ivas->hTcBuffer == NULL || hIvasDec->hasBeenFedFrame ) + { + slots_rendered = 0; + } + else + { + /* this is needed for OMASA-DISC, because the td-rend granularity is 240 samples at 48kHz, leading to wrong slot count. */ + if ( st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) + { + slots_rendered = st_ivas->hTcBuffer->n_samples_rendered / NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); + } + else + { + slots_rendered = st_ivas->hTcBuffer->n_samples_rendered / st_ivas->hTcBuffer->n_samples_granularity; + } + } + + + /* Decode and render */ + if ( ( error = IVAS_DEC_GetSamples( hIvasDec, numSamplesPerChannelToDecode, IVAS_DEC_PCM_FLOAT, pcmBuf, nOutSamples, needNewFrame ) ) != IVAS_ERR_OK ) + { + return error; + } + + /* change buffer layout */ + for ( i = 0; i < numSamplesPerChannelToDecode; ++i ) + { + for ( j = 0; j < BINAURAL_CHANNELS * numPoses; ++j ) + { + output[j][i] = pcmBuf[i * BINAURAL_CHANNELS * numPoses + j]; + } + } + for ( i = 0; i < BINAURAL_CHANNELS * MAX_HEAD_ROT_POSES; ++i ) + { + pOutput[i] = output[i]; + } + + if ( st_ivas->hTcBuffer == NULL ) + { + slots_rendered_new = 0; + } + else + { + /* this is needed for OMASA-DISC, because the td-rend granularity is 240 samples at 48kHz, leading to wrong slot count. */ + if ( st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) + { + slots_rendered_new = st_ivas->hTcBuffer->n_samples_rendered / NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); + } + else + { + slots_rendered_new = st_ivas->hTcBuffer->n_samples_rendered / st_ivas->hTcBuffer->n_samples_granularity; + } + } + + for ( i = 0; i < BINAURAL_CHANNELS * numPoses; ++i ) + { + for ( j = slots_rendered; j < slots_rendered_new; ++j ) + { + mvr2r( hSplitBinRend->hMultiBinCldfbData->Cldfb_RealBuffer_Binaural[i][j], Cldfb_RealBuffer_Binaural[i][j - slots_rendered], CLDFB_NO_CHANNELS_MAX ); + mvr2r( hSplitBinRend->hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural[i][j], Cldfb_ImagBuffer_Binaural[i][j - slots_rendered], CLDFB_NO_CHANNELS_MAX ); + } + } + + max_band = (int16_t) ( ( BINAURAL_MAXBANDS * output_Fs ) / 48000 ); + pcm_out_flag = ( output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0; + td_input = st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV && st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC && st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC_ROOM && st_ivas->renderer_type != RENDERER_STEREO_PARAMETRIC; + + if ( st_ivas->hBinRendererTd != NULL ) + { + ro_md_flag = 1; + } + else + { + ro_md_flag = 0; + } + + if ( st_ivas->hHeadTrackData != NULL ) + { + Quaternion = st_ivas->hHeadTrackData->Quaternions[0]; + } + else + { + Quaternion.w = -3.0f; + Quaternion.x = 0.0f; + Quaternion.y = 0.0f; + Quaternion.z = 0.0f; + } + if ( ( error = ISAR_PRE_REND_MultiBinToSplitBinaural( &hSplitBinRend->splitrend, + Quaternion, + st_ivas->hRenderConfig->split_rend_config.splitRendBitRate, + st_ivas->hRenderConfig->split_rend_config.codec, +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + st_ivas->hRenderConfig->split_rend_config.isar_frame_size_ms, +#endif + st_ivas->hRenderConfig->split_rend_config.codec_frame_size_ms, + splitRendBits, + Cldfb_RealBuffer_Binaural, + Cldfb_ImagBuffer_Binaural, + max_band, pOutput, 1, !td_input, pcm_out_flag, ro_md_flag ) ) != IVAS_ERR_OK ) + + { + return error; + } + + /* convert to int16 with limiting for BINAURAL_SPLIT_PCM */ + if ( pcm_out_flag ) + { + if ( st_ivas->hDecoderConfig->render_framesize == IVAS_RENDER_FRAMESIZE_5MS ) + { +#ifndef DISABLE_LIMITER + ivas_limiter_dec( st_ivas->hLimiter, pOutput, st_ivas->hDecoderConfig->nchan_out, numSamplesPerChannelToDecode, st_ivas->BER_detect ); +#endif + } + else + { + ivas_limiter_dec( st_ivas->hLimiter, pOutput, st_ivas->hDecoderConfig->nchan_out, numSamplesPerChannelToDecode, st_ivas->BER_detect ); + } + +#ifdef DEBUGGING + st_ivas->noClipping += +#endif + ivas_syn_output( pOutput, numSamplesPerChannelToDecode, st_ivas->hDecoderConfig->nchan_out, (int16_t *) pcmBuf_out ); + } + + free( st_ivas->hSplitBinRend->hMultiBinCldfbData ); + + return error; +} +#endif + + /*---------------------------------------------------------------------* * IVAS_DEC_Setup( ) * @@ -949,7 +1294,12 @@ static ivas_error IVAS_DEC_Setup( uint8_t *nTransportChannels, /* o : number of decoded transport PCM channels */ uint8_t *nOutChannels, /* o : number of decoded out channels (PCM or CLDFB) */ uint16_t *nSamplesRendered, /* o : number of samples flushed from the last frame */ - int16_t *data /* o : output synthesis signal */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + const IVAS_DEC_PCM_TYPE pcmType, /* i : type for the decoded PCM resolution */ + void *data /* o : output synthesis signal */ +#else + int16_t *data /* o : output synthesis signal */ +#endif ) { ivas_error error; @@ -985,7 +1335,11 @@ static ivas_error IVAS_DEC_Setup( if ( st_ivas->bfi == 0 ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( error = ivas_dec_setup( st_ivas, nSamplesRendered, pcm_type_API_to_internal( pcmType ), data ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_dec_setup( st_ivas, nSamplesRendered, data ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -1091,7 +1445,13 @@ static ivas_error IVAS_DEC_GetRenderedSamples( const uint16_t nSamplesForRendering, /* i : number of TC samples wanted from the renderer */ uint16_t *nSamplesRendered, /* o : number of samples rendered */ uint16_t *nSamplesAvailableNext, /* o : number of samples still available in the renerer pipeline */ - int16_t *pcmBuf ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + const IVAS_DEC_PCM_TYPE pcmType, + void *pcmBuf +#else + int16_t *pcmBuf +#endif +) { Decoder_Struct *st_ivas; ivas_error error; @@ -1104,7 +1464,11 @@ static ivas_error IVAS_DEC_GetRenderedSamples( st_ivas = hIvasDec->st_ivas; /* run the main IVAS decoding routine */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + error = ivas_jbm_dec_render( st_ivas, nSamplesForRendering, nSamplesRendered, nSamplesAvailableNext, pcm_type_API_to_internal( pcmType ), pcmBuf ); +#else error = ivas_jbm_dec_render( st_ivas, nSamplesForRendering, nSamplesRendered, nSamplesAvailableNext, pcmBuf ); +#endif return error; } @@ -1382,7 +1746,12 @@ ivas_error IVAS_DEC_FeedHeadTrackData( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ IVAS_QUATERNION orientation, /* i : head-tracking data, listener orientation */ IVAS_VECTOR3 Pos, /* i : listener position */ - const int16_t subframe_idx /* i : subframe index */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + const int16_t subframe_idx, /* i : subframe index */ + const ISAR_SPLIT_REND_ROT_AXIS rot_axis /* i : external control for rotation axis for split rendering */ +#else + const int16_t subframe_idx /* i : subframe index */ +#endif ) { HEAD_TRACK_DATA_HANDLE hHeadTrackData; @@ -1416,6 +1785,9 @@ ivas_error IVAS_DEC_FeedHeadTrackData( hHeadTrackData->Pos[subframe_idx].y = Pos.y; hHeadTrackData->Pos[subframe_idx].z = Pos.z; +#ifdef SPLIT_REND_WITH_HEAD_ROT + hHeadTrackData->sr_pose_pred_axis = rot_axis; +#endif hIvasDec->updateOrientation = true; return IVAS_ERR_OK; @@ -1705,6 +2077,24 @@ static ivas_error copyRendererConfigStruct( mvr2r( hRCin->roomAcoustics.pAcoustic_rt60, hRCout->roomAcoustics.pAcoustic_rt60, CLDFB_NO_CHANNELS_MAX ); mvr2r( hRCin->roomAcoustics.pAcoustic_dsr, hRCout->roomAcoustics.pAcoustic_dsr, CLDFB_NO_CHANNELS_MAX ); mvr2r( hRCin->directivity, hRCout->directivity, 3 * MAX_NUM_OBJECTS ); +#ifdef SPLIT_REND_WITH_HEAD_ROT + /* TODO: This seems wrong. Why set default instead of copying from hRCin? + * Currently seems to work because we only ever copy from a default-initialized handle anyway */ + hRCout->split_rend_config.splitRendBitRate = SPLIT_REND_768k; + hRCout->split_rend_config.dof = 3; + hRCout->split_rend_config.hq_mode = 0; + hRCout->split_rend_config.codec_delay_ms = 0; +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + hRCout->split_rend_config.isar_frame_size_ms = 20; +#endif + hRCout->split_rend_config.codec_frame_size_ms = 0; /* 0 means "use default for selected codec" */ + hRCout->split_rend_config.codec = ISAR_SPLIT_REND_CODEC_DEFAULT; + hRCout->split_rend_config.poseCorrectionMode = ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB; + hRCout->split_rend_config.rendererSelection = hRCin->split_rend_config.rendererSelection; +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + hRCout->split_rend_config.lc3plus_highres = hRCin->split_rend_config.lc3plus_highres; +#endif +#endif hRCout->roomAcoustics.use_er = hRCin->roomAcoustics.use_er; hRCout->roomAcoustics.lowComplexity = hRCin->roomAcoustics.lowComplexity; @@ -1761,6 +2151,9 @@ ivas_error IVAS_DEC_FeedRenderConfig( ) { RENDER_CONFIG_HANDLE hRenderConfig; +#ifdef SPLIT_REND_WITH_HEAD_ROT + ivas_error error; +#endif if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || hIvasDec->st_ivas->hRenderConfig == NULL ) { @@ -1801,6 +2194,20 @@ ivas_error IVAS_DEC_FeedRenderConfig( mvr2r( renderConfig.directivity, hRenderConfig->directivity, 3 * MAX_NUM_OBJECTS ); +#ifdef SPLIT_REND_WITH_HEAD_ROT + hRenderConfig->split_rend_config = renderConfig.split_rend_config; + + /* Overwrite any pose correction settings if 0 DOF (no pose correction) was selected */ + if ( hRenderConfig->split_rend_config.dof == 0 ) + { + hRenderConfig->split_rend_config.poseCorrectionMode = ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE; + } + + if ( ( error = isar_split_rend_validate_config( &hRenderConfig->split_rend_config, ( hIvasDec->st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0 ) ) != IVAS_ERR_OK ) + { + return error; + } +#endif return IVAS_ERR_OK; } @@ -1835,11 +2242,19 @@ ivas_error IVAS_DEC_GetDelay( st_ivas = hIvasDec->st_ivas; hDecoderConfig = st_ivas->hDecoderConfig; +#ifdef SPLIT_REND_WITH_HEAD_ROT + nSamples[1] = NS2SA( hDecoderConfig->output_Fs, get_delay( DEC, hDecoderConfig->output_Fs, st_ivas->ivas_format, st_ivas->cldfbAnaDec[0], hDecoderConfig->output_config ) ); +#else nSamples[1] = NS2SA( hDecoderConfig->output_Fs, get_delay( DEC, hDecoderConfig->output_Fs, st_ivas->ivas_format, st_ivas->cldfbAnaDec[0] ) ); +#endif nSamples[2] = (int16_t) roundf( (float) st_ivas->binaural_latency_ns * hDecoderConfig->output_Fs / 1000000000.f ); nSamples[0] = nSamples[1] + nSamples[2]; +#ifdef FIX_921_OMASA_DELAY_PRINTOUT + if ( st_ivas->ivas_format == MASA_FORMAT || st_ivas->ivas_format == MASA_ISM_FORMAT ) +#else if ( st_ivas->ivas_format == MASA_FORMAT ) +#endif { /* note: in MASA, all delay is compensated at the decoder by default, so subtract the encoder delay for print-out */ nSamples[1] -= NS2SA( hDecoderConfig->output_Fs, IVAS_ENC_DELAY_NS ); @@ -2100,9 +2515,14 @@ ivas_error IVAS_DEC_TSM_SetQuality( *---------------------------------------------------------------------*/ ivas_error IVAS_DEC_VoIP_GetSamples( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - uint16_t nSamplesPerChannel, /* i : number of samples per channel requested to be written to output buffer */ - int16_t *pcmBuf, /* i/o: buffer for decoded PCM output. The memory must already be allocated and be able to hold the expected number of output samples, based on frame size and number of output channels */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + uint16_t nSamplesPerChannel, /* i : number of samples per channel requested to be written to output buffer */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + const IVAS_DEC_PCM_TYPE pcmType, + void *pcmBuf, +#else + int16_t *pcmBuf, /* i/o: buffer for decoded PCM output. The memory must already be allocated and be able to hold the expected number of output samples, based on frame size and number of output channels */ +#endif const uint32_t systemTimestamp_ms /* i : current system timestamp */ #ifdef SUPPORT_JBM_TRACEFILE , @@ -2253,7 +2673,11 @@ ivas_error IVAS_DEC_VoIP_GetSamples( /* codec mode to use not known yet - simply output silence */ /* directly set output zero */ int16_t nSamplesToZero = min( nSamplesPerChannel, hIvasDec->nSamplesAvailableNext ); +#ifdef SPLIT_REND_WITH_HEAD_ROT + set_pcm_buffer_to_zero( pcm_buffer_offset( pcmBuf, pcmType, nSamplesRendered * nOutChannels ), pcmType, nSamplesToZero * nOutChannels ); +#else set_s( pcmBuf + nSamplesRendered * nOutChannels, 0, nSamplesToZero * nOutChannels ); +#endif nSamplesRendered += nSamplesToZero; hIvasDec->nSamplesRendered += nSamplesToZero; hIvasDec->nSamplesAvailableNext -= nSamplesToZero; @@ -2265,7 +2689,11 @@ ivas_error IVAS_DEC_VoIP_GetSamples( nSamplesToRender = nSamplesPerChannel - nSamplesRendered; /* render IVAS frames directly to the output buffer */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( error = IVAS_DEC_GetSamples( hIvasDec, nSamplesToRender, pcmType, pcm_buffer_offset( pcmBuf, pcmType, nSamplesRendered * nOutChannels ), &nSamplesRendered_loop, &tmp ) ) != IVAS_ERR_OK ) +#else if ( ( error = IVAS_DEC_GetSamples( hIvasDec, nSamplesToRender, pcmBuf + nSamplesRendered * nOutChannels, &nSamplesRendered_loop, &tmp ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -2287,8 +2715,13 @@ ivas_error IVAS_DEC_VoIP_GetSamples( ivas_error IVAS_DEC_Flush( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ const int16_t nSamplesPerChannel, /* i : number of samples per channel requested to be written to output buffer */ - int16_t *pcmBuf, /* i/o: buffer for decoded PCM output. The memory must already be allocated and be able to hold the expected number of output samples, based on frame size and number of output channels */ - int16_t *nSamplesFlushed /* o : number of samples flushed */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + const IVAS_DEC_PCM_TYPE pcmType, + void *pcmBuf, +#else + int16_t *pcmBuf, /* i/o: buffer for decoded PCM output. The memory must already be allocated and be able to hold the expected number of output samples, based on frame size and number of output channels */ +#endif + int16_t *nSamplesFlushed /* o : number of samples flushed */ ) { ivas_error error; @@ -2300,7 +2733,11 @@ ivas_error IVAS_DEC_Flush( nSamplesToRender = (uint16_t) *nSamplesFlushed; /* render IVAS frames */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + error = IVAS_DEC_GetRenderedSamples( hIvasDec, nSamplesToRender, &nSamplesFlushedLocal, &hIvasDec->nSamplesAvailableNext, pcmType, pcmBuf ); +#else error = IVAS_DEC_GetRenderedSamples( hIvasDec, nSamplesToRender, &nSamplesFlushedLocal, &hIvasDec->nSamplesAvailableNext, pcmBuf ); +#endif return error; } @@ -2567,7 +3004,11 @@ static ivas_error printConfigInfo_dec( get_channel_config( output_config, &config_str[0] ); fprintf( stdout, "Output configuration: %s\n", config_str ); +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) +#else if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) +#endif { fprintf( stdout, "Render framesize: %dms\n", get_render_frame_size_ms( st_ivas->hDecoderConfig->render_framesize ) ); } @@ -3133,3 +3574,305 @@ static ivas_error IVAS_DEC_VoIP_reconfigure( return IVAS_ERR_OK; } + + +#ifdef SPLIT_REND_WITH_HEAD_ROT +/*---------------------------------------------------------------------* + * IVAS_DEC_GetSplitRendBitstreamHeader() + * + * + *---------------------------------------------------------------------*/ + +ivas_error +IVAS_DEC_GetSplitRendBitstreamHeader( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + ISAR_SPLIT_REND_CODEC *pCodec, /* o: pointer to codec setting */ + ISAR_SPLIT_REND_POSE_CORRECTION_MODE *poseCorrection, /* o: pointer to pose correction mode */ +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + int16_t *pIsar_frame_size_ms, /* o: pointer to isar frame size setting */ +#endif + int16_t *pCodec_frame_size_ms /* o: pointer to codec frame size setting */ +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + , + int16_t *pLc3plusHighRes +#endif +) +{ + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + *pCodec = hIvasDec->st_ivas->hRenderConfig->split_rend_config.codec; + *pCodec_frame_size_ms = hIvasDec->st_ivas->hRenderConfig->split_rend_config.codec_frame_size_ms; + *poseCorrection = hIvasDec->st_ivas->hRenderConfig->split_rend_config.poseCorrectionMode; +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + *pIsar_frame_size_ms = hIvasDec->st_ivas->hRenderConfig->split_rend_config.isar_frame_size_ms; + *pLc3plusHighRes = hIvasDec->st_ivas->hRenderConfig->split_rend_config.lc3plus_highres; +#endif + return IVAS_ERR_OK; +} + + +/*---------------------------------------------------------------------* + * IVAS_DEC_GetCldfbSamples() + * + * API function to output CLDFB samples + *---------------------------------------------------------------------*/ + +ivas_error IVAS_DEC_GetCldfbSamples( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + float *out_real, /* o : buffer for decoded PCM real output in CLDFB domain */ + float *out_imag, /* o : buffer for decoded PCM imag output in CLDFB domain */ + AUDIO_CONFIG *audio_config, /* o : audio configuration */ + int16_t *nOutSamples /* o : number of samples per channel written to output buffer */ +) +{ + ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE hSplitBinRend; + int16_t ch, b, slot_idx, num_chs, maxBand, num_samples; + + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || hIvasDec->st_ivas->hSplitBinRend == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + hSplitBinRend = hIvasDec->st_ivas->hSplitBinRend; + num_samples = 0; + + if ( hSplitBinRend->hCldfbDataOut != NULL ) + { + *audio_config = hSplitBinRend->hCldfbDataOut->config; + if ( hSplitBinRend->hCldfbDataOut->config != IVAS_AUDIO_CONFIG_INVALID ) + { + num_chs = audioCfg2channels( hSplitBinRend->hCldfbDataOut->config ); + maxBand = (int16_t) ( ( CLDFB_NO_CHANNELS_MAX * hIvasDec->st_ivas->hDecoderConfig->output_Fs ) / 48000 ); + + for ( slot_idx = 0; slot_idx < CLDFB_NO_COL_MAX; slot_idx++ ) + { + for ( b = 0; b < maxBand; b++ ) + { + for ( ch = 0; ch < num_chs; ch++ ) + { + *out_real++ = hSplitBinRend->hCldfbDataOut->Cldfb_RealBuffer[ch][slot_idx][b]; + *out_imag++ = hSplitBinRend->hCldfbDataOut->Cldfb_ImagBuffer[ch][slot_idx][b]; + } + } + } + num_samples = CLDFB_NO_COL_MAX * maxBand; + } + } + else + { + *audio_config = IVAS_AUDIO_CONFIG_INVALID; + } + + *nOutSamples = num_samples; + + return IVAS_ERR_OK; +} + + +/*---------------------------------------------------------------------* + * pcm_buffer_offset() + * + * + *---------------------------------------------------------------------*/ + +static void *pcm_buffer_offset( + void *buffer, + const IVAS_DEC_PCM_TYPE pcmType, + const int32_t offset ) +{ + switch ( pcmType ) + { + case IVAS_DEC_PCM_FLOAT: + { + float *tmpBuf = (float *) buffer; + return (void *) ( tmpBuf + offset ); + } + break; + case IVAS_DEC_PCM_INT16: + { + int16_t *tmpBuf = (int16_t *) buffer; + return (void *) ( tmpBuf + offset ); + } + break; + default: + break; + } + + return NULL; +} + + +/*---------------------------------------------------------------------* + * set_pcm_buffer_to_zero() + * + * + *---------------------------------------------------------------------*/ + +static ivas_error set_pcm_buffer_to_zero( + void *buffer, + const IVAS_DEC_PCM_TYPE pcmType, + const int16_t nZeroSamples ) +{ + ivas_error error; + + error = IVAS_ERR_OK; + switch ( pcmType ) + { + case IVAS_DEC_PCM_FLOAT: + set_zero( (float *) buffer, nZeroSamples ); + break; + case IVAS_DEC_PCM_INT16: + set_s( (int16_t *) buffer, 0, nZeroSamples ); + break; + default: + error = IVAS_ERR_INTERNAL; + } + + return error; +} + + +/*---------------------------------------------------------------------* + * pcm_type_API_to_internal() + * + * + *---------------------------------------------------------------------*/ + +PCM_RESOLUTION pcm_type_API_to_internal( + const IVAS_DEC_PCM_TYPE pcmType ) +{ + PCM_RESOLUTION pcm_resolution; + pcm_resolution = PCM_NOT_KNOW; + + switch ( pcmType ) + { + case IVAS_DEC_PCM_FLOAT: + pcm_resolution = PCM_FLOAT32; + break; + case IVAS_DEC_PCM_INT16: + pcm_resolution = PCM_INT16; + break; + default: + pcm_resolution = PCM_NOT_KNOW; + } + + return pcm_resolution; +} + + +/*-------------------------------------------------------------------* + * ivas_create_handle_isar() + * + * Initialize IVAS decoder split rend handle + *-------------------------------------------------------------------*/ + +static ivas_error ivas_create_handle_isar( + ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE *hSplitBinRend_out /* o : ISAR split binaural rendering handle */ +) +{ + ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE hSplitBinRend; + + if ( ( hSplitBinRend = (ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE) malloc( sizeof( ISAR_DEC_SPLIT_REND_WRAPPER ) ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for IVAS decoder handle" ); + } + + isar_init_split_rend_handles( &hSplitBinRend->splitrend ); + + hSplitBinRend->hMultiBinCldfbData = NULL; + hSplitBinRend->hCldfbDataOut = NULL; + hSplitBinRend->numTdSamplesPerChannelCached = 0; + + *hSplitBinRend_out = hSplitBinRend; + + return IVAS_ERR_OK; +} + + +/*-------------------------------------------------------------------* + * ivas_destroy_handle_isar() + * + * destroy IVAS decoder split rend handle + *-------------------------------------------------------------------*/ + +static void ivas_destroy_handle_isar( + ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE *hSplitBinRend /* i/o: ISAR split binaural rendering handle */ +) +{ + if ( *hSplitBinRend != NULL ) + { + ISAR_PRE_REND_close( &( *hSplitBinRend )->splitrend, NULL ); + + if ( ( *hSplitBinRend )->hCldfbDataOut != NULL ) + { + free( ( *hSplitBinRend )->hCldfbDataOut ); + ( *hSplitBinRend )->hCldfbDataOut = NULL; + } + } + + return; +} + + +/*---------------------------------------------------------------------* + * IVAS_DEC_is_split_rendering_enabled() + * + * + *---------------------------------------------------------------------*/ + +int16_t IVAS_DEC_is_split_rendering_enabled( + IVAS_DEC_HANDLE hIvasDec /* i/o: IVAS decoder handle */ +) +{ + Decoder_Struct *st_ivas; + int16_t isSplitRend; + + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + st_ivas = hIvasDec->st_ivas; + isSplitRend = 0; + + if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM || + ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_STEREO && st_ivas->hDecoderConfig->Opt_non_diegetic_pan && st_ivas->hRenderConfig->split_rend_config.dof == 0 ) ) + { + isSplitRend = 1; + } + + return isSplitRend; +} + + +/*---------------------------------------------------------------------* + * IVAS_DEC_is_split_rendering_coded_out() + * + * + *---------------------------------------------------------------------*/ + +int16_t IVAS_DEC_is_split_rendering_coded_out( + IVAS_DEC_HANDLE hIvasDec /* i/o: IVAS decoder handle */ +) +{ + Decoder_Struct *st_ivas; + int16_t isSplitCoded; + + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + st_ivas = hIvasDec->st_ivas; + isSplitCoded = 0; + + if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || + ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_STEREO && st_ivas->hDecoderConfig->Opt_non_diegetic_pan && st_ivas->hRenderConfig->split_rend_config.dof == 0 ) ) + { + isSplitCoded = 1; + } + + return isSplitCoded; +} +#endif diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index 443f9ef6ee23fea9bb3747a248e5cb6595aa3b18..8b9d908384ac5c292239f9596da7898238923516 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other @@ -74,6 +74,14 @@ typedef enum _IVAS_DEC_FORCED_REND_MODE } IVAS_DEC_FORCED_REND_MODE; #endif +#ifdef SPLIT_REND_WITH_HEAD_ROT +typedef enum _IVAS_DEC_PCM_TYPE +{ + IVAS_DEC_PCM_INT16, + IVAS_DEC_PCM_FLOAT, + IVAS_DEC_PCM_INVALID +} IVAS_DEC_PCM_TYPE; +#endif /* bitstream formats that can be consumed */ typedef enum _IVAS_DEC_BS_FORMAT @@ -149,11 +157,56 @@ ivas_error IVAS_DEC_FeedFrame_Serial( ivas_error IVAS_DEC_GetSamples( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ const int16_t nSamplesAsked, /* i : number of samples wanted by the caller */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + const IVAS_DEC_PCM_TYPE pcmType, /* i : type for the decoded PCM resolution */ + void *pcmBuf, /* o : output synthesis signal */ +#else int16_t *pcmBuf, /* i/o: buffer for decoded PCM output. The memory must already be allocated and be able to hold the expected number of output samples, based on frame size and number of output channels */ +#endif int16_t *nOutSamples, /* o : number of samples per channel written to output buffer */ bool *needNewFrame /* o : indication that the decoder needs a new frame */ ); +#ifdef SPLIT_REND_WITH_HEAD_ROT +ivas_error IVAS_DEC_GetSplitBinauralBitstream( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + void *pcmBuf_out, /* o : output synthesis signal for BINAURAL_SPLIT_PCM */ + ISAR_SPLIT_REND_BITS_DATA *splitRendBits, /* o : output split rendering bits */ + int16_t *nOutSamples, /* o : number of samples per channel written to output buffer */ + bool *needNewFrame /* o : indication that the decoder needs a new frame */ +); + +/*! r: decoder error code */ +ivas_error IVAS_DEC_GetSplitRendBitstreamHeader( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + ISAR_SPLIT_REND_CODEC *pCodec, /* o: pointer to codec setting */ + ISAR_SPLIT_REND_POSE_CORRECTION_MODE *poseCorrection, /* o: pointer to pose correction mode */ +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + int16_t *pIsar_frame_size_ms, /* o: pointer to isar frame size setting */ +#endif + int16_t *pCodec_frame_size_ms /* o: pointer to codec frame size setting */ +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + , + int16_t *pLc3plusHighRes /* o: pointer to LC3plus High-Res setting */ +#endif +); + +/*! r: decoder error code */ +ivas_error IVAS_DEC_GetCldfbSamples( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + float *out_real, /* o : buffer for decoded PCM real output in CLDFB domain */ + float *out_imag, /* o : buffer for decoded PCM imag output in CLDFB domain */ + IVAS_AUDIO_CONFIG *audio_config, /* o : audio configuration */ + int16_t *nOutSamples /* o : number of samples per channel written to output buffer */ +); + +int16_t IVAS_DEC_is_split_rendering_enabled( + IVAS_DEC_HANDLE hIvasDec /* i: IVAS decoder handle */ +); +int16_t IVAS_DEC_is_split_rendering_coded_out( + IVAS_DEC_HANDLE hIvasDec /* i/o: IVAS decoder handle */ +); +#endif /*! r: error code */ ivas_error IVAS_DEC_GetObjectMetadata( @@ -175,7 +228,12 @@ ivas_error IVAS_DEC_FeedHeadTrackData( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ IVAS_QUATERNION orientation, /* i : head-tracking data, listener orientation */ IVAS_VECTOR3 Pos, /* i : listener position */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + const int16_t subframe_idx, /* i : subframe index */ + const ISAR_SPLIT_REND_ROT_AXIS rot_axis /* i : external control for rotation axis for split rendering */ +#else const int16_t subframe_idx /* i : subframe index */ +#endif ); /*! r: error code */ @@ -228,7 +286,12 @@ ivas_error IVAS_DEC_TSM_SetQuality( ivas_error IVAS_DEC_VoIP_GetSamples( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ uint16_t nSamplesPerChannel, /* i : number of samples per channel requested to be written to output buffer */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + const IVAS_DEC_PCM_TYPE pcmType, + void *pcmBuf, +#else int16_t *pcmBuf, /* i/o: buffer for decoded PCM output. The memory must already be allocated and be able to hold the expected number of output samples, based on frame size and number of output channels */ +#endif const uint32_t systemTimestamp_ms /* i : current system timestamp */ #ifdef SUPPORT_JBM_TRACEFILE , JbmTraceFileWriterFn jbmWriterFn, @@ -239,7 +302,12 @@ ivas_error IVAS_DEC_VoIP_GetSamples( ivas_error IVAS_DEC_Flush( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ const int16_t nSamplesPerChannel, /* i : number of samples per channel requested to be written to output buffer */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + const IVAS_DEC_PCM_TYPE pcmType, + void *pcmBuf, +#else int16_t *pcmBuf, /* i/o: buffer for decoded PCM output. The memory must already be allocated and be able to hold the expected number of output samples, based on frame size and number of output channels */ +#endif int16_t *nSamplesFlushed /* o : number of samples flushed */ ); @@ -252,6 +320,12 @@ ivas_error IVAS_DEC_EnableVoIP( const IVAS_DEC_INPUT_FORMAT inputFormat /* i : format of the input bitstream */ ); +#ifdef SPLIT_REND_WITH_HEAD_ROT +/*! r: error code */ +ivas_error IVAS_DEC_EnableSplitRendering( + IVAS_DEC_HANDLE hIvasDec /* i/o: IVAS decoder handle */ +); +#endif ivas_error IVAS_DEC_SetRenderFramesize( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ diff --git a/lib_dec/lp_exc_d.c b/lib_dec/lp_exc_d.c index c436edcf133f5f4b6232c69700c350fc30d9f1f4..9a53ac9e95a14856883216f96d8de7f938c18f86 100644 --- a/lib_dec/lp_exc_d.c +++ b/lib_dec/lp_exc_d.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/lsf_dec.c b/lib_dec/lsf_dec.c index 119cf7ecf2ef39767141bbbb27d2540c26004489..5119f1022bf0943c60028a28822ae04881c927f8 100644 --- a/lib_dec/lsf_dec.c +++ b/lib_dec/lsf_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/lsf_msvq_ma_dec.c b/lib_dec/lsf_msvq_ma_dec.c index 9c911ab5f6f82be803ce483aced3d5e9948bbfe0..bd236973a6a6aa6903cc044f37dc191c6152d1ef 100644 --- a/lib_dec/lsf_msvq_ma_dec.c +++ b/lib_dec/lsf_msvq_ma_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/nelp_dec.c b/lib_dec/nelp_dec.c index 67d8fb5f8bda758ff4a2a213768eefb6704aae18..b301567a5b341b54393d9390c2466e0c274fc5d6 100644 --- a/lib_dec/nelp_dec.c +++ b/lib_dec/nelp_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/peak_vq_dec.c b/lib_dec/peak_vq_dec.c index 21c8014f86a9305006b8d4cc0c3faaadf5519e85..efc75f828d119bccfddefbc37298faeaed6d2952 100644 --- a/lib_dec/peak_vq_dec.c +++ b/lib_dec/peak_vq_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/pit_dec.c b/lib_dec/pit_dec.c index c569e6609780edd126e0baf65619cbafb54c2ace..d81c555d6804a389552b014a05b319558f8a84de 100644 --- a/lib_dec/pit_dec.c +++ b/lib_dec/pit_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/pitch_extr.c b/lib_dec/pitch_extr.c index a0370946bde5b9b0c429e73adff6115da5ced67d..83a71c91488fd6d40786a2d0fbc9c99f7ea4c2de 100644 --- a/lib_dec/pitch_extr.c +++ b/lib_dec/pitch_extr.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/post_dec.c b/lib_dec/post_dec.c index 5bc31d56eeb2165396b3a01d02beb9a6528b686c..18b48de333704777fabd777d21d8d8a24c29dd9c 100644 --- a/lib_dec/post_dec.c +++ b/lib_dec/post_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/ppp_dec.c b/lib_dec/ppp_dec.c index f9e97edcaaa35fb7a10eec86aab93eb0f4b569bf..c5bbae10bee9463244d976e28a50926ef9428b31 100644 --- a/lib_dec/ppp_dec.c +++ b/lib_dec/ppp_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/pvq_core_dec.c b/lib_dec/pvq_core_dec.c index d5a6eed2e6bf4effb28b5ca0fb68b50ad325a0f0..5079e49f3d1af86636ffbc38e2d1052f38ecc352 100644 --- a/lib_dec/pvq_core_dec.c +++ b/lib_dec/pvq_core_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/pvq_decode.c b/lib_dec/pvq_decode.c index a0da5f09ea6d015f42f9e1ef3b0fff5c04a5275a..ec420678b23782de2788ada76b48db371176a596 100644 --- a/lib_dec/pvq_decode.c +++ b/lib_dec/pvq_decode.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/range_dec.c b/lib_dec/range_dec.c index 25cfdb2155c48c3f5e4a5542996bcc456e590d7d..2bd0497c9f848435cc9b66146f3a8f5f3d0eb086 100644 --- a/lib_dec/range_dec.c +++ b/lib_dec/range_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/re8_dec.c b/lib_dec/re8_dec.c index d9a7c750dc8abb12c4d983cec25690b867f0d80d..26e9b77e318f1a739d613ab518b71c5461bb4f34 100644 --- a/lib_dec/re8_dec.c +++ b/lib_dec/re8_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/rom_dec.c b/lib_dec/rom_dec.c index e0ae59e586a4b5d3d2b30f613a87d76e9a8fc0be..421bab3e62258b978f6189baa4e85321e3f2920c 100644 --- a/lib_dec/rom_dec.c +++ b/lib_dec/rom_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/rom_dec.h b/lib_dec/rom_dec.h index 5930eda56f102d1ca727252fe404549d9f72e650..ad832d3544afbe50c1f5bacb7d36eb2d4170dd2c 100644 --- a/lib_dec/rom_dec.h +++ b/lib_dec/rom_dec.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/rst_dec.c b/lib_dec/rst_dec.c index f3fbd32165e1130df70da4f48b896bf100e1f79e..88d5f23dbfe5c375e0ab6657e2aac85af9b28d74 100644 --- a/lib_dec/rst_dec.c +++ b/lib_dec/rst_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/stat_dec.h b/lib_dec/stat_dec.h index d83b77ab434a78149c4445edc291b969b700e018..482b7a8428715c05209b69b989076d83bb0e202d 100644 --- a/lib_dec/stat_dec.h +++ b/lib_dec/stat_dec.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/stat_noise_uv_dec.c b/lib_dec/stat_noise_uv_dec.c index 2fa711814b4b290092e703bed04190a11bc0984f..a62b27d3cffb3d6d30ee8d8fe3a60205da690140 100644 --- a/lib_dec/stat_noise_uv_dec.c +++ b/lib_dec/stat_noise_uv_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/swb_bwe_dec.c b/lib_dec/swb_bwe_dec.c index a89a17cca85be7d365bcd352253ca615c1c233f0..05a0ac2249e90e4c32cad4212c97c1e6326cf038 100644 --- a/lib_dec/swb_bwe_dec.c +++ b/lib_dec/swb_bwe_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/swb_bwe_dec_hr.c b/lib_dec/swb_bwe_dec_hr.c index 1c4d5c7f6ebb483b5091ce8b691e9db97ee9168b..03347958dfb1e51e544d55e5afd39f1f9279cf6c 100644 --- a/lib_dec/swb_bwe_dec_hr.c +++ b/lib_dec/swb_bwe_dec_hr.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/swb_bwe_dec_lr.c b/lib_dec/swb_bwe_dec_lr.c index c0ccb648c0a4fa32522e835d94a91de1f7ef00e5..34020216b9c24af771bc29b989e345f17c9234ae 100644 --- a/lib_dec/swb_bwe_dec_lr.c +++ b/lib_dec/swb_bwe_dec_lr.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/swb_tbe_dec.c b/lib_dec/swb_tbe_dec.c index 05209bb115e9a54abc91924ce42b534a1a236e5b..f344b1228e9000a1e47cd29be23d5bb3ce994766 100644 --- a/lib_dec/swb_tbe_dec.c +++ b/lib_dec/swb_tbe_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/syn_outp.c b/lib_dec/syn_outp.c index c28666d1effccac38eb83f50b369cac9ca0e706f..68389fa27980f1e1c747e8b0552435df2d7395c2 100644 --- a/lib_dec/syn_outp.c +++ b/lib_dec/syn_outp.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/tcq_core_dec.c b/lib_dec/tcq_core_dec.c index 8b0a6f2d40dbac5e01b5bb3dadadfdffb5b0b88a..3f4dadf0cdd0b1ac8c577957c64992414a1a1492 100644 --- a/lib_dec/tcq_core_dec.c +++ b/lib_dec/tcq_core_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/tcx_utils_dec.c b/lib_dec/tcx_utils_dec.c index 5db8a20b082a433efae7170f55c868401f4c22d5..dc738f0d47d89e9cbc1c32216850d7f9d99c5eb1 100644 --- a/lib_dec/tcx_utils_dec.c +++ b/lib_dec/tcx_utils_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/tns_base_dec.c b/lib_dec/tns_base_dec.c index 444c465042ed8232f18414ca6b69a8355b0a9b8c..17f9944897b3396ecc77032fe9c8914b67d31eed 100644 --- a/lib_dec/tns_base_dec.c +++ b/lib_dec/tns_base_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/tonalMDCTconcealment.c b/lib_dec/tonalMDCTconcealment.c index d2d177ddbc6a8894fd11eef382ff8305777b7284..bad470db9d286cf18c63da9c36ab594edae4f72a 100644 --- a/lib_dec/tonalMDCTconcealment.c +++ b/lib_dec/tonalMDCTconcealment.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/transition_dec.c b/lib_dec/transition_dec.c index 05c7887f4babdbef97dae6bf2a0644a4ae1bb675..64bddfbbae83aab4efd5ba3a4b26df70ab9822a3 100644 --- a/lib_dec/transition_dec.c +++ b/lib_dec/transition_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/updt_dec.c b/lib_dec/updt_dec.c index 54bc4887d2f9ca9de367210db409e39d98436005..014f58f61a68e18b360591bfc8c8524e8fc280ac 100644 --- a/lib_dec/updt_dec.c +++ b/lib_dec/updt_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/vlpc_1st_dec.c b/lib_dec/vlpc_1st_dec.c index cc7b33bc9a5754ffb867eb9ba2a35d4e51e0262e..62ecaea0e674a9017ead8f07bf0a024e99413da1 100644 --- a/lib_dec/vlpc_1st_dec.c +++ b/lib_dec/vlpc_1st_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/vlpc_2st_dec.c b/lib_dec/vlpc_2st_dec.c index 8ac23141b83c681149148297be8f2fafbf1ed2f8..c623ebf5dff9505ca80bc81cd67e380813adabef 100644 --- a/lib_dec/vlpc_2st_dec.c +++ b/lib_dec/vlpc_2st_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/voiced_dec.c b/lib_dec/voiced_dec.c index 5c2bcc1f15e6de19b2d7924b112b886d51696e90..c6c67793173ac48addbe897fd706109b141426b7 100644 --- a/lib_dec/voiced_dec.c +++ b/lib_dec/voiced_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_dec/waveadjust_fec_dec.c b/lib_dec/waveadjust_fec_dec.c index 99a10e886c77a2326a1feefb81756b084c5a3acd..ecfbc919e8c24251d3fc1bd8236ecb30d1c40d3a 100644 --- a/lib_dec/waveadjust_fec_dec.c +++ b/lib_dec/waveadjust_fec_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ACcontextMapping_enc.c b/lib_enc/ACcontextMapping_enc.c index a608db5ea2d160df5e64f5a470337dddfcdc720b..fc960d8a08ddaca9e0149fe7d54e590aec7f5ac7 100644 --- a/lib_enc/ACcontextMapping_enc.c +++ b/lib_enc/ACcontextMapping_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/FEC_enc.c b/lib_enc/FEC_enc.c index 9b753c97b82ac3fb515fe8a241d42c34fe2dd742..84081d8796e239c47122c036328f5894c490363b 100644 --- a/lib_enc/FEC_enc.c +++ b/lib_enc/FEC_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/SNR_calc.c b/lib_enc/SNR_calc.c index 6078062ea35c5a15155853f81e25650a0f93f4e0..39bd603d6d61f56f0df67507d97943992f64c1c5 100644 --- a/lib_enc/SNR_calc.c +++ b/lib_enc/SNR_calc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/acelp_core_enc.c b/lib_enc/acelp_core_enc.c index e9c3d78869022c3faf4022ff14687a9addbb2650..3a951e796ef3a15fd8dfb6bb2026207357de52c8 100644 --- a/lib_enc/acelp_core_enc.c +++ b/lib_enc/acelp_core_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other @@ -372,7 +372,11 @@ ivas_error acelp_core_enc( if ( !nelp_mode && !ppp_mode ) { +#ifdef NONBE_FIX_GSC_BSTR + config_acelp1( ENC, st->total_brate, st->core_brate, st->core, st->extl, st->extl_brate, st->L_frame, st->GSC_noisy_speech, &( st->acelp_cfg ), hBstr->nb_bits_tot, st->coder_type, st->inactive_coder_type_flag, tc_subfr, 0, &nb_bits, unbits, st->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st->idchan, st->active_cnt, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode ); +#else config_acelp1( ENC, st->total_brate, st->core_brate, st->core, st->extl, st->extl_brate, st->L_frame, st->GSC_noisy_speech, &( st->acelp_cfg ), hBstr->nb_bits_tot, st->coder_type, tc_subfr, 0, &nb_bits, unbits, st->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st->idchan, st->active_cnt, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode ); +#endif } /*-----------------------------------------------------------------* @@ -495,7 +499,11 @@ ivas_error acelp_core_enc( { tc_classif_enc( st->L_frame, &tc_subfr, &position, attack_flag, st->pitch[0], res ); +#ifdef NONBE_FIX_GSC_BSTR + config_acelp1( ENC, st->total_brate, st->core_brate, st->core, st->extl, st->extl_brate, st->L_frame, -1, &( st->acelp_cfg ), hBstr->nb_bits_tot, st->coder_type, st->inactive_coder_type_flag, tc_subfr, 1, NULL, unbits, st->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st->idchan, st->active_cnt, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode ); +#else config_acelp1( ENC, st->total_brate, st->core_brate, st->core, st->extl, st->extl_brate, st->L_frame, -1, &( st->acelp_cfg ), hBstr->nb_bits_tot, st->coder_type, tc_subfr, 1, NULL, unbits, st->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st->idchan, st->active_cnt, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode ); +#endif } /*---------------------------------------------------------------* @@ -553,7 +561,11 @@ ivas_error acelp_core_enc( lsf_syn_mem_restore( st, tilt_code_bck, gc_threshold_bck, clip_var_bck, next_force_sf_bck, lsp_new, lsp_mid, clip_var, mem_AR, mem_MA, lsp_new_bck, lsp_mid_bck, Bin_E, Bin_E_old, mem_syn_bck, mem_w0_bck, streaklimit, pstreaklen ); /* Configure ACELP bit allocation */ +#ifdef NONBE_FIX_GSC_BSTR + config_acelp1( ENC, st->total_brate, st->core_brate, st->core, st->extl, st->extl_brate, st->L_frame, -1, &( st->acelp_cfg ), hBstr->nb_bits_tot, st->coder_type, st->inactive_coder_type_flag, tc_subfr, 0, &nb_bits, unbits, 0, &uc_two_stage_flag, 0, 0, st->idchan, st->active_cnt, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode ); +#else config_acelp1( ENC, st->total_brate, st->core_brate, st->core, st->extl, st->extl_brate, st->L_frame, -1, &( st->acelp_cfg ), hBstr->nb_bits_tot, st->coder_type, tc_subfr, 0, &nb_bits, unbits, 0, &uc_two_stage_flag, 0, 0, st->idchan, st->active_cnt, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode ); +#endif /* redo LSF quantization */ lsf_enc( st, lsf_new, lsp_new, lsp_mid, Aq, tdm_low_rate_mode, 0, NULL ); diff --git a/lib_enc/acelp_core_switch_enc.c b/lib_enc/acelp_core_switch_enc.c index efa33ff8a7fde9dbffa0879969b7131316622383..130144e69e808256e430da3fdd865d35dd32bd3a 100644 --- a/lib_enc/acelp_core_switch_enc.c +++ b/lib_enc/acelp_core_switch_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other @@ -132,7 +132,11 @@ void acelp_core_switch_enc( * Excitation encoding *----------------------------------------------------------------*/ +#ifdef NONBE_FIX_GSC_BSTR + config_acelp1( ENC, st->total_brate, cbrate, st->core, -1, -1, st->last_L_frame, -1, &( st->acelp_cfg ), hBstr->nb_bits_tot, GENERIC, st->inactive_coder_type_flag, -1, -1, &j, &i, st->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st->idchan, st->active_cnt, 0 /*tdm_Pitch_reuse_flag*/, 0, 0 /*GSC_IVAS_mode*/ ); +#else config_acelp1( ENC, st->total_brate, cbrate, st->core, -1, -1, st->last_L_frame, -1, &( st->acelp_cfg ), hBstr->nb_bits_tot, GENERIC, -1, -1, &j, &i, st->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st->idchan, st->active_cnt, 0 /*tdm_Pitch_reuse_flag*/, 0, 0 /*GSC_IVAS_mode*/ ); +#endif encod_gen_voic_core_switch( st, st->last_L_frame, inp, Aq, A, T_op, st->voicing, exc, cbrate ); diff --git a/lib_enc/acelp_enc_util.c b/lib_enc/acelp_enc_util.c index fdbc3a8b09a852ee66ee615018bb8c223f6ef96c..1043767fa3bf3827121f68cec91d55e249bb49e4 100644 --- a/lib_enc/acelp_enc_util.c +++ b/lib_enc/acelp_enc_util.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/amr_wb_enc.c b/lib_enc/amr_wb_enc.c index e921698e5aaa5270cd4aa4be7ebf0d70ad09e115..3ae31680c9f88d099b6a17ef7242722af85434be 100644 --- a/lib_enc/amr_wb_enc.c +++ b/lib_enc/amr_wb_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other @@ -310,7 +310,13 @@ void amr_wb_enc( { st->fd_cng_reset_flag = 0; } + +#ifdef NONBE_1211_DTX_BR_SWITCHING + dtx( st, -1, -1, vad_flag_dtx, inp ); +#else dtx( st, -1, vad_flag_dtx, inp ); +#endif + /*----------------------------------------------------------------* * Noise energy down-ward update and total noise energy estimation * Long-term energies and relative frame energy updates diff --git a/lib_enc/analy_lp.c b/lib_enc/analy_lp.c index c0541e78fd6eae201ecbea101d63e7079bb63392..94fcdd58e16fefa5f348df587e1c4fc1ee0d347b 100644 --- a/lib_enc/analy_lp.c +++ b/lib_enc/analy_lp.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/analy_sp.c b/lib_enc/analy_sp.c index 4a4bcb357dbee5cea73b8d7e8ef9c8d2ee026674..514364df515b76ee448cdb4eae6d2662a29eee3d 100644 --- a/lib_enc/analy_sp.c +++ b/lib_enc/analy_sp.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ari_enc.c b/lib_enc/ari_enc.c index 405b3a8994a0a0973f7b90289695e837c14736de..4f37653b37cfc062c68364d6fc216182598f6530 100644 --- a/lib_enc/ari_enc.c +++ b/lib_enc/ari_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ari_hm_enc.c b/lib_enc/ari_hm_enc.c index 46a093369b1e057027af064ed29322e02c694845..56722df065eddebd846f3625ac4cd9fb00d92d74 100644 --- a/lib_enc/ari_hm_enc.c +++ b/lib_enc/ari_hm_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/arith_coder_enc.c b/lib_enc/arith_coder_enc.c index 546e7f07ab8715eab463dcaeb22893a923a8cfc4..c45ba7781788703f501e048acf16d0b895e9d75b 100644 --- a/lib_enc/arith_coder_enc.c +++ b/lib_enc/arith_coder_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/avq_cod.c b/lib_enc/avq_cod.c index 78900b554cc8c5e1999657ddc66ec81921fd2cdd..4994329ea82ea93fa603caa3b400e750200f8b4c 100644 --- a/lib_enc/avq_cod.c +++ b/lib_enc/avq_cod.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/bass_psfilter_enc.c b/lib_enc/bass_psfilter_enc.c index 582ed3f22e59f51af0cd40a6311c6ebdd5efa89b..137d012670f5d2def4d13995e29cf0d27154c26f 100644 --- a/lib_enc/bass_psfilter_enc.c +++ b/lib_enc/bass_psfilter_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/bw_detect.c b/lib_enc/bw_detect.c index 121754e1dcd339c75a99d7fd76fd416faebfa8ae..75a97feafbc664d7d44e5e60eb43a3e0aaa20d68 100644 --- a/lib_enc/bw_detect.c +++ b/lib_enc/bw_detect.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/cng_enc.c b/lib_enc/cng_enc.c index d99e05395cdf31327fa0fe282053cf6444d59770..b0d114be73388db5be052d912fd18c5d097fc725 100644 --- a/lib_enc/cng_enc.c +++ b/lib_enc/cng_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/cod2t32.c b/lib_enc/cod2t32.c index 0d5e548bef1df7cf005da2677c37f1eab951dc06..571601a7469e2032f6f986c8141c42050c931e3e 100644 --- a/lib_enc/cod2t32.c +++ b/lib_enc/cod2t32.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/cod4t64.c b/lib_enc/cod4t64.c index 79d1814f5cced5c37f656129cf1a968f6d2211bc..b9dd6c876377e9a0834025c84191073143d2a519 100644 --- a/lib_enc/cod4t64.c +++ b/lib_enc/cod4t64.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/cod4t64_fast.c b/lib_enc/cod4t64_fast.c index 9c16758d477e454ea61e6d0953491903a106fbbf..2ae06acc31a0989b33e0f06a594a04929c4b9aea 100644 --- a/lib_enc/cod4t64_fast.c +++ b/lib_enc/cod4t64_fast.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/cod_ace.c b/lib_enc/cod_ace.c index 7a5c605d9ac852710e955c2f328869392bb19140..538986c49f6aa62546281db09abc3a80dd747d57 100644 --- a/lib_enc/cod_ace.c +++ b/lib_enc/cod_ace.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/cod_tcx.c b/lib_enc/cod_tcx.c index 4b6e9f9eea4aced49fa3cc798f6e9870b1eacb6b..89282ed8b47aeaef18e90e2af78df893a5eb9bb7 100644 --- a/lib_enc/cod_tcx.c +++ b/lib_enc/cod_tcx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/cod_uv.c b/lib_enc/cod_uv.c index 2c22ed41888c8eff36115f44e10960347de4636b..bd34de2a21e7dcc82b1ea5c8637b369cd112e83a 100644 --- a/lib_enc/cod_uv.c +++ b/lib_enc/cod_uv.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/comvad_decision.c b/lib_enc/comvad_decision.c index 240f1754ba362a86053983f2b56b3e74249b35d7..e681ef96f07dc7127881f698ffb8c74e801972b6 100644 --- a/lib_enc/comvad_decision.c +++ b/lib_enc/comvad_decision.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/cor_shif.c b/lib_enc/cor_shif.c index 67c11d4b9030aa32b52e9d4a14da4bd87bf5bb6c..fb0a0fe61b3850246f3982fa1ebe909a8e02864c 100644 --- a/lib_enc/cor_shif.c +++ b/lib_enc/cor_shif.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/core_enc_2div.c b/lib_enc/core_enc_2div.c index faa7af35878234b35a4b3376964cf2453105d2e7..9a129c9313de3b01ec7be27742d098dd8d532a37 100644 --- a/lib_enc/core_enc_2div.c +++ b/lib_enc/core_enc_2div.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/core_enc_init.c b/lib_enc/core_enc_init.c index b307e0361d600db278ef3c98645bd9164670b172..4b4bd0c4fe4834c7bfc9e381ee673b241ed77f3a 100644 --- a/lib_enc/core_enc_init.c +++ b/lib_enc/core_enc_init.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other @@ -64,7 +64,10 @@ static void init_modes( Encoder_State *st, const int32_t last_total_brate ); void init_coder_ace_plus( Encoder_State *st, /* i : Encoder state */ const int32_t last_total_brate, /* i : last total bitrate */ - const int16_t MCT_flag /* i : hMCT handle allocated (1) or not (0) */ +#ifdef FIX_920_IGF_INIT_ERROR + const int32_t igf_brate, /* i : IGF configuration bitrate */ +#endif + const int16_t MCT_flag /* i : hMCT handle allocated (1) or not (0) */ ) { TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc; @@ -154,7 +157,11 @@ void init_coder_ace_plus( if ( st->igf && st->hIGFEnc != NULL ) { +#ifdef FIX_920_IGF_INIT_ERROR + IGFEncSetMode( st->hIGFEnc, igf_brate, st->bwidth, st->element_mode, st->rf_mode ); +#else IGFEncSetMode( st->hIGFEnc, st->total_brate, st->bwidth, st->element_mode, st->rf_mode ); +#endif } else if ( st->hIGFEnc != NULL ) { diff --git a/lib_enc/core_enc_ol.c b/lib_enc/core_enc_ol.c index e83fd598b49d8fefef3ea02b4602d357a8f57c8f..2a2b78bc13733a4902d03c447e78d9d199936bb7 100644 --- a/lib_enc/core_enc_ol.c +++ b/lib_enc/core_enc_ol.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/core_enc_reconf.c b/lib_enc/core_enc_reconf.c index 9dffda02072d3b831cdaa35a5e45063a34efe09b..e2d5005f73ad37a72e592ae27e2aed4d0b0d20f7 100644 --- a/lib_enc/core_enc_reconf.c +++ b/lib_enc/core_enc_reconf.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/core_enc_switch.c b/lib_enc/core_enc_switch.c index 44952cc1daab965d2eea5d3264c8e6889c5ab396..25266ed4c499e4a9a62f457363fa9053135d0f7a 100644 --- a/lib_enc/core_enc_switch.c +++ b/lib_enc/core_enc_switch.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other @@ -152,7 +152,11 @@ void core_coder_mode_switch( else { st->igf = getIgfPresent( st->element_mode, st->total_brate, st->bwidth, st->rf_mode ); +#ifdef FIX_920_IGF_INIT_ERROR + init_coder_ace_plus( st, last_total_brate, st->total_brate, MCT_flag ); +#else init_coder_ace_plus( st, last_total_brate, MCT_flag ); +#endif } if ( st->igf && st->hBWE_TD != NULL ) diff --git a/lib_enc/core_enc_updt.c b/lib_enc/core_enc_updt.c index acb498824c780860ac6647706eb9172bee2d7004..7969f00f101c57ef39e2e2d2bb18053541295e85 100644 --- a/lib_enc/core_enc_updt.c +++ b/lib_enc/core_enc_updt.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/core_switching_enc.c b/lib_enc/core_switching_enc.c index e964f33c089dbbecaccc55b103afb6b244d4e537..808cb2628cb6b1a48c06d9cbf5a295b0be1464f4 100644 --- a/lib_enc/core_switching_enc.c +++ b/lib_enc/core_switching_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/corr_xh.c b/lib_enc/corr_xh.c index c317878e176ed0201c62e570eec19b115e82fd2a..482704392678149293202c0c8f3aea9ce6e25a66 100644 --- a/lib_enc/corr_xh.c +++ b/lib_enc/corr_xh.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/decision_matrix_enc.c b/lib_enc/decision_matrix_enc.c index e2587fbe0d77637c7fed883c7add26711d1d7e4f..08c2e36b6a0acce11a0469a574ee3d80e8d5604e 100644 --- a/lib_enc/decision_matrix_enc.c +++ b/lib_enc/decision_matrix_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/detect_transient.c b/lib_enc/detect_transient.c index 0b73a12e680ad0e469d78579a0302ef418b7c37a..178d8975c55e1955e9a4fa1e7cf4ab4fbd399f86 100644 --- a/lib_enc/detect_transient.c +++ b/lib_enc/detect_transient.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/diffcod.c b/lib_enc/diffcod.c index fd6646c48abc263f7b7e4094798576f2b183b5b4..8d623d7043524ad05d46eb7c4246606622facd68 100644 --- a/lib_enc/diffcod.c +++ b/lib_enc/diffcod.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/dtx.c b/lib_enc/dtx.c index 606c8aaaf98b43a1c02e08ffd97254f3f5bc7b4d..77a7ad04043eb51039351c804bd282a7641c5e5c 100644 --- a/lib_enc/dtx.c +++ b/lib_enc/dtx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other @@ -65,6 +65,11 @@ #define MAX_BRATE_DTX_EVS ACELP_24k40 /* maximum bitrate to which the default DTX is applied in EVS; otherwise DTX is applied only in silence */ #define MAX_BRATE_DTX_IVAS IVAS_80k /* maximum bitrate to which the default DTX is applied in IVAS; otherwise DTX is applied only in silence */ + +#ifdef NONBE_FIX_1277_EVS_DTX_HIGH_RATE_THRESHOLD +#define DTX_THR_EVS 15 /* lp_noise threshold for DTX at higher bitrates in EVS */ // ToDo: to be removed once EVS is CR fixed +#endif + /*-------------------------------------------------------------------* * Local function prototypes *-------------------------------------------------------------------*/ @@ -78,7 +83,10 @@ static void update_SID_cnt( DTX_ENC_HANDLE hDtxEnc, const int32_t core_brate, co *-------------------------------------------------------------------*/ void dtx( - Encoder_State *st, /* i/o: encoder state structure */ + Encoder_State *st, /* i/o: encoder state structure */ +#ifdef NONBE_1211_DTX_BR_SWITCHING + const int32_t last_ivas_total_brate, /* i : last IVAS total bitrate */ +#endif const int32_t ivas_total_brate, /* i : IVAS total bitrate */ const int16_t vad, /* i : VAD flag for DTX */ const float speech[] /* i : Pointer to the speech frame */ @@ -87,17 +95,48 @@ void dtx( float alpha; DTX_ENC_HANDLE hDtxEnc = st->hDtxEnc; int16_t last_br_cng_flag, last_br_flag, br_dtx_flag; +#ifdef NONBE_1211_DTX_BR_SWITCHING + int32_t total_brate_ref; +#ifdef NONBE_FIX_1277_EVS_DTX_HIGH_RATE_THRESHOLD + int16_t dtx_thr; + + dtx_thr = DTX_THR; + if ( st->element_mode == EVS_MONO ) + { + dtx_thr = DTX_THR_EVS; // ToDo: to be removed once EVS is CR fixed + } +#endif + + total_brate_ref = st->total_brate; +#endif + if ( st->dtx_sce_sba != 0 ) { last_br_cng_flag = 1; last_br_flag = 1; +#ifndef NONBE_1211_DTX_BR_SWITCHING br_dtx_flag = 1; +#endif } else { +#ifdef NONBE_FIX_1277_EVS_DTX_HIGH_RATE_THRESHOLD + last_br_cng_flag = st->last_total_brate_cng <= MAX_BRATE_DTX_EVS || st->lp_noise < dtx_thr || ( st->element_mode == IVAS_SCE && st->last_total_brate_cng <= MAX_BRATE_DTX_IVAS ); +#else last_br_cng_flag = st->last_total_brate_cng <= MAX_BRATE_DTX_EVS || st->lp_noise < 15 || ( st->element_mode == IVAS_SCE && st->last_total_brate_cng <= MAX_BRATE_DTX_IVAS ); +#endif +#ifdef NONBE_1211_DTX_BR_SWITCHING + last_br_flag = ( st->element_mode == EVS_MONO && st->last_total_brate <= MAX_BRATE_DTX_EVS ) || + ( st->element_mode != EVS_MONO && last_ivas_total_brate <= MAX_BRATE_DTX_IVAS ) || +#ifdef NONBE_FIX_1277_EVS_DTX_HIGH_RATE_THRESHOLD + st->lp_noise < dtx_thr; +#else + st->lp_noise < 15; +#endif +#else last_br_flag = st->last_total_brate <= MAX_BRATE_DTX_EVS || st->lp_noise < 15 || ( st->element_mode == IVAS_SCE && st->last_total_brate <= MAX_BRATE_DTX_IVAS ); br_dtx_flag = 0; +#endif } /* Initialization */ @@ -127,6 +166,7 @@ void dtx( last_br_cng_flag ) { st->total_brate = st->last_total_brate_cng; + if ( !( st->total_brate == ACELP_7k20 && st->Opt_SC_VBR ) ) { st->Opt_SC_VBR = 0; @@ -170,11 +210,18 @@ void dtx( * Select SID or FRAME_NO_DATA frame if DTX is enabled *------------------------------------------------------------------------*/ +#ifdef NONBE_1211_DTX_BR_SWITCHING + br_dtx_flag = 1; +#endif if ( st->dtx_sce_sba == 0 ) { br_dtx_flag = ( st->element_mode == EVS_MONO && st->total_brate <= MAX_BRATE_DTX_EVS ) || ( st->element_mode != EVS_MONO && ivas_total_brate <= MAX_BRATE_DTX_IVAS ) || +#ifdef NONBE_FIX_1277_EVS_DTX_HIGH_RATE_THRESHOLD + st->lp_noise < dtx_thr; +#else st->lp_noise < 15; +#endif } if ( st->Opt_DTX_ON && vad == 0 && @@ -258,6 +305,12 @@ void dtx( reset_indices_enc( st->hBstr, st->hBstr->nb_ind_tot ); } } +#ifdef NONBE_1211_DTX_BR_SWITCHING + else if ( st->element_mode != EVS_MONO ) + { + st->total_brate = total_brate_ref; + } +#endif /*------------------------------------------------------------------------* * Reset counters when in active frame (neither SID nor FRAME_NO_DATA frame) diff --git a/lib_enc/enc_acelp.c b/lib_enc/enc_acelp.c index 5e1401828ee47f4b0e12dd039618c975df37c6f2..9d085392f513d7055e7c4570d98f3a21e4267b9c 100644 --- a/lib_enc/enc_acelp.c +++ b/lib_enc/enc_acelp.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/enc_acelp_tcx_main.c b/lib_enc/enc_acelp_tcx_main.c index 5c549b23d292dd2abf57ab228e0b4b1e8463285b..6ede9b9bf18b75a00fcb10e70c379746b0da5e6a 100644 --- a/lib_enc/enc_acelp_tcx_main.c +++ b/lib_enc/enc_acelp_tcx_main.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/enc_acelpx.c b/lib_enc/enc_acelpx.c index c72f2fa1c340fa90d49b0d1cc2195bc3a2048f3f..9a86027503235cc30dd3535faa330a611e54c0fb 100644 --- a/lib_enc/enc_acelpx.c +++ b/lib_enc/enc_acelpx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/enc_amr_wb.c b/lib_enc/enc_amr_wb.c index bb09c0886b61dacb0d13955adab692aba4ad0d67..65b0df913f0635b720ba4ee6feec35ba89cc6458 100644 --- a/lib_enc/enc_amr_wb.c +++ b/lib_enc/enc_amr_wb.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/enc_gain.c b/lib_enc/enc_gain.c index 607c36f6e9a75843068355dfd4f8a88cecaa5abb..b78ed92f2abbd7f915a1889e88791f9607b8ed19 100644 --- a/lib_enc/enc_gain.c +++ b/lib_enc/enc_gain.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/enc_gen_voic.c b/lib_enc/enc_gen_voic.c index 4c78b484c0a220df9d0afc91326e66b0e182e0fe..0d2713b0f9fb9c4990355e0e11035c14707109e3 100644 --- a/lib_enc/enc_gen_voic.c +++ b/lib_enc/enc_gen_voic.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other @@ -255,7 +255,11 @@ void encod_gen_voic( * Transform-domain contribution (inactive frames) *-----------------------------------------------------------------*/ +#ifdef NONBE_FIX_GSC_BSTR + if ( !st->inactive_coder_type_flag && st->coder_type == INACTIVE ) +#else if ( st->total_brate >= MAX_GSC_INACTIVE_BRATE && st->coder_type == INACTIVE ) +#endif { transf_cdbk_enc( st, 0, i_subfr, cn, exc, p_Aq, p_Aw, h1, xn, xn2, y1, y2, Es_pred, &gain_pit, gain_code, g_corr, clip_gain, &gain_preQ, code_preQ, unbits ); } diff --git a/lib_enc/enc_gen_voic_rf.c b/lib_enc/enc_gen_voic_rf.c index 7ceece404da285849d32cbfc147a3558881f379f..d8ca8af3139e4a9a6a72e5cf0d341180d884fa11 100644 --- a/lib_enc/enc_gen_voic_rf.c +++ b/lib_enc/enc_gen_voic_rf.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/enc_higher_acelp.c b/lib_enc/enc_higher_acelp.c index 5610bdfe4e9add94f1660bc404b11e07e06b868f..67704ce34d6dcf4386152bf26e74a89daf550c28 100644 --- a/lib_enc/enc_higher_acelp.c +++ b/lib_enc/enc_higher_acelp.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/enc_nelp.c b/lib_enc/enc_nelp.c index 7d828208b281e6a6f73dfcc9d180501ef239ea20..b05d69f71236ad1c693836c1bd92ac557a8139d6 100644 --- a/lib_enc/enc_nelp.c +++ b/lib_enc/enc_nelp.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/enc_pit_exc.c b/lib_enc/enc_pit_exc.c index eba203b6a6ac5464268fd2ce09c7293534e5e380..a911b6159c3eba65769364f345520a6512b8640b 100644 --- a/lib_enc/enc_pit_exc.c +++ b/lib_enc/enc_pit_exc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/enc_ppp.c b/lib_enc/enc_ppp.c index b5b7e45483e8b28f3f3570055cc187b40dcf99e4..6dbe237ad434dca5c53992de03add7ed1580f463 100644 --- a/lib_enc/enc_ppp.c +++ b/lib_enc/enc_ppp.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/enc_prm.c b/lib_enc/enc_prm.c index 61bfbf2f0feef1024e848d5c305613782eefb4e6..fb1a338ee6b9e86dc0cd728e9f0e59f42624e6b1 100644 --- a/lib_enc/enc_prm.c +++ b/lib_enc/enc_prm.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/enc_tran.c b/lib_enc/enc_tran.c index d713584fa7e9010d71159a2949014ee8d281b5dd..162a1e262b5ee9c2af6a196ae7177b7e965a2907 100644 --- a/lib_enc/enc_tran.c +++ b/lib_enc/enc_tran.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/enc_uv.c b/lib_enc/enc_uv.c index f6c17e410c324bc14e8f44f47ec48faa0f71a062..9c5962502e282eb6b94725fa484860eabc948877 100644 --- a/lib_enc/enc_uv.c +++ b/lib_enc/enc_uv.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/energy.c b/lib_enc/energy.c index f9cb7f6a2ef0630dde1f920d00e8dce2628d15cb..271adb7b78dbd9cdccabe576a32153c2a29d3297 100644 --- a/lib_enc/energy.c +++ b/lib_enc/energy.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/eval_pit_contr.c b/lib_enc/eval_pit_contr.c index 6779afe2af48506c87b82f9814b84bed0cda7f6b..b0529d5b1717025fc4d735ac101a13ba1ee32ac7 100644 --- a/lib_enc/eval_pit_contr.c +++ b/lib_enc/eval_pit_contr.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/evs_enc.c b/lib_enc/evs_enc.c index a515fd03b0e2b91ef53042b7a3343c3c62af33c6..d22e3d3fdd5eb1241e4c01362189bcb32f1d7ce2 100644 --- a/lib_enc/evs_enc.c +++ b/lib_enc/evs_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ext_sig_ana.c b/lib_enc/ext_sig_ana.c index 16f0b1732ac03b0f80096128d6d605ad6c3c4a4b..f963f4a49a52835d9c83cbcf00a2a87af52a3791 100644 --- a/lib_enc/ext_sig_ana.c +++ b/lib_enc/ext_sig_ana.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/fd_cng_enc.c b/lib_enc/fd_cng_enc.c index 407121d59dbd77cdc6efc706cc95bb27ca568b02..da13d3deb865684a8068f023e6dd7e2bdf06d08a 100644 --- a/lib_enc/fd_cng_enc.c +++ b/lib_enc/fd_cng_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/find_tar.c b/lib_enc/find_tar.c index 008fb17cb98a18b443a770d0726b92a815eda841..08139b381b8332162e8a9fe65df4a6008b100cd5 100644 --- a/lib_enc/find_tar.c +++ b/lib_enc/find_tar.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/find_tilt.c b/lib_enc/find_tilt.c index bdfac0569b07e2b49833e9c2f607e4ca8d30b314..641f54293a2d47196d02f0604120fb2648feb552 100644 --- a/lib_enc/find_tilt.c +++ b/lib_enc/find_tilt.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/find_uv.c b/lib_enc/find_uv.c index a80971880fbd3857c3975c5c7099e215912b2635..a4ea9a74519c68fee172d3344977bd20e78e58d6 100644 --- a/lib_enc/find_uv.c +++ b/lib_enc/find_uv.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/find_wsp.c b/lib_enc/find_wsp.c index e08918a4de10e9e9d9f25d965e6552c75f0382bc..27026e421c3ece659cee11fd9b9fa23adde5a7f7 100644 --- a/lib_enc/find_wsp.c +++ b/lib_enc/find_wsp.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/frame_spec_dif_cor_rate.c b/lib_enc/frame_spec_dif_cor_rate.c index b0ececfb38628c38ab0835e13a7ef35866ce14f7..00027180c3adfab15095486c439594f04a624238 100644 --- a/lib_enc/frame_spec_dif_cor_rate.c +++ b/lib_enc/frame_spec_dif_cor_rate.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/gain_enc.c b/lib_enc/gain_enc.c index b114b34c7f171e6b0abe91b9029f6cd25788bc8d..d85e062fba73dc0e6a16cfdb8d390a51f52f597c 100644 --- a/lib_enc/gain_enc.c +++ b/lib_enc/gain_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/gaus_enc.c b/lib_enc/gaus_enc.c index 79b480e5161a0719f12d8d7ea4ce5c1b0e8966a1..83327c98d56c0842ca7f672efb6a3456811592d1 100644 --- a/lib_enc/gaus_enc.c +++ b/lib_enc/gaus_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/gp_clip.c b/lib_enc/gp_clip.c index 43394c2bf58b3246402d851a9aa08c709cdb13e3..7c0ddaf735dbb38ce401472c918caa19f11f0ef8 100644 --- a/lib_enc/gp_clip.c +++ b/lib_enc/gp_clip.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/gs_enc.c b/lib_enc/gs_enc.c index 97f5426e355f8817148ef18eb6242c21623164d1..376dcb6ee46e630e64f6dcf6dbe67e63ce27781a 100644 --- a/lib_enc/gs_enc.c +++ b/lib_enc/gs_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/guided_plc_enc.c b/lib_enc/guided_plc_enc.c index cb5e84683d5aa3163c1ddb7df3b609887b308d20..85104e7698f505f8a9dd6fffd4bdc69bb8b76758 100644 --- a/lib_enc/guided_plc_enc.c +++ b/lib_enc/guided_plc_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/hf_cod_amrwb.c b/lib_enc/hf_cod_amrwb.c index c9cbba3cd472f8e96075cd6e0d14aa379eaeefa1..bf0f5ac75388fdff058ac4df8f6fefa6fa34e255 100644 --- a/lib_enc/hf_cod_amrwb.c +++ b/lib_enc/hf_cod_amrwb.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/hq_classifier_enc.c b/lib_enc/hq_classifier_enc.c index ae30c473e0923b2ff9c7860d3933a80ff581b688..7dfada3fb6d8a59679504004b8e3ebd37c96cf66 100644 --- a/lib_enc/hq_classifier_enc.c +++ b/lib_enc/hq_classifier_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/hq_core_enc.c b/lib_enc/hq_core_enc.c index 3fb39b535a79f8da69a5188083fd2c870b3787a4..3e3a836d8dcdc1701215814696452315a8b01883 100644 --- a/lib_enc/hq_core_enc.c +++ b/lib_enc/hq_core_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/hq_env_enc.c b/lib_enc/hq_env_enc.c index 4d57dde16475b0e99e55c941ad181c891e474b5f..9da38660b699b04d207fbe5a3ad9c52ba491f633 100644 --- a/lib_enc/hq_env_enc.c +++ b/lib_enc/hq_env_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/hq_hr_enc.c b/lib_enc/hq_hr_enc.c index d815295a4df1246a9609dce1976cab538a173ddc..12314bcc8d66913f3bd9e755c65c81913f295d59 100644 --- a/lib_enc/hq_hr_enc.c +++ b/lib_enc/hq_hr_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/hq_lr_enc.c b/lib_enc/hq_lr_enc.c index 343a31713f1c1f49c56b75bb98a54906de482c62..65b5dd4ef5b3a37deeae00c7a6a382ad2ae8f416 100644 --- a/lib_enc/hq_lr_enc.c +++ b/lib_enc/hq_lr_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/hvq_enc.c b/lib_enc/hvq_enc.c index 42ac52cc3c56533b0b026a6dc38421271ad97189..0b80c717b2c03ad9ac2155bf0b7ac627388b4dc6 100644 --- a/lib_enc/hvq_enc.c +++ b/lib_enc/hvq_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/igf_enc.c b/lib_enc/igf_enc.c index 93306733c27478d5310497d5d42a2077c5b72542..e4eb47f95030bfe9c38a0181e4bb5ab40c32296b 100644 --- a/lib_enc/igf_enc.c +++ b/lib_enc/igf_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/igf_scf_enc.c b/lib_enc/igf_scf_enc.c index f893a8b315d3f193d09b62c10f8f7c7ec029a0c4..1d6ef9397ed08f2768bb9ef81ced4a1849d635b7 100644 --- a/lib_enc/igf_scf_enc.c +++ b/lib_enc/igf_scf_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/init_enc.c b/lib_enc/init_enc.c index e722d835000c205114718aa84c7e05bae70d5b32..9734864a64c03f87b3e2c3764f9e9f04a6e4cac6 100644 --- a/lib_enc/init_enc.c +++ b/lib_enc/init_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other @@ -825,7 +825,11 @@ ivas_error init_encoder( set_f( st->totalNoise_increase_hist, 0.f, TOTALNOISE_HIST_SIZE ); st->totalNoise_increase_len = 0; +#ifdef FIX_920_IGF_INIT_ERROR + init_coder_ace_plus( st, st->last_total_brate, igf_brate, 0 /* initialization value */ ); +#else init_coder_ace_plus( st, st->last_total_brate, 0 /* initialization value */ ); +#endif /*-----------------------------------------------------------------* * FD-CNG encoder diff --git a/lib_enc/inov_enc.c b/lib_enc/inov_enc.c index fedc98e103c2d67a90e3f5567d7ca4712d144b90..a61573eaa234f260ba7001e36ef951255397ce11 100644 --- a/lib_enc/inov_enc.c +++ b/lib_enc/inov_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/isf_enc_amr_wb.c b/lib_enc/isf_enc_amr_wb.c index c10ee6288b030dc738eb341571d36dd3111ed839..40e0c54c8e8a690bef6e03522ccd27bb9b59df8a 100644 --- a/lib_enc/isf_enc_amr_wb.c +++ b/lib_enc/isf_enc_amr_wb.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_agc_enc.c b/lib_enc/ivas_agc_enc.c index 09db68d7d6d03f5cd7fd215ccfebd53066d57ec6..856ef66e5c41390521e7e0afc2e2527498475ad2 100644 --- a/lib_enc/ivas_agc_enc.c +++ b/lib_enc/ivas_agc_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_core_enc.c b/lib_enc/ivas_core_enc.c index a4be246987841f3f42009104027389d048adf2ff..ef58b618016619f3263a13885ed50c986ecd9eb7 100644 --- a/lib_enc/ivas_core_enc.c +++ b/lib_enc/ivas_core_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_core_pre_proc.c b/lib_enc/ivas_core_pre_proc.c index 129177c0c11edd78c053a2817d7dcc0801ec2282..026a9ff3fade05c39989e28e3bbe0189a6994b70 100644 --- a/lib_enc/ivas_core_pre_proc.c +++ b/lib_enc/ivas_core_pre_proc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other @@ -209,7 +209,11 @@ ivas_error pre_proc_ivas( } else if ( st->total_brate > MAX_GSC_INACTIVE_BRATE && ( ( st->vad_flag == 0 && st->bwidth >= SWB && st->max_bwidth >= SWB ) || ( st->localVAD == 0 && ( st->bwidth <= WB || st->max_bwidth <= WB ) ) ) ) { +#ifdef NONBE_FIX_GSC_BSTR + /* inactive frames will be coded by AVQ technology (exceptionally it can be later rewritten to GSC technology in ivas_combined_format_brate_sanity()) */ +#else /* inactive frames will be coded by AVQ technology */ +#endif st->coder_type = INACTIVE; } diff --git a/lib_enc/ivas_core_pre_proc_front.c b/lib_enc/ivas_core_pre_proc_front.c index 79003e2974ddd75406a280fbde8991e85da03be3..ea740b6af174dfb8ab604458bd09b374b3ff12b6 100644 --- a/lib_enc/ivas_core_pre_proc_front.c +++ b/lib_enc/ivas_core_pre_proc_front.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other @@ -112,7 +112,10 @@ ivas_error pre_proc_front_ivas( const int16_t front_vad_dtx_flag, /* i : front-VAD DTX flag to overwrite VAD decision*/ const IVAS_FORMAT ivas_format, /* i : IVAS format */ const int16_t MCT_flag, /* i : hMCT handle allocated (1) or not (0) */ - const int32_t ivas_total_brate /* i : IVAS total bitrate - for setting the DTX */ +#ifdef NONBE_1211_DTX_BR_SWITCHING + const int32_t last_ivas_total_brate, /* i : last IVAS total bitrate */ +#endif + const int32_t ivas_total_brate /* i : IVAS total bitrate - for setting the DTX */ #ifdef DEBUG_MODE_INFO , const int16_t ch_idx @@ -227,7 +230,9 @@ ivas_error pre_proc_front_ivas( } #ifdef DEBUG_MODE_INFO + if ( !( hCPE != NULL && hCPE->hStereoTD != NULL && ch_idx > 0 ) ) { + /* for TD stereo only write out first channel. The existence of a second channel can vary, this is just easier to handle */ int16_t tmp_dmx_in[L_FRAME48k]; mvr2s( signal_in - NS2SA( st->input_Fs, ACELP_LOOK_NS ), tmp_dmx_in, input_frame ); dbgwrite( tmp_dmx_in, sizeof( int16_t ), input_frame, 1, strcat( fname( debug_dir, "ivas_input_dmx", 0, ch_idx + 1, ENC ), ".pcm" ) ); @@ -456,6 +461,16 @@ ivas_error pre_proc_front_ivas( st->vad_flag = wb_vad( st, fr_bands, &i, &i, &i, &snr_sum_he, &localVAD_HE_SAD, &( st->flag_noisy_speech_snr ), NULL, NULL, -1000.0f, -1000.0f ); +#ifdef DEBUG_FORCE_DIR + if ( st->force_dir[0] != '\0' ) + { + dbgread( &st->vad_flag, sizeof( int16_t ), 1, fname( st->force_dir, "force_vad_flag.enf", -1, -1, -1 ) ); + } + else + { + dbgwrite( &st->vad_flag, sizeof( int16_t ), 1, 1, "res/force_vad_flag.enf" ); + } +#endif if ( force_front_vad == 1 || front_vad_flag == 1 ) { @@ -504,6 +519,17 @@ ivas_error pre_proc_front_ivas( st->bwidth = hCPE->hCoreCoder[0]->bwidth; } +#ifdef DEBUG_FORCE_DIR + if ( st->force_dir[0] != '\0' ) + { + dbgread( &st->bwidth, sizeof( int16_t ), 1, fname( st->force_dir, "force_bwidth.enf", -1, -1, -1 ) ); + } + else + { + dbgwrite( &st->bwidth, sizeof( int16_t ), 1, 1, "res/force_bwidth.enf" ); + } +#endif + /*----------------------------------------------------------------* * Noise energy down-ward update and total noise energy estimation * Long-term energies and relative frame energy updates @@ -559,7 +585,11 @@ ivas_error pre_proc_front_ivas( st->cng_type = LP_CNG; } +#ifdef NONBE_1211_DTX_BR_SWITCHING + dtx( st, last_ivas_total_brate, ivas_total_brate, *vad_flag_dtx, inp_12k8 ); +#else dtx( st, ivas_total_brate, *vad_flag_dtx, inp_12k8 ); +#endif if ( hCPE != NULL && hCPE->hStereoDft != NULL && st->core_brate == SID_2k40 ) { @@ -704,6 +734,19 @@ ivas_error pre_proc_front_ivas( st->coder_type = find_uv( st, pitch_fr, voicing_fr, inp_12k8, ee, &dE1X, corr_shift, *relE, Etot, hp_E, &flag_spitch, last_core_orig, hStereoClassif ); +#ifdef DEBUG_FORCE_DIR + if ( st->force_dir[0] != '\0' ) + { + dbgread( &st->coder_type, sizeof( int16_t ), 1, fname( st->force_dir, "force_coder_type.enf", -1, -1, -1 ) ); + dbgread( &st->coder_type_raw, sizeof( int16_t ), 1, fname( st->force_dir, "force_coder_type_raw.enf", -1, -1, -1 ) ); + } + else + { + dbgwrite( &st->coder_type, sizeof( int16_t ), 1, 1, "res/force_coder_type.enf" ); + dbgwrite( &st->coder_type_raw, sizeof( int16_t ), 1, 1, "res/force_coder_type_raw.enf" ); + } +#endif + /*-----------------------------------------------------------------* * channel aware mode configuration * *-----------------------------------------------------------------*/ @@ -740,6 +783,17 @@ ivas_error pre_proc_front_ivas( smc_dec = ivas_smc_gmm( st, hStereoClassif, localVAD_HE_SAD, Etot, lsp_new, *cor_map_sum, epsP, PS, non_staX, *relE, &high_lpn_flag, flag_spitch ); +#ifdef DEBUG_FORCE_DIR + if ( st->force_dir[0] != '\0' ) + { + dbgread( &smc_dec, sizeof( int16_t ), 1, fname( st->force_dir, "force_smc_dec_loc1.enf", -1, -1, -1 ) ); + } + else + { + dbgwrite( &smc_dec, sizeof( int16_t ), 1, 1, "res/force_smc_dec_loc1.enf" ); + } +#endif + #ifdef DEBUGGING if ( st->idchan == 0 ) { @@ -848,6 +902,23 @@ ivas_error pre_proc_front_ivas( ivas_smc_mode_selection( st, element_brate, smc_dec, *relE, Etot, attack_flag, inp_12k8, S_map, flag_spitch ); } +#ifdef DEBUG_FORCE_DIR + if ( st->force_dir[0] != '\0' ) + { + dbgread( &smc_dec, sizeof( int16_t ), 1, fname( st->force_dir, "force_smc_dec_loc2.enf", -1, -1, -1 ) ); + dbgread( &st->sp_aud_decision0, sizeof( int16_t ), 1, fname( st->force_dir, "force_sp_aud_decision0.enf", -1, -1, -1 ) ); + dbgread( &st->sp_aud_decision1, sizeof( int16_t ), 1, fname( st->force_dir, "force_sp_aud_decision1.enf", -1, -1, -1 ) ); + dbgread( &st->sp_aud_decision2, sizeof( int16_t ), 1, fname( st->force_dir, "force_sp_aud_decision2.enf", -1, -1, -1 ) ); + } + else + { + dbgwrite( &smc_dec, sizeof( int16_t ), 1, 1, "res/force_smc_dec_loc2.enf" ); + dbgwrite( &st->sp_aud_decision0, sizeof( int16_t ), 1, 1, "res/force_sp_aud_decision0.enf" ); + dbgwrite( &st->sp_aud_decision1, sizeof( int16_t ), 1, 1, "res/force_sp_aud_decision1.enf" ); + dbgwrite( &st->sp_aud_decision2, sizeof( int16_t ), 1, 1, "res/force_sp_aud_decision2.enf" ); + } +#endif + /*----------------------------------------------------------------* * Final VAD correction (when HE-SAD is used instead of the normal VAD, * rewrite the VAD flag by VAD flag with DTX hangover for further processing) diff --git a/lib_enc/ivas_corecoder_enc_reconfig.c b/lib_enc/ivas_corecoder_enc_reconfig.c index 8619b1122b4e6544edd0557fe2d2ccb8003fb0a5..81cf44c35ed34774fb8a4f4361f826500d774da5 100644 --- a/lib_enc/ivas_corecoder_enc_reconfig.c +++ b/lib_enc/ivas_corecoder_enc_reconfig.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_cpe_enc.c b/lib_enc/ivas_cpe_enc.c index 441d8c16db9f2f40a8c2739649169034168c2dad..e6ed38c70d8729fa4b5219f50cd6dfa7c7515d75 100644 --- a/lib_enc/ivas_cpe_enc.c +++ b/lib_enc/ivas_cpe_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other @@ -160,6 +160,9 @@ ivas_error ivas_cpe_enc( #ifdef DEBUGGING sts[n]->force = hEncoderConfig->force; sts[n]->id_element = cpe_id + st_ivas->nSCE; +#ifdef DEBUG_FORCE_DIR + sts[n]->force_dir = hEncoderConfig->force_dir; +#endif #endif } @@ -178,6 +181,19 @@ ivas_error ivas_cpe_enc( { hCPE->element_mode = select_stereo_mode( hCPE, ivas_format ); } +#ifdef DEBUG_FORCE_DIR + else + { + if ( hCPE->hCoreCoder[0]->force_dir[0] != '\0' ) + { + dbgread( &hCPE->element_mode, sizeof( int16_t ), 1, fname( hCPE->hCoreCoder[0]->force_dir, "force_element_mode.enf", -1, -1, -1 ) ); + } + else + { + dbgwrite( &hCPE->element_mode, sizeof( int16_t ), 1, 1, "res/force_element_mode.enf" ); + } + } +#endif stereo_mode_combined_format_enc( st_ivas, hCPE ); @@ -485,7 +501,11 @@ ivas_error ivas_cpe_enc( error = pre_proc_front_ivas( NULL, hCPE, hCPE->element_brate, nb_bits_metadata, input_frame, n, old_inp_12k8[n], old_inp_16k[n], &ener[n], &relE[n], A[n], Aw[n], epsP[n], lsp_new[n], lsp_mid[n], &vad_hover_flag[n], &attack_flag[n], realBuffer[n], imagBuffer[n], old_wsp[n], pitch_fr[n], voicing_fr[n], &loc_harm[n], &cor_map_sum[n], &vad_flag_dtx[n], enerBuffer[n], +#ifdef NONBE_1211_DTX_BR_SWITCHING + fft_buff[n], A[0], lsp_new[0], currFlatness[n], tdm_ratio_idx, fr_bands, Etot_LR, lf_E, localVAD_HE_SAD, band_energies_LR, 0, st_ivas->hSpar != NULL ? st_ivas->hSpar->front_vad_flag : 0, 0, 0, ivas_format, st_ivas->hMCT != NULL, st_ivas->hEncoderConfig->last_ivas_total_brate, ivas_total_brate +#else fft_buff[n], A[0], lsp_new[0], currFlatness[n], tdm_ratio_idx, fr_bands, Etot_LR, lf_E, localVAD_HE_SAD, band_energies_LR, 0, st_ivas->hSpar != NULL ? st_ivas->hSpar->front_vad_flag : 0, 0, 0, ivas_format, st_ivas->hMCT != NULL, ivas_total_brate +#endif #ifdef DEBUG_MODE_INFO , ( st_ivas->nSCE + ( cpe_id * CPE_CHANNELS ) + n ) diff --git a/lib_enc/ivas_decision_matrix_enc.c b/lib_enc/ivas_decision_matrix_enc.c index 084efb6a500dc34b714dc678d82e4ffb19ade741..578c89d25cfbbe1d0375319e00b3ffab701eb6bf 100644 --- a/lib_enc/ivas_decision_matrix_enc.c +++ b/lib_enc/ivas_decision_matrix_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other @@ -166,6 +166,17 @@ void ivas_decision_matrix_enc( } } +#ifdef DEBUG_FORCE_DIR + if ( st->force_dir[0] != '\0' ) + { + dbgread( &st->core, sizeof( int16_t ), 1, fname( st->force_dir, "force_core_loc1.enf", -1, -1, -1 ) ); + } + else + { + dbgwrite( &st->core, sizeof( int16_t ), 1, 1, "res/force_core_loc1.enf" ); + } +#endif + /* do not allow TD stereo ACELP core -> DFT stereo TCX core switching as it is on the WC complexity path */ if ( ( ( st->last_core == ACELP_CORE && last_element_mode == IVAS_CPE_TD && st->element_mode == IVAS_CPE_DFT ) || ( st->tdm_LRTD_flag == 1 && st->total_brate <= IVAS_16k4 ) ) && st->core == TCX_20_CORE && st->total_brate <= MAX_ACELP_BRATE ) /* Override TCX in case of LRTD && primary channel has low bitrate*/ { @@ -246,6 +257,17 @@ void ivas_decision_matrix_enc( st->core = TCX_20_CORE; } +#ifdef DEBUG_FORCE_DIR + if ( st->force_dir[0] != '\0' ) + { + dbgread( &st->core, sizeof( int16_t ), 1, fname( st->force_dir, "force_core_loc2.enf", -1, -1, -1 ) ); + } + else + { + dbgwrite( &st->core, sizeof( int16_t ), 1, 1, "res/force_core_loc2.enf" ); + } +#endif + /*---------------------------------------------------------------------* * Select ACELP and GSC extension layer *---------------------------------------------------------------------*/ @@ -280,6 +302,19 @@ void ivas_decision_matrix_enc( } } } + +#ifdef DEBUG_FORCE_DIR + if ( st->force_dir[0] != '\0' ) + { + dbgread( &st->extl, sizeof( int16_t ), 1, fname( st->force_dir, "force_extl.enf", -1, -1, -1 ) ); + dbgread( &st->extl_brate, sizeof( int32_t ), 1, fname( st->force_dir, "force_extl_brate.enf", -1, -1, -1 ) ); + } + else + { + dbgwrite( &st->extl, sizeof( int16_t ), 1, 1, "res/force_extl.enf" ); + dbgwrite( &st->extl_brate, sizeof( int32_t ), 1, 1, "res/force_extl_brate.enf" ); + } +#endif } /* SWB and FB */ @@ -342,6 +377,19 @@ void ivas_decision_matrix_enc( st->extl_brate = 0; } +#ifdef DEBUG_FORCE_DIR + if ( st->force_dir[0] != '\0' ) + { + dbgread( &st->extl, sizeof( int16_t ), 1, fname( st->force_dir, "force_extl.enf", -1, -1, -1 ) ); + dbgread( &st->extl_brate, sizeof( int32_t ), 1, fname( st->force_dir, "force_extl_brate.enf", -1, -1, -1 ) ); + } + else + { + dbgwrite( &st->extl, sizeof( int16_t ), 1, 1, "res/force_extl.enf" ); + dbgwrite( &st->extl_brate, sizeof( int32_t ), 1, 1, "res/force_extl_brate.enf" ); + } +#endif + /* set IC-BWE bitrate */ if ( st->element_mode == IVAS_CPE_TD && ( st->idchan == 0 ) && !st->tdm_LRTD_flag ) { diff --git a/lib_enc/ivas_dirac_enc.c b/lib_enc/ivas_dirac_enc.c index 5c2493ec191313a2748f563b6e1f90b3a9667e2a..65037a091a94873c135d71aefab58b81f78bc09f 100644 --- a/lib_enc/ivas_dirac_enc.c +++ b/lib_enc/ivas_dirac_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_enc.c b/lib_enc/ivas_enc.c index c52a722c20303c1e1875296c1a9dd7e033979728..e73f131fa3827c8178e20d4dff0dddab8c52775a 100644 --- a/lib_enc/ivas_enc.c +++ b/lib_enc/ivas_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_enc_cov_handler.c b/lib_enc/ivas_enc_cov_handler.c index 0eb88dcc1684ac09aac11dcdee19479829275477..bf666e17ad39e03fa1a818540170c3d02a9f63d3 100644 --- a/lib_enc/ivas_enc_cov_handler.c +++ b/lib_enc/ivas_enc_cov_handler.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_entropy_coder.c b/lib_enc/ivas_entropy_coder.c index 0157711bdd92a8269f9be3c99503220938c935af..06ba3d0233c887bd0a27838bd72bdc7b82295c4a 100644 --- a/lib_enc/ivas_entropy_coder.c +++ b/lib_enc/ivas_entropy_coder.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_front_vad.c b/lib_enc/ivas_front_vad.c index 52c3b8cd45c474b9a11bfaf6107b8a3d20717616..4c2742a5252c776f214992fe94ac407164417b21 100644 --- a/lib_enc/ivas_front_vad.c +++ b/lib_enc/ivas_front_vad.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other @@ -423,7 +423,12 @@ ivas_error front_vad_spar( noise_est_down( fr_bands[0], hFrontVad->hNoiseEst->bckr, tmpN, tmpE, st->min_band, st->max_band, &hFrontVad->hNoiseEst->totalNoise, Etot[0], &hFrontVad->hNoiseEst->Etot_last, &hFrontVad->hNoiseEst->Etot_v_h2 ); corr_shift = correlation_shift( hFrontVad->hNoiseEst->totalNoise ); +#ifdef NONBE_1211_DTX_BR_SWITCHING + dtx( st, hEncoderConfig->last_ivas_total_brate, hEncoderConfig->ivas_total_brate, vad_flag_dtx[0], inp_12k8 ); +#else dtx( st, hEncoderConfig->ivas_total_brate, vad_flag_dtx[0], inp_12k8 ); +#endif + /* linear prediction analysis */ alw_pitch_lag_12k8[0] = st->old_pitch_la; alw_pitch_lag_12k8[1] = st->old_pitch_la; diff --git a/lib_enc/ivas_init_enc.c b/lib_enc/ivas_init_enc.c index e1aa7113af96c8a2d7062645bc5c5ed829a07c42..497281f3705fb7b3c7c28351aad80229a7cb00ee 100644 --- a/lib_enc/ivas_init_enc.c +++ b/lib_enc/ivas_init_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other @@ -276,6 +276,9 @@ void copy_encoder_config( #ifdef DEBUGGING st->force = st_ivas->hEncoderConfig->force; +#ifdef DEBUG_FORCE_DIR + st->force_dir = st_ivas->hEncoderConfig->force_dir; +#endif #endif st->element_mode = st_ivas->hEncoderConfig->element_mode_init; diff --git a/lib_enc/ivas_ism_dtx_enc.c b/lib_enc/ivas_ism_dtx_enc.c index 1277d0d887fccdf689c89162c3f9469db876ee68..7c7114d6ea7f6391a0e286d78dab317fa637f9af 100644 --- a/lib_enc/ivas_ism_dtx_enc.c +++ b/lib_enc/ivas_ism_dtx_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other @@ -155,7 +155,11 @@ int16_t ivas_ism_dtx_enc( ( nchan_ism == 2 && ivas_total_brate <= IVAS_48k ) || ( nchan_ism == 3 && ivas_total_brate <= IVAS_80k ) || ( nchan_ism == 4 && ivas_total_brate <= IVAS_96k ) || +#ifdef NONBE_FIX_1277_EVS_DTX_HIGH_RATE_THRESHOLD + lp_noise_max < DTX_THR ) ) +#else lp_noise_max < 15 ) ) +#endif { dtx_flag = 0; } diff --git a/lib_enc/ivas_ism_enc.c b/lib_enc/ivas_ism_enc.c index bc7ced57ffc6597380739021f11b7162f9e53fdf..f45fe6f51d380c69183b7e162480633227fdd4bf 100644 --- a/lib_enc/ivas_ism_enc.c +++ b/lib_enc/ivas_ism_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other @@ -150,6 +150,9 @@ ivas_error ivas_ism_enc( #ifdef DEBUGGING st->force = st_ivas->hEncoderConfig->force; st->id_element = sce_id; +#ifdef DEBUG_FORCE_DIR + st->force_dir = st_ivas->hEncoderConfig->force_dir; +#endif #endif /*---------------------------------------------------------------* @@ -168,6 +171,10 @@ ivas_error ivas_ism_enc( st->bits_frame_nominal = (int16_t) ( ( hSCE->element_brate / FRAMES_PER_SEC ) - ISM_NB_BITS_METADATA_NOMINAL ); +#ifdef DEBUG_MODE_INFO + dbgwrite( &st->element_mode, sizeof( int16_t ), 1, input_frame, fname( debug_dir, "element_mode", 0, st->id_element, ENC ) ); +#endif + /*----------------------------------------------------------------* * Front Pre-processing *----------------------------------------------------------------*/ @@ -175,7 +182,11 @@ ivas_error ivas_ism_enc( error = pre_proc_front_ivas( hSCE, NULL, hSCE->element_brate, nb_bits_metadata[sce_id], input_frame, 0, old_inp_12k8[sce_id][0], old_inp_16k[sce_id][0], &ener[sce_id][0], &relE[sce_id][0], A[sce_id][0], Aw[sce_id][0], epsP[sce_id][0], lsp_new[sce_id][0], lsp_mid[sce_id][0], &vad_hover_flag[sce_id][0], &attack_flag[sce_id][0], realBuffer[sce_id][0], imagBuffer[sce_id][0], old_wsp[sce_id][0], pitch_fr[sce_id][0], voicing_fr[sce_id][0], &loc_harm[sce_id][0], &cor_map_sum[sce_id][0], &vad_flag_dtx[sce_id][0], enerBuffer[sce_id][0], +#ifdef NONBE_1211_DTX_BR_SWITCHING + fft_buff[sce_id][0], A[sce_id][0], lsp_new[sce_id][0], currFlatness[0], 0, fr_bands, Etot_LR, lf_E, localVAD_HE_SAD, NULL, 0, 0, 0, 0, ISM_FORMAT, 0, st_ivas->hEncoderConfig->last_ivas_total_brate, st_ivas->hEncoderConfig->ivas_total_brate +#else fft_buff[sce_id][0], A[sce_id][0], lsp_new[sce_id][0], currFlatness[0], 0, fr_bands, Etot_LR, lf_E, localVAD_HE_SAD, NULL, 0, 0, 0, 0, ISM_FORMAT, 0, st_ivas->hEncoderConfig->ivas_total_brate +#endif #ifdef DEBUG_MODE_INFO , st->id_element @@ -420,7 +431,21 @@ ivas_error ivas_ism_enc( } } } + + for ( sce_id = 0; sce_id < nchan_transport_ism; sce_id++ ) + { + float tmpF; + int16_t id; + + st = st_ivas->hSCE[sce_id]->hCoreCoder[0]; + id = st->id_element; + + tmpF = st->element_brate / 1000.0f; + dbgwrite( &tmpF, sizeof( float ), 1, input_frame, fname( debug_dir, "element_brate", 0, id, ENC ) ); + } + #endif + pop_wmops(); return error; diff --git a/lib_enc/ivas_ism_metadata_enc.c b/lib_enc/ivas_ism_metadata_enc.c index 849b7957ae86da6e1152d7fa864db63aac05e6a7..c2b047ebb6c522628b1e0aafa2d51a6625c13bb0 100644 --- a/lib_enc/ivas_ism_metadata_enc.c +++ b/lib_enc/ivas_ism_metadata_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other @@ -277,7 +277,9 @@ ivas_error ivas_ism_metadata_enc( } else if ( hIsmMeta[ch]->ism_md_fec_cnt_enc == ISM_MD_FEC_CNT_MAX ) { - +#ifdef NONBE_1273_ISM_METADATA_COUNTER + hIsmMeta[ch]->ism_md_fec_cnt_enc = 0; +#endif lowrate_metadata_flag[ch] = 1; hIsmMeta[ch]->position_angle.angle1_diff_cnt = ISM_FEC_MAX; @@ -297,6 +299,18 @@ ivas_error ivas_ism_metadata_enc( } } +#ifdef DEBUG_FORCE_DIR + if ( hSCE[0]->hCoreCoder[0]->force_dir[0] != '\0' ) + { + dbgread( ism_imp, sizeof( int16_t ), nchan_ism, fname( hSCE[0]->hCoreCoder[0]->force_dir, "force_ism_imp.enf", -1, -1, -1 ) ); + } + else + { + dbgwrite( ism_imp, sizeof( int16_t ), nchan_ism, 1, "res/force_ism_imp.enf" ); + } +#endif + + /*----------------------------------------------------------------* * Write ISM common signaling *----------------------------------------------------------------*/ @@ -555,6 +569,9 @@ ivas_error ivas_ism_metadata_enc( if ( hIsmMeta[ch]->ism_metadata_flag == 0 ) { hIsmMeta[ch]->ism_md_fec_cnt_enc++; +#ifdef NONBE_1273_ISM_METADATA_COUNTER + hIsmMeta[ch]->ism_md_fec_cnt_enc = min( hIsmMeta[ch]->ism_md_fec_cnt_enc, ISM_MD_FEC_CNT_MAX ); +#endif } else { @@ -699,6 +716,9 @@ ivas_error ivas_ism_metadata_enc( if ( hIsmMeta[ch]->ism_metadata_flag == 0 ) { hIsmMeta[ch]->ism_md_fec_cnt_enc++; +#ifdef NONBE_1273_ISM_METADATA_COUNTER + hIsmMeta[ch]->ism_md_fec_cnt_enc = min( hIsmMeta[ch]->ism_md_fec_cnt_enc, ISM_MD_FEC_CNT_MAX ); +#endif } else { diff --git a/lib_enc/ivas_ism_param_enc.c b/lib_enc/ivas_ism_param_enc.c index 6492c537addd1e9b55199059bb34289696fb7d31..ed2692373b03e42048d17ddf1c5a5c6243a39fb5 100644 --- a/lib_enc/ivas_ism_param_enc.c +++ b/lib_enc/ivas_ism_param_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_lfe_enc.c b/lib_enc/ivas_lfe_enc.c index c77b77290b99135b840bf21ce410b6f564eb082a..f4852c82f20b8928f5e91b4a0c46ad0be95b4bd5 100644 --- a/lib_enc/ivas_lfe_enc.c +++ b/lib_enc/ivas_lfe_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_masa_enc.c b/lib_enc/ivas_masa_enc.c index 6019ee03cccf5a706ca89db9d1a332801f0d7b39..062d2e2a44b0a69fddbcbf473d69ea413c985ead 100644 --- a/lib_enc/ivas_masa_enc.c +++ b/lib_enc/ivas_masa_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_mc_param_enc.c b/lib_enc/ivas_mc_param_enc.c index fba29756654186cdef4c5166f822b1b4b99865b3..820b9614b7ba9582e084eb8087be60978cc15495 100644 --- a/lib_enc/ivas_mc_param_enc.c +++ b/lib_enc/ivas_mc_param_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other @@ -62,7 +62,6 @@ static void ivas_param_mc_parameter_quantizer( const float *x, const int16_t L, static void ivas_param_mc_transient_detection( PARAM_MC_ENC_HANDLE hParamMC, TRAN_DET_HANDLE hTranDet, int16_t *bAttackPresent, int16_t *attackIdx ); -static void ivas_param_mc_enc_find_icc_map( PARAM_MC_ENC_HANDLE hParamMC, float Cx_sum[][PARAM_MC_MAX_TRANSPORT_CHANS][PARAM_MC_MAX_TRANSPORT_CHANS], float Cy_sum[][MAX_CICP_CHANNELS][MAX_CICP_CHANNELS], float ILD_q[PARAM_MC_MAX_PARAMETER_BANDS][PARAM_MC_SZ_ILD_MAP], const int16_t nchan_input, const int16_t nchan_transport ); static void ivas_param_mc_quantize_iccs( PARAM_MC_ENC_HANDLE hParamMC, float Cy[MAX_CICP_CHANNELS][MAX_CICP_CHANNELS], const int16_t freq_idx, const int16_t nchan_input, int16_t *ICC_idx_out ); @@ -86,7 +85,7 @@ ivas_error ivas_param_mc_enc_open( Encoder_Struct *st_ivas /* i/o: IVAS encoder handle */ ) { - int16_t i, k, l; + int16_t i; IVAS_FB_CFG *fb_cfg; PARAM_MC_ENC_HANDLE hParamMC; uint16_t config_index; @@ -152,24 +151,7 @@ ivas_error ivas_param_mc_enc_open( } /* open/init parameter coding */ - ivas_param_mc_metadata_open( mc_input_setup, hParamMC->lfe_index, ivas_total_brate, &hParamMC->hMetadataPMC ); - - /* init icc index states */ - for ( i = 0; i < PARAM_MC_PARAMETER_FRAMES; i++ ) - { - set_s( hParamMC->icc_map_index[i], -1, PARAM_MC_SZ_ICC_MAP ); - - for ( l = 0; l < hParamMC->hMetadataPMC.icc_mapping_conf->icc_map_size_lfe; l++ ) - { - for ( k = 0; k < hParamMC->hMetadataPMC.icc_map_size_full; k++ ) - { - if ( hParamMC->hMetadataPMC.icc_mapping[i][l][0] == hParamMC->hMetadataPMC.icc_map_full[0][k] && hParamMC->hMetadataPMC.icc_mapping[i][l][1] == hParamMC->hMetadataPMC.icc_map_full[1][k] ) - { - hParamMC->icc_map_index[i][l] = k; - } - } - } - } + ivas_param_mc_metadata_open( mc_input_setup, ivas_total_brate, &hParamMC->hMetadataPMC ); /* Band Grouping */ if ( hParamMC->hMetadataPMC.num_parameter_bands == 20 ) @@ -235,7 +217,7 @@ ivas_error ivas_param_mc_enc_reconfig( Encoder_Struct *st_ivas /* i/o: IVAS encoder handle */ ) { - int16_t i, k, l; + int16_t i; PARAM_MC_ENC_HANDLE hParamMC; uint16_t config_index; MC_LS_SETUP mc_input_setup; @@ -280,38 +262,8 @@ ivas_error ivas_param_mc_enc_reconfig( /* get dmx factors */ hParamMC->dmx_factors = ivas_param_mc_conf[config_index].dmx_fac; - /* deallocate the full icc map, gets newly allocated in the metadata open function */ - for ( i = 0; i < 2; i++ ) - { -#ifdef DEBUGGING - assert( hParamMC->hMetadataPMC.icc_map_full[i] != NULL ); -#endif - if ( hParamMC->hMetadataPMC.icc_map_full[i] != NULL ) - { - free( hParamMC->hMetadataPMC.icc_map_full[i] ); - hParamMC->hMetadataPMC.icc_map_full[i] = NULL; - } - } - /* open/init parameter coding */ - ivas_param_mc_metadata_open( mc_input_setup, hParamMC->lfe_index, ivas_total_brate, &hParamMC->hMetadataPMC ); - - /* init icc index states */ - for ( i = 0; i < PARAM_MC_PARAMETER_FRAMES; i++ ) - { - set_s( hParamMC->icc_map_index[i], -1, PARAM_MC_SZ_ICC_MAP ); - - for ( l = 0; l < hParamMC->hMetadataPMC.icc_mapping_conf->icc_map_size_lfe; l++ ) - { - for ( k = 0; k < hParamMC->hMetadataPMC.icc_map_size_full; k++ ) - { - if ( hParamMC->hMetadataPMC.icc_mapping[i][l][0] == hParamMC->hMetadataPMC.icc_map_full[0][k] && hParamMC->hMetadataPMC.icc_mapping[i][l][1] == hParamMC->hMetadataPMC.icc_map_full[1][k] ) - { - hParamMC->icc_map_index[i][l] = k; - } - } - } - } + ivas_param_mc_metadata_open( mc_input_setup, ivas_total_brate, &hParamMC->hMetadataPMC ); /* Band Grouping */ if ( hParamMC->hMetadataPMC.num_parameter_bands == 20 ) @@ -375,8 +327,6 @@ void ivas_param_mc_enc_close( return; } - ivas_param_mc_metadata_close( &( *hParamMC )->hMetadataPMC ); - ivas_FB_mixer_close( &( *hParamMC )->hFbMixer, sampling_rate, 0 ); free( ( *hParamMC ) ); @@ -510,16 +460,6 @@ void ivas_param_mc_enc( ivas_param_mc_quantize_ilds( hParamMC, Cy_sum[k], Cx_sum[k], k, nchan_inp, st_ivas->nchan_transport, ILD_idx, ILD_q[k] ); } - /* get icc map */ - if ( hParamMC->hMetadataPMC.flag_use_adaptive_icc_map == 1 ) - { - ivas_param_mc_enc_find_icc_map( hParamMC, Cx_sum, Cy_sum, ILD_q, nchan_inp, st_ivas->nchan_transport ); - } - else - { - ivas_param_mc_default_icc_map( hParamMC->hMetadataPMC.icc_mapping_conf, hParamMC->hMetadataPMC.icc_mapping[hParamMC->hMetadataPMC.param_frame_idx] ); - } - /* ICC parameter quantization */ for ( k = 0; k < hParamMC->hMetadataPMC.nbands_coded; k += band_step ) { @@ -987,230 +927,6 @@ static void ivas_param_mc_param_est_enc( } -/*------------------------------------------------------------------------- - * ivas_param_mc_enc_find_icc_map() - * - * decide which ICCs out of all possible ICCs should be sent - *------------------------------------------------------------------------*/ - -static void ivas_param_mc_enc_find_icc_map( - PARAM_MC_ENC_HANDLE hParamMC, /* i/o: Parametric MC encoder handle */ - float Cx_sum[][PARAM_MC_MAX_TRANSPORT_CHANS][PARAM_MC_MAX_TRANSPORT_CHANS], /* i : Covariance matrix for the downmixed frame */ - float Cy_sum[][MAX_CICP_CHANNELS][MAX_CICP_CHANNELS], /* i : Covariance matrix for the original frame */ - float ILD_q[PARAM_MC_MAX_PARAMETER_BANDS][PARAM_MC_SZ_ILD_MAP], /* i : quantized ILDs */ - const int16_t nchan_input, /* i : number of input channels */ - const int16_t nchan_transport /* i : number of transport channels */ -) -{ - float Cproto_band[MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS]; - float Cx_band[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; - float mat_mult_buffer1[MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS]; - float mapped_error[55]; /* max number of possible mappings for 7.1+4 */ - int16_t icc_map_index[PARAM_MC_SZ_ICC_MAP]; - int16_t map_idx; - float *sorted_error_desc[PARAM_MC_SZ_ICC_MAP]; - int16_t cur_param_band, k, m, i; - int16_t bandstep; - int16_t last_element, el; - int16_t num_parameter_bands; - int16_t ch_idx1, ch_idx2; - int16_t icc_map_size; - int16_t icc_map_size_wo_lfe; - float Nrqq[MAX_OUTPUT_CHANNELS]; - float a[MAX_OUTPUT_CHANNELS]; - float Cy_band[MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS]; - - /* Initialisations */ - num_parameter_bands = hParamMC->hMetadataPMC.nbands_coded; - bandstep = hParamMC->hMetadataPMC.bAttackPresent ? 2 : 1; - set_f( mapped_error, 0.0f, 55 ); - set_s( icc_map_index, -1, PARAM_MC_SZ_ICC_MAP ); - icc_map_size_wo_lfe = hParamMC->hMetadataPMC.icc_mapping_conf->icc_map_size_wo_lfe; - icc_map_size = hParamMC->hMetadataPMC.icc_mapping_conf->icc_map_size_lfe; - - set_zero( Cy_band, nchan_input * nchan_input ); - - /* Estimate the target covariance like in the decoder using the - * already available qunantised ICLDs */ - for ( cur_param_band = 0; cur_param_band < num_parameter_bands; cur_param_band += bandstep ) - { - if ( hParamMC->hMetadataPMC.bAttackPresent || hParamMC->hMetadataPMC.coding_band_mapping[cur_param_band] == hParamMC->hMetadataPMC.param_frame_idx ) - { - /* transfer Cx_sum band to columnwise matrix */ - for ( ch_idx1 = 0; ch_idx1 < nchan_transport; ++ch_idx1 ) - { - for ( ch_idx2 = 0; ch_idx2 < nchan_transport; ++ch_idx2 ) - { - Cx_band[ch_idx1 + nchan_transport * ch_idx2] = Cx_sum[cur_param_band][ch_idx1][ch_idx2]; - } - } - - /* get estimated Cy from Cx and proto matrix */ - matrix_product( hParamMC->dmx_factors, nchan_input, nchan_transport, 0, - Cx_band, nchan_transport, nchan_transport, 0, - mat_mult_buffer1 ); - - matrix_product( mat_mult_buffer1, nchan_input, nchan_transport, 0, - hParamMC->dmx_factors, nchan_input, nchan_transport, 1, - Cproto_band ); - - set_zero( Nrqq, MAX_OUTPUT_CHANNELS ); - - /*get back Nrg*/ - for ( k = 0; k < nchan_input; k++ ) - { - float ref_ener = 0.0f; - int16_t ref_channel_cnt; - int16_t ref_channel_idx; - - for ( ref_channel_cnt = 0; ref_channel_cnt < hParamMC->hMetadataPMC.ild_mapping_conf->num_ref_channels[k]; ref_channel_cnt++ ) - { - ref_channel_idx = hParamMC->hMetadataPMC.ild_mapping_conf->ref_channel_idx[k][ref_channel_cnt]; - ref_ener += Cx_band[ref_channel_idx + ref_channel_idx * nchan_transport]; - } - Nrqq[hParamMC->hMetadataPMC.ild_mapping_conf->ild_index[k]] = powf( 10, ILD_q[cur_param_band][k] / 10.0f ) * hParamMC->hMetadataPMC.ild_factors[k] * ref_ener; - } - - /* apply quantized ICLDs in the estimated covariance */ - for ( k = 0; k < nchan_input; k++ ) - { - a[k] = sqrtf( Nrqq[k] ) / ( sqrtf( Cproto_band[k + nchan_input * k] ) + EPSILON ); - v_multc( Cproto_band + k * nchan_input, a[k], Cproto_band + k * nchan_input, nchan_input ); - } - - for ( k = 0; k < nchan_input; k++ ) - { - int16_t l; - float *Cyp = Cproto_band + k; - float ap = a[k]; - - for ( l = 0; l < nchan_input; l++ ) - { - ( *Cyp ) *= ap; - Cyp += nchan_input; - } - } - - /* transfer Cy_sum band to columnwise matrix */ - for ( ch_idx1 = 0; ch_idx1 < nchan_input; ++ch_idx1 ) - { - for ( ch_idx2 = 0; ch_idx2 < nchan_input; ++ch_idx2 ) - { - Cy_band[ch_idx1 + nchan_transport * ch_idx2] = Cy_sum[cur_param_band][ch_idx1][ch_idx2]; - } - } - - /* apply quantized ICLDs on the input covariance */ - for ( k = 0; k < nchan_input; k++ ) - { - a[k] = sqrtf( Nrqq[k] ) / ( sqrtf( Cy_band[k + nchan_input * k] ) + EPSILON ); - v_multc( Cy_band + k * nchan_input, a[k], Cy_band + k * nchan_input, nchan_input ); - } - - for ( k = 0; k < nchan_input; k++ ) - { - int16_t l; - float *Cyp = Cy_band + k; - float ap = a[k]; - - for ( l = 0; l < nchan_input; l++ ) - { - ( *Cyp ) *= ap; - Cyp += nchan_input; - } - } - - /* for all possible mappings, get the cumulated error between estimated and real Cy */ - for ( map_idx = 0; map_idx < hParamMC->hMetadataPMC.icc_map_size_full - 1; map_idx++ ) - { - int16_t idx0 = hParamMC->hMetadataPMC.icc_map_full[0][map_idx]; - int16_t idx1 = hParamMC->hMetadataPMC.icc_map_full[1][map_idx]; - mapped_error[map_idx] += fabsf( Cproto_band[idx0 + idx1 * nchan_input] - Cy_band[idx0 + idx1 * nchan_input] ); - } - } - } - - /* put a small bias on the error for the past transmitted indices*/ - if ( !hParamMC->hMetadataPMC.bAttackPresent ) - { - for ( i = 0; i < icc_map_size_wo_lfe; i++ ) - { - mapped_error[hParamMC->icc_map_index[hParamMC->hMetadataPMC.param_frame_idx][i]] *= PARAM_MC_ICC_ERROR_BIAS_FAC; - } - } - - /* get the mappings with the biggest expected errors as those who will be transmitted */ - for ( i = 0; i < hParamMC->hMetadataPMC.icc_map_size_full - 1; i++ ) - { - for ( k = 0; k < icc_map_size_wo_lfe; k++ ) - { - if ( icc_map_index[k] == -1 ) - { - /* not filled yet, take the value */ - icc_map_index[k] = i; - sorted_error_desc[k] = &mapped_error[i]; - break; - } - else if ( mapped_error[i] > *sorted_error_desc[k] ) - { - /* push all others down and insert value here */ - for ( m = icc_map_size_wo_lfe - 1; m >= k + 1; m-- ) - { - icc_map_index[m] = icc_map_index[m - 1]; - sorted_error_desc[m] = sorted_error_desc[m - 1]; - } - icc_map_index[k] = i; - sorted_error_desc[k] = &mapped_error[i]; - break; - } - } - } - - /* the indices in ascending order, simple bubble sort */ - for ( last_element = icc_map_size_wo_lfe - 1; last_element >= 0; last_element-- ) - { - for ( el = 0; el < last_element; el++ ) - { - if ( icc_map_index[el] > icc_map_index[el + 1] ) - { - int16_t swp_el = icc_map_index[el]; - icc_map_index[el] = icc_map_index[el + 1]; - icc_map_index[el + 1] = swp_el; - } - } - } - - /* last icc map element is always the C/LFE icc */ - icc_map_index[icc_map_size - 1] = hParamMC->hMetadataPMC.icc_map_size_full - 1; - - /* create map and map index, map index is sorted in ascending order*/ - if ( hParamMC->hMetadataPMC.bAttackPresent ) - { - for ( k = 0; k < PARAM_MC_PARAMETER_FRAMES; k++ ) - { - for ( i = 0; i < icc_map_size; i++ ) - { - hParamMC->hMetadataPMC.icc_mapping[k][i][0] = hParamMC->hMetadataPMC.icc_map_full[0][icc_map_index[i]]; - hParamMC->hMetadataPMC.icc_mapping[k][i][1] = hParamMC->hMetadataPMC.icc_map_full[1][icc_map_index[i]]; - } - mvs2s( icc_map_index, hParamMC->icc_map_index[k], icc_map_size ); - } - } - else - { - for ( i = 0; i < icc_map_size; i++ ) - { - hParamMC->hMetadataPMC.icc_mapping[hParamMC->hMetadataPMC.param_frame_idx][i][0] = hParamMC->hMetadataPMC.icc_map_full[0][icc_map_index[i]]; - hParamMC->hMetadataPMC.icc_mapping[hParamMC->hMetadataPMC.param_frame_idx][i][1] = hParamMC->hMetadataPMC.icc_map_full[1][icc_map_index[i]]; - } - - mvs2s( icc_map_index, hParamMC->icc_map_index[hParamMC->hMetadataPMC.param_frame_idx], icc_map_size ); - } - - return; -} - - /*------------------------------------------------------------------------- * ivas_param_mc_quantize_ilds() * @@ -1447,8 +1163,8 @@ static void ivas_param_mc_quantize_iccs( /* Reduce set of parameters and quantize them */ for ( k = 0; k < num_iccs_to_code; ++k ) { - tmp_map[0] = hParamMC->hMetadataPMC.icc_mapping[hParamMC->hMetadataPMC.param_frame_idx][k][0]; - tmp_map[1] = hParamMC->hMetadataPMC.icc_mapping[hParamMC->hMetadataPMC.param_frame_idx][k][1]; + tmp_map[0] = hParamMC->hMetadataPMC.icc_mapping_conf->icc_mapping[k][0]; + tmp_map[1] = hParamMC->hMetadataPMC.icc_mapping_conf->icc_mapping[k][1]; ICC_vect[k] = Cy[tmp_map[0]][tmp_map[1]]; } @@ -1626,24 +1342,6 @@ static void ivas_param_mc_write_bs( nbands = hParamMC->hMetadataPMC.nbands_coded / band_step + ( ( hParamMC->hMetadataPMC.nbands_coded % band_step ) ? 1 : 0 ); } - /* Encoding of the ICC mapping done as simple bitmap */ - if ( hParamMC->hMetadataPMC.flag_use_adaptive_icc_map == 1 ) - { - uint16_t *bit_buffer_icc_mapping = &bit_buffer[*bit_pos]; - - for ( i = 0; i < hParamMC->hMetadataPMC.icc_map_size_full - 1; i++ ) - { - bit_buffer_icc_mapping[i] = 0; - } - - for ( i = 0; i < icc_map_size_wo_lfe; i++ ) - { - bit_buffer_icc_mapping[hParamMC->icc_map_index[hParamMC->hMetadataPMC.param_frame_idx][i]] = 1; - } - - *bit_pos += hParamMC->hMetadataPMC.icc_map_size_full - 1; - } - ivas_param_mc_encode_parameter( ICC_idx, &hParamMC->hMetadataPMC, &hParamMC->hMetadataPMC.icc_coding, nbands, band_step, icc_map_size_wo_lfe, icc_map_size, bit_buffer, bit_pos ); diff --git a/lib_enc/ivas_mc_paramupmix_enc.c b/lib_enc/ivas_mc_paramupmix_enc.c index bcb519f078a1977f2acbb88add314290606dbd8b..9a09895562f845421871367c83efa7ce41209205 100644 --- a/lib_enc/ivas_mc_paramupmix_enc.c +++ b/lib_enc/ivas_mc_paramupmix_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_mcmasa_enc.c b/lib_enc/ivas_mcmasa_enc.c index 32833d37b7c8871a5a531062497108fb9cf32969..154fffe3ebe666339495c15d55025f6d11a12026 100644 --- a/lib_enc/ivas_mcmasa_enc.c +++ b/lib_enc/ivas_mcmasa_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_mct_core_enc.c b/lib_enc/ivas_mct_core_enc.c index c20d09e332478f157391d07164bdb5cefda1d9c2..3c345b472d32e3c6c6341a3e8e61f5031bfa4ae3 100644 --- a/lib_enc/ivas_mct_core_enc.c +++ b/lib_enc/ivas_mct_core_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_mct_enc.c b/lib_enc/ivas_mct_enc.c index 59bec00e27aecc4e95ba288577a1637f85e80630..ff248f7f33b58c368bdb57571b0d6bc4452be457 100644 --- a/lib_enc/ivas_mct_enc.c +++ b/lib_enc/ivas_mct_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_mct_enc_mct.c b/lib_enc/ivas_mct_enc_mct.c index c5df49bf02686f1b3b6d51814f2be8c3b8ed6e59..d9401d013a48a4efa1cf508f420795db4bf5e033 100644 --- a/lib_enc/ivas_mct_enc_mct.c +++ b/lib_enc/ivas_mct_enc_mct.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_mdct_core_enc.c b/lib_enc/ivas_mdct_core_enc.c index f37eeb435174b4fb74abb4ba58791a4bf489e915..8085fea23142b6919af287743b44bb40d653b2aa 100644 --- a/lib_enc/ivas_mdct_core_enc.c +++ b/lib_enc/ivas_mdct_core_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_omasa_enc.c b/lib_enc/ivas_omasa_enc.c index 8f0cf13487bb3917d845824ed0ba6142fa904378..0e1cc50e6d883030937be53d2e40e8ed9677ba4c 100644 --- a/lib_enc/ivas_omasa_enc.c +++ b/lib_enc/ivas_omasa_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_osba_enc.c b/lib_enc/ivas_osba_enc.c index dffebcf19d5d66046731cc3f86559ead7a2a6cda..9b4621a64890b05cab38fd4891f754ddb2236208 100644 --- a/lib_enc/ivas_osba_enc.c +++ b/lib_enc/ivas_osba_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other @@ -447,7 +447,9 @@ static void ivas_osba_render_ism_to_sba( int16_t azimuth, elevation; float gains[MAX_INPUT_CHANNELS]; float g1, g2; +#ifndef NONE_BE_FIX_BASOP_1044_OSBA_PRERENDER_MIX_GAINS float output_gain; +#endif int16_t nchan_sba; diff --git a/lib_enc/ivas_pca_enc.c b/lib_enc/ivas_pca_enc.c index f8b4c8e9a6fe7c2e6df9808e25031ae2faef2ff5..ae04ba29b3af6be052bd457dc79b3a687c6d9b04 100644 --- a/lib_enc/ivas_pca_enc.c +++ b/lib_enc/ivas_pca_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_qmetadata_enc.c b/lib_enc/ivas_qmetadata_enc.c index 9a4be19f400a45f4d4901aef892a4aac61a73da0..406466d3fba28907b74dae5d3ee177d7b67f8163 100644 --- a/lib_enc/ivas_qmetadata_enc.c +++ b/lib_enc/ivas_qmetadata_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other @@ -41,7 +41,9 @@ #include "ivas_stat_enc.h" #include "wmc_auto.h" #include "prot.h" - +#ifdef NONBE_1319_M2R_PRECISION_ALIGN +#include "basop_settings.h" +#endif /*-----------------------------------------------------------------------* * Local function prototypes @@ -3772,12 +3774,15 @@ static ivas_error requantize_direction_EC_3( /* gradually increase the bits following the performance of the EC layer*/ int16_t j, k; int16_t use_vq; - int16_t diff, allowed_bits, nbits, last_j; + int16_t diff, allowed_bits, last_j; int16_t no_subframes, start_band; float st[MAX_PARAM_SPATIAL_SUBFRAMES], ct[MAX_PARAM_SPATIAL_SUBFRAMES]; int16_t *bits_dir0; +#ifdef DEBUGGING + int16_t nbits; nbits = 0; +#endif no_subframes = q_direction->cfg.nblocks; start_band = q_direction->cfg.start_band; @@ -3808,7 +3813,9 @@ static ivas_error requantize_direction_EC_3( else /* 2D */ { diff = 0; +#ifdef DEBUGGING nbits = 0; +#endif for ( j = start_band; j < coding_subbands; j++ ) { bits_dir0 = (int16_t *) q_direction->band_data[j].bits_sph_idx; @@ -3834,11 +3841,19 @@ static ivas_error requantize_direction_EC_3( if ( q_direction->cfg.mc_ls_setup != MC_LS_SETUP_INVALID ) { +#ifdef DEBUGGING nbits += truncGR0_chan( azimuth_orig[j], q_direction->band_data[j].azimuth, q_direction->band_data[j].azimuth_index, no_subframes, allowed_bits, st, ct ); +#else + truncGR0_chan( azimuth_orig[j], q_direction->band_data[j].azimuth, q_direction->band_data[j].azimuth_index, no_subframes, allowed_bits, st, ct ); +#endif } else { +#ifdef DEBUGGING nbits += truncGR0( azimuth_orig[j], q_direction->band_data[j].azimuth, q_direction->band_data[j].azimuth_index, no_subframes, allowed_bits, st, ct ); +#else + truncGR0( azimuth_orig[j], q_direction->band_data[j].azimuth, q_direction->band_data[j].azimuth_index, no_subframes, allowed_bits, st, ct ); +#endif } if ( allowed_bits <= no_subframes + 1 ) @@ -3865,7 +3880,11 @@ static ivas_error requantize_direction_EC_3( &q_direction->band_data[j].azimuth_index[k], q_direction->cfg.mc_ls_setup ); q_direction->band_data[j].elevation_index[k] = 0; } +#ifdef DEBUGGING nbits += write_fixed_rate_direction( hMetaData, q_direction, j, no_subframes ); +#else + write_fixed_rate_direction( hMetaData, q_direction, j, no_subframes ); +#endif } } } @@ -6016,10 +6035,17 @@ void ivas_omasa_encode_masa_to_total( float dct_data[MAX_PARAM_SPATIAL_SUBFRAMES * MASA_FREQUENCY_BANDS]; int16_t bits_pos, nb_bits; int16_t n_streams, len_stream; +#ifdef NONBE_1319_M2R_PRECISION_ALIGN + Word32 q_dct_data_fx[MAX_PARAM_SPATIAL_SUBFRAMES * MASA_FREQUENCY_BANDS], + dct_data_tmp_fx[MAX_PARAM_SPATIAL_SUBFRAMES * MASA_FREQUENCY_BANDS]; + + int64_t step_fx; + step_fx = STEP_M2T_FX; +#else #ifdef NON_BE_FIX_BASOP_819_THRESHOLD_MASA2TOTAL int32_t int_tmp; #endif - +#endif #ifdef DEBUG_MODE_QMETADATA static FILE *pF = NULL; static FILE *pF_ratio = NULL; @@ -6128,6 +6154,97 @@ void ivas_omasa_encode_masa_to_total( } /* reconstruct masa2total */ +#ifdef NONBE_1319_M2R_PRECISION_ALIGN + q_dct_data_fx[0] = (Word32) ( ( step_fx * q_idx[0] ) >> 6 ); // Q25 + for ( i = 1; i < len_stream; i++ ) + { + if ( ( q_idx[i] & 1 ) == 0 ) + { + q_dct_data_fx[i] = (Word32) ( ( step_fx * ( -q_idx[i] ) ) >> 7 ); // Q25 + } + ELSE + { + q_dct_data_fx[i] = (Word32) ( ( step_fx * ( q_idx[i] + 1 ) ) >> 7 ); // Q25 + } + } + SWITCH( len_stream ) + { + case 4: + matrix_product_q30_fx( dct4_fx, nblocks, nblocks, 1, q_dct_data_fx, nblocks, 1, 0, dct_data_tmp_fx ); + mvl2l( dct_data_tmp_fx, q_dct_data_fx, nblocks ); /*Q30*/ + BREAK; + case 5: + matrix_product_q30_fx( dct5_fx, nbands, nbands, 1, q_dct_data_fx, nbands, 1, 0, dct_data_tmp_fx ); + mvl2l( dct_data_tmp_fx, q_dct_data_fx, nbands ); /*Q30*/ + BREAK; + case 8: + matrix_product_q30_fx( dct8_fx, nbands, nbands, 1, q_dct_data_fx, nbands, 1, 0, dct_data_tmp_fx ); + mvl2l( dct_data_tmp_fx, q_dct_data_fx, nbands ); /*Q30*/ + BREAK; + case 12: + matrix_product_q30_fx( dct12_fx, nbands, nbands, 1, q_dct_data_fx, nbands, 1, 0, dct_data_tmp_fx ); + mvl2l( dct_data_tmp_fx, q_dct_data_fx, nbands ); /*Q30*/ + BREAK; + case 20: + matrix_product_fx( dct5_fx, nbands, nbands, 1, q_dct_data_fx, nbands, nblocks, 0, dct_data_tmp_fx ); + matrix_product_q30_fx( dct_data_tmp_fx, nbands, nblocks, 0, dct4_fx, nblocks, nblocks, 0, q_dct_data_fx ); /* reuse of variable*/ + BREAK; + case 32: + matrix_product_fx( dct8_fx, nbands, nbands, 1, q_dct_data_fx, nbands, nblocks, 0, dct_data_tmp_fx ); + matrix_product_q30_fx( dct_data_tmp_fx, nbands, nblocks, 0, dct4_fx, nblocks, nblocks, 0, q_dct_data_fx ); + BREAK; + default: + printf( "Incorrect number of coefficients for OMASA.\n" ); + BREAK; + } + + /* this is to make sure the comparison to the threshold 0.98 will go the same way in */ + /* fixed point and floating point without having to drag the fixed point values to the */ + /* comparison place in the code; */ + /* 1052266987 is 0.98 in Q30 it is not needed in the fixed point */ + for ( i = 0; i < nblocks * nbands; i++ ) + { + if ( q_dct_data_fx[i] >= 1052266987 && q_dct_data_fx[i] < 1052400000 ) + { + q_dct_data_fx[i] = 1052400000; + } + } + + k = 0; + for ( i = 0; i < nblocks; i++ ) + { + for ( j = 0; j < nbands; j++ ) + { + masa_to_total_energy_ratio[i][j] = q_dct_data_fx[k] / (float) ( 1 << 30 ); + masa_to_total_energy_ratio[i][j] = max( 0.0f, masa_to_total_energy_ratio[i][j] ); + masa_to_total_energy_ratio[i][j] = min( 1.0f, masa_to_total_energy_ratio[i][j] ); + k++; + } + } + + if ( nblocks == 1 ) + { + for ( i = 1; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) + { + for ( j = 0; j < nbands; j++ ) + { + masa_to_total_energy_ratio[i][j] = masa_to_total_energy_ratio[0][j]; + } + } + } + + if ( nbands == 1 ) + { + for ( j = 1; j < 5; j++ ) + { + for ( i = 0; i < nblocks; i++ ) + { + masa_to_total_energy_ratio[i][j] = masa_to_total_energy_ratio[i][0]; + } + } + } + +#else q_dct_data[0] = q_idx[0] * step; for ( i = 1; i < len_stream; i++ ) { @@ -6187,6 +6304,7 @@ void ivas_omasa_encode_masa_to_total( k++; } } +#endif assert( nb_bits == ( hMetaData->nb_bits_tot - bits_pos ) ); #ifdef DEBUG_MODE_QMETADATA diff --git a/lib_enc/ivas_qspherical_enc.c b/lib_enc/ivas_qspherical_enc.c index cb245538cbdeb46ffdf06757f79003bf242d74c0..177741980aed23a975587349e8e29c0d35ce8432 100644 --- a/lib_enc/ivas_qspherical_enc.c +++ b/lib_enc/ivas_qspherical_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_range_uni_enc.c b/lib_enc/ivas_range_uni_enc.c index 82f6813c2e8bcd56293f85de9ca1f5d3dc87f225..7b3ed79514678bd6f1e2fa714a84c33b9f09d659 100644 --- a/lib_enc/ivas_range_uni_enc.c +++ b/lib_enc/ivas_range_uni_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_rom_enc.c b/lib_enc/ivas_rom_enc.c index 9d04a20689b5348063e79e226a7e41f818d98e6e..eee7ba71d22042d91a845654fec0da4d9536a440 100644 --- a/lib_enc/ivas_rom_enc.c +++ b/lib_enc/ivas_rom_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_rom_enc.h b/lib_enc/ivas_rom_enc.h index 60d4ddcf79ebbccb097965b8e413d5ac317dba22..3d48dd2e400df1a0e055598a3664926a214ac9cf 100644 --- a/lib_enc/ivas_rom_enc.h +++ b/lib_enc/ivas_rom_enc.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_sba_enc.c b/lib_enc/ivas_sba_enc.c index 1b62335b9b930d29cced3e44a68a3f0fa7e656b3..da65ea5b8098fd10fc9caa9efff9961ab2ca1c38 100644 --- a/lib_enc/ivas_sba_enc.c +++ b/lib_enc/ivas_sba_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_sce_enc.c b/lib_enc/ivas_sce_enc.c index a1d6d594581625685ab129995381dbcdd87bac38..49cc45dd10903d2e70bda6ab012c97eb81145b1c 100644 --- a/lib_enc/ivas_sce_enc.c +++ b/lib_enc/ivas_sce_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other @@ -120,6 +120,9 @@ ivas_error ivas_sce_enc( #ifdef DEBUGGING st->force = st_ivas->hEncoderConfig->force; st->id_element = sce_id; +#ifdef DEBUG_FORCE_DIR + st->force_dir = st_ivas->hEncoderConfig->force_dir; +#endif #endif /*---------------------------------------------------------------* @@ -183,7 +186,11 @@ ivas_error ivas_sce_enc( &ener[0], &relE[0], A[0], Aw[0], epsP[0], lsp_new[0], lsp_mid[0], &vad_hover_flag[0], &attack_flag[0], realBuffer[0], imagBuffer[0], old_wsp[0], pitch_fr[0], voicing_fr[0], &loc_harm[0], &cor_map_sum[0], &vad_flag_dtx[0], enerBuffer[0], fft_buff[0], A[0], lsp_new[0], currFlatness[0], 0, fr_bands, Etot_LR, lf_E, localVAD_HE_SAD, NULL, flag_16k_smc, +#ifdef NONBE_1211_DTX_BR_SWITCHING + st_ivas->hSpar != NULL ? st_ivas->hSpar->front_vad_flag : 0, st_ivas->hSpar != NULL ? st_ivas->hSpar->force_front_vad : 0, st_ivas->hSpar != NULL ? st_ivas->hSpar->front_vad_dtx_flag : 0, ivas_format, 0, st_ivas->hEncoderConfig->last_ivas_total_brate, st_ivas->hEncoderConfig->ivas_total_brate +#else st_ivas->hSpar != NULL ? st_ivas->hSpar->front_vad_flag : 0, st_ivas->hSpar != NULL ? st_ivas->hSpar->force_front_vad : 0, st_ivas->hSpar != NULL ? st_ivas->hSpar->front_vad_dtx_flag : 0, ivas_format, 0, st_ivas->hEncoderConfig->ivas_total_brate +#endif #ifdef DEBUG_MODE_INFO , st->id_element diff --git a/lib_enc/ivas_sns_enc.c b/lib_enc/ivas_sns_enc.c index 5648aa794d5b1212b241548568a9cd94ad8de2ea..18c9b60810de77b9efa1a7f82202fa0a93857c53 100644 --- a/lib_enc/ivas_sns_enc.c +++ b/lib_enc/ivas_sns_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_spar_encoder.c b/lib_enc/ivas_spar_encoder.c index ec31fe9c677d955e2798ac1f5ba06ac37de612ec..ac5611d69f559ca4d50c9d8731de35619980719b 100644 --- a/lib_enc/ivas_spar_encoder.c +++ b/lib_enc/ivas_spar_encoder.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_spar_md_enc.c b/lib_enc/ivas_spar_md_enc.c index 5a6ef2289b6319a14874b8cb43e9d223674bf2e8..682c5d52e0217358853e421abc39065058aa9818 100644 --- a/lib_enc/ivas_spar_md_enc.c +++ b/lib_enc/ivas_spar_md_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_stat_enc.h b/lib_enc/ivas_stat_enc.h index 6725d778b08d3c06a604006e5fde36cd8694a4dc..59363a41a4ca943b642696987319437e7e85e8f7 100644 --- a/lib_enc/ivas_stat_enc.h +++ b/lib_enc/ivas_stat_enc.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other @@ -39,6 +39,10 @@ #include "ivas_cnst.h" #include "stat_enc.h" #include "ivas_stat_com.h" +#ifdef DEBUG_FORCE_DIR +#include "debug.h" +#endif + /*----------------------------------------------------------------------------------* * DFT Stereo encoder structures @@ -1183,6 +1187,9 @@ typedef struct encoder_config_structure int16_t stereo_mode_cmdl; /* stereo mode forced from the command-line */ int16_t force; /* parameter to force specific "core" of the Core-Coder*/ int16_t mdct_stereo_mode_cmdl; /* mdct stereo mode forced from command-line, employed only when DEBUG_FORCE_MDCT_STEREO_MODE is activated */ +#ifdef DEBUG_FORCE_DIR + char force_dir[FORCE_DIR_MAX_LENGTH]; /* directory containing external binary files for modes/parameters enforcement (empty string indicates no enforcement) */ +#endif #ifdef DEBUG_AGC_ENCODER_CMD_OPTION int16_t Opt_AGC_ON; /* flag indicating AGC operation in SBA */ #endif diff --git a/lib_enc/ivas_stereo_adapt_GR_enc.c b/lib_enc/ivas_stereo_adapt_GR_enc.c index 087ecda8e0553e06e075aaad3c8254e79ec15ac7..75f564deac38042fc09eb533fd94cb0fe3fae89b 100644 --- a/lib_enc/ivas_stereo_adapt_GR_enc.c +++ b/lib_enc/ivas_stereo_adapt_GR_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_stereo_classifier.c b/lib_enc/ivas_stereo_classifier.c index 427b55fe697c14acf16e745a0739459dbb1129d3..e992ed790417ddb9a5174b4e7d7434a7b022dd57 100644 --- a/lib_enc/ivas_stereo_classifier.c +++ b/lib_enc/ivas_stereo_classifier.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other @@ -190,6 +190,17 @@ int16_t select_stereo_mode( } } +#ifdef DEBUG_FORCE_DIR + if ( hCPE->hCoreCoder[0]->force_dir[0] != '\0' ) + { + dbgread( &element_mode, sizeof( int16_t ), 1, fname( hCPE->hCoreCoder[0]->force_dir, "force_element_mode.enf", -1, -1, -1 ) ); + } + else + { + dbgwrite( &element_mode, sizeof( int16_t ), 1, 1, "res/force_element_mode.enf" ); + } +#endif + if ( hCPE->last_element_mode != element_mode ) { if ( hCPE->last_element_mode != IVAS_CPE_DFT && hCPE->last_element_mode != IVAS_CPE_TD ) @@ -622,6 +633,17 @@ void unclr_classifier_td( dbgwrite( &hStereoClassif->unclr_decision, sizeof( int16_t ), 1, 1, "res/unclr_dec_hyst.x" ); #endif +#ifdef DEBUG_FORCE_DIR + if ( hCPE->hCoreCoder[0]->force_dir[0] != '\0' ) + { + dbgread( &hStereoClassif->unclr_decision, sizeof( int16_t ), 1, fname( hCPE->hCoreCoder[0]->force_dir, "force_unclr_decision.enf", -1, -1, -1 ) ); + } + else + { + dbgwrite( &hStereoClassif->unclr_decision, sizeof( int16_t ), 1, 1, "res/force_unclr_decision.enf" ); + } +#endif + return; } @@ -712,6 +734,17 @@ void unclr_classifier_dft( dbgwrite( &hStereoClassif->unclr_decision, sizeof( int16_t ), 1, 1, "res/unclr_dec_hyst.x" ); #endif +#ifdef DEBUG_FORCE_DIR + if ( hCPE->hCoreCoder[0]->force_dir[0] != '\0' ) + { + dbgread( &hStereoClassif->unclr_decision, sizeof( int16_t ), 1, fname( hCPE->hCoreCoder[0]->force_dir, "force_unclr_decision.enf", -1, -1, -1 ) ); + } + else + { + dbgwrite( &hStereoClassif->unclr_decision, sizeof( int16_t ), 1, 1, "res/force_unclr_decision.enf" ); + } +#endif + return; } @@ -846,6 +879,17 @@ void xtalk_classifier_td( dbgwrite( &hStereoClassif->xtalk_decision, sizeof( int16_t ), 1, 1, "res/xtalk_dec_hyst.x" ); #endif +#ifdef DEBUG_FORCE_DIR + if ( hCPE->hCoreCoder[0]->force_dir[0] != '\0' ) + { + dbgread( &hStereoClassif->xtalk_decision, sizeof( int16_t ), 1, fname( hCPE->hCoreCoder[0]->force_dir, "force_xtalk_decision.enf", -1, -1, -1 ) ); + } + else + { + dbgwrite( &hStereoClassif->xtalk_decision, sizeof( int16_t ), 1, 1, "res/force_xtalk_decision.enf" ); + } +#endif + return; } @@ -1006,17 +1050,28 @@ void xtalk_classifier_dft( hStereoClassif->xtalk_decision = 1; } + /* updates */ + hItd->prev_m1 = m1; + hItd->prev_m2 = m2; + hItd->prev_itd1 = itd; + hItd->prev_itd2 = itd2; + #ifdef DEBUG_MODE_TD dbgwrite( &hStereoClassif->xtalk_wscore, sizeof( float ), 1, 1, "res/xtalk_wscore.x" ); dbgwrite( &dec, sizeof( int16_t ), 1, 1, "res/xtalk_dec.x" ); dbgwrite( &hStereoClassif->xtalk_decision, sizeof( int16_t ), 1, 1, "res/xtalk_dec_hyst.x" ); #endif - /* updates */ - hItd->prev_m1 = m1; - hItd->prev_m2 = m2; - hItd->prev_itd1 = itd; - hItd->prev_itd2 = itd2; +#ifdef DEBUG_FORCE_DIR + if ( hCPE->hCoreCoder[0]->force_dir[0] != '\0' ) + { + dbgread( &hStereoClassif->xtalk_decision, sizeof( int16_t ), 1, fname( hCPE->hCoreCoder[0]->force_dir, "force_xtalk_decision.enf", -1, -1, -1 ) ); + } + else + { + dbgwrite( &hStereoClassif->xtalk_decision, sizeof( int16_t ), 1, 1, "res/force_xtalk_decision.enf" ); + } +#endif return; } diff --git a/lib_enc/ivas_stereo_cng_enc.c b/lib_enc/ivas_stereo_cng_enc.c index 76f56532dc7a9f9917c228eefb9efc9524431d13..68b5a9dceaa8a8354dcedf3f822b237a9f3509e4 100644 --- a/lib_enc/ivas_stereo_cng_enc.c +++ b/lib_enc/ivas_stereo_cng_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_stereo_dft_enc.c b/lib_enc/ivas_stereo_dft_enc.c index 84c9780348258368c3e46237ea8ec0cd82da136d..ddf1e0201b0359e65aa87ddca6d64f8c8b6bff89 100644 --- a/lib_enc/ivas_stereo_dft_enc.c +++ b/lib_enc/ivas_stereo_dft_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other @@ -3299,7 +3299,7 @@ static float stereo_dft_calc_mean_ipd_change( ipd_mean_change /= gipd_band_max; #ifdef DEBUG_MODE_DFT - dbgwrite( ipd_change, sizeof( float ), hStereoDft->gipd_band_max, 1, "res/stereo_dft_ipd_change.pcm" ); + // dbgwrite( ipd_change, sizeof( float ), hStereoDft->gipd_band_max, 1, "res/stereo_dft_ipd_change.pcm" ); dbgwrite( &ipd_mean_change, sizeof( float ), 1, 1, "res/stereo_dft_ipd_mean_change.pcm" ); #endif diff --git a/lib_enc/ivas_stereo_dft_enc_itd.c b/lib_enc/ivas_stereo_dft_enc_itd.c index 631fb34c803ccb97c34853d891e9c42ce2033ffb..1d973e92dba7a493fefcea041f410afff6945096 100644 --- a/lib_enc/ivas_stereo_dft_enc_itd.c +++ b/lib_enc/ivas_stereo_dft_enc_itd.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_stereo_dft_td_itd.c b/lib_enc/ivas_stereo_dft_td_itd.c index ee37e924db0532015b9543df5a72b39989f58d14..5f55611fd0d0ed79fcaba04c782d735f2602a6ea 100644 --- a/lib_enc/ivas_stereo_dft_td_itd.c +++ b/lib_enc/ivas_stereo_dft_td_itd.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_stereo_dmx_evs.c b/lib_enc/ivas_stereo_dmx_evs.c index 2ffc13d75d779e73ccc37561d3a4444c33e39672..8b8a8663549f3094cd3bd90fca648a0f0be972f6 100644 --- a/lib_enc/ivas_stereo_dmx_evs.c +++ b/lib_enc/ivas_stereo_dmx_evs.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_stereo_eclvq_enc.c b/lib_enc/ivas_stereo_eclvq_enc.c index f71beece823e102c87ec95b1943e70956685e1e7..c8ff6f6cd7a520c0e2dcbb18faf43e9cbf10b628 100644 --- a/lib_enc/ivas_stereo_eclvq_enc.c +++ b/lib_enc/ivas_stereo_eclvq_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_stereo_ica_enc.c b/lib_enc/ivas_stereo_ica_enc.c index 4cdd1c2fc367bbce50e9ca5ccdedf31b810c94fc..c59528e19a4a02ab18424c5a7e26d117ed3be020 100644 --- a/lib_enc/ivas_stereo_ica_enc.c +++ b/lib_enc/ivas_stereo_ica_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_stereo_icbwe_enc.c b/lib_enc/ivas_stereo_icbwe_enc.c index e7b40e3ba33184854d8ca2640ddebf3da0ce3956..77ea7561963dfceb5312407f1277169211c03404 100644 --- a/lib_enc/ivas_stereo_icbwe_enc.c +++ b/lib_enc/ivas_stereo_icbwe_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_stereo_mdct_core_enc.c b/lib_enc/ivas_stereo_mdct_core_enc.c index 0343b1ebf5b699eacc9d2485608ed80927e10efa..1332dbbfcc3870945c4b08b0fbc39f012c6b8e3f 100644 --- a/lib_enc/ivas_stereo_mdct_core_enc.c +++ b/lib_enc/ivas_stereo_mdct_core_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_stereo_mdct_igf_enc.c b/lib_enc/ivas_stereo_mdct_igf_enc.c index 1924028bcf9ff6ae1ea8f3470f59e5b5090ada01..d9eccd7b4c535c11c1d56f11ef132a4754dd605c 100644 --- a/lib_enc/ivas_stereo_mdct_igf_enc.c +++ b/lib_enc/ivas_stereo_mdct_igf_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_stereo_mdct_stereo_enc.c b/lib_enc/ivas_stereo_mdct_stereo_enc.c index d21244c202375146e686d9f89f8fa935ae24342b..9dce03e6edc973004fc1852c5d92f3220f350aba 100644 --- a/lib_enc/ivas_stereo_mdct_stereo_enc.c +++ b/lib_enc/ivas_stereo_mdct_stereo_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_stereo_switching_enc.c b/lib_enc/ivas_stereo_switching_enc.c index fca3c7785eab9e833c538536f7f61fc9fb99ebf3..4fe1660ae094a2c0034b58fe6d615f05d6f16990 100644 --- a/lib_enc/ivas_stereo_switching_enc.c +++ b/lib_enc/ivas_stereo_switching_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_stereo_td_analysis.c b/lib_enc/ivas_stereo_td_analysis.c index fc318ce6b68b3e1c6b925b33d0123c8ea6c7dec5..ff81b62575677930a311b242167bb423f722c9ef 100644 --- a/lib_enc/ivas_stereo_td_analysis.c +++ b/lib_enc/ivas_stereo_td_analysis.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_stereo_td_enc.c b/lib_enc/ivas_stereo_td_enc.c index 3778bffedd8e07f06a37a8d156ca0970d7eef943..1a71686f03c497714a0ce9eec2fb7045ac916231 100644 --- a/lib_enc/ivas_stereo_td_enc.c +++ b/lib_enc/ivas_stereo_td_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_tcx_core_enc.c b/lib_enc/ivas_tcx_core_enc.c index 7d8394f5af1b48abeeb482dd71404e6b2c773119..91adac9a0fbe1c49d145762b1c825190f0dc7533 100644 --- a/lib_enc/ivas_tcx_core_enc.c +++ b/lib_enc/ivas_tcx_core_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ivas_td_low_rate_enc.c b/lib_enc/ivas_td_low_rate_enc.c index de75faf2f97f46af7df4ca8a628eebb13923450e..fe59005175d173776c7ed11a738170680e6ea640 100644 --- a/lib_enc/ivas_td_low_rate_enc.c +++ b/lib_enc/ivas_td_low_rate_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/lead_indexing.c b/lib_enc/lead_indexing.c index 6208d66eb8228059fdf727c294a69f24d2086d70..f1cfa506525589c750849767a08ff61df4388389 100644 --- a/lib_enc/lead_indexing.c +++ b/lib_enc/lead_indexing.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/lib_enc.c b/lib_enc/lib_enc.c index 0fb8eabb35b33afae2b250b7e9673fa3cf4e4e03..b6e40fd0baabb56524117cdded7a811143f25f00 100644 --- a/lib_enc/lib_enc.c +++ b/lib_enc/lib_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other @@ -990,7 +990,11 @@ static ivas_error configureEncoder( } #endif +#ifdef NONBE_FIX_708_OSBA_BR_SWITCHING_CRASH + if ( hEncoderConfig->Opt_PCA_ON && !( ( hEncoderConfig->ivas_format == SBA_FORMAT || hEncoderConfig->ivas_format == SBA_ISM_FORMAT ) && hEncoderConfig->ivas_total_brate == PCA_BRATE && hEncoderConfig->sba_order == SBA_FOA_ORDER ) ) +#else if ( hEncoderConfig->Opt_PCA_ON && !( hEncoderConfig->ivas_format == SBA_FORMAT && hEncoderConfig->ivas_total_brate == PCA_BRATE && hEncoderConfig->sba_order == SBA_FOA_ORDER ) ) +#endif { return IVAS_ERROR( IVAS_ERR_NOT_SUPPORTED_OPTION, "PCA supported at SBA FOA 256 kbps only." ); } @@ -1057,7 +1061,11 @@ ivas_error IVAS_ENC_GetDelay( return IVAS_ERR_UNEXPECTED_NULL_POINTER; } +#ifdef SPLIT_REND_WITH_HEAD_ROT + *delay = NS2SA( hEncoderConfig->input_Fs, get_delay( ENC, hEncoderConfig->input_Fs, hEncoderConfig->ivas_format, NULL, IVAS_AUDIO_CONFIG_INVALID ) ); +#else *delay = NS2SA( hEncoderConfig->input_Fs, get_delay( ENC, hEncoderConfig->input_Fs, hEncoderConfig->ivas_format, NULL ) ); +#endif *delay *= hEncoderConfig->nchan_inp; @@ -1324,6 +1332,9 @@ ivas_error IVAS_ENC_EncodeFrameToSerial( } else { +#ifdef DEBUG_MODE_INFO + dbgwrite( inputBuffer, sizeof( int16_t ), inputBufferSize, 1, strcat( fname( debug_dir, "ivas_input_dmx", 0, 1, ENC ), ".pcm" ) ); +#endif if ( ( error = evs_enc( hCoreCoder, inputBuffer, st_ivas->mem_hp20_in[0], inputBufferSize ) ) != IVAS_ERR_OK ) { return error; @@ -1459,6 +1470,10 @@ ivas_error IVAS_ENC_SetChannelAwareConfig( ivas_error IVAS_ENC_SetForcedMode( IVAS_ENC_HANDLE hIvasEnc, /* i/o: IVAS encoder handle */ const IVAS_ENC_FORCED_MODE forcedMode /* i : forced coding mode */ +#ifdef DEBUG_FORCE_DIR + , + const char *forcedModeDir /* i : directory containing external binary files for modes/parameters enforcement */ +#endif ) { int16_t newForced; @@ -1470,6 +1485,27 @@ ivas_error IVAS_ENC_SetForcedMode( return error; } +#ifdef DEBUG_FORCE_DIR + hIvasEnc->st_ivas->hEncoderConfig->force_dir[0] = '\0'; + if ( forcedMode < IVAS_ENC_FORCE_FILE ) + { + if ( ( error = forcedModeApiToInternal( forcedMode, &newForced ) ) != IVAS_ERR_OK ) + { + return error; + } + + if ( hIvasEnc->st_ivas->hEncoderConfig->force != newForced ) + { + hIvasEnc->st_ivas->hEncoderConfig->force = newForced; + hIvasEnc->switchingActive = true; + } + } + else if ( forcedMode == IVAS_ENC_FORCE_DIR ) + { + strcpy( hIvasEnc->st_ivas->hEncoderConfig->force_dir, forcedModeDir ); + hIvasEnc->st_ivas->hEncoderConfig->force = IVAS_ENC_FORCE_UNFORCED; + } +#else if ( ( error = forcedModeApiToInternal( forcedMode, &newForced ) ) != IVAS_ERR_OK ) { return error; @@ -1480,6 +1516,7 @@ ivas_error IVAS_ENC_SetForcedMode( hIvasEnc->st_ivas->hEncoderConfig->force = newForced; hIvasEnc->switchingActive = true; } +#endif return IVAS_ERR_OK; } diff --git a/lib_enc/lib_enc.h b/lib_enc/lib_enc.h index 52c05332aea2b6a1831ef60c8b2fe315321ab443..b90d897fbe70ef3dbf7f38e58303983d2c40b2f8 100644 --- a/lib_enc/lib_enc.h +++ b/lib_enc/lib_enc.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other @@ -134,6 +134,10 @@ typedef enum _IVAS_ENC_FORCED_MODE IVAS_ENC_FORCE_TCX, #endif IVAS_ENC_FORCE_HQ, +#ifdef DEBUG_FORCE_DIR + IVAS_ENC_FORCE_FILE, + IVAS_ENC_FORCE_DIR, +#endif IVAS_ENC_FORCE_UNFORCED, IVAS_ENC_FORCE_UNDEFINED = 0xffff } IVAS_ENC_FORCED_MODE; @@ -334,6 +338,9 @@ ivas_error IVAS_ENC_SetChannelAwareConfig( ivas_error IVAS_ENC_SetForcedMode( IVAS_ENC_HANDLE hIvasEnc, /* i/o: IVAS encoder handle */ const IVAS_ENC_FORCED_MODE forcedMode /* i : forced coding mode */ +#ifdef DEBUG_FORCE_DIR + ,const char *forcedModeDir /* i : directory containing external binary files for modes/parameters enforcement */ +#endif ); #endif diff --git a/lib_enc/long_enr.c b/lib_enc/long_enr.c index 488012b6bfa4f6f03802b210494763ba610dc8ad..72018afef77ae0a99c50852b2314e0c50a0b90ca 100644 --- a/lib_enc/long_enr.c +++ b/lib_enc/long_enr.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/lp_exc_e.c b/lib_enc/lp_exc_e.c index 4fb81a9b75bdade7e74cb2007975462ec4cc3846..12b21e2ad6fda79b0559d46c2226467ef1af4582 100644 --- a/lib_enc/lp_exc_e.c +++ b/lib_enc/lp_exc_e.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/lsf_enc.c b/lib_enc/lsf_enc.c index 61a81ffec8fcccb536d323af3fb4d52cc75e9fd9..ea81c54f59fff2eba9d05bbf364e0f63d69c1122 100644 --- a/lib_enc/lsf_enc.c +++ b/lib_enc/lsf_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/lsf_msvq_ma_enc.c b/lib_enc/lsf_msvq_ma_enc.c index d75d570215db246449c83eee2a7ea664e3e782e8..9bb2b7befd90c9f2dae9485d9814b0fdec1cadc1 100644 --- a/lib_enc/lsf_msvq_ma_enc.c +++ b/lib_enc/lsf_msvq_ma_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ltd_stable.c b/lib_enc/ltd_stable.c index a6222a411f11a1e43573879233718d283f85a885..3c40fa2f4198a8962d5518e95a84ba06d7364637 100644 --- a/lib_enc/ltd_stable.c +++ b/lib_enc/ltd_stable.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/mdct_classifier.c b/lib_enc/mdct_classifier.c index f26b1277336fbf9352d52af1d7d5a224129de3b6..d3965243947dc403a14b6aabf2e36a913fde40c8 100644 --- a/lib_enc/mdct_classifier.c +++ b/lib_enc/mdct_classifier.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/mdct_selector.c b/lib_enc/mdct_selector.c index 45f3d3174c982e4f3f1434221e419f4a863a70e9..af48cd0576ee143136018d586b62382e54db60a3 100644 --- a/lib_enc/mdct_selector.c +++ b/lib_enc/mdct_selector.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/mslvq_enc.c b/lib_enc/mslvq_enc.c index e4e98ea1e63e79e1b27af55cc2f97aedffb34973..d68ef4ff7ad4695bfeb02fcca45d5bdfdc7a76ff 100644 --- a/lib_enc/mslvq_enc.c +++ b/lib_enc/mslvq_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/multi_harm.c b/lib_enc/multi_harm.c index c53371e28dc58a5520acd01b3d517c021bc15c74..da4e02d062f31e88985a717c9a4a09dacf3c1d09 100644 --- a/lib_enc/multi_harm.c +++ b/lib_enc/multi_harm.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/nelp_enc.c b/lib_enc/nelp_enc.c index a1ae3c20d733696eb296c5e78c63a3329faadcb2..22ff3a72410290b1f241d2be708eaa5aba0092f3 100644 --- a/lib_enc/nelp_enc.c +++ b/lib_enc/nelp_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/nois_est.c b/lib_enc/nois_est.c index b35b3612b569285381e7c7a171dcaee9e660dad0..d5c93205edc26bc2b3e73fc706f3897924aa04d2 100644 --- a/lib_enc/nois_est.c +++ b/lib_enc/nois_est.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/noise_adjust.c b/lib_enc/noise_adjust.c index 0ba9bd45370e6c1ad28770dddbde4f4aff15c429..350cab9ed3978c4cb677c51cfe4e2ca98604447f 100644 --- a/lib_enc/noise_adjust.c +++ b/lib_enc/noise_adjust.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/normalizecoefs.c b/lib_enc/normalizecoefs.c index bd24f2cd2bd2c2ab654ba60dc72cbe3410edc26c..a54139ed2133a770c9f889d34d6f2b6bb65aa137 100644 --- a/lib_enc/normalizecoefs.c +++ b/lib_enc/normalizecoefs.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/peak_vq_enc.c b/lib_enc/peak_vq_enc.c index efdd0b14a90e251da397e8235bfd037c7b2b97ee..eb76ca5f2226d76a9d37f6a5f8d109049c7130fc 100644 --- a/lib_enc/peak_vq_enc.c +++ b/lib_enc/peak_vq_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/pit_enc.c b/lib_enc/pit_enc.c index d8d51e2a1b7a977b89fc5cc2ea6e488482e8db62..d1306ac791b1544f973b9c47c41ca7ccbdc23a11 100644 --- a/lib_enc/pit_enc.c +++ b/lib_enc/pit_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/pitch_ol.c b/lib_enc/pitch_ol.c index 8f149a35d8893c6f12924f2ce058f54278a506d2..27e82b3804a5827c05cfddc30f652216117cf5d8 100644 --- a/lib_enc/pitch_ol.c +++ b/lib_enc/pitch_ol.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/pitch_ol2.c b/lib_enc/pitch_ol2.c index bc414158e1605fc92c5d3a9a6b21652a7b360b96..0c9b0f830c1f682ac07edf6c748d505210c76ff0 100644 --- a/lib_enc/pitch_ol2.c +++ b/lib_enc/pitch_ol2.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/plc_enc_ext.c b/lib_enc/plc_enc_ext.c index 8e5cfc382da8a37a93807869ed3fae2213181c61..37b1f22e522b84de39575e45a840d3a1173bf7d6 100644 --- a/lib_enc/plc_enc_ext.c +++ b/lib_enc/plc_enc_ext.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/ppp_enc.c b/lib_enc/ppp_enc.c index d55cb135dd440de26da83b9d845347779fbf9915..981828099130a159a14a56a6f8de306b52846192 100644 --- a/lib_enc/ppp_enc.c +++ b/lib_enc/ppp_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/pre_proc.c b/lib_enc/pre_proc.c index 5301559d2fd5ba1aa38c1fbb340273d7e3bd820e..36e33aaa6715cad64beb8356d8f7bb6e6de21727 100644 --- a/lib_enc/pre_proc.c +++ b/lib_enc/pre_proc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other @@ -250,7 +250,13 @@ void pre_proc( /*-----------------------------------------------------------------* * Select SID or FRAME_NO_DATA frame if DTX enabled *-----------------------------------------------------------------*/ + +#ifdef NONBE_1211_DTX_BR_SWITCHING + dtx( st, -1, -1, vad_flag_dtx, inp_12k8 ); +#else dtx( st, -1, vad_flag_dtx, inp_12k8 ); +#endif + /*----------------------------------------------------------------* * Adjust FD-CNG Noise Estimator *----------------------------------------------------------------*/ diff --git a/lib_enc/pvq_core_enc.c b/lib_enc/pvq_core_enc.c index 9f1fe46ac63cf96dbd898a7be6ae3abd9216dddc..83bbb2b0b75d538a5a6919ae9612568a8f3a8391 100644 --- a/lib_enc/pvq_core_enc.c +++ b/lib_enc/pvq_core_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/pvq_encode.c b/lib_enc/pvq_encode.c index eb066e8ed20fcad4dbfff05f4a7ea8da4e3b11ad..c90ee2c6a07ed706163231eae862e320e8116238 100644 --- a/lib_enc/pvq_encode.c +++ b/lib_enc/pvq_encode.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/q_gain2p.c b/lib_enc/q_gain2p.c index 9c89b44c8753110da3c354b7b0bc6a2cf43c5cb8..8e8ae02168d3d5097139e23df88b7e1b04b97e72 100644 --- a/lib_enc/q_gain2p.c +++ b/lib_enc/q_gain2p.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/qlpc_avq.c b/lib_enc/qlpc_avq.c index eabbd8128fe80fc718d334d7f0f66b3c0177ca86..a845ba97e6e5dce5cdc30d1a978bf160b3ad86c1 100644 --- a/lib_enc/qlpc_avq.c +++ b/lib_enc/qlpc_avq.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/qlpc_stoch.c b/lib_enc/qlpc_stoch.c index 31021aee7fc20761b2438e3c2aa68e853979ddaf..65929271c1a6401f06e06db2ff7116b16e757a42 100644 --- a/lib_enc/qlpc_stoch.c +++ b/lib_enc/qlpc_stoch.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/range_enc.c b/lib_enc/range_enc.c index 8ea8c888d22c5d64de577c2346db9c9ba4fd3030..dc76fb06c91320392d5e5c3e08d1d21583453463 100644 --- a/lib_enc/range_enc.c +++ b/lib_enc/range_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/re8_cod.c b/lib_enc/re8_cod.c index 5facffd8f448caeb2534eecc3aa7913ba5fdc7ec..610165c48701239a0c5034a0c28ac62c4231e37a 100644 --- a/lib_enc/re8_cod.c +++ b/lib_enc/re8_cod.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/reordernorm.c b/lib_enc/reordernorm.c index 831adeee53b0f55aa6b0fb940ff66cf31e73d847..44394d675b64b8cdcd37ac32ca6ef989456a37f8 100644 --- a/lib_enc/reordernorm.c +++ b/lib_enc/reordernorm.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/rom_enc.c b/lib_enc/rom_enc.c index ae96fdfc31744efad74681b5e509fddc89182a65..75ccd4d751a908e01143a030f7478cd11bbaaa2b 100644 --- a/lib_enc/rom_enc.c +++ b/lib_enc/rom_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/rom_enc.h b/lib_enc/rom_enc.h index 7e7659ceb6a46baa1066bf5af7af2096ae5f367a..019cc5403196ae1a2ce8fba6c4b93e43a968329d 100644 --- a/lib_enc/rom_enc.h +++ b/lib_enc/rom_enc.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/rst_enc.c b/lib_enc/rst_enc.c index 3a2041875941a62f4e4b09796f49084332c77ad4..b7ad7d5e919779e315b93b19c643d46fcbf48668 100644 --- a/lib_enc/rst_enc.c +++ b/lib_enc/rst_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/set_impulse.c b/lib_enc/set_impulse.c index 2c8a7fdd080353a7880fb30d7ffd018b2f5f70dc..ac645a7ee96affbcd5ab744fe070b7481829258b 100644 --- a/lib_enc/set_impulse.c +++ b/lib_enc/set_impulse.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/setmodeindex.c b/lib_enc/setmodeindex.c index b2187b89908a93a706682a39516e06b35a8c7cd9..2ed06d034ba2632cce2dce766ca5d3f3ba63f78c 100644 --- a/lib_enc/setmodeindex.c +++ b/lib_enc/setmodeindex.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/sig_clas.c b/lib_enc/sig_clas.c index 18ee55df61e0d504d8bd2503ebfc4d4fcef08fbc..ae965c56a88f30e2a6a548616b4aca096eebf5fd 100644 --- a/lib_enc/sig_clas.c +++ b/lib_enc/sig_clas.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/spec_center.c b/lib_enc/spec_center.c index 73835a15117876c83542e86b9c1327ed57edfdf3..2219f7a936a2a482a16b07b64ce2c2e259cda584 100644 --- a/lib_enc/spec_center.c +++ b/lib_enc/spec_center.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/spec_flatness.c b/lib_enc/spec_flatness.c index 0473cc6b983950b3b8f880c205fda63f1bfa36f0..ee469f13d4639cc5bfcc6153da999b6016bf376b 100644 --- a/lib_enc/spec_flatness.c +++ b/lib_enc/spec_flatness.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/speech_music_classif.c b/lib_enc/speech_music_classif.c index fac0f01e4fd0e2b142534236ffba478e37a86c54..6b0a729d854fa22ff176126185a9eb12da90bc0e 100644 --- a/lib_enc/speech_music_classif.c +++ b/lib_enc/speech_music_classif.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/stat_enc.h b/lib_enc/stat_enc.h index b5fc7fdd79bee9fb79fb2692dcfea50cf2a0ef51..4570415dc61e5d2f03fb38ea8c24708aeac39f15 100644 --- a/lib_enc/stat_enc.h +++ b/lib_enc/stat_enc.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other @@ -1170,6 +1170,9 @@ typedef struct enc_core_structure int16_t inactive_coder_type_flag; /* inactive coder type flag (0 = AVQ / 1 = GSC) */ #ifdef DEBUGGING int16_t force; /* flag indicating specific signal type (0 = speech, 1 = music, -1 = N/A) */ +#ifdef DEBUG_FORCE_DIR + char *force_dir; /* directory containing external binary files for modes/parameters enforcement (empty string indicates no enforcement) */ +#endif #endif int16_t ini_frame; /* initialization frames counter */ diff --git a/lib_enc/stat_noise_uv_enc.c b/lib_enc/stat_noise_uv_enc.c index a1adfb052a7c3e3f3ba070f27343d8b0e62ffe14..0771bf77a4fdc0608d37350f2ea9f2897c761acb 100644 --- a/lib_enc/stat_noise_uv_enc.c +++ b/lib_enc/stat_noise_uv_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/subband_fft.c b/lib_enc/subband_fft.c index 638a6d63f830bc1e24cf4575d3e9e201c9296d50..f687f26a598dad30c7e5486dcb83240e8937c1cf 100644 --- a/lib_enc/subband_fft.c +++ b/lib_enc/subband_fft.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/swb_bwe_enc.c b/lib_enc/swb_bwe_enc.c index e2c8812eca9d6b2af15435b40b5dc5a16162eed5..8157f83372462218e04d10dec4cfb25b40ff14d4 100644 --- a/lib_enc/swb_bwe_enc.c +++ b/lib_enc/swb_bwe_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/swb_bwe_enc_hr.c b/lib_enc/swb_bwe_enc_hr.c index 7b2f3687a0dc69eda51d3528ad6598920ac293b2..b6792e0d0d051450627e2cf0029f11a29261ca4e 100644 --- a/lib_enc/swb_bwe_enc_hr.c +++ b/lib_enc/swb_bwe_enc_hr.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/swb_bwe_enc_lr.c b/lib_enc/swb_bwe_enc_lr.c index 63c432ea1afe9d05191953af10469fca50496a37..a0d2b1820dc32981db8a38c53332edaca20bf977 100644 --- a/lib_enc/swb_bwe_enc_lr.c +++ b/lib_enc/swb_bwe_enc_lr.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/swb_pre_proc.c b/lib_enc/swb_pre_proc.c index 3ec175958aa4e12f12a2c33c95522e050f00f9cd..13731873884ec11ddd21bf40cd8cc01b783a5b9f 100644 --- a/lib_enc/swb_pre_proc.c +++ b/lib_enc/swb_pre_proc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/swb_tbe_enc.c b/lib_enc/swb_tbe_enc.c index 1a0dbbf7bbb1f96ceb91cbcc4d60e7f6b4aa3635..febd1b14badfbad7ec4b27cbd00f0501b85e2375 100644 --- a/lib_enc/swb_tbe_enc.c +++ b/lib_enc/swb_tbe_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/tcq_core_enc.c b/lib_enc/tcq_core_enc.c index aad3e54e7366f33374b6da098ca9d94e8ee81370..d66cc76f48c340ddcc9da9037a20614fa7e75449 100644 --- a/lib_enc/tcq_core_enc.c +++ b/lib_enc/tcq_core_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/tcx_ltp_enc.c b/lib_enc/tcx_ltp_enc.c index 0ea2e0424a4ddca8a922ce4b8cee25d905c5d3a9..c806d1b810019774a8dc111d3cbb002d20af5bb4 100644 --- a/lib_enc/tcx_ltp_enc.c +++ b/lib_enc/tcx_ltp_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/tcx_utils_enc.c b/lib_enc/tcx_utils_enc.c index deaab8d696e54d88012ccb2b9416f2001dd495ee..3740b2009161d4647f296d8d538d28d5091d9393 100644 --- a/lib_enc/tcx_utils_enc.c +++ b/lib_enc/tcx_utils_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/tfa_enc.c b/lib_enc/tfa_enc.c index 50dd7c36687fd0faf46ecdc78805c99a99599b53..52e7129ebc132fd525bf0076fe09465c8cea9d2c 100644 --- a/lib_enc/tfa_enc.c +++ b/lib_enc/tfa_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/tns_base_enc.c b/lib_enc/tns_base_enc.c index 594f7824111edb5568679dea1315f25c5a431918..1adea762ec91c4a9c5780dd0a5e5a4f4a7dfe679 100644 --- a/lib_enc/tns_base_enc.c +++ b/lib_enc/tns_base_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/transient_detection.c b/lib_enc/transient_detection.c index 15273d26cc5a4258fbd393872fffa055582d799a..1a53d8b511e6670e27f395b8759e117e51af4224 100644 --- a/lib_enc/transient_detection.c +++ b/lib_enc/transient_detection.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/transition_enc.c b/lib_enc/transition_enc.c index 925a6f1c322e2582ab7e214c0eade34cfbbdf055..e2be62f565689bca3203d0a89c7fb25542169dcc 100644 --- a/lib_enc/transition_enc.c +++ b/lib_enc/transition_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other @@ -178,7 +178,11 @@ void transition_enc( if ( *tc_subfr == TC_0_0 ) { /* this is called only to compute unused bits */ +#ifdef NONBE_FIX_GSC_BSTR + config_acelp1( ENC, st->total_brate, st->core_brate, st->core, st->extl, st->extl_brate, L_FRAME, -1, &( st->acelp_cfg ), hBstr->nb_bits_tot, TRANSITION, -1, TC_0_0, 3, NULL, unbits_ACELP, st->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st->idchan, st->active_cnt, 0 /*tdm_Pitch_reuse_flag*/, st->tdm_LRTD_flag, 0 /*GSC_IVAS_mode*/ ); +#else config_acelp1( ENC, st->total_brate, st->core_brate, st->core, st->extl, st->extl_brate, L_FRAME, -1, &( st->acelp_cfg ), hBstr->nb_bits_tot, TRANSITION, TC_0_0, 3, NULL, unbits_ACELP, st->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st->idchan, st->active_cnt, 0 /*tdm_Pitch_reuse_flag*/, st->tdm_LRTD_flag, 0 /*GSC_IVAS_mode*/ ); +#endif } *clip_gain = gp_clip( st->element_mode, st->core_brate, st->voicing, i_subfr, TRANSITION, xn, gp_cl ); @@ -274,7 +278,11 @@ void transition_enc( if ( i_subfr - *tc_subfr <= L_SUBFR ) { +#ifdef NONBE_FIX_GSC_BSTR + config_acelp1( ENC, st->total_brate, st->core_brate, st->core, st->extl, st->extl_brate, st->L_frame, -1, &( st->acelp_cfg ), hBstr->nb_bits_tot, TRANSITION, -1, *tc_subfr, 2, NULL, unbits_ACELP, st->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st->idchan, st->active_cnt, 0 /*tdm_Pitch_reuse_flag*/, st->tdm_LRTD_flag, 0 /*GSC_IVAS_mode*/ ); +#else config_acelp1( ENC, st->total_brate, st->core_brate, st->core, st->extl, st->extl_brate, st->L_frame, -1, &( st->acelp_cfg ), hBstr->nb_bits_tot, TRANSITION, *tc_subfr, 2, NULL, unbits_ACELP, st->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st->idchan, st->active_cnt, 0 /*tdm_Pitch_reuse_flag*/, st->tdm_LRTD_flag, 0 /*GSC_IVAS_mode*/ ); +#endif } /*-----------------------------------------------------------------* diff --git a/lib_enc/update_decision.c b/lib_enc/update_decision.c index 1269ca68da6e44c4618b2c6c38b32bc5657bfd55..bc0486edbfdf852f6627d9b3f38bd9e30d671b23 100644 --- a/lib_enc/update_decision.c +++ b/lib_enc/update_decision.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/updt_enc.c b/lib_enc/updt_enc.c index 5cc66667fe26bbc55e9eaeab117e1fb405370bd0..325443296cf4b096457e2eaf9cf369b05dcdad63 100644 --- a/lib_enc/updt_enc.c +++ b/lib_enc/updt_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/updt_tar.c b/lib_enc/updt_tar.c index 4c3ff4843cf2aa4c36a1280952ad274da7277f2c..d688a645a9a52c3fa2a7ed8921c7560408c5d78b 100644 --- a/lib_enc/updt_tar.c +++ b/lib_enc/updt_tar.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/vad.c b/lib_enc/vad.c index 62c7ccb913441af7c4c4c008e54812a358afaa8d..60e040925634226f22fbd9ce844e087e34a34f1d 100644 --- a/lib_enc/vad.c +++ b/lib_enc/vad.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/vad_param_updt.c b/lib_enc/vad_param_updt.c index b7adac46ea2047ef9545f92296841969e4720fcc..45e20a876c96ee4cabfc66a02d9725d8981bba8c 100644 --- a/lib_enc/vad_param_updt.c +++ b/lib_enc/vad_param_updt.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/vad_proc.c b/lib_enc/vad_proc.c index 07814aacf38d27eff15d4885f35cd78f76134946..f00cece639a2503c0b3cbaf32ebfd9e75aa5bbf9 100644 --- a/lib_enc/vad_proc.c +++ b/lib_enc/vad_proc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/vbr_average_rate.c b/lib_enc/vbr_average_rate.c index 8e7330c8b824ea86011dc670c2ce6f9d4f48ed03..dd50dbb2f8ae2267146c3aff92da34997024a178 100644 --- a/lib_enc/vbr_average_rate.c +++ b/lib_enc/vbr_average_rate.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/vlpc_1st_cod.c b/lib_enc/vlpc_1st_cod.c index 553cf7e264a57d47ff596702d6dfe5a1ab3d01fd..e098f611aa59ada9db8d072a1f4def5e841cd882 100644 --- a/lib_enc/vlpc_1st_cod.c +++ b/lib_enc/vlpc_1st_cod.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/vlpc_2st_cod.c b/lib_enc/vlpc_2st_cod.c index 9e1e9fe5508416aced348832cab45457f0b15611..abe3c3d55c3aeffdccc2f4ca2514414ce85e5049 100644 --- a/lib_enc/vlpc_2st_cod.c +++ b/lib_enc/vlpc_2st_cod.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/voiced_enc.c b/lib_enc/voiced_enc.c index 18a3305902680b9bea1ea5952820d76310fbae1f..ab4c39fb6538e3f9177b7ab2acf4d4313f01f795 100644 --- a/lib_enc/voiced_enc.c +++ b/lib_enc/voiced_enc.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_enc/waveadjust_fec_cod.c b/lib_enc/waveadjust_fec_cod.c index bd57e4a09330c63bef7baa6ba7a0595bab3f06c6..b0d1d9581c17b980c64b495de7ef53e844ecf96b 100644 --- a/lib_enc/waveadjust_fec_cod.c +++ b/lib_enc/waveadjust_fec_cod.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_isar/isar_MSPred.c b/lib_isar/isar_MSPred.c new file mode 100644 index 0000000000000000000000000000000000000000..d239b2c29fbfb7905dc04ca1723461aa0d71b337 --- /dev/null +++ b/lib_isar/isar_MSPred.c @@ -0,0 +1,470 @@ +/****************************************************************************************************** + + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#include "options.h" +#include +#ifdef SPLIT_REND_WITH_HEAD_ROT +#include "isar_lcld_prot.h" +#include "isar_prot.h" +#include "wmc_auto.h" + + +/*-------------------------------------------------------------------* + * Function _round() + * + * + *-------------------------------------------------------------------*/ + +static int32_t _round( + float val ) +{ + return ( val > 0.0f ? (int32_t) ( val + 0.5f ) : (int32_t) ( val - 0.5f ) ); +} + + +/*-------------------------------------------------------------------* + * Function quantPhase() + * + * + *-------------------------------------------------------------------*/ + +int32_t quantPhase( + float phase ) +{ + int32_t phaseQ; + + phaseQ = _round( phase * PHASE_QUANT_FACTOR ); + if ( phaseQ == PHASE_MAX_VAL ) + { + phaseQ = PHASE_MIN_VAL; + } + return phaseQ; +} + + +/*-------------------------------------------------------------------* + * Function cplxmult_lcld() + * + * + *-------------------------------------------------------------------*/ + +void cplxmult_lcld( + float *pr1, + float *pi1, + const float r2, + const float i2 ) +{ + float r1 = *pr1, i1 = *pi1; + + *pr1 = r1 * r2 - i1 * i2; + *pi1 = r1 * i2 + i1 * r2; + + return; +} + + +/*-------------------------------------------------------------------* + * Function requantPhase() + * + * + *-------------------------------------------------------------------*/ + +int32_t requantPhase( + int32_t phaseQ ) +{ + + if ( phaseQ >= PHASE_MAX_VAL ) + { + phaseQ += PHASE_MAX_VAL; + phaseQ %= ( 2 * PHASE_MAX_VAL ); + phaseQ -= PHASE_MAX_VAL; + } + else if ( phaseQ < PHASE_MIN_VAL ) + { + phaseQ -= PHASE_MAX_VAL; + phaseQ %= ( 2 * PHASE_MAX_VAL ); + phaseQ += PHASE_MAX_VAL; + if ( phaseQ == PHASE_MAX_VAL ) + { + phaseQ = PHASE_MIN_VAL; + } + } + + return phaseQ; +} + + +/*-------------------------------------------------------------------* + * Function quantPred() + * + * + *-------------------------------------------------------------------*/ + +int32_t quantPred( + const float pred ) +{ + int32_t predQ = _round( pred * PRED_QUANT_FACTOR ); + predQ = predQ > PRED_MAX_VAL ? PRED_MAX_VAL : predQ; + predQ = predQ < PRED_MIN_VAL ? PRED_MIN_VAL : predQ; + + return predQ; +} + + +/*-------------------------------------------------------------------* + * Function dequantPhase() + * + * + *-------------------------------------------------------------------*/ + +float dequantPhase( + const int32_t phaseQ ) +{ + return (float) phaseQ / PHASE_QUANT_FACTOR; +} + + +/*-------------------------------------------------------------------* + * Function dequantPred() + * + * + *-------------------------------------------------------------------*/ + +float dequantPred( int32_t predQ ) +{ + return (float) predQ / PRED_QUANT_FACTOR; +} + + +/*-------------------------------------------------------------------* + * Function PrepEncode() + * + * + *-------------------------------------------------------------------*/ + +int32_t PrepEncode( + int32_t *piQuant, + const int32_t *piMSFlags, + const int32_t numBands ) +{ + int32_t b, numMSBands = 0; + + for ( b = 0; b < numBands; b++ ) + { + if ( piMSFlags[b] ) + { + piQuant[numMSBands++] = piQuant[b]; + } + } + + for ( b = numMSBands; b < numBands; b++ ) + { + piQuant[b] = 0; + } + + return numMSBands; +} + + +/*-------------------------------------------------------------------* + * Function EncodePhase() + * + * + *-------------------------------------------------------------------*/ + +void EncodePhase( + int32_t *phaseQuant, + const int32_t numMSBands, + const int32_t diffDim ) +{ + int32_t b; + + if ( diffDim > 0 ) + { + int32_t tmp1, tmp2; + tmp1 = phaseQuant[0]; + for ( b = 1; b < numMSBands; b++ ) + { + tmp2 = phaseQuant[b]; + phaseQuant[b] -= tmp1; + tmp1 = tmp2; + } + } + + if ( diffDim > 1 ) + { + int32_t tmp1, tmp2; + tmp1 = phaseQuant[1]; + for ( b = 2; b < numMSBands; b++ ) + { + tmp2 = phaseQuant[b]; + phaseQuant[b] -= tmp1; + tmp1 = tmp2; + } + } + for ( b = 1; b < numMSBands; b++ ) + { + phaseQuant[b] = requantPhase( phaseQuant[b] ); + } + + return; +} + + +/*-------------------------------------------------------------------* + * Function DecodePhase() + * + * + *-------------------------------------------------------------------*/ + +void DecodePhase( + int32_t *phaseQuant, + const int32_t numMSBands, + const int32_t diffDim ) +{ + int32_t b; + + if ( diffDim > 1 ) + { + for ( b = 2; b < numMSBands; b++ ) + { + phaseQuant[b] += phaseQuant[b - 1]; + } + } + + if ( diffDim > 0 ) + { + for ( b = 1; b < numMSBands; b++ ) + { + phaseQuant[b] += phaseQuant[b - 1]; + } + } + + for ( b = 1; b < numMSBands; b++ ) + { + phaseQuant[b] = requantPhase( phaseQuant[b] ); + } + + return; +} + + +/*-------------------------------------------------------------------* + * Function EncodePredCoef() + * + * + *-------------------------------------------------------------------*/ + +int32_t EncodePredCoef( + int32_t *predQuant, + const int32_t numMSBands ) +{ + int32_t b, tmp1, tmp2; + + tmp1 = predQuant[0]; + for ( b = 1; b < numMSBands; b++ ) + { + tmp2 = predQuant[b]; + predQuant[b] -= tmp1; + tmp1 = tmp2; + } + + return numMSBands; +} + + +/*-------------------------------------------------------------------* + * Function DecodePredCoef() + * + * + *-------------------------------------------------------------------*/ + +void DecodePredCoef( + int32_t *phaseQuant, + const int32_t numMSBands ) +{ + int32_t b; + + for ( b = 1; b < numMSBands; b++ ) + { + phaseQuant[b] += phaseQuant[b - 1]; + } + + return; +} + + +/*-------------------------------------------------------------------* + * Function CountMSBits() + * + * + *-------------------------------------------------------------------*/ + +int32_t CountMSBits( + int32_t iNumBands, + const int32_t iMSMode, + const int32_t *piMSFlags, + const int32_t *piLRPhaseDiff, + const int32_t *piMSPredCoef ) +{ + int32_t iBitsWritten = 0; + int32_t b; + int32_t anyNonZero; + int32_t iNumMSBands = 0; + int32_t piPhaseCopy[MAX_BANDS_48]; + int32_t piPredCopy[MAX_BANDS_48]; + + for ( b = 0; b < MAX_BANDS_48; b++ ) + { + piPhaseCopy[b] = 0; + piPredCopy[b] = 0; + } + + iBitsWritten += 2; /* iMSMode */ + for ( b = 0; b < iNumBands; b++ ) + { + iNumMSBands += ( piMSFlags[b] != 0 ); + } + + if ( iNumMSBands == 0 ) + { + return iBitsWritten; + } + + if ( iNumMSBands < iNumBands ) + { + iBitsWritten += iNumBands; /* piMSFlags */ + } + + if ( iMSMode < 3 ) + { + return iBitsWritten; + } + + /* prepare arrays for coding evaluation */ + for ( b = 0; b < iNumBands; b++ ) + { + piPhaseCopy[b] = piLRPhaseDiff[b]; + piPredCopy[b] = piMSPredCoef[b]; + } + + /* Differential Coding of Phase Data*/ + PrepEncode( piPhaseCopy, piMSFlags, iNumBands ); + PrepEncode( piPredCopy, piMSFlags, iNumBands ); + EncodePhase( piPhaseCopy, iNumMSBands, PHASE_DIFF_DIM ); + EncodePredCoef( piPredCopy, iNumMSBands ); + + iBitsWritten += 1; /* iMSPredAll */ + anyNonZero = 0; /* phase */ + for ( b = 0; b < iNumMSBands; b++ ) + { + if ( piPhaseCopy[b] != 0 ) + { + anyNonZero = 1; + break; + } + } + iBitsWritten++; /*anyNonZero Phase*/ + if ( anyNonZero ) + { + iBitsWritten += PHASE_BAND0_BITS; + for ( b = 1; b < iNumMSBands; b++ ) + { + int32_t tabIdx = piPhaseCopy[b] - ENV_DELTA_MIN; + iBitsWritten += c_aaiRMSEnvHuffEnc[tabIdx][0]; + } + } + anyNonZero = 0; /* prediction */ + for ( b = 0; b < iNumMSBands; b++ ) + { + if ( piPredCopy[b] != 0 ) + { + anyNonZero = 1; + break; + } + } + + iBitsWritten++; /* any nonZero Pred */ + if ( anyNonZero ) + { + iBitsWritten += PRED_BAND0_BITS; + for ( b = 1; b < iNumMSBands; b++ ) + { + int32_t tabIdx = piPredCopy[b] - ENV_DELTA_MIN; + iBitsWritten += c_aaiRMSEnvHuffEnc[tabIdx][0]; + } + } + + return iBitsWritten; +} + + +#ifdef DEBUG_WRITE_MS_PRED +void writeMSPred( + int32_t *phaseQuant, + int32_t *predQuant, + int32_t MSMode, + int32_t numMSBands, + int32_t numBands, + void *fid, + int32_t *piMsFlags ) +{ + int32_t b; + + fid = (FILE *) fid; + fprintf( fid, "%d %d", MSMode, numMSBands ); + for ( b = 0; b < numMSBands; b++ ) + { + fprintf( fid, " %d", phaseQuant[b] ); + } + for ( b = numMSBands; b < numBands; b++ ) + { + fprintf( fid, " %d", 0 ); + } + for ( b = 0; b < numMSBands; b++ ) + { + fprintf( fid, " %d", predQuant[b] ); + } + for ( b = numMSBands; b < numBands; b++ ) + { + fprintf( fid, " %d", 0 ); + } + for ( b = 0; b < numBands; b++ ) + { + fprintf( fid, " %d", piMsFlags[b] ); + } + fprintf( fid, "\n" ); + + return; +} +#endif +#endif diff --git a/lib_isar/isar_NoiseGen.c b/lib_isar/isar_NoiseGen.c new file mode 100644 index 0000000000000000000000000000000000000000..63d91e17000f77f3e58b4cfa0599020654986889 --- /dev/null +++ b/lib_isar/isar_NoiseGen.c @@ -0,0 +1,57 @@ +/****************************************************************************************************** + + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#include +#include "options.h" +#ifdef SPLIT_REND_WITH_HEAD_ROT +#include +#include "prot.h" +#include "isar_lcld_prot.h" +#include "wmc_auto.h" + + +/*------------------------------------------------------------------------------------------* + * Function DeleteNoiseGen() + * + * + *------------------------------------------------------------------------------------------*/ + +void DeleteNoiseGen( NoiseGen *psNoiseGen ) +{ + free( psNoiseGen->pfNoiseBuffer ); + free( psNoiseGen ); + + return; +} + +extern float GetNoise( NoiseGen *psNoiseGen ); +#endif diff --git a/lib_isar/isar_PerceptualModel.c b/lib_isar/isar_PerceptualModel.c new file mode 100644 index 0000000000000000000000000000000000000000..18108c7fedfe3cc5de1a393b35c195e763f8c4e4 --- /dev/null +++ b/lib_isar/isar_PerceptualModel.c @@ -0,0 +1,252 @@ +/****************************************************************************************************** + + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#include +#include "options.h" +#ifdef SPLIT_REND_WITH_HEAD_ROT +#include "isar_lcld_prot.h" +#include "prot.h" +#include "isar_rom_lcld_tables.h" +#include +#include "wmc_auto.h" + + +/*------------------------------------------------------------------------------------------* + * Local constants + *------------------------------------------------------------------------------------------*/ + +#define PERCEPTUAL_MODEL_SCALE ( 64 ) +#define PERCEPTUAL_MODEL_ALPHA_SCALE ( 614 ) +#define PERCEPTUAL_MODEL_ALPHA_INV_SCALE ( 6827 ) +#define PERCEPTUAL_MODEL_ALPHA_SHIFT ( 11 ) + + +/*------------------------------------------------------------------------------------------* + * Function LogAdd() + * + * + *------------------------------------------------------------------------------------------*/ + +static inline int32_t LogAdd( + const int32_t iVal1, + const int32_t iVal2 ) +{ + int32_t iRetVal; + + if ( iVal1 > iVal2 ) + { + iRetVal = iVal1 - iVal2; + iRetVal = ( iRetVal < ( LOG_ADD_TABLE_LENGTH - 1 ) ) ? iRetVal : ( LOG_ADD_TABLE_LENGTH - 1 ); + iRetVal = iVal1 + c_aiLogAddTable[iRetVal]; + } + else + { + iRetVal = iVal2 - iVal1; + iRetVal = ( iRetVal < ( LOG_ADD_TABLE_LENGTH - 1 ) ) ? iRetVal : ( LOG_ADD_TABLE_LENGTH - 1 ); + iRetVal = iVal2 + c_aiLogAddTable[iRetVal]; + } + + return iRetVal; +} + + +/*------------------------------------------------------------------------------------------* + * Function PerceptualModel() + * + * + *------------------------------------------------------------------------------------------*/ + +void PerceptualModel( + const int32_t iMaxQuantBands, + const int32_t *piRMSEnvelope, + int32_t *piExcitation, + int32_t *piSMR ) +{ + int32_t n; + + for ( n = 0; n < iMaxQuantBands; n++ ) + { + int32_t iSLOffset; + + piExcitation[n] = PERCEPTUAL_MODEL_SCALE * piRMSEnvelope[n] + c_aiBandwidthAdjust48[n]; + + /* Calculate sensation level offset */ + iSLOffset = c_aiDefaultTheta48[n] * ( piExcitation[n] - c_aiAbsoluteThresh48[n] ) >> PERCEPTUAL_MODEL_SLGAIN_SHIFT; + + /* Offset envelope by sensation level offset */ + piExcitation[n] -= iSLOffset; + + /* Convert to loudness domain (x^0.3) */ + piExcitation[n] = PERCEPTUAL_MODEL_ALPHA_SCALE * piExcitation[n] >> PERCEPTUAL_MODEL_ALPHA_SHIFT; + } + + /* Spread excitation function */ + for ( n = 0; n < iMaxQuantBands; n++ ) + { + int32_t k; + const int32_t *piSpread; + + piSpread = &c_aaiSpreadFunction48[n * MAX_BANDS_48]; + piSMR[n] = piExcitation[n] + piSpread[n]; + for ( k = 0; k < iMaxQuantBands; k++ ) + { + if ( k != n ) + { + piSMR[n] = LogAdd( piSMR[n], piExcitation[k] + piSpread[k] ); + } + } + } + + for ( n = 0; n < iMaxQuantBands; n++ ) + { + piSMR[n] = PERCEPTUAL_MODEL_ALPHA_INV_SCALE * piSMR[n] >> PERCEPTUAL_MODEL_ALPHA_SHIFT; + piSMR[n] = PERCEPTUAL_MODEL_SCALE * piRMSEnvelope[n] + c_aiBandwidthAdjust48[n] - piSMR[n]; + } + + return; +} + + +/*------------------------------------------------------------------------------------------* + * Function PerceptualModelStereo() + * + * + *------------------------------------------------------------------------------------------*/ + +void PerceptualModelStereo( + const int32_t iMaxQuantBands, + const int32_t *piMSFlags, + const int32_t *piRMSEnvelope0, + const int32_t *piRMSEnvelope1, + int32_t *piExcitation0, + int32_t *piExcitation1, + int32_t *piSMR0, + int32_t *piSMR1 ) +{ + int32_t n; + + for ( n = 0; n < iMaxQuantBands; n++ ) + { + int32_t iMaxRMSEnv; + int32_t iSLOffset; + + iMaxRMSEnv = piRMSEnvelope0[n]; + + piExcitation0[n] = PERCEPTUAL_MODEL_SCALE * iMaxRMSEnv + c_aiBandwidthAdjust48[n]; /* piRMSEnvelope0[n] */ + + /* Calculate sensation level offset */ + iSLOffset = c_aiDefaultTheta48[n] * ( piExcitation0[n] - c_aiAbsoluteThresh48[n] ) >> PERCEPTUAL_MODEL_SLGAIN_SHIFT; + + /* Offset envelope by sensation level offset */ + piExcitation0[n] -= iSLOffset; + + /* Convert to loudness domain (x^0.3) */ + piExcitation0[n] = PERCEPTUAL_MODEL_ALPHA_SCALE * piExcitation0[n] >> PERCEPTUAL_MODEL_ALPHA_SHIFT; + } + + /* Spread excitation function */ + for ( n = 0; n < iMaxQuantBands; n++ ) + { + int32_t k; + const int32_t *piSpread; + + piSpread = &c_aaiSpreadFunction48[n * MAX_BANDS_48]; + piSMR0[n] = piExcitation0[n] + piSpread[n]; + for ( k = 0; k < iMaxQuantBands; k++ ) + { + if ( k != n ) + { + piSMR0[n] = LogAdd( piSMR0[n], piExcitation0[k] + piSpread[k] ); + } + } + } + + for ( n = 0; n < iMaxQuantBands; n++ ) + { + int32_t iMaxRMSEnv; + int32_t iSLOffset; + + iMaxRMSEnv = piRMSEnvelope1[n]; + + piExcitation1[n] = PERCEPTUAL_MODEL_SCALE * iMaxRMSEnv + c_aiBandwidthAdjust48[n]; /* piRMSEnvelope1[n] */ + + /* Calculate sensation level offset */ + iSLOffset = c_aiDefaultTheta48[n] * ( piExcitation1[n] - c_aiAbsoluteThresh48[n] ) >> PERCEPTUAL_MODEL_SLGAIN_SHIFT; + + /* Offset envelope by sensation level offset */ + piExcitation1[n] -= iSLOffset; + + /* Convert to loudness domain (x^0.3) */ + piExcitation1[n] = PERCEPTUAL_MODEL_ALPHA_SCALE * piExcitation1[n] >> PERCEPTUAL_MODEL_ALPHA_SHIFT; + } + + /* Spread excitation function */ + for ( n = 0; n < iMaxQuantBands; n++ ) + { + int32_t k; + const int32_t *piSpread; + + piSpread = &c_aaiSpreadFunction48[n * MAX_BANDS_48]; + piSMR1[n] = piExcitation1[n] + piSpread[n]; + for ( k = 0; k < iMaxQuantBands; k++ ) + { + if ( k != n ) + { + piSMR1[n] = LogAdd( piSMR1[n], piExcitation1[k] + piSpread[k] ); + } + } + } + + for ( n = 0; n < iMaxQuantBands; n++ ) + { + if ( piMSFlags[n] == 1 ) + { + piSMR0[n] = ( piSMR0[n] > piSMR1[n] ) ? piSMR0[n] : piSMR1[n]; + piSMR1[n] = piSMR0[n]; + } + } + + for ( n = 0; n < iMaxQuantBands; n++ ) + { + piSMR0[n] = PERCEPTUAL_MODEL_ALPHA_INV_SCALE * piSMR0[n] >> PERCEPTUAL_MODEL_ALPHA_SHIFT; + piSMR0[n] = PERCEPTUAL_MODEL_SCALE * piRMSEnvelope0[n] + c_aiBandwidthAdjust48[n] - piSMR0[n]; + } + + for ( n = 0; n < iMaxQuantBands; n++ ) + { + piSMR1[n] = PERCEPTUAL_MODEL_ALPHA_INV_SCALE * piSMR1[n] >> PERCEPTUAL_MODEL_ALPHA_SHIFT; + piSMR1[n] = PERCEPTUAL_MODEL_SCALE * piRMSEnvelope1[n] + c_aiBandwidthAdjust48[n] - piSMR1[n]; + } + + return; +} +#endif diff --git a/lib_isar/isar_PredDecoder.c b/lib_isar/isar_PredDecoder.c new file mode 100644 index 0000000000000000000000000000000000000000..df7a3ec62514a362cd7bbee3624c1b7a85b5c87f --- /dev/null +++ b/lib_isar/isar_PredDecoder.c @@ -0,0 +1,462 @@ +/****************************************************************************************************** + + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#include +#include "options.h" +#ifdef SPLIT_REND_WITH_HEAD_ROT +#include +#include "prot.h" +#include "isar_prot.h" +#include "isar_lcld_prot.h" +#include "isar_rom_lcld_tables.h" +#include "wmc_auto.h" + +/*-------------------------------------------------------------------* + * Function CreatePredictionDecoder() + * + * + *-------------------------------------------------------------------*/ + +ivas_error CreatePredictionDecoder( + PredictionDecoder **psPredictionDecoder_out, + const int32_t iChannels, + const int32_t iNumBlocks ) +{ + int16_t n; + int16_t m; + PredictionDecoder *psPredictionDecoder = NULL; + + if ( ( psPredictionDecoder = (PredictionDecoder *) malloc( sizeof( PredictionDecoder ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + + psPredictionDecoder->iChannels = iChannels; + psPredictionDecoder->iNumBlocks = iNumBlocks; + psPredictionDecoder->iNumSubSets = LCLD_BLOCKS_PER_FRAME / psPredictionDecoder->iNumBlocks; + psPredictionDecoder->iSubSetId = 0; + /* PLC_IMPROVEMENT */ + if ( ( psPredictionDecoder->ppiDecodingFailedPrev = (int32_t **) malloc( sizeof( int32_t * ) * iChannels ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD decoder Module \n" ) ); + } + if ( ( psPredictionDecoder->ppiDecodingFailed = (int32_t **) malloc( sizeof( int32_t * ) * iChannels ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD decoder Module \n" ) ); + } + if ( ( psPredictionDecoder->ppiDecodingUnresolved = (int32_t **) malloc( sizeof( int32_t * ) * iChannels ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD decoder Module \n" ) ); + } + for ( n = 0; n < iChannels; n++ ) + { + int32_t k; + if ( ( psPredictionDecoder->ppiDecodingUnresolved[n] = (int32_t *) malloc( sizeof( int32_t ) * LCLD_MAX_NUM_PRED_SUBSETS ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD decoder Module \n" ) ); + } + if ( ( psPredictionDecoder->ppiDecodingFailed[n] = (int32_t *) malloc( sizeof( int32_t ) * LCLD_MAX_NUM_PRED_SUBSETS ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD decoder Module \n" ) ); + } + if ( ( psPredictionDecoder->ppiDecodingFailedPrev[n] = (int32_t *) malloc( sizeof( int32_t ) * LCLD_MAX_NUM_PRED_SUBSETS ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD decoder Module \n" ) ); + } + for ( k = 0; k < LCLD_MAX_NUM_PRED_SUBSETS; k++ ) + { + psPredictionDecoder->ppiDecodingUnresolved[n][k] = 0; + psPredictionDecoder->ppiDecodingFailed[n][k] = 0; + psPredictionDecoder->ppiDecodingFailedPrev[n][k] = 0; + } + } + if ( ( psPredictionDecoder->piPredChanEnable = (int32_t *) malloc( sizeof( int32_t ) * iChannels ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + if ( ( psPredictionDecoder->ppiPredBandEnable = (int32_t **) malloc( sizeof( int32_t * ) * iChannels ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + if ( ( psPredictionDecoder->ppfA1Real = (float **) malloc( sizeof( float * ) * iChannels ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + if ( ( psPredictionDecoder->ppfA1Imag = (float **) malloc( sizeof( float * ) * iChannels ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + if ( ( psPredictionDecoder->ppiA1Mag = (int32_t **) malloc( sizeof( int32_t * ) * iChannels ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + if ( ( psPredictionDecoder->ppiA1Phase = (int32_t **) malloc( sizeof( int32_t * ) * iChannels ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + if ( ( psPredictionDecoder->ppfPredStateReal = (float **) malloc( sizeof( float * ) * iChannels ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD decoder Module \n" ) ); + } + if ( ( psPredictionDecoder->ppfPredStateImag = (float **) malloc( sizeof( float * ) * iChannels ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD decoder Module \n" ) ); + } + + for ( n = 0; n < psPredictionDecoder->iChannels; n++ ) + { + psPredictionDecoder->piPredChanEnable[n] = 0; + if ( ( psPredictionDecoder->ppiPredBandEnable[n] = (int32_t *) malloc( LCLD_BANDS * sizeof( int32_t ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + for ( m = 0; m < LCLD_BANDS; m++ ) + { + psPredictionDecoder->ppiPredBandEnable[n][m] = 0; + } + if ( ( psPredictionDecoder->ppfA1Real[n] = (float *) malloc( sizeof( float ) * LCLD_BANDS ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + if ( ( psPredictionDecoder->ppfA1Imag[n] = (float *) malloc( sizeof( float ) * LCLD_BANDS ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + if ( ( psPredictionDecoder->ppiA1Mag[n] = (int32_t *) malloc( sizeof( int32_t ) * LCLD_BANDS ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + if ( ( psPredictionDecoder->ppiA1Phase[n] = (int32_t *) malloc( sizeof( int32_t ) * LCLD_BANDS ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + if ( ( psPredictionDecoder->ppfPredStateReal[n] = (float *) malloc( LCLD_BANDS * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionDecoder Module \n" ) ); + } + if ( ( psPredictionDecoder->ppfPredStateImag[n] = (float *) malloc( LCLD_BANDS * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionDecoder Module \n" ) ); + } + for ( m = 0; m < LCLD_BANDS; m++ ) + { + psPredictionDecoder->ppfPredStateReal[n][m] = 0; + psPredictionDecoder->ppfPredStateImag[n][m] = 0; + } + } + + /* pre-define these tables? */ + for ( n = 0; n < ( 1 << PRED_QUNAT_FILTER_MAG_BITS ); n++ ) + { + const float fInvMagScale = M_PI / ( 2.0f * (float) ( 1 << ( PRED_QUNAT_FILTER_MAG_BITS ) ) + 1.0f ); + psPredictionDecoder->pfMagLUT[n] = sinf( fInvMagScale * (float) n ); + } + + for ( n = 0; n < ( 1 << PRED_QUANT_FILTER_PHASE_BITS ); n++ ) + { + const float fInvPhaseScale = M_PI / (float) ( 1 << ( PRED_QUANT_FILTER_PHASE_BITS - 1 ) ); + int16_t iVal; + + iVal = n + PRED_QUANT_FILTER_PHASE_MIN; + psPredictionDecoder->pfP2RRealLUT[n] = cosf( fInvPhaseScale * (float) iVal ); + psPredictionDecoder->pfP2RImagLUT[n] = sinf( fInvPhaseScale * (float) iVal ); + } + + *psPredictionDecoder_out = psPredictionDecoder; + + return IVAS_ERR_OK; +} + + +/*-------------------------------------------------------------------* + * Function DeletePredictionDecoder() + * + * + *-------------------------------------------------------------------*/ + +void DeletePredictionDecoder( + PredictionDecoder *psPredictionDecoder ) +{ + int32_t n; + + for ( n = 0; n < psPredictionDecoder->iChannels; n++ ) + { + free( psPredictionDecoder->ppiPredBandEnable[n] ); + free( psPredictionDecoder->ppfA1Real[n] ); + free( psPredictionDecoder->ppfA1Imag[n] ); + free( psPredictionDecoder->ppiA1Mag[n] ); + free( psPredictionDecoder->ppiA1Phase[n] ); + free( psPredictionDecoder->ppfPredStateReal[n] ); + free( psPredictionDecoder->ppfPredStateImag[n] ); + /* PLC_IMPROVEMENT */ + free( psPredictionDecoder->ppiDecodingUnresolved[n] ); + free( psPredictionDecoder->ppiDecodingFailed[n] ); + free( psPredictionDecoder->ppiDecodingFailedPrev[n] ); + } + free( psPredictionDecoder->piPredChanEnable ); + free( psPredictionDecoder->ppiPredBandEnable ); + free( psPredictionDecoder->ppfA1Real ); + free( psPredictionDecoder->ppfA1Imag ); + free( psPredictionDecoder->ppiA1Mag ); + free( psPredictionDecoder->ppiA1Phase ); + free( psPredictionDecoder->ppfPredStateReal ); + free( psPredictionDecoder->ppfPredStateImag ); + /* PLC_IMPROVEMENT */ + free( psPredictionDecoder->ppiDecodingUnresolved ); + free( psPredictionDecoder->ppiDecodingFailed ); + free( psPredictionDecoder->ppiDecodingFailedPrev ); + + free( psPredictionDecoder ); + psPredictionDecoder = NULL; + + return; +} + +/*-------------------------------------------------------------------* + * Function ReadPredictors() + * + * + *-------------------------------------------------------------------*/ + +int32_t ReadPredictors( + PredictionDecoder *psPredictionDecoder, + ISAR_SPLIT_REND_BITS_HANDLE pBits ) +{ + int16_t iBitsRead = 0; + int32_t c; + int32_t b; + int16_t iNumPredBandBits = 6; + const int16_t iSubSetBits = ( LCLD_MAX_NUM_PRED_SUBSETS > 4 ? 3 : 2 ); + + psPredictionDecoder->iNumSubSets = ISAR_SPLIT_REND_BITStream_read_int32( pBits, iSubSetBits ) + 1; + iBitsRead += iSubSetBits; + + if ( psPredictionDecoder->iNumSubSets > 1 ) + { + psPredictionDecoder->iSubSetId = ISAR_SPLIT_REND_BITStream_read_int32( pBits, iSubSetBits ); + iBitsRead += iSubSetBits; + iNumPredBandBits = ( psPredictionDecoder->iNumSubSets >= 4 ? 4 : 5 ); + } + else + { + psPredictionDecoder->iSubSetId = 0; + } + for ( c = 0; c < psPredictionDecoder->iChannels; c++ ) + { + psPredictionDecoder->piPredChanEnable[c] = ISAR_SPLIT_REND_BITStream_read_int32( pBits, psPredictionDecoder->iNumSubSets ); + iBitsRead += (int16_t) psPredictionDecoder->iNumSubSets; + + if ( get_bit( psPredictionDecoder->piPredChanEnable[c], psPredictionDecoder->iSubSetId ) ) + { + int32_t b0 = psPredictionDecoder->iSubSetId; + int32_t bstep = psPredictionDecoder->iNumSubSets; + int32_t iNumPredBands; + + for ( b = b0; b < LCLD_BANDS; b += bstep ) + { + psPredictionDecoder->ppiPredBandEnable[c][b] = 0; + } + iNumPredBands = ISAR_SPLIT_REND_BITStream_read_int32( pBits, iNumPredBandBits ); + iBitsRead += iNumPredBandBits; + iNumPredBands = iNumPredBands * psPredictionDecoder->iNumSubSets + b0; + + for ( b = b0; b < iNumPredBands; b += bstep ) + { + psPredictionDecoder->ppiPredBandEnable[c][b] = ISAR_SPLIT_REND_BITStream_read_int32( pBits, 1 ); + iBitsRead += 1; + + if ( psPredictionDecoder->ppiPredBandEnable[c][b] == 1 ) + { + int32_t iA1Mag; + int32_t iA1Phase; + float fA1Real; + float fA1Imag; + iA1Mag = ISAR_SPLIT_REND_BITStream_read_int32( pBits, PRED_QUNAT_FILTER_MAG_BITS ); + iBitsRead += PRED_QUNAT_FILTER_MAG_BITS; + iA1Phase = ISAR_SPLIT_REND_BITStream_read_int32( pBits, PRED_QUANT_FILTER_PHASE_BITS ); + iBitsRead += PRED_QUANT_FILTER_PHASE_BITS; + + psPredictionDecoder->ppiA1Mag[c][b] = iA1Mag; + psPredictionDecoder->ppiA1Phase[c][b] = iA1Phase + PRED_QUANT_FILTER_PHASE_MIN; + + fA1Real = psPredictionDecoder->pfMagLUT[iA1Mag] * psPredictionDecoder->pfP2RRealLUT[iA1Phase]; + fA1Imag = psPredictionDecoder->pfMagLUT[iA1Mag] * psPredictionDecoder->pfP2RImagLUT[iA1Phase]; + + psPredictionDecoder->ppfA1Real[c][b] = fA1Real; + psPredictionDecoder->ppfA1Imag[c][b] = fA1Imag; + } + } + } + } + + /* disable any inactive prediction bands */ + for ( c = 0; c < psPredictionDecoder->iChannels; c++ ) + { + int32_t set; + for ( set = 0; set < psPredictionDecoder->iNumSubSets; set++ ) + { + if ( !get_bit( psPredictionDecoder->piPredChanEnable[c], set ) ) + { + for ( b = set; b < LCLD_BANDS; b += psPredictionDecoder->iNumSubSets ) + { + psPredictionDecoder->ppiPredBandEnable[c][b] = 0; + } + } + } + } + + return iBitsRead; +} + +/* PLC_IMPROVEMENT */ +void SetDecodingPassed( PredictionDecoder *psPredictionDecoder ) +{ + int32_t n, ch; + for ( ch = 0; ch < psPredictionDecoder->iChannels; ch++ ) + { + for ( n = 0; n < psPredictionDecoder->iNumSubSets; n++ ) + { + psPredictionDecoder->ppiDecodingFailed[ch][n] = 0; + } + } +} +int32_t AnyDecodingUnresolved( PredictionDecoder *psPredictionDecoder ) +{ + int32_t n, ch; + for ( ch = 0; ch < psPredictionDecoder->iChannels; ch++ ) + { + for ( n = 0; n < psPredictionDecoder->iNumSubSets; n++ ) + { + if ( psPredictionDecoder->ppiDecodingUnresolved[ch][n] == 1 ) + { + return 1; + } + } + } + return 0; +} + +void UpdateDecodingFailedStatus( PredictionDecoder *psPredictionDecoder ) +{ + int32_t n, ch; + for ( ch = 0; ch < psPredictionDecoder->iChannels; ch++ ) + { + for ( n = 0; n < psPredictionDecoder->iNumSubSets; n++ ) + { + psPredictionDecoder->ppiDecodingFailedPrev[ch][n] = psPredictionDecoder->ppiDecodingFailed[ch][n]; + } + } +} + +void UpdateDecodingUnresolved( PredictionDecoder *psPredictionDecoder ) +{ + int32_t n, ch; + + int32_t iCurrentSubSet = psPredictionDecoder->iSubSetId; + + for ( ch = 0; ch < psPredictionDecoder->iChannels; ch++ ) + { + /* Prediction data always available for current subset */ + psPredictionDecoder->ppiDecodingUnresolved[ch][iCurrentSubSet] = 0; + + for ( n = 0; n < psPredictionDecoder->iNumSubSets; n++ ) + { + int32_t iSubSetActive = get_bit( psPredictionDecoder->piPredChanEnable[ch], n ); + if ( iSubSetActive == 0 ) + { + /* Prediction information available inactive subsets (e.g. no Prediction) */ + psPredictionDecoder->ppiDecodingUnresolved[ch][n] = 0; + } + } + } +} + +/*-------------------------------------------------------------------* + * Function ApplyInversePredictors() + * + * + *-------------------------------------------------------------------*/ + +void ApplyInversePredictors( + PredictionDecoder *psPredictionDecoder, + float ***pppfReal, + float ***pppfImag ) +{ + int32_t c; + for ( c = 0; c < psPredictionDecoder->iChannels; c++ ) + { + if ( psPredictionDecoder->piPredChanEnable[c] > 0 ) + { + int32_t b; + for ( b = 0; b < LCLD_BANDS; b++ ) + { + if ( psPredictionDecoder->ppiPredBandEnable[c][b] == 1 ) + { + int32_t n; + float fA1Real; + float fA1Imag; + float fPrevReal = 0.0f; + float fPrevImag = 0.0f; + int32_t iSubset = b % psPredictionDecoder->iNumSubSets; + + if ( iSubset != psPredictionDecoder->iSubSetId ) + { + fPrevReal = psPredictionDecoder->ppfPredStateReal[c][b]; + fPrevImag = psPredictionDecoder->ppfPredStateImag[c][b]; + } + + fA1Real = psPredictionDecoder->ppfA1Real[c][b]; + fA1Imag = psPredictionDecoder->ppfA1Imag[c][b]; + for ( n = 0; n < psPredictionDecoder->iNumBlocks; n++ ) + { + float fReal; + float fImag; + + fReal = pppfReal[c][n][b] - fA1Real * fPrevReal + fA1Imag * fPrevImag; + fImag = pppfImag[c][n][b] - fA1Real * fPrevImag - fA1Imag * fPrevReal; + + pppfReal[c][n][b] = fReal; + pppfImag[c][n][b] = fImag; + + fPrevReal = fReal; + fPrevImag = fImag; + } + psPredictionDecoder->ppfPredStateReal[c][b] = fPrevReal; + psPredictionDecoder->ppfPredStateImag[c][b] = fPrevImag; + } + } + } + } + + return; +} +#endif diff --git a/lib_isar/isar_PredEncoder.c b/lib_isar/isar_PredEncoder.c new file mode 100644 index 0000000000000000000000000000000000000000..57dff9dac7e93afc03a25248d45667c46be4e73c --- /dev/null +++ b/lib_isar/isar_PredEncoder.c @@ -0,0 +1,577 @@ +/****************************************************************************************************** + + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#include +#include "options.h" +#ifdef SPLIT_REND_WITH_HEAD_ROT +#include +#include "isar_lcld_prot.h" +#include "isar_rom_lcld_tables.h" +#include "prot.h" +#include "isar_prot.h" +#include "wmc_auto.h" + + +/*-------------------------------------------------------------------* + * Function activate_bit() + * + * + *-------------------------------------------------------------------*/ +static void activate_bit( + int32_t *state, + const int32_t bit_id ) +{ + ( *state ) |= ( 1 << bit_id ); +} + +/*-------------------------------------------------------------------* + * Function deactivate_bit() + * + * + *-------------------------------------------------------------------*/ + +static void deactivate_bit( + int32_t *state, + const int32_t bit_id ) +{ + ( *state ) &= ( ~( 1 << bit_id ) ); +} + +void UpdatePredictionSubSetId( PredictionEncoder *psPredictionEncoder ) +{ + if ( ++psPredictionEncoder->iSubSetId == psPredictionEncoder->iNumSubSets ) + { + psPredictionEncoder->iSubSetId = 0; + } +} + +/*-------------------------------------------------------------------* + * Function CreatePredictionEncoder() + * + * + *-------------------------------------------------------------------*/ + +ivas_error CreatePredictionEncoder( + PredictionEncoder **psPredictionEncoder_out, + const int32_t iChannels, + const int32_t iNumBlocks, + const int32_t iNumSubSets, + const int32_t iMaxNumPredBands ) +{ + int32_t k, n; + PredictionEncoder *psPredictionEncoder = NULL; + + if ( ( psPredictionEncoder = (PredictionEncoder *) malloc( sizeof( PredictionEncoder ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionEncoder Module \n" ) ); + } + + psPredictionEncoder->iChannels = iChannels; + psPredictionEncoder->iNumBlocks = iNumBlocks; + psPredictionEncoder->iSubSetId = 0; + psPredictionEncoder->iMaxNumPredBands = iMaxNumPredBands; + psPredictionEncoder->iNumSubSets = iNumSubSets; + + if ( ( psPredictionEncoder->piPredChanEnable = (int32_t *) malloc( sizeof( int32_t ) * iChannels ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionEncoder Module \n" ) ); + } + + if ( ( psPredictionEncoder->piNumPredBands = (int32_t *) malloc( sizeof( int32_t ) * iChannels ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionEncoder Module \n" ) ); + } + for ( n = 0; n < psPredictionEncoder->iChannels; n++ ) + { + psPredictionEncoder->piPredChanEnable[n] = 0; + psPredictionEncoder->piNumPredBands[n] = 40; + } + + if ( ( psPredictionEncoder->ppiPredBandEnable = (int32_t **) malloc( sizeof( int32_t * ) * iChannels ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionEncoder Module \n" ) ); + } + if ( ( psPredictionEncoder->ppfA1Real = (float **) malloc( sizeof( float * ) * iChannels ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionEncoder Module \n" ) ); + } + if ( ( psPredictionEncoder->ppfA1Imag = (float **) malloc( sizeof( float * ) * iChannels ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionEncoder Module \n" ) ); + } + if ( ( psPredictionEncoder->ppiA1Mag = (int32_t **) malloc( sizeof( int32_t * ) * iChannels ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionEncoder Module \n" ) ); + } + if ( ( psPredictionEncoder->ppiA1Phase = (int32_t **) malloc( sizeof( int32_t * ) * iChannels ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionEncoder Module \n" ) ); + } + if ( ( psPredictionEncoder->pppfInpBufReal = (float ***) malloc( sizeof( float ** ) * iChannels ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionEncoder Module \n" ) ); + } + if ( ( psPredictionEncoder->pppfInpBufImag = (float ***) malloc( sizeof( float ** ) * iChannels ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionEncoder Module \n" ) ); + } + if ( ( psPredictionEncoder->ppfInpPrevReal = (float **) malloc( sizeof( float * ) * iChannels ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionEncoder Module \n" ) ); + } + if ( ( psPredictionEncoder->ppfInpPrevImag = (float **) malloc( sizeof( float * ) * iChannels ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionEncoder Module \n" ) ); + } + if ( ( psPredictionEncoder->ppfPredStateReal = (float **) malloc( sizeof( float * ) * iChannels ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionEncoder Module \n" ) ); + } + if ( ( psPredictionEncoder->ppfPredStateImag = (float **) malloc( sizeof( float * ) * iChannels ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionEncoder Module \n" ) ); + } + if ( ( psPredictionEncoder->ppfPredStateRealTmp = (float **) malloc( sizeof( float * ) * iChannels ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionEncoder Module \n" ) ); + } + if ( ( psPredictionEncoder->ppfPredStateImagTmp = (float **) malloc( sizeof( float * ) * iChannels ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionEncoder Module \n" ) ); + } + + for ( n = 0; n < psPredictionEncoder->iChannels; n++ ) + { + if ( ( psPredictionEncoder->ppiPredBandEnable[n] = (int32_t *) malloc( sizeof( int32_t ) * LCLD_BANDS ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionEncoder Module \n" ) ); + } + if ( ( psPredictionEncoder->ppfA1Real[n] = (float *) malloc( sizeof( float ) * LCLD_BANDS ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionEncoder Module \n" ) ); + } + if ( ( psPredictionEncoder->ppfA1Imag[n] = (float *) malloc( sizeof( float ) * LCLD_BANDS ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionEncoder Module \n" ) ); + } + if ( ( psPredictionEncoder->ppiA1Mag[n] = (int32_t *) malloc( sizeof( int32_t ) * LCLD_BANDS ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionEncoder Module \n" ) ); + } + if ( ( psPredictionEncoder->ppiA1Phase[n] = (int32_t *) malloc( sizeof( int32_t ) * LCLD_BANDS ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionEncoder Module \n" ) ); + } + if ( ( psPredictionEncoder->pppfInpBufReal[n] = (float **) malloc( sizeof( float * ) * LCLD_PRED_WIN_LEN ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionEncoder Module \n" ) ); + } + if ( ( psPredictionEncoder->pppfInpBufImag[n] = (float **) malloc( sizeof( float * ) * LCLD_PRED_WIN_LEN ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionEncoder Module \n" ) ); + } + for ( k = 0; k < LCLD_PRED_WIN_LEN; k++ ) + { + if ( ( psPredictionEncoder->pppfInpBufReal[n][k] = (float *) malloc( LCLD_BANDS * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionEncoder Module \n" ) ); + } + if ( ( psPredictionEncoder->pppfInpBufImag[n][k] = (float *) malloc( LCLD_BANDS * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionEncoder Module \n" ) ); + } + set_zero( psPredictionEncoder->pppfInpBufReal[n][k], LCLD_BANDS ); + set_zero( psPredictionEncoder->pppfInpBufImag[n][k], LCLD_BANDS ); + } + if ( ( psPredictionEncoder->ppfPredStateReal[n] = (float *) malloc( LCLD_BANDS * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionEncoder Module \n" ) ); + } + if ( ( psPredictionEncoder->ppfPredStateImag[n] = (float *) malloc( LCLD_BANDS * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionEncoder Module \n" ) ); + } + set_zero( psPredictionEncoder->ppfPredStateReal[n], LCLD_BANDS ); + set_zero( psPredictionEncoder->ppfPredStateImag[n], LCLD_BANDS ); + + if ( ( psPredictionEncoder->ppfInpPrevReal[n] = (float *) malloc( LCLD_BANDS * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionEncoder Module \n" ) ); + } + if ( ( psPredictionEncoder->ppfInpPrevImag[n] = (float *) malloc( LCLD_BANDS * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionEncoder Module \n" ) ); + } + + set_zero( psPredictionEncoder->ppfInpPrevReal[n], LCLD_BANDS ); + set_zero( psPredictionEncoder->ppfInpPrevImag[n], LCLD_BANDS ); + + if ( ( psPredictionEncoder->ppfPredStateRealTmp[n] = (float *) malloc( LCLD_BANDS * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionEncoder Module \n" ) ); + } + if ( ( psPredictionEncoder->ppfPredStateImagTmp[n] = (float *) malloc( LCLD_BANDS * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionEncoder Module \n" ) ); + } + set_zero( psPredictionEncoder->ppfPredStateRealTmp[n], LCLD_BANDS ); + set_zero( psPredictionEncoder->ppfPredStateImagTmp[n], LCLD_BANDS ); + for ( k = 0; k < LCLD_BANDS; k++ ) + { + psPredictionEncoder->ppiPredBandEnable[n][k] = 0; + psPredictionEncoder->ppfA1Real[n][k] = 0.0f; + psPredictionEncoder->ppfA1Imag[n][k] = 0.0f; + } + } + + *psPredictionEncoder_out = psPredictionEncoder; + + return IVAS_ERR_OK; +} + + +/*-------------------------------------------------------------------* + * Function DeletePredictionEncoder() + * + * + *-------------------------------------------------------------------*/ + +void DeletePredictionEncoder( + PredictionEncoder *psPredictionEncoder ) +{ + int32_t n; + for ( n = 0; n < psPredictionEncoder->iChannels; n++ ) + { + int32_t k; + free( psPredictionEncoder->ppiPredBandEnable[n] ); + free( psPredictionEncoder->ppfA1Real[n] ); + free( psPredictionEncoder->ppfA1Imag[n] ); + free( psPredictionEncoder->ppiA1Mag[n] ); + free( psPredictionEncoder->ppiA1Phase[n] ); + for ( k = 0; k < LCLD_PRED_WIN_LEN; k++ ) + { + free( psPredictionEncoder->pppfInpBufReal[n][k] ); + free( psPredictionEncoder->pppfInpBufImag[n][k] ); + } + free( psPredictionEncoder->pppfInpBufReal[n] ); + free( psPredictionEncoder->pppfInpBufImag[n] ); + free( psPredictionEncoder->ppfInpPrevReal[n] ); + free( psPredictionEncoder->ppfInpPrevImag[n] ); + free( psPredictionEncoder->ppfPredStateReal[n] ); + free( psPredictionEncoder->ppfPredStateImag[n] ); + free( psPredictionEncoder->ppfPredStateRealTmp[n] ); + free( psPredictionEncoder->ppfPredStateImagTmp[n] ); + } + free( psPredictionEncoder->piPredChanEnable ); + free( psPredictionEncoder->piNumPredBands ); + free( psPredictionEncoder->ppiPredBandEnable ); + free( psPredictionEncoder->ppfA1Real ); + free( psPredictionEncoder->ppfA1Imag ); + free( psPredictionEncoder->ppiA1Mag ); + free( psPredictionEncoder->ppiA1Phase ); + free( psPredictionEncoder->pppfInpBufReal ); + free( psPredictionEncoder->pppfInpBufImag ); + free( psPredictionEncoder->ppfInpPrevReal ); + free( psPredictionEncoder->ppfInpPrevImag ); + free( psPredictionEncoder->ppfPredStateReal ); + free( psPredictionEncoder->ppfPredStateImag ); + free( psPredictionEncoder->ppfPredStateRealTmp ); + free( psPredictionEncoder->ppfPredStateImagTmp ); + + + free( psPredictionEncoder ); + + return; +} + + +/*-------------------------------------------------------------------* + * Function ComputePredictors() + * + * + *-------------------------------------------------------------------*/ + +void ComputePredictors( + PredictionEncoder *psPredictionEncoder, + float ***pppfReal, + float ***pppfImag ) +{ + int32_t c; + + int32_t b0 = psPredictionEncoder->iSubSetId; + int32_t bstep = psPredictionEncoder->iNumSubSets; + int32_t iNumBlocks = psPredictionEncoder->iNumBlocks; + float ***pppfRealBuf; + float ***pppfImagBuf; + float pfEstPredBitGain[LCLD_BANDS] = { 0 }; + + if ( iNumBlocks < LCLD_PRED_WIN_LEN ) + { + pppfRealBuf = psPredictionEncoder->pppfInpBufReal; + pppfImagBuf = psPredictionEncoder->pppfInpBufImag; + for ( c = 0; c < psPredictionEncoder->iChannels; c++ ) + { + int32_t n; + for ( n = 0; n < LCLD_PRED_WIN_LEN - iNumBlocks; n++ ) + { + mvr2r( pppfRealBuf[c][n + iNumBlocks], pppfRealBuf[c][n], LCLD_BANDS ); + mvr2r( pppfImagBuf[c][n + iNumBlocks], pppfImagBuf[c][n], LCLD_BANDS ); + } + for ( n = 0; n < iNumBlocks; n++ ) + { + mvr2r( pppfReal[c][n], pppfRealBuf[c][n + LCLD_PRED_WIN_LEN - iNumBlocks], LCLD_BANDS ); + mvr2r( pppfImag[c][n], pppfImagBuf[c][n + LCLD_PRED_WIN_LEN - iNumBlocks], LCLD_BANDS ); + } + } + } + else + { + pppfRealBuf = pppfReal; + pppfImagBuf = pppfImag; + } + + for ( c = 0; c < psPredictionEncoder->iChannels; c++ ) + { + int32_t b; + for ( b = b0; b < psPredictionEncoder->iMaxNumPredBands; b += bstep ) + { + int32_t n; + float fGain = 0.0; + float fBitGain = 0.0; + float *pfRxxReal; + float *pfRxxImag; + float fA1Real; + float fA1Imag; + int32_t iA1Mag; + int32_t iA1Phase; + + pfRxxReal = psPredictionEncoder->pfRxxReal; + pfRxxImag = psPredictionEncoder->pfRxxImag; + + pfRxxReal[0] = 0.0; + pfRxxImag[0] = 0.0; + for ( n = 0; n < LCLD_PRED_WIN_LEN; n++ ) + { + pfRxxReal[0] += ( pppfRealBuf[c][n][b] * pppfRealBuf[c][n][b] + pppfImagBuf[c][n][b] * pppfImagBuf[c][n][b] ); + } + + pfRxxReal[1] = 0.0; + pfRxxImag[1] = 0.0; + for ( n = 1; n < LCLD_PRED_WIN_LEN; n++ ) + { + pfRxxReal[1] += ( pppfRealBuf[c][n][b] * pppfRealBuf[c][n - 1][b] + pppfImagBuf[c][n][b] * pppfImagBuf[c][n - 1][b] ); + pfRxxImag[1] += ( pppfImagBuf[c][n][b] * pppfRealBuf[c][n - 1][b] - pppfRealBuf[c][n][b] * pppfImagBuf[c][n - 1][b] ); + } + + if ( pfRxxReal[0] > 1e-12f ) + { + float fA1Mag; + float fA1Phase; + float fGain2; + float fBitGain2; + int32_t iNumBlocksPerPredCoef = min( iNumBlocks * psPredictionEncoder->iNumSubSets, LCLD_PRED_WIN_LEN ); + + const float fMagScale = ( 2.0f * (float) ( 1 << ( PRED_QUNAT_FILTER_MAG_BITS ) ) + 1.0f ) / M_PI; + const float fInvMagScale = M_PI / ( 2.0f * (float) ( 1 << ( PRED_QUNAT_FILTER_MAG_BITS ) ) + 1.0f ); + const float fPhaseScale = (float) ( 1 << ( PRED_QUANT_FILTER_PHASE_BITS - 1 ) ) / M_PI; + const float fInvPhaseScale = M_PI / (float) ( 1 << ( PRED_QUANT_FILTER_PHASE_BITS - 1 ) ); + + /* Compute filter coefficeints */ + fA1Real = -pfRxxReal[1] / pfRxxReal[0]; + fA1Imag = -pfRxxImag[1] / pfRxxReal[0]; + + /* compute these before quant */ + /* Compute est coding gain based on quantized filter coefficients */ + fGain = 1.0f / ( 1.0f - fA1Real * fA1Real - fA1Imag * fA1Imag ); + fBitGain = 0.65f * log2f( fGain ) * (float) ( iNumBlocksPerPredCoef ) - (float) ( PRED_QUNAT_FILTER_MAG_BITS + PRED_QUANT_FILTER_PHASE_BITS ); + fA1Mag = sqrtf( fA1Real * fA1Real + fA1Imag * fA1Imag ); + fA1Mag = fMagScale * asinf( fA1Mag ); + iA1Mag = (int32_t) ( fA1Mag + 0.5f ); + iA1Mag = ( iA1Mag > PRED_QUANT_FILTER_MAG_MIN ) ? iA1Mag : PRED_QUANT_FILTER_MAG_MIN; + iA1Mag = ( iA1Mag < PRED_QUANT_FILTER_MAG_MAX ) ? iA1Mag : PRED_QUANT_FILTER_MAG_MAX; + fA1Mag = sinf( fInvMagScale * (float) iA1Mag ); + + fA1Phase = atan2f( fA1Imag, fA1Real ); + fA1Phase = fPhaseScale * fA1Phase; + iA1Phase = ( fA1Phase > 0.0f ) ? (int32_t) ( fA1Phase + 0.5f ) : (int32_t) ( fA1Phase - 0.5f ); + iA1Phase = ( iA1Phase > PRED_QUANT_FILTER_PHASE_MIN ) ? iA1Phase : PRED_QUANT_FILTER_PHASE_MIN; + iA1Phase = ( iA1Phase < PRED_QUANT_FILTER_PHASE_MAX ) ? iA1Phase : PRED_QUANT_FILTER_PHASE_MAX; + fA1Phase = fInvPhaseScale * (float) iA1Phase; + + fA1Real = fA1Mag * cosf( fA1Phase ); + fA1Imag = fA1Mag * sinf( fA1Phase ); + + fGain2 = 1.0f / ( 1.0f - fA1Real * fA1Real - fA1Imag * fA1Imag ); + fBitGain2 = 0.65f * log2f( fGain ) * (float) ( iNumBlocksPerPredCoef ) - (float) ( PRED_QUNAT_FILTER_MAG_BITS + PRED_QUANT_FILTER_PHASE_BITS ); + fGain = ( fGain < fGain2 ) ? fGain : fGain2; + fBitGain = ( fBitGain < fBitGain2 ) ? fBitGain : fBitGain2; + } + else + { + fA1Real = 0.0f; + fA1Imag = 0.0f; + iA1Mag = 0; + iA1Phase = 0; + fGain = -10.0f; + } + + pfEstPredBitGain[b] = fBitGain; + psPredictionEncoder->ppiPredBandEnable[c][b] = ( fBitGain > 0.0f ); + psPredictionEncoder->ppfA1Real[c][b] = fA1Real; + psPredictionEncoder->ppfA1Imag[c][b] = fA1Imag; + psPredictionEncoder->ppiA1Mag[c][b] = iA1Mag; + psPredictionEncoder->ppiA1Phase[c][b] = iA1Phase; + } + + { + float fBestCost; + int32_t iPredBands; + float fBitGain; + int32_t iPredChanEnable = 0; + + fBestCost = 0.0; + iPredBands = 0; + fBitGain = -7.0; + for ( b = b0; b < psPredictionEncoder->iMaxNumPredBands; b += bstep ) + { + fBitGain -= 1.0; + if ( psPredictionEncoder->ppiPredBandEnable[c][b] == 1 ) + { + fBitGain += pfEstPredBitGain[b]; + } + if ( fBitGain > fBestCost ) + { + fBestCost = fBitGain; + iPredBands = b; + iPredChanEnable = 1; + } + } + + if ( iPredChanEnable == 1 ) + { + for ( b = iPredBands + bstep; b < LCLD_BANDS; b += bstep ) + { + psPredictionEncoder->ppiPredBandEnable[c][b] = 0; + } + activate_bit( &psPredictionEncoder->piPredChanEnable[c], psPredictionEncoder->iSubSetId ); + psPredictionEncoder->piNumPredBands[c] = iPredBands + bstep; + } + else + { + for ( b = b0; b < LCLD_BANDS; b += bstep ) + { + psPredictionEncoder->ppiPredBandEnable[c][b] = 0; + } + deactivate_bit( &psPredictionEncoder->piPredChanEnable[c], psPredictionEncoder->iSubSetId ); + psPredictionEncoder->piNumPredBands[c] = 0; + } + } + } +} + + +/*-------------------------------------------------------------------* + * Function ApplyForwardPredictors() + * + * + *-------------------------------------------------------------------*/ + +/*-------------------------------------------------------------------* + * Function WritePredictors() + * + * + *-------------------------------------------------------------------*/ + +int32_t WritePredictors( + PredictionEncoder *psPredictionEncoder, + ISAR_SPLIT_REND_BITS_HANDLE pBits ) +{ + int32_t iBitsWritten = 0; + int32_t c; + int32_t iNumSubSets = psPredictionEncoder->iNumSubSets; + int32_t iSubSetId = psPredictionEncoder->iSubSetId; + int32_t iNumPredBandBits = 6; + const int16_t iSubSetBits = ( LCLD_MAX_NUM_PRED_SUBSETS > 4 ? 3 : 2 ); + + /* number of subsets */ + ISAR_SPLIT_REND_BITStream_write_int32( pBits, iNumSubSets - 1, iSubSetBits ); /* otherwise use default */ + iBitsWritten += iSubSetBits; + + if ( iNumSubSets > 1 ) + { + /* write current subset */ + ISAR_SPLIT_REND_BITStream_write_int32( pBits, iSubSetId, iSubSetBits ); + iBitsWritten += iSubSetBits; + iNumPredBandBits = ( iNumSubSets >= 4 ? 4 : 5 ); + } + + for ( c = 0; c < psPredictionEncoder->iChannels; c++ ) + { + int32_t b; + int32_t b0 = iSubSetId; + + ISAR_SPLIT_REND_BITStream_write_int32( pBits, psPredictionEncoder->piPredChanEnable[c], iNumSubSets ); + iBitsWritten += iNumSubSets; + + if ( get_bit( psPredictionEncoder->piPredChanEnable[c], iSubSetId ) ) + { + int32_t iNumPredBands = ( psPredictionEncoder->piNumPredBands[c] - b0 ) / iNumSubSets; + + ISAR_SPLIT_REND_BITStream_write_int32( pBits, iNumPredBands, iNumPredBandBits ); + iBitsWritten += iNumPredBandBits; + + for ( b = b0; b < psPredictionEncoder->piNumPredBands[c]; b += iNumSubSets ) + { + ISAR_SPLIT_REND_BITStream_write_int32( pBits, psPredictionEncoder->ppiPredBandEnable[c][b], 1 ); + iBitsWritten += 1; + + if ( psPredictionEncoder->ppiPredBandEnable[c][b] == 1 ) + { + int32_t iA1Mag; + int32_t iA1Phase; + + iA1Mag = psPredictionEncoder->ppiA1Mag[c][b]; + iA1Phase = psPredictionEncoder->ppiA1Phase[c][b] - PRED_QUANT_FILTER_PHASE_MIN; + + ISAR_SPLIT_REND_BITStream_write_int32( pBits, iA1Mag, PRED_QUNAT_FILTER_MAG_BITS ); + iBitsWritten += PRED_QUNAT_FILTER_MAG_BITS; + + ISAR_SPLIT_REND_BITStream_write_int32( pBits, iA1Phase, PRED_QUANT_FILTER_PHASE_BITS ); + iBitsWritten += PRED_QUANT_FILTER_PHASE_BITS; + } + } + } + } + + return iBitsWritten; +} +#endif diff --git a/lib_isar/isar_RMSEnvGrouping.c b/lib_isar/isar_RMSEnvGrouping.c new file mode 100644 index 0000000000000000000000000000000000000000..b66404dd90abf40ec3a2780b93824b227bd9d64f --- /dev/null +++ b/lib_isar/isar_RMSEnvGrouping.c @@ -0,0 +1,727 @@ +/****************************************************************************************************** + + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#include +#include "options.h" +#ifdef SPLIT_REND_WITH_HEAD_ROT +#include +#include "prot.h" +#include "isar_lcld_prot.h" +#include "isar_rom_lcld_tables.h" +#include "wmc_auto.h" + + +/*-------------------------------------------------------------------* + * Local ROM tables + * + * + *-------------------------------------------------------------------*/ + +static const float c_afThreshQuiet48[23] = { + -8.40653699e+01f, + -8.40653699e+01f, + -8.40653699e+01f, + -8.40653699e+01f, + -8.40653699e+01f, + -8.40653699e+01f, + -8.40653699e+01f, + -8.40653699e+01f, + -8.38067304e+01f, + -8.28409495e+01f, + -8.17031225e+01f, + -7.89799501e+01f, + -7.70607916e+01f, + -7.58484320e+01f, + -7.47976303e+01f, + -7.37491303e+01f, + -7.13163746e+01f, + -6.86144293e+01f, + -6.56295695e+01f, + -6.06521800e+01f, + -3.15408065e+01f, + -1.92542188e+01f, + -1.88401753e+01f, +}; + +static const float c_fiDefaultTheta48[MAX_BANDS_48] = { + 0.4375, + 0.4375, + 0.375, + 0.3125, + 0.3125, + 0.25, + 0.25, + 0.25, + 0.25, + 0.25, + 0.25, + 0.25, + 0.25, + 0.25, + 0.25, + 0.25, + 0.25, + 0.25, + 0.25, + 0.25, + 0.25, + 0.25, + 0.25, +}; + +typedef struct GMNODE +{ + int32_t iGroupStart; + int32_t iGroupLength; + float *pfMergedEnergydB; + int32_t *piQRMSEnvelope; + + int32_t iGroupRMSEnvelopeCost; + float fGroupSNRPenalty; + + struct GMNODE *psNext; +} GMNode; + +struct RMS_ENVELOPE_GROUPING +{ + int32_t iNumBlocks; + int32_t iMaxGroups; + float **ppfBandEnergy; + float **ppfBandEnergydB; + float **ppfWeight; + GMNode *psGMNodes; +}; + + +/*-------------------------------------------------------------------* + * Function CreateRMSEnvelopeGrouping() + * + * + *-------------------------------------------------------------------*/ + +RMSEnvelopeGrouping *CreateRMSEnvelopeGrouping( + const int32_t iNumBlocks ) +{ + int32_t n; + + RMSEnvelopeGrouping *psRMSEnvelopeGrouping; + + psRMSEnvelopeGrouping = (RMSEnvelopeGrouping *) malloc( sizeof( RMSEnvelopeGrouping ) ); + psRMSEnvelopeGrouping->iNumBlocks = iNumBlocks; + + psRMSEnvelopeGrouping->iMaxGroups = iNumBlocks >> 1; + + psRMSEnvelopeGrouping->ppfBandEnergy = (float **) malloc( psRMSEnvelopeGrouping->iNumBlocks * sizeof( float * ) ); + psRMSEnvelopeGrouping->ppfBandEnergydB = (float **) malloc( psRMSEnvelopeGrouping->iNumBlocks * sizeof( float * ) ); + psRMSEnvelopeGrouping->ppfWeight = (float **) malloc( psRMSEnvelopeGrouping->iNumBlocks * sizeof( float * ) ); + for ( n = 0; n < psRMSEnvelopeGrouping->iNumBlocks; n++ ) + { + psRMSEnvelopeGrouping->ppfBandEnergy[n] = (float *) malloc( MAX_BANDS * 2 * sizeof( float ) ); /* 2 for stereo joint group calc */ + psRMSEnvelopeGrouping->ppfBandEnergydB[n] = (float *) malloc( MAX_BANDS * 2 * sizeof( float ) ); + psRMSEnvelopeGrouping->ppfWeight[n] = (float *) malloc( MAX_BANDS * 2 * sizeof( float ) ); + } + + psRMSEnvelopeGrouping->psGMNodes = (GMNode *) malloc( psRMSEnvelopeGrouping->iNumBlocks * sizeof( GMNode ) ); + for ( n = 0; n < psRMSEnvelopeGrouping->iNumBlocks; n++ ) + { + psRMSEnvelopeGrouping->psGMNodes[n].pfMergedEnergydB = (float *) malloc( MAX_BANDS * 2 * sizeof( float ) ); + psRMSEnvelopeGrouping->psGMNodes[n].piQRMSEnvelope = (int32_t *) malloc( MAX_BANDS * 2 * sizeof( int32_t ) ); + psRMSEnvelopeGrouping->psGMNodes[n].iGroupRMSEnvelopeCost = -1; + psRMSEnvelopeGrouping->psGMNodes[n].fGroupSNRPenalty = -1.0; + } + + return psRMSEnvelopeGrouping; +} + + +/*-------------------------------------------------------------------* + * Function DeleteRMSEnvelopeGrouping() + * + * + *-------------------------------------------------------------------*/ + +void DeleteRMSEnvelopeGrouping( + RMSEnvelopeGrouping *psRMSEnvelopeGrouping ) +{ + int32_t n; + + for ( n = 0; n < psRMSEnvelopeGrouping->iNumBlocks; n++ ) + { + free( psRMSEnvelopeGrouping->ppfBandEnergy[n] ); + free( psRMSEnvelopeGrouping->ppfBandEnergydB[n] ); + free( psRMSEnvelopeGrouping->ppfWeight[n] ); + } + free( psRMSEnvelopeGrouping->ppfBandEnergy ); + free( psRMSEnvelopeGrouping->ppfBandEnergydB ); + free( psRMSEnvelopeGrouping->ppfWeight ); + + for ( n = 0; n < psRMSEnvelopeGrouping->iNumBlocks; n++ ) + { + free( psRMSEnvelopeGrouping->psGMNodes[n].pfMergedEnergydB ); + free( psRMSEnvelopeGrouping->psGMNodes[n].piQRMSEnvelope ); + } + free( psRMSEnvelopeGrouping->psGMNodes ); + + free( psRMSEnvelopeGrouping ); + + return; +} + + +/*-------------------------------------------------------------------* + * Function ComputeBandEnergy() + * + * + *-------------------------------------------------------------------*/ + +static void ComputeBandEnergy( + const int32_t iChannels, + const int32_t iNumBlocks, + const int32_t iNumBands, + const int32_t *piBandwidths, + float ***pppfReal, + float ***pppfImag, + float **ppfBandEnergy, + float **ppfBandEnergydB, + float **ppfWeight ) +{ + int32_t n; + + for ( n = 0; n < iChannels; n++ ) + { + int32_t k; + int32_t iChanOffset; + + iChanOffset = n * iNumBands; + for ( k = 0; k < iNumBlocks; k++ ) + { + int32_t b; + int32_t iFBOffset; + float fMaxWeight; + + iFBOffset = 0; + fMaxWeight = 0.0f; + for ( b = 0; b < iNumBands; b++ ) + { + int32_t m; + float fEnergy = 1e-12f; + float fWeight; + + for ( m = 0; m < piBandwidths[b]; m++ ) + { + fEnergy += ( pppfReal[n][k][iFBOffset] * pppfReal[n][k][iFBOffset] + pppfImag[n][k][iFBOffset] * pppfImag[n][k][iFBOffset] ); + iFBOffset++; + } + fEnergy /= (float) ( piBandwidths[b] ); /* Correction removed normalization by 2*/ + ppfBandEnergy[k][iChanOffset + b] = fEnergy; + + fWeight = 0.33f * powf( 10.0f, 0.0068f * ( 10.0f * log10f( fEnergy ) - c_afThreshQuiet48[b] ) ); + fWeight = ( fWeight > 0.33f ) ? fWeight : 0.33f; + fWeight = ( fWeight < 1.0f ) ? fWeight : 1.0f; + fMaxWeight = ( fMaxWeight > fWeight ) ? fMaxWeight : fWeight; + ppfWeight[k][iChanOffset + b] = fWeight; + +#ifdef APPLY_TEMPORAL_SMOOTHING + if ( k > 0 ) + { + float fSmoothEnergy; + fSmoothEnergy = 0.7f * ppfBandEnergy[k - 1][iChanOffset + b] + 0.3f * fEnergy; + + fEnergy = ( fEnergy > fSmoothEnergy ) ? fEnergy : fSmoothEnergy; + } +#endif + fEnergy = 10.0f * log10f( fEnergy ); + ppfBandEnergydB[k][iChanOffset + b] = fEnergy; + } + for ( b = 0; b < iNumBands; b++ ) + { + ppfWeight[k][iChanOffset + b] /= fMaxWeight; + } + } + } + + return; +} + +/*-------------------------------------------------------------------* + * Function ComputeMergeRMS() + * + * + *-------------------------------------------------------------------*/ + +static void ComputeMergeRMS( + const int32_t iNumBands, + const int32_t iStartBlock, + const int32_t iGroupLength, + float **ppfBandEnergy, + float *pfMergedEnergydB, + int32_t *piQRMSEnvelope ) +{ + int32_t b; + float fInvGroupSize = 1.0f / (float) iGroupLength; + + for ( b = 0; b < iNumBands; b++ ) + { + int32_t n; + float fGroupEnergy; + float fRMSEnvelope; + int32_t iQRMSEnvelope; + + fGroupEnergy = 0.0; + for ( n = iStartBlock; n < ( iStartBlock + iGroupLength ); n++ ) + { + fGroupEnergy += ppfBandEnergy[n][b]; + } + fGroupEnergy *= fInvGroupSize; + + fRMSEnvelope = log2f( fGroupEnergy ); + iQRMSEnvelope = ( fRMSEnvelope > 0.0 ) ? (int32_t) ( fRMSEnvelope + 0.5 ) : (int32_t) ( fRMSEnvelope - 0.5 ); + + fGroupEnergy = 10.0f * log10f( fGroupEnergy ); /* Note epsilon was added when computing BandEnergy;*/ + + pfMergedEnergydB[b] = fGroupEnergy; + piQRMSEnvelope[b] = iQRMSEnvelope; + } + + return; +} + + +/*-------------------------------------------------------------------* + * Function ComputeRMSEnvelopeBits() + * + * + *-------------------------------------------------------------------*/ + +static int32_t ComputeRMSEnvelopeBits( + const int32_t iChannels, + const int32_t iNumBands, + const int32_t *piQRMSEnevelope ) +{ + int32_t n; + int32_t iRMSEnvelopeBits = 0; + int32_t iChanOffset = 0; + + for ( n = 0; n < iChannels; n++ ) + { + int32_t b; + int32_t iLastRMSVal; + + iRMSEnvelopeBits += ENV0_BITS; + iLastRMSVal = piQRMSEnevelope[iChanOffset]; + for ( b = 1; b < iNumBands; b++ ) + { + int32_t iDelta; + + iDelta = piQRMSEnevelope[iChanOffset + b] - iLastRMSVal; + iDelta = ( iDelta > ENV_DELTA_MIN ) ? iDelta : ENV_DELTA_MIN; + iDelta = ( iDelta < ENV_DELTA_MAX ) ? iDelta : ENV_DELTA_MAX; + iDelta -= ENV_DELTA_MIN; + iRMSEnvelopeBits += c_aaiRMSEnvHuffEnc[iDelta][0]; + + iLastRMSVal = piQRMSEnevelope[iChanOffset + b]; + } + + iChanOffset += iNumBands; + } + + return iRMSEnvelopeBits; +} + + +/*-------------------------------------------------------------------* + * Function ComputeSNRPenalty() + * + * + *-------------------------------------------------------------------*/ + +static float ComputeSNRPenalty( + const int32_t iChannels, + const int32_t iNumBands, + const int32_t *piBandwidths, + const int32_t iStartBlock, + const int32_t iGroupLength, + float **ppfBandEnergydB, + const int32_t *piRMSEnvelope ) +{ + int32_t n; + int32_t iChanOffset; + float fSNRPenalty = 0.0; + + iChanOffset = 0; + for ( n = 0; n < iChannels; n++ ) + { + int32_t b; + for ( b = 0; b < iNumBands; b++ ) + { + int32_t k; + float fRMSVal; + + fRMSVal = 3.0103f * (float) piRMSEnvelope[iChanOffset + b]; + + for ( k = iStartBlock; k < ( iStartBlock + iGroupLength ); k++ ) + { + float fDeltadB; + + fDeltadB = fRMSVal - ppfBandEnergydB[k][iChanOffset + b]; + if ( fDeltadB < -9.0309f ) + { + fSNRPenalty += 1e10f; /* Some large number to prevent clipping*/ + } + else /*if(fDeltadB < 0.0)*/ + { + fSNRPenalty += fabsf( c_fiDefaultTheta48[b] * fDeltadB - fDeltadB ) * 2.0f * (float) piBandwidths[b] / 6.0f; + } + } + } + + iChanOffset += iNumBands; + } + + return fSNRPenalty; +} + + +/*-------------------------------------------------------------------* + * Function TryMerge2() + * + * + *-------------------------------------------------------------------*/ + +static float TryMerge2( + const int32_t iChannels, + const int32_t iNumBands, + const int32_t *piBandwidths, + float **ppfBandEnergy, + float **ppfBandEnergydB, + GMNode *psGMNode1, + GMNode *psGMNode2 ) +{ + int32_t iRMSEnvBits1; + int32_t iRMSEnvBits2; + int32_t iRMSEnvBitsMerged; + float fSNRPenalty1; + float fSNRPenalty2; + float fSNRPenaltyMerged; + float fMergedCost = 0.0; + + /* First compute current RMS Envelope for each group */ + if ( psGMNode1->iGroupRMSEnvelopeCost == -1 || psGMNode1->fGroupSNRPenalty == -1.0 ) + { + ComputeMergeRMS( iNumBands * iChannels, psGMNode1->iGroupStart, psGMNode1->iGroupLength, ppfBandEnergy, psGMNode1->pfMergedEnergydB, psGMNode1->piQRMSEnvelope ); + + iRMSEnvBits1 = ComputeRMSEnvelopeBits( iChannels, iNumBands, psGMNode1->piQRMSEnvelope ); + + fSNRPenalty1 = ComputeSNRPenalty( iChannels, iNumBands, piBandwidths, psGMNode1->iGroupStart, psGMNode1->iGroupLength, ppfBandEnergydB, psGMNode1->piQRMSEnvelope ); + + psGMNode1->iGroupRMSEnvelopeCost = iRMSEnvBits1; + psGMNode1->fGroupSNRPenalty = fSNRPenalty1; + } + else + { + iRMSEnvBits1 = psGMNode1->iGroupRMSEnvelopeCost; + fSNRPenalty1 = psGMNode1->fGroupSNRPenalty; + } + + if ( psGMNode2->iGroupRMSEnvelopeCost == -1 || psGMNode2->fGroupSNRPenalty == -1.0 ) + { + ComputeMergeRMS( iNumBands * iChannels, psGMNode2->iGroupStart, psGMNode2->iGroupLength, ppfBandEnergy, psGMNode2->pfMergedEnergydB, psGMNode2->piQRMSEnvelope ); + + iRMSEnvBits2 = ComputeRMSEnvelopeBits( iChannels, iNumBands, psGMNode2->piQRMSEnvelope ); + + fSNRPenalty2 = ComputeSNRPenalty( iChannels, iNumBands, piBandwidths, psGMNode2->iGroupStart, psGMNode2->iGroupLength, ppfBandEnergydB, psGMNode2->piQRMSEnvelope ); + + psGMNode2->iGroupRMSEnvelopeCost = iRMSEnvBits2; + psGMNode2->fGroupSNRPenalty = fSNRPenalty2; + } + else + { + iRMSEnvBits2 = psGMNode2->iGroupRMSEnvelopeCost; + fSNRPenalty2 = psGMNode2->fGroupSNRPenalty; + } + + /* Compute the merged group */ + ComputeMergeRMS( iNumBands * iChannels, psGMNode1->iGroupStart, psGMNode1->iGroupLength + psGMNode2->iGroupLength, ppfBandEnergy, psGMNode1->pfMergedEnergydB, psGMNode1->piQRMSEnvelope ); + + /* Compute the RMS Envelope cost for merged group */ + iRMSEnvBitsMerged = ComputeRMSEnvelopeBits( iChannels, iNumBands, psGMNode1->piQRMSEnvelope ); + + /* Compute an approximation of the bit cost based on SNR increase/decrease due to merging */ + fSNRPenaltyMerged = ComputeSNRPenalty( iChannels, iNumBands, piBandwidths, psGMNode1->iGroupStart, psGMNode1->iGroupLength + psGMNode2->iGroupLength, ppfBandEnergydB, psGMNode1->piQRMSEnvelope ); + + fMergedCost = fSNRPenaltyMerged - fSNRPenalty1 - fSNRPenalty2 + (float) iRMSEnvBitsMerged - (float) iRMSEnvBits1 - (float) iRMSEnvBits2; + + return fMergedCost; +} + +/*-------------------------------------------------------------------* + * Function ComputeGreedyGroups3() + * + * + *-------------------------------------------------------------------*/ + +static void ComputeGreedyGroups3( + RMSEnvelopeGrouping *psRMSEnvelopeGrouping, + const int32_t iChannels, + const int32_t iNumBands, + const int32_t *piBandwidths, + const int32_t iMaxGroups ) +{ + + int32_t iDone = 0; + int32_t iNumGroups = psRMSEnvelopeGrouping->iMaxGroups; + + while ( iDone == 0 ) + { + GMNode *psGMNode; + GMNode *psBestGMNode; + float fBestMergeCost; + + fBestMergeCost = 1e20f; + psGMNode = &psRMSEnvelopeGrouping->psGMNodes[0]; + psBestGMNode = NULL; + while ( psGMNode->psNext != NULL ) + { + float fMergeCost; + + fMergeCost = TryMerge2( iChannels, iNumBands, piBandwidths, psRMSEnvelopeGrouping->ppfBandEnergy, psRMSEnvelopeGrouping->ppfBandEnergydB, psGMNode, psGMNode->psNext ); + + if ( fMergeCost < fBestMergeCost ) + { + fBestMergeCost = fMergeCost; + psBestGMNode = psGMNode; + } + + psGMNode = psGMNode->psNext; + } + + if ( fBestMergeCost > 0.0 && iNumGroups <= iMaxGroups ) + { + iDone++; + } + else if ( psBestGMNode != NULL && psBestGMNode->psNext != NULL ) + { + psBestGMNode->iGroupLength += psBestGMNode->psNext->iGroupLength; + psBestGMNode->iGroupRMSEnvelopeCost = -1; + psBestGMNode->fGroupSNRPenalty = -1.0; + psBestGMNode->psNext = psBestGMNode->psNext->psNext; + iNumGroups--; + } + else + { + iDone++; /* This only catches a problem*/ + } + } + + return; +} + + +/*-------------------------------------------------------------------* + * Function ComputeRMSEnvelope() + * + * + *-------------------------------------------------------------------*/ + +static void ComputeRMSEnvelope( + const int32_t iChannels, + const int32_t iNumBands, + const int32_t iNumGroups, + const int32_t *piGroupLengths, + float **ppfBandEnergy, + int32_t ***pppiRMSEnvelope ) +{ + int32_t n; + + for ( n = 0; n < iChannels; n++ ) + { + int32_t b; + int32_t iChanOffset; + + iChanOffset = n * iNumBands; + for ( b = 0; b < iNumBands; b++ ) + { + int32_t k; + int32_t iBlockOffset; + + iBlockOffset = 0; + for ( k = 0; k < iNumGroups; k++ ) + { + int32_t m; + float fGroupEnergy; + fGroupEnergy = 0.0; + for ( m = 0; m < piGroupLengths[k]; m++ ) + { + fGroupEnergy += ppfBandEnergy[iBlockOffset][b + iChanOffset]; + iBlockOffset++; + } + fGroupEnergy /= (float) piGroupLengths[k]; + + fGroupEnergy = log2f( fGroupEnergy ); + pppiRMSEnvelope[n][k][b] = ( fGroupEnergy > 0.0 ) ? (int32_t) ( fGroupEnergy + 0.5 ) : (int32_t) ( fGroupEnergy - 0.5 ); + pppiRMSEnvelope[n][k][b] = ( pppiRMSEnvelope[n][k][b] > ENV_MIN ) ? pppiRMSEnvelope[n][k][b] : ENV_MIN; + pppiRMSEnvelope[n][k][b] = ( pppiRMSEnvelope[n][k][b] < ENV_MAX ) ? pppiRMSEnvelope[n][k][b] : ENV_MAX; + } + } + } + + return; +} + + +/*-------------------------------------------------------------------* + * Function LimitRMSEnvelope() + * + * + *-------------------------------------------------------------------*/ + +static void LimitRMSEnvelope( + const int32_t iBandCount, + const int32_t iRMSDeltaMax, + const int32_t iRMSDeltaMin, + int32_t *piRMSEnvelope ) +{ + int32_t iBand; + int32_t iLastSCF; + + /* Increase low envelope values to ensure that the scale factors traces the large values correctly (checking for max deltas) */ + iLastSCF = piRMSEnvelope[iBandCount - 1]; + for ( iBand = iBandCount - 2; iBand > -1; iBand-- ) + { + int32_t iDelta; + + iDelta = iLastSCF - piRMSEnvelope[iBand]; + + if ( iDelta > iRMSDeltaMax ) + { +#ifdef DEBUG_VERBOSE + printf( "WARNING RMS envelope delta limited\n" ); +#endif + piRMSEnvelope[iBand] += ( iDelta - iRMSDeltaMax ); + } + + iLastSCF = piRMSEnvelope[iBand]; + } + + /* Increase low envelope values to ensure that the envelope traces the large values correctly (checking for min deltas)*/ + iLastSCF = piRMSEnvelope[0]; + for ( iBand = 1; iBand < iBandCount; iBand++ ) + { + int32_t iDelta; + + iDelta = piRMSEnvelope[iBand] - iLastSCF; + + if ( iDelta < iRMSDeltaMin ) + { +#ifdef DEBUG_VERBOSE + printf( "WARNING RMS envelope delta limited\n" ); +#endif + piRMSEnvelope[iBand] += ( iRMSDeltaMin - iDelta ); + } + + iLastSCF = piRMSEnvelope[iBand]; + } + + return; +} + + +/*-------------------------------------------------------------------* + * Function ComputeEnvelopeGrouping() + * + * + *-------------------------------------------------------------------*/ + +void ComputeEnvelopeGrouping( + RMSEnvelopeGrouping *psRMSEnvelopeGrouping, + const int32_t iChannels, + const int32_t iNumBands, + const int32_t *piBandwidths, + float ***pppfReal, + float ***pppfImag, + int32_t *piNumGroups, + int32_t *piGroupLengths, + int32_t ***pppiRMSEnvelope ) +{ + int32_t n; + GMNode *psGMNode; + + /* Compute Band Energies */ + ComputeBandEnergy( iChannels, psRMSEnvelopeGrouping->iNumBlocks, iNumBands, piBandwidths, pppfReal, pppfImag, psRMSEnvelopeGrouping->ppfBandEnergy, psRMSEnvelopeGrouping->ppfBandEnergydB, psRMSEnvelopeGrouping->ppfWeight ); + + /* Init GMNodes */ + psRMSEnvelopeGrouping->psGMNodes[0].iGroupStart = 0; + psRMSEnvelopeGrouping->psGMNodes[0].iGroupLength = 2; + psRMSEnvelopeGrouping->psGMNodes[0].psNext = NULL; + psRMSEnvelopeGrouping->psGMNodes[0].iGroupRMSEnvelopeCost = -1; + psRMSEnvelopeGrouping->psGMNodes[0].fGroupSNRPenalty = -1.0f; + + for ( n = 1; n < psRMSEnvelopeGrouping->iMaxGroups; n++ ) + { + psRMSEnvelopeGrouping->psGMNodes[n - 1].psNext = &psRMSEnvelopeGrouping->psGMNodes[n]; + psRMSEnvelopeGrouping->psGMNodes[n].iGroupStart = n * 2; + psRMSEnvelopeGrouping->psGMNodes[n].iGroupLength = 2; + psRMSEnvelopeGrouping->psGMNodes[n].iGroupRMSEnvelopeCost = -1; + psRMSEnvelopeGrouping->psGMNodes[n].fGroupSNRPenalty = -1.0; + psRMSEnvelopeGrouping->psGMNodes[n].psNext = NULL; + } + + /* Perform grouping via Greedy Merge */ + /* Allows control over max groups can call using 16 if want same as previous call */ + ComputeGreedyGroups3( psRMSEnvelopeGrouping, iChannels, iNumBands, piBandwidths, psRMSEnvelopeGrouping->iNumBlocks ); + + /* Calc Groups from Merge Results */ + *piNumGroups = 0; + psGMNode = &psRMSEnvelopeGrouping->psGMNodes[0]; + while ( psGMNode != NULL ) + { + piGroupLengths[*piNumGroups] = psGMNode->iGroupLength; + *piNumGroups += 1; + psGMNode = psGMNode->psNext; + } + + /* Compute RMS Envelope given group lengths */ + ComputeRMSEnvelope( iChannels, iNumBands, *piNumGroups, piGroupLengths, psRMSEnvelopeGrouping->ppfBandEnergy, pppiRMSEnvelope ); + + /* Envelope Tenting */ + for ( n = 0; n < iChannels; n++ ) + { + int32_t k; + for ( k = 0; k < *piNumGroups; k++ ) + { + LimitRMSEnvelope( iNumBands, ENV_DELTA_MAX, ENV_DELTA_MIN, pppiRMSEnvelope[n][k] ); + } + } + + return; +} +#endif diff --git a/lib_isar/isar_cnst.h b/lib_isar/isar_cnst.h new file mode 100644 index 0000000000000000000000000000000000000000..c81415ff5cfe55122b405d643019d249d11931e3 --- /dev/null +++ b/lib_isar/isar_cnst.h @@ -0,0 +1,135 @@ +/****************************************************************************************************** + + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#ifndef ISAR_CNST_H +#define ISAR_CNST_H + +#include +#include "options.h" + +/* clang-format off */ + +#ifdef SPLIT_REND_WITH_HEAD_ROT + +/*----------------------------------------------------------------------------------* + * Split Binaural Rendering Constants + *----------------------------------------------------------------------------------*/ + +typedef enum +{ + PCM_INT16, + PCM_FLOAT32, + PCM_NOT_KNOW = 0xffff +} PCM_RESOLUTION; + +typedef enum +{ + ANY_YAW, + PITCH_ONLY, + ANY_ROLL, + PRED_ONLY, + PRED_ROLL_ONLY, + COM_GAIN_ONLY, + LR_GAIN_ONLY +} ISAR_SPLIT_REND_POSE_TYPE; + + +#define CLDFB_PLC_XF 2 /* Length of cross-fade into first good frame after frame loss in CLDFB cols. */ + +#define SPLIT_REND_MAX_YAW_ONLY_POSES 2 +#define SPLIT_REND_MAX_PITCH_ONLY_POSES 2 +#define SPLIT_REND_MAX_ROLL_ONLY_POSES 2 +#define SPLIT_REND_MAX_ONE_AXIS_MD_POSES 2 +#define MAX_EXTRAPOLATION_ANGLE 15.0f /* this means additional 15 degrees can be extrapolated on top of MD probing poses*/ + +#define MAX_HEAD_ROT_POSES ( 2 + SPLIT_REND_MAX_YAW_ONLY_POSES + SPLIT_REND_MAX_PITCH_ONLY_POSES + SPLIT_REND_MAX_ROLL_ONLY_POSES ) +#define MAX_SPLIT_REND_MD_BANDS 20 +#define MAX_SPLIT_MD_SUBFRAMES 1 +#define COMPLEX_MD_BAND_THRESH MAX_SPLIT_REND_MD_BANDS +#ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS +#define COMPLEX_MD_BAND_THRESH_LOW 4 +#define COMPLEX_MD_BAND_THRESH_HIGH 10 +#else +#define COMPLEX_MD_BAND_THRESH_LOW 5 +#endif +#define SPLIT_REND_RO_MD_BAND_THRESH 4 + +#define ISAR_SPLIT_REND_NUM_QUANT_STRATS 4 +#define ISAR_SPLIT_REND_PRED_63QUANT_PNTS 63 +#define ISAR_SPLIT_REND_PRED_31QUANT_PNTS 31 +#define ISAR_SPLIT_REND_ROLL_PRED_QUANT_PNTS 31 +#define ISAR_SPLIT_REND_D_QUANT_PNTS 15 +#define ISAR_SPLIT_REND_PRED_MIN_VAL -1.4f +#define ISAR_SPLIT_REND_PRED_MAX_VAL 1.4f + +#define ISAR_SPLIT_REND_PITCH_G_MIN_VAL 0.5f +#define ISAR_SPLIT_REND_PITCH_G_MAX_VAL 1.5f +#define ISAR_SPLIT_REND_PITCH_G_QUANT_PNTS ISAR_SPLIT_REND_D_QUANT_PNTS +#define ISAR_SPLIT_REND_D_MIN_VAL 0.0f +#define ISAR_SPLIT_REND_D_MAX_VAL 1.0f + +#define ISAR_SPLIT_REND_PRED_ROLL_Q_STEP ( ( ISAR_SPLIT_REND_PRED_MAX_VAL - ISAR_SPLIT_REND_PRED_MIN_VAL ) / ( ISAR_SPLIT_REND_ROLL_PRED_QUANT_PNTS - 1 ) ) +#define ISAR_SPLIT_REND_PRED_ROLL_1BYQ_STEP ( ( ISAR_SPLIT_REND_ROLL_PRED_QUANT_PNTS - 1 ) / ( ISAR_SPLIT_REND_PRED_MAX_VAL - ISAR_SPLIT_REND_PRED_MIN_VAL ) ) +#define ISAR_SPLIT_REND_PRED31_Q_STEP ( ( ISAR_SPLIT_REND_PRED_MAX_VAL - ISAR_SPLIT_REND_PRED_MIN_VAL ) / ( ISAR_SPLIT_REND_PRED_31QUANT_PNTS - 1 ) ) +#define ISAR_SPLIT_REND_PRED31_1BYQ_STEP ( ( ISAR_SPLIT_REND_PRED_31QUANT_PNTS - 1 ) / ( ISAR_SPLIT_REND_PRED_MAX_VAL - ISAR_SPLIT_REND_PRED_MIN_VAL ) ) +#define ISAR_SPLIT_REND_PRED63_Q_STEP ( ( ISAR_SPLIT_REND_PRED_MAX_VAL - ISAR_SPLIT_REND_PRED_MIN_VAL ) / ( ISAR_SPLIT_REND_PRED_63QUANT_PNTS - 1 ) ) +#define ISAR_SPLIT_REND_PRED63_1BYQ_STEP ( ( ISAR_SPLIT_REND_PRED_63QUANT_PNTS - 1 ) / ( ISAR_SPLIT_REND_PRED_MAX_VAL - ISAR_SPLIT_REND_PRED_MIN_VAL ) ) + +#define ISAR_SPLIT_REND_D_Q_STEP ( ( ISAR_SPLIT_REND_D_MAX_VAL - ISAR_SPLIT_REND_D_MIN_VAL ) / ( ISAR_SPLIT_REND_D_QUANT_PNTS - 1 ) ) +#define ISAR_SPLIT_REND_D_1BYQ_STEP ( ( ISAR_SPLIT_REND_D_QUANT_PNTS - 1 ) / ( ISAR_SPLIT_REND_D_MAX_VAL - ISAR_SPLIT_REND_D_MIN_VAL ) ) +#define ISAR_SPLIT_REND_PITCH_G_Q_STEP ( ( ISAR_SPLIT_REND_PITCH_G_MAX_VAL - ISAR_SPLIT_REND_PITCH_G_MIN_VAL ) / ( ISAR_SPLIT_REND_PITCH_G_QUANT_PNTS - 1 ) ) +#define ISAR_SPLIT_REND_PITCH_G_1BYQ_STEP ( ( ISAR_SPLIT_REND_PITCH_G_QUANT_PNTS - 1 ) / ( ISAR_SPLIT_REND_PITCH_G_MAX_VAL - ISAR_SPLIT_REND_PITCH_G_MIN_VAL ) ) + +#define ISAR_SPLIT_REND_HEAD_POSE_BITS 9 +#define ISAR_SPLIT_REND_DOF_BITS 2 +#define ISAR_SPLIT_REND_HQ_MODE_BITS 1 +#define ISAR_SPLIT_REND_ROT_AXIS_BITS 3 +#define ISAR_SPLIT_REND_RO_FLAG_BITS 1 + +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS +#define IVAS_LC3PLUS_MAX_NUM_DECODERS 2 +#endif + +/*----------------------------------------------------------------------------------* + * Split rendering bitrate constants + *----------------------------------------------------------------------------------*/ + +#define SPLIT_REND_256k 256000 +#define SPLIT_REND_320k 320000 +#define SPLIT_REND_384k 384000 +#define SPLIT_REND_512k 512000 +#define SPLIT_REND_768k 768000 + +#endif /*SPLIT_REND_WITH_HEAD_ROT */ + +#endif /*ISAR_CNST_H */ +/* clang-format on */ diff --git a/lib_isar/isar_lc3plus_common.c b/lib_isar/isar_lc3plus_common.c new file mode 100644 index 0000000000000000000000000000000000000000..2e5a31cb6e9af5ea6748a1422d7c83c7781ab5a3 --- /dev/null +++ b/lib_isar/isar_lc3plus_common.c @@ -0,0 +1,89 @@ +/****************************************************************************************************** + + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#include "options.h" +#include "isar_lc3plus_common.h" +#include "ivas_error.h" +#include "lc3.h" + +#ifdef SPLIT_REND_WITH_HEAD_ROT +/*-----------------------------------------------------------------------------------------* + * Function ISAR_LC3PLUS_LC3plusErrToIvasErr() + * + * + *-----------------------------------------------------------------------------------------*/ + +ivas_error ISAR_LC3PLUS_LC3plusErrToIvasErr( + const LC3PLUS_Error lc3PlusError ) +{ + switch ( lc3PlusError ) + { + case LC3PLUS_OK: + return IVAS_ERR_OK; + case LC3PLUS_BITRATE_ERROR: + return IVAS_ERR_LC3PLUS_INVALID_BITRATE; + default: + break; + } + + return IVAS_ERR_INTERNAL; +} +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS +ivas_error IVAS_LC3PLUS_LC3plusRtpErrToIvasErr( const LC3PLUS_RTP_ERR lc3PlusRtpError ) +{ + switch ( lc3PlusRtpError ) + { + case LC3PLUS_RTP_ERR_NO_ERROR: + return IVAS_ERR_OK; + case LC3PLUS_RTP_ERR_NULL_PTR: + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + case LC3PLUS_RTP_ERR_INVALID_PARAMETERS: + return IVAS_ERR_WRONG_PARAMS; + case LC3PLUS_RTP_ERR_NOT_IMPLEMENTED: + return IVAS_ERR_NOT_IMPLEMENTED; + case LC3PLUS_RTP_ERR_UNSUPPORTED_CONFIGURATION: + return IVAS_ERR_INTERNAL; + case LC3PLUS_RTP_ERR_INVALID_BITSTREAM: + return IVAS_ERR_UNEXPECTED_LC3PLUS_BITSTREAM; + case LC3PLUS_RTP_ERR_INVALID_BITSTREAM_SIZE: + return IVAS_ERR_INVALID_BUFFER_SIZE; + case LC3PLUS_RTP_ERR_NOT_ENOUGH_FTDS_ALLOCATED: + return IVAS_ERR_INTERNAL; + case LC3PLUS_RTP_ERR_GENERIC_ERROR: + default: + break; + } + + return IVAS_ERR_UNKNOWN; +} +#endif +#endif diff --git a/lib_isar/isar_lc3plus_common.h b/lib_isar/isar_lc3plus_common.h new file mode 100644 index 0000000000000000000000000000000000000000..57060944273cbb46aa0dbfc2ccf684414ae367f9 --- /dev/null +++ b/lib_isar/isar_lc3plus_common.h @@ -0,0 +1,72 @@ +/****************************************************************************************************** + + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#ifndef ISAR_LC3PLUS_COM_H +#define ISAR_LC3PLUS_COM_H + + +#include +#include "options.h" +#include "ivas_error.h" +#ifdef SPLIT_REND_WITH_HEAD_ROT +#include "lc3.h" +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS +#include "isar_lc3plus_payload.h" +#endif + +/*! common configuration parameters between encoder and decoder */ +typedef struct LC3PLUS_CONFIG +{ + /*! frame duration in microseconds [10000, 5000, 2500] */ + int16_t lc3plus_frame_duration_us; + /*! isar frame duration in microseconds [20000, 10000, 5000] */ + int16_t isar_frame_duration_us; + /*! sampling rate*/ + int32_t samplerate; + /*! number of channels */ + int16_t channels; +#if defined ISAR_BITSTREAM_UPDATE_LC3PLUS || defined ISAR_BITSTREAM_UPDATE_LC3PLUS + /*! high resolution mode enabled (1) or disabled (0)*/ + int16_t high_res_mode_enabled; +#endif +} LC3PLUS_CONFIG; + +/*! utility function to convert LC3PLUS_Errors to the suitable ivas_error */ +ivas_error ISAR_LC3PLUS_LC3plusErrToIvasErr( const LC3PLUS_Error lc3PlusError ); + +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS +/*! utility function to convert LC3PLUS_Errors to the suitable ivas_error */ +ivas_error IVAS_LC3PLUS_LC3plusRtpErrToIvasErr( const LC3PLUS_RTP_ERR lc3PlusRtpError ); +#endif + +#endif /* SPLIT_REND_WITH_HEAD_ROT */ +#endif /* ISAR_LC3PLUS_COM_H */ diff --git a/lib_isar/isar_lc3plus_dec.c b/lib_isar/isar_lc3plus_dec.c new file mode 100644 index 0000000000000000000000000000000000000000..15dac2d4162a096dbae87ec963d1157b8e79a947 --- /dev/null +++ b/lib_isar/isar_lc3plus_dec.c @@ -0,0 +1,844 @@ +/****************************************************************************************************** + + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#include +#include "options.h" +#include "prot.h" +#include "ivas_prot.h" +#include "isar_lc3plus_dec.h" +#include "isar_lc3plus_common.h" +#include "lc3.h" +#include "ivas_error_utils.h" +#include "wmc_auto.h" + +#ifdef SPLIT_REND_WITH_HEAD_ROT + +#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS +/*------------------------------------------------------------------------- + * isar_LC3PLUS_AllocateSubframeDecodingMatrix() + * + * + *------------------------------------------------------------------------*/ + +static void isar_LC3PLUS_DEC_FreeSubframeDecodingMatrix( + int16_t **subframeChannelMatrix ) +{ + for ( int16_t i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) + { + free( subframeChannelMatrix[i] ); + } + + free( subframeChannelMatrix ); + + return; +} +#endif + + +/*------------------------------------------------------------------------- + * ISAR_LC3PLUS_DEC_Open() + * + * + *------------------------------------------------------------------------*/ + +ivas_error ISAR_LC3PLUS_DEC_Open( + const LC3PLUS_CONFIG config, /* i : LC3plus decoder configuration */ + ISAR_LC3PLUS_DEC_HANDLE *handle /* o : decoder handle */ +) +{ + LC3PLUS_Error err; + int32_t decoder_size; +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + int16_t i; + + if ( 0 == config.lc3plus_frame_duration_us ) + { + return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Invalid lc3plus_frame_duration_us (0)\n" ); + } +#else + int16_t lc3plusFrameIdx; + int16_t numLC3plusFramesPerIvasFrame; + int16_t i; +#endif + + if ( ( *handle = malloc( sizeof( struct ISAR_LC3PLUS_DEC_HANDLE ) ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LC3plus wrapper handle\n" ); + } + +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + if ( config.channels > IVAS_LC3PLUS_MAX_NUM_DECODERS ) + { + return IVAS_ERROR( IVAS_ERR_INIT_ERROR, "Maximum number of channels exceeds IVAS_LC3PLUS_MAX_NUM_DECODERS\n" ); + } +#else + + if ( 0 == config.lc3plus_frame_duration_us ) + { + return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Invalid lc3plus_frame_duration_us (0)\n" ); + } + numLC3plusFramesPerIvasFrame = (int16_t) ( config.isar_frame_duration_us / config.lc3plus_frame_duration_us ); +#endif + + + ( *handle )->num_decs = 0; + ( *handle )->pcm_conversion_buffer = NULL; + ( *handle )->handles = NULL; + ( *handle )->selective_decoding_states = NULL; + ( *handle )->bitstream_caches = NULL; + + if ( ( ( *handle )->handles = malloc( config.channels * sizeof( ISAR_LC3PLUS_DEC_HANDLE ) ) ) == NULL ) + { + ISAR_LC3PLUS_DEC_Close( handle ); + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LC3plus wrapper handle\n" ); + } + + if ( ( ( *handle )->selective_decoding_states = malloc( config.channels * sizeof( ISAR_LC3PLUS_DEC_SELECTIVE_DECODING_STATE * ) ) ) == NULL ) + { + ISAR_LC3PLUS_DEC_Close( handle ); + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LC3plus wrapper handle\n" ); + } + + for ( i = 0; i < config.channels; ++i ) + { + ( *handle )->handles[i] = NULL; + ( *handle )->selective_decoding_states[i] = NULL; + } + + if ( ( ( *handle )->bitstream_caches = malloc( config.channels * sizeof( ISAR_LC3PLUS_DEC_BITSTREAM_CACHE * ) ) ) == NULL ) + { + ISAR_LC3PLUS_DEC_Close( handle ); + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LC3plus wrapper handle\n" ); + } + for ( i = 0; i < config.channels; ++i ) + { + ( *handle )->bitstream_caches[i] = NULL; + } + + ( *handle )->num_decs = config.channels; + for ( int32_t iCh = 0; iCh < config.channels; iCh++ ) + { + ( *handle )->selective_decoding_states[iCh] = NULL; + if ( NULL != ( *handle )->bitstream_caches ) + { + ( *handle )->bitstream_caches[iCh] = NULL; + } + /* allocate and configure LC3plus decoder */ + decoder_size = lc3plus_dec_get_size( config.samplerate, 1 ); + if ( 0 == decoder_size ) + { + ISAR_LC3PLUS_DEC_Close( handle ); + return IVAS_ERROR( IVAS_ERR_INTERNAL, "lc3plus_dec_get_size failed\n" ); + } + + if ( ( ( *handle )->handles[iCh] = malloc( decoder_size ) ) == NULL ) + { + ISAR_LC3PLUS_DEC_Close( handle ); + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LC3plus decoder\n" ); + } + +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + err = lc3plus_dec_init( ( *handle )->handles[iCh], config.samplerate, 1, LC3PLUS_PLC_ADVANCED, config.high_res_mode_enabled ); +#else + err = lc3plus_dec_init( ( *handle )->handles[iCh], config.samplerate, 1, LC3PLUS_PLC_ADVANCED, 0 ); +#endif + if ( LC3PLUS_OK != err ) + { + ISAR_LC3PLUS_DEC_Close( handle ); + return IVAS_ERROR( ISAR_LC3PLUS_LC3plusErrToIvasErr( err ), "lc3plus_dec_init failed\n" ); + } + + err = lc3plus_dec_set_frame_dms( ( *handle )->handles[iCh], config.lc3plus_frame_duration_us / 100 ); + if ( LC3PLUS_OK != err ) + { + ISAR_LC3PLUS_DEC_Close( handle ); + return IVAS_ERROR( ISAR_LC3PLUS_LC3plusErrToIvasErr( err ), "lc3plus_dec_set_frame_dms failed\n" ); + } + + /* allocate and configure per LC3plus decoder skip state */ + if ( ( ( *handle )->selective_decoding_states[iCh] = malloc( sizeof( ISAR_LC3PLUS_DEC_SELECTIVE_DECODING_STATE ) ) ) == NULL ) + { + ISAR_LC3PLUS_DEC_Close( handle ); + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LC3plus decoder\n" ); + } + +#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS + if ( ( ( *handle )->selective_decoding_states[iCh]->frame_actions = malloc( numLC3plusFramesPerIvasFrame * sizeof( SelectiveDecAction ) ) ) == NULL ) + { + ISAR_LC3PLUS_DEC_Close( handle ); + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LC3plus decoder\n" ); + } +#endif + + ( *handle )->selective_decoding_states[iCh]->has_skipped_a_frame = 0; + ( *handle )->selective_decoding_states[iCh]->shall_decode_cached_frame = 0; +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + ( *handle )->selective_decoding_states[iCh]->frame_action = DEC_ACTION_DECODE_AND_USE; +#else + for ( lc3plusFrameIdx = 0; lc3plusFrameIdx < numLC3plusFramesPerIvasFrame; lc3plusFrameIdx++ ) + { + ( *handle )->selective_decoding_states[iCh]->frame_actions[lc3plusFrameIdx] = DEC_ACTION_DECODE_AND_USE; + } +#endif + + /* allocate and configure per LC3plus decoder bitstream cache */ + if ( ( ( *handle )->bitstream_caches[iCh] = malloc( sizeof( ISAR_LC3PLUS_DEC_BITSTREAM_CACHE ) ) ) == NULL ) + { + ISAR_LC3PLUS_DEC_Close( handle ); + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LC3plus decoder\n" ); + } +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + ( *handle )->bitstream_caches[iCh]->bitstream_cache_capacity = 400 /*LC3plus max non-HR octet count*/; +#else + ( *handle )->bitstream_caches[iCh]->bitstream_cache_capacity = 400 /*LC3plus max non-HR octet count*/ * numLC3plusFramesPerIvasFrame; +#endif + if ( ( ( *handle )->bitstream_caches[iCh]->bitstream_cache = malloc( ( *handle )->bitstream_caches[iCh]->bitstream_cache_capacity ) ) == NULL ) + { + ISAR_LC3PLUS_DEC_Close( handle ); + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LC3plus decoder\n" ); + } + ( *handle )->bitstream_caches[iCh]->bitstream_cache_size = 0; + } + + ( *handle )->config = config; + if ( config.isar_frame_duration_us < config.lc3plus_frame_duration_us || config.isar_frame_duration_us % config.lc3plus_frame_duration_us != 0 ) + { + ISAR_LC3PLUS_DEC_Close( handle ); + return IVAS_ERROR( IVAS_ERR_NOT_IMPLEMENTED, "Current pcm_conversion_buffer sizing requires that lc3plus uses a shorter or equal frame duration than ivas\n" ); + } + + if ( ( ( *handle )->pcm_conversion_buffer = malloc( sizeof( int16_t ) * config.samplerate * config.lc3plus_frame_duration_us / 1000000 ) ) == NULL ) + { + ISAR_LC3PLUS_DEC_Close( handle ); + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LC3plus decoder wrapper pcm_conversion_buffer\n" ); + } + + return IVAS_ERR_OK; +} + +#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS +/*------------------------------------------------------------------------- + * ISAR_LC3PLUS_DEC_AllocateSubframeDecodingMatrix() + * + * + *------------------------------------------------------------------------*/ + +ivas_error ISAR_LC3PLUS_DEC_AllocateSubframeDecodingMatrix( + int16_t ***subframeChannelMatrix, + const uint32_t num_decs ) +{ + int16_t i; + + if ( ( *subframeChannelMatrix = malloc( MAX_PARAM_SPATIAL_SUBFRAMES * sizeof( int16_t * ) ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "subframeChannelMatrix allocation failed\n" ); + } + + for ( i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) + { + ( *subframeChannelMatrix )[i] = NULL; + } + + for ( i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) + { + if ( ( ( *subframeChannelMatrix )[i] = malloc( num_decs * sizeof( int16_t ) ) ) == NULL ) + { + isar_LC3PLUS_DEC_FreeSubframeDecodingMatrix( *subframeChannelMatrix ); + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "subframeChannelMatrix allocation failed\n" ); + } + } + + return IVAS_ERR_OK; +} + + +/*------------------------------------------------------------------------- + * ISAR_LC3PLUS_DEC_SetSelectiveDecodingMatrix() + * + * + *------------------------------------------------------------------------*/ + +ivas_error ISAR_LC3PLUS_DEC_SetSelectiveDecodingMatrix( + ISAR_LC3PLUS_DEC_HANDLE handle, /* i : LC3plus decoder handle */ + int16_t *subframeChannelMatrix[MAX_PARAM_SPATIAL_SUBFRAMES] ) +{ + int16_t numIvasSubFramesPerLC3frame; + uint32_t decIdx; + int16_t ivasSubframeIdx; + int16_t effectiveIsarSubframeDuration; + int16_t actual_num_spatial_subframes; + + if ( NULL == handle ) + { + return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "ISAR_LC3PLUS_DEC_HANDLE is NULL\n" ); + } + + if ( NULL == subframeChannelMatrix ) + { + return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "subframeChannelMatrix is NULL\n" ); + } + + if ( handle->config.lc3plus_frame_duration_us == 0 || handle->config.isar_frame_duration_us % handle->config.lc3plus_frame_duration_us != 0 ) + { + return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "invalid isar_frame_duration_us/lc3plus_frame_duration_us values\n" ); + } + + effectiveIsarSubframeDuration = (int16_t) ( handle->config.isar_frame_duration_us == 20000 ? handle->config.isar_frame_duration_us / MAX_PARAM_SPATIAL_SUBFRAMES : handle->config.isar_frame_duration_us ); + numIvasSubFramesPerLC3frame = (int16_t) handle->config.lc3plus_frame_duration_us / effectiveIsarSubframeDuration; + actual_num_spatial_subframes = (int16_t) handle->config.isar_frame_duration_us / effectiveIsarSubframeDuration; + /* 0.5(0) = 10ms lc3plus, 5ms subframe */ + if ( numIvasSubFramesPerLC3frame != 1 ) + { + return IVAS_ERROR( IVAS_ERR_NOT_IMPLEMENTED, "Selective decoding is only implemented for aligned IVAS-Subframes & LC3plus \n" ); + } + + /* map subframeChannelMatrix to lc3plus skip states */ + /* 1st pass: Flag the required frames */ + for ( decIdx = 0; decIdx < handle->num_decs; decIdx++ ) + { + for ( ivasSubframeIdx = 0; ivasSubframeIdx < actual_num_spatial_subframes; ivasSubframeIdx++ ) + { + if ( 1 == subframeChannelMatrix[ivasSubframeIdx][decIdx] ) + { + /* subframe needed by the user, definitely decode */ + handle->selective_decoding_states[decIdx]->frame_actions[ivasSubframeIdx] = DEC_ACTION_DECODE_AND_USE; + } + else + { + + /* subframe not needed by the user, but might be required to re-initialize a decoder after inactivity */ + if ( + ( ivasSubframeIdx != actual_num_spatial_subframes - 1 ) && 1 == subframeChannelMatrix[ivasSubframeIdx + 1][decIdx] ) + { + /* ... but if the following subframe is required, it needs to be decoded and dropped */ + handle->selective_decoding_states[decIdx]->frame_actions[ivasSubframeIdx] = DEC_ACTION_DECODE_AND_DROP; + } + else + { + handle->selective_decoding_states[decIdx]->frame_actions[ivasSubframeIdx] = DEC_ACTION_SKIP; + } + } + } + } + + /* if a decoder was paused before, it needs to either: + * - Decode the cached frame (if available) and the first required frame OR + * - Decode the previous LC3plus subframe, even if it isn't needed by the user */ + for ( decIdx = 0; decIdx < handle->num_decs; decIdx++ ) + { + if ( handle->selective_decoding_states[decIdx]->has_skipped_a_frame ) + { + /* find the first frame required by the user */ + for ( ivasSubframeIdx = 0; ivasSubframeIdx < actual_num_spatial_subframes; ivasSubframeIdx++ ) + { + if ( DEC_ACTION_DECODE_AND_USE == handle->selective_decoding_states[decIdx]->frame_actions[ivasSubframeIdx] ) + { + /* The first required frame is the first subframe. To flush the decoder, the cached frame must be decoded and dropped */ + if ( 0 == ivasSubframeIdx ) + { + handle->selective_decoding_states[decIdx]->shall_decode_cached_frame = 1; + break; + } + /* The first required frame is not the first frame, so the cache is useless. Instead we decode & drop the previous frame*/ + else + { + handle->selective_decoding_states[decIdx]->frame_actions[ivasSubframeIdx - 1] = DEC_ACTION_DECODE_AND_DROP; + break; + } + } + } + } + } + + /* if a dec gets paused & caching is activated we need to flag the last useful LC3plus frame for caching */ + for ( decIdx = 0; decIdx < handle->num_decs; decIdx++ ) + { + for ( ivasSubframeIdx = 0; ivasSubframeIdx < actual_num_spatial_subframes; ivasSubframeIdx++ ) + { + if ( handle->selective_decoding_states[decIdx]->frame_actions[ivasSubframeIdx] == DEC_ACTION_SKIP && handle->selective_decoding_states[decIdx]->frame_actions[actual_num_spatial_subframes - 1] != DEC_ACTION_DECODE_AND_USE ) + { + handle->selective_decoding_states[decIdx]->frame_actions[actual_num_spatial_subframes - 1] = DEC_ACTION_CACHE; + } + } + } + + return IVAS_ERR_OK; +} +#endif + + +/*------------------------------------------------------------------------- + * ISAR_LC3PLUS_DEC_GetDelay() + * + * + *------------------------------------------------------------------------*/ + +ivas_error ISAR_LC3PLUS_DEC_GetDelay( + ISAR_LC3PLUS_DEC_HANDLE handle, /* i : LC3plus decoder handle */ + int32_t *delayInSamples /* o : decoder delay in number of samples per channel */ +) +{ + int32_t tmpDelayInSamples; + + if ( NULL == handle ) + { + return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "ISAR_LC3PLUS_DEC_HANDLE is NULL\n" ); + } + if ( NULL == delayInSamples ) + { + return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "delayInSamples is NULL\n" ); + } + + *delayInSamples = 0; + /* sanity check whether all encoders are actually configured identically */ + for ( uint32_t iDec = 0; iDec < handle->num_decs; iDec++ ) + { + if ( NULL == handle->handles[iDec] ) + { + return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "LC3plus decoder handle is NULL\n" ); + } + + tmpDelayInSamples = lc3plus_dec_get_delay( handle->handles[iDec] ); + if ( 0 != *delayInSamples && tmpDelayInSamples != *delayInSamples ) + { + return IVAS_ERROR( IVAS_ERR_INTERNAL, "Not all mono LC3plus decoders are configured identically\n" ); + } + + *delayInSamples = tmpDelayInSamples; + } + + return IVAS_ERR_OK; +} + + +/*------------------------------------------------------------------------- + * ISAR_LC3PLUS_DEC_Close() + * + * + *------------------------------------------------------------------------*/ + +void ISAR_LC3PLUS_DEC_Close( + ISAR_LC3PLUS_DEC_HANDLE *handle /* i/o: Pointer to LC3plus decoder handle */ +) +{ + if ( NULL == handle || NULL == *handle ) + { + return; + } + for ( uint32_t iDec = 0; iDec < ( *handle )->num_decs; iDec++ ) + { + if ( NULL != ( *handle )->handles && NULL != ( *handle )->handles[iDec] ) + { + lc3plus_free_decoder_structs( ( *handle )->handles[iDec] ); + free( ( *handle )->handles[iDec] ); + } + + if ( NULL != ( *handle )->selective_decoding_states && NULL != ( *handle )->selective_decoding_states[iDec] ) + { +#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS + free( ( *handle )->selective_decoding_states[iDec]->frame_actions ); +#endif + free( ( *handle )->selective_decoding_states[iDec] ); + } + + if ( NULL != ( *handle )->bitstream_caches && NULL != ( *handle )->bitstream_caches[iDec] ) + { + free( ( *handle )->bitstream_caches[iDec]->bitstream_cache ); + free( ( *handle )->bitstream_caches[iDec] ); + } + } + + if ( NULL != ( *handle )->pcm_conversion_buffer ) + { + free( ( *handle )->pcm_conversion_buffer ); + } + free( ( *handle )->handles ); + + if ( NULL != ( *handle )->bitstream_caches ) + { + free( ( *handle )->bitstream_caches ); + } + free( ( *handle )->selective_decoding_states ); + + free( *handle ); + *handle = NULL; + + return; +} + + +/*------------------------------------------------------------------------- + * decode_or_conceal_one_lc3plus_frame() + * + * + *------------------------------------------------------------------------*/ + +static ivas_error decode_or_conceal_one_lc3plus_frame( + LC3PLUS_Dec *dec, + uint8_t *bitstream_in, + const int32_t bitstream_in_length, + int16_t **pcm_out_buffer, + const int32_t badFrameIndicator ) +{ + LC3PLUS_Error err; + + push_wmops( "lc3plus_dec16" ); + err = lc3plus_dec16( dec, bitstream_in, bitstream_in_length, pcm_out_buffer, NULL, badFrameIndicator ); + pop_wmops(); + + if ( err == LC3PLUS_DECODE_ERROR && 1 == badFrameIndicator ) + { + /* LC3PLUS_DECODE_ERROR && badFrameIndicator means that the decoder has successfully concealed, which is actually OK. */ + err = LC3PLUS_OK; + } + + if ( err != LC3PLUS_OK ) + { + return IVAS_ERROR( ISAR_LC3PLUS_LC3plusErrToIvasErr( err ), "lc3plus_dec16 failed\n" ); + } + + return IVAS_ERR_OK; +} + + +/*------------------------------------------------------------------------- + * isar_LC3PLUS_DEC_Decode_or_Conceal_internal() + * + * + *------------------------------------------------------------------------*/ + +static ivas_error isar_LC3PLUS_DEC_Decode_or_Conceal_internal( + ISAR_LC3PLUS_DEC_HANDLE handle, /* i : LC3plus decoder configuration */ + uint8_t *bitstream_in, /* i : pointer to input bitstream */ + int32_t bitstream_in_size, /* i : size of bitstream_in */ + const int16_t badFrameIndicator, /* i : bad frame indicator. If set to 1, triggers concealment */ + float **pcm_out /* o : decoded samples */ +) +{ + uint32_t iDec; +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + int32_t config_num_media_times; + int32_t iMediaTime; + int32_t iFtd; + LC3PLUS_RTP_PAYLOAD payload; +#else + int32_t iLc3plusFrame; + int32_t lc3framesPerIvasFrame; + int32_t bitstreamOffsetPerCoder; + uint8_t *bitstream_in_iter = bitstream_in; +#endif + int32_t ivasSampleIndex; + int16_t numSamplesPerLC3plusChannel; + ivas_error err; + + if ( NULL == handle ) + { + return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "LC3PLUS_Dec_Wrap_Handle is NULL\n" ); + } + if ( NULL == bitstream_in ) + { + return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "bitstream_in is NULL\n" ); + } + if ( NULL == pcm_out ) + { + return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "pcm_out is NULL\n" ); + } + if ( badFrameIndicator != 0 && badFrameIndicator != 1 ) + { + return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "badFrameIndicator must be 1 or 0\n" ); + } + if ( badFrameIndicator == 0 && bitstream_in_size <= 0 ) + { + return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "bitstream_in_size must be positive\n" ); + } + + if ( handle->config.isar_frame_duration_us % handle->config.lc3plus_frame_duration_us != 0 ) + { + return IVAS_ERROR( IVAS_ERR_NOT_IMPLEMENTED, "isar_frame_duration_us must be equal or multiple of lc3plus_frame_duration_us \n" ); + } + +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + config_num_media_times = handle->config.isar_frame_duration_us / handle->config.lc3plus_frame_duration_us; + if ( !badFrameIndicator ) + { + if ( LC3PLUS_RTP_payload_deserialize( &payload, bitstream_in, bitstream_in_size ) != LC3PLUS_RTP_ERR_NO_ERROR ) + { + return IVAS_ERROR( IVAS_ERR_INTERNAL, "LC3PLUS_RTP_payload_deserialize failed\n" ); + } + if ( payload.sampling_rate_hz != handle->config.samplerate ) + { + return IVAS_ERROR( IVAS_ERR_NOT_IMPLEMENTED, "LC3plus config change (samplerate) in bitstream is not supported\n" ); + } + if ( payload.num_channels != handle->config.channels ) + { + return IVAS_ERROR( IVAS_ERR_NOT_IMPLEMENTED, "LC3plus config change (number of channels) in bitstream is not supported\n" ); + } + if ( payload.frame_duration_us != handle->config.lc3plus_frame_duration_us ) + { + return IVAS_ERROR( IVAS_ERR_NOT_IMPLEMENTED, "LC3plus config change (frame duration) in bitstream is not supported\n" ); + } + if ( payload.high_resolution_enabled != handle->config.high_res_mode_enabled ) + { + return IVAS_ERROR( IVAS_ERR_NOT_IMPLEMENTED, "LC3plus config change (high resolution mode) in bitstream is not supported\n" ); + } + if ( payload.num_media_times != config_num_media_times ) + { + return IVAS_ERROR( IVAS_ERR_NOT_IMPLEMENTED, "LC3plus config change (number of media times per frame data block) in bitstream is not supported\n" ); + } + } +#endif + +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + numSamplesPerLC3plusChannel = (int16_t) ( handle->config.samplerate / ( 1000000 / handle->config.isar_frame_duration_us ) / config_num_media_times ); + for ( iDec = 0; iDec < handle->num_decs; iDec++ ) + { + for ( iMediaTime = 0; iMediaTime < config_num_media_times; iMediaTime++ ) + { + iFtd = iDec + iMediaTime * handle->num_decs; +#else + lc3framesPerIvasFrame = handle->config.isar_frame_duration_us / handle->config.lc3plus_frame_duration_us; + + numSamplesPerLC3plusChannel = (int16_t) ( handle->config.samplerate / ( 1000000 / handle->config.isar_frame_duration_us ) / lc3framesPerIvasFrame ); + bitstreamOffsetPerCoder = bitstream_in_size / handle->num_decs / lc3framesPerIvasFrame; + for ( iDec = 0; iDec < handle->num_decs; iDec++ ) + { + for ( iLc3plusFrame = 0; iLc3plusFrame < lc3framesPerIvasFrame; iLc3plusFrame++ ) + { +#endif + if ( handle->selective_decoding_states[iDec]->shall_decode_cached_frame ) + { + if ( 0 == handle->bitstream_caches[iDec]->bitstream_cache_size ) + { + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "LC3plus cache is empty\n" ); + } + + err = decode_or_conceal_one_lc3plus_frame( handle->handles[iDec], handle->bitstream_caches[iDec]->bitstream_cache, handle->bitstream_caches[iDec]->bitstream_cache_size, &handle->pcm_conversion_buffer, badFrameIndicator ); + if ( err != IVAS_ERR_OK ) + { + return IVAS_ERROR( err, "lc3plus decoding failed\n" ); + } + handle->selective_decoding_states[iDec]->shall_decode_cached_frame = 0; + handle->selective_decoding_states[iDec]->has_skipped_a_frame = 0; + } + + /* reset cache if caching is enabled - it has either been decoded or is not needed */ + if ( NULL != handle->bitstream_caches ) + { + handle->bitstream_caches[iDec]->bitstream_cache_size = 0; + } + +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + switch ( handle->selective_decoding_states[iDec]->frame_action ) +#else + switch ( handle->selective_decoding_states[iDec]->frame_actions[iLc3plusFrame] ) +#endif + { +#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS + case DEC_ACTION_DECODE_AND_DROP: + { + err = decode_or_conceal_one_lc3plus_frame( handle->handles[iDec], bitstream_in_iter, bitstreamOffsetPerCoder, &handle->pcm_conversion_buffer, badFrameIndicator ); + if ( err != IVAS_ERR_OK ) + { + return IVAS_ERROR( err, "lc3plus decoding failed\n" ); + } + handle->selective_decoding_states[iDec]->has_skipped_a_frame = 0; + break; + } +#endif + case DEC_ACTION_DECODE_AND_USE: + { +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + if ( badFrameIndicator ) + { + err = decode_or_conceal_one_lc3plus_frame( handle->handles[iDec], bitstream_in, bitstream_in_size, &handle->pcm_conversion_buffer, badFrameIndicator ); + } + else if ( payload.ftds[iFtd].frame_data_length == LC3PLUS_RTP_FDL_SPEECH_BAD ) + { + return IVAS_ERR_NOT_IMPLEMENTED; + /* Untested therefore disabled. Would probably only need to call concealment, + * but the LC3plus API requires a non-NULL ptr for this which is not available here */ + } + else + { + err = decode_or_conceal_one_lc3plus_frame( handle->handles[iDec], payload.ftds[iFtd].frame_data, payload.ftds[iFtd].frame_data_length, &handle->pcm_conversion_buffer, badFrameIndicator ); + } + if ( err != IVAS_ERR_OK ) + { + return IVAS_ERROR( err, "lc3plus decoding failed\n" ); + } + + for ( int16_t iSampleInt16 = 0; iSampleInt16 < numSamplesPerLC3plusChannel; iSampleInt16++ ) + { + ivasSampleIndex = iSampleInt16 + iMediaTime * numSamplesPerLC3plusChannel; + pcm_out[iDec][ivasSampleIndex] = (float) handle->pcm_conversion_buffer[iSampleInt16]; + } + handle->selective_decoding_states[iDec]->has_skipped_a_frame = 0; + break; +#else + err = decode_or_conceal_one_lc3plus_frame( handle->handles[iDec], bitstream_in_iter, bitstreamOffsetPerCoder, &handle->pcm_conversion_buffer, badFrameIndicator ); + if ( err != IVAS_ERR_OK ) + { + return IVAS_ERROR( err, "lc3plus decoding failed\n" ); + } + + for ( int32_t iSampleInt16 = 0; iSampleInt16 < numSamplesPerLC3plusChannel; iSampleInt16++ ) + { + ivasSampleIndex = iSampleInt16 + iLc3plusFrame * numSamplesPerLC3plusChannel; + pcm_out[iDec][ivasSampleIndex] = (float) handle->pcm_conversion_buffer[iSampleInt16]; + } + handle->selective_decoding_states[iDec]->has_skipped_a_frame = 0; + break; +#endif + } +#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS + case DEC_ACTION_SKIP: + { + /* log that this instance has skipped a frame and must decode twice once reactivated */ + handle->selective_decoding_states[iDec]->has_skipped_a_frame = 1; + break; + } +#endif + case DEC_ACTION_CACHE: + { +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + if ( handle->bitstream_caches[iDec]->bitstream_cache_capacity < (int32_t) payload.ftds[iFtd].frame_data_length ) + { + return IVAS_ERROR( IVAS_ERR_INVALID_BUFFER_SIZE, "bitstream_cache_capacity is too low for LC3plus frame size\n" ); + } + /* store bit rate of cached frame */ + mvc2c( payload.ftds[iFtd].frame_data, handle->bitstream_caches[iDec]->bitstream_cache, (int16_t) payload.ftds[iFtd].frame_data_length ); + handle->bitstream_caches[iDec]->bitstream_cache_size = payload.ftds[iFtd].frame_data_length; + /* log that this instance has skipped a frame and must decode twice once reactivated */ + handle->selective_decoding_states[iDec]->has_skipped_a_frame = 1; + break; +#else + if ( handle->bitstream_caches[iDec]->bitstream_cache_capacity < bitstreamOffsetPerCoder ) + { + return IVAS_ERROR( IVAS_ERR_INVALID_BUFFER_SIZE, "bitstream_cache_capacity is too low for LC3plus frame size\n" ); + } + /* store bit rate of cached frame */ + mvc2c( bitstream_in_iter, handle->bitstream_caches[iDec]->bitstream_cache, (int16_t) bitstreamOffsetPerCoder ); + handle->bitstream_caches[iDec]->bitstream_cache_size = bitstreamOffsetPerCoder; + /* log that this instance has skipped a frame and must decode twice once reactivated */ + handle->selective_decoding_states[iDec]->has_skipped_a_frame = 1; + break; +#endif + } + case DEC_ACTION_NUM_ENUMS: + default: + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "invalid LC3plus decoder state\n" ); + } +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + } /* for each media time */ + /* reset skipping state, must be set by the user before each decode call*/ + handle->selective_decoding_states[iDec]->frame_action = DEC_ACTION_DECODE_AND_USE; + } /* for each dec/channel */ +#else + + bitstream_in_iter += bitstreamOffsetPerCoder; + } + + /* reset skipping state, must be set by the user before each decode call*/ + for ( iLc3plusFrame = 0; iLc3plusFrame < lc3framesPerIvasFrame; iLc3plusFrame++ ) + { + handle->selective_decoding_states[iDec]->frame_actions[iLc3plusFrame] = DEC_ACTION_DECODE_AND_USE; + } + } + +#endif + return IVAS_ERR_OK; +} + + +/*------------------------------------------------------------------------- + * ISAR_LC3PLUS_DEC_Decode() + * + * + *------------------------------------------------------------------------*/ + +ivas_error ISAR_LC3PLUS_DEC_Decode( + ISAR_LC3PLUS_DEC_HANDLE handle, /* i : LC3plus decoder configuration */ + uint8_t *bitstream_in, /* i : pointer to input bitstream */ + const int32_t bitstream_in_size, /* i : size of bitstream_in */ + float **pcm_out /* o : decoded samples */ +) +{ + int16_t badFrameIndicator; + + if ( NULL == handle ) + { + return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "LC3PLUS_Dec_Wrap_Handle is NULL\n" ); + } + if ( NULL == bitstream_in ) + { + return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "bitstream_in is NULL\n" ); + } + if ( NULL == pcm_out ) + { + return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "pcm_out is NULL\n" ); + } + badFrameIndicator = 0; + + return isar_LC3PLUS_DEC_Decode_or_Conceal_internal( handle, bitstream_in, bitstream_in_size, badFrameIndicator, pcm_out ); +} + + +/*------------------------------------------------------------------------- + * ISAR_LC3PLUS_DEC_Conceal() + * + * + *------------------------------------------------------------------------*/ + +ivas_error ISAR_LC3PLUS_DEC_Conceal( + ISAR_LC3PLUS_DEC_HANDLE handle, /* i : LC3plus decoder handle */ + float **pcm_out /* o : concealed samples */ +) +{ + uint8_t bitstream_in[LC3PLUS_MAX_BYTES]; + int16_t badFrameIndicator; + + if ( NULL == handle ) + { + return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "LC3PLUS_Dec_Wrap_Handle is NULL\n" ); + } + + if ( NULL == pcm_out ) + { + return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "pcm_out is NULL\n" ); + } + + /* LC3plus API requires a non-NULL bitstream pointer, even when triggering concealment */ + badFrameIndicator = 1; + + return isar_LC3PLUS_DEC_Decode_or_Conceal_internal( handle, bitstream_in, 0, badFrameIndicator, pcm_out ); +} +#endif /* SPLIT_REND_WITH_HEAD_ROT */ diff --git a/lib_isar/isar_lc3plus_dec.h b/lib_isar/isar_lc3plus_dec.h new file mode 100644 index 0000000000000000000000000000000000000000..3949cf766d4f507ee0eb23c64c25eea203273a96 --- /dev/null +++ b/lib_isar/isar_lc3plus_dec.h @@ -0,0 +1,135 @@ +/****************************************************************************************************** + + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#ifndef ISAR_LC3PLUS_DEC_H +#define ISAR_LC3PLUS_DEC_H + +#include +#include "options.h" +#ifdef SPLIT_REND_WITH_HEAD_ROT +#include "lc3.h" +#include "ivas_error.h" +#include "ivas_cnst.h" +#include "isar_lc3plus_common.h" + + +typedef enum +{ +#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS + DEC_ACTION_DECODE_AND_DROP = 0, +#endif + DEC_ACTION_DECODE_AND_USE, +#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS + DEC_ACTION_SKIP, +#endif + DEC_ACTION_CACHE, + DEC_ACTION_NUM_ENUMS +} SelectiveDecAction; + + +typedef struct ISAR_LC3PLUS_DEC_SELECTIVE_DECODING_STATE +{ + /*! indicates that the decoder has skipped one or more frames. This means it must decode two frames to flush algorithmic delay when re-activated */ + int16_t has_skipped_a_frame; +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + /*! action to execute for the next frame */ + SelectiveDecAction frame_action; +#else + /*! if set to 1, decoder will skip decoding for the next frame */ + SelectiveDecAction *frame_actions; +#endif + /*! if set to 1, decoder will decode the cache before decoding any of current frames */ + int16_t shall_decode_cached_frame; +} ISAR_LC3PLUS_DEC_SELECTIVE_DECODING_STATE; + +typedef struct ISAR_LC3PLUS_DEC_BITSTREAM_CACHE +{ + uint8_t *bitstream_cache; + int32_t bitstream_cache_capacity; + int32_t bitstream_cache_size; +} ISAR_LC3PLUS_DEC_BITSTREAM_CACHE; + +/* decoder wrapper */ +typedef struct ISAR_LC3PLUS_DEC_HANDLE +{ + LC3PLUS_Dec **handles; + ISAR_LC3PLUS_DEC_SELECTIVE_DECODING_STATE **selective_decoding_states; + ISAR_LC3PLUS_DEC_BITSTREAM_CACHE **bitstream_caches; + uint32_t num_decs; + int16_t *pcm_conversion_buffer; + LC3PLUS_CONFIG config; +} * ISAR_LC3PLUS_DEC_HANDLE; + +ivas_error ISAR_LC3PLUS_DEC_Open( + const LC3PLUS_CONFIG config, /* i : decoder configuration */ + ISAR_LC3PLUS_DEC_HANDLE *handle /* o : decoder handle */ +); + +ivas_error ISAR_LC3PLUS_DEC_GetDelay( + ISAR_LC3PLUS_DEC_HANDLE handle, /* i : decoder handle */ + int32_t *delayInSamples /* o : algorithmic delay of encoding and decoding in number of samples per channel */ +); + +void ISAR_LC3PLUS_DEC_Close( + ISAR_LC3PLUS_DEC_HANDLE *handle /* i/o: pointer to decoder handle */ +); + +#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS +/*! Sets a matrix[MAX_PARAM_SPATIAL_SUBFRAMES][numLC3plusDecoders] where all require subframes must be flagged with 1, frames that are not required with 0 */ +ivas_error ISAR_LC3PLUS_DEC_SetSelectiveDecodingMatrix( + ISAR_LC3PLUS_DEC_HANDLE handle, /* i : decoder handle */ + int16_t *subframeChannelMatrix[MAX_PARAM_SPATIAL_SUBFRAMES] /* i : */ +); +#endif + +ivas_error ISAR_LC3PLUS_DEC_Decode( + ISAR_LC3PLUS_DEC_HANDLE handle, /* i : decoder handle */ + uint8_t *bitstream_in, /* i : pointer to input bitstream */ + const int32_t bitstream_in_size, /* i : size of bitstream_in */ + float **pcm_out /* o : decoded samples */ +); + +ivas_error ISAR_LC3PLUS_DEC_Conceal( + ISAR_LC3PLUS_DEC_HANDLE handle, /* i : decoder handle */ + float **pcm_out /* o : concealed samples */ +); + +#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS +ivas_error ISAR_LC3PLUS_DEC_AllocateSubframeDecodingMatrix( + int16_t ***subframeChannelMatrix, + const uint32_t num_decs ); + +void ISAR_LC3PLUS_DEC_FreeSubframeDecodingMatrix( int16_t **subframeChannelMatrix ); +#endif + +#endif /* SPLIT_REND_WITH_HEAD_ROT */ +#endif /* ISAR_LC3PLUS_DEC_H */ diff --git a/lib_isar/isar_lc3plus_enc.c b/lib_isar/isar_lc3plus_enc.c new file mode 100644 index 0000000000000000000000000000000000000000..5e32b2c279a57d0fc378110343cdc00380c28ac1 --- /dev/null +++ b/lib_isar/isar_lc3plus_enc.c @@ -0,0 +1,686 @@ +/****************************************************************************************************** + + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#include "isar_lc3plus_enc.h" +#include "isar_lc3plus_common.h" +#include "lc3.h" +#include "ivas_error_utils.h" +#include "prot.h" +#include "wmc_auto.h" +#include "options.h" + +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS +static const LC3PLUS_RTP_FDL s_fdl_request = LC3PLUS_RTP_FDL_NO_REQ_OR_NO_DATA; +#endif + +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS +static int32_t limit_per_channel_bitrate( LC3PLUS_CONFIG config, + int32_t per_channel_bitrate ) +{ + if ( config.high_res_mode_enabled ) + { + switch ( config.lc3plus_frame_duration_us ) + { + case 10000: + return min( per_channel_bitrate, 500000 ); + case 5000: + return min( per_channel_bitrate, 600000 ); + case 2500: + return min( per_channel_bitrate, 672000 ); + default: + assert( false && "unreachable" ); + } + } + + switch ( config.samplerate ) + { + case 48000: + case 32000: + return min( per_channel_bitrate, 320000 ); + case 24000: + return min( per_channel_bitrate, 314400 ); + case 16000: + return min( per_channel_bitrate, 221600 ); + case 8000: + return min( per_channel_bitrate, 114400 ); + default: + assert( false && "unreachable" ); + } + + assert( false && "unreachable" ); + return -1; +} +#endif + +#ifdef SPLIT_REND_WITH_HEAD_ROT +/*-------------------------------------------------------------------* + * Function ISAR_LC3PLUS_ENC_Open() + * + * + *-------------------------------------------------------------------*/ + +ivas_error ISAR_LC3PLUS_ENC_Open( + const LC3PLUS_CONFIG config, /* i : LC3plus encoder configuration */ + const uint32_t bitsPerSecond, /* i : bit rate */ + ISAR_LC3PLUS_ENC_HANDLE *handle /* o : encoder handle */ +) +{ +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + int32_t num_lc3plus_media_times_per_ivas_frame; +#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS + int32_t lc3plus_num_bytes_per_frame; +#endif + bool is_last_media_time, is_last_channel; +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + ivas_error ivas_err; +#endif +#endif +#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS + int32_t bitsPerSecondPerChannel; +#endif + int32_t encoder_size; + LC3PLUS_Error err; + int32_t lfeChans[1]; + int16_t i; + + lfeChans[0] = 0; + + if ( 0U == config.channels ) + { + return IVAS_ERROR( IVAS_ERR_INTERNAL, "Invalid number of channels\n" ); + } +#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS + bitsPerSecondPerChannel = bitsPerSecond / config.channels; +#endif +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + if ( config.lc3plus_frame_duration_us != 2500 && config.lc3plus_frame_duration_us != 5000 && config.lc3plus_frame_duration_us != 10000 ) + { + return IVAS_ERROR( IVAS_ERR_INTERNAL, "Invalid lc3plus_frame_duration_us\n" ); + } + if ( config.isar_frame_duration_us != 20000 && config.isar_frame_duration_us != 10000 && config.isar_frame_duration_us != 5000 ) + { + return IVAS_ERROR( IVAS_ERR_INTERNAL, "Invalid isar_frame_duration_us\n" ); + } +#endif + encoder_size = lc3plus_enc_get_size( config.samplerate, 1 ); + if ( 0 == encoder_size ) + { + return IVAS_ERROR( IVAS_ERR_INTERNAL, "lc3plus_enc_get_size failed\n" ); + } + + if ( ( *handle = malloc( sizeof( struct ISAR_LC3PLUS_ENC_HANDLE ) ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LC3plus wrapper handle\n" ); + } +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + ( *handle )->config = config; + ( *handle )->frame_type_descriptors = NULL; +#endif + + ( *handle )->pcm_conversion_buffer = NULL; + ( *handle )->num_encs = 0; + if ( ( ( *handle )->handles = malloc( config.channels * sizeof( ISAR_LC3PLUS_ENC_HANDLE ) ) ) == NULL ) + { + ISAR_LC3PLUS_ENC_Close( handle ); + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LC3plus wrapper handle\n" ); + } + + for ( i = 0; i < config.channels; ++i ) + { + ( *handle )->handles[i] = NULL; + } + ( *handle )->num_encs = config.channels; +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + num_lc3plus_media_times_per_ivas_frame = config.isar_frame_duration_us / config.lc3plus_frame_duration_us; + ( *handle )->fdl_request = s_fdl_request; + ( *handle )->num_ftds = config.channels * num_lc3plus_media_times_per_ivas_frame; + ( *handle )->frame_type_descriptors = malloc( ( *handle )->num_ftds * sizeof( LC3PLUS_RTP_FTD ) ); + if ( NULL == ( *handle )->frame_type_descriptors ) + { + ISAR_LC3PLUS_ENC_Close( handle ); + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LC3plus frame_type_descriptors\n" ); + } +#endif + + for ( int32_t iCh = 0; iCh < config.channels; iCh++ ) + { + if ( ( ( *handle )->handles[iCh] = malloc( encoder_size ) ) == NULL ) + { + ISAR_LC3PLUS_ENC_Close( handle ); + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LC3plus encoder\n" ); + } + +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + err = lc3plus_enc_init( ( *handle )->handles[iCh], config.samplerate, 1, config.high_res_mode_enabled, lfeChans ); +#else + err = lc3plus_enc_init( ( *handle )->handles[iCh], config.samplerate, 1, 0, lfeChans ); +#endif + if ( err != LC3PLUS_OK ) + { + ISAR_LC3PLUS_ENC_Close( handle ); + return IVAS_ERROR( ISAR_LC3PLUS_LC3plusErrToIvasErr( err ), "lc3plus_enc_init failed\n" ); + } + + err = lc3plus_enc_set_frame_dms( ( *handle )->handles[iCh], config.lc3plus_frame_duration_us / 100 ); + if ( err != LC3PLUS_OK ) + { + ISAR_LC3PLUS_ENC_Close( handle ); + return IVAS_ERROR( ISAR_LC3PLUS_LC3plusErrToIvasErr( err ), "lc3plus_enc_set_frame_dms failed\n" ); + } +#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS + err = lc3plus_enc_set_bitrate( ( *handle )->handles[iCh], bitsPerSecondPerChannel ); + if ( err != LC3PLUS_OK ) + { + ISAR_LC3PLUS_ENC_Close( handle ); + return IVAS_ERROR( ISAR_LC3PLUS_LC3plusErrToIvasErr( err ), "lc3plus_enc_set_bitrate failed\n" ); + } +#endif + } + + if ( config.isar_frame_duration_us < config.lc3plus_frame_duration_us || config.isar_frame_duration_us % config.lc3plus_frame_duration_us != 0 ) + { + ISAR_LC3PLUS_ENC_Close( handle ); + return IVAS_ERROR( IVAS_ERR_NOT_IMPLEMENTED, "Current pcm_conversion_buffer sizing requires that lc3plus uses a shorter or equal frame duration than ivas\n" ); + } + +#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS + ( *handle )->config = config; +#endif + ( *handle )->pcm_conversion_buffer = malloc( sizeof( int16_t ) * config.samplerate * config.lc3plus_frame_duration_us / 1000000 ); + if ( NULL == ( *handle )->pcm_conversion_buffer ) + { + ISAR_LC3PLUS_ENC_Close( handle ); + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LC3plus encoder wrapper pcm_conversion_buffer\n" ); + } + +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + /* update FDI fields */ + for ( int32_t iMediaTime = 0; iMediaTime < num_lc3plus_media_times_per_ivas_frame; ++iMediaTime ) + { + for ( uint32_t iEnc = 0; iEnc < ( *handle )->num_encs; ++iEnc ) + { + int32_t ftd_index = iEnc + iMediaTime * ( *handle )->num_encs; +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + ( *handle )->frame_type_descriptors[ftd_index].frame_data_length = 0; /* will be set to the correct value in IVAS_LC3PLUS_ENC_SetBitrate */ +#else + lc3plus_num_bytes_per_frame = lc3plus_enc_get_num_bytes( ( *handle )->handles[iEnc] ); + if ( lc3plus_num_bytes_per_frame <= 0 ) + { + ISAR_LC3PLUS_ENC_Close( handle ); + return IVAS_ERROR( IVAS_ERR_INTERNAL, "lc3plus_enc_get_num_bytes reported invalid result failed\n" ); + } + ( *handle )->frame_type_descriptors[ftd_index].frame_data_length = lc3plus_num_bytes_per_frame; +#endif + if ( 0 != LC3PLUS_RTP_ftd_bwr_from_samplerate( &( *handle )->frame_type_descriptors[ftd_index].bwr, config.samplerate, config.high_res_mode_enabled ) ) + { + ISAR_LC3PLUS_ENC_Close( handle ); + return IVAS_ERROR( IVAS_ERR_INTERNAL, "LC3PLUS_RTP_ftd_bwr_from_samplerate failed\n" ); + } + if ( 0 != LC3PLUS_RTP_ftd_fdi_from_frame_duration_us( &( *handle )->frame_type_descriptors[ftd_index].fdi, config.lc3plus_frame_duration_us ) ) + { + ISAR_LC3PLUS_ENC_Close( handle ); + return IVAS_ERROR( IVAS_ERR_INTERNAL, "LC3PLUS_RTP_ftd_fdi_from_frame_duration_us failed\n" ); + } + ( *handle )->frame_type_descriptors[ftd_index].h = LC3PLUS_RTP_FTD_H_PRIMARY; + ( *handle )->frame_type_descriptors[ftd_index].frame_data = NULL; + + /* The FTDs in the ToC are included in the following order: + * 1) First the FTD for the first channel of the first FDB (oldest frame) + * 2) Then the FTDs for the remaining channels for the first FDB in increasing CC order + * 3) Then the FTD for the first channel of the second FDB + * 4) Then the FTDs for the remaining channels for the second FDB + * 5) Etc. to the last FDB */ + is_last_media_time = num_lc3plus_media_times_per_ivas_frame - 1 == iMediaTime; + is_last_channel = ( *handle )->num_encs - 1 == iEnc; + if ( is_last_media_time && is_last_channel ) + { + ( *handle )->frame_type_descriptors[ftd_index].fc = LC3PLUS_RTP_FTD_FC_LAST_OVERALL; + } + else if ( !is_last_media_time && is_last_channel ) + { + ( *handle )->frame_type_descriptors[ftd_index].fc = LC3PLUS_RTP_FTD_FC_LAST_IN_MEDIATIME; + } + else + { + ( *handle )->frame_type_descriptors[ftd_index].fc = LC3PLUS_RTP_FTD_FC_SUBSEQUENT_CHANNEL; + } + } + } + +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + ivas_err = IVAS_LC3PLUS_ENC_SetBitrate( *handle, bitsPerSecond ); + if ( ivas_err != IVAS_ERR_OK ) + { + ISAR_LC3PLUS_ENC_Close( handle ); + return ivas_err; + } +#endif +#endif + return IVAS_ERR_OK; +} + +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS +/*-------------------------------------------------------------------* + * Function IVAS_LC3PLUS_ENC_SetBitrate() + * + * + *-------------------------------------------------------------------*/ + +ivas_error IVAS_LC3PLUS_ENC_SetBitrate( + ISAR_LC3PLUS_ENC_HANDLE handle, /* o : LC3plus encoder handle */ + const uint32_t bitsPerSecond /* i : new target bit rate */ +) +{ + int32_t numLc3plusMediaTimesPerIvasFrame; + int32_t lc3plus_num_bytes_per_frame; + int32_t availableOctetsPerIsarFrame; + int32_t actualOctetsPerFrame; + LC3PLUS_Error err; + int32_t iFtd; + int32_t fdrLength; + int32_t lc3plusPacketRate; + int32_t numSubframes; + int32_t minPayloadOverhead; + int32_t targetLc3PlusBitratePerChannel; + int32_t targetLc3PlusOctetCount; + int32_t lc3plusFdlLength; + + if ( NULL == handle ) + { + return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "LC3PLUS_Enc_Wrap_Handle is NULL\n" ); + } + + availableOctetsPerIsarFrame = bitsPerSecond / ( 1000000 / handle->config.isar_frame_duration_us ) / 8; + lc3plusPacketRate = 1000 * 1000 / handle->config.lc3plus_frame_duration_us; + numLc3plusMediaTimesPerIvasFrame = handle->config.isar_frame_duration_us / handle->config.lc3plus_frame_duration_us; + numSubframes = numLc3plusMediaTimesPerIvasFrame * handle->config.channels; + + /* subtract minimum required payload bytes & calculate a first per-channel target bit rate */ + if ( LC3PLUS_RTP_frame_data_length_get_size( &fdrLength, s_fdl_request ) != LC3PLUS_RTP_ERR_NO_ERROR ) + { + return IVAS_ERROR( IVAS_ERR_INTERNAL, "LC3PLUS_RTP_frame_data_length_get_size failed\n" ); + } + minPayloadOverhead = fdrLength + ( numSubframes * LC3PLUS_RTP_FTD_MIN_SIZE ); + targetLc3PlusBitratePerChannel = ( availableOctetsPerIsarFrame - minPayloadOverhead ) / handle->config.channels * 8 * lc3plusPacketRate / numLc3plusMediaTimesPerIvasFrame; +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + if ( targetLc3PlusBitratePerChannel <= 0 ) + { + return IVAS_ERROR( IVAS_ERR_LC3PLUS_INVALID_BITRATE, "available LC3plus bitrate <= 0\n" ); + } +#endif + targetLc3PlusBitratePerChannel = limit_per_channel_bitrate( handle->config, targetLc3PlusBitratePerChannel ); + targetLc3PlusOctetCount = targetLc3PlusBitratePerChannel / 8 / lc3plusPacketRate; + /* check resulting octet count. If it requires larger than 1-byte length fields, decrease the bitrate by enough to make room for the additional length field */ + if ( LC3PLUS_RTP_frame_data_length_get_size( &lc3plusFdlLength, targetLc3PlusOctetCount ) != LC3PLUS_RTP_ERR_NO_ERROR ) + { + return IVAS_ERROR( IVAS_ERR_INTERNAL, "LC3PLUS_RTP_frame_data_length_get_size failed\n" ); + } + if ( lc3plusFdlLength != LC3PLUS_RTP_FDL_MIN_LENGTH ) + { + /* reduce bitrate to allow for the required fdl field */ + targetLc3PlusBitratePerChannel = ( targetLc3PlusOctetCount - ( lc3plusFdlLength - LC3PLUS_RTP_FDL_MIN_LENGTH ) ) / handle->config.channels * 8 * lc3plusPacketRate; + } + + for ( int32_t iCh = 0; iCh < handle->config.channels; iCh++ ) + { + err = lc3plus_enc_set_bitrate( handle->handles[iCh], targetLc3PlusBitratePerChannel ); + if ( err != LC3PLUS_OK ) + { + return IVAS_ERROR( ISAR_LC3PLUS_LC3plusErrToIvasErr( err ), "lc3plus_enc_set_bitrate failed\n" ); + } + } + + // update FTD settings after bitrate change + for ( int32_t iMediaTime = 0; iMediaTime < numLc3plusMediaTimesPerIvasFrame; ++iMediaTime ) + { + for ( uint32_t iEnc = 0; iEnc < handle->num_encs; ++iEnc ) + { + iFtd = iEnc + iMediaTime * handle->num_encs; + lc3plus_num_bytes_per_frame = lc3plus_enc_get_num_bytes( handle->handles[iEnc] ); + if ( lc3plus_num_bytes_per_frame <= 0 ) + { + return IVAS_ERROR( IVAS_ERR_INTERNAL, "lc3plus_enc_get_num_bytes reported invalid result failed\n" ); + } + handle->frame_type_descriptors[iFtd].frame_data_length = lc3plus_num_bytes_per_frame; + } + } + + // TODO: remove sanity checks? + if ( ISAR_LC3PLUS_ENC_GetOutputBitstreamSize( handle, &actualOctetsPerFrame ) != IVAS_ERR_OK ) + { + return IVAS_ERROR( IVAS_ERR_INTERNAL, "ISAR_LC3PLUS_ENC_GetOutputBitstreamSize failed\n" ); + } + if ( actualOctetsPerFrame > availableOctetsPerIsarFrame ) + { + return IVAS_ERROR( IVAS_ERR_INTERNAL, "Bitrate reduction logic failed\n" ); + } + return IVAS_ERR_OK; +} +#endif + + +/*-------------------------------------------------------------------* + * Function ISAR_LC3PLUS_ENC_GetDelay() + * + * + *-------------------------------------------------------------------*/ + +ivas_error ISAR_LC3PLUS_ENC_GetDelay( + ISAR_LC3PLUS_ENC_HANDLE handle, /* i : LC3plus encoder handle */ + int32_t *delayInSamples /* o : encoder delay in number of samples per channel */ +) +{ + int32_t tmpDelayInSamples; + + if ( NULL == handle ) + { + return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "LC3PLUS_Enc_Wrap_Handle is NULL\n" ); + } + if ( NULL == delayInSamples ) + { + return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "delayInSamples is NULL\n" ); + } + + *delayInSamples = 0; + /* sanity check whether all encoders are actually configured identically */ + for ( uint32_t iEnc = 0; iEnc < handle->num_encs; iEnc++ ) + { + if ( NULL == handle->handles[iEnc] ) + { + return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "LC3plus encoder handle is NULL\n" ); + } + + tmpDelayInSamples = lc3plus_enc_get_delay( handle->handles[iEnc] ); + if ( 0 != *delayInSamples && tmpDelayInSamples != *delayInSamples ) + { + return IVAS_ERROR( IVAS_ERR_INTERNAL, "Not all mono LC3plus encoders are configured identically\n" ); + } + *delayInSamples = tmpDelayInSamples; + } + + return IVAS_ERR_OK; +} + + +/*-------------------------------------------------------------------* + * Function ISAR_LC3PLUS_ENC_GetOutputBitstreamSize() + * + * + *-------------------------------------------------------------------*/ + +ivas_error ISAR_LC3PLUS_ENC_GetOutputBitstreamSize( + ISAR_LC3PLUS_ENC_HANDLE handle, /* i : LC3plus encoder handle */ + int32_t *bsSize /* o : size of each bitstream frame in bytes */ +) +{ +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + LC3PLUS_RTP_ERR rtp_err; + int32_t num_lc3plus_media_times_per_ivas_frame; + int32_t iMediaTime; + int32_t ftd_frame_data_length_size, lc3plus_frame_data_length; + int32_t ftd_index; +#else + int32_t bitstreamSizeMultiplier; +#endif + if ( NULL == handle ) + { + return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "LC3PLUS_Enc_Wrap_Handle is NULL\n" ); + } + if ( NULL == bsSize ) + { + return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "bsSize is NULL\n" ); + } + +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + if ( 0 == handle->config.lc3plus_frame_duration_us ) + { + return IVAS_ERROR( IVAS_ERR_INIT_ERROR, "lc3plus_frame_duration_us is 0\n" ); + } + if ( handle->config.isar_frame_duration_us % handle->config.lc3plus_frame_duration_us != 0 ) + { + return IVAS_ERROR( IVAS_ERR_NOT_IMPLEMENTED, "isar_frame_duration_us must be equal or multiple of lc3plus_frame_duration_us \n" ); + } + + num_lc3plus_media_times_per_ivas_frame = handle->config.isar_frame_duration_us / handle->config.lc3plus_frame_duration_us; +#endif + *bsSize = 0; +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + int32_t fdl_request_length; + rtp_err = LC3PLUS_RTP_frame_data_length_get_size( &fdl_request_length, handle->fdl_request ); + if ( rtp_err != LC3PLUS_RTP_ERR_NO_ERROR ) + { + return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Invalid LC3plus frame_data_length request\n" ); + } + *bsSize += fdl_request_length; +#endif + for ( uint32_t iEnc = 0; iEnc < handle->num_encs; iEnc++ ) + { + if ( NULL == handle->handles[iEnc] ) + { + return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "LC3plus encoder handle is NULL\n" ); + } +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + lc3plus_frame_data_length = lc3plus_enc_get_num_bytes( handle->handles[iEnc] ); + for ( iMediaTime = 0; iMediaTime < num_lc3plus_media_times_per_ivas_frame; ++iMediaTime ) + { + ftd_index = iEnc + iMediaTime * handle->num_encs; + if ( lc3plus_frame_data_length != (int32_t) handle->frame_type_descriptors[ftd_index].frame_data_length ) + { + return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "LC3plus FTD data not synchronised with encoder bitrate\n" ); + } + rtp_err = LC3PLUS_RTP_frame_data_length_get_size( &ftd_frame_data_length_size, handle->frame_type_descriptors[ftd_index].frame_data_length ); + if ( rtp_err != LC3PLUS_RTP_ERR_NO_ERROR ) + { + return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Invalid LC3plus frame_data_length\n" ); + } + *bsSize += LC3PLUS_RTP_FTD_LENGTH_EXCLUDING_FDL; + *bsSize += handle->frame_type_descriptors[ftd_index].frame_data_length; + *bsSize += ftd_frame_data_length_size; + } + } +#else + *bsSize += lc3plus_enc_get_num_bytes( handle->handles[iEnc] ); + } + + if ( handle->config.isar_frame_duration_us % handle->config.lc3plus_frame_duration_us != 0 ) + { + return IVAS_ERROR( IVAS_ERR_NOT_IMPLEMENTED, "isar_frame_duration_us must be equal or multiple of lc3plus_frame_duration_us \n" ); + } + bitstreamSizeMultiplier = handle->config.isar_frame_duration_us / handle->config.lc3plus_frame_duration_us; + + *bsSize *= bitstreamSizeMultiplier; +#endif + + return IVAS_ERR_OK; +} + + +/*-------------------------------------------------------------------* + * Function ISAR_LC3PLUS_ENC_Close() + * + * + *-------------------------------------------------------------------*/ + +void ISAR_LC3PLUS_ENC_Close( + ISAR_LC3PLUS_ENC_HANDLE *handle /* i/o: pointer to LC3plus encoder handle */ +) +{ + if ( NULL == handle || NULL == *handle ) + { + return; + } +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + if ( NULL != ( *handle )->frame_type_descriptors ) + { + free( ( *handle )->frame_type_descriptors ); + } +#endif + for ( uint32_t iEnc = 0; iEnc < ( *handle )->num_encs; iEnc++ ) + { + if ( NULL != ( *handle )->handles[iEnc] ) + { + lc3plus_free_encoder_structs( ( *handle )->handles[iEnc] ); + free( ( *handle )->handles[iEnc] ); + } + } + if ( NULL != ( *handle )->pcm_conversion_buffer ) + { + free( ( *handle )->pcm_conversion_buffer ); + } + + free( ( *handle )->handles ); + free( *handle ); + + *handle = NULL; + + return; +} + + +/*-------------------------------------------------------------------* + * Function ISAR_LC3PLUS_ENC_Encode() + * + * + *-------------------------------------------------------------------*/ + +ivas_error ISAR_LC3PLUS_ENC_Encode( + ISAR_LC3PLUS_ENC_HANDLE handle, /* i : LC3plus encoder handle */ + float **pcm_in, /* i : pointer input samples */ +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + void *bitstream_out, /* o : pointer to bitstream frame */ + const int32_t bitstream_out_size /* i : size of the bitstream_out buffer in bytes. Must be equal to ISAR_LC3PLUS_ENC_GetOutputBitstreamSize. */ +#else + void *bitstream_out /* o : pointer to bitstream frame */ +#endif +) +{ +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + int32_t ftdIndex; + LC3PLUS_RTP_ERR rtpErr; + uint32_t num_media_times; +#else + uint32_t lc3framesPerIvasFrame; + uint8_t *bitstream_out_iter = bitstream_out; +#endif + uint32_t numSamplesPerLC3plusChannel; + int32_t ivasSampleIndex; + int32_t num_bytes = 0; + LC3PLUS_Error err; + + push_wmops( "ISAR_LC3PLUS_ENC_Encode" ); + + if ( NULL == handle ) + { + return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "LC3PLUS_Enc_Wrap_Handle is NULL\n" ); + } + if ( NULL == pcm_in ) + { + return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "pcm_in is NULL\n" ); + } + if ( NULL == bitstream_out ) + { + return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "bitstream_out is NULL\n" ); + } + + if ( handle->config.isar_frame_duration_us % handle->config.lc3plus_frame_duration_us != 0 ) + { + return IVAS_ERROR( IVAS_ERR_NOT_IMPLEMENTED, "isar_frame_duration_us must be equal or multiple of lc3plus_frame_duration_us \n" ); + } +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + num_media_times = handle->config.isar_frame_duration_us / handle->config.lc3plus_frame_duration_us; + numSamplesPerLC3plusChannel = handle->config.samplerate / ( 1000000 / handle->config.isar_frame_duration_us ) / num_media_times; + + size_t actual_size; + rtpErr = LC3PLUS_RTP_payload_serialize( bitstream_out, bitstream_out_size, &actual_size, s_fdl_request, handle->frame_type_descriptors, handle->num_ftds ); + if ( rtpErr != LC3PLUS_RTP_ERR_NO_ERROR ) + { + return IVAS_ERROR( IVAS_LC3PLUS_LC3plusRtpErrToIvasErr( rtpErr ), "LC3PLUS_RTP_payload_serialize failed\n" ); + } +#else + lc3framesPerIvasFrame = handle->config.isar_frame_duration_us / handle->config.lc3plus_frame_duration_us; + + numSamplesPerLC3plusChannel = handle->config.samplerate / ( 1000000 / handle->config.isar_frame_duration_us ) / lc3framesPerIvasFrame; +#endif + for ( uint32_t iEnc = 0; iEnc < handle->num_encs; iEnc++ ) + { +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + for ( uint32_t iMediaTime = 0; iMediaTime < num_media_times; iMediaTime++ ) +#else + for ( uint32_t iLc3plusFrame = 0; iLc3plusFrame < lc3framesPerIvasFrame; iLc3plusFrame++ ) +#endif + { + for ( uint32_t iSampleInt16 = 0; iSampleInt16 < numSamplesPerLC3plusChannel; iSampleInt16++ ) + { +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + ivasSampleIndex = iSampleInt16 + iMediaTime * numSamplesPerLC3plusChannel; +#else + ivasSampleIndex = iSampleInt16 + iLc3plusFrame * numSamplesPerLC3plusChannel; +#endif + handle->pcm_conversion_buffer[iSampleInt16] = (int16_t) max( INT16_MIN, min( pcm_in[iEnc][ivasSampleIndex], INT16_MAX ) ); + } + +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + ftdIndex = iMediaTime * handle->num_encs + iEnc; +#endif + num_bytes = 0; + push_wmops( "lc3plus_enc16" ); +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + err = lc3plus_enc16( handle->handles[iEnc], &handle->pcm_conversion_buffer, handle->frame_type_descriptors[ftdIndex].frame_data, &num_bytes, NULL ); +#else + err = lc3plus_enc16( handle->handles[iEnc], &handle->pcm_conversion_buffer, bitstream_out_iter, &num_bytes, NULL ); +#endif + pop_wmops(); + if ( err != LC3PLUS_OK ) + { + return IVAS_ERROR( ISAR_LC3PLUS_LC3plusErrToIvasErr( err ), "lc3plus_enc16 failed\n" ); + } + if ( 0 == num_bytes ) + { + return IVAS_ERROR( IVAS_ERR_INTERNAL, "lc3plus_enc16 did not produce output\n" ); + } +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + if ( num_bytes != (int32_t) handle->frame_type_descriptors[ftdIndex].frame_data_length ) + { + return IVAS_ERROR( IVAS_ERR_INTERNAL, "payload format and lc3plus enc bitrate are not aligned\n" ); + } +#else + + bitstream_out_iter += num_bytes; +#endif + } + } + + pop_wmops(); + + return IVAS_ERR_OK; +} +#endif /* SPLIT_REND_WITH_HEAD_ROT */ diff --git a/lib_isar/isar_lc3plus_enc.h b/lib_isar/isar_lc3plus_enc.h new file mode 100644 index 0000000000000000000000000000000000000000..256542ef53a731726c0ee6f5535df8fe976b3aba --- /dev/null +++ b/lib_isar/isar_lc3plus_enc.h @@ -0,0 +1,102 @@ +/****************************************************************************************************** + + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#ifndef ISAR_LC3PLUS_ENC_H +#define ISAR_LC3PLUS_ENC_H + +#include +#include "ivas_error.h" +#ifdef SPLIT_REND_WITH_HEAD_ROT +#include "lc3.h" +#include "isar_lc3plus_common.h" +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS +#include "isar_lc3plus_payload.h" +#endif + +/* encoder wrapper */ +typedef struct ISAR_LC3PLUS_ENC_HANDLE +{ + LC3PLUS_CONFIG config; + LC3PLUS_Enc **handles; + uint32_t num_encs; + int16_t *pcm_conversion_buffer; +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + LC3PLUS_RTP_FTD *frame_type_descriptors; + int32_t num_ftds; + LC3PLUS_RTP_FDL fdl_request; +#endif +} * ISAR_LC3PLUS_ENC_HANDLE; + +ivas_error ISAR_LC3PLUS_ENC_Open( + const LC3PLUS_CONFIG config, /* i : encoder configuration */ +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + const uint32_t initialBitsPerSecond, /* i : initial target bit rate */ +#else + const uint32_t bitsPerSecond, /* i : bit rate */ +#endif + ISAR_LC3PLUS_ENC_HANDLE *handle /* o : LC3plus encoder handle */ +); + +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS +ivas_error IVAS_LC3PLUS_ENC_SetBitrate( + ISAR_LC3PLUS_ENC_HANDLE handle, /* o : LC3plus encoder handle */ + const uint32_t bitsPerSecond /* i : new target bit rate */ +); +#endif + +ivas_error ISAR_LC3PLUS_ENC_GetDelay( + ISAR_LC3PLUS_ENC_HANDLE handle, /* i : LC3plus encoder handle */ + int32_t *delayInSamples /* o : algorithmic delay of encoding and decoding in number of samples per channel */ +); + +ivas_error ISAR_LC3PLUS_ENC_GetOutputBitstreamSize( + ISAR_LC3PLUS_ENC_HANDLE handle, /* i : LC3plus encoder handle */ + int32_t *bsSize /* o : size of next bitstream frame in bytes */ +); + +void ISAR_LC3PLUS_ENC_Close( + ISAR_LC3PLUS_ENC_HANDLE *handle /* i/o: pointer to LC3plus encoder handle */ +); + +ivas_error ISAR_LC3PLUS_ENC_Encode( + ISAR_LC3PLUS_ENC_HANDLE handle, /* i : LC3plus encoder handle */ + float **pcm_in, /* i : pointer input samples */ +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + void *bitstream_out, /* o : pointer to bitstream frame */ + const int32_t bitstream_out_size /* i : size of the bitstream_out buffer in bytes. Must be equal to ISAR_LC3PLUS_ENC_GetOutputBitstreamSize. */ +#else + void *bitstream_out /* o : pointer to bitstream frame */ +#endif +); +#endif + +#endif /* ISAR_LC3PLUS_ENC_H */ diff --git a/lib_isar/isar_lc3plus_payload.c b/lib_isar/isar_lc3plus_payload.c new file mode 100644 index 0000000000000000000000000000000000000000..cd053978d1ca7a5ffdc914a853e4e829e6be592f --- /dev/null +++ b/lib_isar/isar_lc3plus_payload.c @@ -0,0 +1,823 @@ +/****************************************************************************************************** + + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#include +#include +#include +#include "isar_lc3plus_payload.h" +#include "options.h" + +#ifdef SPLIT_REND_WITH_HEAD_ROT +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS +static LC3PLUS_RTP_ERR s_frame_duration_ms_from_fdi( int32_t *frame_duration_us, const LC3PLUS_RTP_FTD_FDI fdi ) +{ + if ( NULL == frame_duration_us ) + { + return LC3PLUS_RTP_ERR_NULL_PTR; + } + switch ( fdi ) + { + case LC3PLUS_RTP_FTD_FDI_2500_US: + *frame_duration_us = 2500; + break; + case LC3PLUS_RTP_FTD_FDI_5000_US: + *frame_duration_us = 5000; + break; + case LC3PLUS_RTP_FTD_FDI_10000_US: + *frame_duration_us = 10000; + break; + case LC3PLUS_RTP_FTD_FDI_RESERVED: + default: + return LC3PLUS_RTP_ERR_INVALID_PARAMETERS; + } + return LC3PLUS_RTP_ERR_NO_ERROR; +} + +static LC3PLUS_RTP_ERR s_sampling_rate_hz_from_bwr( int32_t *sample_rate_hz, const LC3PLUS_RTP_FTD_BWR bwr ) +{ + if ( NULL == sample_rate_hz ) + { + return LC3PLUS_RTP_ERR_NULL_PTR; + } + switch ( bwr ) + { + case LC3PLUS_RTP_FTD_BWR_NB: + *sample_rate_hz = 8000; + break; + case LC3PLUS_RTP_FTD_BWR_WB: + *sample_rate_hz = 16000; + break; + case LC3PLUS_RTP_FTD_BWR_SSWB: + *sample_rate_hz = 24000; + break; + case LC3PLUS_RTP_FTD_BWR_SWB: + *sample_rate_hz = 32000; + break; + case LC3PLUS_RTP_FTD_BWR_FBCD: + *sample_rate_hz = 44100; + break; + case LC3PLUS_RTP_FTD_BWR_FB: + *sample_rate_hz = 48000; + break; + case LC3PLUS_RTP_FTD_BWR_FBHR: + *sample_rate_hz = 48000; + break; + case LC3PLUS_RTP_FTD_BWR_UBHR: + *sample_rate_hz = 96000; + break; + default: + return LC3PLUS_RTP_ERR_INVALID_PARAMETERS; + } + return LC3PLUS_RTP_ERR_NO_ERROR; +} + +static LC3PLUS_RTP_ERR s_high_resolution_flag_from_bwr( int16_t *high_resolution_flag, const LC3PLUS_RTP_FTD_BWR bwr ) +{ + if ( NULL == high_resolution_flag ) + { + return LC3PLUS_RTP_ERR_NULL_PTR; + } + switch ( bwr ) + { + case LC3PLUS_RTP_FTD_BWR_NB: + *high_resolution_flag = 0; + break; + case LC3PLUS_RTP_FTD_BWR_WB: + *high_resolution_flag = 0; + break; + case LC3PLUS_RTP_FTD_BWR_SSWB: + *high_resolution_flag = 0; + break; + case LC3PLUS_RTP_FTD_BWR_SWB: + *high_resolution_flag = 0; + break; + case LC3PLUS_RTP_FTD_BWR_FBCD: + *high_resolution_flag = 0; + break; + case LC3PLUS_RTP_FTD_BWR_FB: + *high_resolution_flag = 0; + break; + case LC3PLUS_RTP_FTD_BWR_FBHR: + *high_resolution_flag = 1; + break; + case LC3PLUS_RTP_FTD_BWR_UBHR: + *high_resolution_flag = 1; + break; + default: + return LC3PLUS_RTP_ERR_INVALID_PARAMETERS; + } + return LC3PLUS_RTP_ERR_NO_ERROR; +} + +LC3PLUS_RTP_ERR LC3PLUS_RTP_frame_data_length_get_size( int32_t *length, const LC3PLUS_RTP_FDL frameDataLengthValue ) +{ + if ( frameDataLengthValue == LC3PLUS_RTP_FDL_NO_REQ_OR_NO_DATA || frameDataLengthValue == LC3PLUS_RTP_FDL_SPEECH_BAD || frameDataLengthValue == LC3PLUS_RTP_FDL_SPEECH_SID ) + { + *length = 1; + } + else if ( frameDataLengthValue >= LC3PLUS_RTP_FDL_LENGTH_1_MIN && frameDataLengthValue <= LC3PLUS_RTP_FDL_LENGTH_1_MAX ) + { + *length = 1; + } + else if ( frameDataLengthValue >= LC3PLUS_RTP_FDL_LENGTH_2_MIN && frameDataLengthValue <= LC3PLUS_RTP_FDL_LENGTH_2_MAX ) + { + *length = 2; + } + else if ( frameDataLengthValue >= LC3PLUS_RTP_FDL_LENGTH_3_MIN && frameDataLengthValue <= LC3PLUS_RTP_FDL_LENGTH_3_MAX ) + { + *length = 3; + } + else + { + return LC3PLUS_RTP_ERR_INVALID_PARAMETERS; + } + return LC3PLUS_RTP_ERR_NO_ERROR; +} + +static LC3PLUS_RTP_ERR s_frame_data_length_pack( const LC3PLUS_RTP_FDL frameDataLengthValue, uint8_t *dst ) +{ + int32_t frame_data_length_size; + LC3PLUS_RTP_ERR err; + + if ( NULL == dst ) + { + return LC3PLUS_RTP_ERR_NULL_PTR; + } + + err = LC3PLUS_RTP_frame_data_length_get_size( &frame_data_length_size, frameDataLengthValue ); + if ( err != LC3PLUS_RTP_ERR_NO_ERROR ) + { + return err; + } + if ( 1 == frame_data_length_size ) + { + *dst++ = frameDataLengthValue >> 0 & LC3PLUS_RTP_FDL_EXTENSION_VALUE; + } + else if ( 2 == frame_data_length_size ) + { + const int32_t frameDataLengthValueToWrite = frameDataLengthValue - LC3PLUS_RTP_FDL_EXTENSION_VALUE; + *dst++ = LC3PLUS_RTP_FDL_EXTENSION_VALUE; + *dst = frameDataLengthValueToWrite >> 0 & LC3PLUS_RTP_FDL_EXTENSION_VALUE; + } + else if ( 3 == frame_data_length_size ) + { + const int32_t frameDataLengthValueToWrite = frameDataLengthValue - ( 2 * LC3PLUS_RTP_FDL_EXTENSION_VALUE ); + *dst++ = LC3PLUS_RTP_FDL_EXTENSION_VALUE; + *dst++ = LC3PLUS_RTP_FDL_EXTENSION_VALUE; + *dst = frameDataLengthValueToWrite >> 0 & LC3PLUS_RTP_FDL_EXTENSION_VALUE; + } + return LC3PLUS_RTP_ERR_NO_ERROR; +} + +static int32_t s_get_size_from_fdl( const LC3PLUS_RTP_FDL fdl ) +{ + if ( fdl >= LC3PLUS_RTP_FDL_LENGTH_1_MIN && fdl <= LC3PLUS_RTP_FDL_LENGTH_3_MAX ) + { + return fdl; + } + return 0; +} + +static bool s_fdl_is_magic_value( const LC3PLUS_RTP_FDL fdl ) +{ + if ( fdl == LC3PLUS_RTP_FDL_NO_REQ_OR_NO_DATA || fdl == LC3PLUS_RTP_FDL_SPEECH_SID || fdl == LC3PLUS_RTP_FDL_SPEECH_BAD ) + { + return true; + } + return false; +} + +static bool s_fdl_value_is_valid_request( const LC3PLUS_RTP_FDL fdl_request ) +{ + /* LC3PLUS_RTP_FDL_SPEECH_SID && LC3PLUS_RTP_FDL_SPEECH_SID are not valid values for the FDL request */ + if ( fdl_request == LC3PLUS_RTP_FDL_NO_REQ_OR_NO_DATA || ( fdl_request >= LC3PLUS_RTP_FDL_LENGTH_1_MIN && fdl_request <= LC3PLUS_RTP_FDL_LENGTH_3_MAX ) ) + { + return true; + } + return false; +} + +static LC3PLUS_RTP_ERR s_frame_data_length_parse( LC3PLUS_RTP_FDL *frame_data_length_value, const uint8_t *src, const size_t remaining_capacity ) +{ + int32_t frame_data_length_size; + LC3PLUS_RTP_ERR err; + if ( NULL == src || NULL == frame_data_length_value || remaining_capacity < 1 ) + { + return LC3PLUS_RTP_ERR_NULL_PTR; + } + + if ( remaining_capacity > 2 && LC3PLUS_RTP_FDL_EXTENSION_VALUE == *src && LC3PLUS_RTP_FDL_EXTENSION_VALUE == *( src + 1 ) ) + { + *frame_data_length_value = *( src + 2 ) + 2 * LC3PLUS_RTP_FDL_EXTENSION_VALUE; + } + else if ( remaining_capacity > 1 && LC3PLUS_RTP_FDL_EXTENSION_VALUE == *src ) + { + *frame_data_length_value = *( src + 1 ) + 1 * LC3PLUS_RTP_FDL_EXTENSION_VALUE; + } + else if ( remaining_capacity > 0 ) + { + *frame_data_length_value = *src << 0; + } + else + { + return LC3PLUS_RTP_ERR_INVALID_BITSTREAM_SIZE; + } + + /* sanity check */ + err = LC3PLUS_RTP_frame_data_length_get_size( &frame_data_length_size, *frame_data_length_value ); + if ( err != LC3PLUS_RTP_ERR_NO_ERROR ) + { + return err; + } + return LC3PLUS_RTP_ERR_NO_ERROR; +} + +static LC3PLUS_RTP_ERR s_parse_ftd( const uint8_t *p_read, LC3PLUS_RTP_FTD *receiver_ftd, int32_t *num_bytes_read, const size_t remaining_capacity ) +{ + int32_t frame_data_block_size; + LC3PLUS_RTP_FDL fdl; + LC3PLUS_RTP_ERR err; + if ( NULL == p_read || NULL == receiver_ftd || NULL == num_bytes_read || remaining_capacity < LC3PLUS_RTP_FTD_MIN_SIZE ) + { + return LC3PLUS_RTP_ERR_NULL_PTR; + } + + *num_bytes_read = 0; + receiver_ftd->fc = 0; + receiver_ftd->fdi = 0; + receiver_ftd->bwr = 0; + receiver_ftd->h = 0; + receiver_ftd->fc |= *p_read & LC3PLUS_RTP_FTD_FC_MASK; + receiver_ftd->fdi |= ( *p_read & LC3PLUS_RTP_FTD_FDI_MASK ); + receiver_ftd->bwr |= ( *p_read & LC3PLUS_RTP_FTD_BWR_MASK ); + receiver_ftd->h |= ( *p_read & LC3PLUS_RTP_FTD_H_MASK ); + p_read++; + *num_bytes_read = 1; + + err = s_frame_data_length_parse( &fdl, p_read, remaining_capacity - *num_bytes_read ); + if ( LC3PLUS_RTP_ERR_NO_ERROR != err ) + { + return err; + } + frame_data_block_size = s_get_size_from_fdl( fdl ); + + receiver_ftd->frame_data_length = frame_data_block_size; + int32_t length_field_size; + err = LC3PLUS_RTP_frame_data_length_get_size( &length_field_size, receiver_ftd->frame_data_length ); + if ( LC3PLUS_RTP_ERR_NO_ERROR != err ) + { + return err; + } + *num_bytes_read += length_field_size; + return LC3PLUS_RTP_ERR_NO_ERROR; +} + +LC3PLUS_RTP_ERR LC3PLUS_RTP_payload_serialize( + uint8_t *serialized_buffer, + const size_t serialized_buffer_capacity, + size_t *packed_buffer_actual_size, + const LC3PLUS_RTP_FDL fdl_request, + LC3PLUS_RTP_FTD *sender_ftds, + const size_t sender_ftds_num ) +{ + LC3PLUS_RTP_ERR err; + uint8_t *p_write = serialized_buffer; + uint32_t i; + int32_t bytes_written = 0; + int32_t lc3plus_frame_size_sum; + uint8_t *p_frame_data; + int32_t fdl_request_length; + + if ( NULL == serialized_buffer || NULL == packed_buffer_actual_size || NULL == sender_ftds ) + { + return LC3PLUS_RTP_ERR_NULL_PTR; + } + + *packed_buffer_actual_size = 0; + err = LC3PLUS_RTP_frame_data_length_get_size( &fdl_request_length, fdl_request ); + if ( LC3PLUS_RTP_ERR_NO_ERROR != err ) + { + return err; + } + if ( !s_fdl_value_is_valid_request( fdl_request ) ) + { + return LC3PLUS_RTP_ERR_INVALID_FDL_REQUEST; + } + if ( (int32_t) serialized_buffer_capacity < bytes_written + fdl_request_length ) + { + return LC3PLUS_RTP_ERR_INVALID_BITSTREAM_SIZE; + } + err = s_frame_data_length_pack( fdl_request, p_write ); + if ( LC3PLUS_RTP_ERR_NO_ERROR != err ) + { + return err; + } + bytes_written += fdl_request_length; + p_write += bytes_written; + + for ( i = 0; i < sender_ftds_num; ++i ) + { + /* only the last ftd may have the LC3PLUS_RTP_FTD_FC_LAST_OVERALL value */ + if ( sender_ftds[i].fc == LC3PLUS_RTP_FTD_FC_LAST_OVERALL && i != ( sender_ftds_num - 1 ) ) + { + return LC3PLUS_RTP_ERR_INVALID_PARAMETERS; + } + /* the last ftd must have the LC3PLUS_RTP_FTD_FC_LAST_OVERALL value */ + if ( sender_ftds[i].fc != LC3PLUS_RTP_FTD_FC_LAST_OVERALL && i == ( sender_ftds_num - 1 ) ) + { + return LC3PLUS_RTP_ERR_INVALID_PARAMETERS; + } + if ( (int32_t) serialized_buffer_capacity < bytes_written + LC3PLUS_RTP_FTD_LENGTH_EXCLUDING_FDL ) + { + return LC3PLUS_RTP_ERR_INVALID_BITSTREAM_SIZE; + } + *p_write = 0x00; + *p_write |= LC3PLUS_RTP_FTD_FC_MASK & (uint8_t) sender_ftds[i].fc; + *p_write |= LC3PLUS_RTP_FTD_FDI_MASK & (uint8_t) sender_ftds[i].fdi; + *p_write |= LC3PLUS_RTP_FTD_BWR_MASK & (uint8_t) sender_ftds[i].bwr; + *p_write |= LC3PLUS_RTP_FTD_H_MASK & (uint8_t) sender_ftds[i].h; + p_write++; + bytes_written += LC3PLUS_RTP_FTD_LENGTH_EXCLUDING_FDL; + + int32_t fdl_length; + err = LC3PLUS_RTP_frame_data_length_get_size( &fdl_length, sender_ftds[i].frame_data_length ); + if ( LC3PLUS_RTP_ERR_NO_ERROR != err ) + { + return err; + } + if ( (int32_t) serialized_buffer_capacity < bytes_written + fdl_length ) + { + return LC3PLUS_RTP_ERR_INVALID_BITSTREAM_SIZE; + } + err = s_frame_data_length_pack( sender_ftds[i].frame_data_length, p_write ); + if ( LC3PLUS_RTP_ERR_NO_ERROR != err ) + { + return err; + } + p_write += fdl_length; + bytes_written += fdl_length; + } + + lc3plus_frame_size_sum = 0; + p_frame_data = serialized_buffer + bytes_written; + for ( i = 0; i < sender_ftds_num; ++i ) + { + sender_ftds[i].frame_data = p_frame_data; + p_frame_data += sender_ftds[i].frame_data_length; + lc3plus_frame_size_sum += sender_ftds[i].frame_data_length; + } + *packed_buffer_actual_size = bytes_written + lc3plus_frame_size_sum; + assert( *packed_buffer_actual_size <= serialized_buffer_capacity ); + return LC3PLUS_RTP_ERR_NO_ERROR; +} + +static LC3PLUS_RTP_ERR s_ftds_parse( + LC3PLUS_RTP_FTD *receiver_ftds, + const int32_t receiver_ftds_num_max, + int16_t *receiver_ftds_num, + uint8_t *serialized_buffer, + const size_t serialized_buffer_size ) +{ + int32_t diff; + uint8_t *p_read; + uint32_t ftds_offset_sum = 0; + int16_t i; + LC3PLUS_RTP_ERR error; + int32_t frame_offset_counter; + int32_t size; + + p_read = serialized_buffer; + if ( NULL == receiver_ftds || NULL == receiver_ftds_num || NULL == serialized_buffer ) + { + return LC3PLUS_RTP_ERR_NULL_PTR; + } + if ( 0 == serialized_buffer_size ) + { + return LC3PLUS_RTP_ERR_EMPTY_TOC; + } + if ( receiver_ftds_num_max <= 0 ) + { + return LC3PLUS_RTP_ERR_INVALID_PARAMETERS; + } + { + int32_t num_bytes_read_sum = 0; + const int32_t min_num_bytes_per_ftd = 2; + int16_t receiver_ftds_index = 0; + bool another_ftd = true; + int32_t num_bytes_read_per_ftd; + + while ( another_ftd ) + { + if ( (int32_t) serialized_buffer_size < min_num_bytes_per_ftd ) + { + return LC3PLUS_RTP_ERR_INVALID_BITSTREAM_SIZE; + } + if ( num_bytes_read_sum >= (int32_t) serialized_buffer_size - min_num_bytes_per_ftd ) + { + return LC3PLUS_RTP_ERR_INVALID_BITSTREAM_SIZE; + } + num_bytes_read_per_ftd = 0; + error = s_parse_ftd( p_read, &receiver_ftds[receiver_ftds_index], &num_bytes_read_per_ftd, serialized_buffer_size - num_bytes_read_sum ); + if ( LC3PLUS_RTP_ERR_NO_ERROR != error ) + { + return error; + } + p_read += num_bytes_read_per_ftd; + num_bytes_read_sum += num_bytes_read_per_ftd; + + if ( receiver_ftds[receiver_ftds_index].fc == LC3PLUS_RTP_FTD_FC_RESERVED ) + { + return LC3PLUS_RTP_ERR_INVALID_BITSTREAM; + } + else if ( receiver_ftds[receiver_ftds_index].fc == LC3PLUS_RTP_FTD_FC_LAST_OVERALL ) + { + another_ftd = false; + } + + if ( another_ftd ) + { + if ( receiver_ftds_index >= receiver_ftds_num_max ) + { + return LC3PLUS_RTP_ERR_NOT_ENOUGH_FTDS_ALLOCATED; + } + ( receiver_ftds_index )++; + } + } + *receiver_ftds_num = receiver_ftds_index + 1; + } + + /* set frame-data pointers into serialized_buffer */ + for ( i = 0; i < *receiver_ftds_num; ++i ) + { + error = LC3PLUS_RTP_frame_data_length_get_size( &size, receiver_ftds[i].frame_data_length ); + if ( error != LC3PLUS_RTP_ERR_NO_ERROR ) + { + return error; + } + ftds_offset_sum += LC3PLUS_RTP_FTD_LENGTH_EXCLUDING_FDL + size; + } + + frame_offset_counter = 0; + for ( i = 0; i < *receiver_ftds_num; ++i ) + { + if ( s_fdl_is_magic_value( receiver_ftds[i].frame_data_length ) ) + { + receiver_ftds[i].frame_data = NULL; + } + else + { + receiver_ftds[i].frame_data = serialized_buffer + ftds_offset_sum + frame_offset_counter; + frame_offset_counter += receiver_ftds[i].frame_data_length; + } + } + + if ( ftds_offset_sum + frame_offset_counter != serialized_buffer_size ) + { + /* parsed content & size n bytes of input buffer do not line up */ + /* if the buffer capacity is larger and the remaining bytes are zero, we don't treat this as an error since it's due to the IVAS-Split rendering zero padding */ + diff = serialized_buffer_size - ( ftds_offset_sum + frame_offset_counter ); + if ( diff < 0 ) + { + return LC3PLUS_RTP_ERR_INVALID_BITSTREAM_SIZE; + } + /* verify that all bytes are zero */ + p_read += frame_offset_counter; + for ( i = 0; i < diff; ++i ) + { + if ( *p_read != 0 ) + { + /* non-zero byte in padding region */ + return LC3PLUS_RTP_ERR_NONZERO_PADDING_BYTES; + } + p_read++; + } + } + return LC3PLUS_RTP_ERR_NO_ERROR; +} + +LC3PLUS_RTP_ERR LC3PLUS_RTP_payload_deserialize( + LC3PLUS_RTP_PAYLOAD *payload, + uint8_t *serialized_buffer, + const size_t serialized_buffer_size ) +{ + int32_t new_frame_duration_us; + int32_t new_sampling_rate_hz; + int16_t new_high_resolution_flag; + int16_t i = 0; + int16_t channel_id = 0; + int16_t media_time_id = 0; + const int16_t invalid_value = -1; + int16_t media_times_per_channel[LC3PLUS_RTP_PAYLOAD_MAX_NUM_CHANNELS]; + int16_t channels_per_media_time[LC3PLUS_RTP_PAYLOAD_MAX_NUM_MEDIA_TIMES]; + LC3PLUS_RTP_ERR err; + + if ( NULL == payload || NULL == serialized_buffer ) + { + return LC3PLUS_RTP_ERR_NULL_PTR; + } + if ( 0 == serialized_buffer_size ) + { + return LC3PLUS_RTP_ERR_INVALID_PARAMETERS; + } + + for ( media_time_id = 0; media_time_id < LC3PLUS_RTP_PAYLOAD_MAX_NUM_MEDIA_TIMES; ++media_time_id ) + { + channels_per_media_time[media_time_id] = invalid_value; + } + media_time_id = 0; + for ( channel_id = 0; channel_id < LC3PLUS_RTP_PAYLOAD_MAX_NUM_CHANNELS; ++channel_id ) + { + media_times_per_channel[channel_id] = invalid_value; + } + channel_id = 0; + + err = s_frame_data_length_parse( &payload->fdl_request, serialized_buffer, serialized_buffer_size ); + if ( LC3PLUS_RTP_ERR_NO_ERROR != err ) + { + return err; + } + int32_t fdl_request_length; + err = LC3PLUS_RTP_frame_data_length_get_size( &fdl_request_length, payload->fdl_request ); + if ( LC3PLUS_RTP_ERR_NO_ERROR != err ) + { + return err; + } + if ( !s_fdl_value_is_valid_request( payload->fdl_request ) ) + { + return LC3PLUS_RTP_ERR_INVALID_FDL_REQUEST; + } + + err = s_ftds_parse( payload->ftds, sizeof( payload->ftds ) / sizeof( LC3PLUS_RTP_FTD ), &payload->num_ftds, serialized_buffer + fdl_request_length, serialized_buffer_size - fdl_request_length ); + if ( LC3PLUS_RTP_ERR_NO_ERROR != err ) + { + return err; + } + if ( 0 == payload->num_ftds ) + { + return LC3PLUS_RTP_ERR_GENERIC_ERROR; + } + /* verify shared setting between all FTDs [samplerate, frame_duration, channel count] */ + + /* initialize on the first FTD, use this as reference */ + err = s_frame_duration_ms_from_fdi( &payload->frame_duration_us, payload->ftds[0].fdi ); + if ( LC3PLUS_RTP_ERR_NO_ERROR != err ) + { + return err; + } + err = s_sampling_rate_hz_from_bwr( &payload->sampling_rate_hz, payload->ftds[0].bwr ); + if ( LC3PLUS_RTP_ERR_NO_ERROR != err ) + { + return err; + } + err = s_high_resolution_flag_from_bwr( &payload->high_resolution_enabled, payload->ftds[0].bwr ); + if ( LC3PLUS_RTP_ERR_NO_ERROR != err ) + { + return err; + } + payload->num_channels = 0; + payload->num_media_times = 0; + for ( i = 0; i < payload->num_ftds; ++i ) + { + if ( payload->ftds[i].h != LC3PLUS_RTP_FTD_H_PRIMARY ) + { + /* not implemented */ + return LC3PLUS_RTP_ERR_NOT_IMPLEMENTED; + } + + err = s_frame_duration_ms_from_fdi( &new_frame_duration_us, payload->ftds[i].fdi ); + if ( LC3PLUS_RTP_ERR_NO_ERROR != err ) + { + return err; + } + if ( payload->frame_duration_us != new_frame_duration_us ) + { + /* mixed frame durations not supported */ + return LC3PLUS_RTP_ERR_UNSUPPORTED_CONFIGURATION; + } + + err = s_sampling_rate_hz_from_bwr( &new_sampling_rate_hz, payload->ftds[i].bwr ); + if ( LC3PLUS_RTP_ERR_NO_ERROR != err ) + { + return err; + } + if ( payload->sampling_rate_hz != new_sampling_rate_hz ) + { + /* mixed sampling frequencies not supported */ + return LC3PLUS_RTP_ERR_UNSUPPORTED_CONFIGURATION; + } + + + err = s_high_resolution_flag_from_bwr( &new_high_resolution_flag, payload->ftds[i].bwr ); + if ( LC3PLUS_RTP_ERR_NO_ERROR != err ) + { + return err; + } + if ( payload->high_resolution_enabled != new_high_resolution_flag ) + { + /* mixed high resolution mode not supported */ + return LC3PLUS_RTP_ERR_UNSUPPORTED_CONFIGURATION; + } + + switch ( payload->ftds[i].fc ) + { + case LC3PLUS_RTP_FTD_FC_LAST_OVERALL: + channels_per_media_time[media_time_id]++; + media_times_per_channel[channel_id]++; + channel_id = 0; + media_time_id = 0; + break; + case LC3PLUS_RTP_FTD_FC_SUBSEQUENT_CHANNEL: + media_times_per_channel[channel_id]++; + channels_per_media_time[media_time_id]++; + channel_id++; + break; + case LC3PLUS_RTP_FTD_FC_LAST_IN_MEDIATIME: + media_times_per_channel[channel_id]++; + channels_per_media_time[media_time_id]++; + channel_id = 0; + media_time_id++; + break; + case LC3PLUS_RTP_FTD_FC_RESERVED: + default: + return LC3PLUS_RTP_ERR_INVALID_BITSTREAM; + } + } + + { + int32_t valid_num_media_times_per_channel; + int32_t iCh; + /* check whether all channels exist for each media time */ + if ( media_times_per_channel[0] == invalid_value ) + { + return LC3PLUS_RTP_ERR_NOT_IMPLEMENTED; + } + valid_num_media_times_per_channel = media_times_per_channel[0]; + for ( iCh = 0; iCh < LC3PLUS_RTP_PAYLOAD_MAX_NUM_CHANNELS; ++iCh ) + { + if ( media_times_per_channel[iCh] == invalid_value ) + { + break; + } + if ( valid_num_media_times_per_channel != media_times_per_channel[iCh] ) + { + return LC3PLUS_RTP_ERR_NOT_IMPLEMENTED; + } + } + } + { + /* whether all media times exist for each channel */ + int32_t iMediaTime; + int32_t valid_num_channels_per_media_time; + if ( channels_per_media_time[0] == invalid_value ) + { + return LC3PLUS_RTP_ERR_NOT_IMPLEMENTED; + } + valid_num_channels_per_media_time = channels_per_media_time[0]; + for ( iMediaTime = 0; iMediaTime < LC3PLUS_RTP_PAYLOAD_MAX_NUM_MEDIA_TIMES; ++iMediaTime ) + { + if ( channels_per_media_time[iMediaTime] == invalid_value ) + { + break; + } + if ( valid_num_channels_per_media_time != channels_per_media_time[iMediaTime] ) + { + return LC3PLUS_RTP_ERR_NOT_IMPLEMENTED; + } + } + } + + /* convert zero-index to count */ + payload->num_channels = channels_per_media_time[0] + 1; + payload->num_media_times = media_times_per_channel[0] + 1; + + /* verify that all media times have the same number of channels, partial packets are not supported */ + if ( payload->num_ftds != payload->num_channels * payload->num_media_times ) + { + return LC3PLUS_RTP_ERR_GENERIC_ERROR; + } + return LC3PLUS_RTP_ERR_NO_ERROR; +} + +LC3PLUS_RTP_ERR LC3PLUS_RTP_ftd_bwr_from_samplerate( LC3PLUS_RTP_FTD_BWR *bwr, const int32_t sampling_rate, const int32_t high_res_enabled ) +{ + if ( NULL == bwr ) + { + return LC3PLUS_RTP_ERR_NULL_PTR; + } + switch ( sampling_rate ) + { + case 8000: + if ( high_res_enabled ) + { + return LC3PLUS_RTP_ERR_INVALID_PARAMETERS; + } + *bwr = LC3PLUS_RTP_FTD_BWR_NB; + return LC3PLUS_RTP_ERR_NO_ERROR; + case 16000: + if ( high_res_enabled ) + { + return LC3PLUS_RTP_ERR_INVALID_PARAMETERS; + } + *bwr = LC3PLUS_RTP_FTD_BWR_WB; + return LC3PLUS_RTP_ERR_NO_ERROR; + case 24000: + if ( high_res_enabled ) + { + return LC3PLUS_RTP_ERR_INVALID_PARAMETERS; + } + *bwr = LC3PLUS_RTP_FTD_BWR_SSWB; + return LC3PLUS_RTP_ERR_NO_ERROR; + case 32000: + if ( high_res_enabled ) + { + return LC3PLUS_RTP_ERR_INVALID_PARAMETERS; + } + *bwr = LC3PLUS_RTP_FTD_BWR_SWB; + return LC3PLUS_RTP_ERR_NO_ERROR; + case 44100: + if ( high_res_enabled ) + { + return LC3PLUS_RTP_ERR_INVALID_PARAMETERS; + } + *bwr = LC3PLUS_RTP_FTD_BWR_FBCD; + return LC3PLUS_RTP_ERR_NO_ERROR; + case 48000: + if ( 0 == high_res_enabled ) + { + *bwr = LC3PLUS_RTP_FTD_BWR_FB; + return LC3PLUS_RTP_ERR_NO_ERROR; + } + else + { + *bwr = LC3PLUS_RTP_FTD_BWR_FBHR; + return LC3PLUS_RTP_ERR_NO_ERROR; + } + case 96000: + if ( 0 == high_res_enabled ) + { + return LC3PLUS_RTP_ERR_INVALID_PARAMETERS; + } + *bwr = LC3PLUS_RTP_FTD_BWR_UBHR; + return LC3PLUS_RTP_ERR_NO_ERROR; + default: + break; + } + + return LC3PLUS_RTP_ERR_INVALID_PARAMETERS; +} + +LC3PLUS_RTP_ERR LC3PLUS_RTP_ftd_fdi_from_frame_duration_us( LC3PLUS_RTP_FTD_FDI *fdi, const int32_t frame_duration_us ) +{ + if ( NULL == fdi ) + { + return LC3PLUS_RTP_ERR_NULL_PTR; + } + switch ( frame_duration_us ) + { + case 2500: + *fdi = LC3PLUS_RTP_FTD_FDI_2500_US; + return LC3PLUS_RTP_ERR_NO_ERROR; + case 5000: + *fdi = LC3PLUS_RTP_FTD_FDI_5000_US; + return LC3PLUS_RTP_ERR_NO_ERROR; + case 10000: + *fdi = LC3PLUS_RTP_FTD_FDI_10000_US; + return LC3PLUS_RTP_ERR_NO_ERROR; + default: + break; + } + + return LC3PLUS_RTP_ERR_INVALID_PARAMETERS; +} + +#endif /* ISAR_BITSTREAM_UPDATE_LC3PLUS */ +#endif /* SPLIT_REND_WITH_HEAD_ROT */ diff --git a/lib_isar/isar_lc3plus_payload.h b/lib_isar/isar_lc3plus_payload.h new file mode 100644 index 0000000000000000000000000000000000000000..c225c91591685f0f55f9d906d9719cb89a9fd136 --- /dev/null +++ b/lib_isar/isar_lc3plus_payload.h @@ -0,0 +1,216 @@ +/****************************************************************************************************** + + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#ifndef ISAR_LC3PLUS_PAYLOAD_H +#define ISAR_LC3PLUS_PAYLOAD_H + +#include +#include +#include "lc3.h" +#include "options.h" + +#ifdef SPLIT_REND_WITH_HEAD_ROT +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + +/* Implementation of the "B.2.6 Table of contents" part of the RTP payload format + * for LC3plus as specified in ETSI TS 103 634. */ + +typedef enum LC3PLUS_RTP_ERR +{ + LC3PLUS_RTP_ERR_NO_ERROR, + LC3PLUS_RTP_ERR_NULL_PTR, + LC3PLUS_RTP_ERR_INVALID_PARAMETERS, + LC3PLUS_RTP_ERR_EMPTY_TOC, + LC3PLUS_RTP_ERR_NOT_IMPLEMENTED, + LC3PLUS_RTP_ERR_UNSUPPORTED_CONFIGURATION, + LC3PLUS_RTP_ERR_INVALID_BITSTREAM, + LC3PLUS_RTP_ERR_INVALID_BITSTREAM_SIZE, + LC3PLUS_RTP_ERR_NOT_ENOUGH_FTDS_ALLOCATED, + LC3PLUS_RTP_ERR_INVALID_FDL_REQUEST, + LC3PLUS_RTP_ERR_NONZERO_PADDING_BYTES, + LC3PLUS_RTP_ERR_GENERIC_ERROR +} LC3PLUS_RTP_ERR; + +/* + * The content of the FTD is shown in Figure B.6. + * 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 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * |FC |FDI| BWR |H| FDL1 | (FDL2) | (FDL3) | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + */ + +/* FC (2 bits): + * Frame and Channel (FC) indicator for subsequent frame data (if available). The meaning of the FC + * indicator is shown in Table B.2. The FC value defines the media time stamp (in integer increments + * of TSI) and the channel counter (CC, starting from 1 for the first channel) for the subsequent + * FTD (if available). */ +typedef enum LC3PLUS_RTP_FTD_FC +{ + LC3PLUS_RTP_FTD_FC_LAST_OVERALL = 0x00, /* Last FDL in ToC, no FDL follows the current FDL */ + LC3PLUS_RTP_FTD_FC_SUBSEQUENT_CHANNEL = 0x01, /* The next FDL is for the next channel for the same media time */ + LC3PLUS_RTP_FTD_FC_LAST_IN_MEDIATIME = 0x02, /* The next FDL is for first channel for next media time, channel counter is reset */ + LC3PLUS_RTP_FTD_FC_RESERVED = 0x03, /* Reserved */ +} LC3PLUS_RTP_FTD_FC; +#define LC3PLUS_RTP_FTD_FC_MASK 0x03 + +/* FDI (2 bits): + * Frame Duration Index, with encoding as shown in Table B.3. The FDI shall be static for a given + * payload type during the session. The FDI also dictates the TSI, needed for deriving the media + * time in case of more than one frame in the payload. */ +typedef enum LC3PLUS_RTP_FTD_FDI +{ + LC3PLUS_RTP_FTD_FDI_2500_US = 0x00, + LC3PLUS_RTP_FTD_FDI_5000_US = 0x04, + LC3PLUS_RTP_FTD_FDI_10000_US = 0x08, + LC3PLUS_RTP_FTD_FDI_RESERVED = 0x0C, +} LC3PLUS_RTP_FTD_FDI; +#define LC3PLUS_RTP_FTD_FDI_MASK 0x0C +LC3PLUS_RTP_ERR LC3PLUS_RTP_ftd_fdi_from_frame_duration_us( LC3PLUS_RTP_FTD_FDI *fdi, const int32_t frame_duration_us ); + +/* BWR (3 bits): + * Bandwidth and resolution combination used by the codec is jointly encoded into a bandwidth and + * resolution (BWR) index. The BWR index is encoded as shown in Table B.4. The BWR encoding is + * defined in Table B.4. The BWR index shall be static for a given payload type during the session. */ +typedef enum LC3PLUS_RTP_FTD_BWR +{ + LC3PLUS_RTP_FTD_BWR_NB = 0x00, + LC3PLUS_RTP_FTD_BWR_WB = 0x10, + LC3PLUS_RTP_FTD_BWR_SSWB = 0x20, + LC3PLUS_RTP_FTD_BWR_SWB = 0x30, + LC3PLUS_RTP_FTD_BWR_FBCD = 0x40, + LC3PLUS_RTP_FTD_BWR_FB = 0x50, + LC3PLUS_RTP_FTD_BWR_FBHR = 0x60, + LC3PLUS_RTP_FTD_BWR_UBHR = 0x70, +} LC3PLUS_RTP_FTD_BWR; +#define LC3PLUS_RTP_FTD_BWR_MASK 0x70 +LC3PLUS_RTP_ERR LC3PLUS_RTP_ftd_bwr_from_samplerate( LC3PLUS_RTP_FTD_BWR *bwr, const int32_t sampling_rate, const int32_t high_res_enabled ); + +/* H (1 bit): + * Indicates whether the corresponding frame is a normal frame (primary encoding) or a helper frame + * (secondary encoding). 0 indicates a primary frame, 1 indicates secondary (redundant) frame */ +typedef enum LC3PLUS_RTP_FTD_H +{ + LC3PLUS_RTP_FTD_H_PRIMARY = 0x00, + LC3PLUS_RTP_FTD_H_SECONDARY = 0x80, +} LC3PLUS_RTP_FTD_H; +#define LC3PLUS_RTP_FTD_H_MASK 0x80 + +typedef enum LC3PLUS_RTP_FDL +{ + LC3PLUS_RTP_FDL_NO_REQ_OR_NO_DATA = 0, + LC3PLUS_RTP_FDL_SPEECH_BAD = 1, + LC3PLUS_RTP_FDL_SPEECH_SID = 2, + LC3PLUS_RTP_FDL_RESERVED_MIN = 3, + LC3PLUS_RTP_FDL_RESERVED_MAX = 19, + LC3PLUS_RTP_FDL_LENGTH_1_MIN = 20, + LC3PLUS_RTP_FDL_LENGTH_1_MAX = 254, + LC3PLUS_RTP_FDL_LENGTH_2_MIN = 255, + LC3PLUS_RTP_FDL_LENGTH_2_MAX = 509, + LC3PLUS_RTP_FDL_LENGTH_3_MIN = 510, + LC3PLUS_RTP_FDL_LENGTH_3_MAX = 765 +} LC3PLUS_RTP_FDL; +/* value used to indicate that the Frame Data Length (FDL) extends to the next byte */ +#define LC3PLUS_RTP_FDL_EXTENSION_VALUE 0xFF + +typedef struct LC3PLUS_RTP_FTD +{ + LC3PLUS_RTP_FTD_FC fc; + LC3PLUS_RTP_FTD_FDI fdi; + LC3PLUS_RTP_FTD_BWR bwr; + LC3PLUS_RTP_FTD_H h; + uint8_t *frame_data; + LC3PLUS_RTP_FDL frame_data_length; +} LC3PLUS_RTP_FTD; +#define LC3PLUS_RTP_FTD_LENGTH_EXCLUDING_FDL 1 +#define LC3PLUS_RTP_FDL_MIN_LENGTH 1 +#define LC3PLUS_RTP_FTD_MIN_SIZE ( LC3PLUS_RTP_FTD_LENGTH_EXCLUDING_FDL + LC3PLUS_RTP_FDL_MIN_LENGTH ) + +/*! Serialize the sender_ftds structs and fdl_request into a linear compact buffer + * @param[out] serialized_buffer pointer to the start of the memory location where the serialized buffer will be written to + * @param[in] serialized_buffer_capacity capacity of the serialized_buffer in bytes + * @param[out] packed_buffer_actual_size actually used size of in bytes of the packed_buffer (<=serialized_buffer_capacity) + * @param[in] fdl_request frame data length request + * @param[in,out] sender_ftds the function will overwrite the frame_data pointer with the correct memory location in + * the packed_buffer (so it can subsequently be used as input for the LC3plus encode call) + * @param[in] sender_ftds_num number of sender_ftds + * @return LC3PLUS_RTP_ERR_NO_ERROR in case of success */ +LC3PLUS_RTP_ERR LC3PLUS_RTP_payload_serialize( + uint8_t *serialized_buffer, + const size_t serialized_buffer_capacity, + size_t *packed_buffer_actual_size, + const LC3PLUS_RTP_FDL fdl_request, + LC3PLUS_RTP_FTD *sender_ftds, + const size_t sender_ftds_num ); + +/*! Get size of the frame data length field for a certain frame data length value in bytes. + * @param[out] length size of the frame data length field in bytes [1,2,3] + * @param[in] frameDataLengthValue frame data length value + * @return LC3PLUS_RTP_ERR_NO_ERROR in case of success */ +LC3PLUS_RTP_ERR LC3PLUS_RTP_frame_data_length_get_size( int32_t *length, const LC3PLUS_RTP_FDL frameDataLengthValue ); + +#define LC3PLUS_RTP_PAYLOAD_MAX_NUM_CHANNELS 16 +#define LC3PLUS_RTP_PAYLOAD_MAX_NUM_MEDIA_TIMES 8 /* max ivas frame duration/min lc3plus frame duration: 20000/2500 */ +#define LC3PLUS_RTP_PAYLOAD_MAX_NUM_FTDS LC3PLUS_RTP_PAYLOAD_MAX_NUM_CHANNELS *LC3PLUS_RTP_PAYLOAD_MAX_NUM_MEDIA_TIMES + +typedef struct LC3PLUS_RTP_PAYLOAD_CONFIG +{ + /* frame duration in us shared among all FTDs */ + int32_t frame_duration_us; + /* high resolution flag shared among all FTDs */ + int16_t high_resolution_enabled; + /* sampling frequency shared among all FTDs */ + int32_t sampling_rate_hz; + /* number of individual channels in the payload */ + int16_t num_channels; + /* number of individual media times in the payload */ + int16_t num_media_times; + /* frame data length request */ + LC3PLUS_RTP_FDL fdl_request; + /* FTD data with pointer to raw frame data */ + LC3PLUS_RTP_FTD ftds[LC3PLUS_RTP_PAYLOAD_MAX_NUM_FTDS]; + /* actual number of ftds */ + int16_t num_ftds; +} LC3PLUS_RTP_PAYLOAD; + +/*! Deserialized a serialized buffer into a LC3PLUS_RTP_PAYLOAD struct + * @param payload pointer to target LC3PLUS_RTP_PAYLOAD object. Note: frame_data pointers in the struct will point to the respective memory locations in the serialized_buffer. + * @param serialized_buffer pointer to the start of the serialized input buffer + * @param serialized_buffer_size size of the serialized input buffer in bytes + * @return LC3PLUS_RTP_ERR_NO_ERROR in case of success */ +LC3PLUS_RTP_ERR LC3PLUS_RTP_payload_deserialize( + LC3PLUS_RTP_PAYLOAD *payload, + uint8_t *serialized_buffer, + const size_t serialized_buffer_size ); + +#endif /* ISAR_BITSTREAM_UPDATE_LC3PLUS */ +#endif /* #ifdef SPLIT_REND_WITH_HEAD_ROT */ +#endif /* ISAR_LC3PLUS_PAYLOAD_H */ diff --git a/lib_isar/isar_lcld_decoder.c b/lib_isar/isar_lcld_decoder.c new file mode 100644 index 0000000000000000000000000000000000000000..e15155331c50eb8a83fb807053bd9b9afff6c60e --- /dev/null +++ b/lib_isar/isar_lcld_decoder.c @@ -0,0 +1,1711 @@ +/****************************************************************************************************** + + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#include +#include "options.h" +#ifdef SPLIT_REND_WITH_HEAD_ROT +#include "isar_lcld_prot.h" +#include "isar_rom_lcld_tables.h" +#include "prot.h" +#include +#include "isar_prot.h" +#include "wmc_auto.h" + + +/*------------------------------------------------------------------------------------------* + * Local constants + *------------------------------------------------------------------------------------------*/ + +#define HUFF_READ_SIZE ( 4 ) + +/*------------------------------------------------------------------------------------------* + * Local structures + *------------------------------------------------------------------------------------------*/ + +typedef struct TableNode +{ + struct TableNode **ppoNextTable; + struct TableNode *poOrderedNext; + + int32_t *piCodeIndex; + int32_t *piDifference; + int32_t *piLength; +} TableNode; +typedef struct TableList +{ + TableNode *poOrderedTop; + TableNode *poOrderedBottom; + +} TableList; + +struct LCLD_DECODER +{ + int32_t iSampleRate; + int32_t iChannels; + int32_t iNumBlocks; + + int32_t iNumBands; + const int32_t *piBandwidths; + + int32_t iMSMode; + int32_t *piMSFlags; + TableList *ptable_list; + uint32_t ( *c_apauiHuffDecTable_RAM[2 * ALLOC_TABLE_SIZE] )[HUFF_DEC_TABLE_SIZE]; + uint32_t num_decode_table[2 * ALLOC_TABLE_SIZE]; + int32_t piMSPredCoefs[MAX_BANDS]; + int32_t piLRPhaseDiffs[MAX_BANDS]; + int32_t iCommonGrouping; + int32_t *piNumGroups; + int32_t **ppiGroupLengths; + + int32_t ***pppiRMSEnvelope; + int32_t ***pppiSMR; + int32_t ***pppiExcitation; + int32_t ***pppiAlloc; + + int32_t iAllocOffset; + int32_t iRealOnlyOut; + + int32_t ***pppiLCLDSignReal; + int32_t ***pppiLCLDSignImag; + int32_t ***pppiQLCLDReal; + int32_t ***pppiQLCLDImag; + + PredictionDecoder *psPredictionDecoder; + + + NoiseGen *psNoiseGen; +}; + +static void CreateDecodeTable( LCLDDecoder *psLCLDDecoder, const int32_t num, const uint16_t ( *ppuiEncTable )[2], const int32_t iSize, const int32_t iReadLength, uint32_t *iTables ); +static TableNode *CreateTableList( const int32_t iReadLength ); +static void DeleteTableList( TableList *ptable_list, int32_t iTables ); +static TableNode *GetNextTable( const int32_t iIndex, TableList *table_list, TableNode *poParent, const int32_t iReadLength, uint32_t *iTablesCreated ); +static void AddcodeTableList( TableList *ptable_list, const int32_t iLength, const int32_t iCode, const int32_t iCodeIndex, const int32_t iReadLength, uint32_t *iTables ); +static void CompleteTables( LCLDDecoder *psLCLDDecoder, const int32_t n, TableList *ptable_list, const int32_t iReadLength, const int32_t iTablesCreated ); + +static TableNode *CreateTableList( const int32_t iReadLength ) +{ + int32_t n; + int32_t iMaxTables; + TableNode *ptable_top; + iMaxTables = 1 << iReadLength; + ptable_top = (TableNode *) malloc( sizeof( TableNode ) ); + ptable_top->ppoNextTable = + (TableNode **) malloc( iMaxTables * sizeof( TableNode * ) ); + ptable_top->piCodeIndex = (int32_t *) malloc( iMaxTables * sizeof( int32_t ) ); + ptable_top->piDifference = (int32_t *) malloc( iMaxTables * sizeof( int32_t ) ); + ptable_top->piLength = (int32_t *) malloc( iMaxTables * sizeof( int32_t ) ); + for ( n = 0; n < iMaxTables; n++ ) + { + ptable_top->ppoNextTable[n] = NULL; + ptable_top->piCodeIndex[n] = 0xffff; + ptable_top->piDifference[n] = 0; + ptable_top->piLength[n] = 0; + } + + return ptable_top; +} +static void DeleteTableList( TableList *ptable_list, int32_t iTables ) +{ + + TableNode *node; + node = ptable_list->poOrderedTop; + + while ( ( iTables ) ) + { + + TableNode *node1 = node; + node = node1->poOrderedNext; + if ( node1->piCodeIndex != NULL ) + { + free( node1->piCodeIndex ); + } + if ( node1->piLength != NULL ) + { + free( node1->piLength ); + } + if ( node1->piDifference != NULL ) + { + free( node1->piDifference ); + } + if ( node1->ppoNextTable != NULL ) + { + free( node1->ppoNextTable ); + } + if ( node1 != NULL ) + { + free( node1 ); + } + iTables--; + } + if ( ptable_list != NULL ) + { + free( ptable_list ); + } +} +static TableNode *GetNextTable( const int32_t iIndex, TableList *table_list, TableNode *poParent, const int32_t iReadLength, uint32_t *iTablesCreated ) +{ + TableNode *poNextNode; + + if ( poParent->ppoNextTable[iIndex] == NULL ) + { + poNextNode = CreateTableList( iReadLength ); + poParent->ppoNextTable[iIndex] = poNextNode; + poParent->piDifference[iIndex] = *iTablesCreated; /* this is a link to the next table rather than the difference */ + table_list->poOrderedBottom->poOrderedNext = poNextNode; + table_list->poOrderedBottom = poNextNode; + + ( *iTablesCreated )++; + } + else + { + poNextNode = poParent->ppoNextTable[iIndex]; + } + + return poNextNode; +} +static void CompleteTables( LCLDDecoder *psLCLDDecoder, const int32_t n, TableList *ptable_list, const int32_t iReadLength, const int32_t iTablesCreated ) +{ + + int32_t iMaxTables; + int32_t j; + TableNode *poNode; + + iMaxTables = 1 << iReadLength; + psLCLDDecoder->c_apauiHuffDecTable_RAM[n] = + malloc( iTablesCreated * iMaxTables * sizeof( uint32_t ) ); + + poNode = ptable_list->poOrderedTop; + for ( j = 0; j < iTablesCreated; j++ ) + { + int32_t k; + if ( poNode != NULL ) + { + for ( k = 0; k < iMaxTables; k++ ) + { + uint32_t uiCode; + uiCode = poNode->piDifference[k]; + uiCode <<= 16; + uiCode |= poNode->piCodeIndex[k]; + psLCLDDecoder->c_apauiHuffDecTable_RAM[n][j][k] = uiCode; + } + } + poNode = poNode->poOrderedNext; + } +} +static void AddcodeTableList( TableList *ptable_list, const int32_t iLength, const int32_t iCode, const int32_t iCodeIndex, const int32_t iReadLength, uint32_t *iTables ) +{ + int32_t iDifference; + int32_t iMask; + int32_t iCurrentLength; + int32_t iIndex; + int32_t iCodeLow; + int32_t iCodeHigh; + + TableNode *poNode; + poNode = ptable_list->poOrderedTop; + iMask = ( 1 << iReadLength ) - 1; + iCurrentLength = iLength; + while ( iCurrentLength > iReadLength ) + { + iDifference = iCurrentLength - iReadLength; + iIndex = iCode >> iDifference; + iIndex &= iMask; + poNode = GetNextTable( iIndex, ptable_list, poNode, iReadLength, iTables ); + iCurrentLength -= iReadLength; + } + + iMask = ( 1 << iCurrentLength ) - 1; + iDifference = iReadLength - iCurrentLength; + iCodeLow = ( iCode & iMask ) << iDifference; + iMask = ( 1 << iDifference ) - 1; + iCodeHigh = iCodeLow | iMask; + for ( iIndex = iCodeLow; iIndex <= iCodeHigh; iIndex++ ) + { + poNode->piCodeIndex[iIndex] = iCodeIndex; + poNode->piDifference[iIndex] = iDifference; + poNode->piLength[iIndex] = iLength; + } +} + +static void CreateDecodeTable( LCLDDecoder *psLCLDDecoder, const int32_t num, const uint16_t ( *ppuiEncTable )[2], const int32_t iSize, const int32_t iReadLength, uint32_t *iTables ) +{ + int32_t n; + uint32_t **ppsort_enc_table; + TableList *ptable_list; + ptable_list = (TableList *) malloc( sizeof( TableList ) ); + + ppsort_enc_table = (uint32_t **) malloc( iSize * sizeof( int32_t * ) ); + for ( n = 0; n < iSize; n++ ) + { + + ppsort_enc_table[n] = (uint32_t *) malloc( 3 * sizeof( int32_t ) ); + ppsort_enc_table[n][0] = (uint32_t) ppuiEncTable[n][0]; + ppsort_enc_table[n][1] = (uint32_t) ppuiEncTable[n][1]; + ppsort_enc_table[n][2] = (uint32_t) n; + } + + for ( n = 0; n < iSize; n++ ) + { + uint32_t iMin; + int32_t iMinIndex; + int32_t k; + + iMin = ppsort_enc_table[n][0]; + iMinIndex = n; + for ( k = n; k < iSize; k++ ) + { + if ( ppsort_enc_table[k][0] < iMin ) + { + iMin = ppsort_enc_table[k][0]; + iMinIndex = k; + } + } + + if ( iMinIndex != n ) + { + uint32_t uiLength; + uint32_t uiCode; + uint32_t uiCodeIndex; + + uiLength = ppsort_enc_table[n][0]; + uiCode = ppsort_enc_table[n][1]; + uiCodeIndex = ppsort_enc_table[n][2]; + + ppsort_enc_table[n][0] = ppsort_enc_table[iMinIndex][0]; + ppsort_enc_table[n][1] = ppsort_enc_table[iMinIndex][1]; + ppsort_enc_table[n][2] = ppsort_enc_table[iMinIndex][2]; + + ppsort_enc_table[iMinIndex][0] = uiLength; + ppsort_enc_table[iMinIndex][1] = uiCode; + ppsort_enc_table[iMinIndex][2] = uiCodeIndex; + } + } + ptable_list->poOrderedTop = CreateTableList( iReadLength ); + ptable_list->poOrderedBottom = ptable_list->poOrderedTop; + for ( n = 0; n < iSize; n++ ) + { + int32_t iLength; + int32_t iCode; + int32_t iCodeIndex; + + iLength = ppsort_enc_table[n][0]; + iCode = ppsort_enc_table[n][1]; + iCodeIndex = ppsort_enc_table[n][2]; + AddcodeTableList( ptable_list, iLength, iCode, iCodeIndex, iReadLength, + iTables ); + } + + CompleteTables( psLCLDDecoder, num, ptable_list, iReadLength, *iTables ); + DeleteTableList( ptable_list, *iTables ); + for ( n = 0; n < iSize; n++ ) + { + free( ppsort_enc_table[n] ); + } + free( ppsort_enc_table ); +} + + +/*------------------------------------------------------------------------------------------* + * Function CreateLCLDDecoder() + * + * + *------------------------------------------------------------------------------------------*/ + +ivas_error CreateLCLDDecoder( + LCLDDecoder **psLCLDDecoder_out, + const int32_t iSampleRate, + const int32_t iChannels, + const int32_t iNumBlocks, + const int32_t iRealOnlyOut ) +{ + int32_t n; + int32_t read_length; + ivas_error error; + LCLDDecoder *psLCLDDecoder = NULL; + + assert( iSampleRate == 48000 ); + assert( iNumBlocks == 16 || iNumBlocks == 8 || iNumBlocks == 4 ); + if ( ( psLCLDDecoder = (LCLDDecoder *) malloc( sizeof( LCLDDecoder ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + psLCLDDecoder->iSampleRate = iSampleRate; + psLCLDDecoder->iChannels = iChannels; + psLCLDDecoder->iAllocOffset = 0; + psLCLDDecoder->iRealOnlyOut = iRealOnlyOut; + if ( iRealOnlyOut == 1 ) + { + psLCLDDecoder->iNumBlocks = iNumBlocks / 2; + } + else + { + psLCLDDecoder->iNumBlocks = iNumBlocks; + } + psLCLDDecoder->iNumBands = 0; /* read from bitstream*/ + psLCLDDecoder->piBandwidths = c_aiBandwidths48; + + psLCLDDecoder->iMSMode = 0; + if ( ( psLCLDDecoder->piMSFlags = (int32_t *) malloc( MAX_BANDS * sizeof( int32_t ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + for ( n = 0; n < MAX_BANDS; n++ ) + { + psLCLDDecoder->piLRPhaseDiffs[n] = 0; + psLCLDDecoder->piMSPredCoefs[n] = 0; + } + + psLCLDDecoder->iCommonGrouping = 1; /* Common grouping always on only impacts stereo */ + if ( ( psLCLDDecoder->piNumGroups = (int32_t *) malloc( psLCLDDecoder->iChannels * sizeof( int32_t ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + if ( ( psLCLDDecoder->ppiGroupLengths = (int32_t **) malloc( psLCLDDecoder->iChannels * sizeof( int32_t * ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + if ( ( psLCLDDecoder->pppiRMSEnvelope = (int32_t ***) malloc( psLCLDDecoder->iChannels * sizeof( int32_t ** ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + if ( ( psLCLDDecoder->pppiSMR = (int32_t ***) malloc( psLCLDDecoder->iChannels * sizeof( int32_t ** ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + if ( ( psLCLDDecoder->pppiExcitation = (int32_t ***) malloc( psLCLDDecoder->iChannels * sizeof( int32_t ** ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + if ( ( psLCLDDecoder->pppiAlloc = (int32_t ***) malloc( psLCLDDecoder->iChannels * sizeof( int32_t ** ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + + if ( ( psLCLDDecoder->pppiLCLDSignReal = (int32_t ***) malloc( psLCLDDecoder->iChannels * sizeof( int32_t ** ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + if ( ( psLCLDDecoder->pppiLCLDSignImag = (int32_t ***) malloc( psLCLDDecoder->iChannels * sizeof( int32_t ** ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + if ( ( psLCLDDecoder->pppiQLCLDReal = (int32_t ***) malloc( psLCLDDecoder->iChannels * sizeof( int32_t ** ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + if ( ( psLCLDDecoder->pppiQLCLDImag = (int32_t ***) malloc( psLCLDDecoder->iChannels * sizeof( int32_t ** ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + + for ( n = 0; n < iChannels; n++ ) + { + int16_t k; + if ( ( psLCLDDecoder->ppiGroupLengths[n] = (int32_t *) malloc( LCLD_BLOCKS_PER_FRAME * sizeof( int32_t ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + if ( ( psLCLDDecoder->pppiRMSEnvelope[n] = (int32_t **) malloc( LCLD_BLOCKS_PER_FRAME * sizeof( int32_t * ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + if ( ( psLCLDDecoder->pppiSMR[n] = (int32_t **) malloc( LCLD_BLOCKS_PER_FRAME * sizeof( int32_t * ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + if ( ( psLCLDDecoder->pppiExcitation[n] = (int32_t **) malloc( LCLD_BLOCKS_PER_FRAME * sizeof( int32_t * ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + if ( ( psLCLDDecoder->pppiAlloc[n] = (int32_t **) malloc( LCLD_BLOCKS_PER_FRAME * sizeof( int32_t * ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + + if ( ( psLCLDDecoder->pppiLCLDSignReal[n] = (int32_t **) malloc( LCLD_BLOCKS_PER_FRAME * sizeof( int32_t * ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + if ( ( psLCLDDecoder->pppiLCLDSignImag[n] = (int32_t **) malloc( LCLD_BLOCKS_PER_FRAME * sizeof( int32_t * ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + if ( ( psLCLDDecoder->pppiQLCLDReal[n] = (int32_t **) malloc( LCLD_BLOCKS_PER_FRAME * sizeof( int32_t * ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + if ( ( psLCLDDecoder->pppiQLCLDImag[n] = (int32_t **) malloc( LCLD_BLOCKS_PER_FRAME * sizeof( int32_t * ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + + for ( k = 0; k < LCLD_BLOCKS_PER_FRAME; k++ ) + { + if ( ( psLCLDDecoder->pppiRMSEnvelope[n][k] = (int32_t *) malloc( MAX_BANDS * sizeof( int32_t ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + if ( ( psLCLDDecoder->pppiSMR[n][k] = (int32_t *) malloc( MAX_BANDS * sizeof( int32_t ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + if ( ( psLCLDDecoder->pppiExcitation[n][k] = (int32_t *) malloc( MAX_BANDS * sizeof( int32_t ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + if ( ( psLCLDDecoder->pppiAlloc[n][k] = (int32_t *) malloc( MAX_BANDS * sizeof( int32_t ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + + if ( ( psLCLDDecoder->pppiLCLDSignReal[n][k] = (int32_t *) malloc( LCLD_BANDS * sizeof( int32_t ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + if ( ( psLCLDDecoder->pppiLCLDSignImag[n][k] = (int32_t *) malloc( LCLD_BANDS * sizeof( int32_t ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + if ( ( psLCLDDecoder->pppiQLCLDReal[n][k] = (int32_t *) malloc( LCLD_BANDS * sizeof( int32_t ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + if ( ( psLCLDDecoder->pppiQLCLDImag[n][k] = (int32_t *) malloc( LCLD_BANDS * sizeof( int32_t ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + } + } + + read_length = READ_LENGTH; + for ( n = 0; n < ALLOC_TABLE_SIZE * 2; n++ ) + { + psLCLDDecoder->num_decode_table[n] = 1; + if ( c_apauiHuffEncTabels[n] != NULL ) + { + + CreateDecodeTable( psLCLDDecoder, n, c_apauiHuffEncTabels[n], num_row_aauiLCLDHuff[n], read_length, &psLCLDDecoder->num_decode_table[n] ); + } + else + { + psLCLDDecoder->c_apauiHuffDecTable_RAM[n] = NULL; + } + } + + if ( ( error = CreatePredictionDecoder( &psLCLDDecoder->psPredictionDecoder, iChannels, psLCLDDecoder->iNumBlocks ) ) != IVAS_ERR_OK ) + { + return error; + } + psLCLDDecoder->psNoiseGen = NULL; /* CreateNoiseGen(); No noise fill for now*/ + *psLCLDDecoder_out = psLCLDDecoder; + + return IVAS_ERR_OK; +} + + +/*------------------------------------------------------------------------------------------* + * Function CreateLCLDDecoder() + * + * + *------------------------------------------------------------------------------------------*/ + +void DeleteLCLDDecoder( LCLDDecoder *psLCLDDecoder ) +{ + int32_t k, n; + + if ( psLCLDDecoder != NULL ) + { + if ( psLCLDDecoder->piMSFlags != NULL ) + { + free( psLCLDDecoder->piMSFlags ); + } + + if ( psLCLDDecoder->piNumGroups != NULL ) + { + free( psLCLDDecoder->piNumGroups ); + } + + if ( psLCLDDecoder->ppiGroupLengths != NULL ) + { + for ( n = 0; n < psLCLDDecoder->iChannels; n++ ) + { + free( psLCLDDecoder->ppiGroupLengths[n] ); + } + free( psLCLDDecoder->ppiGroupLengths ); + } + + if ( psLCLDDecoder->pppiRMSEnvelope != NULL ) + { + for ( n = 0; n < psLCLDDecoder->iChannels; n++ ) + { + for ( k = 0; k < LCLD_BLOCKS_PER_FRAME; k++ ) + { + free( psLCLDDecoder->pppiRMSEnvelope[n][k] ); + } + free( psLCLDDecoder->pppiRMSEnvelope[n] ); + } + free( psLCLDDecoder->pppiRMSEnvelope ); + } + + if ( psLCLDDecoder->pppiSMR != NULL ) + { + for ( n = 0; n < psLCLDDecoder->iChannels; n++ ) + { + for ( k = 0; k < LCLD_BLOCKS_PER_FRAME; k++ ) + { + free( psLCLDDecoder->pppiSMR[n][k] ); + } + free( psLCLDDecoder->pppiSMR[n] ); + } + free( psLCLDDecoder->pppiSMR ); + } + + if ( psLCLDDecoder->pppiExcitation != NULL ) + { + for ( n = 0; n < psLCLDDecoder->iChannels; n++ ) + { + for ( k = 0; k < LCLD_BLOCKS_PER_FRAME; k++ ) + { + free( psLCLDDecoder->pppiExcitation[n][k] ); + } + free( psLCLDDecoder->pppiExcitation[n] ); + } + free( psLCLDDecoder->pppiExcitation ); + } + + + if ( psLCLDDecoder->pppiAlloc != NULL ) + { + for ( n = 0; n < psLCLDDecoder->iChannels; n++ ) + { + for ( k = 0; k < LCLD_BLOCKS_PER_FRAME; k++ ) + { + free( psLCLDDecoder->pppiAlloc[n][k] ); + } + free( psLCLDDecoder->pppiAlloc[n] ); + } + free( psLCLDDecoder->pppiAlloc ); + } + + if ( psLCLDDecoder->pppiLCLDSignReal != NULL ) + { + for ( n = 0; n < psLCLDDecoder->iChannels; n++ ) + { + for ( k = 0; k < LCLD_BLOCKS_PER_FRAME; k++ ) + { + free( psLCLDDecoder->pppiLCLDSignReal[n][k] ); + } + free( psLCLDDecoder->pppiLCLDSignReal[n] ); + } + free( psLCLDDecoder->pppiLCLDSignReal ); + } + + if ( psLCLDDecoder->pppiLCLDSignImag != NULL ) + { + for ( n = 0; n < psLCLDDecoder->iChannels; n++ ) + { + for ( k = 0; k < LCLD_BLOCKS_PER_FRAME; k++ ) + { + free( psLCLDDecoder->pppiLCLDSignImag[n][k] ); + } + free( psLCLDDecoder->pppiLCLDSignImag[n] ); + } + free( psLCLDDecoder->pppiLCLDSignImag ); + } + + if ( psLCLDDecoder->pppiQLCLDReal != NULL ) + { + for ( n = 0; n < psLCLDDecoder->iChannels; n++ ) + { + for ( k = 0; k < LCLD_BLOCKS_PER_FRAME; k++ ) + { + free( psLCLDDecoder->pppiQLCLDReal[n][k] ); + } + free( psLCLDDecoder->pppiQLCLDReal[n] ); + } + free( psLCLDDecoder->pppiQLCLDReal ); + } + + if ( psLCLDDecoder->pppiQLCLDImag != NULL ) + { + for ( n = 0; n < psLCLDDecoder->iChannels; n++ ) + { + for ( k = 0; k < LCLD_BLOCKS_PER_FRAME; k++ ) + { + free( psLCLDDecoder->pppiQLCLDImag[n][k] ); + } + free( psLCLDDecoder->pppiQLCLDImag[n] ); + } + free( psLCLDDecoder->pppiQLCLDImag ); + } + + for ( n = 0; n < ALLOC_TABLE_SIZE * 2; n++ ) + { + if ( psLCLDDecoder->num_decode_table[n] > 1 ) + { + + if ( psLCLDDecoder->c_apauiHuffDecTable_RAM[n] != NULL ) + { + free( psLCLDDecoder->c_apauiHuffDecTable_RAM[n] ); + } + } + } + + if ( psLCLDDecoder->psPredictionDecoder != NULL ) + { + DeletePredictionDecoder( psLCLDDecoder->psPredictionDecoder ); + psLCLDDecoder->psPredictionDecoder = NULL; + } + + if ( psLCLDDecoder->psNoiseGen != NULL ) + { + DeleteNoiseGen( psLCLDDecoder->psNoiseGen ); + } + + free( psLCLDDecoder ); + } +} + +/*------------------------------------------------------------------------------------------* + * Local function declarations + * + * + *------------------------------------------------------------------------------------------*/ + +static void ApplyRMSEnvelope( const int32_t iNumBands, const int32_t *piBandwidths, const int32_t iNumGroups, const int32_t *piGroupLengths, int32_t **ppiRMSEnvelope, float **ppfReal, float **ppfImag ); + +static void ReplaceSign( const int32_t iNumBlocks, const int32_t iNumLCLDBands, int32_t **ppiSignReal, int32_t **ppiSignImag, float **ppfReal, float **ppfImag, const int32_t *piBandwidths ); + +static void InvQuantizeSpectrum( const int32_t iNumGroups, const int32_t *piGroupLengths, const int32_t iNumBands, const int32_t *piBandwidths, int32_t **ppiAlloc, int32_t **ppiQReal, int32_t **ppiQImag, float **ppfReal, float **ppfImag, NoiseGen *psNoiseGen ); + +static void InvMSCoding( const int32_t iNumBlocks, const int32_t iNumBands, const int32_t *piBandwidths, const int32_t iMSMode, const int32_t *piMSFlags, const int32_t *piLRPhaseDiffs, const int32_t *piMSPredCoefs, float ***pppfReal, float ***pppfImag ); + +static int32_t ReadHeaderInformation( int32_t *piNumBands, ISAR_SPLIT_REND_BITS_HANDLE pBits ); + +static int32_t ReadMSInformation( const int32_t iNumBands, int32_t *piMSMode, int32_t *piMSFlags, int32_t *piLRPhaseDiffs, int32_t *piMSPredCoefs, ISAR_SPLIT_REND_BITS_HANDLE pBits ); + +static int32_t ReadGroupInformation( const int32_t iChannels, const int32_t iNumBlocks, int32_t *piCommonGrouping, int32_t *piNumGroups, int32_t **ppiGroupLengths, ISAR_SPLIT_REND_BITS_HANDLE pBits ); + +static int32_t ReadHuff( const uint32_t ( *pauiHuffDecTable )[HUFF_DEC_TABLE_SIZE], int32_t *piSymbol, ISAR_SPLIT_REND_BITS_HANDLE pBits ); + +static int32_t ReadRMSEnvelope( const int32_t iChannels, const int32_t *piNumGroups, const int32_t iNumBands, int32_t ***pppiRMSEnvelope, ISAR_SPLIT_REND_BITS_HANDLE pBits ); + +static int32_t ReadAllocInformation( int32_t *piAllocOffset, ISAR_SPLIT_REND_BITS_HANDLE pBits ); +static int32_t +ReadLCLDData( const int32_t *piNumGroups, int32_t **ppiGroupLengths, const int32_t iNumBands, const int32_t iNumChannels, int32_t **ppiDecodingUnresolved, int32_t **ppiPredEnable, const int32_t iNumSubSets, const int32_t iSubSetId, int32_t ***pppiAlloc, int32_t ***pppiSignReal, int32_t ***pppiSignImag, int32_t ***pppiQReal, int32_t ***pppiQImag, int32_t **ppiDecodingFailed, ISAR_SPLIT_REND_BITS_HANDLE pBits, uint32_t ( *c_apauiHuffDecTables[2 * ALLOC_TABLE_SIZE] )[HUFF_DEC_TABLE_SIZE] ); +static void ComputeAllocation( const int32_t iChannels, const int32_t *piNumGroups, const int32_t iNumBands, int32_t ***pppiSMR, const int32_t iAllocOffset, int32_t ***pppiAlloc ); + +void SetDecodingUnresolved( LCLDDecoder *psLCLDDecoder ) +{ + int32_t n, ch; + PredictionDecoder *psPredictionDecoder = psLCLDDecoder->psPredictionDecoder; + for ( ch = 0; ch < psPredictionDecoder->iChannels; ch++ ) + { + for ( n = 0; n < psPredictionDecoder->iNumSubSets; n++ ) + { + psPredictionDecoder->ppiDecodingUnresolved[ch][n] = 1; + psPredictionDecoder->ppiDecodingFailed[ch][n] = 1; + psPredictionDecoder->ppiDecodingFailedPrev[ch][n] = 1; + } + } +} + +int32_t AnyDecodingFailedPrev( LCLDDecoder *psLCLDDecoder ) +{ + int32_t n, ch; + PredictionDecoder *psPredictionDecoder = psLCLDDecoder->psPredictionDecoder; + for ( ch = 0; ch < psPredictionDecoder->iChannels; ch++ ) + { + for ( n = 0; n < psPredictionDecoder->iNumSubSets; n++ ) + { + if ( psPredictionDecoder->ppiDecodingFailedPrev[ch][n] == 1 ) + { + return 1; + } + } + } + return 0; +} + +int32_t AnyDecodingFailed( LCLDDecoder *psLCLDDecoder ) +{ + int32_t n, ch; + PredictionDecoder *psPredictionDecoder = psLCLDDecoder->psPredictionDecoder; + for ( ch = 0; ch < psPredictionDecoder->iChannels; ch++ ) + { + for ( n = 0; n < psPredictionDecoder->iNumSubSets; n++ ) + { + if ( psPredictionDecoder->ppiDecodingFailed[ch][n] == 1 ) + { + return 1; + } + } + } + return 0; +} + +int32_t **GetDecodingFailedStatus( LCLDDecoder *psLCLDDecoder ) +{ + return psLCLDDecoder->psPredictionDecoder->ppiDecodingFailed; +} + +int16_t GetNumSubSets( LCLDDecoder *psLCLDDecoder ) +{ + return (int16_t) psLCLDDecoder->psPredictionDecoder->iNumSubSets; +} + +int32_t **GetDecodingFailedPrevStatus( LCLDDecoder *psLCLDDecoder ) +{ + return psLCLDDecoder->psPredictionDecoder->ppiDecodingFailedPrev; +} + +static void UnpackReal( + const int32_t iChannels, + const int32_t iNumBlocks, + float ***pppfReal, + float ***pppfImag ) +{ + int32_t ch, b, n; + for ( ch = 0; ch < iChannels; ch++ ) + { + for ( b = 0; b < LCLD_BANDS; b++ ) + { + int32_t iRealBlock = iNumBlocks - 1; + for ( n = iNumBlocks / 2 - 1; n >= 0; n-- ) + { + pppfReal[ch][iRealBlock][b] = pppfImag[ch][n][b] * 2.0f; + pppfReal[ch][iRealBlock - 1][b] = pppfReal[ch][n][b] * 2.0f; + pppfImag[ch][iRealBlock][b] = 0.0f; + pppfImag[ch][iRealBlock - 1][b] = 0.0f; + iRealBlock -= 2; + } + } + } +} + +/*------------------------------------------------------------------------------------------* + * Function DecodeLCLDFrame() + * + * + *------------------------------------------------------------------------------------------*/ + +int32_t DecodeLCLDFrame( + LCLDDecoder *psLCLDDecoder, + ISAR_SPLIT_REND_BITS_HANDLE pBits, + float ***pppfLCLDReal, + float ***pppfLCLDImag ) +{ + int32_t k, n; + + ReadHeaderInformation( &psLCLDDecoder->iNumBands, pBits ); + + if ( psLCLDDecoder->iChannels == 2 ) + { + ReadMSInformation( psLCLDDecoder->iNumBands, &psLCLDDecoder->iMSMode, psLCLDDecoder->piMSFlags, psLCLDDecoder->piLRPhaseDiffs, psLCLDDecoder->piMSPredCoefs, pBits ); + } + + ReadPredictors( psLCLDDecoder->psPredictionDecoder, pBits ); + UpdateDecodingUnresolved( psLCLDDecoder->psPredictionDecoder ); + UpdateDecodingFailedStatus( psLCLDDecoder->psPredictionDecoder ); + + ReadGroupInformation( psLCLDDecoder->iChannels, psLCLDDecoder->iNumBlocks, &psLCLDDecoder->iCommonGrouping, psLCLDDecoder->piNumGroups, psLCLDDecoder->ppiGroupLengths, pBits ); + + ReadRMSEnvelope( psLCLDDecoder->iChannels, (const int32_t *) psLCLDDecoder->piNumGroups, psLCLDDecoder->iNumBands, psLCLDDecoder->pppiRMSEnvelope, pBits ); + + + ReadAllocInformation( &psLCLDDecoder->iAllocOffset, pBits ); + + if ( psLCLDDecoder->iChannels == 2 && psLCLDDecoder->iCommonGrouping == 1 ) + { /* MS Mode? */ + for ( k = 0; k < psLCLDDecoder->piNumGroups[0]; k++ ) + { + PerceptualModelStereo( psLCLDDecoder->iNumBands, psLCLDDecoder->piMSFlags, + psLCLDDecoder->pppiRMSEnvelope[0][k], + psLCLDDecoder->pppiRMSEnvelope[1][k], + psLCLDDecoder->pppiExcitation[0][k], + psLCLDDecoder->pppiExcitation[1][k], + psLCLDDecoder->pppiSMR[0][k], + psLCLDDecoder->pppiSMR[1][k] ); + } + } + else + { + for ( n = 0; n < psLCLDDecoder->iChannels; n++ ) + { /* This will be updated to support multiple sample rates*/ + for ( k = 0; k < psLCLDDecoder->piNumGroups[n]; k++ ) + { + PerceptualModel( psLCLDDecoder->iNumBands, psLCLDDecoder->pppiRMSEnvelope[n][k], psLCLDDecoder->pppiExcitation[n][k], psLCLDDecoder->pppiSMR[n][k] ); + } + } + } + + ComputeAllocation( psLCLDDecoder->iChannels, (const int32_t *) psLCLDDecoder->piNumGroups, psLCLDDecoder->iNumBands, psLCLDDecoder->pppiSMR, psLCLDDecoder->iAllocOffset, psLCLDDecoder->pppiAlloc ); + + ReadLCLDData( + psLCLDDecoder->piNumGroups, + psLCLDDecoder->ppiGroupLengths, + psLCLDDecoder->iNumBands, + psLCLDDecoder->iChannels, + psLCLDDecoder->psPredictionDecoder->ppiDecodingUnresolved, + psLCLDDecoder->psPredictionDecoder->ppiPredBandEnable, + psLCLDDecoder->psPredictionDecoder->iNumSubSets, + psLCLDDecoder->psPredictionDecoder->iSubSetId, + psLCLDDecoder->pppiAlloc, + psLCLDDecoder->pppiLCLDSignReal, + psLCLDDecoder->pppiLCLDSignImag, + psLCLDDecoder->pppiQLCLDReal, + psLCLDDecoder->pppiQLCLDImag, + psLCLDDecoder->psPredictionDecoder->ppiDecodingFailed, + pBits, + psLCLDDecoder->c_apauiHuffDecTable_RAM ); + + for ( n = 0; n < psLCLDDecoder->iChannels; n++ ) + { + InvQuantizeSpectrum( psLCLDDecoder->piNumGroups[n], + (const int32_t *) psLCLDDecoder->ppiGroupLengths[n], + psLCLDDecoder->iNumBands, psLCLDDecoder->piBandwidths, + psLCLDDecoder->pppiAlloc[n], + psLCLDDecoder->pppiQLCLDReal[n], + psLCLDDecoder->pppiQLCLDImag[n], + pppfLCLDReal[n], pppfLCLDImag[n], + psLCLDDecoder->psNoiseGen ); + + ReplaceSign( psLCLDDecoder->iNumBlocks, psLCLDDecoder->iNumBands, + psLCLDDecoder->pppiLCLDSignReal[n], + psLCLDDecoder->pppiLCLDSignImag[n], + pppfLCLDReal[n], pppfLCLDImag[n], psLCLDDecoder->piBandwidths ); + } +#ifdef DEBUG_WRITE_PREDICTORS + { + static FILE *fid; + if ( !fid ) + fid = fopen( "pred_dec.txt", "wt" ); + for ( n = 0; n < psLCLDDecoder->iChannels; n++ ) + { + int16_t b; + for ( b = 0; b < 60; b++ ) + fprintf( fid, "%.5f ", (float) psLCLDDecoder->psPredictionDecoder->ppiPredBandEnable[n][b] * psLCLDDecoder->psPredictionDecoder->ppfA1Imag[n][b] ); + } + fprintf( fid, "%d %d\n", psLCLDDecoder->psPredictionDecoder->iSubSetId, psLCLDDecoder->psPredictionDecoder->piPredChanEnable[n] ); + } +#endif + + ApplyInversePredictors( psLCLDDecoder->psPredictionDecoder, pppfLCLDReal, pppfLCLDImag ); + + for ( n = 0; n < psLCLDDecoder->iChannels; n++ ) + { + ApplyRMSEnvelope( psLCLDDecoder->iNumBands, psLCLDDecoder->piBandwidths, + psLCLDDecoder->piNumGroups[n], + (const int32_t *) psLCLDDecoder->ppiGroupLengths[n], + psLCLDDecoder->pppiRMSEnvelope[n], + pppfLCLDReal[n], pppfLCLDImag[n] ); + } + + if ( psLCLDDecoder->iChannels == 2 && psLCLDDecoder->iMSMode > 0 ) + { + InvMSCoding( psLCLDDecoder->iNumBlocks, psLCLDDecoder->iNumBands, + psLCLDDecoder->piBandwidths, psLCLDDecoder->iMSMode, + (const int32_t *) psLCLDDecoder->piMSFlags, + (const int32_t *) psLCLDDecoder->piLRPhaseDiffs, + (const int32_t *) psLCLDDecoder->piMSPredCoefs, + pppfLCLDReal, pppfLCLDImag ); + } + + if ( psLCLDDecoder->iRealOnlyOut == 1 ) + { + UnpackReal( psLCLDDecoder->iChannels, + psLCLDDecoder->iNumBlocks * 2, + pppfLCLDReal, + pppfLCLDImag ); + } + + return AnyDecodingUnresolved( psLCLDDecoder->psPredictionDecoder ); +} + + +/*------------------------------------------------------------------------------------------* + * Local functions + * + * + *------------------------------------------------------------------------------------------*/ + +static void ApplyRMSEnvelope( + const int32_t iNumBands, + const int32_t *piBandwidths, + const int32_t iNumGroups, + const int32_t *piGroupLengths, + int32_t **ppiRMSEnvelope, + float **ppfReal, + float **ppfImag ) +{ + int32_t b, k, n; + int32_t iBlockOffset, iFBOffset; + + iBlockOffset = 0; + for ( n = 0; n < iNumGroups; n++ ) + { + for ( k = 0; k < piGroupLengths[n]; k++ ) + { + iFBOffset = 0; + for ( b = 0; b < iNumBands; b++ ) + { + int32_t m; + int32_t iRMSEnv; + float fGain; + + iRMSEnv = ppiRMSEnvelope[n][b]; + fGain = + c_afRMSEnvReconstructTable[ENV_RECONSTRUCT_TABLE_CENTER + iRMSEnv]; + for ( m = 0; m < piBandwidths[b]; m++ ) + { + ppfReal[iBlockOffset][iFBOffset] *= fGain; + ppfImag[iBlockOffset][iFBOffset] *= fGain; + iFBOffset++; + } + } + iBlockOffset++; + } + } + + return; +} + +static void ReplaceSign( + const int32_t iNumBlocks, + const int32_t iNumLCLDBands, + int32_t **ppiSignReal, + int32_t **ppiSignImag, + float **ppfReal, + float **ppfImag, + const int32_t *piBandwidths ) +{ + int32_t b, n; + int32_t m, idx; + + for ( n = 0; n < iNumBlocks; n++ ) + { + idx = 0; + for ( b = 0; b < iNumLCLDBands; b++ ) + { + for ( m = 0; m < piBandwidths[b]; m++ ) + { + if ( ppiSignReal[n][idx] == 1 ) + { + ppfReal[n][idx] = -ppfReal[n][idx]; + } + + if ( ppiSignImag[n][idx] == 1 ) + { + ppfImag[n][idx] = -ppfImag[n][idx]; + } + idx++; + } + } + } + + return; +} + + +static void InvQuantizeSpectrum( + const int32_t iNumGroups, + const int32_t *piGroupLengths, + const int32_t iNumBands, + const int32_t *piBandwidths, + int32_t **ppiAlloc, + int32_t **ppiQReal, + int32_t **ppiQImag, + float **ppfReal, + float **ppfImag, + NoiseGen *psNoiseGen /* Pass in NULL to switch off noise gen */ +) +{ + int32_t b, k, n; + int32_t iBlockOffest, iFBOffset; + + iBlockOffest = 0; + for ( n = 0; n < iNumGroups; n++ ) + { + for ( k = 0; k < piGroupLengths[n]; k++ ) + { + iFBOffset = 0; + for ( b = 0; b < iNumBands; b++ ) + { + int32_t m; + int32_t iAlloc; + float fInvSCFGain; + + iAlloc = ppiAlloc[n][b]; + fInvSCFGain = c_afInvScaleFactor[iAlloc]; + + if ( iAlloc > 0 ) + { + for ( m = 0; m < piBandwidths[b]; m++ ) + { + int32_t iQuantValue; + + iQuantValue = ppiQReal[iBlockOffest][iFBOffset]; + ppfReal[iBlockOffest][iFBOffset] = (float) iQuantValue * fInvSCFGain; + + iQuantValue = ppiQImag[iBlockOffest][iFBOffset]; + ppfImag[iBlockOffest][iFBOffset] = (float) iQuantValue * fInvSCFGain; + + iFBOffset++; + } + } + else if ( psNoiseGen != NULL ) + { + for ( m = 0; m < piBandwidths[b]; m++ ) + { + ppfReal[iBlockOffest][iFBOffset] = 0.7f * GetNoise( psNoiseGen ); + ppfImag[iBlockOffest][iFBOffset] = 0.7f * GetNoise( psNoiseGen ); + + iFBOffset++; + } + } + else + { + iFBOffset += piBandwidths[b]; + } + } + + iBlockOffest++; + } + } + + return; +} + + +static void InvMSCoding( + const int32_t iNumBlocks, + const int32_t iNumBands, + const int32_t *piBandwidths, + const int32_t iMSMode, + const int32_t *piMSFlags, + const int32_t *piLRPhaseDiffs, + const int32_t *piMSPredCoefs, + float ***pppfReal, + float ***pppfImag ) +{ + if ( iMSMode > 0 ) + { + int32_t b; + int32_t iFBOffset; + int32_t bMSPred = 0; + + iFBOffset = 0; + for ( b = 0; b < iNumBands; b++ ) + { + if ( piMSFlags[b] == 1 ) + { + int32_t n; + int32_t phaseIdx; + float fPred; + phaseIdx = piLRPhaseDiffs[bMSPred] - PHASE_MIN_VAL; + fPred = dequantPred( piMSPredCoefs[bMSPred] ); + for ( n = 0; n < piBandwidths[b]; n++ ) + { + int32_t k; + for ( k = 0; k < iNumBlocks; k++ ) + { + float fLeftReal; + float fLeftImag; + float fRightReal; + float fRightImag; + + if ( iMSMode == 3 ) + { + pppfReal[1][k][iFBOffset] += fPred * pppfReal[0][k][iFBOffset]; + pppfImag[1][k][iFBOffset] += fPred * pppfImag[0][k][iFBOffset]; + } + + fLeftReal = ( pppfReal[0][k][iFBOffset] + pppfReal[1][k][iFBOffset] ); + fLeftImag = ( pppfImag[0][k][iFBOffset] + pppfImag[1][k][iFBOffset] ); + fRightReal = ( pppfReal[0][k][iFBOffset] - pppfReal[1][k][iFBOffset] ); + fRightImag = ( pppfImag[0][k][iFBOffset] - pppfImag[1][k][iFBOffset] ); + + if ( iMSMode == 3 ) + { + cplxmult_lcld( &fRightReal, &fRightImag, c_afRotRealImag[phaseIdx][0], -c_afRotRealImag[phaseIdx][1] ); + } + + pppfReal[0][k][iFBOffset] = fLeftReal; + pppfReal[1][k][iFBOffset] = fRightReal; + pppfImag[0][k][iFBOffset] = fLeftImag; + pppfImag[1][k][iFBOffset] = fRightImag; + } + iFBOffset++; + } + bMSPred++; + } + else + { + iFBOffset += piBandwidths[b]; + } + } + } + + return; +} + + +/* Currently only the number of bands in frame */ +static int32_t ReadHeaderInformation( + int32_t *piNumBands, + ISAR_SPLIT_REND_BITS_HANDLE pBits ) +{ + int32_t iBitsRead; + + iBitsRead = 0; + *piNumBands = ISAR_SPLIT_REND_BITStream_read_int32( pBits, 5 ); + iBitsRead += 5; + + return iBitsRead; +} + + +static int32_t ReadMSInformation( + const int32_t iNumBands, + int32_t *piMSMode, + int32_t *piMSFlags, + int32_t *piLRPhaseDiffs, + int32_t *piMSPredCoefs, + ISAR_SPLIT_REND_BITS_HANDLE pBits ) +{ + int32_t iBitsRead; + + iBitsRead = 0; + *piMSMode = ISAR_SPLIT_REND_BITStream_read_int32( pBits, 2 ); + iBitsRead += 2; + + if ( *piMSMode == 0 ) + { + int32_t n; + for ( n = 0; n < iNumBands; n++ ) + { + piMSFlags[n] = 0; + } + } + else if ( *piMSMode == 1 ) + { + int32_t n; + for ( n = 0; n < iNumBands; n++ ) + { + piMSFlags[n] = 1; + } + } + else if ( *piMSMode == 2 ) + { + int32_t n; + for ( n = 0; n < iNumBands; n++ ) + { + piMSFlags[n] = ISAR_SPLIT_REND_BITStream_read_int32( pBits, 1 ); + iBitsRead += 1; + } + } + else if ( *piMSMode == 3 ) + { + int32_t n; + int32_t iMSPredAll; + int32_t iNumMSPredBands = 0; + int32_t anyNonZero; + iMSPredAll = ISAR_SPLIT_REND_BITStream_read_int32( pBits, 1 ); + iBitsRead += 1; + if ( iMSPredAll ) + { + iNumMSPredBands = iNumBands; + for ( n = 0; n < iNumBands; n++ ) + { + piMSFlags[n] = 1; + } + } + else + { + for ( n = 0; n < iNumBands; n++ ) + { + piMSFlags[n] = ISAR_SPLIT_REND_BITStream_read_int32( pBits, 1 ); + iBitsRead += 1; + if ( piMSFlags[n] ) + { + iNumMSPredBands++; + } + } + } + anyNonZero = ISAR_SPLIT_REND_BITStream_read_int32( pBits, 1 ); + if ( anyNonZero ) + { + piLRPhaseDiffs[0] = ISAR_SPLIT_REND_BITStream_read_int32( pBits, PHASE_BAND0_BITS ); + piLRPhaseDiffs[0] += PHASE_MIN_VAL; + iBitsRead += PHASE_BAND0_BITS; + for ( n = 1; n < iNumMSPredBands; n++ ) + { + int32_t tabIdx; + iBitsRead += ReadHuff( c_aaiRMSEnvHuffDec, &tabIdx, pBits ); + piLRPhaseDiffs[n] = tabIdx + ENV_DELTA_MIN; + } + DecodePhase( piLRPhaseDiffs, iNumMSPredBands, PHASE_DIFF_DIM ); + } + else + { + for ( n = 0; n < iNumMSPredBands; n++ ) + { + piLRPhaseDiffs[n] = 0; + } + } + anyNonZero = ISAR_SPLIT_REND_BITStream_read_int32( pBits, 1 ); + if ( anyNonZero ) + { + piMSPredCoefs[0] = ISAR_SPLIT_REND_BITStream_read_int32( pBits, PRED_BAND0_BITS ); + piMSPredCoefs[0] += PRED_MIN_VAL; + iBitsRead += PRED_BAND0_BITS; + for ( n = 1; n < iNumMSPredBands; n++ ) + { + int32_t tabIdx; + iBitsRead += ReadHuff( c_aaiRMSEnvHuffDec, &tabIdx, pBits ); + piMSPredCoefs[n] = tabIdx + ENV_DELTA_MIN; + } + DecodePredCoef( piMSPredCoefs, iNumMSPredBands ); + } + else + { + for ( n = 0; n < iNumMSPredBands; n++ ) + { + piMSPredCoefs[n] = 0; + } + } +#ifdef DEBUG_WRITE_MS_PRED + { + static FILE *fid; + if ( !fid ) + fid = fopen( "ms_pred_dec.txt", "wt" ); + writeMSPred( piLRPhaseDiffs, piMSPredCoefs, *piMSMode, iNumMSPredBands, iNumBands, fid, piMSFlags ); + } +#endif + } + else + { + printf( "ERROR UNSUPPORTED MS MODE\n" ); + } + + return iBitsRead; +} + +static int32_t ReadGroupInformation( + const int32_t iChannels, + const int32_t iNumBlocks, + int32_t *piCommonGrouping, + int32_t *piNumGroups, + int32_t **ppiGroupLengths, + ISAR_SPLIT_REND_BITS_HANDLE pBits ) +{ + int32_t c, k, iBitsRead; + + iBitsRead = 0; + if ( iChannels == 2 ) + { + *piCommonGrouping = ISAR_SPLIT_REND_BITStream_read_int32( pBits, 1 ); + iBitsRead += 1; + + if ( *piCommonGrouping == 1 ) + { + piNumGroups[0] = 0; + ppiGroupLengths[0][piNumGroups[0]] = 1; + for ( k = 0; k < ( iNumBlocks - 1 ); k++ ) + { + int32_t iGroupStart; + + iGroupStart = ISAR_SPLIT_REND_BITStream_read_int32( pBits, 1 ); + iBitsRead += 1; + + if ( iGroupStart == 1 ) + { + piNumGroups[0]++; + ppiGroupLengths[0][piNumGroups[0]] = 1; + } + else + { + ppiGroupLengths[0][piNumGroups[0]]++; + } + } + piNumGroups[0]++; + + piNumGroups[1] = piNumGroups[0]; + for ( k = 0; k < piNumGroups[1]; k++ ) + { + ppiGroupLengths[1][k] = ppiGroupLengths[0][k]; + } + } + else + { + for ( c = 0; c < iChannels; c++ ) + { + piNumGroups[c] = 0; + ppiGroupLengths[c][piNumGroups[c]] = 1; + for ( k = 0; k < ( iNumBlocks - 1 ); k++ ) + { + int32_t iGroupStart; + + iGroupStart = ISAR_SPLIT_REND_BITStream_read_int32( pBits, 1 ); + iBitsRead += 1; + + if ( iGroupStart == 1 ) + { + piNumGroups[c]++; + ppiGroupLengths[c][piNumGroups[c]] = 1; + } + else + { + ppiGroupLengths[c][piNumGroups[c]]++; + } + } + piNumGroups[c]++; + } + } + } + else + { + for ( c = 0; c < iChannels; c++ ) + { + piNumGroups[c] = 0; + ppiGroupLengths[c][piNumGroups[c]] = 1; + for ( k = 0; k < ( iNumBlocks - 1 ); k++ ) + { + int32_t iGroupStart; + + iGroupStart = ISAR_SPLIT_REND_BITStream_read_int32( pBits, 1 ); + iBitsRead += 1; + + if ( iGroupStart == 1 ) + { + piNumGroups[c]++; + ppiGroupLengths[c][piNumGroups[c]] = 1; + } + else + { + ppiGroupLengths[c][piNumGroups[c]]++; + } + } + piNumGroups[c]++; + } + } + + return iBitsRead; +} + + +static int32_t BSForceBack( + ISAR_SPLIT_REND_BITS_HANDLE pBits, + int32_t iValue, + int32_t iBitCount ) +{ + pBits->bits_read -= iBitCount; + + return ( iValue >> iBitCount ); +} + + +static int32_t ReadHuff( + const uint32_t ( *pauiHuffDecTable )[HUFF_DEC_TABLE_SIZE], + int32_t *piSymbol, + ISAR_SPLIT_REND_BITS_HANDLE pBits ) +{ + int32_t iBitsRead; + int32_t iSymbol; + int32_t iIndex; + int32_t iVal; + + iVal = 0; + iIndex = 0; + iSymbol = 0xFFFF; + iBitsRead = 0; + while ( iSymbol == 0xFFFF ) + { + iIndex = ISAR_SPLIT_REND_BITStream_read_int32( pBits, HUFF_READ_SIZE ); + iBitsRead += HUFF_READ_SIZE; + + iIndex = pauiHuffDecTable[iVal][iIndex]; + iSymbol = ( iIndex & 0xFFFF ); + + iVal = ( iIndex >> 16 ); + } + + if ( iVal ) + { + BSForceBack( pBits, iIndex, iVal ); + iBitsRead -= iVal; + } + + *piSymbol = iSymbol; + + return iBitsRead; +} + + +static int32_t ReadRMSEnvelope( + const int32_t iChannels, + const int32_t *piNumGroups, + const int32_t iNumBands, + int32_t ***pppiRMSEnvelope, + ISAR_SPLIT_REND_BITS_HANDLE pBits ) +{ + int32_t b, k, n; + int32_t iBitsRead, iLastRMSVal; + + iBitsRead = 0; + for ( n = 0; n < iChannels; n++ ) + { + for ( k = 0; k < piNumGroups[n]; k++ ) + { + iLastRMSVal = ISAR_SPLIT_REND_BITStream_read_int32( pBits, ENV0_BITS ); + iBitsRead += ENV0_BITS; + + iLastRMSVal += ENV_MIN; + pppiRMSEnvelope[n][k][0] = iLastRMSVal; + for ( b = 1; b < iNumBands; b++ ) + { + int32_t iDelta; + + iBitsRead += ReadHuff( c_aaiRMSEnvHuffDec, &iDelta, pBits ); + + iDelta += ENV_DELTA_MIN; + iLastRMSVal += iDelta; + pppiRMSEnvelope[n][k][b] = iLastRMSVal; + } + } + } + + return iBitsRead; +} + + +static int32_t ReadAllocInformation( + int32_t *piAllocOffset, + ISAR_SPLIT_REND_BITS_HANDLE pBits ) +{ + int32_t iBitsRead; + + iBitsRead = 0; + *piAllocOffset = ISAR_SPLIT_REND_BITStream_read_int32( pBits, ALLOC_OFFSET_BITS ); + *piAllocOffset += MIN_ALLOC_OFFSET; + iBitsRead += ALLOC_OFFSET_BITS; + + return iBitsRead; +} + +static int32_t ReadLCLDData( + const int32_t *piNumGroups, + int32_t **ppiGroupLengths, + const int32_t iNumBands, + const int32_t iNumChannels, + int32_t **ppiDecodingUnresolved, + int32_t **ppiPredEnable, + const int32_t iNumSubSets, + const int32_t iSubSetId, + int32_t ***pppiAlloc, + int32_t ***pppiSignReal, + int32_t ***pppiSignImag, + int32_t ***pppiQReal, + int32_t ***pppiQImag, + int32_t **ppiDecodingFailed, + ISAR_SPLIT_REND_BITS_HANDLE pBits, + uint32_t ( *c_apauiHuffDecTables[2 * ALLOC_TABLE_SIZE] )[HUFF_DEC_TABLE_SIZE] ) +{ + int32_t iBitsRead; + int32_t iDecodingStopped = 0; + int32_t iNumLcldBands = c_aiNumLcldBandsPerBand[iNumBands - 1]; + int32_t s; + int32_t iSet = iSubSetId; + + iBitsRead = 0; + for ( s = 0; s < iNumSubSets; s++, iSet-- ) + { + int32_t ch; + + if ( iSet < 0 ) + { + iSet = iNumSubSets - 1; + } + + for ( ch = 0; ch < iNumChannels; ch++ ) + { + int32_t n; + int32_t iBlockOffest; + + if ( ppiDecodingUnresolved[ch][iSet] == 1 ) + { + iDecodingStopped = 1; + ppiDecodingFailed[ch][iSet] = 1; /* mark as not decoded (is also initialized like that when a frame is lost */ + } + else + { + ppiDecodingFailed[ch][iSet] = 0; /* mark as correctly decoded */ + } + iBlockOffest = 0; + for ( n = 0; n < piNumGroups[ch]; n++ ) + { + int32_t k; + for ( k = 0; k < ppiGroupLengths[ch][n]; k++ ) + { + int32_t iFBOffset; + + for ( iFBOffset = iSet; iFBOffset < iNumLcldBands; iFBOffset += iNumSubSets ) + { + int32_t b; + int32_t iAlloc; + int32_t iHuffDim; + int32_t iHuffMod; + + b = c_aiBandIdPerLcldBand[iFBOffset]; + + iAlloc = pppiAlloc[ch][n][b]; + + iHuffDim = c_aiHuffmanDim[iAlloc]; + iHuffMod = c_aiHuffmanMod[iAlloc]; + + if ( iDecodingStopped == 1 ) + { + pppiQReal[ch][iBlockOffest][iFBOffset] = 0; + pppiQImag[ch][iBlockOffest][iFBOffset] = 0; + pppiSignReal[ch][iBlockOffest][iFBOffset] = 0; + pppiSignImag[ch][iBlockOffest][iFBOffset] = 0; + } + else if ( iAlloc > 0 ) + { + const uint32_t( *pauiHuffmanTable )[HUFF_DEC_TABLE_SIZE] = NULL; + const uint32_t( *pauiHuffmanTableDPCM )[HUFF_DEC_TABLE_SIZE] = NULL; + int32_t iQuantValue1 = 0; + int32_t iQuantValue2 = 0; + pauiHuffmanTable = (const uint32_t( * )[HUFF_DEC_TABLE_SIZE]) c_apauiHuffDecTables[iAlloc]; + pauiHuffmanTableDPCM = (const uint32_t( * )[HUFF_DEC_TABLE_SIZE]) c_apauiHuffDecTables[ALLOC_TABLE_SIZE + iAlloc]; +#ifdef LCLD_HANDLE_PRED_START_SAMPLE + if ( ppiPredEnable[ch][iFBOffset] == 1 && ( iBlockOffest > 0 || iSet != iSubSetId ) ) +#else + if ( ppiPredEnable[ch][iFBOffset] == 1 ) +#endif + { + if ( iHuffDim == 2 ) + { + int32_t iSymbol; + iBitsRead += ReadHuff( pauiHuffmanTableDPCM, &iSymbol, pBits ); + iQuantValue1 = iSymbol / iHuffMod; + iQuantValue2 = iSymbol % iHuffMod; + } + else + { + iBitsRead += ReadHuff( pauiHuffmanTableDPCM, &iQuantValue1, pBits ); + iBitsRead += ReadHuff( pauiHuffmanTableDPCM, &iQuantValue2, pBits ); + } + } + else + { + if ( iHuffDim == 2 ) + { + int32_t iSymbol; + + iBitsRead += ReadHuff( pauiHuffmanTable, &iSymbol, pBits ); + iQuantValue1 = iSymbol / iHuffMod; + iQuantValue2 = iSymbol % iHuffMod; + } + else + { + iBitsRead += ReadHuff( pauiHuffmanTable, &iQuantValue1, pBits ); + iBitsRead += ReadHuff( pauiHuffmanTable, &iQuantValue2, pBits ); + } + } + + pppiQReal[ch][iBlockOffest][iFBOffset] = iQuantValue1; + pppiQImag[ch][iBlockOffest][iFBOffset] = iQuantValue2; + + if ( iQuantValue1 > 0 ) + { + pppiSignReal[ch][iBlockOffest][iFBOffset] = ISAR_SPLIT_REND_BITStream_read_int32( pBits, 1 ); + iBitsRead += 1; + } + else + { + pppiSignReal[ch][iBlockOffest][iFBOffset] = 0; + } + if ( iQuantValue2 > 0 ) + { + pppiSignImag[ch][iBlockOffest][iFBOffset] = ISAR_SPLIT_REND_BITStream_read_int32( pBits, 1 ); + iBitsRead += 1; + } + else + { + pppiSignImag[ch][iBlockOffest][iFBOffset] = 0; + } + } + else + { + pppiSignReal[ch][iBlockOffest][iFBOffset] = 0; + pppiSignImag[ch][iBlockOffest][iFBOffset] = 0; + } + } + iBlockOffest++; + } + } + } + } + + return iBitsRead; +} + +static void ComputeAllocation( + const int32_t iChannels, + const int32_t *piNumGroups, + const int32_t iNumBands, + int32_t ***pppiSMR, + const int32_t iAllocOffset, + int32_t ***pppiAlloc ) +{ + int32_t b, k, n, iAlloc; + + for ( n = 0; n < iChannels; n++ ) + { + for ( k = 0; k < piNumGroups[n]; k++ ) + { + for ( b = 0; b < iNumBands; b++ ) + { + iAlloc = ( ( pppiSMR[n][k][b] + iAllocOffset * ALLOC_OFFSET_SCALE ) >> 5 ); + iAlloc = ( iAlloc > MIN_ALLOC ) ? iAlloc : MIN_ALLOC; + iAlloc = ( iAlloc < MAX_ALLOC ) ? iAlloc : MAX_ALLOC; + pppiAlloc[n][k][b] = iAlloc; + } + } + } + + return; +} +#endif diff --git a/lib_isar/isar_lcld_encoder.c b/lib_isar/isar_lcld_encoder.c new file mode 100644 index 0000000000000000000000000000000000000000..37bd19dc5ad7fced58b0b3557fcd22c3ccdf6bb5 --- /dev/null +++ b/lib_isar/isar_lcld_encoder.c @@ -0,0 +1,1893 @@ +/****************************************************************************************************** + + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#include +#include "options.h" +#ifdef SPLIT_REND_WITH_HEAD_ROT +#include +#include +#include "prot.h" +#include "isar_prot.h" +#include "wmc_auto.h" + +/*------------------------------------------------------------------------------------------* + * Local structures + *------------------------------------------------------------------------------------------*/ + +struct LCLD_ENCODER +{ + int32_t iSampleRate; + int32_t iChannels; + int32_t iNumBlocks; + + int32_t iTargetBitRate; + + int32_t iNumBands; + const int32_t *piBandwidths; + + int32_t iMSMode; + int32_t *piMSFlags; + int32_t piMSPredCoefs[MAX_BANDS]; + int32_t piLRPhaseDiffs[MAX_BANDS]; + int32_t iAllowSidePred; + + int32_t iRealOnlyOut; + + RMSEnvelopeGrouping *psRMSEnvelopeGrouping; + + int32_t iCommonGrouping; + int32_t *piNumGroups; + int32_t **ppiGroupLengths; + + int32_t ***pppiRMSEnvelope; + int32_t ***pppiSMR; + int32_t ***pppiExcitation; + int32_t ***pppiAlloc; + + int32_t iAllocOffset; + + int32_t ***pppiLCLDSignReal; + int32_t ***pppiLCLDSignImag; + int32_t ***pppiQLCLDReal; + int32_t ***pppiQLCLDImag; + + + PredictionEncoder *psPredictionEncoder; +}; + +/*------------------------------------------------------------------------------------------* + * Function Quantize() + * + * + *------------------------------------------------------------------------------------------*/ + +static int32_t Quantize( + const float fVal, + const float fScale, + int32_t *iSign, + const int32_t iMaxVal ) +{ + int32_t iVal; + if ( fVal > 0.0f ) + { + iVal = (int32_t) ( fScale * fVal + 0.5f ); + *iSign = 0; + } + else + { + iVal = (int32_t) ( -fScale * fVal + 0.5f ); + *iSign = 1; + } + iVal = ( iVal < iMaxVal ) ? iVal : iMaxVal; + + return iVal; +} + +/*------------------------------------------------------------------------------------------* + * Function UnQuantize() + * + * + *------------------------------------------------------------------------------------------*/ + +static float UnQuantize( + const int32_t iVal, + const float fScale, + const int32_t iSign ) +{ + float fVal; + if ( iSign == 0 ) + { + fVal = fScale * (float) iVal; + } + else + { + fVal = -fScale * (float) iVal; + } + return fVal; +} + +static void PackReal( + const int32_t iChannels, + const int32_t iNumBlocks, + float ***pppfReal, + float ***pppfImag ) +{ + int32_t ch, b, n; + for ( ch = 0; ch < iChannels; ch++ ) + { + for ( b = 0; b < LCLD_BANDS; b++ ) + { + int32_t iRealBlock = 0; + for ( n = 0; n < iNumBlocks; n += 2 ) + { + pppfImag[ch][iRealBlock][b] = pppfReal[ch][n + 1][b]; + pppfReal[ch][iRealBlock][b] = pppfReal[ch][n][b]; + iRealBlock++; + } + } + } +} + +/*------------------------------------------------------------------------------------------* + * Function CreateLCLDEncoder() + * + * + *------------------------------------------------------------------------------------------*/ + +ivas_error CreateLCLDEncoder( + LCLDEncoder **psLCLDEncoder_out, + const int32_t iSampleRate, + const int32_t iChannels, + const int32_t iTargetBitRate, + const int32_t iAllowSidePred, + const int16_t iNumBlocks, + const int16_t iNumSubSets, + const int32_t iRealOnlyOut ) +{ + int32_t n; + LCLDEncoder *psLCLDEncoder; + ivas_error error; + int32_t iMaxNumPredBands = 0; + + assert( iSampleRate == 48000 ); + assert( iNumBlocks == 16 || iNumBlocks == 8 || iNumBlocks == 4 ); + assert( iNumSubSets > 0 && iNumSubSets <= LCLD_MAX_NUM_PRED_SUBSETS ); + + if ( ( psLCLDEncoder = (LCLDEncoder *) malloc( sizeof( LCLDEncoder ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + + psLCLDEncoder->iSampleRate = iSampleRate; + psLCLDEncoder->iChannels = iChannels; + psLCLDEncoder->iRealOnlyOut = iRealOnlyOut; + psLCLDEncoder->iAllocOffset = 0; + + psLCLDEncoder->iTargetBitRate = iTargetBitRate; + + psLCLDEncoder->piBandwidths = c_aiBandwidths48; + psLCLDEncoder->iNumBands = DEF_BANDS_48; /* 22 bands = 50 CLDFB bands (rather than 23 bands) */ + iMaxNumPredBands = min( c_aiNumLcldBandsPerBand[psLCLDEncoder->iNumBands - 1], 50 ); + if ( iRealOnlyOut == 1 ) + { + iMaxNumPredBands = 0; + assert( iNumSubSets == 1 ); + psLCLDEncoder->iNumBlocks = iNumBlocks / 2; + } + else + { + psLCLDEncoder->iNumBlocks = iNumBlocks; + } + psLCLDEncoder->iMSMode = 0; + if ( ( psLCLDEncoder->piMSFlags = (int32_t *) malloc( MAX_BANDS * sizeof( int32_t ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + + for ( n = 0; n < MAX_BANDS; n++ ) + { + psLCLDEncoder->piLRPhaseDiffs[n] = 0; + psLCLDEncoder->piMSPredCoefs[n] = 0; + } + psLCLDEncoder->iAllowSidePred = iAllowSidePred; + psLCLDEncoder->psRMSEnvelopeGrouping = CreateRMSEnvelopeGrouping( psLCLDEncoder->iNumBlocks ); + + psLCLDEncoder->iCommonGrouping = 1; /*Common grouping always on only impacts stereo */ + if ( ( psLCLDEncoder->piNumGroups = (int32_t *) malloc( psLCLDEncoder->iChannels * sizeof( int32_t ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + + if ( ( psLCLDEncoder->ppiGroupLengths = (int32_t **) malloc( psLCLDEncoder->iChannels * sizeof( int32_t * ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + + if ( ( psLCLDEncoder->pppiRMSEnvelope = (int32_t ***) malloc( psLCLDEncoder->iChannels * sizeof( int32_t ** ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + + if ( ( psLCLDEncoder->pppiSMR = (int32_t ***) malloc( psLCLDEncoder->iChannels * sizeof( int32_t ** ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + + if ( ( psLCLDEncoder->pppiExcitation = (int32_t ***) malloc( psLCLDEncoder->iChannels * sizeof( int32_t ** ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + + if ( ( psLCLDEncoder->pppiAlloc = (int32_t ***) malloc( psLCLDEncoder->iChannels * sizeof( int32_t ** ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + + + if ( ( psLCLDEncoder->pppiLCLDSignReal = (int32_t ***) malloc( psLCLDEncoder->iChannels * sizeof( int32_t ** ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + + if ( ( psLCLDEncoder->pppiLCLDSignImag = (int32_t ***) malloc( psLCLDEncoder->iChannels * sizeof( int32_t ** ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + + if ( ( psLCLDEncoder->pppiQLCLDReal = (int32_t ***) malloc( psLCLDEncoder->iChannels * sizeof( int32_t ** ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + + if ( ( psLCLDEncoder->pppiQLCLDImag = (int32_t ***) malloc( psLCLDEncoder->iChannels * sizeof( int32_t ** ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + + + for ( n = 0; n < iChannels; n++ ) + { + int32_t k; + if ( ( psLCLDEncoder->ppiGroupLengths[n] = (int32_t *) malloc( LCLD_BLOCKS_PER_FRAME * sizeof( int32_t ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + + if ( ( psLCLDEncoder->pppiRMSEnvelope[n] = (int32_t **) malloc( LCLD_BLOCKS_PER_FRAME * sizeof( int32_t * ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + + if ( ( psLCLDEncoder->pppiSMR[n] = (int32_t **) malloc( LCLD_BLOCKS_PER_FRAME * sizeof( int32_t * ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + + if ( ( psLCLDEncoder->pppiExcitation[n] = (int32_t **) malloc( LCLD_BLOCKS_PER_FRAME * sizeof( int32_t * ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + + if ( ( psLCLDEncoder->pppiAlloc[n] = (int32_t **) malloc( LCLD_BLOCKS_PER_FRAME * sizeof( int32_t * ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + + + if ( ( psLCLDEncoder->pppiLCLDSignReal[n] = (int32_t **) malloc( LCLD_BLOCKS_PER_FRAME * sizeof( int32_t * ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + + if ( ( psLCLDEncoder->pppiLCLDSignImag[n] = (int32_t **) malloc( LCLD_BLOCKS_PER_FRAME * sizeof( int32_t * ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + + if ( ( psLCLDEncoder->pppiQLCLDReal[n] = (int32_t **) malloc( LCLD_BLOCKS_PER_FRAME * sizeof( int32_t * ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + + if ( ( psLCLDEncoder->pppiQLCLDImag[n] = (int32_t **) malloc( LCLD_BLOCKS_PER_FRAME * sizeof( int32_t * ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + + for ( k = 0; k < LCLD_BLOCKS_PER_FRAME; k++ ) + { + if ( ( psLCLDEncoder->pppiRMSEnvelope[n][k] = (int32_t *) malloc( MAX_BANDS * sizeof( int32_t ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + + if ( ( psLCLDEncoder->pppiSMR[n][k] = (int32_t *) malloc( MAX_BANDS * sizeof( int32_t ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + + if ( ( psLCLDEncoder->pppiExcitation[n][k] = (int32_t *) malloc( MAX_BANDS * sizeof( int32_t ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + + if ( ( psLCLDEncoder->pppiAlloc[n][k] = (int32_t *) malloc( MAX_BANDS * sizeof( int32_t ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + + + if ( ( psLCLDEncoder->pppiLCLDSignReal[n][k] = (int32_t *) malloc( LCLD_BANDS * sizeof( int32_t ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + + if ( ( psLCLDEncoder->pppiLCLDSignImag[n][k] = (int32_t *) malloc( LCLD_BANDS * sizeof( int32_t ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + + if ( ( psLCLDEncoder->pppiQLCLDReal[n][k] = (int32_t *) malloc( LCLD_BANDS * sizeof( int32_t ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + + if ( ( psLCLDEncoder->pppiQLCLDImag[n][k] = (int32_t *) malloc( LCLD_BANDS * sizeof( int32_t ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + } + } + + if ( ( error = CreatePredictionEncoder( &( psLCLDEncoder->psPredictionEncoder ), iChannels, psLCLDEncoder->iNumBlocks, (int32_t) iNumSubSets, iMaxNumPredBands ) ) != IVAS_ERR_OK ) + { + return error; + } + + *psLCLDEncoder_out = psLCLDEncoder; + + return IVAS_ERR_OK; +} + + +/*------------------------------------------------------------------------------------------* + * Function DeleteLCLDEncoder() + * + * + *------------------------------------------------------------------------------------------*/ + +void DeleteLCLDEncoder( + LCLDEncoder *psLCLDEncoder ) +{ + int32_t k, n; + + if ( psLCLDEncoder != NULL ) + { + + if ( psLCLDEncoder->piMSFlags != NULL ) + { + free( psLCLDEncoder->piMSFlags ); + } + + if ( psLCLDEncoder->piNumGroups != NULL ) + { + free( psLCLDEncoder->piNumGroups ); + } + + if ( psLCLDEncoder->psRMSEnvelopeGrouping != NULL ) + { + DeleteRMSEnvelopeGrouping( psLCLDEncoder->psRMSEnvelopeGrouping ); + } + + if ( psLCLDEncoder->ppiGroupLengths != NULL ) + { + for ( n = 0; n < psLCLDEncoder->iChannels; n++ ) + { + free( psLCLDEncoder->ppiGroupLengths[n] ); + } + free( psLCLDEncoder->ppiGroupLengths ); + } + if ( psLCLDEncoder->pppiRMSEnvelope != NULL ) + { + for ( n = 0; n < psLCLDEncoder->iChannels; n++ ) + { + for ( k = 0; k < LCLD_BLOCKS_PER_FRAME; k++ ) + { + free( psLCLDEncoder->pppiRMSEnvelope[n][k] ); + } + free( psLCLDEncoder->pppiRMSEnvelope[n] ); + } + free( psLCLDEncoder->pppiRMSEnvelope ); + } + + if ( psLCLDEncoder->pppiSMR != NULL ) + { + for ( n = 0; n < psLCLDEncoder->iChannels; n++ ) + { + for ( k = 0; k < LCLD_BLOCKS_PER_FRAME; k++ ) + { + free( psLCLDEncoder->pppiSMR[n][k] ); + } + free( psLCLDEncoder->pppiSMR[n] ); + } + free( psLCLDEncoder->pppiSMR ); + } + + if ( psLCLDEncoder->pppiExcitation != NULL ) + { + for ( n = 0; n < psLCLDEncoder->iChannels; n++ ) + { + for ( k = 0; k < LCLD_BLOCKS_PER_FRAME; k++ ) + { + free( psLCLDEncoder->pppiExcitation[n][k] ); + } + free( psLCLDEncoder->pppiExcitation[n] ); + } + free( psLCLDEncoder->pppiExcitation ); + } + + if ( psLCLDEncoder->pppiAlloc != NULL ) + { + for ( n = 0; n < psLCLDEncoder->iChannels; n++ ) + { + for ( k = 0; k < LCLD_BLOCKS_PER_FRAME; k++ ) + { + free( psLCLDEncoder->pppiAlloc[n][k] ); + } + free( psLCLDEncoder->pppiAlloc[n] ); + } + free( psLCLDEncoder->pppiAlloc ); + } + + if ( psLCLDEncoder->pppiLCLDSignReal != NULL ) + { + for ( n = 0; n < psLCLDEncoder->iChannels; n++ ) + { + for ( k = 0; k < LCLD_BLOCKS_PER_FRAME; k++ ) + { + free( psLCLDEncoder->pppiLCLDSignReal[n][k] ); + } + free( psLCLDEncoder->pppiLCLDSignReal[n] ); + } + free( psLCLDEncoder->pppiLCLDSignReal ); + } + + if ( psLCLDEncoder->pppiLCLDSignImag != NULL ) + { + for ( n = 0; n < psLCLDEncoder->iChannels; n++ ) + { + for ( k = 0; k < LCLD_BLOCKS_PER_FRAME; k++ ) + { + free( psLCLDEncoder->pppiLCLDSignImag[n][k] ); + } + free( psLCLDEncoder->pppiLCLDSignImag[n] ); + } + free( psLCLDEncoder->pppiLCLDSignImag ); + } + + if ( psLCLDEncoder->pppiQLCLDReal != NULL ) + { + for ( n = 0; n < psLCLDEncoder->iChannels; n++ ) + { + for ( k = 0; k < LCLD_BLOCKS_PER_FRAME; k++ ) + { + free( psLCLDEncoder->pppiQLCLDReal[n][k] ); + } + free( psLCLDEncoder->pppiQLCLDReal[n] ); + } + free( psLCLDEncoder->pppiQLCLDReal ); + } + + if ( psLCLDEncoder->pppiQLCLDImag != NULL ) + { + for ( n = 0; n < psLCLDEncoder->iChannels; n++ ) + { + for ( k = 0; k < LCLD_BLOCKS_PER_FRAME; k++ ) + { + free( psLCLDEncoder->pppiQLCLDImag[n][k] ); + } + free( psLCLDEncoder->pppiQLCLDImag[n] ); + } + free( psLCLDEncoder->pppiQLCLDImag ); + } + + DeletePredictionEncoder( psLCLDEncoder->psPredictionEncoder ); + free( psLCLDEncoder ); + } + + return; +} + +/*------------------------------------------------------------------------------------------* + * Local function declarations + *------------------------------------------------------------------------------------------*/ + +static int32_t MSModeCalculation( const int32_t iNumBlocks, const int32_t iNumBands, const int32_t *piBandwidths, float ***pppfReal, float ***pppfImag, int32_t *piMSMode, int32_t *piLRPhaseDiff, int32_t *piMSPredCoef, const int32_t iAllowSidePred, const int32_t iRealOnlyOut, int32_t *piMSFlags ); + +static void RemoveRMSEnvelope( const int32_t iNumBands, const int32_t *piBandwidths, const int32_t iNumGroups, const int32_t *piGroupLengths, int32_t **ppiRMSEnvelope, float **ppfReal, float **ppfImag ); + +static int32_t CountLCLDBits( const int32_t iNumGroups, const int32_t *piGroupLengths, const int32_t iNumBands, const int32_t *piBandwidths, const int32_t *piPredEnable, int32_t **ppiAlloc, int32_t **ppiQReal, int32_t **ppiQImag ); + +static int32_t WriteHeaderInformation( const int32_t iNumBands, ISAR_SPLIT_REND_BITS_HANDLE pBits ); + +static int32_t WriteMSInformation( const int32_t iNumBands, const int32_t iMSMode, const int32_t *piMSFlags, const int32_t *piLRPhaseDiffs, const int32_t *piMSPredCoefs, int32_t iNumMSPredBands, ISAR_SPLIT_REND_BITS_HANDLE pBits ); + +static int32_t WriteGroupInformation( const int32_t iChannels, const int32_t iCommonGrouping, const int32_t *piNumGroups, int32_t **ppiGroupLengths, ISAR_SPLIT_REND_BITS_HANDLE pBits ); + +static int32_t WriteRMSEnvelope( const int32_t iChannels, const int32_t *piNumGroups, const int32_t iNumBands, int32_t ***pppiRMSEnvelope, ISAR_SPLIT_REND_BITS_HANDLE pBits ); + +static int32_t WriteAllocInformation( const int32_t iAllocOffset, ISAR_SPLIT_REND_BITS_HANDLE pBits ); + +static int32_t WriteLCLDData( const int32_t *piNumGroups, int32_t **ppiGroupLengths, const int32_t iNumBands, const int32_t iNumChannels, int32_t **ppiPredEnable, const int32_t iNumSubSets, const int32_t iSubSetId, int32_t ***pppiAlloc, int32_t ***pppiSignReal, int32_t ***pppiSignImag, int32_t ***pppiQReal, int32_t ***pppiQImag, ISAR_SPLIT_REND_BITS_HANDLE pBits ); + +static int32_t ComputeAllocation( const int32_t iChannels, const int32_t *piNumGroups, int32_t **ppiGroupLengths, const int32_t iNumBands, const int32_t *piBandwidths, float ***pppfReal, float ***pppfImag, int32_t ***pppiSMR, const int32_t iAvailableBits, int32_t *piAllocOffset, int32_t ***pppiAlloc, int32_t ***pppiQReal, int32_t ***pppiQImag, int32_t ***pppiSignReal, int32_t ***pppiSignImag, PredictionEncoder *psPredictionEncoder ); + +/*------------------------------------------------------------------------------------------* + * Function EncodeLCLDFrame() + * + * + *------------------------------------------------------------------------------------------*/ + +int32_t EncodeLCLDFrame( + LCLDEncoder *psLCLDEncoder, + float ***pppfLCLDReal, + float ***pppfLCLDImag, + int32_t *piBitsWritten, + const int32_t available_bits, + ISAR_SPLIT_REND_BITS_HANDLE pBits ) +{ + int32_t n; + int32_t iAvailableBits, iBitsWritten; + int32_t iNumMSBands = 0; + int32_t iAudioBitsWritten; + + iAvailableBits = available_bits; /* HCBR for now*/ + iBitsWritten = 0; + assert( available_bits <= pBits->buf_len * 8 ); + + if ( psLCLDEncoder->iRealOnlyOut == 1 ) + { + PackReal( psLCLDEncoder->iChannels, psLCLDEncoder->iNumBlocks * 2, pppfLCLDReal, pppfLCLDImag ); + } + + /* Do MS calc here */ + if ( psLCLDEncoder->iChannels == 2 ) + { + iNumMSBands = MSModeCalculation( psLCLDEncoder->iNumBlocks, + psLCLDEncoder->iNumBands, + psLCLDEncoder->piBandwidths, + pppfLCLDReal, + pppfLCLDImag, + &psLCLDEncoder->iMSMode, + psLCLDEncoder->piLRPhaseDiffs, + psLCLDEncoder->piMSPredCoefs, + psLCLDEncoder->iAllowSidePred, + psLCLDEncoder->iRealOnlyOut, + psLCLDEncoder->piMSFlags ); + + if ( psLCLDEncoder->iMSMode > 0 ) + { + psLCLDEncoder->iCommonGrouping = 1; /* Make sure common grouping is enabled when MS is in use */ + } + } + + + /* Compute Grouping and RMS Envelopes */ + if ( psLCLDEncoder->iChannels == 2 && psLCLDEncoder->iCommonGrouping == 1 ) + { + ComputeEnvelopeGrouping( psLCLDEncoder->psRMSEnvelopeGrouping, + psLCLDEncoder->iChannels, + psLCLDEncoder->iNumBands, + psLCLDEncoder->piBandwidths, + pppfLCLDReal, + pppfLCLDImag, + &psLCLDEncoder->piNumGroups[0], + psLCLDEncoder->ppiGroupLengths[0], + psLCLDEncoder->pppiRMSEnvelope ); + + psLCLDEncoder->piNumGroups[1] = psLCLDEncoder->piNumGroups[0]; + for ( n = 0; n < psLCLDEncoder->piNumGroups[0]; n++ ) + { + psLCLDEncoder->ppiGroupLengths[1][n] = psLCLDEncoder->ppiGroupLengths[0][n]; + } + } + else + { + for ( n = 0; n < psLCLDEncoder->iChannels; n++ ) + { + ComputeEnvelopeGrouping( psLCLDEncoder->psRMSEnvelopeGrouping, + psLCLDEncoder->iChannels, + psLCLDEncoder->iNumBands, + psLCLDEncoder->piBandwidths, + &pppfLCLDReal[n], + &pppfLCLDImag[n], + &psLCLDEncoder->piNumGroups[n], + psLCLDEncoder->ppiGroupLengths[n], + &psLCLDEncoder->pppiRMSEnvelope[n] ); + } + } + + for ( n = 0; n < psLCLDEncoder->iChannels; n++ ) + { + RemoveRMSEnvelope( psLCLDEncoder->iNumBands, + psLCLDEncoder->piBandwidths, + psLCLDEncoder->piNumGroups[n], + (const int32_t *) psLCLDEncoder->ppiGroupLengths[n], + psLCLDEncoder->pppiRMSEnvelope[n], + pppfLCLDReal[n], + pppfLCLDImag[n] ); + } + + ComputePredictors( psLCLDEncoder->psPredictionEncoder, pppfLCLDReal, pppfLCLDImag ); + + iBitsWritten += WriteHeaderInformation( psLCLDEncoder->iNumBands, pBits ); + + if ( psLCLDEncoder->iChannels == 2 ) + { + iBitsWritten += WriteMSInformation( psLCLDEncoder->iNumBands, + psLCLDEncoder->iMSMode, + (const int32_t *) psLCLDEncoder->piMSFlags, + (const int32_t *) psLCLDEncoder->piLRPhaseDiffs, + (const int32_t *) psLCLDEncoder->piMSPredCoefs, + iNumMSBands, + pBits ); + } + + + iBitsWritten += WritePredictors( psLCLDEncoder->psPredictionEncoder, pBits ); + + iBitsWritten += WriteGroupInformation( psLCLDEncoder->iChannels, psLCLDEncoder->iCommonGrouping, (const int32_t *) psLCLDEncoder->piNumGroups, psLCLDEncoder->ppiGroupLengths, pBits ); + + iBitsWritten += WriteRMSEnvelope( psLCLDEncoder->iChannels, (const int32_t *) psLCLDEncoder->piNumGroups, psLCLDEncoder->iNumBands, psLCLDEncoder->pppiRMSEnvelope, pBits ); + + + if ( psLCLDEncoder->iChannels == 2 && psLCLDEncoder->iCommonGrouping == 1 ) + { + int32_t k; + for ( k = 0; k < psLCLDEncoder->piNumGroups[0]; k++ ) + { + PerceptualModelStereo( psLCLDEncoder->iNumBands, + psLCLDEncoder->piMSFlags, + psLCLDEncoder->pppiRMSEnvelope[0][k], + psLCLDEncoder->pppiRMSEnvelope[1][k], + psLCLDEncoder->pppiExcitation[0][k], + psLCLDEncoder->pppiExcitation[1][k], + psLCLDEncoder->pppiSMR[0][k], + psLCLDEncoder->pppiSMR[1][k] ); + } + } + else + { + for ( n = 0; n < psLCLDEncoder->iChannels; n++ ) + { + int32_t k; + for ( k = 0; k < psLCLDEncoder->piNumGroups[n]; k++ ) + { + PerceptualModel( psLCLDEncoder->iNumBands, + psLCLDEncoder->pppiRMSEnvelope[n][k], + psLCLDEncoder->pppiExcitation[n][k], + psLCLDEncoder->pppiSMR[n][k] ); + } + } + } +#ifdef DEBUG_WRITE_PREDICTORS + { + static FILE *fid; + if ( !fid ) + fid = fopen( "pred_enc.txt", "wt" ); + for ( n = 0; n < psLCLDEncoder->iChannels; n++ ) + { + int16_t b; + for ( b = 0; b < 60; b++ ) + fprintf( fid, "%.5f ", (float) psLCLDEncoder->psPredictionEncoder->ppiPredBandEnable[n][b] * psLCLDEncoder->psPredictionEncoder->ppfA1Imag[n][b] ); + } + fprintf( fid, "%d %d\n", psLCLDEncoder->psPredictionEncoder->iSubSetId, psLCLDEncoder->psPredictionEncoder->piPredChanEnable[n] ); + } +#endif + iAvailableBits -= iBitsWritten; + ComputeAllocation( psLCLDEncoder->iChannels, + (const int32_t *) psLCLDEncoder->piNumGroups, + psLCLDEncoder->ppiGroupLengths, + psLCLDEncoder->iNumBands, + psLCLDEncoder->piBandwidths, + pppfLCLDReal, + pppfLCLDImag, + psLCLDEncoder->pppiSMR, + iAvailableBits, + &psLCLDEncoder->iAllocOffset, + psLCLDEncoder->pppiAlloc, + psLCLDEncoder->pppiQLCLDReal, + psLCLDEncoder->pppiQLCLDImag, + psLCLDEncoder->pppiLCLDSignReal, + psLCLDEncoder->pppiLCLDSignImag, + psLCLDEncoder->psPredictionEncoder ); + + iBitsWritten += WriteAllocInformation( psLCLDEncoder->iAllocOffset, + pBits ); + iAudioBitsWritten = iBitsWritten; + iBitsWritten += WriteLCLDData( psLCLDEncoder->piNumGroups, + psLCLDEncoder->ppiGroupLengths, + psLCLDEncoder->iNumBands, + psLCLDEncoder->iChannels, + psLCLDEncoder->psPredictionEncoder->ppiPredBandEnable, + psLCLDEncoder->psPredictionEncoder->iNumSubSets, + psLCLDEncoder->psPredictionEncoder->iSubSetId, + psLCLDEncoder->pppiAlloc, + psLCLDEncoder->pppiLCLDSignReal, + psLCLDEncoder->pppiLCLDSignImag, + psLCLDEncoder->pppiQLCLDReal, + psLCLDEncoder->pppiQLCLDImag, + pBits ); + *piBitsWritten = iBitsWritten; + iAudioBitsWritten = iBitsWritten - iAudioBitsWritten; + + UpdatePredictionSubSetId( psLCLDEncoder->psPredictionEncoder ); + + return 0; +} + + +/*------------------------------------------------------------------------------------------* + * Local functions + * + * + *------------------------------------------------------------------------------------------*/ + +enum MSPred_Types +{ + MS_PHASE_AND_PRED = 0, /* LR phase alignment + real-valued M/S prediction */ + MS_PRED_ONLY = 1, /* real-valued M/S prediction */ + MS_PHASE_ONLY = 2 /* LR phase alignment + M/S */ +}; + +enum MS_BS_TYPES +{ + MS_OFF = 0, + MS_ALL = 1, + MS_SOME = 2, + MS_PRED = 3 +}; + +static int32_t MSModeCalculation( + const int32_t iNumBlocks, + const int32_t iNumBands, + const int32_t *piBandwidths, + float ***pppfReal, + float ***pppfImag, + int32_t *piMSMode, + int32_t *piLRPhaseDiffs, + int32_t *piMSPredCoefs, + const int32_t iAllowSidePred, + const int32_t iRealOnlyOut, + int32_t *piMSFlags ) +{ + int32_t b; + int32_t iFBOffset; + int32_t iNumMSBands; + int32_t iMSPredType; + float fMSBitGain = 0.0f; + float pfMSPredBitGain[3]; + float fPred; + int32_t piMSPredFlags0[MAX_BANDS]; + int32_t piMSPredFlags1[MAX_BANDS]; + int32_t piMSPredFlags2[MAX_BANDS]; + int32_t *ppiMSPredFlags[3]; + int32_t piMSPredCoefs0[MAX_BANDS]; + int32_t piMSPredCoefs1[MAX_BANDS]; + int32_t piMSPredCoefs2[MAX_BANDS]; + int32_t *ppiMSPredCoefs[3]; + int32_t piMSPredPhase0[MAX_BANDS]; + int32_t piMSPredPhase1[MAX_BANDS]; + int32_t piMSPredPhase2[MAX_BANDS]; + int32_t *ppiMSPredPhase[3]; + int32_t iMsInfoBits; + int32_t piMsPredInfoBits[3]; + + const float feps = 1e-12f; + float fBitsFactor = 3.32192809488736f; /* = 1/log10(2), from dB/10 to bits assuming 1 bit per log2(SNR) or 1 bit per 3dB SNR */ + + set_zero( pfMSPredBitGain, 3 ); + set_l( piMsPredInfoBits, 0, 3 ); + + set_l( piMSPredFlags0, 0, MAX_BANDS ); + set_l( piMSPredFlags1, 0, MAX_BANDS ); + set_l( piMSPredFlags2, 0, MAX_BANDS ); + set_l( piMSPredCoefs0, 0, MAX_BANDS ); + set_l( piMSPredCoefs1, 0, MAX_BANDS ); + set_l( piMSPredCoefs2, 0, MAX_BANDS ); + set_l( piMSPredPhase0, 0, MAX_BANDS ); + set_l( piMSPredPhase1, 0, MAX_BANDS ); + set_l( piMSPredPhase2, 0, MAX_BANDS ); + + if ( iNumBlocks < LCLD_BLOCKS_PER_FRAME ) + { + fBitsFactor *= ( 0.7f + (float) ( iNumBlocks - 4 ) / (float) ( LCLD_BLOCKS_PER_FRAME - 4 ) * ( 1.0f - 0.7f ) ); /* Tuning for relatively higher side rate due to shorter frame length */ + } + + ppiMSPredFlags[0] = piMSPredFlags0; + ppiMSPredFlags[1] = piMSPredFlags1; + ppiMSPredFlags[2] = piMSPredFlags2; + + ppiMSPredCoefs[0] = piMSPredCoefs0; + ppiMSPredCoefs[1] = piMSPredCoefs1; + ppiMSPredCoefs[2] = piMSPredCoefs2; + + ppiMSPredPhase[0] = piMSPredPhase0; + ppiMSPredPhase[1] = piMSPredPhase1; + ppiMSPredPhase[2] = piMSPredPhase2; + + *piMSMode = MS_OFF; + iFBOffset = 0; + iNumMSBands = 0; + for ( b = 0; b < iNumBands; b++ ) + { + int32_t n; + float fLeftEnergy; + float fRightEnergy; + float fMidEnergy; + float fSideEnergy; + float fLRRatio; + float fMSRatio; + float pfMSPredRatio[3] = { 0.0f }; + float fMidEnergyPred; + float fSideEnergyPred; + float fLRCovReal = 0.0f; + float fLRCovImag = 0.0f; + int32_t iPhase; + int32_t iPred; + int32_t tabIdx = 0; + float fNumLines = (float) ( iRealOnlyOut == 1 ? iNumBlocks * piBandwidths[b] * 4 : iNumBlocks * piBandwidths[b] * 2 ); /* per band per channel */ + float fLevelToSMRdBFactor = (float) c_aiDefaultTheta48[b] / (float) ( 1 << PERCEPTUAL_MODEL_SLGAIN_SHIFT ); /* frequency dependent SMR slope in psy model */ + fLeftEnergy = 0.0f; + fRightEnergy = 0.0f; + fMidEnergy = 0.0f; + fSideEnergy = 0.0f; + + for ( n = 0; n < piBandwidths[b]; n++ ) + { + int32_t k; + for ( k = 0; k < iNumBlocks; k++ ) + { + float fMidReal; + float fMidImag; + float fSideReal; + float fSideImag; + + fMidReal = 0.5f * ( pppfReal[0][k][iFBOffset] + pppfReal[1][k][iFBOffset] ); + fMidImag = 0.5f * ( pppfImag[0][k][iFBOffset] + pppfImag[1][k][iFBOffset] ); + fSideReal = 0.5f * ( pppfReal[0][k][iFBOffset] - pppfReal[1][k][iFBOffset] ); + fSideImag = 0.5f * ( pppfImag[0][k][iFBOffset] - pppfImag[1][k][iFBOffset] ); + + fLeftEnergy += ( pppfReal[0][k][iFBOffset] * pppfReal[0][k][iFBOffset] + pppfImag[0][k][iFBOffset] * pppfImag[0][k][iFBOffset] ); + fRightEnergy += ( pppfReal[1][k][iFBOffset] * pppfReal[1][k][iFBOffset] + pppfImag[1][k][iFBOffset] * pppfImag[1][k][iFBOffset] ); + fMidEnergy += ( fMidReal * fMidReal + fMidImag * fMidImag ); + fSideEnergy += ( fSideReal * fSideReal + fSideImag * fSideImag ); + + fLRCovReal += ( pppfReal[0][k][iFBOffset] * pppfReal[1][k][iFBOffset] + pppfImag[0][k][iFBOffset] * pppfImag[1][k][iFBOffset] ); + fLRCovImag += ( pppfImag[0][k][iFBOffset] * pppfReal[1][k][iFBOffset] - pppfImag[1][k][iFBOffset] * pppfReal[0][k][iFBOffset] ); + } + + iFBOffset++; + } + + /* M/S prediction without phase alignment*/ + fPred = 0.25f * ( fLeftEnergy - fRightEnergy ) / ( fMidEnergy + feps ); + iPred = quantPred( fPred ); + fPred = dequantPred( iPred ); + fSideEnergyPred = fSideEnergy + ( fPred * fPred * fMidEnergy - 2.0f * fPred * 0.25f * ( fLeftEnergy - fRightEnergy ) ); + + ppiMSPredCoefs[MS_PRED_ONLY][b] = iPred; + ppiMSPredPhase[MS_PRED_ONLY][b] = 0; + pfMSPredRatio[MS_PRED_ONLY] = log10f( ( fMidEnergy + feps ) / ( fSideEnergyPred + feps ) ); + + /* Phase alignment*/ + iPhase = 0; + if ( fLRCovReal * fLRCovReal + fLRCovImag * fLRCovImag > 0.5f * fLeftEnergy * fRightEnergy ) + { + float fPhase = atan2f( fLRCovImag, fLRCovReal ); + iPhase = quantPhase( fPhase ); + } + + /* adjust covariance */ + tabIdx = iPhase - PHASE_MIN_VAL; + cplxmult_lcld( &fLRCovReal, &fLRCovImag, c_afRotRealImag[tabIdx][0], -c_afRotRealImag[tabIdx][1] ); + + /* compute MS prediction coefficient based on adjusted covariance */ + fMidEnergyPred = 0.25f * ( fLeftEnergy + fRightEnergy + 2.0f * fLRCovReal ); + fSideEnergyPred = 0.25f * ( fLeftEnergy + fRightEnergy - 2.0f * fLRCovReal ); + + /* M/S with LR phase alignment but without prediction */ + ppiMSPredCoefs[MS_PHASE_ONLY][b] = 0; + ppiMSPredPhase[MS_PHASE_ONLY][b] = iPhase; + pfMSPredRatio[MS_PHASE_ONLY] = log10f( ( fMidEnergyPred + feps ) / ( fSideEnergyPred + feps ) ); + + /* M/S with LR phase alignment and prediction */ + fPred = fMidEnergyPred == 0.0f ? 0.0f : 0.25f * ( fLeftEnergy - fRightEnergy ) / fMidEnergyPred; + iPred = quantPred( fPred ); + fPred = dequantPred( iPred ); + fSideEnergyPred += ( fPred * fPred * fMidEnergyPred - 2.0f * fPred * 0.25f * ( fLeftEnergy - fRightEnergy ) ); + /* -= fPred * fPred * fMidEnergyPred doesn't work because fPred is quantized and does not match MS/MM exactly */ + ppiMSPredCoefs[MS_PHASE_AND_PRED][b] = iPred; + ppiMSPredPhase[MS_PHASE_AND_PRED][b] = iPhase; + pfMSPredRatio[MS_PHASE_AND_PRED] = log10f( ( fMidEnergyPred + feps ) / ( fSideEnergyPred + feps ) ); + + /* Plain M/S */ + fLeftEnergy = log10f( fLeftEnergy + feps ); + fRightEnergy = log10f( fRightEnergy + feps ); + fMidEnergy = log10f( fMidEnergy + feps ); + fSideEnergy = log10f( fSideEnergy + feps ); + + fLRRatio = ( fLeftEnergy > fRightEnergy ? fLeftEnergy - fRightEnergy : fRightEnergy - fLeftEnergy ); + fMSRatio = ( fMidEnergy > fSideEnergy ? fMidEnergy - fSideEnergy : fSideEnergy - fMidEnergy ); + + if ( fMSRatio > fLRRatio ) + { + iNumMSBands++; + piMSFlags[b] = 1; + fMSBitGain += fNumLines * ( fMSRatio - fLRRatio ) * fLevelToSMRdBFactor * fBitsFactor; + } + else + { + piMSFlags[b] = 0; + } + piLRPhaseDiffs[b] = 0; + piMSPredCoefs[b] = 0; + + /* MSPred bit gains based on increase of level ratio compared to L/R ratio and the level dependent psy-model */ + for ( iMSPredType = 0; iMSPredType < 3; iMSPredType++ ) + { + if ( pfMSPredRatio[iMSPredType] > fLRRatio ) + { + ppiMSPredFlags[iMSPredType][b] = 1; + pfMSPredBitGain[iMSPredType] += fNumLines * ( pfMSPredRatio[iMSPredType] - fLRRatio ) * fLevelToSMRdBFactor * fBitsFactor; + } + } + } + + /* remove signalling cost from bit gains */ + for ( iMSPredType = 0; iMSPredType < 3; iMSPredType++ ) + { + piMsPredInfoBits[iMSPredType] = CountMSBits( iNumBands, MS_PRED, ppiMSPredFlags[iMSPredType], ppiMSPredPhase[iMSPredType], ppiMSPredCoefs[iMSPredType] ); + pfMSPredBitGain[iMSPredType] = max( pfMSPredBitGain[iMSPredType] - piMsPredInfoBits[iMSPredType], 0.0f ); + } + + /* find the best M/S Pred type */ + if ( iRealOnlyOut == 1 ) + { + iMSPredType = MS_PRED_ONLY; + } + else + { + iMSPredType = MS_PHASE_AND_PRED; + iMSPredType = ( pfMSPredBitGain[MS_PRED_ONLY] > pfMSPredBitGain[iMSPredType] ? MS_PRED_ONLY : iMSPredType ); + iMSPredType = ( pfMSPredBitGain[MS_PHASE_ONLY] > pfMSPredBitGain[iMSPredType] ? MS_PHASE_ONLY : iMSPredType ); + } + + /* plain M/S */ + iMsInfoBits = CountMSBits( iNumBands, MS_SOME, piMSFlags, NULL, NULL ); + fMSBitGain = max( fMSBitGain - iMsInfoBits, 0.0f ); + if ( iAllowSidePred && pfMSPredBitGain[iMSPredType] > 1.1f * fMSBitGain ) + { + *piMSMode = MS_PRED; + iNumMSBands = 0; + for ( b = 0; b < iNumBands; b++ ) + { + piMSFlags[b] = ppiMSPredFlags[iMSPredType][b]; + if ( piMSFlags[b] == 1 ) + { + piMSPredCoefs[b] = ppiMSPredCoefs[iMSPredType][b]; + piLRPhaseDiffs[b] = ppiMSPredPhase[iMSPredType][b]; + iNumMSBands++; + } + else + { + piMSPredCoefs[b] = 0; + piLRPhaseDiffs[b] = 0; + } + } + } + else if ( iNumMSBands == iNumBands ) + { + *piMSMode = MS_ALL; + } + else if ( iNumMSBands > 0 ) + { + *piMSMode = MS_SOME; + } + else + { + *piMSMode = MS_OFF; + } +#ifdef DEBUG_WRITE_MS_PRED + { + static FILE *fid; + int32_t iActualInfoBits = CountMSBits( iNumBands, *piMSMode, piMSFlags, piLRPhaseDiffs, piMSPredCoefs ); + if ( !fid ) + fid = fopen( "ms_info_bits.txt", "wt" ); + fprintf( fid, "%d %d %d %d %d\n", iMsInfoBits, piMsPredInfoBits[MS_PHASE_AND_PRED], piMsPredInfoBits[MS_PRED_ONLY], piMsPredInfoBits[MS_PHASE_ONLY], iActualInfoBits ); + } +#endif + if ( *piMSMode != MS_OFF ) + { + iFBOffset = 0; + for ( b = 0; b < iNumBands; b++ ) + { + if ( piMSFlags[b] == 1 ) + { + int32_t n; + int32_t phaseIdx; + phaseIdx = piLRPhaseDiffs[b] - PHASE_MIN_VAL; + fPred = dequantPred( piMSPredCoefs[b] ); + for ( n = 0; n < piBandwidths[b]; n++ ) + { + int32_t k; + for ( k = 0; k < iNumBlocks; k++ ) + { + float fMidReal; + float fMidImag; + float fSideReal; + float fSideImag; + + if ( *piMSMode == MS_PRED ) + { + cplxmult_lcld( &pppfReal[1][k][iFBOffset], &pppfImag[1][k][iFBOffset], c_afRotRealImag[phaseIdx][0], c_afRotRealImag[phaseIdx][1] ); + } + + fMidReal = 0.5f * ( pppfReal[0][k][iFBOffset] + pppfReal[1][k][iFBOffset] ); + fMidImag = 0.5f * ( pppfImag[0][k][iFBOffset] + pppfImag[1][k][iFBOffset] ); + fSideReal = 0.5f * ( pppfReal[0][k][iFBOffset] - pppfReal[1][k][iFBOffset] ); + fSideImag = 0.5f * ( pppfImag[0][k][iFBOffset] - pppfImag[1][k][iFBOffset] ); + + if ( *piMSMode == MS_PRED ) + { + fSideReal -= fPred * fMidReal; + fSideImag -= fPred * fMidImag; + } + + pppfReal[0][k][iFBOffset] = fMidReal; + pppfReal[1][k][iFBOffset] = fSideReal; + pppfImag[0][k][iFBOffset] = fMidImag; + pppfImag[1][k][iFBOffset] = fSideImag; + } + iFBOffset++; + } + } + else + { + iFBOffset += piBandwidths[b]; + } + } + } +#ifdef DEBUG_WRITE_MS_PRED + { + static FILE *fid; + if ( !fid ) + fid = fopen( "ms_enc.txt", "wt" ); + writeMSPred( piLRPhaseDiffs, piMSPredCoefs, *piMSMode, iNumMSBands, iNumBands, fid, piMSFlags ); + } +#endif + if ( *piMSMode == MS_PRED ) + { + /* Differential Coding of Phase Data*/ + PrepEncode( piLRPhaseDiffs, piMSFlags, iNumBands ); + PrepEncode( piMSPredCoefs, piMSFlags, iNumBands ); +#ifdef DEBUG_WRITE_MS_PRED + { + static FILE *fid; + if ( !fid ) + fid = fopen( "ms_pred_enc.txt", "wt" ); + writeMSPred( piLRPhaseDiffs, piMSPredCoefs, *piMSMode, iNumMSBands, iNumBands, fid, piMSFlags ); + } +#endif + /* Differential Coding*/ + EncodePhase( piLRPhaseDiffs, iNumMSBands, PHASE_DIFF_DIM ); + EncodePredCoef( piMSPredCoefs, iNumMSBands ); + } + + return iNumMSBands; +} + + +static void RemoveRMSEnvelope( + const int32_t iNumBands, + const int32_t *piBandwidths, + const int32_t iNumGroups, + const int32_t *piGroupLengths, + int32_t **ppiRMSEnvelope, + float **ppfReal, + float **ppfImag ) +{ + int32_t k, n, b, iFBOffset, m, iRMSEnv; + int32_t iBlockOffset; + float fGain; + + iBlockOffset = 0; + for ( n = 0; n < iNumGroups; n++ ) + { + for ( k = 0; k < piGroupLengths[n]; k++ ) + { + iFBOffset = 0; + for ( b = 0; b < iNumBands; b++ ) + { + iRMSEnv = ppiRMSEnvelope[n][b]; + fGain = c_afRMSEnvReconstructTable[ENV_RECONSTRUCT_TABLE_CENTER - iRMSEnv]; + for ( m = 0; m < piBandwidths[b]; m++ ) + { + ppfReal[iBlockOffset][iFBOffset] *= fGain; + ppfImag[iBlockOffset][iFBOffset] *= fGain; + iFBOffset++; + } + } + iBlockOffset++; + } + } + + return; +} + +static void QuantizeSpectrumDPCM_Opt( + const int32_t iNumGroups, + const int32_t *piGroupLengths, + const int32_t iNumBands, + const int32_t *piBandwidths, + int32_t **ppiAlloc, + float **ppfReal, + float **ppfImag, + int32_t **ppiQReal, + int32_t **ppiQImag, + int32_t **ppiSignReal, + int32_t **ppiSignImag, + const int32_t iNumSubSets, + const int32_t iSubSetId, + const int32_t *piPredEnable, + float *pfA1Real, + float *pfA1Imag, + float *pfPredStateReal, + float *pfPredStateImag ) +{ + int32_t b, n; + int32_t iFBOffset; + int32_t k, iAlloc, iMaxQuantVal; + float fSCFGain, fInvSCFGain; + + iFBOffset = 0; + for ( b = 0; b < iNumBands; b++ ) + { + int32_t m; + for ( m = 0; m < piBandwidths[b]; m++ ) + { + int32_t iBlockOffset = 0; + if ( piPredEnable[iFBOffset] == 1 ) + { + float fReal; + float fImag; + int32_t iSubset = iFBOffset % iNumSubSets; + float fPrevReal = 0.0f; + float fPrevImag = 0.0f; + if ( iSubset != iSubSetId ) + { + /* run predictors across sub-frames */ + fPrevReal = pfPredStateReal[iFBOffset]; + fPrevImag = pfPredStateImag[iFBOffset]; + } + for ( n = 0; n < iNumGroups; n++ ) + { + iAlloc = ppiAlloc[n][b]; + iMaxQuantVal = c_aiQuantMaxValues[iAlloc]; + fSCFGain = c_afScaleFactor[iAlloc]; + fInvSCFGain = c_afInvScaleFactor[iAlloc]; + for ( k = 0; k < piGroupLengths[n]; k++ ) + { + /* prediction */ + fReal = pfA1Real[iFBOffset] * fPrevReal - pfA1Imag[iFBOffset] * fPrevImag; + fImag = pfA1Real[iFBOffset] * fPrevImag + pfA1Imag[iFBOffset] * fPrevReal; + + ppiQReal[iBlockOffset][iFBOffset] = Quantize( ppfReal[iBlockOffset][iFBOffset] + fReal, /* quantize residual */ + fSCFGain, + &ppiSignReal[iBlockOffset][iFBOffset], + iMaxQuantVal ); + + ppiQImag[iBlockOffset][iFBOffset] = Quantize( ppfImag[iBlockOffset][iFBOffset] + fImag, + fSCFGain, + &ppiSignImag[iBlockOffset][iFBOffset], + iMaxQuantVal ); + + fPrevReal = UnQuantize( ppiQReal[iBlockOffset][iFBOffset], + fInvSCFGain, + ppiSignReal[iBlockOffset][iFBOffset] ) - + fReal; /* add prediction to quantized residual = reconstructed sample */ + + fPrevImag = UnQuantize( ppiQImag[iBlockOffset][iFBOffset], + fInvSCFGain, + ppiSignImag[iBlockOffset][iFBOffset] ) - + fImag; + + iBlockOffset++; + } /* group length */ + } /* groups */ + pfPredStateReal[iFBOffset] = fPrevReal; + pfPredStateImag[iFBOffset] = fPrevImag; + } /* predEnable */ + else + { /* no prediction */ + for ( n = 0; n < iNumGroups; n++ ) + { + iAlloc = ppiAlloc[n][b]; + iMaxQuantVal = c_aiQuantMaxValues[iAlloc]; + fSCFGain = c_afScaleFactor[iAlloc]; + fInvSCFGain = c_afInvScaleFactor[iAlloc]; + for ( k = 0; k < piGroupLengths[n]; k++ ) + { + ppiQReal[iBlockOffset][iFBOffset] = Quantize( ppfReal[iBlockOffset][iFBOffset], + fSCFGain, + &ppiSignReal[iBlockOffset][iFBOffset], + iMaxQuantVal ); + + ppiQImag[iBlockOffset][iFBOffset] = Quantize( ppfImag[iBlockOffset][iFBOffset], + fSCFGain, + &ppiSignImag[iBlockOffset][iFBOffset], + iMaxQuantVal ); + + iBlockOffset++; + } /* group length */ + } /* groups */ + } /* predEnable */ + iFBOffset++; + } /* bandwidth */ + } /* bands */ +} + +static int32_t CountLCLDBits( + const int32_t iNumGroups, + const int32_t *piGroupLengths, + const int32_t iNumBands, + const int32_t *piBandwidths, + const int32_t *piPredEnable, + int32_t **ppiAlloc, + int32_t **ppiQReal, + int32_t **ppiQImag ) +{ + int32_t k, n, b, iFBOffset; + int32_t iBits, iBlockOffest; + int32_t m, iAlloc, iHuffDim, iHuffMod; + + iBits = 0; + iBlockOffest = 0; + for ( n = 0; n < iNumGroups; n++ ) + { + for ( k = 0; k < piGroupLengths[n]; k++ ) + { + iFBOffset = 0; + for ( b = 0; b < iNumBands; b++ ) + { + iAlloc = ppiAlloc[n][b]; + + iHuffDim = c_aiHuffmanDim[iAlloc]; + iHuffMod = c_aiHuffmanMod[iAlloc]; + + if ( iAlloc > 0 ) + { + const uint16_t( *pauiHuffmanTable )[2] = NULL; + const uint16_t( *pauiHuffmanTableDPCM )[2] = NULL; + pauiHuffmanTable = c_apauiHuffEncTabels[iAlloc]; + pauiHuffmanTableDPCM = c_apauiHuffEncTabels[ALLOC_TABLE_SIZE + iAlloc]; + for ( m = 0; m < piBandwidths[b]; m++ ) + { + int32_t iQuantValue1; + int32_t iQuantValue2; + + iQuantValue1 = ppiQReal[iBlockOffest][iFBOffset]; + iQuantValue2 = ppiQImag[iBlockOffest][iFBOffset]; + + iBits += ( iQuantValue1 > 0 ) ? 1 : 0; /* Sign bit for vals > 0 */ + iBits += ( iQuantValue2 > 0 ) ? 1 : 0; /* Sign bit for vals > 0 */ + + if ( piPredEnable[iFBOffset] == 1 ) + { + if ( iHuffDim == 2 ) + { + iQuantValue1 *= iHuffMod; + iQuantValue1 += iQuantValue2; + iBits += pauiHuffmanTableDPCM[iQuantValue1][0]; + } + else + { + iBits += pauiHuffmanTableDPCM[iQuantValue1][0]; + iBits += pauiHuffmanTableDPCM[iQuantValue2][0]; + } + } + else + { + if ( iHuffDim == 2 ) + { + iQuantValue1 *= iHuffMod; + iQuantValue1 += iQuantValue2; + iBits += pauiHuffmanTable[iQuantValue1][0]; + } + else + { + iBits += pauiHuffmanTable[iQuantValue1][0]; + iBits += pauiHuffmanTable[iQuantValue2][0]; + } + } + + iFBOffset++; + } + } + else + { + iFBOffset += piBandwidths[b]; + } + } + + iBlockOffest++; + } + } + + return iBits; +} + + +/* Currently only the number of bands in frame */ +static int32_t WriteHeaderInformation( + const int32_t iNumBands, + ISAR_SPLIT_REND_BITS_HANDLE pBits ) +{ + int32_t iBitsWritten; + + iBitsWritten = 0; + ISAR_SPLIT_REND_BITStream_write_int32( pBits, iNumBands, 5 ); + iBitsWritten += 5; + + return iBitsWritten; +} + + +static int32_t WriteMSInformation( + const int32_t iNumBands, + const int32_t iMSMode, + const int32_t *piMSFlags, + const int32_t *piLRPhaseDiff, + const int32_t *piMSPredCoef, + int32_t iNumMSPredBands, + ISAR_SPLIT_REND_BITS_HANDLE pBits ) +{ + int32_t iBitsWritten; + int32_t iMSPredAll = ( iNumMSPredBands == iNumBands ); +#ifdef DEBUG_WRITE_MS_PRED + int32_t iBitsWrittenTmp = 0; +#endif + iBitsWritten = 0; + ISAR_SPLIT_REND_BITStream_write_int32( pBits, iMSMode, 2 ); + iBitsWritten += 2; + + if ( iMSMode == 3 ) + { + ISAR_SPLIT_REND_BITStream_write_int32( pBits, iMSPredAll, 1 ); + iBitsWritten += 1; + } + + if ( iMSMode == 2 || ( iMSMode == 3 && !iMSPredAll ) ) + { + int32_t n; + for ( n = 0; n < iNumBands; n++ ) + { + ISAR_SPLIT_REND_BITStream_write_int32( pBits, piMSFlags[n], 1 ); + iBitsWritten += 1; + } + } + +#ifdef DEBUG_WRITE_MS_PRED + iBitsWrittenTmp = iBitsWritten; +#endif + if ( iMSMode == 3 ) + { + int32_t b; + int32_t anyNonZero; + anyNonZero = 0; + for ( b = 0; b < iNumMSPredBands; b++ ) + { + if ( piLRPhaseDiff[b] != 0 ) + { + anyNonZero = 1; + break; + } + } + ISAR_SPLIT_REND_BITStream_write_int32( pBits, anyNonZero, 1 ); + iBitsWritten++; + + if ( anyNonZero ) + { + ISAR_SPLIT_REND_BITStream_write_int32( pBits, piLRPhaseDiff[0] - PHASE_MIN_VAL, PHASE_BAND0_BITS ); + iBitsWritten += PHASE_BAND0_BITS; + for ( b = 1; b < iNumMSPredBands; b++ ) + { + int32_t tabIdx = piLRPhaseDiff[b] - ENV_DELTA_MIN; + ISAR_SPLIT_REND_BITStream_write_int32( pBits, c_aaiRMSEnvHuffEnc[tabIdx][1], c_aaiRMSEnvHuffEnc[tabIdx][0] ); + iBitsWritten += c_aaiRMSEnvHuffEnc[tabIdx][0]; + } + } + + anyNonZero = 0; + for ( b = 0; b < iNumMSPredBands; b++ ) + { + if ( piMSPredCoef[b] != 0 ) + { + anyNonZero = 1; + break; + } + } + + ISAR_SPLIT_REND_BITStream_write_int32( pBits, anyNonZero, 1 ); + iBitsWritten++; + + if ( anyNonZero ) + { + ISAR_SPLIT_REND_BITStream_write_int32( pBits, piMSPredCoef[0] - PRED_MIN_VAL, PRED_BAND0_BITS ); + iBitsWritten += PRED_BAND0_BITS; + for ( b = 1; b < iNumMSPredBands; b++ ) + { + int32_t tabIdx = piMSPredCoef[b] - ENV_DELTA_MIN; + ISAR_SPLIT_REND_BITStream_write_int32( pBits, c_aaiRMSEnvHuffEnc[tabIdx][1], c_aaiRMSEnvHuffEnc[tabIdx][0] ); + iBitsWritten += c_aaiRMSEnvHuffEnc[tabIdx][0]; + } + } + } +#ifdef DEBUG_WRITE_MS_PRED + { + static FILE *fid = 0; + if ( !fid ) + { + fid = fopen( "ms_pred_bitrate.txt", "wt" ); + } + fprintf( fid, "%f\n", (float) ( ( iBitsWritten - iBitsWrittenTmp ) * ( iMSMode == 3 ) * 50 ) / 1000.0f ); /*kb/s*/ + } +#endif + + return iBitsWritten; +} + + +static int32_t WriteGroupInformation( + const int32_t iChannels, + const int32_t iCommonGrouping, + const int32_t *piNumGroups, + int32_t **ppiGroupLengths, + ISAR_SPLIT_REND_BITS_HANDLE pBits ) +{ + int32_t c, k, n, iBitsWritten; + + iBitsWritten = 0; + if ( iChannels == 2 && iCommonGrouping == 1 ) + { + ISAR_SPLIT_REND_BITStream_write_int32( pBits, iCommonGrouping, 1 ); + iBitsWritten += 1; + + for ( n = 0; n < piNumGroups[0]; n++ ) + { + for ( k = 1; k < ppiGroupLengths[0][n]; k++ ) + { + ISAR_SPLIT_REND_BITStream_write_int32( pBits, 0, 1 ); + iBitsWritten += 1; + } + if ( n < ( piNumGroups[0] - 1 ) ) + { + ISAR_SPLIT_REND_BITStream_write_int32( pBits, 1, 1 ); + iBitsWritten += 1; + } + } + } + else if ( iChannels == 2 ) + { + ISAR_SPLIT_REND_BITStream_write_int32( pBits, iCommonGrouping, 1 ); + iBitsWritten += 1; + + for ( c = 0; c < iChannels; c++ ) + { + for ( n = 0; n < piNumGroups[c]; n++ ) + { + for ( k = 1; k < ppiGroupLengths[c][n]; k++ ) + { + ISAR_SPLIT_REND_BITStream_write_int32( pBits, 0, 1 ); + iBitsWritten += 1; + } + if ( n < ( piNumGroups[c] - 1 ) ) + { + ISAR_SPLIT_REND_BITStream_write_int32( pBits, 1, 1 ); + iBitsWritten += 1; + } + } + } + } + else + { + for ( c = 0; c < iChannels; c++ ) + { + for ( n = 0; n < piNumGroups[c]; n++ ) + { + for ( k = 1; k < ppiGroupLengths[c][n]; k++ ) + { + ISAR_SPLIT_REND_BITStream_write_int32( pBits, 0, 1 ); + iBitsWritten += 1; + } + + if ( n < ( piNumGroups[c] - 1 ) ) + { + ISAR_SPLIT_REND_BITStream_write_int32( pBits, 1, 1 ); + iBitsWritten += 1; + } + } + } + } + + return iBitsWritten; +} + + +static int32_t WriteRMSEnvelope( + const int32_t iChannels, + const int32_t *piNumGroups, + const int32_t iNumBands, + int32_t ***pppiRMSEnvelope, + ISAR_SPLIT_REND_BITS_HANDLE pBits ) +{ + int32_t k, n; + int32_t iBitsWritten; + + iBitsWritten = 0; + for ( n = 0; n < iChannels; n++ ) + { + for ( k = 0; k < piNumGroups[n]; k++ ) + { + int32_t b; + int32_t iLastRMSVal; + + iLastRMSVal = pppiRMSEnvelope[n][k][0]; + iLastRMSVal = ( iLastRMSVal > ENV_MIN ) ? iLastRMSVal : ENV_MIN; + iLastRMSVal = ( iLastRMSVal < ENV_MAX ) ? iLastRMSVal : ENV_MAX; + ISAR_SPLIT_REND_BITStream_write_int32( pBits, ( iLastRMSVal - ENV_MIN ), ENV0_BITS ); + iBitsWritten += ENV0_BITS; + + for ( b = 1; b < iNumBands; b++ ) + { + int32_t iDelta; + + iDelta = pppiRMSEnvelope[n][k][b] - iLastRMSVal; + iDelta = ( iDelta > ENV_DELTA_MIN ) ? iDelta : ENV_DELTA_MIN; + iDelta = ( iDelta < ENV_DELTA_MAX ) ? iDelta : ENV_DELTA_MAX; + iDelta -= ENV_DELTA_MIN; + ISAR_SPLIT_REND_BITStream_write_int32( pBits, c_aaiRMSEnvHuffEnc[iDelta][1], c_aaiRMSEnvHuffEnc[iDelta][0] ); + iBitsWritten += c_aaiRMSEnvHuffEnc[iDelta][0]; + + iLastRMSVal = pppiRMSEnvelope[n][k][b]; + } + } + } + + return iBitsWritten; +} + + +static int32_t WriteAllocInformation( + const int32_t iAllocOffset, + ISAR_SPLIT_REND_BITS_HANDLE pBits ) +{ + int32_t iBitsWritten; + + iBitsWritten = 0; + + if ( iAllocOffset < MIN_ALLOC_OFFSET || iAllocOffset > MAX_ALLOC_OFFSET ) + { + printf( "Serious error\n" ); + } + + ISAR_SPLIT_REND_BITStream_write_int32( pBits, ( iAllocOffset - MIN_ALLOC_OFFSET ), ALLOC_OFFSET_BITS ); + iBitsWritten += ALLOC_OFFSET_BITS; + + return iBitsWritten; +} + +static int32_t WriteLCLDData( + const int32_t *piNumGroups, + int32_t **ppiGroupLengths, + const int32_t iNumBands, + const int32_t iNumChannels, + int32_t **ppiPredEnable, + const int32_t iNumSubSets, + const int32_t iSubSetId, + int32_t ***pppiAlloc, + int32_t ***pppiSignReal, + int32_t ***pppiSignImag, + int32_t ***pppiQReal, + int32_t ***pppiQImag, + ISAR_SPLIT_REND_BITS_HANDLE pBits ) +{ + int32_t iBitsWritten; + int32_t iNumLcldBands = c_aiNumLcldBandsPerBand[iNumBands - 1]; + int32_t s; + int32_t iSet = iSubSetId; + + iBitsWritten = 0; + for ( s = 0; s < iNumSubSets; s++, iSet-- ) + { + int32_t ch; + if ( iSet < 0 ) + { + iSet = iNumSubSets - 1; + } + + for ( ch = 0; ch < iNumChannels; ch++ ) + { + int32_t iBlockOffest = 0; + int32_t n; + for ( n = 0; n < piNumGroups[ch]; n++ ) + { + int32_t k; + for ( k = 0; k < ppiGroupLengths[ch][n]; k++ ) + { + int32_t iFBOffset; + for ( iFBOffset = iSet; iFBOffset < iNumLcldBands; iFBOffset += iNumSubSets ) + { + int32_t b; + int32_t iAlloc; + int32_t iHuffDim; + int32_t iHuffMod; + + b = c_aiBandIdPerLcldBand[iFBOffset]; + + iAlloc = pppiAlloc[ch][n][b]; + + iHuffDim = c_aiHuffmanDim[iAlloc]; + iHuffMod = c_aiHuffmanMod[iAlloc]; + + if ( iAlloc > 0 ) + { + const uint16_t( *pauiHuffmanTable )[2] = NULL; + const uint16_t( *pauiHuffmanTableDPCM )[2] = NULL; + int32_t iQuantValue1; + int32_t iQuantValue2; + pauiHuffmanTable = c_apauiHuffEncTabels[iAlloc]; + pauiHuffmanTableDPCM = c_apauiHuffEncTabels[ALLOC_TABLE_SIZE + iAlloc]; + + iQuantValue1 = pppiQReal[ch][iBlockOffest][iFBOffset]; + iQuantValue2 = pppiQImag[ch][iBlockOffest][iFBOffset]; +#ifdef LCLD_HANDLE_PRED_START_SAMPLE + if ( ppiPredEnable[ch][iFBOffset] == 1 && ( iBlockOffest > 0 || iSet != iSubSetId ) ) +#else + if ( ppiPredEnable[ch][iFBOffset] == 1 ) +#endif + { + if ( iHuffDim == 2 ) + { + int32_t iSymbol; + iSymbol = iQuantValue1; + iSymbol *= iHuffMod; + iSymbol += iQuantValue2; + ISAR_SPLIT_REND_BITStream_write_int32( pBits, pauiHuffmanTableDPCM[iSymbol][1], pauiHuffmanTableDPCM[iSymbol][0] ); + iBitsWritten += pauiHuffmanTableDPCM[iSymbol][0]; + } + else + { + ISAR_SPLIT_REND_BITStream_write_int32( pBits, pauiHuffmanTableDPCM[iQuantValue1][1], pauiHuffmanTableDPCM[iQuantValue1][0] ); + iBitsWritten += pauiHuffmanTableDPCM[iQuantValue1][0]; + + ISAR_SPLIT_REND_BITStream_write_int32( pBits, pauiHuffmanTableDPCM[iQuantValue2][1], pauiHuffmanTableDPCM[iQuantValue2][0] ); + iBitsWritten += pauiHuffmanTableDPCM[iQuantValue2][0]; + } + } + else + { + if ( iHuffDim == 2 ) + { + int32_t iSymbol; + iSymbol = iQuantValue1; + iSymbol *= iHuffMod; + iSymbol += iQuantValue2; + ISAR_SPLIT_REND_BITStream_write_int32( pBits, pauiHuffmanTable[iSymbol][1], pauiHuffmanTable[iSymbol][0] ); + iBitsWritten += pauiHuffmanTable[iSymbol][0]; + } + else + { + ISAR_SPLIT_REND_BITStream_write_int32( pBits, pauiHuffmanTable[iQuantValue1][1], pauiHuffmanTable[iQuantValue1][0] ); + iBitsWritten += pauiHuffmanTable[iQuantValue1][0]; + + ISAR_SPLIT_REND_BITStream_write_int32( pBits, pauiHuffmanTable[iQuantValue2][1], pauiHuffmanTable[iQuantValue2][0] ); + iBitsWritten += pauiHuffmanTable[iQuantValue2][0]; + } + } + + if ( iQuantValue1 > 0 ) + { + ISAR_SPLIT_REND_BITStream_write_int32( pBits, pppiSignReal[ch][iBlockOffest][iFBOffset], 1 ); + iBitsWritten += 1; + } + if ( iQuantValue2 > 0 ) + { + ISAR_SPLIT_REND_BITStream_write_int32( pBits, pppiSignImag[ch][iBlockOffest][iFBOffset], 1 ); + iBitsWritten += 1; + } + } + } + iBlockOffest++; + } + } + } + } + + return iBitsWritten; +} + +static int32_t ComputeAllocation( + const int32_t iChannels, + const int32_t *piNumGroups, + int32_t **ppiGroupLengths, + const int32_t iNumBands, + const int32_t *piBandwidths, + float ***pppfReal, + float ***pppfImag, + int32_t ***pppiSMR, + const int32_t iAvailableBits, + int32_t *piAllocOffset, + int32_t ***pppiAlloc, + int32_t ***pppiQReal, + int32_t ***pppiQImag, + int32_t ***pppiSignReal, + int32_t ***pppiSignImag, + PredictionEncoder *psPredictionEncoder ) +{ + int32_t iBitsUsed, iDone, iDelta; + int32_t b, k, n; + int32_t iLimitAllocOffset; + + iBitsUsed = ALLOC_OFFSET_BITS; /* Bits used for Alloc Offset */ + + iDone = 0; + iDelta = -MIN_ALLOC_OFFSET; + *piAllocOffset = 0; + + while ( iDone == 0 ) + { + iBitsUsed = ALLOC_OFFSET_BITS; + + iLimitAllocOffset = *piAllocOffset; + iLimitAllocOffset = ( iLimitAllocOffset > MIN_ALLOC_OFFSET ) ? iLimitAllocOffset : MIN_ALLOC_OFFSET; + iLimitAllocOffset = ( iLimitAllocOffset < MAX_ALLOC_OFFSET ) ? iLimitAllocOffset : MAX_ALLOC_OFFSET; + + for ( n = 0; n < iChannels; n++ ) + { + for ( k = 0; k < piNumGroups[n]; k++ ) + { + for ( b = 0; b < iNumBands; b++ ) + { + int32_t iAlloc; + iAlloc = ( ( pppiSMR[n][k][b] + iLimitAllocOffset * ALLOC_OFFSET_SCALE ) >> 5 ); + iAlloc = ( iAlloc > MIN_ALLOC ) ? iAlloc : MIN_ALLOC; + iAlloc = ( iAlloc < MAX_ALLOC ) ? iAlloc : MAX_ALLOC; + pppiAlloc[n][k][b] = iAlloc; + } + } + + if ( psPredictionEncoder->iNumSubSets > 1 ) + { + mvr2r( psPredictionEncoder->ppfPredStateReal[n], psPredictionEncoder->ppfPredStateRealTmp[n], LCLD_BANDS ); + mvr2r( psPredictionEncoder->ppfPredStateImag[n], psPredictionEncoder->ppfPredStateImagTmp[n], LCLD_BANDS ); + } + + QuantizeSpectrumDPCM_Opt( piNumGroups[n], + (const int32_t *) ppiGroupLengths[n], + iNumBands, + piBandwidths, + pppiAlloc[n], + pppfReal[n], + pppfImag[n], + pppiQReal[n], + pppiQImag[n], + pppiSignReal[n], + pppiSignImag[n], + psPredictionEncoder->iNumSubSets, + psPredictionEncoder->iSubSetId, + psPredictionEncoder->ppiPredBandEnable[n], + psPredictionEncoder->ppfA1Real[n], + psPredictionEncoder->ppfA1Imag[n], + psPredictionEncoder->ppfPredStateRealTmp[n], + psPredictionEncoder->ppfPredStateImagTmp[n] ); + + iBitsUsed += CountLCLDBits( piNumGroups[n], + (const int32_t *) ppiGroupLengths[n], + iNumBands, + piBandwidths, + (const int32_t *) psPredictionEncoder->ppiPredBandEnable[n], + pppiAlloc[n], + pppiQReal[n], + pppiQImag[n] ); + } + + if ( *piAllocOffset <= MIN_ALLOC_OFFSET && iBitsUsed > iAvailableBits ) + { +#ifdef DEBUG_VERBOSE + printf( "Frame can not be coded with the number of bits available\n" ); +#endif + /* iLastError = ENC_ERROR_STREAM_FAILURE;*/ + return -1; + } + else if ( *piAllocOffset >= MAX_ALLOC_OFFSET && iBitsUsed < iAvailableBits ) + { + *piAllocOffset = MAX_ALLOC_OFFSET; + iDone++; + } + else + { + if ( iDelta == 0 && iBitsUsed > iAvailableBits ) + { + iDelta = 1; + } + else if ( iDelta == 0 && iBitsUsed < iAvailableBits ) + { + iDone++; + } + else if ( iBitsUsed == iAvailableBits ) + { + iDone++; + } + + if ( iBitsUsed > iAvailableBits ) + { + *piAllocOffset -= iDelta; + iDelta >>= 1; + } + else if ( iBitsUsed < iAvailableBits ) + { + *piAllocOffset += iDelta; + iDelta >>= 1; + } + } + } + + if ( psPredictionEncoder->iNumSubSets > 1 ) + { + for ( n = 0; n < iChannels; n++ ) + { + mvr2r( psPredictionEncoder->ppfPredStateRealTmp[n], psPredictionEncoder->ppfPredStateReal[n], LCLD_BANDS ); + mvr2r( psPredictionEncoder->ppfPredStateImagTmp[n], psPredictionEncoder->ppfPredStateImag[n], LCLD_BANDS ); + } + } + + /* + printf("%d\n",*piAllocOffset); + printf("%d\t%d\t%d\n",pppiAlloc[0][0][0],pppiAlloc[0][0][1],pppiAlloc[0][0][22]); + + printf("%d\t%d\t%d\t%d\n",*piAllocOffset,iAvailableBits,iBitsUsed,iAvailableBits - iBitsUsed); + */ + + return iBitsUsed; +} +#endif diff --git a/lib_isar/isar_lcld_prot.h b/lib_isar/isar_lcld_prot.h new file mode 100644 index 0000000000000000000000000000000000000000..eee363ced2b1539e1e2da61303e74af91d29682f --- /dev/null +++ b/lib_isar/isar_lcld_prot.h @@ -0,0 +1,393 @@ +/****************************************************************************************************** + + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#ifndef ISAR_LCLD_PROT_H +#define ISAR_LCLD_PROT_H + +#include "options.h" +#ifdef SPLIT_REND_WITH_HEAD_ROT +#include "common_api_types.h" +#include "isar_rom_lcld_tables.h" + +/* clang-format off */ + +typedef struct LCLD_ENCODER LCLDEncoder; + +ivas_error CreateLCLDEncoder( + LCLDEncoder **psLCLDEncoder_out, + const int32_t iSampleRate, + const int32_t iChannels, + const int32_t iTargetBitRate, + const int32_t iAllowSidePred, + const int16_t iNumBlocks, + const int16_t iNumSubSets, + const int32_t iRealOnlyOut + ); + +void DeleteLCLDEncoder( + LCLDEncoder *psLCLDEncoder +); + +int32_t EncodeLCLDFrame( + LCLDEncoder *psLCLDEncoder, + float ***pppfLCLDReal, + float ***pppfLCLDImag, + int32_t *piNumiBites, + const int32_t available_bits, + ISAR_SPLIT_REND_BITS_HANDLE pBits ); + + +typedef struct LCLD_DECODER LCLDDecoder; + +ivas_error CreateLCLDDecoder( + LCLDDecoder **psLCLDDecoder_out, + const int32_t iSampleRate, + const int32_t iChannels, + const int32_t iNumBlocks, + const int32_t iRealOnlyOut); + +void DeleteLCLDDecoder( + LCLDDecoder *psLCLDDecoder +); + +int32_t DecodeLCLDFrame( + LCLDDecoder *psLCLDDecoder, + ISAR_SPLIT_REND_BITS_HANDLE pBits, + float ***pppfLCLDReal, + float ***pppfLCLDImag +); + + +/*----------------------------------------------------------------------------------* + * MSPred prototypes + *----------------------------------------------------------------------------------*/ + +int32_t quantPhase( + float phase +); + +void cplxmult_lcld( + float *pr1, + float *pi1, + const float r2, + const float i2 +); + + +int32_t requantPhase( + int32_t phaseQ +); + +int32_t quantPred( + const float pred +); + +float dequantPhase( + const int32_t phaseQ +); + +float dequantPred( + int32_t predQ +); + +int32_t PrepEncode( + int32_t *piQuant, + const int32_t *piMSFlags, + const int32_t numBands +); + +void EncodePhase( + int32_t *phaseQuant, + const int32_t numMSBands, + const int32_t diffDim +); + +void DecodePhase( + int32_t *phaseQuant, + const int32_t numMSBands, + const int32_t diffDim +); + +int32_t EncodePredCoef( + int32_t *predQuant, + const int32_t numMSBands +); + +void DecodePredCoef( + int32_t *phaseQuant, + const int32_t numMSBands +); + +void writeMSPred( + int32_t *phaseQuant, + int32_t *predQuant, + const int32_t MSMode, + const int32_t numMSBands, + int32_t numBands, + void *fid, + int32_t *piMsFlags +); + +int32_t CountMSBits( + int32_t iNumBands, + const int32_t iMSMode, + const int32_t *piMSFlags, + const int32_t *piLRPhaseDiff, + const int32_t *piMSPredCoef +); + + +/*----------------------------------------------------------------------------------* + * NoiseGen prototypes + *----------------------------------------------------------------------------------*/ + +typedef struct NOISE_GEN +{ + int32_t iNoiseBufferLength; + int32_t iNoiseBufferMask; + int32_t iNoiseBufferIndex; + float *pfNoiseBuffer; +} NoiseGen; + +void DeleteNoiseGen( + NoiseGen *psNoiseGen +); + +inline float GetNoise( NoiseGen *psNoiseGen ) +{ + float fNoiseSample; + + fNoiseSample = psNoiseGen->pfNoiseBuffer[psNoiseGen->iNoiseBufferIndex]; + psNoiseGen->iNoiseBufferIndex++; + psNoiseGen->iNoiseBufferIndex &= psNoiseGen->iNoiseBufferMask; + + return fNoiseSample; +} + + +/*----------------------------------------------------------------------------------* + * PereptualModel prototypes + *----------------------------------------------------------------------------------*/ + +extern void PerceptualModel( + const int32_t iMaxQuantBands, + const int32_t *piRMSEnvelope, + int32_t *piExcitation, + int32_t *piSMR +); + +extern void PerceptualModelStereo( + const int32_t iMaxQuantBands, + const int32_t *piMSFlags, + const int32_t *piRMSEnvelope0, + const int32_t *piRMSEnvelope1, + int32_t *piExcitation0, + int32_t *piExcitation1, + int32_t *piSMR0, + int32_t *piSMR1 +); + + +/*----------------------------------------------------------------------------------* + * PredEncoder/PredDecoder prototypes + *----------------------------------------------------------------------------------*/ + +typedef struct PREDICTION_ENCODER +{ + int32_t iChannels; + int32_t iNumBlocks; + + int32_t iSubSetId; + int32_t iNumSubSets; + int32_t iMaxNumPredBands; + float ***pppfInpBufReal; /* channels, LCLD_PRED_WIN_LEN, bands */ + float ***pppfInpBufImag; + float **ppfPredStateReal; /* channels, bands */ + float **ppfPredStateImag; + float **ppfPredStateRealTmp; + float **ppfPredStateImagTmp; + float **ppfInpPrevReal; /* channels, bands */ + float **ppfInpPrevImag; + float pfRxxReal[2]; + float pfRxxImag[2]; + + int32_t *piPredChanEnable; + int32_t *piNumPredBands; + int32_t **ppiPredBandEnable; + + float **ppfA1Real; + float **ppfA1Imag; + + int32_t **ppiA1Mag; + int32_t **ppiA1Phase; +} PredictionEncoder; + +ivas_error CreatePredictionEncoder( + PredictionEncoder **psPredictionEncoder_out, + const int32_t iChannels, + const int32_t iNumBlocks, + const int32_t iNumSubSets, + const int32_t iMaxNumPredBands +); + +void DeletePredictionEncoder( + PredictionEncoder *psPredictionEncoder +); + +void ComputePredictors( + PredictionEncoder *psPredictionEncoder, + float ***pppfReal, + float ***pppfImag +); + + +int32_t WritePredictors( + PredictionEncoder *psPredictionEncoder, + ISAR_SPLIT_REND_BITS_HANDLE pBits +); + +typedef struct PREDICTION_DECODER +{ + int32_t iChannels; + int32_t iNumBlocks; + int32_t iSubSetId; + int32_t iNumSubSets; + float **ppfPredStateReal; + float **ppfPredStateImag; + + int32_t *piPredChanEnable; + int32_t **ppiPredBandEnable; + + /* PLC_IMPROVEMENT */ + int32_t **ppiDecodingUnresolved; + int32_t **ppiDecodingFailed; + int32_t **ppiDecodingFailedPrev; + + float **ppfA1Real; + float **ppfA1Imag; + + int32_t **ppiA1Mag; + int32_t **ppiA1Phase; + + float pfMagLUT[1 << PRED_QUNAT_FILTER_MAG_BITS]; + float pfP2RRealLUT[1 << PRED_QUANT_FILTER_PHASE_BITS]; + float pfP2RImagLUT[1 << PRED_QUANT_FILTER_PHASE_BITS]; + +} PredictionDecoder; + +ivas_error CreatePredictionDecoder( + PredictionDecoder **psPredictionDecoder_out, + const int32_t iChannels, + const int32_t iNumBlocks +); + +void DeletePredictionDecoder( + PredictionDecoder *psPredictionDecoder +); + +int32_t ReadPredictors( + PredictionDecoder *psPredictionDecoder, + ISAR_SPLIT_REND_BITS_HANDLE pBits +); + +/* PLC_IMPROVEMENT */ +void UpdatePredictionSubSetId( + PredictionEncoder *psPredictionEncoder); + +void SetDecodingUnresolved( + LCLDDecoder *psLCLDDecoder); + +int32_t AnyDecodingFailedPrev( + LCLDDecoder *psLCLDDecoder); + +int32_t AnyDecodingFailed( + LCLDDecoder *psLCLDDecoder); + +int32_t **GetDecodingFailedStatus( + LCLDDecoder *psLCLDDecoder); + +int16_t GetNumSubSets( + LCLDDecoder *psLCLDDecoder); + +int32_t **GetDecodingFailedPrevStatus( + LCLDDecoder *psLCLDDecoder); + +void SetDecodingPassed( + PredictionDecoder *psPredictionDecoder); + +void UpdateDecodingUnresolved( + PredictionDecoder *psPredictionDecoder); + +void UpdateDecodingFailedStatus( + PredictionDecoder *psPredictionDecoder); + +int32_t AnyDecodingUnresolved( + PredictionDecoder *psPredictionDecoder); + +void ApplyInversePredictors( + PredictionDecoder *psPredictionDecoder, + float ***pppfReal, + float ***pppfImag +); + + +/*----------------------------------------------------------------------------------* + * RMSEnvGrouping prototypes + *----------------------------------------------------------------------------------*/ + +typedef struct RMS_ENVELOPE_GROUPING RMSEnvelopeGrouping; + +RMSEnvelopeGrouping *CreateRMSEnvelopeGrouping( + const int32_t iNumBlocks +); + +void DeleteRMSEnvelopeGrouping( + RMSEnvelopeGrouping *psRMSEnvelopeGrouping +); + +void ComputeEnvelopeGrouping( + RMSEnvelopeGrouping *psRMSEnvelopeGrouping, + const int32_t iChannels, + const int32_t iNumBands, + const int32_t *piBandwidths, + float ***pppfReal, + float ***pppfImag, + int32_t *piNumGroups, + int32_t *piGroupLengths, + int32_t ***pppiRMSEnvelope +); + + +#endif +/* clang-format on */ + +#endif /* _LCLD_ENCODER_H_ */ diff --git a/lib_isar/isar_prot.h b/lib_isar/isar_prot.h new file mode 100644 index 0000000000000000000000000000000000000000..4f1f3e7b951ad690c26f485635df6c746254c4c3 --- /dev/null +++ b/lib_isar/isar_prot.h @@ -0,0 +1,393 @@ +/****************************************************************************************************** + + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#ifndef ISAR_PROT_H +#define ISAR_PROT_H + + +#include "isar_stat.h" + +#ifdef SPLIT_REND_WITH_HEAD_ROT + +#include +#include "options.h" +#include "ivas_error.h" +#include "lib_isar_post_rend.h" + +ivas_error isar_splitBinPreRendOpen( + ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE *hBinHrSplitPreRend, + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG + , + const int32_t output_Fs +#endif +); + +ivas_error split_renderer_open_lc3plus( + SPLIT_REND_WRAPPER *hSplitRendWrapper, + const ISAR_SPLIT_REND_CONFIG_DATA *pSplitRendConfig, + const int32_t OutSampleRate, +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + const IVAS_RENDER_FRAMESIZE ivas_frame_size +#else + const int16_t num_subframes +#endif +); + +void isar_splitBinPreRendClose( + ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE *hBinHrSplitPreRend ); + +void lc3plusTimeAlignCldfbPoseCorr( + SPLIT_REND_WRAPPER *hSplitBin, + float Cldfb_In_BinReal[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + float Cldfb_In_BinImag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX] ); + +ivas_error splitRendLc3plusEncodeAndWrite( + SPLIT_REND_WRAPPER *hSplitBin, + ISAR_SPLIT_REND_BITS_HANDLE pBits, +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + const int32_t available_bits, +#else + const int32_t SplitRendBitRate, +#endif + float *in[] ); + +int32_t ISAR_SPLIT_REND_BITStream_read_int32( + ISAR_SPLIT_REND_BITS_HANDLE pBits, + const int32_t bits ); + +void ISAR_SPLIT_REND_BITStream_write_int32( + ISAR_SPLIT_REND_BITS_HANDLE pBits, + const int32_t val, + const int32_t bits ); + +ivas_error isar_splitBinLCLDEncOpen( + ISAR_BIN_HR_SPLIT_LCLD_ENC_HANDLE *hSplitBinLCLDEnc, + const int32_t iSampleRate, + const int16_t iChannels, + const int32_t iDataRate, + const int16_t iNumBlocks, + const int16_t iNumIterations ); + +ivas_error isar_splitBinRendPLCOpen( + ISAR_SPLIT_REND_PLC_HANDLE *phSplitRendPLC, + const int16_t iNumSubSets ); + +void isar_splitBinRendPLCClose( + ISAR_SPLIT_REND_PLC_HANDLE *phSplitRendPLC ); + +ivas_error isar_splitBinLCLDDecOpen( + ISAR_BIN_HR_SPLIT_LCLD_DEC_HANDLE *hSplitBinLCLDDec, + const int32_t iSampleRate, + const int16_t iChannels, + const int16_t iNumBlocks, + const int16_t iNumIterations ); + +void isar_splitBinLCLDDecClose( + ISAR_BIN_HR_SPLIT_LCLD_DEC_HANDLE *hSplitBinLCLDDec ); + +void isar_splitBinRendPLCsaveState( + ISAR_SPLIT_REND_PLC_HANDLE hSplitRendPLC, + float Cldfb_RealBuffer_Binaural[BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + float Cldfb_ImagBuffer_Binaural[BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + const int16_t num_chs, + const int16_t iNumBlocks, + const int16_t iNumIterations ); + +void isar_splitBinRendPLC_xf( + ISAR_SPLIT_REND_PLC_HANDLE hSplitRendPLC, + float Cldfb_RealBuffer_Binaural[BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + float Cldfb_ImagBuffer_Binaural[BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + const int16_t num_chs, + const int16_t iNumBlocks, + const int16_t iNumIterations, + int32_t **ppiDecodingFailed, + int32_t **ppiDecodingFailedPrev ); + +void isar_splitBinRendPLC( + ISAR_SPLIT_REND_PLC_HANDLE hSplitRendPLC, + float Cldfb_RealBuffer_Binaural[BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + float Cldfb_ImagBuffer_Binaural[BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + const int16_t num_chs, + const int16_t iNumBlocks, + const int16_t iNumIterations, + int32_t **ppiDecodingFailed ); + +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG +void isar_log_cldfb2wav_data( + float Cldfb_In_Real[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + float Cldfb_In_Imag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + HANDLE_CLDFB_FILTER_BANK *cldfbSyn, + const int16_t num_chs, + const int16_t num_freq_bands, + const int32_t output_Fs, + const int16_t start_slot_idx, + const int16_t md_band_idx, + const char *filename ); +#endif + +void isar_splitBinLCLDDecProcess( + ISAR_BIN_HR_SPLIT_LCLD_DEC_HANDLE hSplitBinLCLDDec, + ISAR_SPLIT_REND_BITS_HANDLE pBits, + float Cldfb_Out_Real[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + float Cldfb_Out_Imag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + const int16_t bfi ); + +void set_fix_rotation_mat( + float fix_pos_rot_mat[][BINAURAL_CHANNELS][BINAURAL_CHANNELS], + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData ); + +void isar_splitBinLCLDEncClose( + ISAR_BIN_HR_SPLIT_LCLD_ENC_HANDLE *hSplitBinLCLDEnc ); + +void isar_splitBinLCLDEncProcess( + ISAR_BIN_HR_SPLIT_LCLD_ENC_HANDLE hSplitBinLCLDEnc, + float Cldfb_In_Real[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + float Cldfb_In_Imag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + const int32_t available_bits, + ISAR_SPLIT_REND_BITS_HANDLE pBits ); + +void set_pose_types( + ISAR_SPLIT_REND_POSE_TYPE pose_type[MAX_HEAD_ROT_POSES - 1], + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData ); + +void isar_split_rend_init_huff_cfg( + ISAR_BIN_HR_SPLIT_REND_HUFF_HANDLE pHuff_cfg ); + +ivas_error isar_splitBinPostRendOpen( + ISAR_BIN_HR_SPLIT_POST_REND_HANDLE *hBinHrSplitPostRend, + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + const int32_t output_Fs ); + +void isar_splitBinPostRendClose( + ISAR_BIN_HR_SPLIT_POST_REND_HANDLE *hBinHrSplitPostRend ); + +void isar_SplitRenderer_getdiagdiff( + int16_t in_idx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], + int16_t out_idx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], + const int16_t sign, + const int16_t min_val, + const int16_t max_val ); + +void isar_split_rend_get_quant_params( + const int16_t num_md_bands, + int16_t pred_real_bands_yaw[ISAR_SPLIT_REND_NUM_QUANT_STRATS], + int16_t pred_imag_bands_yaw[ISAR_SPLIT_REND_NUM_QUANT_STRATS], + int16_t pred_quant_pnts_yaw[ISAR_SPLIT_REND_NUM_QUANT_STRATS], + float pred_quantstep_yaw[ISAR_SPLIT_REND_NUM_QUANT_STRATS], + float pred_1byquantstep_yaw[ISAR_SPLIT_REND_NUM_QUANT_STRATS], + int16_t d_bands_yaw[ISAR_SPLIT_REND_NUM_QUANT_STRATS], + int16_t bands_pitch[ISAR_SPLIT_REND_NUM_QUANT_STRATS], + int16_t pred_real_bands_roll[ISAR_SPLIT_REND_NUM_QUANT_STRATS], + int16_t pred_imag_bands_roll[ISAR_SPLIT_REND_NUM_QUANT_STRATS], +#ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS + const int16_t ro_flag, +#endif + int16_t *num_quant_strats +#ifndef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS + , + int16_t *num_complex_bands +#endif +); + +void isar_splitBinPostRendMdDec( + ISAR_SPLIT_REND_BITS_HANDLE pBits, + ISAR_BIN_HR_SPLIT_POST_REND_HANDLE hBinHrSplitPostRend, +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + BIN_HR_SPLIT_PRE_REND_HANDLE hBinHrSplitPreRend +#else + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData +#endif +); + +void Quat2EulerDegree( + const IVAS_QUATERNION quat, /* i : quaternion describing the rotation */ + float *yaw, /* o : yaw */ + float *pitch, /* o : pitch */ + float *roll /* o : roll */ +); + +void isar_mat_mult_2by2_complex( + float in_re1[2][2], + float in_im1[2][2], + float in_re2[2][2], + float in_im2[2][2], + float out_re2[2][2], + float out_im2[2][2] ); + +void isar_rend_CldfbSplitPostRendProcess( + ISAR_BIN_HR_SPLIT_POST_REND_HANDLE hBinHrSplitPostRend, + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + const IVAS_QUATERNION QuaternionPost, + float Cldfb_RealBuffer_Binaural[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], + float Cldfb_ImagBuffer_Binaural[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], + float output[][L_FRAME48k], + const int16_t cldfb_in_flag ); + +void isar_rend_CldfbSplitPreRendProcess( + const ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE hBinHrSplitPreRend, + const IVAS_QUATERNION headPosition, + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + float Cldfb_In_BinReal[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + float Cldfb_In_BinImag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + ISAR_SPLIT_REND_BITS_HANDLE pBits, + const int32_t target_md_bits, + const int16_t low_res_pre_rend_rot, + const int16_t ro_md_flag ); + +ivas_error isar_renderMultiTDBinToSplitBinaural( + SPLIT_REND_WRAPPER *hSplitBin, + const IVAS_QUATERNION headPosition, + const int32_t SplitRendBitRate, +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + const int16_t isar_frame_size_ms, +#endif + const int16_t codec_frame_size_ms, + ISAR_SPLIT_REND_BITS_HANDLE pBits, + const int16_t max_bands, + float *in[], + const int16_t low_res_pre_rend_rot, + const int16_t pcm_out_flag, + const int16_t ro_md_flag ); + +void isar_init_multi_bin_pose_data( + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData ); + +void isar_renderSplitGetMultiBinPoseData( + const ISAR_SPLIT_REND_CONFIG_DATA *pSplit_rend_config, + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + const ISAR_SPLIT_REND_ROT_AXIS rot_axis ); + +#ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS +int16_t isar_renderSplitGetRot_axisNumBits( + const int16_t dof ); + +ISAR_SPLIT_REND_ROT_AXIS isar_renderSplitGetRot_axisFromCode( + const int16_t dof, + const int16_t code ); + +int16_t isar_renderSplitGetCodeFromRot_axis( + const int16_t dof, + const ISAR_SPLIT_REND_ROT_AXIS rot_axis, + int16_t *num_bits ); +#endif + +void isar_init_split_post_rend_handles( + ISAR_SPLIT_POST_REND_WRAPPER *hSplitRendWrapper ); + +void isar_set_split_rend_ht_setup( + SPLIT_REND_WRAPPER *hSplitrend, + IVAS_QUATERNION Quaternions[MAX_PARAM_SPATIAL_SUBFRAMES], + float Rmat[MAX_PARAM_SPATIAL_SUBFRAMES][3][3] ); + +#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS +int32_t isar_get_lc3plus_bitrate( + const int32_t SplitRendBitRate, + const ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrectionMode, + const int16_t split_prerender_frame_size_ms ); +#endif + +ivas_error isar_split_rend_validate_config( + const ISAR_SPLIT_REND_CONFIG_DATA *pSplitRendConfig, + const int16_t pcm_out_flag ); + +int32_t isar_get_lcld_bitrate( + const int32_t SplitRendBitRate, + const ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrectionMode ); + +#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS +int8_t isar_get_lc3plus_bitrate_id( + const int32_t SplitRendBitRate ); +#endif + +int32_t isar_get_split_rend_md_target_brate( + const int32_t SplitRendBitRate, + const int16_t pcm_out_flag ); + +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS +ivas_error isar_framesize_to_ms( + const IVAS_RENDER_FRAMESIZE frame_size, /* i : frame size enum */ + int16_t *ms /* o : frame size in ms */ +); +#endif + +ivas_error isar_split_rend_choose_default_codec( + ISAR_SPLIT_REND_CODEC *pCodec, /* i/o: pointer to codec setting */ +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + int16_t *pIsar_frame_size_ms, /* i/o: pointer to isar frame size setting */ +#endif + int16_t *pCodec_frame_size_ms, /* i/o: pointer to codec frame size setting */ + const int16_t cldfb_in_flag, /* i : flag indicating rendering in TD */ + const int16_t pcm_out_flag, /* i : flag to indicate PCM output */ + const int16_t num_subframes /* i : number of subframes */ +); + +void ISAR_SPLIT_REND_BITStream_init( + ISAR_SPLIT_REND_BITS_HANDLE pBits, + const int32_t buf_len_bytes, + uint8_t *pbuf ); + +void isar_split_rend_huffman_dec_init_min_max_len( + isar_split_rend_huffman_cfg_t *p_huff_cfg ); + +int16_t wrap_a( + int16_t val, + const int16_t min_val, + const int16_t max_val ); + +#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS +int32_t isar_get_lc3plus_size_from_id( + const int8_t SplitRendBitRateId, + const ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrectionMode, + const int16_t split_prerender_frame_size_ms ); +#endif + +void isar_renderSplitUpdateNoCorrectionPoseData( + const ISAR_SPLIT_REND_CONFIG_DATA *pSplit_rend_config, + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData ); + +int32_t get_bit( + const int32_t state, + const int32_t bit_id ); + +ISAR_POST_REND_AudioConfigType isar_getAudioConfigType( + const IVAS_AUDIO_CONFIG config ); + +void isar_init_split_rend_handles( + SPLIT_REND_WRAPPER *hSplitRendWrapper ); + +#endif + +/* clang-format on */ + +#endif /* ISAR_PROT_H */ diff --git a/lib_isar/isar_rom_lcld_tables.c b/lib_isar/isar_rom_lcld_tables.c new file mode 100644 index 0000000000000000000000000000000000000000..043f7b6252f0c13eefdf54ecde6cc4d82b3fc222 --- /dev/null +++ b/lib_isar/isar_rom_lcld_tables.c @@ -0,0 +1,12097 @@ +/****************************************************************************************************** + + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#include "isar_rom_lcld_tables.h" +#include "options.h" +#ifdef SPLIT_REND_WITH_HEAD_ROT +#include "wmc_auto.h" +#include "prot.h" +#include "isar_lcld_prot.h" + +/* clang-format off */ +const int32_t c_aiNumLcldBandsPerBand[MAX_BANDS_48] = { + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 21, 24, 27, 31, 37, 43, 50, 60 +}; + +const int32_t c_aiBandIdPerLcldBand[LCLD_BANDS] = { + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 16, 17, 17, 17, 18, 18, 18, + 18, 19, 19, 19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22 +}; + +/* phi = (-12:12)'/12 *pi; tmp = [cos(phi),sin(phi)]; tmp = tmp';sprintf('{%.8ff, %.8ff},\n',tmp(:)) */ +const float c_afRotRealImag[PHASE_MAX_VAL - PHASE_MIN_VAL + 1][2] = +{ + { -1.00000000f, -0.00000000f }, + { -0.96592583f, -0.25881905f }, + { -0.86602540f, -0.50000000f }, + { -0.70710678f, -0.70710678f }, + { -0.50000000f, -0.86602540f }, + { -0.25881905f, -0.96592583f }, + { 0.00000000f, -1.00000000f }, + { 0.25881905f, -0.96592583f }, + { 0.50000000f, -0.86602540f }, + { 0.70710678f, -0.70710678f }, + { 0.86602540f, -0.50000000f }, + { 0.96592583f, -0.25881905f }, + { 1.00000000f, 0.00000000f }, + { 0.96592583f, 0.25881905f }, + { 0.86602540f, 0.50000000f }, + { 0.70710678f, 0.70710678f }, + { 0.50000000f, 0.86602540f }, + { 0.25881905f, 0.96592583f }, + { 0.00000000f, 1.00000000f }, + { -0.25881905f, 0.96592583f }, + { -0.50000000f, 0.86602540f }, + { -0.70710678f, 0.70710678f }, + { -0.86602540f, 0.50000000f }, + { -0.96592583f, 0.25881905f }, + { -1.00000000f, 0.00000000f } +}; + +const int32_t c_aiBandwidths48[MAX_BANDS_48] = +{ + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 2, + 2, + 2, + 2, + 2, + 3, + 3, + 4, + 6, + 6, + 7, + 10, +}; + + +const float c_afScaleFactor[ALLOC_TABLE_SIZE] = { + 0.0f, + 0.353553390593f, + 0.420448207627f, + 0.500000000000f, + 0.594603557501f, + 0.707106781187f, + 0.840896415254f, + 1.000000000000f, + 1.189207115003f, + 1.414213562373f, + 1.681792830507f, + 2.000000000000f, + 2.378414230005f, + 2.828427124746f, + 3.363585661015f, + 4.0f, + 4.756828460011f, + 5.656854249492f, + 6.727171322030f, + 8.0f, + 9.513656920022f, + 11.31370849898f, + 13.45434264406f, + 16.00000000000f, + 19.02731384004f, + 22.62741699797f, + 26.90868528812f, + 32.000000000000000f, + 38.054627680087073f, + 45.254833995939038f, + 53.817370576237735f, + 64.000000000000000f, +}; + +const float c_afInvScaleFactor[ALLOC_TABLE_SIZE] = { + 0.0f, + 2.367513562373095f, + 2.046407115002721f, + 1.775900000000000f, + 1.536446415253715f, + 1.323056781186548f, + 1.132903557501360f, + 0.965800000000000f, + 0.821348207626857f, + 0.695103390593274f, + 0.587801778750680f, + 0.495800000000000f, + 0.418124103813429f, + 0.352176695296637f, + 0.296200889375340f, + 0.249400000000000f, + 0.209812051906714f, + 0.176538347648318f, + 0.148525444687670f, + 0.124900000000000f, + 0.105056025953357f, + 0.088388347648318f, + 0.074325444687670f, + 0.062500000000000f, + 0.052556025953357f, + 0.044194173824159f, + 0.037162722343835f, + 0.031250000000000f, + 0.026278012976679f, + 0.022097086912080f, + 0.018581361171918f, + 0.015625000000000f, +}; + +const float c_afRMSEnvReconstructTable[ENV_RECONSTRUCT_TABLE_SIZE] = { + 2.32830644e-10f, + 3.29272254e-10f, + 4.65661287e-10f, + 6.58544508e-10f, + 9.31322575e-10f, + 1.31708902e-09f, + 1.86264515e-09f, + 2.63417803e-09f, + 3.72529030e-09f, + 5.26835606e-09f, + 7.45058060e-09f, + 1.05367121e-08f, + 1.49011612e-08f, + 2.10734243e-08f, + 2.98023224e-08f, + 4.21468485e-08f, + 5.96046448e-08f, + 8.42936970e-08f, + 1.19209290e-07f, + 1.68587394e-07f, + 2.38418579e-07f, + 3.37174788e-07f, + 4.76837158e-07f, + 6.74349576e-07f, + 9.53674316e-07f, + 1.34869915e-06f, + 1.90734863e-06f, + 2.69739830e-06f, + 3.81469727e-06f, + 5.39479661e-06f, + 7.62939453e-06f, + 1.07895932e-05f, + 1.52587891e-05f, + 2.15791864e-05f, + 3.05175781e-05f, + 4.31583729e-05f, + 6.10351562e-05f, + 8.63167458e-05f, + 1.22070312e-04f, + 1.72633492e-04f, + 2.44140625e-04f, + 3.45266983e-04f, + 4.88281250e-04f, + 6.90533966e-04f, + 9.76562500e-04f, + 1.38106793e-03f, + 1.95312500e-03f, + 2.76213586e-03f, + 3.90625000e-03f, + 5.52427173e-03f, + 7.81250000e-03f, + 1.10485435e-02f, + 1.56250000e-02f, + 2.20970869e-02f, + 3.12500000e-02f, + 4.41941738e-02f, + 6.25000000e-02f, + 8.83883476e-02f, + 1.25000000e-01f, + 1.76776695e-01f, + 2.50000000e-01f, + 3.53553391e-01f, + 5.00000000e-01f, + 7.07106781e-01f, + 1.00000000e+00f, + 1.41421356e+00f, + 2.00000000e+00f, + 2.82842712e+00f, + 4.00000000e+00f, + 5.65685425e+00f, + 8.00000000e+00f, + 1.13137085e+01f, + 1.60000000e+01f, + 2.26274170e+01f, + 3.20000000e+01f, + 4.52548340e+01f, + 6.40000000e+01f, + 9.05096680e+01f, + 1.28000000e+02f, + 1.81019336e+02f, + 2.56000000e+02f, + 3.62038672e+02f, + 5.12000000e+02f, + 7.24077344e+02f, + 1.02400000e+03f, + 1.44815469e+03f, + 2.04800000e+03f, + 2.89630938e+03f, + 4.09600000e+03f, + 5.79261875e+03f, + 8.19200000e+03f, + 1.15852375e+04f, + 1.63840000e+04f, + 2.31704750e+04f, + 3.27680000e+04f, + 4.63409500e+04f, + 6.55360000e+04f, + 9.26819000e+04f, + 1.31072000e+05f, + 1.85363800e+05f, + 2.62144000e+05f, + 3.70727600e+05f, + 5.24288000e+05f, + 7.41455200e+05f, + 1.04857600e+06f, + 1.48291040e+06f, + 2.09715200e+06f, + 2.96582080e+06f, + 4.19430400e+06f, + 5.93164160e+06f, + 8.38860800e+06f, + 1.18632832e+07f, + 1.67772160e+07f, + 2.37265664e+07f, + 3.35544320e+07f, + 4.74531328e+07f, + 6.71088640e+07f, + 9.49062656e+07f, + 1.34217728e+08f, + 1.89812531e+08f, + 2.68435456e+08f, + 3.79625062e+08f, + 5.36870912e+08f, + 7.59250125e+08f, + 1.07374182e+09f, + 1.51850025e+09f, + 2.14748365e+09f, + 3.03700050e+09f, + 4.29496730e+09f, +}; + +const int32_t c_aiQuantMaxValues[ALLOC_TABLE_SIZE] = { + 0, + 3, + 3, + 4, + 5, + 5, + 6, + 7, + 8, + 9, + 12, + 13, + 16, + 17, + 19, + 23, + 26, + 26, + 27, + 28, + 31, + 36, + 38, + 45, + 54, + 64, + 76, + 90, + 108, + 128, + 152, + 180, +}; + +const int32_t c_aiHuffmanDim[ALLOC_TABLE_SIZE] = { + 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, +}; + +const int32_t c_aiHuffmanMod[ALLOC_TABLE_SIZE] = { + 0, + 4, + 4, + 5, + 6, + 6, + 7, + 8, + 9, + 10, + 13, + 14, + 17, + 18, + 20, + 24, + 27, + 27, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, +}; + +const int32_t c_aiHuffmanSize[ALLOC_TABLE_SIZE] = { + 1, + 16, + 16, + 25, + 36, + 36, + 49, + 64, + 81, + 100, + 169, + 196, + 289, + 324, + 400, + 576, + 729, + 729, + 28, + 29, + 32, + 37, + 39, + 46, + 55, + 65, + 77, + 91, + 109, + 129, + 153, + 181, +}; + +const uint32_t c_aaiRMSEnvHuffEnc[64][2] = { + { 0x0014, 0x0000 }, + { 0x0014, 0x0001 }, + { 0x0014, 0x0002 }, + { 0x0014, 0x0003 }, + { 0x0014, 0x0004 }, + { 0x0014, 0x0005 }, + { 0x0013, 0x0003 }, + { 0x0013, 0x0004 }, + { 0x0013, 0x0005 }, + { 0x0013, 0x0006 }, + { 0x0013, 0x0007 }, + { 0x0012, 0x000b }, + { 0x000d, 0x0002 }, + { 0x000e, 0x0001 }, + { 0x000e, 0x0002 }, + { 0x000d, 0x0003 }, + { 0x000b, 0x0002 }, + { 0x000a, 0x0003 }, + { 0x000a, 0x0004 }, + { 0x000a, 0x0005 }, + { 0x0009, 0x0004 }, + { 0x0009, 0x0005 }, + { 0x0009, 0x0006 }, + { 0x0008, 0x0005 }, + { 0x0008, 0x0006 }, + { 0x0007, 0x0004 }, + { 0x0006, 0x0003 }, + { 0x0006, 0x0004 }, + { 0x0005, 0x0003 }, + { 0x0004, 0x0002 }, + { 0x0003, 0x0002 }, + { 0x0002, 0x0002 }, + { 0x0002, 0x0003 }, + { 0x0003, 0x0003 }, + { 0x0004, 0x0003 }, + { 0x0006, 0x0005 }, + { 0x0007, 0x0005 }, + { 0x0008, 0x0007 }, + { 0x0009, 0x0007 }, + { 0x0009, 0x0008 }, + { 0x0009, 0x0009 }, + { 0x000a, 0x0006 }, + { 0x000a, 0x0007 }, + { 0x000b, 0x0003 }, + { 0x000c, 0x0002 }, + { 0x000c, 0x0003 }, + { 0x000b, 0x0004 }, + { 0x000b, 0x0005 }, + { 0x000e, 0x0003 }, + { 0x0010, 0x0003 }, + { 0x0013, 0x0008 }, + { 0x0013, 0x0009 }, + { 0x0013, 0x000a }, + { 0x0013, 0x000b }, + { 0x0013, 0x000c }, + { 0x0013, 0x000d }, + { 0x0013, 0x000e }, + { 0x0013, 0x000f }, + { 0x0013, 0x0010 }, + { 0x0013, 0x0011 }, + { 0x0013, 0x0012 }, + { 0x0013, 0x0013 }, + { 0x0013, 0x0014 }, + { 0x0013, 0x0015 }, +}; + +const uint32_t c_aaiRMSEnvHuffDec[13][HUFF_DEC_TABLE_SIZE] = { + { + 0x0002ffff, + 0x0001ffff, + 0x0000001d, + 0x00000022, + 0x0001001e, + 0x0001001e, + 0x00010021, + 0x00010021, + 0x0002001f, + 0x0002001f, + 0x0002001f, + 0x0002001f, + 0x00020020, + 0x00020020, + 0x00020020, + 0x00020020, + }, + { + 0x0002001b, + 0x0002001b, + 0x0002001b, + 0x0002001b, + 0x00020023, + 0x00020023, + 0x00020023, + 0x00020023, + 0x0003001c, + 0x0003001c, + 0x0003001c, + 0x0003001c, + 0x0003001c, + 0x0003001c, + 0x0003001c, + 0x0003001c, + }, + { + 0x0006ffff, + 0x0007ffff, + 0x0003ffff, + 0x0004ffff, + 0x0005ffff, + 0x00000017, + 0x00000018, + 0x00000025, + 0x00010019, + 0x00010019, + 0x00010024, + 0x00010024, + 0x0002001a, + 0x0002001a, + 0x0002001a, + 0x0002001a, + }, + { + 0x00030014, + 0x00030014, + 0x00030014, + 0x00030014, + 0x00030014, + 0x00030014, + 0x00030014, + 0x00030014, + 0x00030015, + 0x00030015, + 0x00030015, + 0x00030015, + 0x00030015, + 0x00030015, + 0x00030015, + 0x00030015, + }, + { + 0x00030016, + 0x00030016, + 0x00030016, + 0x00030016, + 0x00030016, + 0x00030016, + 0x00030016, + 0x00030016, + 0x00030026, + 0x00030026, + 0x00030026, + 0x00030026, + 0x00030026, + 0x00030026, + 0x00030026, + 0x00030026, + }, + { + 0x00030027, + 0x00030027, + 0x00030027, + 0x00030027, + 0x00030027, + 0x00030027, + 0x00030027, + 0x00030027, + 0x00030028, + 0x00030028, + 0x00030028, + 0x00030028, + 0x00030028, + 0x00030028, + 0x00030028, + 0x00030028, + }, + { + 0x0009ffff, + 0x0008ffff, + 0x0000002c, + 0x0000002d, + 0x00010010, + 0x00010010, + 0x0001002b, + 0x0001002b, + 0x0001002e, + 0x0001002e, + 0x0001002f, + 0x0001002f, + 0x00020011, + 0x00020011, + 0x00020011, + 0x00020011, + }, + { + 0x00020012, + 0x00020012, + 0x00020012, + 0x00020012, + 0x00020013, + 0x00020013, + 0x00020013, + 0x00020013, + 0x00020029, + 0x00020029, + 0x00020029, + 0x00020029, + 0x0002002a, + 0x0002002a, + 0x0002002a, + 0x0002002a, + }, + { + 0x0003000c, + 0x0003000c, + 0x0003000c, + 0x0003000c, + 0x0003000c, + 0x0003000c, + 0x0003000c, + 0x0003000c, + 0x0003000f, + 0x0003000f, + 0x0003000f, + 0x0003000f, + 0x0003000f, + 0x0003000f, + 0x0003000f, + 0x0003000f, + }, + { + 0x000bffff, + 0x000cffff, + 0x000affff, + 0x00000031, + 0x0002000d, + 0x0002000d, + 0x0002000d, + 0x0002000d, + 0x0002000e, + 0x0002000e, + 0x0002000e, + 0x0002000e, + 0x00020030, + 0x00020030, + 0x00020030, + 0x00020030, + }, + { + 0x0001003a, + 0x0001003a, + 0x0001003b, + 0x0001003b, + 0x0001003c, + 0x0001003c, + 0x0001003d, + 0x0001003d, + 0x0001003e, + 0x0001003e, + 0x0001003f, + 0x0001003f, + 0x0002000b, + 0x0002000b, + 0x0002000b, + 0x0002000b, + }, + { + 0x00000000, + 0x00000001, + 0x00000002, + 0x00000003, + 0x00000004, + 0x00000005, + 0x00010006, + 0x00010006, + 0x00010007, + 0x00010007, + 0x00010008, + 0x00010008, + 0x00010009, + 0x00010009, + 0x0001000a, + 0x0001000a, + }, + { + 0x00010032, + 0x00010032, + 0x00010033, + 0x00010033, + 0x00010034, + 0x00010034, + 0x00010035, + 0x00010035, + 0x00010036, + 0x00010036, + 0x00010037, + 0x00010037, + 0x00010038, + 0x00010038, + 0x00010039, + 0x00010039, + }, +}; + +const uint16_t c_aauiLCLDHuffEnc1[16][2] = + { + { 0x0001, 0x0001 }, + { 0x0003, 0x0001 }, + { 0x0005, 0x0001 }, + { 0x000b, 0x0000 }, + { 0x0002, 0x0001 }, + { 0x0004, 0x0001 }, + { 0x0007, 0x0001 }, + { 0x000b, 0x0001 }, + { 0x0006, 0x0001 }, + { 0x0008, 0x0001 }, + { 0x000b, 0x0002 }, + { 0x000b, 0x0003 }, + { 0x000b, 0x0004 }, + { 0x000b, 0x0005 }, + { 0x000b, 0x0006 }, + { 0x000b, 0x0007 }, + }; + +const uint16_t c_aauiLCLDHuffEnc2[16][2] = + { + { 0x0001, 0x0001 }, + { 0x0003, 0x0001 }, + { 0x0005, 0x0001 }, + { 0x000c, 0x0000 }, + { 0x0002, 0x0001 }, + { 0x0004, 0x0001 }, + { 0x0007, 0x0001 }, + { 0x000c, 0x0001 }, + { 0x0006, 0x0001 }, + { 0x0008, 0x0001 }, + { 0x0009, 0x0001 }, + { 0x000c, 0x0002 }, + { 0x000c, 0x0003 }, + { 0x000c, 0x0004 }, + { 0x000c, 0x0005 }, + { 0x000b, 0x0003 }, + }; + +const uint16_t c_aauiLCLDHuffEnc3[25][2] = + { + { 0x0001, 0x0001 }, + { 0x0003, 0x0001 }, + { 0x0006, 0x0001 }, + { 0x000d, 0x0000 }, + { 0x000d, 0x0001 }, + { 0x0002, 0x0001 }, + { 0x0004, 0x0001 }, + { 0x0007, 0x0001 }, + { 0x000d, 0x0002 }, + { 0x000d, 0x0003 }, + { 0x0006, 0x0002 }, + { 0x0006, 0x0003 }, + { 0x0008, 0x0001 }, + { 0x000d, 0x0004 }, + { 0x000d, 0x0005 }, + { 0x0009, 0x0001 }, + { 0x000c, 0x0007 }, + { 0x000d, 0x0006 }, + { 0x000d, 0x0007 }, + { 0x000d, 0x0008 }, + { 0x000d, 0x0009 }, + { 0x000d, 0x000a }, + { 0x000d, 0x000b }, + { 0x000d, 0x000c }, + { 0x000d, 0x000d }, + + }; + +const uint16_t c_aauiLCLDHuffEnc4[36][2] = + { + { 0x0001, 0x0001 }, + { 0x0003, 0x0001 }, + { 0x0006, 0x0001 }, + { 0x000b, 0x0001 }, + { 0x0010, 0x0000 }, + { 0x0010, 0x0001 }, + { 0x0002, 0x0001 }, + { 0x0004, 0x0001 }, + { 0x0007, 0x0001 }, + { 0x000a, 0x0001 }, + { 0x0010, 0x0002 }, + { 0x0010, 0x0003 }, + { 0x0006, 0x0002 }, + { 0x0006, 0x0003 }, + { 0x0008, 0x0001 }, + { 0x000e, 0x0006 }, + { 0x0010, 0x0004 }, + { 0x0010, 0x0005 }, + { 0x000a, 0x0002 }, + { 0x000a, 0x0003 }, + { 0x000e, 0x0007 }, + { 0x0010, 0x0006 }, + { 0x0010, 0x0007 }, + { 0x0010, 0x0008 }, + { 0x0010, 0x0009 }, + { 0x0010, 0x000a }, + { 0x0010, 0x000b }, + { 0x0010, 0x000c }, + { 0x0010, 0x000d }, + { 0x0010, 0x000e }, + { 0x0010, 0x000f }, + { 0x0010, 0x0010 }, + { 0x0010, 0x0011 }, + { 0x000f, 0x0009 }, + { 0x000f, 0x000a }, + { 0x000f, 0x000b }, + + }; + +const uint16_t c_aauiLCLDHuffEnc5[36][2] = + { + { 0x0001, 0x0001 }, + { 0x0003, 0x0001 }, + { 0x0006, 0x0001 }, + { 0x000a, 0x0001 }, + { 0x000f, 0x0003 }, + { 0x0012, 0x0000 }, + { 0x0002, 0x0001 }, + { 0x0004, 0x0001 }, + { 0x0007, 0x0001 }, + { 0x000b, 0x0001 }, + { 0x0011, 0x0008 }, + { 0x0012, 0x0001 }, + { 0x0006, 0x0002 }, + { 0x0006, 0x0003 }, + { 0x0008, 0x0001 }, + { 0x000c, 0x0001 }, + { 0x0012, 0x0002 }, + { 0x0012, 0x0003 }, + { 0x000a, 0x0002 }, + { 0x000a, 0x0003 }, + { 0x000d, 0x0001 }, + { 0x0012, 0x0004 }, + { 0x0012, 0x0005 }, + { 0x0012, 0x0006 }, + { 0x0011, 0x0009 }, + { 0x0011, 0x000a }, + { 0x0012, 0x0007 }, + { 0x0012, 0x0008 }, + { 0x0012, 0x0009 }, + { 0x0012, 0x000a }, + { 0x0012, 0x000b }, + { 0x0012, 0x000c }, + { 0x0012, 0x000d }, + { 0x0012, 0x000e }, + { 0x0012, 0x000f }, + { 0x0011, 0x000b }, + + }; + +const uint16_t c_aauiLCLDHuffEnc6[49][2] = + { + { 0x0001, 0x0001 }, + { 0x0003, 0x0001 }, + { 0x0006, 0x0001 }, + { 0x000a, 0x0001 }, + { 0x0010, 0x0003 }, + { 0x0014, 0x0000 }, + { 0x0014, 0x0001 }, + { 0x0002, 0x0001 }, + { 0x0004, 0x0001 }, + { 0x0007, 0x0001 }, + { 0x000a, 0x0002 }, + { 0x0010, 0x0004 }, + { 0x0014, 0x0002 }, + { 0x0014, 0x0003 }, + { 0x0006, 0x0002 }, + { 0x0006, 0x0003 }, + { 0x0008, 0x0001 }, + { 0x000d, 0x0001 }, + { 0x0012, 0x0007 }, + { 0x0014, 0x0004 }, + { 0x0014, 0x0005 }, + { 0x000a, 0x0003 }, + { 0x000b, 0x0001 }, + { 0x000c, 0x0001 }, + { 0x0011, 0x0004 }, + { 0x0014, 0x0006 }, + { 0x0014, 0x0007 }, + { 0x0014, 0x0008 }, + { 0x0010, 0x0005 }, + { 0x000f, 0x0003 }, + { 0x0011, 0x0005 }, + { 0x0014, 0x0009 }, + { 0x0014, 0x000a }, + { 0x0014, 0x000b }, + { 0x0014, 0x000c }, + { 0x0014, 0x000d }, + { 0x0013, 0x000d }, + { 0x0014, 0x000e }, + { 0x0014, 0x000f }, + { 0x0014, 0x0010 }, + { 0x0014, 0x0011 }, + { 0x0014, 0x0012 }, + { 0x0014, 0x0013 }, + { 0x0014, 0x0014 }, + { 0x0014, 0x0015 }, + { 0x0014, 0x0016 }, + { 0x0014, 0x0017 }, + { 0x0014, 0x0018 }, + { 0x0014, 0x0019 }, + + }; + +const uint16_t c_aauiLCLDHuffEnc7[64][2] = + { + { 0x0002, 0x0001 }, + { 0x0002, 0x0002 }, + { 0x0005, 0x0001 }, + { 0x0009, 0x0001 }, + { 0x000f, 0x0002 }, + { 0x0015, 0x0000 }, + { 0x0015, 0x0001 }, + { 0x0015, 0x0002 }, + { 0x0002, 0x0003 }, + { 0x0003, 0x0001 }, + { 0x0006, 0x0001 }, + { 0x0009, 0x0002 }, + { 0x000f, 0x0003 }, + { 0x0014, 0x0011 }, + { 0x0015, 0x0003 }, + { 0x0015, 0x0004 }, + { 0x0005, 0x0002 }, + { 0x0005, 0x0003 }, + { 0x0007, 0x0001 }, + { 0x000b, 0x0001 }, + { 0x0010, 0x0002 }, + { 0x0015, 0x0005 }, + { 0x0015, 0x0006 }, + { 0x0015, 0x0007 }, + { 0x000a, 0x0001 }, + { 0x0009, 0x0003 }, + { 0x000c, 0x0001 }, + { 0x000f, 0x0004 }, + { 0x0012, 0x0006 }, + { 0x0015, 0x0008 }, + { 0x0015, 0x0009 }, + { 0x0015, 0x000a }, + { 0x000f, 0x0005 }, + { 0x000e, 0x0003 }, + { 0x0010, 0x0003 }, + { 0x0012, 0x0007 }, + { 0x0014, 0x0012 }, + { 0x0015, 0x000b }, + { 0x0015, 0x000c }, + { 0x0015, 0x000d }, + { 0x0014, 0x0013 }, + { 0x0014, 0x0014 }, + { 0x0013, 0x000b }, + { 0x0014, 0x0015 }, + { 0x0015, 0x000e }, + { 0x0015, 0x000f }, + { 0x0015, 0x0010 }, + { 0x0015, 0x0011 }, + { 0x0015, 0x0012 }, + { 0x0015, 0x0013 }, + { 0x0015, 0x0014 }, + { 0x0015, 0x0015 }, + { 0x0015, 0x0016 }, + { 0x0015, 0x0017 }, + { 0x0015, 0x0018 }, + { 0x0015, 0x0019 }, + { 0x0015, 0x001a }, + { 0x0015, 0x001b }, + { 0x0015, 0x001c }, + { 0x0015, 0x001d }, + { 0x0015, 0x001e }, + { 0x0015, 0x001f }, + { 0x0015, 0x0020 }, + { 0x0015, 0x0021 }, + }; + +const uint16_t c_aauiLCLDHuffEnc8[81][2] = + { + { 0x0001, 0x0001 }, + { 0x0003, 0x0001 }, + { 0x0006, 0x0001 }, + { 0x000a, 0x0001 }, + { 0x000f, 0x0002 }, + { 0x0014, 0x0008 }, + { 0x0017, 0x0000 }, + { 0x0017, 0x0001 }, + { 0x0017, 0x0002 }, + { 0x0003, 0x0002 }, + { 0x0003, 0x0003 }, + { 0x0005, 0x0001 }, + { 0x0009, 0x0001 }, + { 0x000f, 0x0003 }, + { 0x0012, 0x0004 }, + { 0x0015, 0x000d }, + { 0x0017, 0x0003 }, + { 0x0017, 0x0004 }, + { 0x0005, 0x0002 }, + { 0x0005, 0x0003 }, + { 0x0007, 0x0001 }, + { 0x000c, 0x0001 }, + { 0x0010, 0x0002 }, + { 0x0013, 0x0005 }, + { 0x0017, 0x0005 }, + { 0x0017, 0x0006 }, + { 0x0017, 0x0007 }, + { 0x0009, 0x0002 }, + { 0x0009, 0x0003 }, + { 0x000b, 0x0001 }, + { 0x000f, 0x0004 }, + { 0x0012, 0x0005 }, + { 0x0016, 0x0015 }, + { 0x0017, 0x0008 }, + { 0x0017, 0x0009 }, + { 0x0017, 0x000a }, + { 0x000f, 0x0005 }, + { 0x000e, 0x0003 }, + { 0x0010, 0x0003 }, + { 0x0012, 0x0006 }, + { 0x0014, 0x0009 }, + { 0x0017, 0x000b }, + { 0x0017, 0x000c }, + { 0x0017, 0x000d }, + { 0x0017, 0x000e }, + { 0x0013, 0x0006 }, + { 0x0012, 0x0007 }, + { 0x0013, 0x0007 }, + { 0x0015, 0x000e }, + { 0x0017, 0x000f }, + { 0x0017, 0x0010 }, + { 0x0017, 0x0011 }, + { 0x0017, 0x0012 }, + { 0x0017, 0x0013 }, + { 0x0016, 0x0016 }, + { 0x0016, 0x0017 }, + { 0x0015, 0x000f }, + { 0x0016, 0x0018 }, + { 0x0017, 0x0014 }, + { 0x0017, 0x0015 }, + { 0x0017, 0x0016 }, + { 0x0017, 0x0017 }, + { 0x0017, 0x0018 }, + { 0x0017, 0x0019 }, + { 0x0017, 0x001a }, + { 0x0017, 0x001b }, + { 0x0017, 0x001c }, + { 0x0017, 0x001d }, + { 0x0017, 0x001e }, + { 0x0017, 0x001f }, + { 0x0017, 0x0020 }, + { 0x0017, 0x0021 }, + { 0x0017, 0x0022 }, + { 0x0017, 0x0023 }, + { 0x0017, 0x0024 }, + { 0x0017, 0x0025 }, + { 0x0017, 0x0026 }, + { 0x0017, 0x0027 }, + { 0x0017, 0x0028 }, + { 0x0017, 0x0029 }, + { 0x0016, 0x0019 }, + + }; + +const uint16_t c_aauiLCLDHuffEnc9[100][2] = + { + { 0x0001, 0x0001 }, + { 0x0003, 0x0001 }, + { 0x0006, 0x0001 }, + { 0x0009, 0x0001 }, + { 0x000d, 0x0002 }, + { 0x0011, 0x0004 }, + { 0x0014, 0x000a }, + { 0x0017, 0x0000 }, + { 0x0017, 0x0001 }, + { 0x0017, 0x0002 }, + { 0x0003, 0x0002 }, + { 0x0003, 0x0003 }, + { 0x0005, 0x0001 }, + { 0x0009, 0x0002 }, + { 0x000d, 0x0003 }, + { 0x0010, 0x0004 }, + { 0x0013, 0x0007 }, + { 0x0016, 0x0018 }, + { 0x0017, 0x0003 }, + { 0x0017, 0x0004 }, + { 0x0005, 0x0002 }, + { 0x0005, 0x0003 }, + { 0x0008, 0x0002 }, + { 0x000b, 0x0002 }, + { 0x000e, 0x0002 }, + { 0x0011, 0x0005 }, + { 0x0014, 0x000b }, + { 0x0016, 0x0019 }, + { 0x0017, 0x0005 }, + { 0x0017, 0x0006 }, + { 0x0009, 0x0003 }, + { 0x0008, 0x0003 }, + { 0x000b, 0x0003 }, + { 0x000d, 0x0004 }, + { 0x0010, 0x0005 }, + { 0x0012, 0x0006 }, + { 0x0015, 0x000f }, + { 0x0017, 0x0007 }, + { 0x0017, 0x0008 }, + { 0x0017, 0x0009 }, + { 0x000d, 0x0005 }, + { 0x000c, 0x0003 }, + { 0x000e, 0x0003 }, + { 0x0010, 0x0006 }, + { 0x0012, 0x0007 }, + { 0x0014, 0x000c }, + { 0x0017, 0x000a }, + { 0x0016, 0x001a }, + { 0x0017, 0x000b }, + { 0x0017, 0x000c }, + { 0x0011, 0x0006 }, + { 0x0010, 0x0007 }, + { 0x0011, 0x0007 }, + { 0x0013, 0x0008 }, + { 0x0013, 0x0009 }, + { 0x0015, 0x0010 }, + { 0x0017, 0x000d }, + { 0x0017, 0x000e }, + { 0x0017, 0x000f }, + { 0x0017, 0x0010 }, + { 0x0013, 0x000a }, + { 0x0013, 0x000b }, + { 0x0014, 0x000d }, + { 0x0015, 0x0011 }, + { 0x0017, 0x0011 }, + { 0x0016, 0x001b }, + { 0x0017, 0x0012 }, + { 0x0017, 0x0013 }, + { 0x0017, 0x0014 }, + { 0x0017, 0x0015 }, + { 0x0017, 0x0016 }, + { 0x0015, 0x0012 }, + { 0x0015, 0x0013 }, + { 0x0017, 0x0017 }, + { 0x0016, 0x001c }, + { 0x0017, 0x0018 }, + { 0x0017, 0x0019 }, + { 0x0017, 0x001a }, + { 0x0017, 0x001b }, + { 0x0017, 0x001c }, + { 0x0017, 0x001d }, + { 0x0017, 0x001e }, + { 0x0017, 0x001f }, + { 0x0017, 0x0020 }, + { 0x0017, 0x0021 }, + { 0x0017, 0x0022 }, + { 0x0017, 0x0023 }, + { 0x0017, 0x0024 }, + { 0x0017, 0x0025 }, + { 0x0017, 0x0026 }, + { 0x0017, 0x0027 }, + { 0x0017, 0x0028 }, + { 0x0017, 0x0029 }, + { 0x0017, 0x002a }, + { 0x0017, 0x002b }, + { 0x0017, 0x002c }, + { 0x0017, 0x002d }, + { 0x0017, 0x002e }, + { 0x0017, 0x002f }, + { 0x0016, 0x001d }, + + }; + +const uint16_t c_aauiLCLDHuffEnc10[169][2] = + { + { 0x0001, 0x0001 }, + { 0x0004, 0x0002 }, + { 0x0005, 0x0002 }, + { 0x0007, 0x0002 }, + { 0x000a, 0x0002 }, + { 0x000e, 0x0004 }, + { 0x0011, 0x0007 }, + { 0x0013, 0x0012 }, + { 0x0016, 0x0000 }, + { 0x0016, 0x0001 }, + { 0x0016, 0x0002 }, + { 0x0016, 0x0003 }, + { 0x0016, 0x0004 }, + { 0x0004, 0x0003 }, + { 0x0003, 0x0003 }, + { 0x0004, 0x0004 }, + { 0x0007, 0x0003 }, + { 0x000a, 0x0003 }, + { 0x000d, 0x0004 }, + { 0x0010, 0x0007 }, + { 0x0013, 0x0013 }, + { 0x0015, 0x0035 }, + { 0x0016, 0x0005 }, + { 0x0016, 0x0006 }, + { 0x0016, 0x0007 }, + { 0x0016, 0x0008 }, + { 0x0005, 0x0003 }, + { 0x0004, 0x0005 }, + { 0x0006, 0x0003 }, + { 0x0008, 0x0002 }, + { 0x000b, 0x0002 }, + { 0x000e, 0x0005 }, + { 0x0010, 0x0008 }, + { 0x0013, 0x0014 }, + { 0x0014, 0x001d }, + { 0x0016, 0x0009 }, + { 0x0016, 0x000a }, + { 0x0016, 0x000b }, + { 0x0016, 0x000c }, + { 0x0007, 0x0004 }, + { 0x0007, 0x0005 }, + { 0x0008, 0x0003 }, + { 0x000a, 0x0004 }, + { 0x000d, 0x0005 }, + { 0x000f, 0x0005 }, + { 0x0011, 0x0008 }, + { 0x0014, 0x001e }, + { 0x0014, 0x001f }, + { 0x0016, 0x000d }, + { 0x0016, 0x000e }, + { 0x0016, 0x000f }, + { 0x0016, 0x0010 }, + { 0x000a, 0x0005 }, + { 0x0009, 0x0003 }, + { 0x000b, 0x0003 }, + { 0x000d, 0x0006 }, + { 0x000f, 0x0006 }, + { 0x0011, 0x0009 }, + { 0x0013, 0x0015 }, + { 0x0014, 0x0020 }, + { 0x0016, 0x0011 }, + { 0x0016, 0x0012 }, + { 0x0016, 0x0013 }, + { 0x0016, 0x0014 }, + { 0x0016, 0x0015 }, + { 0x000e, 0x0006 }, + { 0x000d, 0x0007 }, + { 0x000e, 0x0007 }, + { 0x000f, 0x0007 }, + { 0x0011, 0x000a }, + { 0x0012, 0x000c }, + { 0x0016, 0x0016 }, + { 0x0016, 0x0017 }, + { 0x0016, 0x0018 }, + { 0x0016, 0x0019 }, + { 0x0016, 0x001a }, + { 0x0016, 0x001b }, + { 0x0016, 0x001c }, + { 0x0011, 0x000b }, + { 0x0010, 0x0009 }, + { 0x0011, 0x000c }, + { 0x0011, 0x000d }, + { 0x0013, 0x0016 }, + { 0x0016, 0x001d }, + { 0x0016, 0x001e }, + { 0x0016, 0x001f }, + { 0x0016, 0x0020 }, + { 0x0016, 0x0021 }, + { 0x0016, 0x0022 }, + { 0x0016, 0x0023 }, + { 0x0016, 0x0024 }, + { 0x0014, 0x0021 }, + { 0x0014, 0x0022 }, + { 0x0012, 0x000d }, + { 0x0013, 0x0017 }, + { 0x0016, 0x0025 }, + { 0x0016, 0x0026 }, + { 0x0016, 0x0027 }, + { 0x0016, 0x0028 }, + { 0x0016, 0x0029 }, + { 0x0016, 0x002a }, + { 0x0016, 0x002b }, + { 0x0016, 0x002c }, + { 0x0016, 0x002d }, + { 0x0015, 0x0036 }, + { 0x0015, 0x0037 }, + { 0x0014, 0x0023 }, + { 0x0015, 0x0038 }, + { 0x0016, 0x002e }, + { 0x0016, 0x002f }, + { 0x0016, 0x0030 }, + { 0x0016, 0x0031 }, + { 0x0016, 0x0032 }, + { 0x0016, 0x0033 }, + { 0x0016, 0x0034 }, + { 0x0016, 0x0035 }, + { 0x0016, 0x0036 }, + { 0x0016, 0x0037 }, + { 0x0016, 0x0038 }, + { 0x0016, 0x0039 }, + { 0x0016, 0x003a }, + { 0x0016, 0x003b }, + { 0x0016, 0x003c }, + { 0x0016, 0x003d }, + { 0x0016, 0x003e }, + { 0x0016, 0x003f }, + { 0x0016, 0x0040 }, + { 0x0016, 0x0041 }, + { 0x0016, 0x0042 }, + { 0x0016, 0x0043 }, + { 0x0016, 0x0044 }, + { 0x0016, 0x0045 }, + { 0x0016, 0x0046 }, + { 0x0016, 0x0047 }, + { 0x0016, 0x0048 }, + { 0x0016, 0x0049 }, + { 0x0016, 0x004a }, + { 0x0016, 0x004b }, + { 0x0016, 0x004c }, + { 0x0016, 0x004d }, + { 0x0016, 0x004e }, + { 0x0016, 0x004f }, + { 0x0016, 0x0050 }, + { 0x0016, 0x0051 }, + { 0x0016, 0x0052 }, + { 0x0016, 0x0053 }, + { 0x0016, 0x0054 }, + { 0x0016, 0x0055 }, + { 0x0016, 0x0056 }, + { 0x0016, 0x0057 }, + { 0x0016, 0x0058 }, + { 0x0016, 0x0059 }, + { 0x0016, 0x005a }, + { 0x0016, 0x005b }, + { 0x0016, 0x005c }, + { 0x0016, 0x005d }, + { 0x0016, 0x005e }, + { 0x0016, 0x005f }, + { 0x0016, 0x0060 }, + { 0x0016, 0x0061 }, + { 0x0016, 0x0062 }, + { 0x0016, 0x0063 }, + { 0x0016, 0x0064 }, + { 0x0016, 0x0065 }, + { 0x0016, 0x0066 }, + { 0x0016, 0x0067 }, + { 0x0016, 0x0068 }, + { 0x0016, 0x0069 }, + { 0x0015, 0x0039 }, + + }; + +const uint16_t c_aauiLCLDHuffEnc11[196][2] = + { + { 0x0001, 0x0001 }, + { 0x0004, 0x0003 }, + { 0x0005, 0x0003 }, + { 0x0007, 0x0002 }, + { 0x0009, 0x0003 }, + { 0x000c, 0x0004 }, + { 0x000f, 0x0005 }, + { 0x0012, 0x000d }, + { 0x0014, 0x001f }, + { 0x0016, 0x0000 }, + { 0x0016, 0x0001 }, + { 0x0016, 0x0002 }, + { 0x0016, 0x0003 }, + { 0x0016, 0x0004 }, + { 0x0004, 0x0004 }, + { 0x0003, 0x0003 }, + { 0x0005, 0x0004 }, + { 0x0006, 0x0003 }, + { 0x0009, 0x0004 }, + { 0x000b, 0x0004 }, + { 0x000e, 0x0005 }, + { 0x0010, 0x0007 }, + { 0x0012, 0x000e }, + { 0x0014, 0x0020 }, + { 0x0016, 0x0005 }, + { 0x0016, 0x0006 }, + { 0x0016, 0x0007 }, + { 0x0016, 0x0008 }, + { 0x0005, 0x0005 }, + { 0x0004, 0x0005 }, + { 0x0006, 0x0004 }, + { 0x0007, 0x0003 }, + { 0x000a, 0x0004 }, + { 0x000c, 0x0005 }, + { 0x000e, 0x0006 }, + { 0x0011, 0x000a }, + { 0x0012, 0x000f }, + { 0x0015, 0x003b }, + { 0x0016, 0x0009 }, + { 0x0016, 0x000a }, + { 0x0016, 0x000b }, + { 0x0016, 0x000c }, + { 0x0007, 0x0004 }, + { 0x0006, 0x0005 }, + { 0x0007, 0x0005 }, + { 0x0009, 0x0005 }, + { 0x000b, 0x0005 }, + { 0x000d, 0x0005 }, + { 0x000f, 0x0006 }, + { 0x0012, 0x0010 }, + { 0x0014, 0x0021 }, + { 0x0016, 0x000d }, + { 0x0016, 0x000e }, + { 0x0016, 0x000f }, + { 0x0016, 0x0010 }, + { 0x0016, 0x0011 }, + { 0x0009, 0x0006 }, + { 0x0009, 0x0007 }, + { 0x000a, 0x0005 }, + { 0x000b, 0x0006 }, + { 0x000d, 0x0006 }, + { 0x000f, 0x0007 }, + { 0x0011, 0x000b }, + { 0x0013, 0x0017 }, + { 0x0014, 0x0022 }, + { 0x0016, 0x0012 }, + { 0x0016, 0x0013 }, + { 0x0016, 0x0014 }, + { 0x0016, 0x0015 }, + { 0x0016, 0x0016 }, + { 0x000c, 0x0006 }, + { 0x000b, 0x0007 }, + { 0x000c, 0x0007 }, + { 0x000d, 0x0007 }, + { 0x000e, 0x0007 }, + { 0x0010, 0x0008 }, + { 0x0012, 0x0011 }, + { 0x0014, 0x0023 }, + { 0x0015, 0x003c }, + { 0x0016, 0x0017 }, + { 0x0016, 0x0018 }, + { 0x0016, 0x0019 }, + { 0x0016, 0x001a }, + { 0x0016, 0x001b }, + { 0x000f, 0x0008 }, + { 0x000e, 0x0008 }, + { 0x000e, 0x0009 }, + { 0x000f, 0x0009 }, + { 0x0011, 0x000c }, + { 0x0013, 0x0018 }, + { 0x0014, 0x0024 }, + { 0x0016, 0x001c }, + { 0x0016, 0x001d }, + { 0x0016, 0x001e }, + { 0x0016, 0x001f }, + { 0x0016, 0x0020 }, + { 0x0016, 0x0021 }, + { 0x0016, 0x0022 }, + { 0x0011, 0x000d }, + { 0x0010, 0x0009 }, + { 0x0012, 0x0012 }, + { 0x0012, 0x0013 }, + { 0x0014, 0x0025 }, + { 0x0015, 0x003d }, + { 0x0014, 0x0026 }, + { 0x0016, 0x0023 }, + { 0x0016, 0x0024 }, + { 0x0016, 0x0025 }, + { 0x0016, 0x0026 }, + { 0x0016, 0x0027 }, + { 0x0016, 0x0028 }, + { 0x0016, 0x0029 }, + { 0x0014, 0x0027 }, + { 0x0013, 0x0019 }, + { 0x0014, 0x0028 }, + { 0x0014, 0x0029 }, + { 0x0014, 0x002a }, + { 0x0016, 0x002a }, + { 0x0016, 0x002b }, + { 0x0016, 0x002c }, + { 0x0016, 0x002d }, + { 0x0016, 0x002e }, + { 0x0016, 0x002f }, + { 0x0016, 0x0030 }, + { 0x0016, 0x0031 }, + { 0x0016, 0x0032 }, + { 0x0014, 0x002b }, + { 0x0014, 0x002c }, + { 0x0014, 0x002d }, + { 0x0016, 0x0033 }, + { 0x0016, 0x0034 }, + { 0x0016, 0x0035 }, + { 0x0016, 0x0036 }, + { 0x0016, 0x0037 }, + { 0x0016, 0x0038 }, + { 0x0016, 0x0039 }, + { 0x0016, 0x003a }, + { 0x0016, 0x003b }, + { 0x0016, 0x003c }, + { 0x0016, 0x003d }, + { 0x0016, 0x003e }, + { 0x0016, 0x003f }, + { 0x0016, 0x0040 }, + { 0x0016, 0x0041 }, + { 0x0016, 0x0042 }, + { 0x0016, 0x0043 }, + { 0x0016, 0x0044 }, + { 0x0016, 0x0045 }, + { 0x0016, 0x0046 }, + { 0x0016, 0x0047 }, + { 0x0016, 0x0048 }, + { 0x0016, 0x0049 }, + { 0x0016, 0x004a }, + { 0x0016, 0x004b }, + { 0x0016, 0x004c }, + { 0x0016, 0x004d }, + { 0x0016, 0x004e }, + { 0x0016, 0x004f }, + { 0x0016, 0x0050 }, + { 0x0016, 0x0051 }, + { 0x0016, 0x0052 }, + { 0x0016, 0x0053 }, + { 0x0016, 0x0054 }, + { 0x0016, 0x0055 }, + { 0x0016, 0x0056 }, + { 0x0016, 0x0057 }, + { 0x0016, 0x0058 }, + { 0x0016, 0x0059 }, + { 0x0016, 0x005a }, + { 0x0016, 0x005b }, + { 0x0016, 0x005c }, + { 0x0016, 0x005d }, + { 0x0016, 0x005e }, + { 0x0016, 0x005f }, + { 0x0016, 0x0060 }, + { 0x0016, 0x0061 }, + { 0x0016, 0x0062 }, + { 0x0016, 0x0063 }, + { 0x0016, 0x0064 }, + { 0x0016, 0x0065 }, + { 0x0016, 0x0066 }, + { 0x0016, 0x0067 }, + { 0x0016, 0x0068 }, + { 0x0016, 0x0069 }, + { 0x0016, 0x006a }, + { 0x0016, 0x006b }, + { 0x0016, 0x006c }, + { 0x0016, 0x006d }, + { 0x0016, 0x006e }, + { 0x0016, 0x006f }, + { 0x0016, 0x0070 }, + { 0x0016, 0x0071 }, + { 0x0016, 0x0072 }, + { 0x0016, 0x0073 }, + { 0x0016, 0x0074 }, + { 0x0016, 0x0075 }, + + }; + +const uint16_t c_aauiLCLDHuffEnc12[289][2] = + { + { 0x0001, 0x0001 }, + { 0x0004, 0x0004 }, + { 0x0005, 0x0004 }, + { 0x0007, 0x0004 }, + { 0x0008, 0x0002 }, + { 0x000b, 0x0004 }, + { 0x000e, 0x0006 }, + { 0x0010, 0x0009 }, + { 0x0012, 0x0014 }, + { 0x0013, 0x001f }, + { 0x0016, 0x0000 }, + { 0x0016, 0x0001 }, + { 0x0016, 0x0002 }, + { 0x0016, 0x0003 }, + { 0x0016, 0x0004 }, + { 0x0016, 0x0005 }, + { 0x0016, 0x0006 }, + { 0x0004, 0x0005 }, + { 0x0004, 0x0006 }, + { 0x0005, 0x0005 }, + { 0x0006, 0x0003 }, + { 0x0008, 0x0003 }, + { 0x000a, 0x0004 }, + { 0x000d, 0x0006 }, + { 0x000f, 0x0008 }, + { 0x0011, 0x000c }, + { 0x0013, 0x0020 }, + { 0x0016, 0x0007 }, + { 0x0015, 0x0063 }, + { 0x0016, 0x0008 }, + { 0x0016, 0x0009 }, + { 0x0016, 0x000a }, + { 0x0016, 0x000b }, + { 0x0016, 0x000c }, + { 0x0005, 0x0006 }, + { 0x0004, 0x0007 }, + { 0x0005, 0x0007 }, + { 0x0006, 0x0004 }, + { 0x0008, 0x0004 }, + { 0x000b, 0x0005 }, + { 0x000d, 0x0007 }, + { 0x0010, 0x000a }, + { 0x0012, 0x0015 }, + { 0x0015, 0x0064 }, + { 0x0016, 0x000d }, + { 0x0016, 0x000e }, + { 0x0016, 0x000f }, + { 0x0016, 0x0010 }, + { 0x0016, 0x0011 }, + { 0x0016, 0x0012 }, + { 0x0016, 0x0013 }, + { 0x0006, 0x0005 }, + { 0x0006, 0x0006 }, + { 0x0006, 0x0007 }, + { 0x0008, 0x0005 }, + { 0x000a, 0x0005 }, + { 0x000c, 0x0005 }, + { 0x000e, 0x0007 }, + { 0x0010, 0x000b }, + { 0x0012, 0x0016 }, + { 0x0014, 0x0037 }, + { 0x0015, 0x0065 }, + { 0x0016, 0x0014 }, + { 0x0016, 0x0015 }, + { 0x0016, 0x0016 }, + { 0x0016, 0x0017 }, + { 0x0016, 0x0018 }, + { 0x0016, 0x0019 }, + { 0x0008, 0x0006 }, + { 0x0007, 0x0005 }, + { 0x0008, 0x0007 }, + { 0x000a, 0x0006 }, + { 0x000c, 0x0006 }, + { 0x000e, 0x0008 }, + { 0x0010, 0x000c }, + { 0x0011, 0x000d }, + { 0x0013, 0x0021 }, + { 0x0015, 0x0066 }, + { 0x0016, 0x001a }, + { 0x0016, 0x001b }, + { 0x0016, 0x001c }, + { 0x0016, 0x001d }, + { 0x0016, 0x001e }, + { 0x0016, 0x001f }, + { 0x0016, 0x0020 }, + { 0x000b, 0x0006 }, + { 0x000a, 0x0007 }, + { 0x000b, 0x0007 }, + { 0x000c, 0x0007 }, + { 0x000e, 0x0009 }, + { 0x000f, 0x0009 }, + { 0x0011, 0x000e }, + { 0x0013, 0x0022 }, + { 0x0015, 0x0067 }, + { 0x0015, 0x0068 }, + { 0x0016, 0x0021 }, + { 0x0016, 0x0022 }, + { 0x0016, 0x0023 }, + { 0x0016, 0x0024 }, + { 0x0016, 0x0025 }, + { 0x0016, 0x0026 }, + { 0x0016, 0x0027 }, + { 0x000e, 0x000a }, + { 0x000d, 0x0008 }, + { 0x000d, 0x0009 }, + { 0x000e, 0x000b }, + { 0x000f, 0x000a }, + { 0x0011, 0x000f }, + { 0x0013, 0x0023 }, + { 0x0014, 0x0038 }, + { 0x0016, 0x0028 }, + { 0x0016, 0x0029 }, + { 0x0016, 0x002a }, + { 0x0016, 0x002b }, + { 0x0016, 0x002c }, + { 0x0016, 0x002d }, + { 0x0016, 0x002e }, + { 0x0016, 0x002f }, + { 0x0016, 0x0030 }, + { 0x0010, 0x000d }, + { 0x000f, 0x000b }, + { 0x0010, 0x000e }, + { 0x0010, 0x000f }, + { 0x0012, 0x0017 }, + { 0x0013, 0x0024 }, + { 0x0014, 0x0039 }, + { 0x0016, 0x0031 }, + { 0x0016, 0x0032 }, + { 0x0016, 0x0033 }, + { 0x0016, 0x0034 }, + { 0x0016, 0x0035 }, + { 0x0016, 0x0036 }, + { 0x0016, 0x0037 }, + { 0x0016, 0x0038 }, + { 0x0016, 0x0039 }, + { 0x0016, 0x003a }, + { 0x0013, 0x0025 }, + { 0x0011, 0x0010 }, + { 0x0011, 0x0011 }, + { 0x0013, 0x0026 }, + { 0x0013, 0x0027 }, + { 0x0014, 0x003a }, + { 0x0014, 0x003b }, + { 0x0016, 0x003b }, + { 0x0016, 0x003c }, + { 0x0016, 0x003d }, + { 0x0016, 0x003e }, + { 0x0016, 0x003f }, + { 0x0016, 0x0040 }, + { 0x0016, 0x0041 }, + { 0x0016, 0x0042 }, + { 0x0016, 0x0043 }, + { 0x0016, 0x0044 }, + { 0x0015, 0x0069 }, + { 0x0014, 0x003c }, + { 0x0014, 0x003d }, + { 0x0015, 0x006a }, + { 0x0015, 0x006b }, + { 0x0015, 0x006c }, + { 0x0016, 0x0045 }, + { 0x0016, 0x0046 }, + { 0x0016, 0x0047 }, + { 0x0016, 0x0048 }, + { 0x0016, 0x0049 }, + { 0x0016, 0x004a }, + { 0x0016, 0x004b }, + { 0x0016, 0x004c }, + { 0x0016, 0x004d }, + { 0x0016, 0x004e }, + { 0x0016, 0x004f }, + { 0x0016, 0x0050 }, + { 0x0016, 0x0051 }, + { 0x0015, 0x006d }, + { 0x0016, 0x0052 }, + { 0x0016, 0x0053 }, + { 0x0016, 0x0054 }, + { 0x0016, 0x0055 }, + { 0x0016, 0x0056 }, + { 0x0016, 0x0057 }, + { 0x0016, 0x0058 }, + { 0x0016, 0x0059 }, + { 0x0016, 0x005a }, + { 0x0016, 0x005b }, + { 0x0016, 0x005c }, + { 0x0016, 0x005d }, + { 0x0016, 0x005e }, + { 0x0016, 0x005f }, + { 0x0016, 0x0060 }, + { 0x0016, 0x0061 }, + { 0x0016, 0x0062 }, + { 0x0016, 0x0063 }, + { 0x0016, 0x0064 }, + { 0x0016, 0x0065 }, + { 0x0016, 0x0066 }, + { 0x0016, 0x0067 }, + { 0x0016, 0x0068 }, + { 0x0016, 0x0069 }, + { 0x0016, 0x006a }, + { 0x0016, 0x006b }, + { 0x0016, 0x006c }, + { 0x0016, 0x006d }, + { 0x0016, 0x006e }, + { 0x0016, 0x006f }, + { 0x0016, 0x0070 }, + { 0x0016, 0x0071 }, + { 0x0016, 0x0072 }, + { 0x0016, 0x0073 }, + { 0x0016, 0x0074 }, + { 0x0016, 0x0075 }, + { 0x0016, 0x0076 }, + { 0x0016, 0x0077 }, + { 0x0016, 0x0078 }, + { 0x0016, 0x0079 }, + { 0x0016, 0x007a }, + { 0x0016, 0x007b }, + { 0x0016, 0x007c }, + { 0x0016, 0x007d }, + { 0x0016, 0x007e }, + { 0x0016, 0x007f }, + { 0x0016, 0x0080 }, + { 0x0016, 0x0081 }, + { 0x0016, 0x0082 }, + { 0x0016, 0x0083 }, + { 0x0016, 0x0084 }, + { 0x0016, 0x0085 }, + { 0x0016, 0x0086 }, + { 0x0016, 0x0087 }, + { 0x0016, 0x0088 }, + { 0x0016, 0x0089 }, + { 0x0016, 0x008a }, + { 0x0016, 0x008b }, + { 0x0016, 0x008c }, + { 0x0016, 0x008d }, + { 0x0016, 0x008e }, + { 0x0016, 0x008f }, + { 0x0016, 0x0090 }, + { 0x0016, 0x0091 }, + { 0x0016, 0x0092 }, + { 0x0016, 0x0093 }, + { 0x0016, 0x0094 }, + { 0x0016, 0x0095 }, + { 0x0016, 0x0096 }, + { 0x0016, 0x0097 }, + { 0x0016, 0x0098 }, + { 0x0016, 0x0099 }, + { 0x0016, 0x009a }, + { 0x0016, 0x009b }, + { 0x0016, 0x009c }, + { 0x0016, 0x009d }, + { 0x0016, 0x009e }, + { 0x0016, 0x009f }, + { 0x0016, 0x00a0 }, + { 0x0016, 0x00a1 }, + { 0x0016, 0x00a2 }, + { 0x0016, 0x00a3 }, + { 0x0016, 0x00a4 }, + { 0x0016, 0x00a5 }, + { 0x0016, 0x00a6 }, + { 0x0016, 0x00a7 }, + { 0x0016, 0x00a8 }, + { 0x0016, 0x00a9 }, + { 0x0016, 0x00aa }, + { 0x0016, 0x00ab }, + { 0x0016, 0x00ac }, + { 0x0016, 0x00ad }, + { 0x0016, 0x00ae }, + { 0x0016, 0x00af }, + { 0x0016, 0x00b0 }, + { 0x0016, 0x00b1 }, + { 0x0016, 0x00b2 }, + { 0x0016, 0x00b3 }, + { 0x0016, 0x00b4 }, + { 0x0016, 0x00b5 }, + { 0x0016, 0x00b6 }, + { 0x0016, 0x00b7 }, + { 0x0016, 0x00b8 }, + { 0x0016, 0x00b9 }, + { 0x0016, 0x00ba }, + { 0x0016, 0x00bb }, + { 0x0016, 0x00bc }, + { 0x0016, 0x00bd }, + { 0x0016, 0x00be }, + { 0x0016, 0x00bf }, + { 0x0016, 0x00c0 }, + { 0x0016, 0x00c1 }, + { 0x0016, 0x00c2 }, + { 0x0016, 0x00c3 }, + { 0x0016, 0x00c4 }, + { 0x0016, 0x00c5 }, + + }; + +const uint16_t c_aauiLCLDHuffEnc13[324][2] = + { + { 0x0004, 0x0006 }, + { 0x0004, 0x0007 }, + { 0x0005, 0x0005 }, + { 0x0005, 0x0006 }, + { 0x0006, 0x0004 }, + { 0x0008, 0x0005 }, + { 0x000a, 0x0005 }, + { 0x000c, 0x0007 }, + { 0x000e, 0x000b }, + { 0x0010, 0x0011 }, + { 0x0012, 0x002d }, + { 0x0015, 0x0000 }, + { 0x0014, 0x0035 }, + { 0x0015, 0x0001 }, + { 0x0015, 0x0002 }, + { 0x0015, 0x0003 }, + { 0x0015, 0x0004 }, + { 0x0015, 0x0005 }, + { 0x0004, 0x0008 }, + { 0x0003, 0x0007 }, + { 0x0004, 0x0009 }, + { 0x0004, 0x000a }, + { 0x0006, 0x0005 }, + { 0x0008, 0x0006 }, + { 0x0009, 0x0006 }, + { 0x000c, 0x0008 }, + { 0x000d, 0x0009 }, + { 0x0010, 0x0012 }, + { 0x0011, 0x001a }, + { 0x0015, 0x0006 }, + { 0x0015, 0x0007 }, + { 0x0015, 0x0008 }, + { 0x0015, 0x0009 }, + { 0x0015, 0x000a }, + { 0x0015, 0x000b }, + { 0x0015, 0x000c }, + { 0x0005, 0x0007 }, + { 0x0004, 0x000b }, + { 0x0004, 0x000c }, + { 0x0005, 0x0008 }, + { 0x0006, 0x0006 }, + { 0x0008, 0x0007 }, + { 0x000a, 0x0006 }, + { 0x000c, 0x0009 }, + { 0x000e, 0x000c }, + { 0x0010, 0x0013 }, + { 0x0012, 0x002e }, + { 0x0015, 0x000d }, + { 0x0015, 0x000e }, + { 0x0015, 0x000f }, + { 0x0015, 0x0010 }, + { 0x0015, 0x0011 }, + { 0x0015, 0x0012 }, + { 0x0015, 0x0013 }, + { 0x0005, 0x0009 }, + { 0x0004, 0x000d }, + { 0x0005, 0x000a }, + { 0x0006, 0x0007 }, + { 0x0007, 0x0005 }, + { 0x0009, 0x0007 }, + { 0x000b, 0x0008 }, + { 0x000d, 0x000a }, + { 0x000f, 0x000e }, + { 0x0010, 0x0014 }, + { 0x0011, 0x001b }, + { 0x0014, 0x0036 }, + { 0x0015, 0x0014 }, + { 0x0015, 0x0015 }, + { 0x0015, 0x0016 }, + { 0x0015, 0x0017 }, + { 0x0015, 0x0018 }, + { 0x0015, 0x0019 }, + { 0x0006, 0x0008 }, + { 0x0005, 0x000b }, + { 0x0006, 0x0009 }, + { 0x0007, 0x0006 }, + { 0x0009, 0x0008 }, + { 0x000a, 0x0007 }, + { 0x000c, 0x000a }, + { 0x000e, 0x000d }, + { 0x0010, 0x0015 }, + { 0x0011, 0x001c }, + { 0x0013, 0x0053 }, + { 0x0015, 0x001a }, + { 0x0015, 0x001b }, + { 0x0015, 0x001c }, + { 0x0015, 0x001d }, + { 0x0015, 0x001e }, + { 0x0015, 0x001f }, + { 0x0015, 0x0020 }, + { 0x0008, 0x0008 }, + { 0x0007, 0x0007 }, + { 0x0008, 0x0009 }, + { 0x0009, 0x0009 }, + { 0x000a, 0x0008 }, + { 0x000c, 0x000b }, + { 0x000d, 0x000b }, + { 0x000f, 0x000f }, + { 0x0010, 0x0016 }, + { 0x0011, 0x001d }, + { 0x0014, 0x0037 }, + { 0x0015, 0x0021 }, + { 0x0015, 0x0022 }, + { 0x0015, 0x0023 }, + { 0x0015, 0x0024 }, + { 0x0015, 0x0025 }, + { 0x0015, 0x0026 }, + { 0x0015, 0x0027 }, + { 0x000a, 0x0009 }, + { 0x000a, 0x000a }, + { 0x000a, 0x000b }, + { 0x000b, 0x0009 }, + { 0x000c, 0x000c }, + { 0x000d, 0x000c }, + { 0x000f, 0x0010 }, + { 0x0010, 0x0017 }, + { 0x0012, 0x002f }, + { 0x0015, 0x0028 }, + { 0x0015, 0x0029 }, + { 0x0015, 0x002a }, + { 0x0015, 0x002b }, + { 0x0015, 0x002c }, + { 0x0015, 0x002d }, + { 0x0015, 0x002e }, + { 0x0015, 0x002f }, + { 0x0015, 0x0030 }, + { 0x000c, 0x000d }, + { 0x000c, 0x000e }, + { 0x000c, 0x000f }, + { 0x000d, 0x000d }, + { 0x000e, 0x000e }, + { 0x000f, 0x0011 }, + { 0x0010, 0x0018 }, + { 0x0011, 0x001e }, + { 0x0014, 0x0038 }, + { 0x0015, 0x0031 }, + { 0x0015, 0x0032 }, + { 0x0015, 0x0033 }, + { 0x0015, 0x0034 }, + { 0x0015, 0x0035 }, + { 0x0015, 0x0036 }, + { 0x0015, 0x0037 }, + { 0x0015, 0x0038 }, + { 0x0015, 0x0039 }, + { 0x000f, 0x0012 }, + { 0x000e, 0x000f }, + { 0x000e, 0x0010 }, + { 0x000e, 0x0011 }, + { 0x000f, 0x0013 }, + { 0x0010, 0x0019 }, + { 0x0011, 0x001f }, + { 0x0013, 0x0054 }, + { 0x0015, 0x003a }, + { 0x0014, 0x0039 }, + { 0x0015, 0x003b }, + { 0x0015, 0x003c }, + { 0x0015, 0x003d }, + { 0x0015, 0x003e }, + { 0x0015, 0x003f }, + { 0x0015, 0x0040 }, + { 0x0015, 0x0041 }, + { 0x0015, 0x0042 }, + { 0x0010, 0x001a }, + { 0x000f, 0x0014 }, + { 0x000f, 0x0015 }, + { 0x0010, 0x001b }, + { 0x0011, 0x0020 }, + { 0x0012, 0x0030 }, + { 0x0013, 0x0055 }, + { 0x0015, 0x0043 }, + { 0x0015, 0x0044 }, + { 0x0014, 0x003a }, + { 0x0015, 0x0045 }, + { 0x0015, 0x0046 }, + { 0x0015, 0x0047 }, + { 0x0015, 0x0048 }, + { 0x0015, 0x0049 }, + { 0x0015, 0x004a }, + { 0x0015, 0x004b }, + { 0x0015, 0x004c }, + { 0x0012, 0x0031 }, + { 0x0011, 0x0021 }, + { 0x0013, 0x0056 }, + { 0x0013, 0x0057 }, + { 0x0012, 0x0032 }, + { 0x0015, 0x004d }, + { 0x0015, 0x004e }, + { 0x0015, 0x004f }, + { 0x0015, 0x0050 }, + { 0x0015, 0x0051 }, + { 0x0015, 0x0052 }, + { 0x0015, 0x0053 }, + { 0x0015, 0x0054 }, + { 0x0015, 0x0055 }, + { 0x0015, 0x0056 }, + { 0x0015, 0x0057 }, + { 0x0015, 0x0058 }, + { 0x0015, 0x0059 }, + { 0x0015, 0x005a }, + { 0x0014, 0x003b }, + { 0x0012, 0x0033 }, + { 0x0013, 0x0058 }, + { 0x0013, 0x0059 }, + { 0x0015, 0x005b }, + { 0x0015, 0x005c }, + { 0x0015, 0x005d }, + { 0x0015, 0x005e }, + { 0x0015, 0x005f }, + { 0x0015, 0x0060 }, + { 0x0015, 0x0061 }, + { 0x0015, 0x0062 }, + { 0x0015, 0x0063 }, + { 0x0015, 0x0064 }, + { 0x0015, 0x0065 }, + { 0x0015, 0x0066 }, + { 0x0015, 0x0067 }, + { 0x0015, 0x0068 }, + { 0x0015, 0x0069 }, + { 0x0014, 0x003c }, + { 0x0014, 0x003d }, + { 0x0014, 0x003e }, + { 0x0014, 0x003f }, + { 0x0014, 0x0040 }, + { 0x0014, 0x0041 }, + { 0x0014, 0x0042 }, + { 0x0014, 0x0043 }, + { 0x0014, 0x0044 }, + { 0x0014, 0x0045 }, + { 0x0014, 0x0046 }, + { 0x0014, 0x0047 }, + { 0x0014, 0x0048 }, + { 0x0014, 0x0049 }, + { 0x0014, 0x004a }, + { 0x0014, 0x004b }, + { 0x0014, 0x004c }, + { 0x0014, 0x004d }, + { 0x0014, 0x004e }, + { 0x0014, 0x004f }, + { 0x0014, 0x0050 }, + { 0x0014, 0x0051 }, + { 0x0014, 0x0052 }, + { 0x0014, 0x0053 }, + { 0x0014, 0x0054 }, + { 0x0014, 0x0055 }, + { 0x0014, 0x0056 }, + { 0x0014, 0x0057 }, + { 0x0014, 0x0058 }, + { 0x0014, 0x0059 }, + { 0x0014, 0x005a }, + { 0x0014, 0x005b }, + { 0x0014, 0x005c }, + { 0x0014, 0x005d }, + { 0x0014, 0x005e }, + { 0x0014, 0x005f }, + { 0x0014, 0x0060 }, + { 0x0014, 0x0061 }, + { 0x0014, 0x0062 }, + { 0x0014, 0x0063 }, + { 0x0014, 0x0064 }, + { 0x0014, 0x0065 }, + { 0x0014, 0x0066 }, + { 0x0014, 0x0067 }, + { 0x0014, 0x0068 }, + { 0x0014, 0x0069 }, + { 0x0014, 0x006a }, + { 0x0014, 0x006b }, + { 0x0014, 0x006c }, + { 0x0014, 0x006d }, + { 0x0014, 0x006e }, + { 0x0014, 0x006f }, + { 0x0014, 0x0070 }, + { 0x0014, 0x0071 }, + { 0x0014, 0x0072 }, + { 0x0014, 0x0073 }, + { 0x0014, 0x0074 }, + { 0x0014, 0x0075 }, + { 0x0014, 0x0076 }, + { 0x0014, 0x0077 }, + { 0x0014, 0x0078 }, + { 0x0014, 0x0079 }, + { 0x0014, 0x007a }, + { 0x0014, 0x007b }, + { 0x0014, 0x007c }, + { 0x0014, 0x007d }, + { 0x0014, 0x007e }, + { 0x0014, 0x007f }, + { 0x0014, 0x0080 }, + { 0x0014, 0x0081 }, + { 0x0014, 0x0082 }, + { 0x0014, 0x0083 }, + { 0x0014, 0x0084 }, + { 0x0014, 0x0085 }, + { 0x0014, 0x0086 }, + { 0x0014, 0x0087 }, + { 0x0014, 0x0088 }, + { 0x0014, 0x0089 }, + { 0x0014, 0x008a }, + { 0x0014, 0x008b }, + { 0x0014, 0x008c }, + { 0x0014, 0x008d }, + { 0x0014, 0x008e }, + { 0x0014, 0x008f }, + { 0x0014, 0x0090 }, + { 0x0014, 0x0091 }, + { 0x0014, 0x0092 }, + { 0x0014, 0x0093 }, + { 0x0014, 0x0094 }, + { 0x0014, 0x0095 }, + { 0x0014, 0x0096 }, + { 0x0014, 0x0097 }, + { 0x0014, 0x0098 }, + { 0x0014, 0x0099 }, + { 0x0014, 0x009a }, + { 0x0014, 0x009b }, + { 0x0014, 0x009c }, + { 0x0014, 0x009d }, + { 0x0014, 0x009e }, + { 0x0014, 0x009f }, + { 0x0014, 0x00a0 }, + { 0x0014, 0x00a1 }, + { 0x0014, 0x00a2 }, + { 0x0014, 0x00a3 }, + { 0x0014, 0x00a4 }, + { 0x0014, 0x00a5 }, + + }; + +const uint16_t c_aauiLCLDHuffEnc14[400][2] = + { + { 0x0005, 0x0007 }, + { 0x0004, 0x0009 }, + { 0x0005, 0x0008 }, + { 0x0005, 0x0009 }, + { 0x0006, 0x0006 }, + { 0x0007, 0x0006 }, + { 0x0009, 0x0007 }, + { 0x000b, 0x0008 }, + { 0x000d, 0x000c }, + { 0x000f, 0x0013 }, + { 0x0010, 0x001b }, + { 0x0013, 0x0082 }, + { 0x0013, 0x0083 }, + { 0x0014, 0x0000 }, + { 0x0014, 0x0001 }, + { 0x0014, 0x0002 }, + { 0x0014, 0x0003 }, + { 0x0014, 0x0004 }, + { 0x0014, 0x0005 }, + { 0x0014, 0x0006 }, + { 0x0004, 0x000a }, + { 0x0004, 0x000b }, + { 0x0004, 0x000c }, + { 0x0005, 0x000a }, + { 0x0005, 0x000b }, + { 0x0006, 0x0007 }, + { 0x0008, 0x0006 }, + { 0x000a, 0x0007 }, + { 0x000c, 0x000a }, + { 0x000e, 0x000e }, + { 0x000f, 0x0014 }, + { 0x0011, 0x002a }, + { 0x0012, 0x004a }, + { 0x0013, 0x0084 }, + { 0x0014, 0x0007 }, + { 0x0014, 0x0008 }, + { 0x0014, 0x0009 }, + { 0x0014, 0x000a }, + { 0x0014, 0x000b }, + { 0x0014, 0x000c }, + { 0x0005, 0x000c }, + { 0x0004, 0x000d }, + { 0x0004, 0x000e }, + { 0x0005, 0x000d }, + { 0x0006, 0x0008 }, + { 0x0007, 0x0007 }, + { 0x0008, 0x0007 }, + { 0x000a, 0x0008 }, + { 0x000c, 0x000b }, + { 0x000e, 0x000f }, + { 0x000f, 0x0015 }, + { 0x0012, 0x004b }, + { 0x0013, 0x0085 }, + { 0x0014, 0x000d }, + { 0x0014, 0x000e }, + { 0x0014, 0x000f }, + { 0x0014, 0x0010 }, + { 0x0014, 0x0011 }, + { 0x0014, 0x0012 }, + { 0x0014, 0x0013 }, + { 0x0005, 0x000e }, + { 0x0004, 0x000f }, + { 0x0005, 0x000f }, + { 0x0005, 0x0010 }, + { 0x0006, 0x0009 }, + { 0x0008, 0x0008 }, + { 0x0009, 0x0008 }, + { 0x000b, 0x0009 }, + { 0x000d, 0x000d }, + { 0x000e, 0x0010 }, + { 0x0010, 0x001c }, + { 0x0011, 0x002b }, + { 0x0014, 0x0014 }, + { 0x0014, 0x0015 }, + { 0x0014, 0x0016 }, + { 0x0014, 0x0017 }, + { 0x0014, 0x0018 }, + { 0x0014, 0x0019 }, + { 0x0014, 0x001a }, + { 0x0014, 0x001b }, + { 0x0006, 0x000a }, + { 0x0005, 0x0011 }, + { 0x0006, 0x000b }, + { 0x0006, 0x000c }, + { 0x0007, 0x0008 }, + { 0x0008, 0x0009 }, + { 0x000a, 0x0009 }, + { 0x000c, 0x000c }, + { 0x000e, 0x0011 }, + { 0x000f, 0x0016 }, + { 0x0010, 0x001d }, + { 0x0012, 0x004c }, + { 0x0014, 0x001c }, + { 0x0014, 0x001d }, + { 0x0014, 0x001e }, + { 0x0014, 0x001f }, + { 0x0014, 0x0020 }, + { 0x0014, 0x0021 }, + { 0x0014, 0x0022 }, + { 0x0014, 0x0023 }, + { 0x0007, 0x0009 }, + { 0x0006, 0x000d }, + { 0x0007, 0x000a }, + { 0x0007, 0x000b }, + { 0x0009, 0x0009 }, + { 0x000a, 0x000a }, + { 0x000b, 0x000a }, + { 0x000d, 0x000e }, + { 0x000f, 0x0017 }, + { 0x0011, 0x002c }, + { 0x0010, 0x001e }, + { 0x0014, 0x0024 }, + { 0x0014, 0x0025 }, + { 0x0014, 0x0026 }, + { 0x0014, 0x0027 }, + { 0x0014, 0x0028 }, + { 0x0014, 0x0029 }, + { 0x0014, 0x002a }, + { 0x0014, 0x002b }, + { 0x0014, 0x002c }, + { 0x0009, 0x000a }, + { 0x0008, 0x000a }, + { 0x0008, 0x000b }, + { 0x0009, 0x000b }, + { 0x000a, 0x000b }, + { 0x000b, 0x000b }, + { 0x000d, 0x000f }, + { 0x000e, 0x0012 }, + { 0x000f, 0x0018 }, + { 0x0011, 0x002d }, + { 0x0011, 0x002e }, + { 0x0013, 0x0086 }, + { 0x0014, 0x002d }, + { 0x0014, 0x002e }, + { 0x0014, 0x002f }, + { 0x0014, 0x0030 }, + { 0x0014, 0x0031 }, + { 0x0014, 0x0032 }, + { 0x0014, 0x0033 }, + { 0x0014, 0x0034 }, + { 0x000b, 0x000c }, + { 0x000a, 0x000c }, + { 0x000a, 0x000d }, + { 0x000b, 0x000d }, + { 0x000c, 0x000d }, + { 0x000d, 0x0010 }, + { 0x000e, 0x0013 }, + { 0x000f, 0x0019 }, + { 0x0010, 0x001f }, + { 0x0013, 0x0087 }, + { 0x0014, 0x0035 }, + { 0x0014, 0x0036 }, + { 0x0013, 0x0088 }, + { 0x0014, 0x0037 }, + { 0x0014, 0x0038 }, + { 0x0014, 0x0039 }, + { 0x0014, 0x003a }, + { 0x0014, 0x003b }, + { 0x0014, 0x003c }, + { 0x0014, 0x003d }, + { 0x000d, 0x0011 }, + { 0x000c, 0x000e }, + { 0x000c, 0x000f }, + { 0x000d, 0x0012 }, + { 0x000d, 0x0013 }, + { 0x000e, 0x0014 }, + { 0x0010, 0x0020 }, + { 0x0010, 0x0021 }, + { 0x0012, 0x004d }, + { 0x0011, 0x002f }, + { 0x0014, 0x003e }, + { 0x0014, 0x003f }, + { 0x0014, 0x0040 }, + { 0x0014, 0x0041 }, + { 0x0014, 0x0042 }, + { 0x0014, 0x0043 }, + { 0x0014, 0x0044 }, + { 0x0014, 0x0045 }, + { 0x0014, 0x0046 }, + { 0x0014, 0x0047 }, + { 0x000f, 0x001a }, + { 0x000e, 0x0015 }, + { 0x000e, 0x0016 }, + { 0x000e, 0x0017 }, + { 0x000f, 0x001b }, + { 0x0011, 0x0030 }, + { 0x0011, 0x0031 }, + { 0x0013, 0x0089 }, + { 0x0013, 0x008a }, + { 0x0013, 0x008b }, + { 0x0014, 0x0048 }, + { 0x0014, 0x0049 }, + { 0x0014, 0x004a }, + { 0x0014, 0x004b }, + { 0x0014, 0x004c }, + { 0x0014, 0x004d }, + { 0x0014, 0x004e }, + { 0x0014, 0x004f }, + { 0x0014, 0x0050 }, + { 0x0014, 0x0051 }, + { 0x0010, 0x0022 }, + { 0x0010, 0x0023 }, + { 0x0010, 0x0024 }, + { 0x0010, 0x0025 }, + { 0x0011, 0x0032 }, + { 0x0011, 0x0033 }, + { 0x0012, 0x004e }, + { 0x0012, 0x004f }, + { 0x0014, 0x0052 }, + { 0x0013, 0x008c }, + { 0x0013, 0x008d }, + { 0x0014, 0x0053 }, + { 0x0014, 0x0054 }, + { 0x0014, 0x0055 }, + { 0x0014, 0x0056 }, + { 0x0014, 0x0057 }, + { 0x0014, 0x0058 }, + { 0x0014, 0x0059 }, + { 0x0014, 0x005a }, + { 0x0014, 0x005b }, + { 0x0011, 0x0034 }, + { 0x0011, 0x0035 }, + { 0x0012, 0x0050 }, + { 0x0012, 0x0051 }, + { 0x0013, 0x008e }, + { 0x0014, 0x005c }, + { 0x0014, 0x005d }, + { 0x0014, 0x005e }, + { 0x0014, 0x005f }, + { 0x0014, 0x0060 }, + { 0x0014, 0x0061 }, + { 0x0014, 0x0062 }, + { 0x0014, 0x0063 }, + { 0x0014, 0x0064 }, + { 0x0014, 0x0065 }, + { 0x0014, 0x0066 }, + { 0x0014, 0x0067 }, + { 0x0014, 0x0068 }, + { 0x0014, 0x0069 }, + { 0x0014, 0x006a }, + { 0x0012, 0x0052 }, + { 0x0013, 0x008f }, + { 0x0013, 0x0090 }, + { 0x0014, 0x006b }, + { 0x0013, 0x0091 }, + { 0x0014, 0x006c }, + { 0x0014, 0x006d }, + { 0x0014, 0x006e }, + { 0x0014, 0x006f }, + { 0x0014, 0x0070 }, + { 0x0014, 0x0071 }, + { 0x0014, 0x0072 }, + { 0x0014, 0x0073 }, + { 0x0014, 0x0074 }, + { 0x0014, 0x0075 }, + { 0x0014, 0x0076 }, + { 0x0014, 0x0077 }, + { 0x0014, 0x0078 }, + { 0x0014, 0x0079 }, + { 0x0014, 0x007a }, + { 0x0014, 0x007b }, + { 0x0014, 0x007c }, + { 0x0013, 0x0092 }, + { 0x0012, 0x0053 }, + { 0x0014, 0x007d }, + { 0x0014, 0x007e }, + { 0x0014, 0x007f }, + { 0x0014, 0x0080 }, + { 0x0014, 0x0081 }, + { 0x0014, 0x0082 }, + { 0x0014, 0x0083 }, + { 0x0014, 0x0084 }, + { 0x0014, 0x0085 }, + { 0x0014, 0x0086 }, + { 0x0014, 0x0087 }, + { 0x0014, 0x0088 }, + { 0x0014, 0x0089 }, + { 0x0014, 0x008a }, + { 0x0014, 0x008b }, + { 0x0014, 0x008c }, + { 0x0014, 0x008d }, + { 0x0014, 0x008e }, + { 0x0013, 0x0093 }, + { 0x0014, 0x008f }, + { 0x0014, 0x0090 }, + { 0x0014, 0x0091 }, + { 0x0014, 0x0092 }, + { 0x0014, 0x0093 }, + { 0x0014, 0x0094 }, + { 0x0014, 0x0095 }, + { 0x0014, 0x0096 }, + { 0x0014, 0x0097 }, + { 0x0014, 0x0098 }, + { 0x0014, 0x0099 }, + { 0x0014, 0x009a }, + { 0x0014, 0x009b }, + { 0x0014, 0x009c }, + { 0x0014, 0x009d }, + { 0x0014, 0x009e }, + { 0x0014, 0x009f }, + { 0x0014, 0x00a0 }, + { 0x0014, 0x00a1 }, + { 0x0014, 0x00a2 }, + { 0x0014, 0x00a3 }, + { 0x0014, 0x00a4 }, + { 0x0014, 0x00a5 }, + { 0x0014, 0x00a6 }, + { 0x0014, 0x00a7 }, + { 0x0014, 0x00a8 }, + { 0x0014, 0x00a9 }, + { 0x0014, 0x00aa }, + { 0x0014, 0x00ab }, + { 0x0014, 0x00ac }, + { 0x0014, 0x00ad }, + { 0x0014, 0x00ae }, + { 0x0014, 0x00af }, + { 0x0014, 0x00b0 }, + { 0x0014, 0x00b1 }, + { 0x0014, 0x00b2 }, + { 0x0014, 0x00b3 }, + { 0x0014, 0x00b4 }, + { 0x0014, 0x00b5 }, + { 0x0014, 0x00b6 }, + { 0x0014, 0x00b7 }, + { 0x0014, 0x00b8 }, + { 0x0014, 0x00b9 }, + { 0x0014, 0x00ba }, + { 0x0014, 0x00bb }, + { 0x0014, 0x00bc }, + { 0x0014, 0x00bd }, + { 0x0014, 0x00be }, + { 0x0014, 0x00bf }, + { 0x0014, 0x00c0 }, + { 0x0014, 0x00c1 }, + { 0x0014, 0x00c2 }, + { 0x0014, 0x00c3 }, + { 0x0014, 0x00c4 }, + { 0x0014, 0x00c5 }, + { 0x0014, 0x00c6 }, + { 0x0014, 0x00c7 }, + { 0x0014, 0x00c8 }, + { 0x0014, 0x00c9 }, + { 0x0014, 0x00ca }, + { 0x0014, 0x00cb }, + { 0x0014, 0x00cc }, + { 0x0014, 0x00cd }, + { 0x0014, 0x00ce }, + { 0x0014, 0x00cf }, + { 0x0014, 0x00d0 }, + { 0x0014, 0x00d1 }, + { 0x0014, 0x00d2 }, + { 0x0014, 0x00d3 }, + { 0x0014, 0x00d4 }, + { 0x0014, 0x00d5 }, + { 0x0014, 0x00d6 }, + { 0x0014, 0x00d7 }, + { 0x0014, 0x00d8 }, + { 0x0014, 0x00d9 }, + { 0x0014, 0x00da }, + { 0x0014, 0x00db }, + { 0x0014, 0x00dc }, + { 0x0014, 0x00dd }, + { 0x0014, 0x00de }, + { 0x0014, 0x00df }, + { 0x0014, 0x00e0 }, + { 0x0014, 0x00e1 }, + { 0x0014, 0x00e2 }, + { 0x0014, 0x00e3 }, + { 0x0014, 0x00e4 }, + { 0x0014, 0x00e5 }, + { 0x0014, 0x00e6 }, + { 0x0014, 0x00e7 }, + { 0x0014, 0x00e8 }, + { 0x0014, 0x00e9 }, + { 0x0014, 0x00ea }, + { 0x0014, 0x00eb }, + { 0x0014, 0x00ec }, + { 0x0014, 0x00ed }, + { 0x0014, 0x00ee }, + { 0x0014, 0x00ef }, + { 0x0014, 0x00f0 }, + { 0x0014, 0x00f1 }, + { 0x0014, 0x00f2 }, + { 0x0014, 0x00f3 }, + { 0x0014, 0x00f4 }, + { 0x0014, 0x00f5 }, + { 0x0014, 0x00f6 }, + { 0x0014, 0x00f7 }, + { 0x0014, 0x00f8 }, + { 0x0014, 0x00f9 }, + { 0x0014, 0x00fa }, + { 0x0014, 0x00fb }, + { 0x0014, 0x00fc }, + { 0x0014, 0x00fd }, + { 0x0014, 0x00fe }, + { 0x0014, 0x00ff }, + { 0x0014, 0x0100 }, + { 0x0014, 0x0101 }, + { 0x0014, 0x0102 }, + { 0x0014, 0x0103 }, + }; + +const uint16_t c_aauiLCLDHuffEnc15[576][2] = + { + { 0x0005, 0x000a }, + { 0x0005, 0x000b }, + { 0x0005, 0x000c }, + { 0x0006, 0x0009 }, + { 0x0006, 0x000a }, + { 0x0007, 0x0008 }, + { 0x0008, 0x0009 }, + { 0x0009, 0x0008 }, + { 0x000b, 0x000b }, + { 0x000d, 0x000e }, + { 0x000e, 0x0011 }, + { 0x000f, 0x001a }, + { 0x0012, 0x006e }, + { 0x0014, 0x0000 }, + { 0x0013, 0x00cc }, + { 0x0014, 0x0001 }, + { 0x0014, 0x0002 }, + { 0x0014, 0x0003 }, + { 0x0014, 0x0004 }, + { 0x0014, 0x0005 }, + { 0x0014, 0x0006 }, + { 0x0014, 0x0007 }, + { 0x0014, 0x0008 }, + { 0x0014, 0x0009 }, + { 0x0005, 0x000d }, + { 0x0004, 0x000c }, + { 0x0004, 0x000d }, + { 0x0005, 0x000e }, + { 0x0005, 0x000f }, + { 0x0006, 0x000b }, + { 0x0007, 0x0009 }, + { 0x0008, 0x000a }, + { 0x000a, 0x000a }, + { 0x000c, 0x000c }, + { 0x000d, 0x000f }, + { 0x000f, 0x001b }, + { 0x0011, 0x003d }, + { 0x0011, 0x003e }, + { 0x0013, 0x00cd }, + { 0x0014, 0x000a }, + { 0x0014, 0x000b }, + { 0x0014, 0x000c }, + { 0x0014, 0x000d }, + { 0x0014, 0x000e }, + { 0x0014, 0x000f }, + { 0x0014, 0x0010 }, + { 0x0014, 0x0011 }, + { 0x0014, 0x0012 }, + { 0x0005, 0x0010 }, + { 0x0004, 0x000e }, + { 0x0004, 0x000f }, + { 0x0005, 0x0011 }, + { 0x0005, 0x0012 }, + { 0x0006, 0x000c }, + { 0x0007, 0x000a }, + { 0x0009, 0x0009 }, + { 0x000a, 0x000b }, + { 0x000c, 0x000d }, + { 0x000e, 0x0012 }, + { 0x0010, 0x0027 }, + { 0x0011, 0x003f }, + { 0x0012, 0x006f }, + { 0x0014, 0x0013 }, + { 0x0014, 0x0014 }, + { 0x0014, 0x0015 }, + { 0x0014, 0x0016 }, + { 0x0014, 0x0017 }, + { 0x0014, 0x0018 }, + { 0x0014, 0x0019 }, + { 0x0014, 0x001a }, + { 0x0014, 0x001b }, + { 0x0014, 0x001c }, + { 0x0006, 0x000d }, + { 0x0005, 0x0013 }, + { 0x0005, 0x0014 }, + { 0x0005, 0x0015 }, + { 0x0006, 0x000e }, + { 0x0007, 0x000b }, + { 0x0008, 0x000b }, + { 0x0009, 0x000a }, + { 0x000b, 0x000c }, + { 0x000c, 0x000e }, + { 0x000e, 0x0013 }, + { 0x000f, 0x001c }, + { 0x0011, 0x0040 }, + { 0x0012, 0x0070 }, + { 0x0014, 0x001d }, + { 0x0014, 0x001e }, + { 0x0014, 0x001f }, + { 0x0014, 0x0020 }, + { 0x0014, 0x0021 }, + { 0x0014, 0x0022 }, + { 0x0014, 0x0023 }, + { 0x0014, 0x0024 }, + { 0x0014, 0x0025 }, + { 0x0014, 0x0026 }, + { 0x0006, 0x000f }, + { 0x0005, 0x0016 }, + { 0x0005, 0x0017 }, + { 0x0006, 0x0010 }, + { 0x0006, 0x0011 }, + { 0x0007, 0x000c }, + { 0x0009, 0x000b }, + { 0x000a, 0x000c }, + { 0x000b, 0x000d }, + { 0x000d, 0x0010 }, + { 0x000e, 0x0014 }, + { 0x0010, 0x0028 }, + { 0x0011, 0x0041 }, + { 0x0013, 0x00ce }, + { 0x0014, 0x0027 }, + { 0x0014, 0x0028 }, + { 0x0014, 0x0029 }, + { 0x0014, 0x002a }, + { 0x0014, 0x002b }, + { 0x0014, 0x002c }, + { 0x0014, 0x002d }, + { 0x0014, 0x002e }, + { 0x0014, 0x002f }, + { 0x0014, 0x0030 }, + { 0x0007, 0x000d }, + { 0x0006, 0x0012 }, + { 0x0006, 0x0013 }, + { 0x0007, 0x000e }, + { 0x0007, 0x000f }, + { 0x0008, 0x000c }, + { 0x0009, 0x000c }, + { 0x000b, 0x000e }, + { 0x000c, 0x000f }, + { 0x000e, 0x0015 }, + { 0x0010, 0x0029 }, + { 0x0011, 0x0042 }, + { 0x0014, 0x0031 }, + { 0x0014, 0x0032 }, + { 0x0014, 0x0033 }, + { 0x0014, 0x0034 }, + { 0x0014, 0x0035 }, + { 0x0014, 0x0036 }, + { 0x0014, 0x0037 }, + { 0x0014, 0x0038 }, + { 0x0014, 0x0039 }, + { 0x0014, 0x003a }, + { 0x0014, 0x003b }, + { 0x0014, 0x003c }, + { 0x0008, 0x000d }, + { 0x0007, 0x0010 }, + { 0x0007, 0x0011 }, + { 0x0008, 0x000e }, + { 0x0009, 0x000d }, + { 0x0009, 0x000e }, + { 0x000b, 0x000f }, + { 0x000c, 0x0010 }, + { 0x000d, 0x0011 }, + { 0x000f, 0x001d }, + { 0x0010, 0x002a }, + { 0x0011, 0x0043 }, + { 0x0014, 0x003d }, + { 0x0013, 0x00cf }, + { 0x0014, 0x003e }, + { 0x0014, 0x003f }, + { 0x0014, 0x0040 }, + { 0x0014, 0x0041 }, + { 0x0014, 0x0042 }, + { 0x0014, 0x0043 }, + { 0x0014, 0x0044 }, + { 0x0014, 0x0045 }, + { 0x0014, 0x0046 }, + { 0x0014, 0x0047 }, + { 0x0009, 0x000f }, + { 0x0008, 0x000f }, + { 0x0009, 0x0010 }, + { 0x0009, 0x0011 }, + { 0x000a, 0x000d }, + { 0x000b, 0x0010 }, + { 0x000c, 0x0011 }, + { 0x000d, 0x0012 }, + { 0x000e, 0x0016 }, + { 0x0010, 0x002b }, + { 0x0011, 0x0044 }, + { 0x0012, 0x0071 }, + { 0x0014, 0x0048 }, + { 0x0014, 0x0049 }, + { 0x0014, 0x004a }, + { 0x0014, 0x004b }, + { 0x0014, 0x004c }, + { 0x0014, 0x004d }, + { 0x0014, 0x004e }, + { 0x0014, 0x004f }, + { 0x0014, 0x0050 }, + { 0x0014, 0x0051 }, + { 0x0014, 0x0052 }, + { 0x0014, 0x0053 }, + { 0x000b, 0x0011 }, + { 0x000a, 0x000e }, + { 0x000a, 0x000f }, + { 0x000b, 0x0012 }, + { 0x000b, 0x0013 }, + { 0x000c, 0x0012 }, + { 0x000d, 0x0013 }, + { 0x000e, 0x0017 }, + { 0x0010, 0x002c }, + { 0x0012, 0x0072 }, + { 0x0011, 0x0045 }, + { 0x0013, 0x00d0 }, + { 0x0013, 0x00d1 }, + { 0x0014, 0x0054 }, + { 0x0014, 0x0055 }, + { 0x0014, 0x0056 }, + { 0x0014, 0x0057 }, + { 0x0014, 0x0058 }, + { 0x0014, 0x0059 }, + { 0x0014, 0x005a }, + { 0x0014, 0x005b }, + { 0x0014, 0x005c }, + { 0x0014, 0x005d }, + { 0x0014, 0x005e }, + { 0x000c, 0x0013 }, + { 0x000c, 0x0014 }, + { 0x000c, 0x0015 }, + { 0x000d, 0x0014 }, + { 0x000d, 0x0015 }, + { 0x000e, 0x0018 }, + { 0x000f, 0x001e }, + { 0x0010, 0x002d }, + { 0x0011, 0x0046 }, + { 0x0011, 0x0047 }, + { 0x0011, 0x0048 }, + { 0x0014, 0x005f }, + { 0x0014, 0x0060 }, + { 0x0014, 0x0061 }, + { 0x0014, 0x0062 }, + { 0x0014, 0x0063 }, + { 0x0014, 0x0064 }, + { 0x0014, 0x0065 }, + { 0x0014, 0x0066 }, + { 0x0014, 0x0067 }, + { 0x0014, 0x0068 }, + { 0x0014, 0x0069 }, + { 0x0014, 0x006a }, + { 0x0014, 0x006b }, + { 0x000e, 0x0019 }, + { 0x000d, 0x0016 }, + { 0x000d, 0x0017 }, + { 0x000e, 0x001a }, + { 0x000e, 0x001b }, + { 0x000f, 0x001f }, + { 0x0010, 0x002e }, + { 0x0011, 0x0049 }, + { 0x0012, 0x0073 }, + { 0x0014, 0x006c }, + { 0x0014, 0x006d }, + { 0x0014, 0x006e }, + { 0x0014, 0x006f }, + { 0x0014, 0x0070 }, + { 0x0014, 0x0071 }, + { 0x0014, 0x0072 }, + { 0x0014, 0x0073 }, + { 0x0014, 0x0074 }, + { 0x0014, 0x0075 }, + { 0x0014, 0x0076 }, + { 0x0014, 0x0077 }, + { 0x0014, 0x0078 }, + { 0x0014, 0x0079 }, + { 0x0014, 0x007a }, + { 0x0010, 0x002f }, + { 0x000f, 0x0020 }, + { 0x0010, 0x0030 }, + { 0x000f, 0x0021 }, + { 0x0010, 0x0031 }, + { 0x0011, 0x004a }, + { 0x0011, 0x004b }, + { 0x0012, 0x0074 }, + { 0x0014, 0x007b }, + { 0x0014, 0x007c }, + { 0x0013, 0x00d2 }, + { 0x0014, 0x007d }, + { 0x0014, 0x007e }, + { 0x0014, 0x007f }, + { 0x0014, 0x0080 }, + { 0x0014, 0x0081 }, + { 0x0014, 0x0082 }, + { 0x0014, 0x0083 }, + { 0x0014, 0x0084 }, + { 0x0014, 0x0085 }, + { 0x0014, 0x0086 }, + { 0x0014, 0x0087 }, + { 0x0014, 0x0088 }, + { 0x0014, 0x0089 }, + { 0x0012, 0x0075 }, + { 0x0010, 0x0032 }, + { 0x0010, 0x0033 }, + { 0x0011, 0x004c }, + { 0x0011, 0x004d }, + { 0x0013, 0x00d3 }, + { 0x0013, 0x00d4 }, + { 0x0012, 0x0076 }, + { 0x0013, 0x00d5 }, + { 0x0014, 0x008a }, + { 0x0014, 0x008b }, + { 0x0014, 0x008c }, + { 0x0014, 0x008d }, + { 0x0014, 0x008e }, + { 0x0014, 0x008f }, + { 0x0014, 0x0090 }, + { 0x0014, 0x0091 }, + { 0x0014, 0x0092 }, + { 0x0014, 0x0093 }, + { 0x0014, 0x0094 }, + { 0x0014, 0x0095 }, + { 0x0014, 0x0096 }, + { 0x0014, 0x0097 }, + { 0x0014, 0x0098 }, + { 0x0013, 0x00d6 }, + { 0x0013, 0x00d7 }, + { 0x0012, 0x0077 }, + { 0x0012, 0x0078 }, + { 0x0014, 0x0099 }, + { 0x0014, 0x009a }, + { 0x0013, 0x00d8 }, + { 0x0014, 0x009b }, + { 0x0014, 0x009c }, + { 0x0014, 0x009d }, + { 0x0014, 0x009e }, + { 0x0014, 0x009f }, + { 0x0014, 0x00a0 }, + { 0x0014, 0x00a1 }, + { 0x0014, 0x00a2 }, + { 0x0014, 0x00a3 }, + { 0x0014, 0x00a4 }, + { 0x0014, 0x00a5 }, + { 0x0014, 0x00a6 }, + { 0x0014, 0x00a7 }, + { 0x0014, 0x00a8 }, + { 0x0014, 0x00a9 }, + { 0x0014, 0x00aa }, + { 0x0014, 0x00ab }, + { 0x0014, 0x00ac }, + { 0x0014, 0x00ad }, + { 0x0014, 0x00ae }, + { 0x0014, 0x00af }, + { 0x0012, 0x0079 }, + { 0x0014, 0x00b0 }, + { 0x0014, 0x00b1 }, + { 0x0014, 0x00b2 }, + { 0x0014, 0x00b3 }, + { 0x0014, 0x00b4 }, + { 0x0014, 0x00b5 }, + { 0x0014, 0x00b6 }, + { 0x0014, 0x00b7 }, + { 0x0014, 0x00b8 }, + { 0x0014, 0x00b9 }, + { 0x0014, 0x00ba }, + { 0x0014, 0x00bb }, + { 0x0014, 0x00bc }, + { 0x0014, 0x00bd }, + { 0x0014, 0x00be }, + { 0x0014, 0x00bf }, + { 0x0014, 0x00c0 }, + { 0x0014, 0x00c1 }, + { 0x0014, 0x00c2 }, + { 0x0014, 0x00c3 }, + { 0x0014, 0x00c4 }, + { 0x0014, 0x00c5 }, + { 0x0014, 0x00c6 }, + { 0x0013, 0x00d9 }, + { 0x0013, 0x00da }, + { 0x0014, 0x00c7 }, + { 0x0014, 0x00c8 }, + { 0x0014, 0x00c9 }, + { 0x0014, 0x00ca }, + { 0x0014, 0x00cb }, + { 0x0014, 0x00cc }, + { 0x0014, 0x00cd }, + { 0x0014, 0x00ce }, + { 0x0014, 0x00cf }, + { 0x0014, 0x00d0 }, + { 0x0014, 0x00d1 }, + { 0x0014, 0x00d2 }, + { 0x0014, 0x00d3 }, + { 0x0014, 0x00d4 }, + { 0x0014, 0x00d5 }, + { 0x0014, 0x00d6 }, + { 0x0014, 0x00d7 }, + { 0x0014, 0x00d8 }, + { 0x0014, 0x00d9 }, + { 0x0014, 0x00da }, + { 0x0014, 0x00db }, + { 0x0014, 0x00dc }, + { 0x0014, 0x00dd }, + { 0x0014, 0x00de }, + { 0x0014, 0x00df }, + { 0x0014, 0x00e0 }, + { 0x0014, 0x00e1 }, + { 0x0014, 0x00e2 }, + { 0x0014, 0x00e3 }, + { 0x0014, 0x00e4 }, + { 0x0014, 0x00e5 }, + { 0x0014, 0x00e6 }, + { 0x0014, 0x00e7 }, + { 0x0014, 0x00e8 }, + { 0x0014, 0x00e9 }, + { 0x0014, 0x00ea }, + { 0x0014, 0x00eb }, + { 0x0014, 0x00ec }, + { 0x0014, 0x00ed }, + { 0x0014, 0x00ee }, + { 0x0014, 0x00ef }, + { 0x0014, 0x00f0 }, + { 0x0014, 0x00f1 }, + { 0x0014, 0x00f2 }, + { 0x0014, 0x00f3 }, + { 0x0014, 0x00f4 }, + { 0x0014, 0x00f5 }, + { 0x0014, 0x00f6 }, + { 0x0014, 0x00f7 }, + { 0x0014, 0x00f8 }, + { 0x0014, 0x00f9 }, + { 0x0014, 0x00fa }, + { 0x0014, 0x00fb }, + { 0x0014, 0x00fc }, + { 0x0014, 0x00fd }, + { 0x0014, 0x00fe }, + { 0x0014, 0x00ff }, + { 0x0014, 0x0100 }, + { 0x0014, 0x0101 }, + { 0x0014, 0x0102 }, + { 0x0014, 0x0103 }, + { 0x0014, 0x0104 }, + { 0x0014, 0x0105 }, + { 0x0014, 0x0106 }, + { 0x0014, 0x0107 }, + { 0x0014, 0x0108 }, + { 0x0014, 0x0109 }, + { 0x0014, 0x010a }, + { 0x0014, 0x010b }, + { 0x0014, 0x010c }, + { 0x0014, 0x010d }, + { 0x0014, 0x010e }, + { 0x0014, 0x010f }, + { 0x0014, 0x0110 }, + { 0x0014, 0x0111 }, + { 0x0014, 0x0112 }, + { 0x0014, 0x0113 }, + { 0x0014, 0x0114 }, + { 0x0014, 0x0115 }, + { 0x0014, 0x0116 }, + { 0x0014, 0x0117 }, + { 0x0014, 0x0118 }, + { 0x0014, 0x0119 }, + { 0x0014, 0x011a }, + { 0x0014, 0x011b }, + { 0x0014, 0x011c }, + { 0x0014, 0x011d }, + { 0x0014, 0x011e }, + { 0x0014, 0x011f }, + { 0x0014, 0x0120 }, + { 0x0014, 0x0121 }, + { 0x0014, 0x0122 }, + { 0x0014, 0x0123 }, + { 0x0014, 0x0124 }, + { 0x0014, 0x0125 }, + { 0x0014, 0x0126 }, + { 0x0014, 0x0127 }, + { 0x0014, 0x0128 }, + { 0x0014, 0x0129 }, + { 0x0014, 0x012a }, + { 0x0014, 0x012b }, + { 0x0014, 0x012c }, + { 0x0014, 0x012d }, + { 0x0014, 0x012e }, + { 0x0014, 0x012f }, + { 0x0014, 0x0130 }, + { 0x0014, 0x0131 }, + { 0x0014, 0x0132 }, + { 0x0014, 0x0133 }, + { 0x0014, 0x0134 }, + { 0x0014, 0x0135 }, + { 0x0014, 0x0136 }, + { 0x0014, 0x0137 }, + { 0x0014, 0x0138 }, + { 0x0014, 0x0139 }, + { 0x0014, 0x013a }, + { 0x0014, 0x013b }, + { 0x0014, 0x013c }, + { 0x0014, 0x013d }, + { 0x0014, 0x013e }, + { 0x0014, 0x013f }, + { 0x0014, 0x0140 }, + { 0x0014, 0x0141 }, + { 0x0014, 0x0142 }, + { 0x0014, 0x0143 }, + { 0x0014, 0x0144 }, + { 0x0014, 0x0145 }, + { 0x0014, 0x0146 }, + { 0x0014, 0x0147 }, + { 0x0014, 0x0148 }, + { 0x0014, 0x0149 }, + { 0x0014, 0x014a }, + { 0x0014, 0x014b }, + { 0x0014, 0x014c }, + { 0x0014, 0x014d }, + { 0x0014, 0x014e }, + { 0x0014, 0x014f }, + { 0x0014, 0x0150 }, + { 0x0014, 0x0151 }, + { 0x0014, 0x0152 }, + { 0x0014, 0x0153 }, + { 0x0014, 0x0154 }, + { 0x0014, 0x0155 }, + { 0x0014, 0x0156 }, + { 0x0014, 0x0157 }, + { 0x0014, 0x0158 }, + { 0x0014, 0x0159 }, + { 0x0014, 0x015a }, + { 0x0014, 0x015b }, + { 0x0014, 0x015c }, + { 0x0014, 0x015d }, + { 0x0014, 0x015e }, + { 0x0014, 0x015f }, + { 0x0014, 0x0160 }, + { 0x0014, 0x0161 }, + { 0x0014, 0x0162 }, + { 0x0014, 0x0163 }, + { 0x0014, 0x0164 }, + { 0x0014, 0x0165 }, + { 0x0014, 0x0166 }, + { 0x0014, 0x0167 }, + { 0x0014, 0x0168 }, + { 0x0014, 0x0169 }, + { 0x0014, 0x016a }, + { 0x0014, 0x016b }, + { 0x0014, 0x016c }, + { 0x0014, 0x016d }, + { 0x0014, 0x016e }, + { 0x0014, 0x016f }, + { 0x0014, 0x0170 }, + { 0x0014, 0x0171 }, + { 0x0014, 0x0172 }, + { 0x0014, 0x0173 }, + { 0x0014, 0x0174 }, + { 0x0014, 0x0175 }, + { 0x0014, 0x0176 }, + { 0x0014, 0x0177 }, + { 0x0014, 0x0178 }, + { 0x0014, 0x0179 }, + { 0x0014, 0x017a }, + { 0x0014, 0x017b }, + { 0x0014, 0x017c }, + { 0x0014, 0x017d }, + { 0x0014, 0x017e }, + { 0x0014, 0x017f }, + { 0x0014, 0x0180 }, + { 0x0014, 0x0181 }, + { 0x0014, 0x0182 }, + { 0x0014, 0x0183 }, + { 0x0014, 0x0184 }, + { 0x0014, 0x0185 }, + { 0x0014, 0x0186 }, + { 0x0014, 0x0187 }, + { 0x0014, 0x0188 }, + { 0x0014, 0x0189 }, + { 0x0014, 0x018a }, + { 0x0014, 0x018b }, + { 0x0014, 0x018c }, + { 0x0014, 0x018d }, + { 0x0014, 0x018e }, + { 0x0014, 0x018f }, + { 0x0014, 0x0190 }, + { 0x0014, 0x0191 }, + { 0x0014, 0x0192 }, + { 0x0014, 0x0193 }, + { 0x0014, 0x0194 }, + { 0x0014, 0x0195 }, + { 0x0014, 0x0196 }, + { 0x0014, 0x0197 }, + { 0x0013, 0x00db }, + }; + +const uint16_t c_aauiLCLDHuffEnc16[729][2] = + { + { 0x0006, 0x000d }, + { 0x0005, 0x0010 }, + { 0x0006, 0x000e }, + { 0x0006, 0x000f }, + { 0x0006, 0x0010 }, + { 0x0007, 0x000a }, + { 0x0007, 0x000b }, + { 0x0008, 0x000a }, + { 0x0009, 0x000b }, + { 0x000b, 0x000d }, + { 0x000c, 0x000e }, + { 0x000e, 0x0016 }, + { 0x0010, 0x002d }, + { 0x0011, 0x0051 }, + { 0x0012, 0x008c }, + { 0x0014, 0x0000 }, + { 0x0014, 0x0001 }, + { 0x0014, 0x0002 }, + { 0x0014, 0x0003 }, + { 0x0014, 0x0004 }, + { 0x0014, 0x0005 }, + { 0x0014, 0x0006 }, + { 0x0014, 0x0007 }, + { 0x0014, 0x0008 }, + { 0x0014, 0x0009 }, + { 0x0014, 0x000a }, + { 0x0014, 0x000b }, + { 0x0005, 0x0011 }, + { 0x0004, 0x000f }, + { 0x0005, 0x0012 }, + { 0x0005, 0x0013 }, + { 0x0005, 0x0014 }, + { 0x0006, 0x0011 }, + { 0x0006, 0x0012 }, + { 0x0007, 0x000c }, + { 0x0008, 0x000b }, + { 0x000a, 0x000c }, + { 0x000b, 0x000e }, + { 0x000d, 0x0010 }, + { 0x000e, 0x0017 }, + { 0x000f, 0x001c }, + { 0x0013, 0x010b }, + { 0x0013, 0x010c }, + { 0x0014, 0x000c }, + { 0x0014, 0x000d }, + { 0x0014, 0x000e }, + { 0x0014, 0x000f }, + { 0x0014, 0x0010 }, + { 0x0014, 0x0011 }, + { 0x0014, 0x0012 }, + { 0x0014, 0x0013 }, + { 0x0014, 0x0014 }, + { 0x0014, 0x0015 }, + { 0x0014, 0x0016 }, + { 0x0006, 0x0013 }, + { 0x0005, 0x0015 }, + { 0x0005, 0x0016 }, + { 0x0005, 0x0017 }, + { 0x0005, 0x0018 }, + { 0x0006, 0x0014 }, + { 0x0007, 0x000d }, + { 0x0007, 0x000e }, + { 0x0009, 0x000c }, + { 0x000a, 0x000d }, + { 0x000c, 0x000f }, + { 0x000d, 0x0011 }, + { 0x000f, 0x001d }, + { 0x0011, 0x0052 }, + { 0x0012, 0x008d }, + { 0x0012, 0x008e }, + { 0x0014, 0x0017 }, + { 0x0014, 0x0018 }, + { 0x0014, 0x0019 }, + { 0x0014, 0x001a }, + { 0x0014, 0x001b }, + { 0x0014, 0x001c }, + { 0x0014, 0x001d }, + { 0x0014, 0x001e }, + { 0x0014, 0x001f }, + { 0x0014, 0x0020 }, + { 0x0014, 0x0021 }, + { 0x0006, 0x0015 }, + { 0x0005, 0x0019 }, + { 0x0005, 0x001a }, + { 0x0005, 0x001b }, + { 0x0006, 0x0016 }, + { 0x0006, 0x0017 }, + { 0x0007, 0x000f }, + { 0x0008, 0x000c }, + { 0x0009, 0x000d }, + { 0x000b, 0x000f }, + { 0x000c, 0x0010 }, + { 0x000d, 0x0012 }, + { 0x000f, 0x001e }, + { 0x0012, 0x008f }, + { 0x0014, 0x0022 }, + { 0x0014, 0x0023 }, + { 0x0014, 0x0024 }, + { 0x0014, 0x0025 }, + { 0x0014, 0x0026 }, + { 0x0014, 0x0027 }, + { 0x0014, 0x0028 }, + { 0x0014, 0x0029 }, + { 0x0014, 0x002a }, + { 0x0014, 0x002b }, + { 0x0014, 0x002c }, + { 0x0014, 0x002d }, + { 0x0014, 0x002e }, + { 0x0006, 0x0018 }, + { 0x0005, 0x001c }, + { 0x0005, 0x001d }, + { 0x0006, 0x0019 }, + { 0x0006, 0x001a }, + { 0x0007, 0x0010 }, + { 0x0007, 0x0011 }, + { 0x0008, 0x000d }, + { 0x000a, 0x000e }, + { 0x000b, 0x0010 }, + { 0x000c, 0x0011 }, + { 0x000e, 0x0018 }, + { 0x0010, 0x002e }, + { 0x0012, 0x0090 }, + { 0x0013, 0x010d }, + { 0x0013, 0x010e }, + { 0x0014, 0x002f }, + { 0x0014, 0x0030 }, + { 0x0014, 0x0031 }, + { 0x0014, 0x0032 }, + { 0x0014, 0x0033 }, + { 0x0014, 0x0034 }, + { 0x0014, 0x0035 }, + { 0x0014, 0x0036 }, + { 0x0014, 0x0037 }, + { 0x0014, 0x0038 }, + { 0x0014, 0x0039 }, + { 0x0007, 0x0012 }, + { 0x0006, 0x001b }, + { 0x0006, 0x001c }, + { 0x0006, 0x001d }, + { 0x0007, 0x0013 }, + { 0x0007, 0x0014 }, + { 0x0008, 0x000e }, + { 0x0009, 0x000e }, + { 0x000b, 0x0011 }, + { 0x000c, 0x0012 }, + { 0x000d, 0x0013 }, + { 0x000e, 0x0019 }, + { 0x0010, 0x002f }, + { 0x0012, 0x0091 }, + { 0x0014, 0x003a }, + { 0x0014, 0x003b }, + { 0x0014, 0x003c }, + { 0x0014, 0x003d }, + { 0x0014, 0x003e }, + { 0x0014, 0x003f }, + { 0x0014, 0x0040 }, + { 0x0014, 0x0041 }, + { 0x0014, 0x0042 }, + { 0x0014, 0x0043 }, + { 0x0014, 0x0044 }, + { 0x0014, 0x0045 }, + { 0x0014, 0x0046 }, + { 0x0007, 0x0015 }, + { 0x0006, 0x001e }, + { 0x0006, 0x001f }, + { 0x0007, 0x0016 }, + { 0x0007, 0x0017 }, + { 0x0008, 0x000f }, + { 0x0009, 0x000f }, + { 0x000a, 0x000f }, + { 0x000b, 0x0012 }, + { 0x000d, 0x0014 }, + { 0x000e, 0x001a }, + { 0x000f, 0x001f }, + { 0x0013, 0x010f }, + { 0x0011, 0x0053 }, + { 0x0014, 0x0047 }, + { 0x0014, 0x0048 }, + { 0x0014, 0x0049 }, + { 0x0014, 0x004a }, + { 0x0014, 0x004b }, + { 0x0014, 0x004c }, + { 0x0014, 0x004d }, + { 0x0014, 0x004e }, + { 0x0014, 0x004f }, + { 0x0014, 0x0050 }, + { 0x0014, 0x0051 }, + { 0x0014, 0x0052 }, + { 0x0014, 0x0053 }, + { 0x0008, 0x0010 }, + { 0x0007, 0x0018 }, + { 0x0007, 0x0019 }, + { 0x0008, 0x0011 }, + { 0x0008, 0x0012 }, + { 0x0009, 0x0010 }, + { 0x000a, 0x0010 }, + { 0x000b, 0x0013 }, + { 0x000c, 0x0013 }, + { 0x000e, 0x001b }, + { 0x000f, 0x0020 }, + { 0x0010, 0x0030 }, + { 0x0012, 0x0092 }, + { 0x0014, 0x0054 }, + { 0x0014, 0x0055 }, + { 0x0014, 0x0056 }, + { 0x0014, 0x0057 }, + { 0x0014, 0x0058 }, + { 0x0014, 0x0059 }, + { 0x0014, 0x005a }, + { 0x0014, 0x005b }, + { 0x0014, 0x005c }, + { 0x0014, 0x005d }, + { 0x0014, 0x005e }, + { 0x0014, 0x005f }, + { 0x0014, 0x0060 }, + { 0x0014, 0x0061 }, + { 0x0009, 0x0011 }, + { 0x0008, 0x0013 }, + { 0x0009, 0x0012 }, + { 0x0009, 0x0013 }, + { 0x000a, 0x0011 }, + { 0x000a, 0x0012 }, + { 0x000b, 0x0014 }, + { 0x000c, 0x0014 }, + { 0x000d, 0x0015 }, + { 0x000e, 0x001c }, + { 0x000f, 0x0021 }, + { 0x0013, 0x0110 }, + { 0x0012, 0x0093 }, + { 0x0012, 0x0094 }, + { 0x0014, 0x0062 }, + { 0x0014, 0x0063 }, + { 0x0014, 0x0064 }, + { 0x0014, 0x0065 }, + { 0x0014, 0x0066 }, + { 0x0014, 0x0067 }, + { 0x0014, 0x0068 }, + { 0x0014, 0x0069 }, + { 0x0014, 0x006a }, + { 0x0014, 0x006b }, + { 0x0014, 0x006c }, + { 0x0014, 0x006d }, + { 0x0014, 0x006e }, + { 0x000b, 0x0015 }, + { 0x000a, 0x0013 }, + { 0x000a, 0x0014 }, + { 0x000a, 0x0015 }, + { 0x000b, 0x0016 }, + { 0x000c, 0x0015 }, + { 0x000d, 0x0016 }, + { 0x000d, 0x0017 }, + { 0x000f, 0x0022 }, + { 0x0010, 0x0031 }, + { 0x0012, 0x0095 }, + { 0x0012, 0x0096 }, + { 0x0014, 0x006f }, + { 0x0013, 0x0111 }, + { 0x0014, 0x0070 }, + { 0x0014, 0x0071 }, + { 0x0014, 0x0072 }, + { 0x0014, 0x0073 }, + { 0x0014, 0x0074 }, + { 0x0014, 0x0075 }, + { 0x0014, 0x0076 }, + { 0x0014, 0x0077 }, + { 0x0014, 0x0078 }, + { 0x0014, 0x0079 }, + { 0x0014, 0x007a }, + { 0x0014, 0x007b }, + { 0x0014, 0x007c }, + { 0x000c, 0x0016 }, + { 0x000b, 0x0017 }, + { 0x000c, 0x0017 }, + { 0x000c, 0x0018 }, + { 0x000c, 0x0019 }, + { 0x000d, 0x0018 }, + { 0x000e, 0x001d }, + { 0x000f, 0x0023 }, + { 0x000f, 0x0024 }, + { 0x0011, 0x0054 }, + { 0x0012, 0x0097 }, + { 0x0014, 0x007d }, + { 0x0014, 0x007e }, + { 0x0014, 0x007f }, + { 0x0014, 0x0080 }, + { 0x0014, 0x0081 }, + { 0x0014, 0x0082 }, + { 0x0014, 0x0083 }, + { 0x0014, 0x0084 }, + { 0x0014, 0x0085 }, + { 0x0014, 0x0086 }, + { 0x0014, 0x0087 }, + { 0x0014, 0x0088 }, + { 0x0014, 0x0089 }, + { 0x0014, 0x008a }, + { 0x0014, 0x008b }, + { 0x0014, 0x008c }, + { 0x000e, 0x001e }, + { 0x000d, 0x0019 }, + { 0x000d, 0x001a }, + { 0x000d, 0x001b }, + { 0x000e, 0x001f }, + { 0x000f, 0x0025 }, + { 0x000f, 0x0026 }, + { 0x0010, 0x0032 }, + { 0x0010, 0x0033 }, + { 0x0012, 0x0098 }, + { 0x0013, 0x0112 }, + { 0x0014, 0x008d }, + { 0x0014, 0x008e }, + { 0x0014, 0x008f }, + { 0x0014, 0x0090 }, + { 0x0014, 0x0091 }, + { 0x0014, 0x0092 }, + { 0x0014, 0x0093 }, + { 0x0014, 0x0094 }, + { 0x0014, 0x0095 }, + { 0x0014, 0x0096 }, + { 0x0014, 0x0097 }, + { 0x0014, 0x0098 }, + { 0x0014, 0x0099 }, + { 0x0014, 0x009a }, + { 0x0014, 0x009b }, + { 0x0014, 0x009c }, + { 0x000f, 0x0027 }, + { 0x000f, 0x0028 }, + { 0x000f, 0x0029 }, + { 0x000f, 0x002a }, + { 0x0010, 0x0034 }, + { 0x000f, 0x002b }, + { 0x0011, 0x0055 }, + { 0x0012, 0x0099 }, + { 0x0012, 0x009a }, + { 0x0012, 0x009b }, + { 0x0014, 0x009d }, + { 0x0013, 0x0113 }, + { 0x0014, 0x009e }, + { 0x0014, 0x009f }, + { 0x0014, 0x00a0 }, + { 0x0014, 0x00a1 }, + { 0x0014, 0x00a2 }, + { 0x0014, 0x00a3 }, + { 0x0014, 0x00a4 }, + { 0x0014, 0x00a5 }, + { 0x0014, 0x00a6 }, + { 0x0014, 0x00a7 }, + { 0x0014, 0x00a8 }, + { 0x0014, 0x00a9 }, + { 0x0014, 0x00aa }, + { 0x0014, 0x00ab }, + { 0x0014, 0x00ac }, + { 0x0011, 0x0056 }, + { 0x0010, 0x0035 }, + { 0x0010, 0x0036 }, + { 0x0010, 0x0037 }, + { 0x0011, 0x0057 }, + { 0x0012, 0x009c }, + { 0x0012, 0x009d }, + { 0x0012, 0x009e }, + { 0x0014, 0x00ad }, + { 0x0014, 0x00ae }, + { 0x0014, 0x00af }, + { 0x0014, 0x00b0 }, + { 0x0014, 0x00b1 }, + { 0x0014, 0x00b2 }, + { 0x0014, 0x00b3 }, + { 0x0014, 0x00b4 }, + { 0x0014, 0x00b5 }, + { 0x0014, 0x00b6 }, + { 0x0014, 0x00b7 }, + { 0x0014, 0x00b8 }, + { 0x0014, 0x00b9 }, + { 0x0014, 0x00ba }, + { 0x0014, 0x00bb }, + { 0x0014, 0x00bc }, + { 0x0014, 0x00bd }, + { 0x0014, 0x00be }, + { 0x0014, 0x00bf }, + { 0x0012, 0x009f }, + { 0x0011, 0x0058 }, + { 0x0012, 0x00a0 }, + { 0x0014, 0x00c0 }, + { 0x0011, 0x0059 }, + { 0x0013, 0x0114 }, + { 0x0012, 0x00a1 }, + { 0x0014, 0x00c1 }, + { 0x0013, 0x0115 }, + { 0x0014, 0x00c2 }, + { 0x0014, 0x00c3 }, + { 0x0014, 0x00c4 }, + { 0x0014, 0x00c5 }, + { 0x0014, 0x00c6 }, + { 0x0014, 0x00c7 }, + { 0x0014, 0x00c8 }, + { 0x0014, 0x00c9 }, + { 0x0014, 0x00ca }, + { 0x0014, 0x00cb }, + { 0x0014, 0x00cc }, + { 0x0014, 0x00cd }, + { 0x0014, 0x00ce }, + { 0x0014, 0x00cf }, + { 0x0014, 0x00d0 }, + { 0x0014, 0x00d1 }, + { 0x0014, 0x00d2 }, + { 0x0014, 0x00d3 }, + { 0x0014, 0x00d4 }, + { 0x0014, 0x00d5 }, + { 0x0014, 0x00d6 }, + { 0x0014, 0x00d7 }, + { 0x0014, 0x00d8 }, + { 0x0014, 0x00d9 }, + { 0x0014, 0x00da }, + { 0x0014, 0x00db }, + { 0x0014, 0x00dc }, + { 0x0014, 0x00dd }, + { 0x0014, 0x00de }, + { 0x0014, 0x00df }, + { 0x0014, 0x00e0 }, + { 0x0014, 0x00e1 }, + { 0x0014, 0x00e2 }, + { 0x0014, 0x00e3 }, + { 0x0014, 0x00e4 }, + { 0x0014, 0x00e5 }, + { 0x0014, 0x00e6 }, + { 0x0014, 0x00e7 }, + { 0x0014, 0x00e8 }, + { 0x0014, 0x00e9 }, + { 0x0014, 0x00ea }, + { 0x0014, 0x00eb }, + { 0x0014, 0x00ec }, + { 0x0014, 0x00ed }, + { 0x0014, 0x00ee }, + { 0x0014, 0x00ef }, + { 0x0014, 0x00f0 }, + { 0x0014, 0x00f1 }, + { 0x0014, 0x00f2 }, + { 0x0014, 0x00f3 }, + { 0x0014, 0x00f4 }, + { 0x0014, 0x00f5 }, + { 0x0014, 0x00f6 }, + { 0x0014, 0x00f7 }, + { 0x0014, 0x00f8 }, + { 0x0014, 0x00f9 }, + { 0x0014, 0x00fa }, + { 0x0014, 0x00fb }, + { 0x0014, 0x00fc }, + { 0x0014, 0x00fd }, + { 0x0014, 0x00fe }, + { 0x0014, 0x00ff }, + { 0x0014, 0x0100 }, + { 0x0014, 0x0101 }, + { 0x0014, 0x0102 }, + { 0x0014, 0x0103 }, + { 0x0014, 0x0104 }, + { 0x0014, 0x0105 }, + { 0x0014, 0x0106 }, + { 0x0014, 0x0107 }, + { 0x0014, 0x0108 }, + { 0x0014, 0x0109 }, + { 0x0014, 0x010a }, + { 0x0014, 0x010b }, + { 0x0014, 0x010c }, + { 0x0014, 0x010d }, + { 0x0014, 0x010e }, + { 0x0014, 0x010f }, + { 0x0014, 0x0110 }, + { 0x0014, 0x0111 }, + { 0x0014, 0x0112 }, + { 0x0014, 0x0113 }, + { 0x0014, 0x0114 }, + { 0x0014, 0x0115 }, + { 0x0014, 0x0116 }, + { 0x0014, 0x0117 }, + { 0x0014, 0x0118 }, + { 0x0014, 0x0119 }, + { 0x0014, 0x011a }, + { 0x0014, 0x011b }, + { 0x0014, 0x011c }, + { 0x0014, 0x011d }, + { 0x0014, 0x011e }, + { 0x0014, 0x011f }, + { 0x0014, 0x0120 }, + { 0x0014, 0x0121 }, + { 0x0014, 0x0122 }, + { 0x0014, 0x0123 }, + { 0x0014, 0x0124 }, + { 0x0014, 0x0125 }, + { 0x0013, 0x0116 }, + { 0x0014, 0x0126 }, + { 0x0014, 0x0127 }, + { 0x0014, 0x0128 }, + { 0x0014, 0x0129 }, + { 0x0014, 0x012a }, + { 0x0014, 0x012b }, + { 0x0014, 0x012c }, + { 0x0014, 0x012d }, + { 0x0014, 0x012e }, + { 0x0014, 0x012f }, + { 0x0014, 0x0130 }, + { 0x0014, 0x0131 }, + { 0x0014, 0x0132 }, + { 0x0014, 0x0133 }, + { 0x0014, 0x0134 }, + { 0x0014, 0x0135 }, + { 0x0014, 0x0136 }, + { 0x0014, 0x0137 }, + { 0x0014, 0x0138 }, + { 0x0014, 0x0139 }, + { 0x0014, 0x013a }, + { 0x0014, 0x013b }, + { 0x0014, 0x013c }, + { 0x0014, 0x013d }, + { 0x0014, 0x013e }, + { 0x0014, 0x013f }, + { 0x0014, 0x0140 }, + { 0x0014, 0x0141 }, + { 0x0014, 0x0142 }, + { 0x0014, 0x0143 }, + { 0x0014, 0x0144 }, + { 0x0014, 0x0145 }, + { 0x0014, 0x0146 }, + { 0x0014, 0x0147 }, + { 0x0014, 0x0148 }, + { 0x0014, 0x0149 }, + { 0x0014, 0x014a }, + { 0x0014, 0x014b }, + { 0x0014, 0x014c }, + { 0x0014, 0x014d }, + { 0x0014, 0x014e }, + { 0x0014, 0x014f }, + { 0x0014, 0x0150 }, + { 0x0014, 0x0151 }, + { 0x0014, 0x0152 }, + { 0x0014, 0x0153 }, + { 0x0014, 0x0154 }, + { 0x0014, 0x0155 }, + { 0x0014, 0x0156 }, + { 0x0014, 0x0157 }, + { 0x0014, 0x0158 }, + { 0x0014, 0x0159 }, + { 0x0014, 0x015a }, + { 0x0014, 0x015b }, + { 0x0014, 0x015c }, + { 0x0014, 0x015d }, + { 0x0014, 0x015e }, + { 0x0014, 0x015f }, + { 0x0014, 0x0160 }, + { 0x0014, 0x0161 }, + { 0x0014, 0x0162 }, + { 0x0014, 0x0163 }, + { 0x0014, 0x0164 }, + { 0x0014, 0x0165 }, + { 0x0014, 0x0166 }, + { 0x0014, 0x0167 }, + { 0x0014, 0x0168 }, + { 0x0014, 0x0169 }, + { 0x0014, 0x016a }, + { 0x0014, 0x016b }, + { 0x0014, 0x016c }, + { 0x0014, 0x016d }, + { 0x0014, 0x016e }, + { 0x0014, 0x016f }, + { 0x0014, 0x0170 }, + { 0x0014, 0x0171 }, + { 0x0014, 0x0172 }, + { 0x0014, 0x0173 }, + { 0x0014, 0x0174 }, + { 0x0014, 0x0175 }, + { 0x0014, 0x0176 }, + { 0x0014, 0x0177 }, + { 0x0014, 0x0178 }, + { 0x0014, 0x0179 }, + { 0x0014, 0x017a }, + { 0x0014, 0x017b }, + { 0x0014, 0x017c }, + { 0x0014, 0x017d }, + { 0x0014, 0x017e }, + { 0x0014, 0x017f }, + { 0x0014, 0x0180 }, + { 0x0014, 0x0181 }, + { 0x0014, 0x0182 }, + { 0x0014, 0x0183 }, + { 0x0014, 0x0184 }, + { 0x0014, 0x0185 }, + { 0x0014, 0x0186 }, + { 0x0014, 0x0187 }, + { 0x0014, 0x0188 }, + { 0x0014, 0x0189 }, + { 0x0014, 0x018a }, + { 0x0014, 0x018b }, + { 0x0014, 0x018c }, + { 0x0014, 0x018d }, + { 0x0014, 0x018e }, + { 0x0014, 0x018f }, + { 0x0014, 0x0190 }, + { 0x0014, 0x0191 }, + { 0x0014, 0x0192 }, + { 0x0014, 0x0193 }, + { 0x0014, 0x0194 }, + { 0x0014, 0x0195 }, + { 0x0014, 0x0196 }, + { 0x0014, 0x0197 }, + { 0x0014, 0x0198 }, + { 0x0014, 0x0199 }, + { 0x0014, 0x019a }, + { 0x0014, 0x019b }, + { 0x0014, 0x019c }, + { 0x0014, 0x019d }, + { 0x0014, 0x019e }, + { 0x0014, 0x019f }, + { 0x0014, 0x01a0 }, + { 0x0014, 0x01a1 }, + { 0x0014, 0x01a2 }, + { 0x0014, 0x01a3 }, + { 0x0014, 0x01a4 }, + { 0x0014, 0x01a5 }, + { 0x0014, 0x01a6 }, + { 0x0014, 0x01a7 }, + { 0x0014, 0x01a8 }, + { 0x0014, 0x01a9 }, + { 0x0014, 0x01aa }, + { 0x0014, 0x01ab }, + { 0x0014, 0x01ac }, + { 0x0014, 0x01ad }, + { 0x0014, 0x01ae }, + { 0x0014, 0x01af }, + { 0x0014, 0x01b0 }, + { 0x0014, 0x01b1 }, + { 0x0014, 0x01b2 }, + { 0x0014, 0x01b3 }, + { 0x0014, 0x01b4 }, + { 0x0014, 0x01b5 }, + { 0x0014, 0x01b6 }, + { 0x0014, 0x01b7 }, + { 0x0014, 0x01b8 }, + { 0x0014, 0x01b9 }, + { 0x0014, 0x01ba }, + { 0x0014, 0x01bb }, + { 0x0014, 0x01bc }, + { 0x0014, 0x01bd }, + { 0x0014, 0x01be }, + { 0x0014, 0x01bf }, + { 0x0014, 0x01c0 }, + { 0x0014, 0x01c1 }, + { 0x0014, 0x01c2 }, + { 0x0014, 0x01c3 }, + { 0x0014, 0x01c4 }, + { 0x0014, 0x01c5 }, + { 0x0014, 0x01c6 }, + { 0x0014, 0x01c7 }, + { 0x0014, 0x01c8 }, + { 0x0014, 0x01c9 }, + { 0x0014, 0x01ca }, + { 0x0014, 0x01cb }, + { 0x0014, 0x01cc }, + { 0x0014, 0x01cd }, + { 0x0014, 0x01ce }, + { 0x0014, 0x01cf }, + { 0x0014, 0x01d0 }, + { 0x0014, 0x01d1 }, + { 0x0014, 0x01d2 }, + { 0x0014, 0x01d3 }, + { 0x0014, 0x01d4 }, + { 0x0014, 0x01d5 }, + { 0x0014, 0x01d6 }, + { 0x0014, 0x01d7 }, + { 0x0014, 0x01d8 }, + { 0x0014, 0x01d9 }, + { 0x0014, 0x01da }, + { 0x0014, 0x01db }, + { 0x0014, 0x01dc }, + { 0x0014, 0x01dd }, + { 0x0014, 0x01de }, + { 0x0014, 0x01df }, + { 0x0014, 0x01e0 }, + { 0x0014, 0x01e1 }, + { 0x0014, 0x01e2 }, + { 0x0014, 0x01e3 }, + { 0x0014, 0x01e4 }, + { 0x0014, 0x01e5 }, + { 0x0014, 0x01e6 }, + { 0x0014, 0x01e7 }, + { 0x0014, 0x01e8 }, + { 0x0014, 0x01e9 }, + { 0x0014, 0x01ea }, + { 0x0014, 0x01eb }, + { 0x0014, 0x01ec }, + { 0x0014, 0x01ed }, + { 0x0014, 0x01ee }, + { 0x0014, 0x01ef }, + { 0x0014, 0x01f0 }, + { 0x0014, 0x01f1 }, + { 0x0014, 0x01f2 }, + { 0x0014, 0x01f3 }, + { 0x0014, 0x01f4 }, + { 0x0014, 0x01f5 }, + { 0x0014, 0x01f6 }, + { 0x0014, 0x01f7 }, + { 0x0014, 0x01f8 }, + { 0x0014, 0x01f9 }, + { 0x0014, 0x01fa }, + { 0x0014, 0x01fb }, + { 0x0014, 0x01fc }, + { 0x0014, 0x01fd }, + { 0x0014, 0x01fe }, + { 0x0014, 0x01ff }, + { 0x0014, 0x0200 }, + { 0x0014, 0x0201 }, + { 0x0014, 0x0202 }, + { 0x0014, 0x0203 }, + { 0x0014, 0x0204 }, + { 0x0014, 0x0205 }, + { 0x0014, 0x0206 }, + { 0x0014, 0x0207 }, + { 0x0014, 0x0208 }, + { 0x0014, 0x0209 }, + { 0x0014, 0x020a }, + { 0x0014, 0x020b }, + { 0x0014, 0x020c }, + { 0x0014, 0x020d }, + { 0x0014, 0x020e }, + { 0x0014, 0x020f }, + { 0x0014, 0x0210 }, + { 0x0014, 0x0211 }, + { 0x0014, 0x0212 }, + { 0x0014, 0x0213 }, + { 0x0014, 0x0214 }, + { 0x0014, 0x0215 }, + { 0x0013, 0x0117 }, + + }; + + +const uint16_t c_aauiLCLDHuffEnc17[729][2] = + { + { 0x0006, 0x0012 }, + { 0x0006, 0x0013 }, + { 0x0006, 0x0014 }, + { 0x0006, 0x0015 }, + { 0x0007, 0x000f }, + { 0x0007, 0x0010 }, + { 0x0007, 0x0011 }, + { 0x0008, 0x000e }, + { 0x0008, 0x000f }, + { 0x0009, 0x000f }, + { 0x000a, 0x000f }, + { 0x000c, 0x0011 }, + { 0x000d, 0x0014 }, + { 0x000e, 0x0017 }, + { 0x0010, 0x002d }, + { 0x0011, 0x004c }, + { 0x0012, 0x008a }, + { 0x0014, 0x0000 }, + { 0x0014, 0x0001 }, + { 0x0014, 0x0002 }, + { 0x0014, 0x0003 }, + { 0x0014, 0x0004 }, + { 0x0014, 0x0005 }, + { 0x0014, 0x0006 }, + { 0x0014, 0x0007 }, + { 0x0014, 0x0008 }, + { 0x0014, 0x0009 }, + { 0x0006, 0x0016 }, + { 0x0005, 0x0018 }, + { 0x0005, 0x0019 }, + { 0x0005, 0x001a }, + { 0x0006, 0x0017 }, + { 0x0006, 0x0018 }, + { 0x0006, 0x0019 }, + { 0x0007, 0x0012 }, + { 0x0007, 0x0013 }, + { 0x0008, 0x0010 }, + { 0x000a, 0x0010 }, + { 0x000b, 0x0011 }, + { 0x000c, 0x0012 }, + { 0x000e, 0x0018 }, + { 0x000f, 0x0020 }, + { 0x0011, 0x004d }, + { 0x0013, 0x00e4 }, + { 0x0014, 0x000a }, + { 0x0014, 0x000b }, + { 0x0014, 0x000c }, + { 0x0014, 0x000d }, + { 0x0014, 0x000e }, + { 0x0014, 0x000f }, + { 0x0014, 0x0010 }, + { 0x0014, 0x0011 }, + { 0x0014, 0x0012 }, + { 0x0014, 0x0013 }, + { 0x0006, 0x001a }, + { 0x0005, 0x001b }, + { 0x0005, 0x001c }, + { 0x0005, 0x001d }, + { 0x0006, 0x001b }, + { 0x0006, 0x001c }, + { 0x0006, 0x001d }, + { 0x0007, 0x0014 }, + { 0x0008, 0x0011 }, + { 0x0009, 0x0010 }, + { 0x000a, 0x0011 }, + { 0x000b, 0x0012 }, + { 0x000c, 0x0013 }, + { 0x000e, 0x0019 }, + { 0x000f, 0x0021 }, + { 0x0010, 0x002e }, + { 0x0013, 0x00e5 }, + { 0x0013, 0x00e6 }, + { 0x0014, 0x0014 }, + { 0x0014, 0x0015 }, + { 0x0014, 0x0016 }, + { 0x0014, 0x0017 }, + { 0x0014, 0x0018 }, + { 0x0014, 0x0019 }, + { 0x0014, 0x001a }, + { 0x0014, 0x001b }, + { 0x0014, 0x001c }, + { 0x0006, 0x001e }, + { 0x0005, 0x001e }, + { 0x0005, 0x001f }, + { 0x0006, 0x001f }, + { 0x0006, 0x0020 }, + { 0x0006, 0x0021 }, + { 0x0006, 0x0022 }, + { 0x0007, 0x0015 }, + { 0x0008, 0x0012 }, + { 0x0009, 0x0011 }, + { 0x000a, 0x0012 }, + { 0x000b, 0x0013 }, + { 0x000c, 0x0014 }, + { 0x000e, 0x001a }, + { 0x000f, 0x0022 }, + { 0x0010, 0x002f }, + { 0x0013, 0x00e7 }, + { 0x0013, 0x00e8 }, + { 0x0014, 0x001d }, + { 0x0014, 0x001e }, + { 0x0014, 0x001f }, + { 0x0014, 0x0020 }, + { 0x0014, 0x0021 }, + { 0x0014, 0x0022 }, + { 0x0014, 0x0023 }, + { 0x0014, 0x0024 }, + { 0x0014, 0x0025 }, + { 0x0006, 0x0023 }, + { 0x0006, 0x0024 }, + { 0x0006, 0x0025 }, + { 0x0006, 0x0026 }, + { 0x0006, 0x0027 }, + { 0x0006, 0x0028 }, + { 0x0007, 0x0016 }, + { 0x0007, 0x0017 }, + { 0x0008, 0x0013 }, + { 0x0009, 0x0012 }, + { 0x000a, 0x0013 }, + { 0x000c, 0x0015 }, + { 0x000d, 0x0015 }, + { 0x000f, 0x0023 }, + { 0x0010, 0x0030 }, + { 0x0011, 0x004e }, + { 0x0014, 0x0026 }, + { 0x0014, 0x0027 }, + { 0x0014, 0x0028 }, + { 0x0014, 0x0029 }, + { 0x0014, 0x002a }, + { 0x0014, 0x002b }, + { 0x0014, 0x002c }, + { 0x0014, 0x002d }, + { 0x0014, 0x002e }, + { 0x0014, 0x002f }, + { 0x0014, 0x0030 }, + { 0x0007, 0x0018 }, + { 0x0006, 0x0029 }, + { 0x0006, 0x002a }, + { 0x0006, 0x002b }, + { 0x0006, 0x002c }, + { 0x0007, 0x0019 }, + { 0x0007, 0x001a }, + { 0x0008, 0x0014 }, + { 0x0009, 0x0013 }, + { 0x000a, 0x0014 }, + { 0x000b, 0x0014 }, + { 0x000c, 0x0016 }, + { 0x000d, 0x0016 }, + { 0x000f, 0x0024 }, + { 0x0010, 0x0031 }, + { 0x0011, 0x004f }, + { 0x0014, 0x0031 }, + { 0x0014, 0x0032 }, + { 0x0014, 0x0033 }, + { 0x0014, 0x0034 }, + { 0x0014, 0x0035 }, + { 0x0014, 0x0036 }, + { 0x0014, 0x0037 }, + { 0x0014, 0x0038 }, + { 0x0014, 0x0039 }, + { 0x0014, 0x003a }, + { 0x0014, 0x003b }, + { 0x0007, 0x001b }, + { 0x0006, 0x002d }, + { 0x0006, 0x002e }, + { 0x0006, 0x002f }, + { 0x0007, 0x001c }, + { 0x0007, 0x001d }, + { 0x0008, 0x0015 }, + { 0x0009, 0x0014 }, + { 0x000a, 0x0015 }, + { 0x000a, 0x0016 }, + { 0x000c, 0x0017 }, + { 0x000d, 0x0017 }, + { 0x000e, 0x001b }, + { 0x000f, 0x0025 }, + { 0x0011, 0x0050 }, + { 0x0011, 0x0051 }, + { 0x0014, 0x003c }, + { 0x0014, 0x003d }, + { 0x0014, 0x003e }, + { 0x0014, 0x003f }, + { 0x0014, 0x0040 }, + { 0x0014, 0x0041 }, + { 0x0014, 0x0042 }, + { 0x0014, 0x0043 }, + { 0x0014, 0x0044 }, + { 0x0014, 0x0045 }, + { 0x0014, 0x0046 }, + { 0x0008, 0x0016 }, + { 0x0007, 0x001e }, + { 0x0007, 0x001f }, + { 0x0007, 0x0020 }, + { 0x0007, 0x0021 }, + { 0x0008, 0x0017 }, + { 0x0008, 0x0018 }, + { 0x0009, 0x0015 }, + { 0x000a, 0x0017 }, + { 0x000b, 0x0015 }, + { 0x000c, 0x0018 }, + { 0x000e, 0x001c }, + { 0x000e, 0x001d }, + { 0x0010, 0x0032 }, + { 0x0012, 0x008b }, + { 0x0012, 0x008c }, + { 0x0014, 0x0047 }, + { 0x0014, 0x0048 }, + { 0x0014, 0x0049 }, + { 0x0014, 0x004a }, + { 0x0014, 0x004b }, + { 0x0014, 0x004c }, + { 0x0014, 0x004d }, + { 0x0014, 0x004e }, + { 0x0014, 0x004f }, + { 0x0014, 0x0050 }, + { 0x0014, 0x0051 }, + { 0x0008, 0x0019 }, + { 0x0007, 0x0022 }, + { 0x0007, 0x0023 }, + { 0x0008, 0x001a }, + { 0x0008, 0x001b }, + { 0x0009, 0x0016 }, + { 0x0009, 0x0017 }, + { 0x000a, 0x0018 }, + { 0x000b, 0x0016 }, + { 0x000c, 0x0019 }, + { 0x000d, 0x0018 }, + { 0x000e, 0x001e }, + { 0x0010, 0x0033 }, + { 0x0011, 0x0052 }, + { 0x0014, 0x0052 }, + { 0x0013, 0x00e9 }, + { 0x0014, 0x0053 }, + { 0x0014, 0x0054 }, + { 0x0014, 0x0055 }, + { 0x0014, 0x0056 }, + { 0x0014, 0x0057 }, + { 0x0014, 0x0058 }, + { 0x0014, 0x0059 }, + { 0x0014, 0x005a }, + { 0x0014, 0x005b }, + { 0x0014, 0x005c }, + { 0x0014, 0x005d }, + { 0x0009, 0x0018 }, + { 0x0008, 0x001c }, + { 0x0008, 0x001d }, + { 0x0009, 0x0019 }, + { 0x0009, 0x001a }, + { 0x000a, 0x0019 }, + { 0x000a, 0x001a }, + { 0x000b, 0x0017 }, + { 0x000c, 0x001a }, + { 0x000d, 0x0019 }, + { 0x000e, 0x001f }, + { 0x000f, 0x0026 }, + { 0x0010, 0x0034 }, + { 0x0012, 0x008d }, + { 0x0013, 0x00ea }, + { 0x0014, 0x005e }, + { 0x0014, 0x005f }, + { 0x0014, 0x0060 }, + { 0x0014, 0x0061 }, + { 0x0014, 0x0062 }, + { 0x0014, 0x0063 }, + { 0x0014, 0x0064 }, + { 0x0014, 0x0065 }, + { 0x0014, 0x0066 }, + { 0x0014, 0x0067 }, + { 0x0014, 0x0068 }, + { 0x0014, 0x0069 }, + { 0x000b, 0x0018 }, + { 0x0009, 0x001b }, + { 0x000a, 0x001b }, + { 0x000a, 0x001c }, + { 0x000a, 0x001d }, + { 0x000b, 0x0019 }, + { 0x000b, 0x001a }, + { 0x000c, 0x001b }, + { 0x000d, 0x001a }, + { 0x000e, 0x0020 }, + { 0x000f, 0x0027 }, + { 0x0012, 0x008e }, + { 0x0011, 0x0053 }, + { 0x0013, 0x00eb }, + { 0x0014, 0x006a }, + { 0x0014, 0x006b }, + { 0x0014, 0x006c }, + { 0x0014, 0x006d }, + { 0x0014, 0x006e }, + { 0x0014, 0x006f }, + { 0x0014, 0x0070 }, + { 0x0014, 0x0071 }, + { 0x0014, 0x0072 }, + { 0x0014, 0x0073 }, + { 0x0014, 0x0074 }, + { 0x0014, 0x0075 }, + { 0x0014, 0x0076 }, + { 0x000c, 0x001c }, + { 0x000b, 0x001b }, + { 0x000b, 0x001c }, + { 0x000b, 0x001d }, + { 0x000c, 0x001d }, + { 0x000c, 0x001e }, + { 0x000d, 0x001b }, + { 0x000d, 0x001c }, + { 0x000e, 0x0021 }, + { 0x0010, 0x0035 }, + { 0x0010, 0x0036 }, + { 0x0011, 0x0054 }, + { 0x0013, 0x00ec }, + { 0x0014, 0x0077 }, + { 0x0014, 0x0078 }, + { 0x0014, 0x0079 }, + { 0x0014, 0x007a }, + { 0x0014, 0x007b }, + { 0x0014, 0x007c }, + { 0x0014, 0x007d }, + { 0x0014, 0x007e }, + { 0x0014, 0x007f }, + { 0x0014, 0x0080 }, + { 0x0014, 0x0081 }, + { 0x0014, 0x0082 }, + { 0x0014, 0x0083 }, + { 0x0014, 0x0084 }, + { 0x000d, 0x001d }, + { 0x000c, 0x001f }, + { 0x000c, 0x0020 }, + { 0x000c, 0x0021 }, + { 0x000d, 0x001e }, + { 0x000d, 0x001f }, + { 0x000e, 0x0022 }, + { 0x000f, 0x0028 }, + { 0x0010, 0x0037 }, + { 0x0010, 0x0038 }, + { 0x0010, 0x0039 }, + { 0x0012, 0x008f }, + { 0x0013, 0x00ed }, + { 0x0014, 0x0085 }, + { 0x0014, 0x0086 }, + { 0x0014, 0x0087 }, + { 0x0014, 0x0088 }, + { 0x0014, 0x0089 }, + { 0x0014, 0x008a }, + { 0x0014, 0x008b }, + { 0x0014, 0x008c }, + { 0x0014, 0x008d }, + { 0x0014, 0x008e }, + { 0x0014, 0x008f }, + { 0x0014, 0x0090 }, + { 0x0014, 0x0091 }, + { 0x0014, 0x0092 }, + { 0x000e, 0x0023 }, + { 0x000d, 0x0020 }, + { 0x000d, 0x0021 }, + { 0x000e, 0x0024 }, + { 0x000e, 0x0025 }, + { 0x000e, 0x0026 }, + { 0x000f, 0x0029 }, + { 0x0010, 0x003a }, + { 0x0010, 0x003b }, + { 0x0012, 0x0090 }, + { 0x0014, 0x0093 }, + { 0x0014, 0x0094 }, + { 0x0014, 0x0095 }, + { 0x0014, 0x0096 }, + { 0x0014, 0x0097 }, + { 0x0014, 0x0098 }, + { 0x0014, 0x0099 }, + { 0x0014, 0x009a }, + { 0x0014, 0x009b }, + { 0x0014, 0x009c }, + { 0x0014, 0x009d }, + { 0x0014, 0x009e }, + { 0x0014, 0x009f }, + { 0x0014, 0x00a0 }, + { 0x0014, 0x00a1 }, + { 0x0014, 0x00a2 }, + { 0x0014, 0x00a3 }, + { 0x000f, 0x002a }, + { 0x000e, 0x0027 }, + { 0x000f, 0x002b }, + { 0x000f, 0x002c }, + { 0x000f, 0x002d }, + { 0x0010, 0x003c }, + { 0x0010, 0x003d }, + { 0x0011, 0x0055 }, + { 0x0011, 0x0056 }, + { 0x0014, 0x00a4 }, + { 0x0014, 0x00a5 }, + { 0x0014, 0x00a6 }, + { 0x0014, 0x00a7 }, + { 0x0014, 0x00a8 }, + { 0x0014, 0x00a9 }, + { 0x0014, 0x00aa }, + { 0x0014, 0x00ab }, + { 0x0014, 0x00ac }, + { 0x0014, 0x00ad }, + { 0x0014, 0x00ae }, + { 0x0014, 0x00af }, + { 0x0014, 0x00b0 }, + { 0x0014, 0x00b1 }, + { 0x0014, 0x00b2 }, + { 0x0014, 0x00b3 }, + { 0x0014, 0x00b4 }, + { 0x0014, 0x00b5 }, + { 0x0012, 0x0091 }, + { 0x0010, 0x003e }, + { 0x0010, 0x003f }, + { 0x0011, 0x0057 }, + { 0x0011, 0x0058 }, + { 0x0011, 0x0059 }, + { 0x0012, 0x0092 }, + { 0x0013, 0x00ee }, + { 0x0013, 0x00ef }, + { 0x0012, 0x0093 }, + { 0x0014, 0x00b6 }, + { 0x0014, 0x00b7 }, + { 0x0014, 0x00b8 }, + { 0x0014, 0x00b9 }, + { 0x0014, 0x00ba }, + { 0x0014, 0x00bb }, + { 0x0014, 0x00bc }, + { 0x0014, 0x00bd }, + { 0x0014, 0x00be }, + { 0x0014, 0x00bf }, + { 0x0014, 0x00c0 }, + { 0x0014, 0x00c1 }, + { 0x0014, 0x00c2 }, + { 0x0014, 0x00c3 }, + { 0x0014, 0x00c4 }, + { 0x0014, 0x00c5 }, + { 0x0014, 0x00c6 }, + { 0x0013, 0x00f0 }, + { 0x0012, 0x0094 }, + { 0x0012, 0x0095 }, + { 0x0012, 0x0096 }, + { 0x0014, 0x00c7 }, + { 0x0014, 0x00c8 }, + { 0x0014, 0x00c9 }, + { 0x0014, 0x00ca }, + { 0x0014, 0x00cb }, + { 0x0014, 0x00cc }, + { 0x0014, 0x00cd }, + { 0x0014, 0x00ce }, + { 0x0014, 0x00cf }, + { 0x0014, 0x00d0 }, + { 0x0014, 0x00d1 }, + { 0x0014, 0x00d2 }, + { 0x0014, 0x00d3 }, + { 0x0014, 0x00d4 }, + { 0x0014, 0x00d5 }, + { 0x0014, 0x00d6 }, + { 0x0014, 0x00d7 }, + { 0x0014, 0x00d8 }, + { 0x0014, 0x00d9 }, + { 0x0014, 0x00da }, + { 0x0014, 0x00db }, + { 0x0014, 0x00dc }, + { 0x0014, 0x00dd }, + { 0x0014, 0x00de }, + { 0x0012, 0x0097 }, + { 0x0014, 0x00df }, + { 0x0014, 0x00e0 }, + { 0x0014, 0x00e1 }, + { 0x0014, 0x00e2 }, + { 0x0014, 0x00e3 }, + { 0x0014, 0x00e4 }, + { 0x0014, 0x00e5 }, + { 0x0014, 0x00e6 }, + { 0x0014, 0x00e7 }, + { 0x0014, 0x00e8 }, + { 0x0014, 0x00e9 }, + { 0x0014, 0x00ea }, + { 0x0014, 0x00eb }, + { 0x0014, 0x00ec }, + { 0x0014, 0x00ed }, + { 0x0014, 0x00ee }, + { 0x0014, 0x00ef }, + { 0x0014, 0x00f0 }, + { 0x0014, 0x00f1 }, + { 0x0014, 0x00f2 }, + { 0x0014, 0x00f3 }, + { 0x0014, 0x00f4 }, + { 0x0014, 0x00f5 }, + { 0x0014, 0x00f6 }, + { 0x0014, 0x00f7 }, + { 0x0014, 0x00f8 }, + { 0x0014, 0x00f9 }, + { 0x0014, 0x00fa }, + { 0x0014, 0x00fb }, + { 0x0014, 0x00fc }, + { 0x0014, 0x00fd }, + { 0x0014, 0x00fe }, + { 0x0014, 0x00ff }, + { 0x0014, 0x0100 }, + { 0x0014, 0x0101 }, + { 0x0014, 0x0102 }, + { 0x0014, 0x0103 }, + { 0x0014, 0x0104 }, + { 0x0014, 0x0105 }, + { 0x0014, 0x0106 }, + { 0x0014, 0x0107 }, + { 0x0014, 0x0108 }, + { 0x0014, 0x0109 }, + { 0x0014, 0x010a }, + { 0x0014, 0x010b }, + { 0x0014, 0x010c }, + { 0x0014, 0x010d }, + { 0x0014, 0x010e }, + { 0x0014, 0x010f }, + { 0x0014, 0x0110 }, + { 0x0014, 0x0111 }, + { 0x0014, 0x0112 }, + { 0x0014, 0x0113 }, + { 0x0014, 0x0114 }, + { 0x0014, 0x0115 }, + { 0x0014, 0x0116 }, + { 0x0014, 0x0117 }, + { 0x0014, 0x0118 }, + { 0x0014, 0x0119 }, + { 0x0014, 0x011a }, + { 0x0014, 0x011b }, + { 0x0014, 0x011c }, + { 0x0014, 0x011d }, + { 0x0014, 0x011e }, + { 0x0014, 0x011f }, + { 0x0014, 0x0120 }, + { 0x0014, 0x0121 }, + { 0x0014, 0x0122 }, + { 0x0014, 0x0123 }, + { 0x0014, 0x0124 }, + { 0x0014, 0x0125 }, + { 0x0014, 0x0126 }, + { 0x0014, 0x0127 }, + { 0x0014, 0x0128 }, + { 0x0014, 0x0129 }, + { 0x0014, 0x012a }, + { 0x0014, 0x012b }, + { 0x0014, 0x012c }, + { 0x0014, 0x012d }, + { 0x0014, 0x012e }, + { 0x0014, 0x012f }, + { 0x0014, 0x0130 }, + { 0x0014, 0x0131 }, + { 0x0014, 0x0132 }, + { 0x0014, 0x0133 }, + { 0x0014, 0x0134 }, + { 0x0014, 0x0135 }, + { 0x0014, 0x0136 }, + { 0x0014, 0x0137 }, + { 0x0014, 0x0138 }, + { 0x0014, 0x0139 }, + { 0x0014, 0x013a }, + { 0x0014, 0x013b }, + { 0x0014, 0x013c }, + { 0x0014, 0x013d }, + { 0x0014, 0x013e }, + { 0x0014, 0x013f }, + { 0x0014, 0x0140 }, + { 0x0014, 0x0141 }, + { 0x0014, 0x0142 }, + { 0x0014, 0x0143 }, + { 0x0014, 0x0144 }, + { 0x0014, 0x0145 }, + { 0x0014, 0x0146 }, + { 0x0014, 0x0147 }, + { 0x0014, 0x0148 }, + { 0x0014, 0x0149 }, + { 0x0014, 0x014a }, + { 0x0014, 0x014b }, + { 0x0014, 0x014c }, + { 0x0014, 0x014d }, + { 0x0014, 0x014e }, + { 0x0014, 0x014f }, + { 0x0014, 0x0150 }, + { 0x0014, 0x0151 }, + { 0x0014, 0x0152 }, + { 0x0014, 0x0153 }, + { 0x0014, 0x0154 }, + { 0x0014, 0x0155 }, + { 0x0014, 0x0156 }, + { 0x0014, 0x0157 }, + { 0x0014, 0x0158 }, + { 0x0014, 0x0159 }, + { 0x0014, 0x015a }, + { 0x0014, 0x015b }, + { 0x0014, 0x015c }, + { 0x0014, 0x015d }, + { 0x0014, 0x015e }, + { 0x0014, 0x015f }, + { 0x0014, 0x0160 }, + { 0x0014, 0x0161 }, + { 0x0014, 0x0162 }, + { 0x0014, 0x0163 }, + { 0x0014, 0x0164 }, + { 0x0014, 0x0165 }, + { 0x0014, 0x0166 }, + { 0x0014, 0x0167 }, + { 0x0014, 0x0168 }, + { 0x0014, 0x0169 }, + { 0x0014, 0x016a }, + { 0x0014, 0x016b }, + { 0x0014, 0x016c }, + { 0x0014, 0x016d }, + { 0x0014, 0x016e }, + { 0x0014, 0x016f }, + { 0x0014, 0x0170 }, + { 0x0014, 0x0171 }, + { 0x0014, 0x0172 }, + { 0x0014, 0x0173 }, + { 0x0014, 0x0174 }, + { 0x0014, 0x0175 }, + { 0x0014, 0x0176 }, + { 0x0014, 0x0177 }, + { 0x0014, 0x0178 }, + { 0x0014, 0x0179 }, + { 0x0014, 0x017a }, + { 0x0014, 0x017b }, + { 0x0014, 0x017c }, + { 0x0014, 0x017d }, + { 0x0014, 0x017e }, + { 0x0014, 0x017f }, + { 0x0014, 0x0180 }, + { 0x0014, 0x0181 }, + { 0x0014, 0x0182 }, + { 0x0014, 0x0183 }, + { 0x0014, 0x0184 }, + { 0x0014, 0x0185 }, + { 0x0014, 0x0186 }, + { 0x0014, 0x0187 }, + { 0x0014, 0x0188 }, + { 0x0014, 0x0189 }, + { 0x0014, 0x018a }, + { 0x0014, 0x018b }, + { 0x0014, 0x018c }, + { 0x0014, 0x018d }, + { 0x0014, 0x018e }, + { 0x0014, 0x018f }, + { 0x0014, 0x0190 }, + { 0x0014, 0x0191 }, + { 0x0014, 0x0192 }, + { 0x0014, 0x0193 }, + { 0x0014, 0x0194 }, + { 0x0014, 0x0195 }, + { 0x0014, 0x0196 }, + { 0x0014, 0x0197 }, + { 0x0014, 0x0198 }, + { 0x0014, 0x0199 }, + { 0x0014, 0x019a }, + { 0x0014, 0x019b }, + { 0x0014, 0x019c }, + { 0x0014, 0x019d }, + { 0x0014, 0x019e }, + { 0x0014, 0x019f }, + { 0x0014, 0x01a0 }, + { 0x0014, 0x01a1 }, + { 0x0014, 0x01a2 }, + { 0x0014, 0x01a3 }, + { 0x0014, 0x01a4 }, + { 0x0014, 0x01a5 }, + { 0x0014, 0x01a6 }, + { 0x0014, 0x01a7 }, + { 0x0014, 0x01a8 }, + { 0x0014, 0x01a9 }, + { 0x0014, 0x01aa }, + { 0x0014, 0x01ab }, + { 0x0014, 0x01ac }, + { 0x0014, 0x01ad }, + { 0x0014, 0x01ae }, + { 0x0014, 0x01af }, + { 0x0014, 0x01b0 }, + { 0x0014, 0x01b1 }, + { 0x0014, 0x01b2 }, + { 0x0014, 0x01b3 }, + { 0x0014, 0x01b4 }, + { 0x0014, 0x01b5 }, + { 0x0014, 0x01b6 }, + { 0x0014, 0x01b7 }, + { 0x0014, 0x01b8 }, + { 0x0014, 0x01b9 }, + { 0x0014, 0x01ba }, + { 0x0014, 0x01bb }, + { 0x0014, 0x01bc }, + { 0x0014, 0x01bd }, + { 0x0014, 0x01be }, + { 0x0014, 0x01bf }, + { 0x0014, 0x01c0 }, + { 0x0014, 0x01c1 }, + { 0x0014, 0x01c2 }, + { 0x0014, 0x01c3 }, + { 0x0014, 0x01c4 }, + { 0x0014, 0x01c5 }, + { 0x0014, 0x01c6 }, + { 0x0014, 0x01c7 }, + { 0x0013, 0x00f1 }, + { 0x0013, 0x00f2 }, + { 0x0013, 0x00f3 }, + { 0x0013, 0x00f4 }, + { 0x0013, 0x00f5 }, + { 0x0013, 0x00f6 }, + { 0x0013, 0x00f7 }, + { 0x0013, 0x00f8 }, + { 0x0013, 0x00f9 }, + { 0x0013, 0x00fa }, + { 0x0013, 0x00fb }, + { 0x0013, 0x00fc }, + { 0x0013, 0x00fd }, + { 0x0013, 0x00fe }, + { 0x0013, 0x00ff }, + { 0x0013, 0x0100 }, + { 0x0013, 0x0101 }, + { 0x0013, 0x0102 }, + { 0x0013, 0x0103 }, + { 0x0013, 0x0104 }, + { 0x0013, 0x0105 }, + { 0x0013, 0x0106 }, + { 0x0013, 0x0107 }, + { 0x0013, 0x0108 }, + { 0x0013, 0x0109 }, + { 0x0013, 0x010a }, + { 0x0013, 0x010b }, + { 0x0013, 0x010c }, + { 0x0013, 0x010d }, + { 0x0013, 0x010e }, + { 0x0013, 0x010f }, + { 0x0013, 0x0110 }, + { 0x0013, 0x0111 }, + { 0x0013, 0x0112 }, + { 0x0013, 0x0113 }, + + }; + +const uint16_t c_aauiLCLDHuffEnc18[28][2] = + { + { 0x0004, 0x0001 }, + { 0x0003, 0x0002 }, + { 0x0003, 0x0003 }, + { 0x0003, 0x0004 }, + { 0x0003, 0x0005 }, + { 0x0003, 0x0006 }, + { 0x0003, 0x0007 }, + { 0x0004, 0x0002 }, + { 0x0004, 0x0003 }, + { 0x0005, 0x0001 }, + { 0x0006, 0x0001 }, + { 0x0007, 0x0001 }, + { 0x0008, 0x0001 }, + { 0x0009, 0x0001 }, + { 0x000a, 0x0001 }, + { 0x000b, 0x0001 }, + { 0x000c, 0x0001 }, + { 0x000d, 0x0001 }, + { 0x000e, 0x0001 }, + { 0x000f, 0x0001 }, + { 0x0011, 0x0003 }, + { 0x0012, 0x0001 }, + { 0x0012, 0x0002 }, + { 0x0012, 0x0003 }, + { 0x0013, 0x0000 }, + { 0x0013, 0x0001 }, + { 0x0012, 0x0004 }, + { 0x0012, 0x0005 }, + + }; + + +const uint16_t c_aauiLCLDHuffEnc19[29][2] = + { + { 0x0004, 0x0002 }, + { 0x0003, 0x0003 }, + { 0x0003, 0x0004 }, + { 0x0003, 0x0005 }, + { 0x0003, 0x0006 }, + { 0x0003, 0x0007 }, + { 0x0004, 0x0003 }, + { 0x0004, 0x0004 }, + { 0x0004, 0x0005 }, + { 0x0005, 0x0001 }, + { 0x0005, 0x0002 }, + { 0x0005, 0x0003 }, + { 0x0006, 0x0001 }, + { 0x0007, 0x0001 }, + { 0x0008, 0x0001 }, + { 0x0009, 0x0001 }, + { 0x000a, 0x0001 }, + { 0x000b, 0x0001 }, + { 0x000c, 0x0001 }, + { 0x000d, 0x0001 }, + { 0x000e, 0x0001 }, + { 0x000f, 0x0001 }, + { 0x0010, 0x0001 }, + { 0x0012, 0x0002 }, + { 0x0013, 0x0000 }, + { 0x0013, 0x0001 }, + { 0x0013, 0x0002 }, + { 0x0013, 0x0003 }, + { 0x0012, 0x0003 }, + + }; + +const uint16_t c_aauiLCLDHuffEnc20[32][2] = + { + { 0x0004, 0x0002 }, + { 0x0003, 0x0005 }, + { 0x0003, 0x0006 }, + { 0x0003, 0x0007 }, + { 0x0004, 0x0003 }, + { 0x0004, 0x0004 }, + { 0x0004, 0x0005 }, + { 0x0004, 0x0006 }, + { 0x0004, 0x0007 }, + { 0x0004, 0x0008 }, + { 0x0004, 0x0009 }, + { 0x0005, 0x0002 }, + { 0x0005, 0x0003 }, + { 0x0006, 0x0001 }, + { 0x0006, 0x0002 }, + { 0x0006, 0x0003 }, + { 0x0007, 0x0001 }, + { 0x0008, 0x0001 }, + { 0x0009, 0x0001 }, + { 0x000a, 0x0001 }, + { 0x000b, 0x0001 }, + { 0x000c, 0x0001 }, + { 0x000d, 0x0001 }, + { 0x000e, 0x0001 }, + { 0x000f, 0x0001 }, + { 0x0010, 0x0001 }, + { 0x0011, 0x0001 }, + { 0x0014, 0x0000 }, + { 0x0014, 0x0001 }, + { 0x0013, 0x0001 }, + { 0x0013, 0x0002 }, + { 0x0013, 0x0003 }, + }; + +const uint16_t c_aauiLCLDHuffEnc21[37][2] = + { + { 0x0005, 0x0002 }, + { 0x0003, 0x0006 }, + { 0x0003, 0x0007 }, + { 0x0004, 0x0003 }, + { 0x0004, 0x0004 }, + { 0x0004, 0x0005 }, + { 0x0004, 0x0006 }, + { 0x0004, 0x0007 }, + { 0x0004, 0x0008 }, + { 0x0004, 0x0009 }, + { 0x0004, 0x000a }, + { 0x0004, 0x000b }, + { 0x0005, 0x0003 }, + { 0x0005, 0x0004 }, + { 0x0005, 0x0005 }, + { 0x0006, 0x0002 }, + { 0x0006, 0x0003 }, + { 0x0007, 0x0002 }, + { 0x0007, 0x0003 }, + { 0x0008, 0x0001 }, + { 0x0008, 0x0002 }, + { 0x0008, 0x0003 }, + { 0x0009, 0x0001 }, + { 0x000b, 0x0001 }, + { 0x000b, 0x0002 }, + { 0x000b, 0x0003 }, + { 0x000c, 0x0001 }, + { 0x000d, 0x0001 }, + { 0x000e, 0x0001 }, + { 0x000f, 0x0001 }, + { 0x0010, 0x0001 }, + { 0x0011, 0x0001 }, + { 0x0014, 0x0000 }, + { 0x0014, 0x0001 }, + { 0x0013, 0x0001 }, + { 0x0013, 0x0002 }, + { 0x0013, 0x0003 }, + + }; + +const uint16_t c_aauiLCLDHuffEnc22[39][2] = + { + { 0x0005, 0x0002 }, + { 0x0004, 0x0004 }, + { 0x0004, 0x0005 }, + { 0x0004, 0x0006 }, + { 0x0004, 0x0007 }, + { 0x0004, 0x0008 }, + { 0x0004, 0x0009 }, + { 0x0004, 0x000a }, + { 0x0004, 0x000b }, + { 0x0004, 0x000c }, + { 0x0004, 0x000d }, + { 0x0004, 0x000e }, + { 0x0004, 0x000f }, + { 0x0005, 0x0003 }, + { 0x0005, 0x0004 }, + { 0x0005, 0x0005 }, + { 0x0005, 0x0006 }, + { 0x0005, 0x0007 }, + { 0x0006, 0x0002 }, + { 0x0006, 0x0003 }, + { 0x0007, 0x0002 }, + { 0x0007, 0x0003 }, + { 0x0008, 0x0002 }, + { 0x0008, 0x0003 }, + { 0x0009, 0x0002 }, + { 0x0009, 0x0003 }, + { 0x000a, 0x0001 }, + { 0x000a, 0x0002 }, + { 0x000a, 0x0003 }, + { 0x000c, 0x0001 }, + { 0x000c, 0x0002 }, + { 0x000c, 0x0003 }, + { 0x000e, 0x0001 }, + { 0x000e, 0x0002 }, + { 0x000f, 0x0001 }, + { 0x000e, 0x0003 }, + { 0x0011, 0x0000 }, + { 0x0010, 0x0001 }, + { 0x0011, 0x0001 }, + + }; + +const uint16_t c_aauiLCLDHuffEnc23[46][2] = + { + { 0x0005, 0x0003 }, + { 0x0004, 0x0006 }, + { 0x0004, 0x0007 }, + { 0x0004, 0x0008 }, + { 0x0004, 0x0009 }, + { 0x0004, 0x000a }, + { 0x0004, 0x000b }, + { 0x0004, 0x000c }, + { 0x0004, 0x000d }, + { 0x0004, 0x000e }, + { 0x0004, 0x000f }, + { 0x0005, 0x0004 }, + { 0x0005, 0x0005 }, + { 0x0005, 0x0006 }, + { 0x0005, 0x0007 }, + { 0x0005, 0x0008 }, + { 0x0005, 0x0009 }, + { 0x0005, 0x000a }, + { 0x0005, 0x000b }, + { 0x0006, 0x0003 }, + { 0x0006, 0x0004 }, + { 0x0006, 0x0005 }, + { 0x0007, 0x0002 }, + { 0x0007, 0x0003 }, + { 0x0007, 0x0004 }, + { 0x0007, 0x0005 }, + { 0x0008, 0x0002 }, + { 0x0008, 0x0003 }, + { 0x0009, 0x0002 }, + { 0x0009, 0x0003 }, + { 0x000a, 0x0002 }, + { 0x000a, 0x0003 }, + { 0x000b, 0x0002 }, + { 0x000b, 0x0003 }, + { 0x000c, 0x0002 }, + { 0x000c, 0x0003 }, + { 0x000d, 0x0002 }, + { 0x000d, 0x0003 }, + { 0x000e, 0x0001 }, + { 0x000e, 0x0002 }, + { 0x000e, 0x0003 }, + { 0x000f, 0x0001 }, + { 0x0010, 0x0001 }, + { 0x0012, 0x0000 }, + { 0x0012, 0x0001 }, + { 0x0011, 0x0001 }, + + }; + +const uint16_t c_aauiLCLDHuffEnc24[55][2] = + { + { 0x0005, 0x0004 }, + { 0x0004, 0x0009 }, + { 0x0004, 0x000a }, + { 0x0004, 0x000b }, + { 0x0004, 0x000c }, + { 0x0004, 0x000d }, + { 0x0004, 0x000e }, + { 0x0004, 0x000f }, + { 0x0005, 0x0005 }, + { 0x0005, 0x0006 }, + { 0x0005, 0x0007 }, + { 0x0005, 0x0008 }, + { 0x0005, 0x0009 }, + { 0x0005, 0x000a }, + { 0x0005, 0x000b }, + { 0x0005, 0x000c }, + { 0x0005, 0x000d }, + { 0x0005, 0x000e }, + { 0x0005, 0x000f }, + { 0x0005, 0x0010 }, + { 0x0005, 0x0011 }, + { 0x0006, 0x0003 }, + { 0x0006, 0x0004 }, + { 0x0006, 0x0005 }, + { 0x0006, 0x0006 }, + { 0x0006, 0x0007 }, + { 0x0007, 0x0003 }, + { 0x0007, 0x0004 }, + { 0x0007, 0x0005 }, + { 0x0008, 0x0003 }, + { 0x0008, 0x0004 }, + { 0x0008, 0x0005 }, + { 0x0009, 0x0002 }, + { 0x0009, 0x0003 }, + { 0x0009, 0x0004 }, + { 0x0009, 0x0005 }, + { 0x000a, 0x0002 }, + { 0x000a, 0x0003 }, + { 0x000b, 0x0002 }, + { 0x000b, 0x0003 }, + { 0x000c, 0x0003 }, + { 0x000d, 0x0002 }, + { 0x000d, 0x0003 }, + { 0x000d, 0x0004 }, + { 0x000d, 0x0005 }, + { 0x000e, 0x0002 }, + { 0x000e, 0x0003 }, + { 0x000f, 0x0001 }, + { 0x000f, 0x0002 }, + { 0x000f, 0x0003 }, + { 0x0010, 0x0001 }, + { 0x0011, 0x0001 }, + { 0x0013, 0x0000 }, + { 0x0012, 0x0001 }, + { 0x0013, 0x0001 }, + + }; + +const uint16_t c_aauiLCLDHuffEnc25[65][2] = + { + { 0x0005, 0x0005 }, + { 0x0004, 0x000c }, + { 0x0004, 0x000d }, + { 0x0004, 0x000e }, + { 0x0005, 0x0006 }, + { 0x0004, 0x000f }, + { 0x0005, 0x0007 }, + { 0x0005, 0x0008 }, + { 0x0005, 0x0009 }, + { 0x0005, 0x000a }, + { 0x0005, 0x000b }, + { 0x0005, 0x000c }, + { 0x0005, 0x000d }, + { 0x0005, 0x000e }, + { 0x0005, 0x000f }, + { 0x0005, 0x0010 }, + { 0x0005, 0x0011 }, + { 0x0005, 0x0012 }, + { 0x0005, 0x0013 }, + { 0x0005, 0x0014 }, + { 0x0005, 0x0015 }, + { 0x0005, 0x0016 }, + { 0x0005, 0x0017 }, + { 0x0006, 0x0004 }, + { 0x0006, 0x0005 }, + { 0x0006, 0x0006 }, + { 0x0006, 0x0007 }, + { 0x0006, 0x0008 }, + { 0x0006, 0x0009 }, + { 0x0007, 0x0003 }, + { 0x0007, 0x0004 }, + { 0x0007, 0x0005 }, + { 0x0007, 0x0006 }, + { 0x0007, 0x0007 }, + { 0x0008, 0x0003 }, + { 0x0008, 0x0004 }, + { 0x0008, 0x0005 }, + { 0x0009, 0x0003 }, + { 0x0009, 0x0004 }, + { 0x0009, 0x0005 }, + { 0x000a, 0x0003 }, + { 0x000a, 0x0004 }, + { 0x000a, 0x0005 }, + { 0x000b, 0x0003 }, + { 0x000b, 0x0004 }, + { 0x000b, 0x0005 }, + { 0x000c, 0x0002 }, + { 0x000c, 0x0003 }, + { 0x000c, 0x0004 }, + { 0x000c, 0x0005 }, + { 0x000d, 0x0003 }, + { 0x000e, 0x0003 }, + { 0x000e, 0x0004 }, + { 0x000f, 0x0003 }, + { 0x000e, 0x0005 }, + { 0x000f, 0x0004 }, + { 0x0010, 0x0001 }, + { 0x000f, 0x0005 }, + { 0x0010, 0x0002 }, + { 0x0010, 0x0003 }, + { 0x0010, 0x0004 }, + { 0x0010, 0x0005 }, + { 0x0011, 0x0001 }, + { 0x0012, 0x0000 }, + { 0x0012, 0x0001 }, + + }; + +const uint16_t c_aauiLCLDHuffEnc26[77][2] = + { + { 0x0006, 0x0004 }, + { 0x0005, 0x0007 }, + { 0x0005, 0x0008 }, + { 0x0005, 0x0009 }, + { 0x0005, 0x000a }, + { 0x0005, 0x000b }, + { 0x0005, 0x000c }, + { 0x0005, 0x000d }, + { 0x0005, 0x000e }, + { 0x0005, 0x000f }, + { 0x0005, 0x0010 }, + { 0x0005, 0x0011 }, + { 0x0005, 0x0012 }, + { 0x0005, 0x0013 }, + { 0x0005, 0x0014 }, + { 0x0005, 0x0015 }, + { 0x0005, 0x0016 }, + { 0x0005, 0x0017 }, + { 0x0005, 0x0018 }, + { 0x0005, 0x0019 }, + { 0x0005, 0x001a }, + { 0x0005, 0x001b }, + { 0x0005, 0x001c }, + { 0x0005, 0x001d }, + { 0x0005, 0x001e }, + { 0x0005, 0x001f }, + { 0x0006, 0x0005 }, + { 0x0006, 0x0006 }, + { 0x0006, 0x0007 }, + { 0x0006, 0x0008 }, + { 0x0006, 0x0009 }, + { 0x0006, 0x000a }, + { 0x0006, 0x000b }, + { 0x0006, 0x000c }, + { 0x0006, 0x000d }, + { 0x0007, 0x0004 }, + { 0x0007, 0x0005 }, + { 0x0007, 0x0006 }, + { 0x0007, 0x0007 }, + { 0x0008, 0x0004 }, + { 0x0008, 0x0005 }, + { 0x0008, 0x0006 }, + { 0x0008, 0x0007 }, + { 0x0009, 0x0003 }, + { 0x0009, 0x0004 }, + { 0x0009, 0x0005 }, + { 0x0009, 0x0006 }, + { 0x0009, 0x0007 }, + { 0x000a, 0x0003 }, + { 0x000a, 0x0004 }, + { 0x000a, 0x0005 }, + { 0x000b, 0x0004 }, + { 0x000b, 0x0005 }, + { 0x000c, 0x0003 }, + { 0x000c, 0x0004 }, + { 0x000c, 0x0005 }, + { 0x000c, 0x0006 }, + { 0x000c, 0x0007 }, + { 0x000d, 0x0003 }, + { 0x000d, 0x0004 }, + { 0x000e, 0x0002 }, + { 0x000d, 0x0005 }, + { 0x000e, 0x0003 }, + { 0x000e, 0x0004 }, + { 0x000f, 0x0003 }, + { 0x000e, 0x0005 }, + { 0x0010, 0x0002 }, + { 0x0010, 0x0003 }, + { 0x0010, 0x0004 }, + { 0x0011, 0x0002 }, + { 0x0012, 0x0001 }, + { 0x0010, 0x0005 }, + { 0x0012, 0x0002 }, + { 0x0011, 0x0003 }, + { 0x0012, 0x0003 }, + { 0x0013, 0x0000 }, + { 0x0013, 0x0001 }, + + }; + + +const uint16_t c_aauiLCLDHuffEnc27[91][2] = + { + { 0x0006, 0x0006 }, + { 0x0005, 0x000b }, + { 0x0005, 0x000c }, + { 0x0005, 0x000d }, + { 0x0005, 0x000e }, + { 0x0005, 0x000f }, + { 0x0005, 0x0010 }, + { 0x0005, 0x0011 }, + { 0x0005, 0x0012 }, + { 0x0005, 0x0013 }, + { 0x0005, 0x0014 }, + { 0x0005, 0x0015 }, + { 0x0005, 0x0016 }, + { 0x0005, 0x0017 }, + { 0x0005, 0x0018 }, + { 0x0005, 0x0019 }, + { 0x0005, 0x001a }, + { 0x0005, 0x001b }, + { 0x0005, 0x001c }, + { 0x0005, 0x001d }, + { 0x0005, 0x001e }, + { 0x0005, 0x001f }, + { 0x0006, 0x0007 }, + { 0x0006, 0x0008 }, + { 0x0006, 0x0009 }, + { 0x0006, 0x000a }, + { 0x0006, 0x000b }, + { 0x0006, 0x000c }, + { 0x0006, 0x000d }, + { 0x0006, 0x000e }, + { 0x0006, 0x000f }, + { 0x0006, 0x0010 }, + { 0x0006, 0x0011 }, + { 0x0006, 0x0012 }, + { 0x0006, 0x0013 }, + { 0x0006, 0x0014 }, + { 0x0006, 0x0015 }, + { 0x0007, 0x0005 }, + { 0x0007, 0x0006 }, + { 0x0007, 0x0007 }, + { 0x0007, 0x0008 }, + { 0x0007, 0x0009 }, + { 0x0007, 0x000a }, + { 0x0007, 0x000b }, + { 0x0008, 0x0004 }, + { 0x0008, 0x0005 }, + { 0x0008, 0x0006 }, + { 0x0008, 0x0007 }, + { 0x0008, 0x0008 }, + { 0x0008, 0x0009 }, + { 0x0009, 0x0004 }, + { 0x0009, 0x0005 }, + { 0x0009, 0x0006 }, + { 0x0009, 0x0007 }, + { 0x000a, 0x0004 }, + { 0x000a, 0x0005 }, + { 0x000a, 0x0006 }, + { 0x000a, 0x0007 }, + { 0x000b, 0x0004 }, + { 0x000b, 0x0005 }, + { 0x000b, 0x0006 }, + { 0x000b, 0x0007 }, + { 0x000c, 0x0004 }, + { 0x000c, 0x0005 }, + { 0x000c, 0x0006 }, + { 0x000c, 0x0007 }, + { 0x000d, 0x0004 }, + { 0x000d, 0x0005 }, + { 0x000d, 0x0006 }, + { 0x000d, 0x0007 }, + { 0x000e, 0x0003 }, + { 0x000e, 0x0004 }, + { 0x000e, 0x0005 }, + { 0x000e, 0x0006 }, + { 0x000e, 0x0007 }, + { 0x000f, 0x0003 }, + { 0x000f, 0x0004 }, + { 0x0010, 0x0003 }, + { 0x000f, 0x0005 }, + { 0x0012, 0x0000 }, + { 0x0010, 0x0004 }, + { 0x0010, 0x0005 }, + { 0x0012, 0x0001 }, + { 0x0012, 0x0002 }, + { 0x0011, 0x0004 }, + { 0x0011, 0x0005 }, + { 0x0012, 0x0003 }, + { 0x0012, 0x0004 }, + { 0x0012, 0x0005 }, + { 0x0012, 0x0006 }, + { 0x0012, 0x0007 }, + + }; + +const uint16_t c_aauiLCLDHuffEnc28[109][2] = + { + { 0x0006, 0x0008 }, + { 0x0005, 0x0010 }, + { 0x0005, 0x0011 }, + { 0x0005, 0x0012 }, + { 0x0005, 0x0013 }, + { 0x0005, 0x0014 }, + { 0x0005, 0x0015 }, + { 0x0005, 0x0016 }, + { 0x0005, 0x0017 }, + { 0x0005, 0x0018 }, + { 0x0005, 0x0019 }, + { 0x0005, 0x001a }, + { 0x0005, 0x001b }, + { 0x0005, 0x001c }, + { 0x0005, 0x001d }, + { 0x0005, 0x001e }, + { 0x0006, 0x0009 }, + { 0x0005, 0x001f }, + { 0x0006, 0x000a }, + { 0x0006, 0x000b }, + { 0x0006, 0x000c }, + { 0x0006, 0x000d }, + { 0x0006, 0x000e }, + { 0x0006, 0x000f }, + { 0x0006, 0x0010 }, + { 0x0006, 0x0011 }, + { 0x0006, 0x0012 }, + { 0x0006, 0x0013 }, + { 0x0006, 0x0014 }, + { 0x0006, 0x0015 }, + { 0x0006, 0x0016 }, + { 0x0006, 0x0017 }, + { 0x0006, 0x0018 }, + { 0x0006, 0x0019 }, + { 0x0006, 0x001a }, + { 0x0006, 0x001b }, + { 0x0006, 0x001c }, + { 0x0006, 0x001d }, + { 0x0006, 0x001e }, + { 0x0006, 0x001f }, + { 0x0007, 0x0006 }, + { 0x0007, 0x0007 }, + { 0x0007, 0x0008 }, + { 0x0007, 0x0009 }, + { 0x0007, 0x000a }, + { 0x0007, 0x000b }, + { 0x0007, 0x000c }, + { 0x0007, 0x000d }, + { 0x0007, 0x000e }, + { 0x0007, 0x000f }, + { 0x0008, 0x0005 }, + { 0x0008, 0x0006 }, + { 0x0008, 0x0007 }, + { 0x0008, 0x0008 }, + { 0x0008, 0x0009 }, + { 0x0008, 0x000a }, + { 0x0008, 0x000b }, + { 0x0009, 0x0004 }, + { 0x0009, 0x0005 }, + { 0x0009, 0x0006 }, + { 0x0009, 0x0007 }, + { 0x0009, 0x0008 }, + { 0x0009, 0x0009 }, + { 0x000a, 0x0005 }, + { 0x000a, 0x0006 }, + { 0x000a, 0x0007 }, + { 0x000b, 0x0005 }, + { 0x000b, 0x0006 }, + { 0x000b, 0x0007 }, + { 0x000b, 0x0008 }, + { 0x000b, 0x0009 }, + { 0x000c, 0x0004 }, + { 0x000c, 0x0005 }, + { 0x000c, 0x0006 }, + { 0x000c, 0x0007 }, + { 0x000c, 0x0008 }, + { 0x000c, 0x0009 }, + { 0x000d, 0x0004 }, + { 0x000d, 0x0005 }, + { 0x000d, 0x0006 }, + { 0x000d, 0x0007 }, + { 0x000e, 0x0004 }, + { 0x000e, 0x0005 }, + { 0x000e, 0x0006 }, + { 0x000e, 0x0007 }, + { 0x0010, 0x0004 }, + { 0x000f, 0x0005 }, + { 0x0010, 0x0005 }, + { 0x000f, 0x0006 }, + { 0x000f, 0x0007 }, + { 0x0010, 0x0006 }, + { 0x0011, 0x0006 }, + { 0x0010, 0x0007 }, + { 0x0013, 0x0000 }, + { 0x0010, 0x0008 }, + { 0x0010, 0x0009 }, + { 0x0013, 0x0001 }, + { 0x0011, 0x0007 }, + { 0x0012, 0x0001 }, + { 0x0012, 0x0002 }, + { 0x0012, 0x0003 }, + { 0x0012, 0x0004 }, + { 0x0012, 0x0005 }, + { 0x0012, 0x0006 }, + { 0x0012, 0x0007 }, + { 0x0012, 0x0008 }, + { 0x0012, 0x0009 }, + { 0x0012, 0x000a }, + { 0x0012, 0x000b }, + + }; + +const uint16_t c_aauiLCLDHuffEnc29[129][2] = + { + { 0x0006, 0x0009 }, + { 0x0005, 0x0019 }, + { 0x0006, 0x000a }, + { 0x0005, 0x001a }, + { 0x0005, 0x001b }, + { 0x0005, 0x001c }, + { 0x0006, 0x000b }, + { 0x0005, 0x001d }, + { 0x0005, 0x001e }, + { 0x0006, 0x000c }, + { 0x0006, 0x000d }, + { 0x0005, 0x001f }, + { 0x0006, 0x000e }, + { 0x0006, 0x000f }, + { 0x0006, 0x0010 }, + { 0x0006, 0x0011 }, + { 0x0006, 0x0012 }, + { 0x0006, 0x0013 }, + { 0x0006, 0x0014 }, + { 0x0006, 0x0015 }, + { 0x0006, 0x0016 }, + { 0x0006, 0x0017 }, + { 0x0006, 0x0018 }, + { 0x0006, 0x0019 }, + { 0x0006, 0x001a }, + { 0x0006, 0x001b }, + { 0x0006, 0x001c }, + { 0x0006, 0x001d }, + { 0x0006, 0x001e }, + { 0x0006, 0x001f }, + { 0x0006, 0x0020 }, + { 0x0006, 0x0021 }, + { 0x0006, 0x0022 }, + { 0x0006, 0x0023 }, + { 0x0006, 0x0024 }, + { 0x0006, 0x0025 }, + { 0x0006, 0x0026 }, + { 0x0006, 0x0027 }, + { 0x0006, 0x0028 }, + { 0x0006, 0x0029 }, + { 0x0006, 0x002a }, + { 0x0006, 0x002b }, + { 0x0006, 0x002c }, + { 0x0006, 0x002d }, + { 0x0006, 0x002e }, + { 0x0006, 0x002f }, + { 0x0006, 0x0030 }, + { 0x0006, 0x0031 }, + { 0x0007, 0x0007 }, + { 0x0007, 0x0008 }, + { 0x0007, 0x0009 }, + { 0x0007, 0x000a }, + { 0x0007, 0x000b }, + { 0x0007, 0x000c }, + { 0x0007, 0x000d }, + { 0x0007, 0x000e }, + { 0x0007, 0x000f }, + { 0x0007, 0x0010 }, + { 0x0007, 0x0011 }, + { 0x0008, 0x0006 }, + { 0x0008, 0x0007 }, + { 0x0008, 0x0008 }, + { 0x0008, 0x0009 }, + { 0x0008, 0x000a }, + { 0x0008, 0x000b }, + { 0x0008, 0x000c }, + { 0x0008, 0x000d }, + { 0x0009, 0x0006 }, + { 0x0009, 0x0007 }, + { 0x0009, 0x0008 }, + { 0x0009, 0x0009 }, + { 0x0009, 0x000a }, + { 0x0009, 0x000b }, + { 0x000a, 0x0005 }, + { 0x000a, 0x0006 }, + { 0x000a, 0x0007 }, + { 0x000a, 0x0008 }, + { 0x000a, 0x0009 }, + { 0x000a, 0x000a }, + { 0x000a, 0x000b }, + { 0x000b, 0x0006 }, + { 0x000b, 0x0007 }, + { 0x000b, 0x0008 }, + { 0x000b, 0x0009 }, + { 0x000c, 0x0006 }, + { 0x000c, 0x0007 }, + { 0x000c, 0x0008 }, + { 0x000c, 0x0009 }, + { 0x000c, 0x000a }, + { 0x000c, 0x000b }, + { 0x000d, 0x0005 }, + { 0x000d, 0x0006 }, + { 0x000d, 0x0007 }, + { 0x000d, 0x0008 }, + { 0x000d, 0x0009 }, + { 0x000d, 0x000a }, + { 0x000d, 0x000b }, + { 0x000e, 0x0006 }, + { 0x000e, 0x0007 }, + { 0x000e, 0x0008 }, + { 0x000e, 0x0009 }, + { 0x000f, 0x0004 }, + { 0x000f, 0x0005 }, + { 0x000f, 0x0006 }, + { 0x000f, 0x0007 }, + { 0x0011, 0x0007 }, + { 0x000f, 0x0008 }, + { 0x0012, 0x0000 }, + { 0x000f, 0x0009 }, + { 0x0010, 0x0005 }, + { 0x000f, 0x000a }, + { 0x000f, 0x000b }, + { 0x0012, 0x0001 }, + { 0x0010, 0x0006 }, + { 0x0010, 0x0007 }, + { 0x0012, 0x0002 }, + { 0x0012, 0x0003 }, + { 0x0012, 0x0004 }, + { 0x0012, 0x0005 }, + { 0x0012, 0x0006 }, + { 0x0012, 0x0007 }, + { 0x0012, 0x0008 }, + { 0x0011, 0x0008 }, + { 0x0012, 0x0009 }, + { 0x0012, 0x000a }, + { 0x0012, 0x000b }, + { 0x0012, 0x000c }, + { 0x0012, 0x000d }, + { 0x0011, 0x0009 }, + + }; + +const uint16_t c_aauiLCLDHuffEnc30[153][2] = + { + { 0x0007, 0x0009 }, + { 0x0006, 0x000e }, + { 0x0006, 0x000f }, + { 0x0006, 0x0010 }, + { 0x0006, 0x0011 }, + { 0x0006, 0x0012 }, + { 0x0006, 0x0013 }, + { 0x0006, 0x0014 }, + { 0x0006, 0x0015 }, + { 0x0006, 0x0016 }, + { 0x0006, 0x0017 }, + { 0x0006, 0x0018 }, + { 0x0006, 0x0019 }, + { 0x0006, 0x001a }, + { 0x0006, 0x001b }, + { 0x0006, 0x001c }, + { 0x0006, 0x001d }, + { 0x0006, 0x001e }, + { 0x0006, 0x001f }, + { 0x0006, 0x0020 }, + { 0x0006, 0x0021 }, + { 0x0006, 0x0022 }, + { 0x0006, 0x0023 }, + { 0x0006, 0x0024 }, + { 0x0006, 0x0025 }, + { 0x0006, 0x0026 }, + { 0x0006, 0x0027 }, + { 0x0006, 0x0028 }, + { 0x0006, 0x0029 }, + { 0x0006, 0x002a }, + { 0x0006, 0x002b }, + { 0x0006, 0x002c }, + { 0x0006, 0x002d }, + { 0x0006, 0x002e }, + { 0x0006, 0x002f }, + { 0x0006, 0x0030 }, + { 0x0006, 0x0031 }, + { 0x0006, 0x0032 }, + { 0x0006, 0x0033 }, + { 0x0006, 0x0034 }, + { 0x0006, 0x0035 }, + { 0x0006, 0x0036 }, + { 0x0006, 0x0037 }, + { 0x0006, 0x0038 }, + { 0x0006, 0x0039 }, + { 0x0006, 0x003a }, + { 0x0006, 0x003b }, + { 0x0006, 0x003c }, + { 0x0006, 0x003d }, + { 0x0006, 0x003e }, + { 0x0006, 0x003f }, + { 0x0007, 0x000a }, + { 0x0007, 0x000b }, + { 0x0007, 0x000c }, + { 0x0007, 0x000d }, + { 0x0007, 0x000e }, + { 0x0007, 0x000f }, + { 0x0007, 0x0010 }, + { 0x0007, 0x0011 }, + { 0x0007, 0x0012 }, + { 0x0007, 0x0013 }, + { 0x0007, 0x0014 }, + { 0x0007, 0x0015 }, + { 0x0007, 0x0016 }, + { 0x0007, 0x0017 }, + { 0x0007, 0x0018 }, + { 0x0007, 0x0019 }, + { 0x0007, 0x001a }, + { 0x0007, 0x001b }, + { 0x0008, 0x0008 }, + { 0x0008, 0x0009 }, + { 0x0008, 0x000a }, + { 0x0008, 0x000b }, + { 0x0008, 0x000c }, + { 0x0008, 0x000d }, + { 0x0008, 0x000e }, + { 0x0008, 0x000f }, + { 0x0008, 0x0010 }, + { 0x0008, 0x0011 }, + { 0x0009, 0x0007 }, + { 0x0009, 0x0008 }, + { 0x0009, 0x0009 }, + { 0x0009, 0x000a }, + { 0x0009, 0x000b }, + { 0x0009, 0x000c }, + { 0x0009, 0x000d }, + { 0x0009, 0x000e }, + { 0x000a, 0x0008 }, + { 0x0009, 0x000f }, + { 0x000a, 0x0009 }, + { 0x000a, 0x000a }, + { 0x000a, 0x000b }, + { 0x000a, 0x000c }, + { 0x000a, 0x000d }, + { 0x000b, 0x0007 }, + { 0x000b, 0x0008 }, + { 0x000b, 0x0009 }, + { 0x000b, 0x000a }, + { 0x000b, 0x000b }, + { 0x000b, 0x000c }, + { 0x000b, 0x000d }, + { 0x000c, 0x0008 }, + { 0x000b, 0x000e }, + { 0x000b, 0x000f }, + { 0x000c, 0x0009 }, + { 0x000c, 0x000a }, + { 0x000d, 0x0008 }, + { 0x000c, 0x000b }, + { 0x000c, 0x000c }, + { 0x000d, 0x0009 }, + { 0x000c, 0x000d }, + { 0x000d, 0x000a }, + { 0x000d, 0x000b }, + { 0x000d, 0x000c }, + { 0x000d, 0x000d }, + { 0x000e, 0x0008 }, + { 0x000d, 0x000e }, + { 0x000d, 0x000f }, + { 0x000e, 0x0009 }, + { 0x000e, 0x000a }, + { 0x000e, 0x000b }, + { 0x000e, 0x000c }, + { 0x000f, 0x0006 }, + { 0x000f, 0x0007 }, + { 0x000f, 0x0008 }, + { 0x0010, 0x0006 }, + { 0x000e, 0x000d }, + { 0x000e, 0x000e }, + { 0x000e, 0x000f }, + { 0x0010, 0x0007 }, + { 0x000f, 0x0009 }, + { 0x0010, 0x0008 }, + { 0x000f, 0x000a }, + { 0x000f, 0x000b }, + { 0x000f, 0x000c }, + { 0x000f, 0x000d }, + { 0x0010, 0x0009 }, + { 0x0011, 0x0000 }, + { 0x0011, 0x0001 }, + { 0x0011, 0x0002 }, + { 0x000f, 0x000e }, + { 0x0010, 0x000a }, + { 0x0011, 0x0003 }, + { 0x0011, 0x0004 }, + { 0x0011, 0x0005 }, + { 0x000f, 0x000f }, + { 0x0011, 0x0006 }, + { 0x0011, 0x0007 }, + { 0x0011, 0x0008 }, + { 0x0011, 0x0009 }, + { 0x0011, 0x000a }, + { 0x0011, 0x000b }, + { 0x0010, 0x000b }, + + }; + +const uint16_t c_aauiLCLDHuffEnc31[181][2] = + { + { 0x0007, 0x000b }, + { 0x0006, 0x0015 }, + { 0x0006, 0x0016 }, + { 0x0006, 0x0017 }, + { 0x0006, 0x0018 }, + { 0x0006, 0x0019 }, + { 0x0006, 0x001a }, + { 0x0006, 0x001b }, + { 0x0006, 0x001c }, + { 0x0006, 0x001d }, + { 0x0006, 0x001e }, + { 0x0006, 0x001f }, + { 0x0006, 0x0020 }, + { 0x0006, 0x0021 }, + { 0x0006, 0x0022 }, + { 0x0006, 0x0023 }, + { 0x0006, 0x0024 }, + { 0x0006, 0x0025 }, + { 0x0006, 0x0026 }, + { 0x0006, 0x0027 }, + { 0x0006, 0x0028 }, + { 0x0006, 0x0029 }, + { 0x0006, 0x002a }, + { 0x0006, 0x002b }, + { 0x0006, 0x002c }, + { 0x0006, 0x002d }, + { 0x0006, 0x002e }, + { 0x0006, 0x002f }, + { 0x0006, 0x0030 }, + { 0x0006, 0x0031 }, + { 0x0006, 0x0032 }, + { 0x0006, 0x0033 }, + { 0x0006, 0x0034 }, + { 0x0006, 0x0035 }, + { 0x0006, 0x0036 }, + { 0x0006, 0x0037 }, + { 0x0006, 0x0038 }, + { 0x0006, 0x0039 }, + { 0x0006, 0x003a }, + { 0x0006, 0x003b }, + { 0x0006, 0x003c }, + { 0x0006, 0x003d }, + { 0x0006, 0x003e }, + { 0x0007, 0x000c }, + { 0x0006, 0x003f }, + { 0x0007, 0x000d }, + { 0x0007, 0x000e }, + { 0x0007, 0x000f }, + { 0x0007, 0x0010 }, + { 0x0007, 0x0011 }, + { 0x0007, 0x0012 }, + { 0x0007, 0x0013 }, + { 0x0007, 0x0014 }, + { 0x0007, 0x0015 }, + { 0x0007, 0x0016 }, + { 0x0007, 0x0017 }, + { 0x0007, 0x0018 }, + { 0x0007, 0x0019 }, + { 0x0007, 0x001a }, + { 0x0007, 0x001b }, + { 0x0007, 0x001c }, + { 0x0007, 0x001d }, + { 0x0007, 0x001e }, + { 0x0007, 0x001f }, + { 0x0007, 0x0020 }, + { 0x0007, 0x0021 }, + { 0x0007, 0x0022 }, + { 0x0007, 0x0023 }, + { 0x0007, 0x0024 }, + { 0x0007, 0x0025 }, + { 0x0007, 0x0026 }, + { 0x0007, 0x0027 }, + { 0x0007, 0x0028 }, + { 0x0007, 0x0029 }, + { 0x0008, 0x0009 }, + { 0x0008, 0x000a }, + { 0x0008, 0x000b }, + { 0x0008, 0x000c }, + { 0x0008, 0x000d }, + { 0x0008, 0x000e }, + { 0x0008, 0x000f }, + { 0x0008, 0x0010 }, + { 0x0008, 0x0011 }, + { 0x0008, 0x0012 }, + { 0x0008, 0x0013 }, + { 0x0008, 0x0014 }, + { 0x0008, 0x0015 }, + { 0x0009, 0x0008 }, + { 0x0009, 0x0009 }, + { 0x0009, 0x000a }, + { 0x0009, 0x000b }, + { 0x0009, 0x000c }, + { 0x0009, 0x000d }, + { 0x0009, 0x000e }, + { 0x0009, 0x000f }, + { 0x0009, 0x0010 }, + { 0x0009, 0x0011 }, + { 0x000a, 0x0008 }, + { 0x000a, 0x0009 }, + { 0x000a, 0x000a }, + { 0x000a, 0x000b }, + { 0x000a, 0x000c }, + { 0x000a, 0x000d }, + { 0x000a, 0x000e }, + { 0x000a, 0x000f }, + { 0x000b, 0x0008 }, + { 0x000b, 0x0009 }, + { 0x000b, 0x000a }, + { 0x000b, 0x000b }, + { 0x000b, 0x000c }, + { 0x000b, 0x000d }, + { 0x000b, 0x000e }, + { 0x000c, 0x0008 }, + { 0x000c, 0x0009 }, + { 0x000b, 0x000f }, + { 0x000c, 0x000a }, + { 0x000c, 0x000b }, + { 0x000c, 0x000c }, + { 0x000c, 0x000d }, + { 0x000d, 0x0008 }, + { 0x000c, 0x000e }, + { 0x000d, 0x0009 }, + { 0x000d, 0x000a }, + { 0x000c, 0x000f }, + { 0x000d, 0x000b }, + { 0x000d, 0x000c }, + { 0x000d, 0x000d }, + { 0x000d, 0x000e }, + { 0x000d, 0x000f }, + { 0x000e, 0x0008 }, + { 0x000e, 0x0009 }, + { 0x000e, 0x000a }, + { 0x000e, 0x000b }, + { 0x000e, 0x000c }, + { 0x000e, 0x000d }, + { 0x000e, 0x000e }, + { 0x000e, 0x000f }, + { 0x000f, 0x0009 }, + { 0x000f, 0x000a }, + { 0x000f, 0x000b }, + { 0x000f, 0x000c }, + { 0x0010, 0x0009 }, + { 0x000f, 0x000d }, + { 0x000f, 0x000e }, + { 0x0010, 0x000a }, + { 0x0010, 0x000b }, + { 0x0010, 0x000c }, + { 0x0010, 0x000d }, + { 0x0011, 0x000a }, + { 0x0010, 0x000e }, + { 0x000f, 0x000f }, + { 0x0010, 0x000f }, + { 0x0012, 0x0000 }, + { 0x0012, 0x0001 }, + { 0x0011, 0x000b }, + { 0x0011, 0x000c }, + { 0x0010, 0x0010 }, + { 0x0012, 0x0002 }, + { 0x0012, 0x0003 }, + { 0x0011, 0x000d }, + { 0x0011, 0x000e }, + { 0x0011, 0x000f }, + { 0x0011, 0x0010 }, + { 0x0011, 0x0011 }, + { 0x0010, 0x0011 }, + { 0x0012, 0x0004 }, + { 0x0012, 0x0005 }, + { 0x0012, 0x0006 }, + { 0x0012, 0x0007 }, + { 0x0012, 0x0008 }, + { 0x0012, 0x0009 }, + { 0x0012, 0x000a }, + { 0x0012, 0x000b }, + { 0x0012, 0x000c }, + { 0x0012, 0x000d }, + { 0x0012, 0x000e }, + { 0x0012, 0x000f }, + { 0x0012, 0x0010 }, + { 0x0012, 0x0011 }, + { 0x0012, 0x0012 }, + { 0x0012, 0x0013 }, + + }; + +const uint16_t c_aauiLCLDHuffEnc33[16][2] = + { + { 0x0001, 0x0001 }, + { 0x0003, 0x0001 }, + { 0x0008, 0x0000 }, + { 0x0008, 0x0001 }, + { 0x0002, 0x0001 }, + { 0x0004, 0x0001 }, + { 0x0008, 0x0002 }, + { 0x0008, 0x0003 }, + { 0x0008, 0x0004 }, + { 0x0008, 0x0005 }, + { 0x0008, 0x0006 }, + { 0x0008, 0x0007 }, + { 0x0007, 0x0004 }, + { 0x0007, 0x0005 }, + { 0x0007, 0x0006 }, + { 0x0007, 0x0007 }, + }; + +const uint16_t c_aauiLCLDHuffEnc34[16][2] = + { + { 0x0001, 0x0001 }, + { 0x0003, 0x0001 }, + { 0x0008, 0x0000 }, + { 0x0008, 0x0001 }, + { 0x0002, 0x0001 }, + { 0x0004, 0x0001 }, + { 0x0008, 0x0002 }, + { 0x0008, 0x0003 }, + { 0x0008, 0x0004 }, + { 0x0008, 0x0005 }, + { 0x0008, 0x0006 }, + { 0x0008, 0x0007 }, + { 0x0007, 0x0004 }, + { 0x0007, 0x0005 }, + { 0x0007, 0x0006 }, + { 0x0007, 0x0007 }, + }; + +const uint16_t c_aauiLCLDHuffEnc35[25][2] = + { + { 0x0001, 0x0001 }, + { 0x0003, 0x0001 }, + { 0x0007, 0x0006 }, + { 0x0009, 0x0000 }, + { 0x0009, 0x0001 }, + { 0x0002, 0x0001 }, + { 0x0004, 0x0001 }, + { 0x0009, 0x0002 }, + { 0x0009, 0x0003 }, + { 0x0009, 0x0004 }, + { 0x0007, 0x0007 }, + { 0x0009, 0x0005 }, + { 0x0009, 0x0006 }, + { 0x0009, 0x0007 }, + { 0x0009, 0x0008 }, + { 0x0009, 0x0009 }, + { 0x0009, 0x000a }, + { 0x0009, 0x000b }, + { 0x0009, 0x000c }, + { 0x0009, 0x000d }, + { 0x0008, 0x0007 }, + { 0x0008, 0x0008 }, + { 0x0008, 0x0009 }, + { 0x0008, 0x000a }, + { 0x0008, 0x000b }, + + }; + +const uint16_t c_aauiLCLDHuffEnc36[36][2] = + { + { 0x0001, 0x0001 }, + { 0x0002, 0x0001 }, + { 0x0006, 0x0002 }, + { 0x000b, 0x0000 }, + { 0x000b, 0x0001 }, + { 0x000b, 0x0002 }, + { 0x0003, 0x0001 }, + { 0x0004, 0x0001 }, + { 0x0008, 0x0005 }, + { 0x000b, 0x0003 }, + { 0x000b, 0x0004 }, + { 0x000b, 0x0005 }, + { 0x0006, 0x0003 }, + { 0x0007, 0x0003 }, + { 0x000b, 0x0006 }, + { 0x000b, 0x0007 }, + { 0x000b, 0x0008 }, + { 0x000b, 0x0009 }, + { 0x000b, 0x000a }, + { 0x000b, 0x000b }, + { 0x000b, 0x000c }, + { 0x000b, 0x000d }, + { 0x000b, 0x000e }, + { 0x000b, 0x000f }, + { 0x000a, 0x0008 }, + { 0x000a, 0x0009 }, + { 0x000a, 0x000a }, + { 0x000a, 0x000b }, + { 0x000a, 0x000c }, + { 0x000a, 0x000d }, + { 0x000a, 0x000e }, + { 0x000a, 0x000f }, + { 0x000a, 0x0010 }, + { 0x000a, 0x0011 }, + { 0x000a, 0x0012 }, + { 0x000a, 0x0013 }, + + }; + +const uint16_t c_aauiLCLDHuffEnc37[36][2] = + { + { 0x0001, 0x0001 }, + { 0x0002, 0x0001 }, + { 0x0006, 0x0001 }, + { 0x000c, 0x0000 }, + { 0x000c, 0x0001 }, + { 0x000c, 0x0002 }, + { 0x0003, 0x0001 }, + { 0x0004, 0x0001 }, + { 0x0006, 0x0002 }, + { 0x000c, 0x0003 }, + { 0x000c, 0x0004 }, + { 0x000c, 0x0005 }, + { 0x0006, 0x0003 }, + { 0x0007, 0x0001 }, + { 0x000a, 0x0007 }, + { 0x000c, 0x0006 }, + { 0x000c, 0x0007 }, + { 0x000c, 0x0008 }, + { 0x000c, 0x0009 }, + { 0x000c, 0x000a }, + { 0x000c, 0x000b }, + { 0x000c, 0x000c }, + { 0x000c, 0x000d }, + { 0x000c, 0x000e }, + { 0x000c, 0x000f }, + { 0x000c, 0x0010 }, + { 0x000c, 0x0011 }, + { 0x000c, 0x0012 }, + { 0x000c, 0x0013 }, + { 0x000c, 0x0014 }, + { 0x000c, 0x0015 }, + { 0x000c, 0x0016 }, + { 0x000c, 0x0017 }, + { 0x000c, 0x0018 }, + { 0x000c, 0x0019 }, + { 0x000b, 0x000d }, + + }; + +const uint16_t c_aauiLCLDHuffEnc38[49][2] = + { + { 0x0001, 0x0001 }, + { 0x0003, 0x0001 }, + { 0x0006, 0x0001 }, + { 0x000c, 0x0012 }, + { 0x000d, 0x0000 }, + { 0x000d, 0x0001 }, + { 0x000d, 0x0002 }, + { 0x0002, 0x0001 }, + { 0x0004, 0x0001 }, + { 0x0007, 0x0001 }, + { 0x000b, 0x000a }, + { 0x000d, 0x0003 }, + { 0x000d, 0x0004 }, + { 0x000d, 0x0005 }, + { 0x0006, 0x0002 }, + { 0x0006, 0x0003 }, + { 0x0009, 0x0003 }, + { 0x000d, 0x0006 }, + { 0x000d, 0x0007 }, + { 0x000d, 0x0008 }, + { 0x000d, 0x0009 }, + { 0x000c, 0x0013 }, + { 0x000b, 0x000b }, + { 0x000d, 0x000a }, + { 0x000d, 0x000b }, + { 0x000d, 0x000c }, + { 0x000d, 0x000d }, + { 0x000d, 0x000e }, + { 0x000d, 0x000f }, + { 0x000d, 0x0010 }, + { 0x000d, 0x0011 }, + { 0x000d, 0x0012 }, + { 0x000d, 0x0013 }, + { 0x000d, 0x0014 }, + { 0x000d, 0x0015 }, + { 0x000d, 0x0016 }, + { 0x000d, 0x0017 }, + { 0x000d, 0x0018 }, + { 0x000d, 0x0019 }, + { 0x000d, 0x001a }, + { 0x000d, 0x001b }, + { 0x000d, 0x001c }, + { 0x000d, 0x001d }, + { 0x000d, 0x001e }, + { 0x000d, 0x001f }, + { 0x000d, 0x0020 }, + { 0x000d, 0x0021 }, + { 0x000d, 0x0022 }, + { 0x000d, 0x0023 }, + + }; + +const uint16_t c_aauiLCLDHuffEnc39[64][2] = + { + { 0x0001, 0x0001 }, + { 0x0002, 0x0001 }, + { 0x0006, 0x0001 }, + { 0x000a, 0x0002 }, + { 0x000f, 0x0000 }, + { 0x000f, 0x0001 }, + { 0x000f, 0x0002 }, + { 0x000f, 0x0003 }, + { 0x0003, 0x0001 }, + { 0x0004, 0x0001 }, + { 0x0007, 0x0001 }, + { 0x000a, 0x0003 }, + { 0x000f, 0x0004 }, + { 0x000f, 0x0005 }, + { 0x000f, 0x0006 }, + { 0x000f, 0x0007 }, + { 0x0006, 0x0002 }, + { 0x0006, 0x0003 }, + { 0x0009, 0x0003 }, + { 0x000d, 0x000e }, + { 0x000f, 0x0008 }, + { 0x000f, 0x0009 }, + { 0x000f, 0x000a }, + { 0x000f, 0x000b }, + { 0x000a, 0x0004 }, + { 0x000a, 0x0005 }, + { 0x000d, 0x000f }, + { 0x000f, 0x000c }, + { 0x000f, 0x000d }, + { 0x000f, 0x000e }, + { 0x000f, 0x000f }, + { 0x000f, 0x0010 }, + { 0x000f, 0x0011 }, + { 0x000f, 0x0012 }, + { 0x000f, 0x0013 }, + { 0x000f, 0x0014 }, + { 0x000f, 0x0015 }, + { 0x000f, 0x0016 }, + { 0x000f, 0x0017 }, + { 0x000f, 0x0018 }, + { 0x000f, 0x0019 }, + { 0x000f, 0x001a }, + { 0x000f, 0x001b }, + { 0x000f, 0x001c }, + { 0x000f, 0x001d }, + { 0x000f, 0x001e }, + { 0x000f, 0x001f }, + { 0x000f, 0x0020 }, + { 0x000f, 0x0021 }, + { 0x000f, 0x0022 }, + { 0x000f, 0x0023 }, + { 0x000f, 0x0024 }, + { 0x000f, 0x0025 }, + { 0x000f, 0x0026 }, + { 0x000f, 0x0027 }, + { 0x000f, 0x0028 }, + { 0x000f, 0x0029 }, + { 0x000e, 0x0015 }, + { 0x000e, 0x0016 }, + { 0x000e, 0x0017 }, + { 0x000e, 0x0018 }, + { 0x000e, 0x0019 }, + { 0x000e, 0x001a }, + { 0x000e, 0x001b }, + }; + +const uint16_t c_aauiLCLDHuffEnc40[81][2] = + { + { 0x0001, 0x0001 }, + { 0x0002, 0x0001 }, + { 0x0006, 0x0001 }, + { 0x000b, 0x0002 }, + { 0x000f, 0x0011 }, + { 0x0011, 0x0000 }, + { 0x0011, 0x0001 }, + { 0x0011, 0x0002 }, + { 0x0011, 0x0003 }, + { 0x0003, 0x0001 }, + { 0x0004, 0x0001 }, + { 0x0007, 0x0001 }, + { 0x000a, 0x0002 }, + { 0x000e, 0x0009 }, + { 0x0011, 0x0004 }, + { 0x0011, 0x0005 }, + { 0x0011, 0x0006 }, + { 0x0011, 0x0007 }, + { 0x0006, 0x0002 }, + { 0x0006, 0x0003 }, + { 0x0008, 0x0001 }, + { 0x000d, 0x0005 }, + { 0x0011, 0x0008 }, + { 0x0011, 0x0009 }, + { 0x0011, 0x000a }, + { 0x0011, 0x000b }, + { 0x0011, 0x000c }, + { 0x000b, 0x0003 }, + { 0x000a, 0x0003 }, + { 0x000c, 0x0003 }, + { 0x0011, 0x000d }, + { 0x0011, 0x000e }, + { 0x0011, 0x000f }, + { 0x0011, 0x0010 }, + { 0x0011, 0x0011 }, + { 0x0011, 0x0012 }, + { 0x0011, 0x0013 }, + { 0x0011, 0x0014 }, + { 0x0011, 0x0015 }, + { 0x0011, 0x0016 }, + { 0x0011, 0x0017 }, + { 0x0011, 0x0018 }, + { 0x0011, 0x0019 }, + { 0x0011, 0x001a }, + { 0x0011, 0x001b }, + { 0x0011, 0x001c }, + { 0x0011, 0x001d }, + { 0x0011, 0x001e }, + { 0x0011, 0x001f }, + { 0x0011, 0x0020 }, + { 0x0011, 0x0021 }, + { 0x0011, 0x0022 }, + { 0x0011, 0x0023 }, + { 0x0011, 0x0024 }, + { 0x0011, 0x0025 }, + { 0x0011, 0x0026 }, + { 0x0011, 0x0027 }, + { 0x0011, 0x0028 }, + { 0x0011, 0x0029 }, + { 0x0011, 0x002a }, + { 0x0011, 0x002b }, + { 0x0011, 0x002c }, + { 0x0011, 0x002d }, + { 0x0011, 0x002e }, + { 0x0011, 0x002f }, + { 0x0011, 0x0030 }, + { 0x0011, 0x0031 }, + { 0x0011, 0x0032 }, + { 0x0011, 0x0033 }, + { 0x0011, 0x0034 }, + { 0x0011, 0x0035 }, + { 0x0011, 0x0036 }, + { 0x0011, 0x0037 }, + { 0x0011, 0x0038 }, + { 0x0011, 0x0039 }, + { 0x0011, 0x003a }, + { 0x0011, 0x003b }, + { 0x0010, 0x001e }, + { 0x0010, 0x001f }, + { 0x0010, 0x0020 }, + { 0x0010, 0x0021 }, + + }; + +const uint16_t c_aauiLCLDHuffEnc41[100][2] = + { + { 0x0001, 0x0001 }, + { 0x0003, 0x0001 }, + { 0x0006, 0x0001 }, + { 0x000b, 0x0001 }, + { 0x0011, 0x0014 }, + { 0x0013, 0x0000 }, + { 0x0013, 0x0001 }, + { 0x0013, 0x0002 }, + { 0x0013, 0x0003 }, + { 0x0013, 0x0004 }, + { 0x0002, 0x0001 }, + { 0x0004, 0x0001 }, + { 0x0007, 0x0001 }, + { 0x000a, 0x0001 }, + { 0x0010, 0x000b }, + { 0x0013, 0x0005 }, + { 0x0013, 0x0006 }, + { 0x0013, 0x0007 }, + { 0x0013, 0x0008 }, + { 0x0013, 0x0009 }, + { 0x0006, 0x0002 }, + { 0x0006, 0x0003 }, + { 0x0008, 0x0001 }, + { 0x000d, 0x0002 }, + { 0x0011, 0x0015 }, + { 0x0013, 0x000a }, + { 0x0013, 0x000b }, + { 0x0013, 0x000c }, + { 0x0013, 0x000d }, + { 0x0013, 0x000e }, + { 0x000a, 0x0002 }, + { 0x000a, 0x0003 }, + { 0x000d, 0x0003 }, + { 0x0010, 0x000c }, + { 0x0013, 0x000f }, + { 0x0013, 0x0010 }, + { 0x0013, 0x0011 }, + { 0x0013, 0x0012 }, + { 0x0013, 0x0013 }, + { 0x0013, 0x0014 }, + { 0x0010, 0x000d }, + { 0x000f, 0x0007 }, + { 0x0012, 0x0027 }, + { 0x0013, 0x0015 }, + { 0x0013, 0x0016 }, + { 0x0013, 0x0017 }, + { 0x0013, 0x0018 }, + { 0x0013, 0x0019 }, + { 0x0013, 0x001a }, + { 0x0013, 0x001b }, + { 0x0013, 0x001c }, + { 0x0013, 0x001d }, + { 0x0013, 0x001e }, + { 0x0013, 0x001f }, + { 0x0013, 0x0020 }, + { 0x0013, 0x0021 }, + { 0x0013, 0x0022 }, + { 0x0013, 0x0023 }, + { 0x0013, 0x0024 }, + { 0x0013, 0x0025 }, + { 0x0013, 0x0026 }, + { 0x0013, 0x0027 }, + { 0x0013, 0x0028 }, + { 0x0013, 0x0029 }, + { 0x0013, 0x002a }, + { 0x0013, 0x002b }, + { 0x0013, 0x002c }, + { 0x0013, 0x002d }, + { 0x0013, 0x002e }, + { 0x0013, 0x002f }, + { 0x0013, 0x0030 }, + { 0x0013, 0x0031 }, + { 0x0013, 0x0032 }, + { 0x0013, 0x0033 }, + { 0x0013, 0x0034 }, + { 0x0013, 0x0035 }, + { 0x0013, 0x0036 }, + { 0x0013, 0x0037 }, + { 0x0013, 0x0038 }, + { 0x0013, 0x0039 }, + { 0x0013, 0x003a }, + { 0x0013, 0x003b }, + { 0x0013, 0x003c }, + { 0x0013, 0x003d }, + { 0x0013, 0x003e }, + { 0x0013, 0x003f }, + { 0x0013, 0x0040 }, + { 0x0013, 0x0041 }, + { 0x0013, 0x0042 }, + { 0x0013, 0x0043 }, + { 0x0013, 0x0044 }, + { 0x0013, 0x0045 }, + { 0x0013, 0x0046 }, + { 0x0013, 0x0047 }, + { 0x0013, 0x0048 }, + { 0x0013, 0x0049 }, + { 0x0013, 0x004a }, + { 0x0013, 0x004b }, + { 0x0013, 0x004c }, + { 0x0013, 0x004d }, + + }; + +const uint16_t c_aauiLCLDHuffEnc42[169][2] = + { + { 0x0001, 0x0001 }, + { 0x0003, 0x0001 }, + { 0x0006, 0x0001 }, + { 0x0009, 0x0001 }, + { 0x000e, 0x0006 }, + { 0x0013, 0x0000 }, + { 0x0013, 0x0001 }, + { 0x0013, 0x0002 }, + { 0x0013, 0x0003 }, + { 0x0013, 0x0004 }, + { 0x0013, 0x0005 }, + { 0x0013, 0x0006 }, + { 0x0013, 0x0007 }, + { 0x0003, 0x0002 }, + { 0x0003, 0x0003 }, + { 0x0005, 0x0001 }, + { 0x0009, 0x0002 }, + { 0x000d, 0x0004 }, + { 0x0010, 0x0013 }, + { 0x0013, 0x0008 }, + { 0x0013, 0x0009 }, + { 0x0013, 0x000a }, + { 0x0013, 0x000b }, + { 0x0013, 0x000c }, + { 0x0013, 0x000d }, + { 0x0013, 0x000e }, + { 0x0005, 0x0002 }, + { 0x0005, 0x0003 }, + { 0x0008, 0x0002 }, + { 0x000b, 0x0002 }, + { 0x000f, 0x000b }, + { 0x0011, 0x0025 }, + { 0x0013, 0x000f }, + { 0x0013, 0x0010 }, + { 0x0013, 0x0011 }, + { 0x0013, 0x0012 }, + { 0x0013, 0x0013 }, + { 0x0013, 0x0014 }, + { 0x0013, 0x0015 }, + { 0x0009, 0x0003 }, + { 0x0008, 0x0003 }, + { 0x000b, 0x0003 }, + { 0x000d, 0x0005 }, + { 0x0010, 0x0014 }, + { 0x0013, 0x0016 }, + { 0x0013, 0x0017 }, + { 0x0013, 0x0018 }, + { 0x0013, 0x0019 }, + { 0x0013, 0x001a }, + { 0x0013, 0x001b }, + { 0x0013, 0x001c }, + { 0x0013, 0x001d }, + { 0x000d, 0x0006 }, + { 0x000d, 0x0007 }, + { 0x000e, 0x0007 }, + { 0x0010, 0x0015 }, + { 0x0013, 0x001e }, + { 0x0013, 0x001f }, + { 0x0013, 0x0020 }, + { 0x0013, 0x0021 }, + { 0x0013, 0x0022 }, + { 0x0013, 0x0023 }, + { 0x0013, 0x0024 }, + { 0x0013, 0x0025 }, + { 0x0013, 0x0026 }, + { 0x0012, 0x0045 }, + { 0x0013, 0x0027 }, + { 0x0013, 0x0028 }, + { 0x0013, 0x0029 }, + { 0x0013, 0x002a }, + { 0x0013, 0x002b }, + { 0x0013, 0x002c }, + { 0x0013, 0x002d }, + { 0x0013, 0x002e }, + { 0x0013, 0x002f }, + { 0x0013, 0x0030 }, + { 0x0013, 0x0031 }, + { 0x0013, 0x0032 }, + { 0x0013, 0x0033 }, + { 0x0013, 0x0034 }, + { 0x0013, 0x0035 }, + { 0x0013, 0x0036 }, + { 0x0013, 0x0037 }, + { 0x0013, 0x0038 }, + { 0x0013, 0x0039 }, + { 0x0013, 0x003a }, + { 0x0013, 0x003b }, + { 0x0013, 0x003c }, + { 0x0013, 0x003d }, + { 0x0013, 0x003e }, + { 0x0013, 0x003f }, + { 0x0013, 0x0040 }, + { 0x0013, 0x0041 }, + { 0x0013, 0x0042 }, + { 0x0013, 0x0043 }, + { 0x0013, 0x0044 }, + { 0x0013, 0x0045 }, + { 0x0013, 0x0046 }, + { 0x0013, 0x0047 }, + { 0x0013, 0x0048 }, + { 0x0013, 0x0049 }, + { 0x0013, 0x004a }, + { 0x0013, 0x004b }, + { 0x0013, 0x004c }, + { 0x0013, 0x004d }, + { 0x0013, 0x004e }, + { 0x0013, 0x004f }, + { 0x0013, 0x0050 }, + { 0x0013, 0x0051 }, + { 0x0013, 0x0052 }, + { 0x0013, 0x0053 }, + { 0x0013, 0x0054 }, + { 0x0013, 0x0055 }, + { 0x0013, 0x0056 }, + { 0x0013, 0x0057 }, + { 0x0013, 0x0058 }, + { 0x0013, 0x0059 }, + { 0x0013, 0x005a }, + { 0x0013, 0x005b }, + { 0x0013, 0x005c }, + { 0x0013, 0x005d }, + { 0x0013, 0x005e }, + { 0x0013, 0x005f }, + { 0x0013, 0x0060 }, + { 0x0013, 0x0061 }, + { 0x0013, 0x0062 }, + { 0x0013, 0x0063 }, + { 0x0013, 0x0064 }, + { 0x0013, 0x0065 }, + { 0x0013, 0x0066 }, + { 0x0013, 0x0067 }, + { 0x0013, 0x0068 }, + { 0x0013, 0x0069 }, + { 0x0013, 0x006a }, + { 0x0013, 0x006b }, + { 0x0013, 0x006c }, + { 0x0013, 0x006d }, + { 0x0013, 0x006e }, + { 0x0013, 0x006f }, + { 0x0013, 0x0070 }, + { 0x0013, 0x0071 }, + { 0x0013, 0x0072 }, + { 0x0013, 0x0073 }, + { 0x0013, 0x0074 }, + { 0x0013, 0x0075 }, + { 0x0013, 0x0076 }, + { 0x0013, 0x0077 }, + { 0x0013, 0x0078 }, + { 0x0013, 0x0079 }, + { 0x0013, 0x007a }, + { 0x0013, 0x007b }, + { 0x0013, 0x007c }, + { 0x0013, 0x007d }, + { 0x0013, 0x007e }, + { 0x0013, 0x007f }, + { 0x0013, 0x0080 }, + { 0x0013, 0x0081 }, + { 0x0013, 0x0082 }, + { 0x0013, 0x0083 }, + { 0x0013, 0x0084 }, + { 0x0013, 0x0085 }, + { 0x0013, 0x0086 }, + { 0x0013, 0x0087 }, + { 0x0013, 0x0088 }, + { 0x0013, 0x0089 }, + { 0x0012, 0x0046 }, + { 0x0012, 0x0047 }, + { 0x0012, 0x0048 }, + { 0x0012, 0x0049 }, + + }; + +const uint16_t c_aauiLCLDHuffEnc43[196][2] = + { + { 0x0001, 0x0001 }, + { 0x0003, 0x0001 }, + { 0x0006, 0x0001 }, + { 0x0009, 0x0002 }, + { 0x000c, 0x0003 }, + { 0x0010, 0x0017 }, + { 0x0013, 0x0000 }, + { 0x0013, 0x0001 }, + { 0x0013, 0x0002 }, + { 0x0013, 0x0003 }, + { 0x0013, 0x0004 }, + { 0x0013, 0x0005 }, + { 0x0013, 0x0006 }, + { 0x0013, 0x0007 }, + { 0x0003, 0x0002 }, + { 0x0003, 0x0003 }, + { 0x0005, 0x0001 }, + { 0x0009, 0x0003 }, + { 0x000c, 0x0004 }, + { 0x0010, 0x0018 }, + { 0x0012, 0x0050 }, + { 0x0013, 0x0008 }, + { 0x0013, 0x0009 }, + { 0x0013, 0x000a }, + { 0x0013, 0x000b }, + { 0x0013, 0x000c }, + { 0x0013, 0x000d }, + { 0x0013, 0x000e }, + { 0x0005, 0x0002 }, + { 0x0005, 0x0003 }, + { 0x0008, 0x0003 }, + { 0x000a, 0x0002 }, + { 0x000d, 0x0004 }, + { 0x0011, 0x002a }, + { 0x0013, 0x000f }, + { 0x0013, 0x0010 }, + { 0x0013, 0x0011 }, + { 0x0013, 0x0012 }, + { 0x0013, 0x0013 }, + { 0x0013, 0x0014 }, + { 0x0013, 0x0015 }, + { 0x0013, 0x0016 }, + { 0x0009, 0x0004 }, + { 0x0009, 0x0005 }, + { 0x000a, 0x0003 }, + { 0x000c, 0x0005 }, + { 0x000f, 0x000d }, + { 0x0012, 0x0051 }, + { 0x0013, 0x0017 }, + { 0x0013, 0x0018 }, + { 0x0013, 0x0019 }, + { 0x0013, 0x001a }, + { 0x0013, 0x001b }, + { 0x0013, 0x001c }, + { 0x0013, 0x001d }, + { 0x0013, 0x001e }, + { 0x000c, 0x0006 }, + { 0x000c, 0x0007 }, + { 0x000d, 0x0005 }, + { 0x000f, 0x000e }, + { 0x0011, 0x002b }, + { 0x0013, 0x001f }, + { 0x0013, 0x0020 }, + { 0x0013, 0x0021 }, + { 0x0013, 0x0022 }, + { 0x0013, 0x0023 }, + { 0x0013, 0x0024 }, + { 0x0013, 0x0025 }, + { 0x0013, 0x0026 }, + { 0x0013, 0x0027 }, + { 0x0011, 0x002c }, + { 0x000f, 0x000f }, + { 0x0010, 0x0019 }, + { 0x0012, 0x0052 }, + { 0x0012, 0x0053 }, + { 0x0013, 0x0028 }, + { 0x0013, 0x0029 }, + { 0x0013, 0x002a }, + { 0x0013, 0x002b }, + { 0x0013, 0x002c }, + { 0x0013, 0x002d }, + { 0x0013, 0x002e }, + { 0x0013, 0x002f }, + { 0x0013, 0x0030 }, + { 0x0013, 0x0031 }, + { 0x0011, 0x002d }, + { 0x0013, 0x0032 }, + { 0x0013, 0x0033 }, + { 0x0013, 0x0034 }, + { 0x0013, 0x0035 }, + { 0x0013, 0x0036 }, + { 0x0013, 0x0037 }, + { 0x0013, 0x0038 }, + { 0x0013, 0x0039 }, + { 0x0013, 0x003a }, + { 0x0013, 0x003b }, + { 0x0013, 0x003c }, + { 0x0013, 0x003d }, + { 0x0013, 0x003e }, + { 0x0013, 0x003f }, + { 0x0013, 0x0040 }, + { 0x0013, 0x0041 }, + { 0x0013, 0x0042 }, + { 0x0013, 0x0043 }, + { 0x0013, 0x0044 }, + { 0x0013, 0x0045 }, + { 0x0013, 0x0046 }, + { 0x0013, 0x0047 }, + { 0x0013, 0x0048 }, + { 0x0013, 0x0049 }, + { 0x0013, 0x004a }, + { 0x0013, 0x004b }, + { 0x0013, 0x004c }, + { 0x0013, 0x004d }, + { 0x0013, 0x004e }, + { 0x0013, 0x004f }, + { 0x0013, 0x0050 }, + { 0x0013, 0x0051 }, + { 0x0013, 0x0052 }, + { 0x0013, 0x0053 }, + { 0x0013, 0x0054 }, + { 0x0013, 0x0055 }, + { 0x0013, 0x0056 }, + { 0x0013, 0x0057 }, + { 0x0013, 0x0058 }, + { 0x0013, 0x0059 }, + { 0x0013, 0x005a }, + { 0x0013, 0x005b }, + { 0x0013, 0x005c }, + { 0x0013, 0x005d }, + { 0x0013, 0x005e }, + { 0x0013, 0x005f }, + { 0x0013, 0x0060 }, + { 0x0013, 0x0061 }, + { 0x0013, 0x0062 }, + { 0x0013, 0x0063 }, + { 0x0013, 0x0064 }, + { 0x0013, 0x0065 }, + { 0x0013, 0x0066 }, + { 0x0013, 0x0067 }, + { 0x0013, 0x0068 }, + { 0x0013, 0x0069 }, + { 0x0013, 0x006a }, + { 0x0013, 0x006b }, + { 0x0013, 0x006c }, + { 0x0013, 0x006d }, + { 0x0013, 0x006e }, + { 0x0013, 0x006f }, + { 0x0013, 0x0070 }, + { 0x0013, 0x0071 }, + { 0x0013, 0x0072 }, + { 0x0013, 0x0073 }, + { 0x0013, 0x0074 }, + { 0x0013, 0x0075 }, + { 0x0013, 0x0076 }, + { 0x0013, 0x0077 }, + { 0x0013, 0x0078 }, + { 0x0013, 0x0079 }, + { 0x0013, 0x007a }, + { 0x0013, 0x007b }, + { 0x0013, 0x007c }, + { 0x0013, 0x007d }, + { 0x0013, 0x007e }, + { 0x0013, 0x007f }, + { 0x0013, 0x0080 }, + { 0x0013, 0x0081 }, + { 0x0013, 0x0082 }, + { 0x0013, 0x0083 }, + { 0x0013, 0x0084 }, + { 0x0013, 0x0085 }, + { 0x0013, 0x0086 }, + { 0x0013, 0x0087 }, + { 0x0013, 0x0088 }, + { 0x0013, 0x0089 }, + { 0x0013, 0x008a }, + { 0x0013, 0x008b }, + { 0x0013, 0x008c }, + { 0x0013, 0x008d }, + { 0x0013, 0x008e }, + { 0x0013, 0x008f }, + { 0x0013, 0x0090 }, + { 0x0013, 0x0091 }, + { 0x0013, 0x0092 }, + { 0x0013, 0x0093 }, + { 0x0013, 0x0094 }, + { 0x0013, 0x0095 }, + { 0x0013, 0x0096 }, + { 0x0013, 0x0097 }, + { 0x0013, 0x0098 }, + { 0x0013, 0x0099 }, + { 0x0013, 0x009a }, + { 0x0013, 0x009b }, + { 0x0013, 0x009c }, + { 0x0013, 0x009d }, + { 0x0013, 0x009e }, + { 0x0013, 0x009f }, + + }; + +const uint16_t c_aauiLCLDHuffEnc44[289][2] = + { + { 0x0001, 0x0001 }, + { 0x0003, 0x0001 }, + { 0x0006, 0x0002 }, + { 0x0008, 0x0002 }, + { 0x000b, 0x0002 }, + { 0x000f, 0x000a }, + { 0x0011, 0x0022 }, + { 0x0014, 0x0000 }, + { 0x0014, 0x0001 }, + { 0x0014, 0x0002 }, + { 0x0014, 0x0003 }, + { 0x0014, 0x0004 }, + { 0x0014, 0x0005 }, + { 0x0014, 0x0006 }, + { 0x0014, 0x0007 }, + { 0x0014, 0x0008 }, + { 0x0014, 0x0009 }, + { 0x0003, 0x0002 }, + { 0x0003, 0x0003 }, + { 0x0005, 0x0002 }, + { 0x0008, 0x0003 }, + { 0x000b, 0x0003 }, + { 0x000e, 0x0007 }, + { 0x0012, 0x003f }, + { 0x0014, 0x000a }, + { 0x0014, 0x000b }, + { 0x0014, 0x000c }, + { 0x0014, 0x000d }, + { 0x0014, 0x000e }, + { 0x0014, 0x000f }, + { 0x0014, 0x0010 }, + { 0x0014, 0x0011 }, + { 0x0014, 0x0012 }, + { 0x0014, 0x0013 }, + { 0x0006, 0x0003 }, + { 0x0005, 0x0003 }, + { 0x0007, 0x0003 }, + { 0x0009, 0x0002 }, + { 0x000c, 0x0003 }, + { 0x000f, 0x000b }, + { 0x0012, 0x0040 }, + { 0x0014, 0x0014 }, + { 0x0014, 0x0015 }, + { 0x0014, 0x0016 }, + { 0x0014, 0x0017 }, + { 0x0014, 0x0018 }, + { 0x0014, 0x0019 }, + { 0x0014, 0x001a }, + { 0x0014, 0x001b }, + { 0x0014, 0x001c }, + { 0x0014, 0x001d }, + { 0x0008, 0x0004 }, + { 0x0008, 0x0005 }, + { 0x0009, 0x0003 }, + { 0x000b, 0x0004 }, + { 0x000d, 0x0005 }, + { 0x0010, 0x0013 }, + { 0x0014, 0x001e }, + { 0x0014, 0x001f }, + { 0x0014, 0x0020 }, + { 0x0014, 0x0021 }, + { 0x0014, 0x0022 }, + { 0x0014, 0x0023 }, + { 0x0014, 0x0024 }, + { 0x0014, 0x0025 }, + { 0x0014, 0x0026 }, + { 0x0014, 0x0027 }, + { 0x0014, 0x0028 }, + { 0x000b, 0x0005 }, + { 0x000b, 0x0006 }, + { 0x000b, 0x0007 }, + { 0x000e, 0x0008 }, + { 0x0011, 0x0023 }, + { 0x0012, 0x0041 }, + { 0x0014, 0x0029 }, + { 0x0014, 0x002a }, + { 0x0013, 0x007b }, + { 0x0014, 0x002b }, + { 0x0014, 0x002c }, + { 0x0014, 0x002d }, + { 0x0014, 0x002e }, + { 0x0014, 0x002f }, + { 0x0014, 0x0030 }, + { 0x0014, 0x0031 }, + { 0x0014, 0x0032 }, + { 0x000f, 0x000c }, + { 0x000e, 0x0009 }, + { 0x000f, 0x000d }, + { 0x0011, 0x0024 }, + { 0x0012, 0x0042 }, + { 0x0014, 0x0033 }, + { 0x0014, 0x0034 }, + { 0x0014, 0x0035 }, + { 0x0014, 0x0036 }, + { 0x0014, 0x0037 }, + { 0x0014, 0x0038 }, + { 0x0014, 0x0039 }, + { 0x0014, 0x003a }, + { 0x0014, 0x003b }, + { 0x0014, 0x003c }, + { 0x0014, 0x003d }, + { 0x0014, 0x003e }, + { 0x0013, 0x007c }, + { 0x0011, 0x0025 }, + { 0x0012, 0x0043 }, + { 0x0014, 0x003f }, + { 0x0014, 0x0040 }, + { 0x0014, 0x0041 }, + { 0x0014, 0x0042 }, + { 0x0014, 0x0043 }, + { 0x0014, 0x0044 }, + { 0x0014, 0x0045 }, + { 0x0014, 0x0046 }, + { 0x0014, 0x0047 }, + { 0x0014, 0x0048 }, + { 0x0014, 0x0049 }, + { 0x0014, 0x004a }, + { 0x0014, 0x004b }, + { 0x0014, 0x004c }, + { 0x0014, 0x004d }, + { 0x0014, 0x004e }, + { 0x0014, 0x004f }, + { 0x0014, 0x0050 }, + { 0x0014, 0x0051 }, + { 0x0014, 0x0052 }, + { 0x0014, 0x0053 }, + { 0x0014, 0x0054 }, + { 0x0014, 0x0055 }, + { 0x0014, 0x0056 }, + { 0x0014, 0x0057 }, + { 0x0014, 0x0058 }, + { 0x0014, 0x0059 }, + { 0x0014, 0x005a }, + { 0x0014, 0x005b }, + { 0x0014, 0x005c }, + { 0x0014, 0x005d }, + { 0x0014, 0x005e }, + { 0x0014, 0x005f }, + { 0x0014, 0x0060 }, + { 0x0014, 0x0061 }, + { 0x0014, 0x0062 }, + { 0x0014, 0x0063 }, + { 0x0014, 0x0064 }, + { 0x0014, 0x0065 }, + { 0x0014, 0x0066 }, + { 0x0014, 0x0067 }, + { 0x0014, 0x0068 }, + { 0x0014, 0x0069 }, + { 0x0014, 0x006a }, + { 0x0014, 0x006b }, + { 0x0014, 0x006c }, + { 0x0014, 0x006d }, + { 0x0014, 0x006e }, + { 0x0014, 0x006f }, + { 0x0014, 0x0070 }, + { 0x0014, 0x0071 }, + { 0x0014, 0x0072 }, + { 0x0014, 0x0073 }, + { 0x0014, 0x0074 }, + { 0x0014, 0x0075 }, + { 0x0014, 0x0076 }, + { 0x0014, 0x0077 }, + { 0x0014, 0x0078 }, + { 0x0014, 0x0079 }, + { 0x0014, 0x007a }, + { 0x0014, 0x007b }, + { 0x0014, 0x007c }, + { 0x0014, 0x007d }, + { 0x0014, 0x007e }, + { 0x0014, 0x007f }, + { 0x0014, 0x0080 }, + { 0x0014, 0x0081 }, + { 0x0014, 0x0082 }, + { 0x0014, 0x0083 }, + { 0x0014, 0x0084 }, + { 0x0014, 0x0085 }, + { 0x0014, 0x0086 }, + { 0x0014, 0x0087 }, + { 0x0014, 0x0088 }, + { 0x0014, 0x0089 }, + { 0x0014, 0x008a }, + { 0x0014, 0x008b }, + { 0x0014, 0x008c }, + { 0x0014, 0x008d }, + { 0x0014, 0x008e }, + { 0x0014, 0x008f }, + { 0x0014, 0x0090 }, + { 0x0014, 0x0091 }, + { 0x0014, 0x0092 }, + { 0x0014, 0x0093 }, + { 0x0014, 0x0094 }, + { 0x0014, 0x0095 }, + { 0x0014, 0x0096 }, + { 0x0014, 0x0097 }, + { 0x0014, 0x0098 }, + { 0x0014, 0x0099 }, + { 0x0014, 0x009a }, + { 0x0014, 0x009b }, + { 0x0014, 0x009c }, + { 0x0014, 0x009d }, + { 0x0014, 0x009e }, + { 0x0014, 0x009f }, + { 0x0014, 0x00a0 }, + { 0x0014, 0x00a1 }, + { 0x0014, 0x00a2 }, + { 0x0014, 0x00a3 }, + { 0x0014, 0x00a4 }, + { 0x0014, 0x00a5 }, + { 0x0014, 0x00a6 }, + { 0x0014, 0x00a7 }, + { 0x0014, 0x00a8 }, + { 0x0014, 0x00a9 }, + { 0x0014, 0x00aa }, + { 0x0014, 0x00ab }, + { 0x0014, 0x00ac }, + { 0x0014, 0x00ad }, + { 0x0014, 0x00ae }, + { 0x0014, 0x00af }, + { 0x0014, 0x00b0 }, + { 0x0014, 0x00b1 }, + { 0x0014, 0x00b2 }, + { 0x0014, 0x00b3 }, + { 0x0014, 0x00b4 }, + { 0x0014, 0x00b5 }, + { 0x0014, 0x00b6 }, + { 0x0014, 0x00b7 }, + { 0x0014, 0x00b8 }, + { 0x0014, 0x00b9 }, + { 0x0014, 0x00ba }, + { 0x0014, 0x00bb }, + { 0x0014, 0x00bc }, + { 0x0014, 0x00bd }, + { 0x0014, 0x00be }, + { 0x0014, 0x00bf }, + { 0x0014, 0x00c0 }, + { 0x0014, 0x00c1 }, + { 0x0014, 0x00c2 }, + { 0x0014, 0x00c3 }, + { 0x0014, 0x00c4 }, + { 0x0014, 0x00c5 }, + { 0x0014, 0x00c6 }, + { 0x0014, 0x00c7 }, + { 0x0014, 0x00c8 }, + { 0x0014, 0x00c9 }, + { 0x0014, 0x00ca }, + { 0x0014, 0x00cb }, + { 0x0014, 0x00cc }, + { 0x0014, 0x00cd }, + { 0x0014, 0x00ce }, + { 0x0014, 0x00cf }, + { 0x0014, 0x00d0 }, + { 0x0014, 0x00d1 }, + { 0x0014, 0x00d2 }, + { 0x0014, 0x00d3 }, + { 0x0014, 0x00d4 }, + { 0x0014, 0x00d5 }, + { 0x0014, 0x00d6 }, + { 0x0014, 0x00d7 }, + { 0x0014, 0x00d8 }, + { 0x0014, 0x00d9 }, + { 0x0014, 0x00da }, + { 0x0014, 0x00db }, + { 0x0014, 0x00dc }, + { 0x0014, 0x00dd }, + { 0x0014, 0x00de }, + { 0x0014, 0x00df }, + { 0x0014, 0x00e0 }, + { 0x0014, 0x00e1 }, + { 0x0014, 0x00e2 }, + { 0x0014, 0x00e3 }, + { 0x0014, 0x00e4 }, + { 0x0014, 0x00e5 }, + { 0x0014, 0x00e6 }, + { 0x0014, 0x00e7 }, + { 0x0014, 0x00e8 }, + { 0x0014, 0x00e9 }, + { 0x0014, 0x00ea }, + { 0x0014, 0x00eb }, + { 0x0014, 0x00ec }, + { 0x0014, 0x00ed }, + { 0x0014, 0x00ee }, + { 0x0014, 0x00ef }, + { 0x0014, 0x00f0 }, + { 0x0014, 0x00f1 }, + { 0x0014, 0x00f2 }, + { 0x0014, 0x00f3 }, + { 0x0014, 0x00f4 }, + { 0x0014, 0x00f5 }, + { 0x0013, 0x007d }, + + }; + + +const uint16_t c_aauiLCLDHuffEnc45[324][2] = + { + { 0x0002, 0x0002 }, + { 0x0003, 0x0002 }, + { 0x0005, 0x0003 }, + { 0x0007, 0x0002 }, + { 0x0009, 0x0003 }, + { 0x000c, 0x0005 }, + { 0x0010, 0x0025 }, + { 0x0012, 0x0088 }, + { 0x0013, 0x0000 }, + { 0x0013, 0x0001 }, + { 0x0013, 0x0002 }, + { 0x0013, 0x0003 }, + { 0x0013, 0x0004 }, + { 0x0013, 0x0005 }, + { 0x0013, 0x0006 }, + { 0x0013, 0x0007 }, + { 0x0013, 0x0008 }, + { 0x0013, 0x0009 }, + { 0x0002, 0x0003 }, + { 0x0003, 0x0003 }, + { 0x0005, 0x0004 }, + { 0x0006, 0x0003 }, + { 0x0009, 0x0004 }, + { 0x000b, 0x0004 }, + { 0x000f, 0x0014 }, + { 0x0011, 0x0048 }, + { 0x0013, 0x000a }, + { 0x0013, 0x000b }, + { 0x0013, 0x000c }, + { 0x0013, 0x000d }, + { 0x0013, 0x000e }, + { 0x0013, 0x000f }, + { 0x0013, 0x0010 }, + { 0x0013, 0x0011 }, + { 0x0013, 0x0012 }, + { 0x0013, 0x0013 }, + { 0x0005, 0x0005 }, + { 0x0004, 0x0003 }, + { 0x0006, 0x0004 }, + { 0x0007, 0x0003 }, + { 0x000a, 0x0004 }, + { 0x000d, 0x0007 }, + { 0x000f, 0x0015 }, + { 0x0013, 0x0014 }, + { 0x0013, 0x0015 }, + { 0x0013, 0x0016 }, + { 0x0013, 0x0017 }, + { 0x0013, 0x0018 }, + { 0x0013, 0x0019 }, + { 0x0013, 0x001a }, + { 0x0013, 0x001b }, + { 0x0013, 0x001c }, + { 0x0013, 0x001d }, + { 0x0013, 0x001e }, + { 0x0007, 0x0004 }, + { 0x0006, 0x0005 }, + { 0x0007, 0x0005 }, + { 0x0009, 0x0005 }, + { 0x000b, 0x0005 }, + { 0x000d, 0x0008 }, + { 0x0010, 0x0026 }, + { 0x0012, 0x0089 }, + { 0x0012, 0x008a }, + { 0x0013, 0x001f }, + { 0x0013, 0x0020 }, + { 0x0013, 0x0021 }, + { 0x0013, 0x0022 }, + { 0x0013, 0x0023 }, + { 0x0013, 0x0024 }, + { 0x0013, 0x0025 }, + { 0x0013, 0x0026 }, + { 0x0013, 0x0027 }, + { 0x0009, 0x0006 }, + { 0x0009, 0x0007 }, + { 0x000a, 0x0005 }, + { 0x000b, 0x0006 }, + { 0x000d, 0x0009 }, + { 0x000f, 0x0016 }, + { 0x0011, 0x0049 }, + { 0x0013, 0x0028 }, + { 0x0013, 0x0029 }, + { 0x0013, 0x002a }, + { 0x0013, 0x002b }, + { 0x0013, 0x002c }, + { 0x0013, 0x002d }, + { 0x0013, 0x002e }, + { 0x0013, 0x002f }, + { 0x0013, 0x0030 }, + { 0x0013, 0x0031 }, + { 0x0013, 0x0032 }, + { 0x000c, 0x0006 }, + { 0x000b, 0x0007 }, + { 0x000c, 0x0007 }, + { 0x000e, 0x000d }, + { 0x0010, 0x0027 }, + { 0x0012, 0x008b }, + { 0x0012, 0x008c }, + { 0x0013, 0x0033 }, + { 0x0013, 0x0034 }, + { 0x0013, 0x0035 }, + { 0x0013, 0x0036 }, + { 0x0013, 0x0037 }, + { 0x0013, 0x0038 }, + { 0x0013, 0x0039 }, + { 0x0013, 0x003a }, + { 0x0013, 0x003b }, + { 0x0013, 0x003c }, + { 0x0013, 0x003d }, + { 0x000f, 0x0017 }, + { 0x000f, 0x0018 }, + { 0x000f, 0x0019 }, + { 0x0012, 0x008d }, + { 0x0013, 0x003e }, + { 0x0013, 0x003f }, + { 0x0013, 0x0040 }, + { 0x0013, 0x0041 }, + { 0x0013, 0x0042 }, + { 0x0013, 0x0043 }, + { 0x0013, 0x0044 }, + { 0x0013, 0x0045 }, + { 0x0013, 0x0046 }, + { 0x0013, 0x0047 }, + { 0x0013, 0x0048 }, + { 0x0013, 0x0049 }, + { 0x0013, 0x004a }, + { 0x0013, 0x004b }, + { 0x0013, 0x004c }, + { 0x0012, 0x008e }, + { 0x0012, 0x008f }, + { 0x0013, 0x004d }, + { 0x0013, 0x004e }, + { 0x0013, 0x004f }, + { 0x0013, 0x0050 }, + { 0x0013, 0x0051 }, + { 0x0013, 0x0052 }, + { 0x0013, 0x0053 }, + { 0x0013, 0x0054 }, + { 0x0013, 0x0055 }, + { 0x0013, 0x0056 }, + { 0x0013, 0x0057 }, + { 0x0013, 0x0058 }, + { 0x0013, 0x0059 }, + { 0x0013, 0x005a }, + { 0x0013, 0x005b }, + { 0x0013, 0x005c }, + { 0x0013, 0x005d }, + { 0x0013, 0x005e }, + { 0x0013, 0x005f }, + { 0x0013, 0x0060 }, + { 0x0013, 0x0061 }, + { 0x0013, 0x0062 }, + { 0x0013, 0x0063 }, + { 0x0013, 0x0064 }, + { 0x0013, 0x0065 }, + { 0x0013, 0x0066 }, + { 0x0013, 0x0067 }, + { 0x0013, 0x0068 }, + { 0x0013, 0x0069 }, + { 0x0013, 0x006a }, + { 0x0013, 0x006b }, + { 0x0013, 0x006c }, + { 0x0013, 0x006d }, + { 0x0013, 0x006e }, + { 0x0013, 0x006f }, + { 0x0013, 0x0070 }, + { 0x0013, 0x0071 }, + { 0x0013, 0x0072 }, + { 0x0013, 0x0073 }, + { 0x0013, 0x0074 }, + { 0x0013, 0x0075 }, + { 0x0013, 0x0076 }, + { 0x0013, 0x0077 }, + { 0x0013, 0x0078 }, + { 0x0013, 0x0079 }, + { 0x0013, 0x007a }, + { 0x0013, 0x007b }, + { 0x0013, 0x007c }, + { 0x0013, 0x007d }, + { 0x0013, 0x007e }, + { 0x0013, 0x007f }, + { 0x0013, 0x0080 }, + { 0x0013, 0x0081 }, + { 0x0013, 0x0082 }, + { 0x0013, 0x0083 }, + { 0x0013, 0x0084 }, + { 0x0013, 0x0085 }, + { 0x0013, 0x0086 }, + { 0x0013, 0x0087 }, + { 0x0013, 0x0088 }, + { 0x0013, 0x0089 }, + { 0x0013, 0x008a }, + { 0x0013, 0x008b }, + { 0x0013, 0x008c }, + { 0x0013, 0x008d }, + { 0x0013, 0x008e }, + { 0x0013, 0x008f }, + { 0x0013, 0x0090 }, + { 0x0013, 0x0091 }, + { 0x0013, 0x0092 }, + { 0x0013, 0x0093 }, + { 0x0013, 0x0094 }, + { 0x0013, 0x0095 }, + { 0x0013, 0x0096 }, + { 0x0013, 0x0097 }, + { 0x0013, 0x0098 }, + { 0x0013, 0x0099 }, + { 0x0013, 0x009a }, + { 0x0013, 0x009b }, + { 0x0013, 0x009c }, + { 0x0013, 0x009d }, + { 0x0013, 0x009e }, + { 0x0013, 0x009f }, + { 0x0013, 0x00a0 }, + { 0x0013, 0x00a1 }, + { 0x0013, 0x00a2 }, + { 0x0013, 0x00a3 }, + { 0x0013, 0x00a4 }, + { 0x0013, 0x00a5 }, + { 0x0013, 0x00a6 }, + { 0x0013, 0x00a7 }, + { 0x0013, 0x00a8 }, + { 0x0013, 0x00a9 }, + { 0x0013, 0x00aa }, + { 0x0013, 0x00ab }, + { 0x0013, 0x00ac }, + { 0x0013, 0x00ad }, + { 0x0013, 0x00ae }, + { 0x0013, 0x00af }, + { 0x0013, 0x00b0 }, + { 0x0013, 0x00b1 }, + { 0x0013, 0x00b2 }, + { 0x0013, 0x00b3 }, + { 0x0013, 0x00b4 }, + { 0x0013, 0x00b5 }, + { 0x0013, 0x00b6 }, + { 0x0013, 0x00b7 }, + { 0x0013, 0x00b8 }, + { 0x0013, 0x00b9 }, + { 0x0013, 0x00ba }, + { 0x0013, 0x00bb }, + { 0x0013, 0x00bc }, + { 0x0013, 0x00bd }, + { 0x0013, 0x00be }, + { 0x0013, 0x00bf }, + { 0x0013, 0x00c0 }, + { 0x0013, 0x00c1 }, + { 0x0013, 0x00c2 }, + { 0x0013, 0x00c3 }, + { 0x0013, 0x00c4 }, + { 0x0013, 0x00c5 }, + { 0x0013, 0x00c6 }, + { 0x0013, 0x00c7 }, + { 0x0013, 0x00c8 }, + { 0x0013, 0x00c9 }, + { 0x0013, 0x00ca }, + { 0x0013, 0x00cb }, + { 0x0013, 0x00cc }, + { 0x0013, 0x00cd }, + { 0x0013, 0x00ce }, + { 0x0013, 0x00cf }, + { 0x0013, 0x00d0 }, + { 0x0013, 0x00d1 }, + { 0x0013, 0x00d2 }, + { 0x0013, 0x00d3 }, + { 0x0013, 0x00d4 }, + { 0x0013, 0x00d5 }, + { 0x0013, 0x00d6 }, + { 0x0013, 0x00d7 }, + { 0x0013, 0x00d8 }, + { 0x0013, 0x00d9 }, + { 0x0013, 0x00da }, + { 0x0013, 0x00db }, + { 0x0013, 0x00dc }, + { 0x0013, 0x00dd }, + { 0x0013, 0x00de }, + { 0x0013, 0x00df }, + { 0x0013, 0x00e0 }, + { 0x0013, 0x00e1 }, + { 0x0013, 0x00e2 }, + { 0x0013, 0x00e3 }, + { 0x0013, 0x00e4 }, + { 0x0013, 0x00e5 }, + { 0x0013, 0x00e6 }, + { 0x0013, 0x00e7 }, + { 0x0013, 0x00e8 }, + { 0x0013, 0x00e9 }, + { 0x0013, 0x00ea }, + { 0x0013, 0x00eb }, + { 0x0013, 0x00ec }, + { 0x0013, 0x00ed }, + { 0x0013, 0x00ee }, + { 0x0013, 0x00ef }, + { 0x0013, 0x00f0 }, + { 0x0013, 0x00f1 }, + { 0x0013, 0x00f2 }, + { 0x0013, 0x00f3 }, + { 0x0013, 0x00f4 }, + { 0x0013, 0x00f5 }, + { 0x0013, 0x00f6 }, + { 0x0013, 0x00f7 }, + { 0x0013, 0x00f8 }, + { 0x0013, 0x00f9 }, + { 0x0013, 0x00fa }, + { 0x0013, 0x00fb }, + { 0x0013, 0x00fc }, + { 0x0013, 0x00fd }, + { 0x0013, 0x00fe }, + { 0x0013, 0x00ff }, + { 0x0013, 0x0100 }, + { 0x0013, 0x0101 }, + { 0x0013, 0x0102 }, + { 0x0013, 0x0103 }, + { 0x0013, 0x0104 }, + { 0x0013, 0x0105 }, + { 0x0013, 0x0106 }, + { 0x0013, 0x0107 }, + { 0x0013, 0x0108 }, + { 0x0013, 0x0109 }, + { 0x0013, 0x010a }, + { 0x0013, 0x010b }, + { 0x0013, 0x010c }, + { 0x0013, 0x010d }, + { 0x0013, 0x010e }, + { 0x0013, 0x010f }, + + }; + +const uint16_t c_aauiLCLDHuffEnc46[400][2] = + { + { 0x0002, 0x0002 }, + { 0x0003, 0x0002 }, + { 0x0005, 0x0003 }, + { 0x0007, 0x0004 }, + { 0x0009, 0x0005 }, + { 0x000b, 0x0006 }, + { 0x000d, 0x000a }, + { 0x000f, 0x0018 }, + { 0x0012, 0x00a6 }, + { 0x0013, 0x0000 }, + { 0x0013, 0x0001 }, + { 0x0013, 0x0002 }, + { 0x0013, 0x0003 }, + { 0x0013, 0x0004 }, + { 0x0013, 0x0005 }, + { 0x0013, 0x0006 }, + { 0x0013, 0x0007 }, + { 0x0013, 0x0008 }, + { 0x0013, 0x0009 }, + { 0x0013, 0x000a }, + { 0x0002, 0x0003 }, + { 0x0003, 0x0003 }, + { 0x0005, 0x0004 }, + { 0x0006, 0x0004 }, + { 0x0008, 0x0004 }, + { 0x000a, 0x0006 }, + { 0x000c, 0x0008 }, + { 0x000e, 0x0011 }, + { 0x0012, 0x00a7 }, + { 0x0013, 0x000b }, + { 0x0013, 0x000c }, + { 0x0013, 0x000d }, + { 0x0013, 0x000e }, + { 0x0013, 0x000f }, + { 0x0013, 0x0010 }, + { 0x0013, 0x0011 }, + { 0x0013, 0x0012 }, + { 0x0013, 0x0013 }, + { 0x0013, 0x0014 }, + { 0x0013, 0x0015 }, + { 0x0005, 0x0005 }, + { 0x0005, 0x0006 }, + { 0x0005, 0x0007 }, + { 0x0007, 0x0005 }, + { 0x0009, 0x0006 }, + { 0x000b, 0x0007 }, + { 0x000d, 0x000b }, + { 0x000f, 0x0019 }, + { 0x0013, 0x0016 }, + { 0x0013, 0x0017 }, + { 0x0013, 0x0018 }, + { 0x0013, 0x0019 }, + { 0x0013, 0x001a }, + { 0x0013, 0x001b }, + { 0x0013, 0x001c }, + { 0x0013, 0x001d }, + { 0x0013, 0x001e }, + { 0x0013, 0x001f }, + { 0x0013, 0x0020 }, + { 0x0013, 0x0021 }, + { 0x0007, 0x0006 }, + { 0x0006, 0x0005 }, + { 0x0007, 0x0007 }, + { 0x0008, 0x0005 }, + { 0x000a, 0x0007 }, + { 0x000c, 0x0009 }, + { 0x000e, 0x0012 }, + { 0x000f, 0x001a }, + { 0x0012, 0x00a8 }, + { 0x0013, 0x0022 }, + { 0x0013, 0x0023 }, + { 0x0013, 0x0024 }, + { 0x0013, 0x0025 }, + { 0x0013, 0x0026 }, + { 0x0013, 0x0027 }, + { 0x0013, 0x0028 }, + { 0x0013, 0x0029 }, + { 0x0013, 0x002a }, + { 0x0013, 0x002b }, + { 0x0013, 0x002c }, + { 0x0009, 0x0007 }, + { 0x0008, 0x0006 }, + { 0x0008, 0x0007 }, + { 0x000a, 0x0008 }, + { 0x000b, 0x0008 }, + { 0x000d, 0x000c }, + { 0x000e, 0x0013 }, + { 0x0010, 0x002c }, + { 0x0013, 0x002d }, + { 0x0013, 0x002e }, + { 0x0013, 0x002f }, + { 0x0013, 0x0030 }, + { 0x0013, 0x0031 }, + { 0x0013, 0x0032 }, + { 0x0013, 0x0033 }, + { 0x0013, 0x0034 }, + { 0x0013, 0x0035 }, + { 0x0013, 0x0036 }, + { 0x0013, 0x0037 }, + { 0x0013, 0x0038 }, + { 0x000b, 0x0009 }, + { 0x000a, 0x0009 }, + { 0x000b, 0x000a }, + { 0x000b, 0x000b }, + { 0x000d, 0x000d }, + { 0x000f, 0x001b }, + { 0x0010, 0x002d }, + { 0x0013, 0x0039 }, + { 0x0013, 0x003a }, + { 0x0013, 0x003b }, + { 0x0013, 0x003c }, + { 0x0013, 0x003d }, + { 0x0013, 0x003e }, + { 0x0013, 0x003f }, + { 0x0013, 0x0040 }, + { 0x0013, 0x0041 }, + { 0x0013, 0x0042 }, + { 0x0013, 0x0043 }, + { 0x0013, 0x0044 }, + { 0x0013, 0x0045 }, + { 0x000d, 0x000e }, + { 0x000c, 0x000a }, + { 0x000c, 0x000b }, + { 0x000d, 0x000f }, + { 0x000f, 0x001c }, + { 0x000f, 0x001d }, + { 0x0013, 0x0046 }, + { 0x0013, 0x0047 }, + { 0x0013, 0x0048 }, + { 0x0013, 0x0049 }, + { 0x0013, 0x004a }, + { 0x0013, 0x004b }, + { 0x0013, 0x004c }, + { 0x0013, 0x004d }, + { 0x0013, 0x004e }, + { 0x0013, 0x004f }, + { 0x0013, 0x0050 }, + { 0x0013, 0x0051 }, + { 0x0013, 0x0052 }, + { 0x0013, 0x0053 }, + { 0x000f, 0x001e }, + { 0x000f, 0x001f }, + { 0x000f, 0x0020 }, + { 0x000f, 0x0021 }, + { 0x0010, 0x002e }, + { 0x0012, 0x00a9 }, + { 0x0013, 0x0054 }, + { 0x0013, 0x0055 }, + { 0x0012, 0x00aa }, + { 0x0013, 0x0056 }, + { 0x0013, 0x0057 }, + { 0x0013, 0x0058 }, + { 0x0013, 0x0059 }, + { 0x0013, 0x005a }, + { 0x0013, 0x005b }, + { 0x0013, 0x005c }, + { 0x0013, 0x005d }, + { 0x0013, 0x005e }, + { 0x0013, 0x005f }, + { 0x0013, 0x0060 }, + { 0x0013, 0x0061 }, + { 0x0010, 0x002f }, + { 0x0013, 0x0062 }, + { 0x0011, 0x0057 }, + { 0x0013, 0x0063 }, + { 0x0013, 0x0064 }, + { 0x0013, 0x0065 }, + { 0x0013, 0x0066 }, + { 0x0013, 0x0067 }, + { 0x0013, 0x0068 }, + { 0x0013, 0x0069 }, + { 0x0013, 0x006a }, + { 0x0013, 0x006b }, + { 0x0013, 0x006c }, + { 0x0013, 0x006d }, + { 0x0013, 0x006e }, + { 0x0013, 0x006f }, + { 0x0013, 0x0070 }, + { 0x0013, 0x0071 }, + { 0x0013, 0x0072 }, + { 0x0013, 0x0073 }, + { 0x0013, 0x0074 }, + { 0x0013, 0x0075 }, + { 0x0013, 0x0076 }, + { 0x0013, 0x0077 }, + { 0x0013, 0x0078 }, + { 0x0013, 0x0079 }, + { 0x0013, 0x007a }, + { 0x0013, 0x007b }, + { 0x0013, 0x007c }, + { 0x0013, 0x007d }, + { 0x0013, 0x007e }, + { 0x0013, 0x007f }, + { 0x0013, 0x0080 }, + { 0x0013, 0x0081 }, + { 0x0013, 0x0082 }, + { 0x0013, 0x0083 }, + { 0x0013, 0x0084 }, + { 0x0013, 0x0085 }, + { 0x0013, 0x0086 }, + { 0x0013, 0x0087 }, + { 0x0013, 0x0088 }, + { 0x0013, 0x0089 }, + { 0x0013, 0x008a }, + { 0x0013, 0x008b }, + { 0x0013, 0x008c }, + { 0x0013, 0x008d }, + { 0x0013, 0x008e }, + { 0x0013, 0x008f }, + { 0x0013, 0x0090 }, + { 0x0013, 0x0091 }, + { 0x0013, 0x0092 }, + { 0x0013, 0x0093 }, + { 0x0013, 0x0094 }, + { 0x0013, 0x0095 }, + { 0x0013, 0x0096 }, + { 0x0013, 0x0097 }, + { 0x0013, 0x0098 }, + { 0x0013, 0x0099 }, + { 0x0013, 0x009a }, + { 0x0013, 0x009b }, + { 0x0013, 0x009c }, + { 0x0013, 0x009d }, + { 0x0013, 0x009e }, + { 0x0013, 0x009f }, + { 0x0013, 0x00a0 }, + { 0x0013, 0x00a1 }, + { 0x0013, 0x00a2 }, + { 0x0013, 0x00a3 }, + { 0x0013, 0x00a4 }, + { 0x0013, 0x00a5 }, + { 0x0013, 0x00a6 }, + { 0x0013, 0x00a7 }, + { 0x0013, 0x00a8 }, + { 0x0013, 0x00a9 }, + { 0x0013, 0x00aa }, + { 0x0013, 0x00ab }, + { 0x0013, 0x00ac }, + { 0x0013, 0x00ad }, + { 0x0013, 0x00ae }, + { 0x0013, 0x00af }, + { 0x0013, 0x00b0 }, + { 0x0013, 0x00b1 }, + { 0x0013, 0x00b2 }, + { 0x0013, 0x00b3 }, + { 0x0013, 0x00b4 }, + { 0x0013, 0x00b5 }, + { 0x0013, 0x00b6 }, + { 0x0013, 0x00b7 }, + { 0x0013, 0x00b8 }, + { 0x0013, 0x00b9 }, + { 0x0013, 0x00ba }, + { 0x0013, 0x00bb }, + { 0x0013, 0x00bc }, + { 0x0013, 0x00bd }, + { 0x0013, 0x00be }, + { 0x0013, 0x00bf }, + { 0x0013, 0x00c0 }, + { 0x0013, 0x00c1 }, + { 0x0013, 0x00c2 }, + { 0x0013, 0x00c3 }, + { 0x0013, 0x00c4 }, + { 0x0013, 0x00c5 }, + { 0x0013, 0x00c6 }, + { 0x0013, 0x00c7 }, + { 0x0013, 0x00c8 }, + { 0x0013, 0x00c9 }, + { 0x0013, 0x00ca }, + { 0x0013, 0x00cb }, + { 0x0013, 0x00cc }, + { 0x0013, 0x00cd }, + { 0x0013, 0x00ce }, + { 0x0013, 0x00cf }, + { 0x0013, 0x00d0 }, + { 0x0013, 0x00d1 }, + { 0x0013, 0x00d2 }, + { 0x0013, 0x00d3 }, + { 0x0013, 0x00d4 }, + { 0x0013, 0x00d5 }, + { 0x0013, 0x00d6 }, + { 0x0013, 0x00d7 }, + { 0x0013, 0x00d8 }, + { 0x0013, 0x00d9 }, + { 0x0013, 0x00da }, + { 0x0013, 0x00db }, + { 0x0013, 0x00dc }, + { 0x0013, 0x00dd }, + { 0x0013, 0x00de }, + { 0x0013, 0x00df }, + { 0x0013, 0x00e0 }, + { 0x0013, 0x00e1 }, + { 0x0013, 0x00e2 }, + { 0x0013, 0x00e3 }, + { 0x0013, 0x00e4 }, + { 0x0013, 0x00e5 }, + { 0x0013, 0x00e6 }, + { 0x0013, 0x00e7 }, + { 0x0013, 0x00e8 }, + { 0x0013, 0x00e9 }, + { 0x0013, 0x00ea }, + { 0x0013, 0x00eb }, + { 0x0013, 0x00ec }, + { 0x0013, 0x00ed }, + { 0x0013, 0x00ee }, + { 0x0013, 0x00ef }, + { 0x0013, 0x00f0 }, + { 0x0013, 0x00f1 }, + { 0x0013, 0x00f2 }, + { 0x0013, 0x00f3 }, + { 0x0013, 0x00f4 }, + { 0x0013, 0x00f5 }, + { 0x0013, 0x00f6 }, + { 0x0013, 0x00f7 }, + { 0x0013, 0x00f8 }, + { 0x0013, 0x00f9 }, + { 0x0013, 0x00fa }, + { 0x0013, 0x00fb }, + { 0x0013, 0x00fc }, + { 0x0013, 0x00fd }, + { 0x0013, 0x00fe }, + { 0x0013, 0x00ff }, + { 0x0013, 0x0100 }, + { 0x0013, 0x0101 }, + { 0x0013, 0x0102 }, + { 0x0013, 0x0103 }, + { 0x0013, 0x0104 }, + { 0x0013, 0x0105 }, + { 0x0013, 0x0106 }, + { 0x0013, 0x0107 }, + { 0x0013, 0x0108 }, + { 0x0013, 0x0109 }, + { 0x0013, 0x010a }, + { 0x0013, 0x010b }, + { 0x0013, 0x010c }, + { 0x0013, 0x010d }, + { 0x0013, 0x010e }, + { 0x0013, 0x010f }, + { 0x0013, 0x0110 }, + { 0x0013, 0x0111 }, + { 0x0013, 0x0112 }, + { 0x0013, 0x0113 }, + { 0x0013, 0x0114 }, + { 0x0013, 0x0115 }, + { 0x0013, 0x0116 }, + { 0x0013, 0x0117 }, + { 0x0013, 0x0118 }, + { 0x0013, 0x0119 }, + { 0x0013, 0x011a }, + { 0x0013, 0x011b }, + { 0x0013, 0x011c }, + { 0x0013, 0x011d }, + { 0x0013, 0x011e }, + { 0x0013, 0x011f }, + { 0x0013, 0x0120 }, + { 0x0013, 0x0121 }, + { 0x0013, 0x0122 }, + { 0x0013, 0x0123 }, + { 0x0013, 0x0124 }, + { 0x0013, 0x0125 }, + { 0x0013, 0x0126 }, + { 0x0013, 0x0127 }, + { 0x0013, 0x0128 }, + { 0x0013, 0x0129 }, + { 0x0013, 0x012a }, + { 0x0013, 0x012b }, + { 0x0013, 0x012c }, + { 0x0013, 0x012d }, + { 0x0013, 0x012e }, + { 0x0013, 0x012f }, + { 0x0013, 0x0130 }, + { 0x0013, 0x0131 }, + { 0x0013, 0x0132 }, + { 0x0013, 0x0133 }, + { 0x0013, 0x0134 }, + { 0x0013, 0x0135 }, + { 0x0013, 0x0136 }, + { 0x0013, 0x0137 }, + { 0x0013, 0x0138 }, + { 0x0013, 0x0139 }, + { 0x0013, 0x013a }, + { 0x0013, 0x013b }, + { 0x0013, 0x013c }, + { 0x0013, 0x013d }, + { 0x0013, 0x013e }, + { 0x0013, 0x013f }, + { 0x0013, 0x0140 }, + { 0x0013, 0x0141 }, + { 0x0013, 0x0142 }, + { 0x0013, 0x0143 }, + { 0x0013, 0x0144 }, + { 0x0013, 0x0145 }, + { 0x0013, 0x0146 }, + { 0x0013, 0x0147 }, + { 0x0013, 0x0148 }, + { 0x0013, 0x0149 }, + { 0x0013, 0x014a }, + { 0x0013, 0x014b }, + { 0x0012, 0x00ab }, + { 0x0012, 0x00ac }, + { 0x0012, 0x00ad }, + }; + +const uint16_t c_aauiLCLDHuffEnc47[576][2] = + { + { 0x0002, 0x0003 }, + { 0x0003, 0x0003 }, + { 0x0005, 0x0005 }, + { 0x0006, 0x0004 }, + { 0x0008, 0x0006 }, + { 0x000a, 0x0007 }, + { 0x000c, 0x000b }, + { 0x000d, 0x000d }, + { 0x0010, 0x0041 }, + { 0x0013, 0x0000 }, + { 0x0013, 0x0001 }, + { 0x0013, 0x0002 }, + { 0x0013, 0x0003 }, + { 0x0013, 0x0004 }, + { 0x0013, 0x0005 }, + { 0x0013, 0x0006 }, + { 0x0013, 0x0007 }, + { 0x0013, 0x0008 }, + { 0x0013, 0x0009 }, + { 0x0013, 0x000a }, + { 0x0013, 0x000b }, + { 0x0013, 0x000c }, + { 0x0013, 0x000d }, + { 0x0013, 0x000e }, + { 0x0003, 0x0004 }, + { 0x0003, 0x0005 }, + { 0x0004, 0x0004 }, + { 0x0006, 0x0005 }, + { 0x0007, 0x0005 }, + { 0x0009, 0x0006 }, + { 0x000b, 0x0007 }, + { 0x000d, 0x000e }, + { 0x000f, 0x0025 }, + { 0x000f, 0x0026 }, + { 0x0012, 0x00f6 }, + { 0x0013, 0x000f }, + { 0x0013, 0x0010 }, + { 0x0013, 0x0011 }, + { 0x0013, 0x0012 }, + { 0x0013, 0x0013 }, + { 0x0013, 0x0014 }, + { 0x0013, 0x0015 }, + { 0x0013, 0x0016 }, + { 0x0013, 0x0017 }, + { 0x0013, 0x0018 }, + { 0x0013, 0x0019 }, + { 0x0013, 0x001a }, + { 0x0013, 0x001b }, + { 0x0005, 0x0006 }, + { 0x0004, 0x0005 }, + { 0x0005, 0x0007 }, + { 0x0006, 0x0006 }, + { 0x0008, 0x0007 }, + { 0x0009, 0x0007 }, + { 0x000b, 0x0008 }, + { 0x000d, 0x000f }, + { 0x000f, 0x0027 }, + { 0x0012, 0x00f7 }, + { 0x0013, 0x001c }, + { 0x0013, 0x001d }, + { 0x0013, 0x001e }, + { 0x0013, 0x001f }, + { 0x0013, 0x0020 }, + { 0x0013, 0x0021 }, + { 0x0013, 0x0022 }, + { 0x0013, 0x0023 }, + { 0x0013, 0x0024 }, + { 0x0013, 0x0025 }, + { 0x0013, 0x0026 }, + { 0x0013, 0x0027 }, + { 0x0013, 0x0028 }, + { 0x0013, 0x0029 }, + { 0x0006, 0x0007 }, + { 0x0006, 0x0008 }, + { 0x0006, 0x0009 }, + { 0x0007, 0x0006 }, + { 0x0009, 0x0008 }, + { 0x000a, 0x0008 }, + { 0x000c, 0x000c }, + { 0x000e, 0x0017 }, + { 0x0010, 0x0042 }, + { 0x0012, 0x00f8 }, + { 0x0013, 0x002a }, + { 0x0013, 0x002b }, + { 0x0013, 0x002c }, + { 0x0013, 0x002d }, + { 0x0013, 0x002e }, + { 0x0013, 0x002f }, + { 0x0013, 0x0030 }, + { 0x0013, 0x0031 }, + { 0x0013, 0x0032 }, + { 0x0013, 0x0033 }, + { 0x0013, 0x0034 }, + { 0x0013, 0x0035 }, + { 0x0013, 0x0036 }, + { 0x0013, 0x0037 }, + { 0x0008, 0x0008 }, + { 0x0007, 0x0007 }, + { 0x0008, 0x0009 }, + { 0x0009, 0x0009 }, + { 0x000a, 0x0009 }, + { 0x000b, 0x0009 }, + { 0x000d, 0x0010 }, + { 0x000f, 0x0028 }, + { 0x000f, 0x0029 }, + { 0x0011, 0x007f }, + { 0x0013, 0x0038 }, + { 0x0013, 0x0039 }, + { 0x0013, 0x003a }, + { 0x0013, 0x003b }, + { 0x0013, 0x003c }, + { 0x0013, 0x003d }, + { 0x0013, 0x003e }, + { 0x0013, 0x003f }, + { 0x0013, 0x0040 }, + { 0x0013, 0x0041 }, + { 0x0013, 0x0042 }, + { 0x0013, 0x0043 }, + { 0x0013, 0x0044 }, + { 0x0013, 0x0045 }, + { 0x000a, 0x000a }, + { 0x0009, 0x000a }, + { 0x0009, 0x000b }, + { 0x000a, 0x000b }, + { 0x000b, 0x000a }, + { 0x000d, 0x0011 }, + { 0x000f, 0x002a }, + { 0x0010, 0x0043 }, + { 0x0012, 0x00f9 }, + { 0x0013, 0x0046 }, + { 0x0013, 0x0047 }, + { 0x0013, 0x0048 }, + { 0x0013, 0x0049 }, + { 0x0013, 0x004a }, + { 0x0013, 0x004b }, + { 0x0013, 0x004c }, + { 0x0013, 0x004d }, + { 0x0013, 0x004e }, + { 0x0013, 0x004f }, + { 0x0013, 0x0050 }, + { 0x0013, 0x0051 }, + { 0x0013, 0x0052 }, + { 0x0013, 0x0053 }, + { 0x0013, 0x0054 }, + { 0x000b, 0x000b }, + { 0x000b, 0x000c }, + { 0x000b, 0x000d }, + { 0x000c, 0x000d }, + { 0x000d, 0x0012 }, + { 0x000e, 0x0018 }, + { 0x0010, 0x0044 }, + { 0x0013, 0x0055 }, + { 0x0013, 0x0056 }, + { 0x0013, 0x0057 }, + { 0x0013, 0x0058 }, + { 0x0013, 0x0059 }, + { 0x0013, 0x005a }, + { 0x0013, 0x005b }, + { 0x0013, 0x005c }, + { 0x0013, 0x005d }, + { 0x0013, 0x005e }, + { 0x0013, 0x005f }, + { 0x0013, 0x0060 }, + { 0x0013, 0x0061 }, + { 0x0013, 0x0062 }, + { 0x0013, 0x0063 }, + { 0x0013, 0x0064 }, + { 0x0013, 0x0065 }, + { 0x000e, 0x0019 }, + { 0x000d, 0x0013 }, + { 0x000d, 0x0014 }, + { 0x000d, 0x0015 }, + { 0x000f, 0x002b }, + { 0x0010, 0x0045 }, + { 0x0013, 0x0066 }, + { 0x0012, 0x00fa }, + { 0x0013, 0x0067 }, + { 0x0013, 0x0068 }, + { 0x0013, 0x0069 }, + { 0x0013, 0x006a }, + { 0x0013, 0x006b }, + { 0x0013, 0x006c }, + { 0x0013, 0x006d }, + { 0x0013, 0x006e }, + { 0x0013, 0x006f }, + { 0x0013, 0x0070 }, + { 0x0013, 0x0071 }, + { 0x0013, 0x0072 }, + { 0x0013, 0x0073 }, + { 0x0013, 0x0074 }, + { 0x0013, 0x0075 }, + { 0x0013, 0x0076 }, + { 0x0010, 0x0046 }, + { 0x000f, 0x002c }, + { 0x000f, 0x002d }, + { 0x0010, 0x0047 }, + { 0x0011, 0x0080 }, + { 0x0013, 0x0077 }, + { 0x0013, 0x0078 }, + { 0x0013, 0x0079 }, + { 0x0013, 0x007a }, + { 0x0013, 0x007b }, + { 0x0013, 0x007c }, + { 0x0013, 0x007d }, + { 0x0013, 0x007e }, + { 0x0013, 0x007f }, + { 0x0013, 0x0080 }, + { 0x0013, 0x0081 }, + { 0x0013, 0x0082 }, + { 0x0013, 0x0083 }, + { 0x0013, 0x0084 }, + { 0x0013, 0x0085 }, + { 0x0013, 0x0086 }, + { 0x0013, 0x0087 }, + { 0x0013, 0x0088 }, + { 0x0013, 0x0089 }, + { 0x0013, 0x008a }, + { 0x0010, 0x0048 }, + { 0x0010, 0x0049 }, + { 0x0011, 0x0081 }, + { 0x0013, 0x008b }, + { 0x0012, 0x00fb }, + { 0x0013, 0x008c }, + { 0x0013, 0x008d }, + { 0x0013, 0x008e }, + { 0x0013, 0x008f }, + { 0x0013, 0x0090 }, + { 0x0013, 0x0091 }, + { 0x0013, 0x0092 }, + { 0x0013, 0x0093 }, + { 0x0013, 0x0094 }, + { 0x0013, 0x0095 }, + { 0x0013, 0x0096 }, + { 0x0013, 0x0097 }, + { 0x0013, 0x0098 }, + { 0x0013, 0x0099 }, + { 0x0013, 0x009a }, + { 0x0013, 0x009b }, + { 0x0013, 0x009c }, + { 0x0013, 0x009d }, + { 0x0013, 0x009e }, + { 0x0013, 0x009f }, + { 0x0013, 0x00a0 }, + { 0x0012, 0x00fc }, + { 0x0013, 0x00a1 }, + { 0x0013, 0x00a2 }, + { 0x0013, 0x00a3 }, + { 0x0013, 0x00a4 }, + { 0x0013, 0x00a5 }, + { 0x0013, 0x00a6 }, + { 0x0013, 0x00a7 }, + { 0x0013, 0x00a8 }, + { 0x0013, 0x00a9 }, + { 0x0013, 0x00aa }, + { 0x0013, 0x00ab }, + { 0x0013, 0x00ac }, + { 0x0013, 0x00ad }, + { 0x0013, 0x00ae }, + { 0x0013, 0x00af }, + { 0x0013, 0x00b0 }, + { 0x0013, 0x00b1 }, + { 0x0013, 0x00b2 }, + { 0x0013, 0x00b3 }, + { 0x0013, 0x00b4 }, + { 0x0013, 0x00b5 }, + { 0x0013, 0x00b6 }, + { 0x0013, 0x00b7 }, + { 0x0013, 0x00b8 }, + { 0x0013, 0x00b9 }, + { 0x0013, 0x00ba }, + { 0x0013, 0x00bb }, + { 0x0013, 0x00bc }, + { 0x0013, 0x00bd }, + { 0x0013, 0x00be }, + { 0x0013, 0x00bf }, + { 0x0013, 0x00c0 }, + { 0x0013, 0x00c1 }, + { 0x0013, 0x00c2 }, + { 0x0013, 0x00c3 }, + { 0x0013, 0x00c4 }, + { 0x0013, 0x00c5 }, + { 0x0013, 0x00c6 }, + { 0x0013, 0x00c7 }, + { 0x0013, 0x00c8 }, + { 0x0013, 0x00c9 }, + { 0x0013, 0x00ca }, + { 0x0013, 0x00cb }, + { 0x0013, 0x00cc }, + { 0x0013, 0x00cd }, + { 0x0013, 0x00ce }, + { 0x0013, 0x00cf }, + { 0x0013, 0x00d0 }, + { 0x0013, 0x00d1 }, + { 0x0013, 0x00d2 }, + { 0x0013, 0x00d3 }, + { 0x0013, 0x00d4 }, + { 0x0013, 0x00d5 }, + { 0x0013, 0x00d6 }, + { 0x0013, 0x00d7 }, + { 0x0013, 0x00d8 }, + { 0x0013, 0x00d9 }, + { 0x0013, 0x00da }, + { 0x0013, 0x00db }, + { 0x0013, 0x00dc }, + { 0x0013, 0x00dd }, + { 0x0013, 0x00de }, + { 0x0013, 0x00df }, + { 0x0013, 0x00e0 }, + { 0x0013, 0x00e1 }, + { 0x0013, 0x00e2 }, + { 0x0013, 0x00e3 }, + { 0x0013, 0x00e4 }, + { 0x0013, 0x00e5 }, + { 0x0013, 0x00e6 }, + { 0x0013, 0x00e7 }, + { 0x0013, 0x00e8 }, + { 0x0013, 0x00e9 }, + { 0x0013, 0x00ea }, + { 0x0013, 0x00eb }, + { 0x0013, 0x00ec }, + { 0x0013, 0x00ed }, + { 0x0013, 0x00ee }, + { 0x0013, 0x00ef }, + { 0x0013, 0x00f0 }, + { 0x0013, 0x00f1 }, + { 0x0013, 0x00f2 }, + { 0x0013, 0x00f3 }, + { 0x0013, 0x00f4 }, + { 0x0013, 0x00f5 }, + { 0x0013, 0x00f6 }, + { 0x0013, 0x00f7 }, + { 0x0013, 0x00f8 }, + { 0x0013, 0x00f9 }, + { 0x0013, 0x00fa }, + { 0x0013, 0x00fb }, + { 0x0013, 0x00fc }, + { 0x0013, 0x00fd }, + { 0x0013, 0x00fe }, + { 0x0013, 0x00ff }, + { 0x0013, 0x0100 }, + { 0x0013, 0x0101 }, + { 0x0013, 0x0102 }, + { 0x0013, 0x0103 }, + { 0x0013, 0x0104 }, + { 0x0013, 0x0105 }, + { 0x0013, 0x0106 }, + { 0x0013, 0x0107 }, + { 0x0013, 0x0108 }, + { 0x0013, 0x0109 }, + { 0x0013, 0x010a }, + { 0x0013, 0x010b }, + { 0x0013, 0x010c }, + { 0x0013, 0x010d }, + { 0x0013, 0x010e }, + { 0x0013, 0x010f }, + { 0x0013, 0x0110 }, + { 0x0013, 0x0111 }, + { 0x0013, 0x0112 }, + { 0x0013, 0x0113 }, + { 0x0013, 0x0114 }, + { 0x0013, 0x0115 }, + { 0x0013, 0x0116 }, + { 0x0013, 0x0117 }, + { 0x0013, 0x0118 }, + { 0x0013, 0x0119 }, + { 0x0013, 0x011a }, + { 0x0013, 0x011b }, + { 0x0013, 0x011c }, + { 0x0013, 0x011d }, + { 0x0013, 0x011e }, + { 0x0013, 0x011f }, + { 0x0013, 0x0120 }, + { 0x0013, 0x0121 }, + { 0x0013, 0x0122 }, + { 0x0013, 0x0123 }, + { 0x0013, 0x0124 }, + { 0x0013, 0x0125 }, + { 0x0013, 0x0126 }, + { 0x0013, 0x0127 }, + { 0x0013, 0x0128 }, + { 0x0013, 0x0129 }, + { 0x0013, 0x012a }, + { 0x0013, 0x012b }, + { 0x0013, 0x012c }, + { 0x0013, 0x012d }, + { 0x0013, 0x012e }, + { 0x0013, 0x012f }, + { 0x0013, 0x0130 }, + { 0x0013, 0x0131 }, + { 0x0013, 0x0132 }, + { 0x0013, 0x0133 }, + { 0x0013, 0x0134 }, + { 0x0013, 0x0135 }, + { 0x0013, 0x0136 }, + { 0x0013, 0x0137 }, + { 0x0013, 0x0138 }, + { 0x0013, 0x0139 }, + { 0x0013, 0x013a }, + { 0x0013, 0x013b }, + { 0x0013, 0x013c }, + { 0x0013, 0x013d }, + { 0x0013, 0x013e }, + { 0x0013, 0x013f }, + { 0x0013, 0x0140 }, + { 0x0013, 0x0141 }, + { 0x0013, 0x0142 }, + { 0x0013, 0x0143 }, + { 0x0013, 0x0144 }, + { 0x0013, 0x0145 }, + { 0x0013, 0x0146 }, + { 0x0013, 0x0147 }, + { 0x0013, 0x0148 }, + { 0x0013, 0x0149 }, + { 0x0013, 0x014a }, + { 0x0013, 0x014b }, + { 0x0013, 0x014c }, + { 0x0013, 0x014d }, + { 0x0013, 0x014e }, + { 0x0013, 0x014f }, + { 0x0013, 0x0150 }, + { 0x0013, 0x0151 }, + { 0x0013, 0x0152 }, + { 0x0013, 0x0153 }, + { 0x0013, 0x0154 }, + { 0x0013, 0x0155 }, + { 0x0013, 0x0156 }, + { 0x0013, 0x0157 }, + { 0x0013, 0x0158 }, + { 0x0013, 0x0159 }, + { 0x0013, 0x015a }, + { 0x0013, 0x015b }, + { 0x0013, 0x015c }, + { 0x0013, 0x015d }, + { 0x0013, 0x015e }, + { 0x0013, 0x015f }, + { 0x0013, 0x0160 }, + { 0x0013, 0x0161 }, + { 0x0013, 0x0162 }, + { 0x0013, 0x0163 }, + { 0x0013, 0x0164 }, + { 0x0013, 0x0165 }, + { 0x0013, 0x0166 }, + { 0x0013, 0x0167 }, + { 0x0013, 0x0168 }, + { 0x0013, 0x0169 }, + { 0x0013, 0x016a }, + { 0x0013, 0x016b }, + { 0x0013, 0x016c }, + { 0x0013, 0x016d }, + { 0x0013, 0x016e }, + { 0x0013, 0x016f }, + { 0x0013, 0x0170 }, + { 0x0013, 0x0171 }, + { 0x0013, 0x0172 }, + { 0x0013, 0x0173 }, + { 0x0013, 0x0174 }, + { 0x0013, 0x0175 }, + { 0x0013, 0x0176 }, + { 0x0013, 0x0177 }, + { 0x0013, 0x0178 }, + { 0x0013, 0x0179 }, + { 0x0013, 0x017a }, + { 0x0013, 0x017b }, + { 0x0013, 0x017c }, + { 0x0013, 0x017d }, + { 0x0013, 0x017e }, + { 0x0013, 0x017f }, + { 0x0013, 0x0180 }, + { 0x0013, 0x0181 }, + { 0x0013, 0x0182 }, + { 0x0013, 0x0183 }, + { 0x0013, 0x0184 }, + { 0x0013, 0x0185 }, + { 0x0013, 0x0186 }, + { 0x0013, 0x0187 }, + { 0x0013, 0x0188 }, + { 0x0013, 0x0189 }, + { 0x0013, 0x018a }, + { 0x0013, 0x018b }, + { 0x0013, 0x018c }, + { 0x0013, 0x018d }, + { 0x0013, 0x018e }, + { 0x0013, 0x018f }, + { 0x0013, 0x0190 }, + { 0x0013, 0x0191 }, + { 0x0013, 0x0192 }, + { 0x0013, 0x0193 }, + { 0x0013, 0x0194 }, + { 0x0013, 0x0195 }, + { 0x0013, 0x0196 }, + { 0x0013, 0x0197 }, + { 0x0013, 0x0198 }, + { 0x0013, 0x0199 }, + { 0x0013, 0x019a }, + { 0x0013, 0x019b }, + { 0x0013, 0x019c }, + { 0x0013, 0x019d }, + { 0x0013, 0x019e }, + { 0x0013, 0x019f }, + { 0x0013, 0x01a0 }, + { 0x0013, 0x01a1 }, + { 0x0013, 0x01a2 }, + { 0x0013, 0x01a3 }, + { 0x0013, 0x01a4 }, + { 0x0013, 0x01a5 }, + { 0x0013, 0x01a6 }, + { 0x0013, 0x01a7 }, + { 0x0013, 0x01a8 }, + { 0x0013, 0x01a9 }, + { 0x0013, 0x01aa }, + { 0x0013, 0x01ab }, + { 0x0013, 0x01ac }, + { 0x0013, 0x01ad }, + { 0x0013, 0x01ae }, + { 0x0013, 0x01af }, + { 0x0013, 0x01b0 }, + { 0x0013, 0x01b1 }, + { 0x0013, 0x01b2 }, + { 0x0013, 0x01b3 }, + { 0x0013, 0x01b4 }, + { 0x0013, 0x01b5 }, + { 0x0013, 0x01b6 }, + { 0x0013, 0x01b7 }, + { 0x0013, 0x01b8 }, + { 0x0013, 0x01b9 }, + { 0x0013, 0x01ba }, + { 0x0013, 0x01bb }, + { 0x0013, 0x01bc }, + { 0x0013, 0x01bd }, + { 0x0013, 0x01be }, + { 0x0013, 0x01bf }, + { 0x0013, 0x01c0 }, + { 0x0013, 0x01c1 }, + { 0x0013, 0x01c2 }, + { 0x0013, 0x01c3 }, + { 0x0013, 0x01c4 }, + { 0x0013, 0x01c5 }, + { 0x0013, 0x01c6 }, + { 0x0013, 0x01c7 }, + { 0x0013, 0x01c8 }, + { 0x0013, 0x01c9 }, + { 0x0013, 0x01ca }, + { 0x0013, 0x01cb }, + { 0x0013, 0x01cc }, + { 0x0013, 0x01cd }, + { 0x0013, 0x01ce }, + { 0x0013, 0x01cf }, + { 0x0013, 0x01d0 }, + { 0x0013, 0x01d1 }, + { 0x0013, 0x01d2 }, + { 0x0013, 0x01d3 }, + { 0x0013, 0x01d4 }, + { 0x0013, 0x01d5 }, + { 0x0013, 0x01d6 }, + { 0x0013, 0x01d7 }, + { 0x0013, 0x01d8 }, + { 0x0013, 0x01d9 }, + { 0x0013, 0x01da }, + { 0x0013, 0x01db }, + { 0x0013, 0x01dc }, + { 0x0013, 0x01dd }, + { 0x0013, 0x01de }, + { 0x0013, 0x01df }, + { 0x0013, 0x01e0 }, + { 0x0013, 0x01e1 }, + { 0x0013, 0x01e2 }, + { 0x0013, 0x01e3 }, + { 0x0013, 0x01e4 }, + { 0x0013, 0x01e5 }, + { 0x0013, 0x01e6 }, + { 0x0013, 0x01e7 }, + { 0x0013, 0x01e8 }, + { 0x0013, 0x01e9 }, + { 0x0013, 0x01ea }, + { 0x0013, 0x01eb }, + { 0x0012, 0x00fd }, + }; + +const uint16_t c_aauiLCLDHuffEnc48[729][2] = + { + { 0x0002, 0x0003 }, + { 0x0003, 0x0003 }, + { 0x0005, 0x0006 }, + { 0x0006, 0x0006 }, + { 0x0008, 0x0006 }, + { 0x0009, 0x0007 }, + { 0x000b, 0x000b }, + { 0x000c, 0x000d }, + { 0x000f, 0x0030 }, + { 0x0010, 0x0055 }, + { 0x0012, 0x0136 }, + { 0x0013, 0x0000 }, + { 0x0013, 0x0001 }, + { 0x0013, 0x0002 }, + { 0x0013, 0x0003 }, + { 0x0013, 0x0004 }, + { 0x0013, 0x0005 }, + { 0x0013, 0x0006 }, + { 0x0013, 0x0007 }, + { 0x0013, 0x0008 }, + { 0x0013, 0x0009 }, + { 0x0013, 0x000a }, + { 0x0013, 0x000b }, + { 0x0013, 0x000c }, + { 0x0013, 0x000d }, + { 0x0013, 0x000e }, + { 0x0013, 0x000f }, + { 0x0003, 0x0004 }, + { 0x0003, 0x0005 }, + { 0x0005, 0x0007 }, + { 0x0006, 0x0007 }, + { 0x0007, 0x0007 }, + { 0x0008, 0x0007 }, + { 0x000a, 0x0008 }, + { 0x000c, 0x000e }, + { 0x000d, 0x0012 }, + { 0x000f, 0x0031 }, + { 0x0011, 0x00a0 }, + { 0x0013, 0x0010 }, + { 0x0013, 0x0011 }, + { 0x0013, 0x0012 }, + { 0x0013, 0x0013 }, + { 0x0013, 0x0014 }, + { 0x0013, 0x0015 }, + { 0x0013, 0x0016 }, + { 0x0013, 0x0017 }, + { 0x0013, 0x0018 }, + { 0x0013, 0x0019 }, + { 0x0013, 0x001a }, + { 0x0013, 0x001b }, + { 0x0013, 0x001c }, + { 0x0013, 0x001d }, + { 0x0013, 0x001e }, + { 0x0013, 0x001f }, + { 0x0005, 0x0008 }, + { 0x0004, 0x0005 }, + { 0x0005, 0x0009 }, + { 0x0006, 0x0008 }, + { 0x0007, 0x0008 }, + { 0x0008, 0x0008 }, + { 0x000a, 0x0009 }, + { 0x000c, 0x000f }, + { 0x000d, 0x0013 }, + { 0x000f, 0x0032 }, + { 0x0011, 0x00a1 }, + { 0x0013, 0x0020 }, + { 0x0013, 0x0021 }, + { 0x0013, 0x0022 }, + { 0x0013, 0x0023 }, + { 0x0013, 0x0024 }, + { 0x0013, 0x0025 }, + { 0x0013, 0x0026 }, + { 0x0013, 0x0027 }, + { 0x0013, 0x0028 }, + { 0x0013, 0x0029 }, + { 0x0013, 0x002a }, + { 0x0013, 0x002b }, + { 0x0013, 0x002c }, + { 0x0013, 0x002d }, + { 0x0013, 0x002e }, + { 0x0013, 0x002f }, + { 0x0006, 0x0009 }, + { 0x0006, 0x000a }, + { 0x0006, 0x000b }, + { 0x0007, 0x0009 }, + { 0x0008, 0x0009 }, + { 0x0009, 0x0008 }, + { 0x000b, 0x000c }, + { 0x000d, 0x0014 }, + { 0x000e, 0x001d }, + { 0x000f, 0x0033 }, + { 0x0012, 0x0137 }, + { 0x0013, 0x0030 }, + { 0x0013, 0x0031 }, + { 0x0013, 0x0032 }, + { 0x0013, 0x0033 }, + { 0x0013, 0x0034 }, + { 0x0013, 0x0035 }, + { 0x0013, 0x0036 }, + { 0x0013, 0x0037 }, + { 0x0013, 0x0038 }, + { 0x0013, 0x0039 }, + { 0x0013, 0x003a }, + { 0x0013, 0x003b }, + { 0x0013, 0x003c }, + { 0x0013, 0x003d }, + { 0x0013, 0x003e }, + { 0x0013, 0x003f }, + { 0x0008, 0x000a }, + { 0x0007, 0x000a }, + { 0x0007, 0x000b }, + { 0x0008, 0x000b }, + { 0x0009, 0x0009 }, + { 0x000a, 0x000a }, + { 0x000c, 0x0010 }, + { 0x000d, 0x0015 }, + { 0x000f, 0x0034 }, + { 0x0010, 0x0056 }, + { 0x0012, 0x0138 }, + { 0x0013, 0x0040 }, + { 0x0013, 0x0041 }, + { 0x0013, 0x0042 }, + { 0x0013, 0x0043 }, + { 0x0013, 0x0044 }, + { 0x0013, 0x0045 }, + { 0x0013, 0x0046 }, + { 0x0013, 0x0047 }, + { 0x0013, 0x0048 }, + { 0x0013, 0x0049 }, + { 0x0013, 0x004a }, + { 0x0013, 0x004b }, + { 0x0013, 0x004c }, + { 0x0013, 0x004d }, + { 0x0013, 0x004e }, + { 0x0013, 0x004f }, + { 0x0009, 0x000a }, + { 0x0008, 0x000c }, + { 0x0008, 0x000d }, + { 0x0009, 0x000b }, + { 0x000a, 0x000b }, + { 0x000c, 0x0011 }, + { 0x000d, 0x0016 }, + { 0x000e, 0x001e }, + { 0x0010, 0x0057 }, + { 0x0011, 0x00a2 }, + { 0x0011, 0x00a3 }, + { 0x0013, 0x0050 }, + { 0x0013, 0x0051 }, + { 0x0013, 0x0052 }, + { 0x0013, 0x0053 }, + { 0x0013, 0x0054 }, + { 0x0013, 0x0055 }, + { 0x0013, 0x0056 }, + { 0x0013, 0x0057 }, + { 0x0013, 0x0058 }, + { 0x0013, 0x0059 }, + { 0x0013, 0x005a }, + { 0x0013, 0x005b }, + { 0x0013, 0x005c }, + { 0x0013, 0x005d }, + { 0x0013, 0x005e }, + { 0x0013, 0x005f }, + { 0x000b, 0x000d }, + { 0x000a, 0x000c }, + { 0x000a, 0x000d }, + { 0x000b, 0x000e }, + { 0x000c, 0x0012 }, + { 0x000d, 0x0017 }, + { 0x000e, 0x001f }, + { 0x0010, 0x0058 }, + { 0x0012, 0x0139 }, + { 0x0011, 0x00a4 }, + { 0x0012, 0x013a }, + { 0x0013, 0x0060 }, + { 0x0013, 0x0061 }, + { 0x0013, 0x0062 }, + { 0x0013, 0x0063 }, + { 0x0013, 0x0064 }, + { 0x0013, 0x0065 }, + { 0x0013, 0x0066 }, + { 0x0013, 0x0067 }, + { 0x0013, 0x0068 }, + { 0x0013, 0x0069 }, + { 0x0013, 0x006a }, + { 0x0013, 0x006b }, + { 0x0013, 0x006c }, + { 0x0013, 0x006d }, + { 0x0013, 0x006e }, + { 0x0013, 0x006f }, + { 0x000c, 0x0013 }, + { 0x000b, 0x000f }, + { 0x000c, 0x0014 }, + { 0x000c, 0x0015 }, + { 0x000d, 0x0018 }, + { 0x000e, 0x0020 }, + { 0x000f, 0x0035 }, + { 0x0012, 0x013b }, + { 0x0013, 0x0070 }, + { 0x0013, 0x0071 }, + { 0x0013, 0x0072 }, + { 0x0013, 0x0073 }, + { 0x0013, 0x0074 }, + { 0x0013, 0x0075 }, + { 0x0013, 0x0076 }, + { 0x0013, 0x0077 }, + { 0x0013, 0x0078 }, + { 0x0013, 0x0079 }, + { 0x0013, 0x007a }, + { 0x0013, 0x007b }, + { 0x0013, 0x007c }, + { 0x0013, 0x007d }, + { 0x0013, 0x007e }, + { 0x0013, 0x007f }, + { 0x0013, 0x0080 }, + { 0x0013, 0x0081 }, + { 0x0013, 0x0082 }, + { 0x000e, 0x0021 }, + { 0x000d, 0x0019 }, + { 0x000e, 0x0022 }, + { 0x000e, 0x0023 }, + { 0x000f, 0x0036 }, + { 0x0010, 0x0059 }, + { 0x0011, 0x00a5 }, + { 0x0013, 0x0083 }, + { 0x0011, 0x00a6 }, + { 0x0012, 0x013c }, + { 0x0013, 0x0084 }, + { 0x0013, 0x0085 }, + { 0x0013, 0x0086 }, + { 0x0013, 0x0087 }, + { 0x0013, 0x0088 }, + { 0x0013, 0x0089 }, + { 0x0013, 0x008a }, + { 0x0013, 0x008b }, + { 0x0013, 0x008c }, + { 0x0013, 0x008d }, + { 0x0013, 0x008e }, + { 0x0013, 0x008f }, + { 0x0013, 0x0090 }, + { 0x0013, 0x0091 }, + { 0x0013, 0x0092 }, + { 0x0013, 0x0093 }, + { 0x0013, 0x0094 }, + { 0x0010, 0x005a }, + { 0x000f, 0x0037 }, + { 0x000f, 0x0038 }, + { 0x000f, 0x0039 }, + { 0x0010, 0x005b }, + { 0x0010, 0x005c }, + { 0x0013, 0x0095 }, + { 0x0011, 0x00a7 }, + { 0x0013, 0x0096 }, + { 0x0013, 0x0097 }, + { 0x0013, 0x0098 }, + { 0x0013, 0x0099 }, + { 0x0013, 0x009a }, + { 0x0013, 0x009b }, + { 0x0013, 0x009c }, + { 0x0013, 0x009d }, + { 0x0013, 0x009e }, + { 0x0013, 0x009f }, + { 0x0013, 0x00a0 }, + { 0x0013, 0x00a1 }, + { 0x0013, 0x00a2 }, + { 0x0013, 0x00a3 }, + { 0x0013, 0x00a4 }, + { 0x0013, 0x00a5 }, + { 0x0013, 0x00a6 }, + { 0x0013, 0x00a7 }, + { 0x0013, 0x00a8 }, + { 0x0010, 0x005d }, + { 0x0010, 0x005e }, + { 0x0013, 0x00a9 }, + { 0x0010, 0x005f }, + { 0x0013, 0x00aa }, + { 0x0012, 0x013d }, + { 0x0013, 0x00ab }, + { 0x0013, 0x00ac }, + { 0x0013, 0x00ad }, + { 0x0013, 0x00ae }, + { 0x0013, 0x00af }, + { 0x0013, 0x00b0 }, + { 0x0013, 0x00b1 }, + { 0x0013, 0x00b2 }, + { 0x0013, 0x00b3 }, + { 0x0013, 0x00b4 }, + { 0x0013, 0x00b5 }, + { 0x0013, 0x00b6 }, + { 0x0013, 0x00b7 }, + { 0x0013, 0x00b8 }, + { 0x0013, 0x00b9 }, + { 0x0013, 0x00ba }, + { 0x0013, 0x00bb }, + { 0x0013, 0x00bc }, + { 0x0013, 0x00bd }, + { 0x0013, 0x00be }, + { 0x0013, 0x00bf }, + { 0x0013, 0x00c0 }, + { 0x0011, 0x00a8 }, + { 0x0013, 0x00c1 }, + { 0x0011, 0x00a9 }, + { 0x0013, 0x00c2 }, + { 0x0013, 0x00c3 }, + { 0x0013, 0x00c4 }, + { 0x0013, 0x00c5 }, + { 0x0013, 0x00c6 }, + { 0x0013, 0x00c7 }, + { 0x0013, 0x00c8 }, + { 0x0013, 0x00c9 }, + { 0x0013, 0x00ca }, + { 0x0013, 0x00cb }, + { 0x0013, 0x00cc }, + { 0x0013, 0x00cd }, + { 0x0013, 0x00ce }, + { 0x0013, 0x00cf }, + { 0x0013, 0x00d0 }, + { 0x0013, 0x00d1 }, + { 0x0013, 0x00d2 }, + { 0x0013, 0x00d3 }, + { 0x0013, 0x00d4 }, + { 0x0013, 0x00d5 }, + { 0x0013, 0x00d6 }, + { 0x0013, 0x00d7 }, + { 0x0013, 0x00d8 }, + { 0x0013, 0x00d9 }, + { 0x0013, 0x00da }, + { 0x0012, 0x013e }, + { 0x0013, 0x00db }, + { 0x0013, 0x00dc }, + { 0x0013, 0x00dd }, + { 0x0013, 0x00de }, + { 0x0013, 0x00df }, + { 0x0013, 0x00e0 }, + { 0x0013, 0x00e1 }, + { 0x0013, 0x00e2 }, + { 0x0013, 0x00e3 }, + { 0x0013, 0x00e4 }, + { 0x0013, 0x00e5 }, + { 0x0013, 0x00e6 }, + { 0x0013, 0x00e7 }, + { 0x0013, 0x00e8 }, + { 0x0013, 0x00e9 }, + { 0x0013, 0x00ea }, + { 0x0013, 0x00eb }, + { 0x0013, 0x00ec }, + { 0x0013, 0x00ed }, + { 0x0013, 0x00ee }, + { 0x0013, 0x00ef }, + { 0x0013, 0x00f0 }, + { 0x0013, 0x00f1 }, + { 0x0013, 0x00f2 }, + { 0x0013, 0x00f3 }, + { 0x0013, 0x00f4 }, + { 0x0013, 0x00f5 }, + { 0x0013, 0x00f6 }, + { 0x0013, 0x00f7 }, + { 0x0013, 0x00f8 }, + { 0x0013, 0x00f9 }, + { 0x0013, 0x00fa }, + { 0x0013, 0x00fb }, + { 0x0013, 0x00fc }, + { 0x0013, 0x00fd }, + { 0x0013, 0x00fe }, + { 0x0013, 0x00ff }, + { 0x0013, 0x0100 }, + { 0x0013, 0x0101 }, + { 0x0013, 0x0102 }, + { 0x0013, 0x0103 }, + { 0x0013, 0x0104 }, + { 0x0013, 0x0105 }, + { 0x0013, 0x0106 }, + { 0x0013, 0x0107 }, + { 0x0013, 0x0108 }, + { 0x0013, 0x0109 }, + { 0x0013, 0x010a }, + { 0x0013, 0x010b }, + { 0x0013, 0x010c }, + { 0x0013, 0x010d }, + { 0x0013, 0x010e }, + { 0x0013, 0x010f }, + { 0x0013, 0x0110 }, + { 0x0013, 0x0111 }, + { 0x0013, 0x0112 }, + { 0x0013, 0x0113 }, + { 0x0013, 0x0114 }, + { 0x0013, 0x0115 }, + { 0x0013, 0x0116 }, + { 0x0013, 0x0117 }, + { 0x0013, 0x0118 }, + { 0x0013, 0x0119 }, + { 0x0013, 0x011a }, + { 0x0013, 0x011b }, + { 0x0013, 0x011c }, + { 0x0013, 0x011d }, + { 0x0013, 0x011e }, + { 0x0013, 0x011f }, + { 0x0013, 0x0120 }, + { 0x0013, 0x0121 }, + { 0x0013, 0x0122 }, + { 0x0013, 0x0123 }, + { 0x0013, 0x0124 }, + { 0x0013, 0x0125 }, + { 0x0013, 0x0126 }, + { 0x0013, 0x0127 }, + { 0x0013, 0x0128 }, + { 0x0013, 0x0129 }, + { 0x0013, 0x012a }, + { 0x0013, 0x012b }, + { 0x0013, 0x012c }, + { 0x0013, 0x012d }, + { 0x0013, 0x012e }, + { 0x0013, 0x012f }, + { 0x0013, 0x0130 }, + { 0x0013, 0x0131 }, + { 0x0013, 0x0132 }, + { 0x0013, 0x0133 }, + { 0x0013, 0x0134 }, + { 0x0013, 0x0135 }, + { 0x0013, 0x0136 }, + { 0x0013, 0x0137 }, + { 0x0013, 0x0138 }, + { 0x0013, 0x0139 }, + { 0x0013, 0x013a }, + { 0x0013, 0x013b }, + { 0x0013, 0x013c }, + { 0x0013, 0x013d }, + { 0x0013, 0x013e }, + { 0x0013, 0x013f }, + { 0x0013, 0x0140 }, + { 0x0013, 0x0141 }, + { 0x0013, 0x0142 }, + { 0x0013, 0x0143 }, + { 0x0013, 0x0144 }, + { 0x0013, 0x0145 }, + { 0x0013, 0x0146 }, + { 0x0013, 0x0147 }, + { 0x0013, 0x0148 }, + { 0x0013, 0x0149 }, + { 0x0013, 0x014a }, + { 0x0013, 0x014b }, + { 0x0013, 0x014c }, + { 0x0013, 0x014d }, + { 0x0013, 0x014e }, + { 0x0013, 0x014f }, + { 0x0013, 0x0150 }, + { 0x0013, 0x0151 }, + { 0x0013, 0x0152 }, + { 0x0013, 0x0153 }, + { 0x0013, 0x0154 }, + { 0x0013, 0x0155 }, + { 0x0013, 0x0156 }, + { 0x0013, 0x0157 }, + { 0x0013, 0x0158 }, + { 0x0013, 0x0159 }, + { 0x0013, 0x015a }, + { 0x0013, 0x015b }, + { 0x0013, 0x015c }, + { 0x0013, 0x015d }, + { 0x0013, 0x015e }, + { 0x0013, 0x015f }, + { 0x0013, 0x0160 }, + { 0x0013, 0x0161 }, + { 0x0013, 0x0162 }, + { 0x0013, 0x0163 }, + { 0x0013, 0x0164 }, + { 0x0013, 0x0165 }, + { 0x0013, 0x0166 }, + { 0x0013, 0x0167 }, + { 0x0013, 0x0168 }, + { 0x0013, 0x0169 }, + { 0x0013, 0x016a }, + { 0x0013, 0x016b }, + { 0x0013, 0x016c }, + { 0x0013, 0x016d }, + { 0x0013, 0x016e }, + { 0x0013, 0x016f }, + { 0x0013, 0x0170 }, + { 0x0013, 0x0171 }, + { 0x0013, 0x0172 }, + { 0x0013, 0x0173 }, + { 0x0013, 0x0174 }, + { 0x0013, 0x0175 }, + { 0x0013, 0x0176 }, + { 0x0013, 0x0177 }, + { 0x0013, 0x0178 }, + { 0x0013, 0x0179 }, + { 0x0013, 0x017a }, + { 0x0013, 0x017b }, + { 0x0013, 0x017c }, + { 0x0013, 0x017d }, + { 0x0013, 0x017e }, + { 0x0013, 0x017f }, + { 0x0013, 0x0180 }, + { 0x0013, 0x0181 }, + { 0x0013, 0x0182 }, + { 0x0013, 0x0183 }, + { 0x0013, 0x0184 }, + { 0x0013, 0x0185 }, + { 0x0013, 0x0186 }, + { 0x0013, 0x0187 }, + { 0x0013, 0x0188 }, + { 0x0013, 0x0189 }, + { 0x0013, 0x018a }, + { 0x0013, 0x018b }, + { 0x0013, 0x018c }, + { 0x0013, 0x018d }, + { 0x0013, 0x018e }, + { 0x0013, 0x018f }, + { 0x0013, 0x0190 }, + { 0x0013, 0x0191 }, + { 0x0013, 0x0192 }, + { 0x0013, 0x0193 }, + { 0x0013, 0x0194 }, + { 0x0013, 0x0195 }, + { 0x0013, 0x0196 }, + { 0x0013, 0x0197 }, + { 0x0013, 0x0198 }, + { 0x0013, 0x0199 }, + { 0x0013, 0x019a }, + { 0x0013, 0x019b }, + { 0x0013, 0x019c }, + { 0x0013, 0x019d }, + { 0x0013, 0x019e }, + { 0x0013, 0x019f }, + { 0x0013, 0x01a0 }, + { 0x0013, 0x01a1 }, + { 0x0013, 0x01a2 }, + { 0x0013, 0x01a3 }, + { 0x0013, 0x01a4 }, + { 0x0013, 0x01a5 }, + { 0x0013, 0x01a6 }, + { 0x0013, 0x01a7 }, + { 0x0013, 0x01a8 }, + { 0x0013, 0x01a9 }, + { 0x0013, 0x01aa }, + { 0x0013, 0x01ab }, + { 0x0013, 0x01ac }, + { 0x0013, 0x01ad }, + { 0x0013, 0x01ae }, + { 0x0013, 0x01af }, + { 0x0013, 0x01b0 }, + { 0x0013, 0x01b1 }, + { 0x0013, 0x01b2 }, + { 0x0013, 0x01b3 }, + { 0x0013, 0x01b4 }, + { 0x0013, 0x01b5 }, + { 0x0013, 0x01b6 }, + { 0x0013, 0x01b7 }, + { 0x0013, 0x01b8 }, + { 0x0013, 0x01b9 }, + { 0x0013, 0x01ba }, + { 0x0013, 0x01bb }, + { 0x0013, 0x01bc }, + { 0x0013, 0x01bd }, + { 0x0013, 0x01be }, + { 0x0013, 0x01bf }, + { 0x0013, 0x01c0 }, + { 0x0013, 0x01c1 }, + { 0x0013, 0x01c2 }, + { 0x0013, 0x01c3 }, + { 0x0013, 0x01c4 }, + { 0x0013, 0x01c5 }, + { 0x0013, 0x01c6 }, + { 0x0013, 0x01c7 }, + { 0x0013, 0x01c8 }, + { 0x0013, 0x01c9 }, + { 0x0013, 0x01ca }, + { 0x0013, 0x01cb }, + { 0x0013, 0x01cc }, + { 0x0013, 0x01cd }, + { 0x0013, 0x01ce }, + { 0x0013, 0x01cf }, + { 0x0013, 0x01d0 }, + { 0x0013, 0x01d1 }, + { 0x0013, 0x01d2 }, + { 0x0013, 0x01d3 }, + { 0x0013, 0x01d4 }, + { 0x0013, 0x01d5 }, + { 0x0013, 0x01d6 }, + { 0x0013, 0x01d7 }, + { 0x0013, 0x01d8 }, + { 0x0013, 0x01d9 }, + { 0x0013, 0x01da }, + { 0x0013, 0x01db }, + { 0x0013, 0x01dc }, + { 0x0013, 0x01dd }, + { 0x0013, 0x01de }, + { 0x0013, 0x01df }, + { 0x0013, 0x01e0 }, + { 0x0013, 0x01e1 }, + { 0x0013, 0x01e2 }, + { 0x0013, 0x01e3 }, + { 0x0013, 0x01e4 }, + { 0x0013, 0x01e5 }, + { 0x0013, 0x01e6 }, + { 0x0013, 0x01e7 }, + { 0x0013, 0x01e8 }, + { 0x0013, 0x01e9 }, + { 0x0013, 0x01ea }, + { 0x0013, 0x01eb }, + { 0x0013, 0x01ec }, + { 0x0013, 0x01ed }, + { 0x0013, 0x01ee }, + { 0x0013, 0x01ef }, + { 0x0013, 0x01f0 }, + { 0x0013, 0x01f1 }, + { 0x0013, 0x01f2 }, + { 0x0013, 0x01f3 }, + { 0x0013, 0x01f4 }, + { 0x0013, 0x01f5 }, + { 0x0013, 0x01f6 }, + { 0x0013, 0x01f7 }, + { 0x0013, 0x01f8 }, + { 0x0013, 0x01f9 }, + { 0x0013, 0x01fa }, + { 0x0013, 0x01fb }, + { 0x0013, 0x01fc }, + { 0x0013, 0x01fd }, + { 0x0013, 0x01fe }, + { 0x0013, 0x01ff }, + { 0x0013, 0x0200 }, + { 0x0013, 0x0201 }, + { 0x0013, 0x0202 }, + { 0x0013, 0x0203 }, + { 0x0013, 0x0204 }, + { 0x0013, 0x0205 }, + { 0x0013, 0x0206 }, + { 0x0013, 0x0207 }, + { 0x0013, 0x0208 }, + { 0x0013, 0x0209 }, + { 0x0013, 0x020a }, + { 0x0013, 0x020b }, + { 0x0013, 0x020c }, + { 0x0013, 0x020d }, + { 0x0013, 0x020e }, + { 0x0013, 0x020f }, + { 0x0013, 0x0210 }, + { 0x0013, 0x0211 }, + { 0x0013, 0x0212 }, + { 0x0013, 0x0213 }, + { 0x0013, 0x0214 }, + { 0x0013, 0x0215 }, + { 0x0013, 0x0216 }, + { 0x0013, 0x0217 }, + { 0x0013, 0x0218 }, + { 0x0013, 0x0219 }, + { 0x0013, 0x021a }, + { 0x0013, 0x021b }, + { 0x0013, 0x021c }, + { 0x0013, 0x021d }, + { 0x0013, 0x021e }, + { 0x0013, 0x021f }, + { 0x0013, 0x0220 }, + { 0x0013, 0x0221 }, + { 0x0013, 0x0222 }, + { 0x0013, 0x0223 }, + { 0x0013, 0x0224 }, + { 0x0013, 0x0225 }, + { 0x0013, 0x0226 }, + { 0x0013, 0x0227 }, + { 0x0013, 0x0228 }, + { 0x0013, 0x0229 }, + { 0x0013, 0x022a }, + { 0x0013, 0x022b }, + { 0x0013, 0x022c }, + { 0x0013, 0x022d }, + { 0x0013, 0x022e }, + { 0x0013, 0x022f }, + { 0x0013, 0x0230 }, + { 0x0013, 0x0231 }, + { 0x0013, 0x0232 }, + { 0x0013, 0x0233 }, + { 0x0013, 0x0234 }, + { 0x0013, 0x0235 }, + { 0x0013, 0x0236 }, + { 0x0013, 0x0237 }, + { 0x0013, 0x0238 }, + { 0x0013, 0x0239 }, + { 0x0013, 0x023a }, + { 0x0013, 0x023b }, + { 0x0013, 0x023c }, + { 0x0013, 0x023d }, + { 0x0013, 0x023e }, + { 0x0013, 0x023f }, + { 0x0013, 0x0240 }, + { 0x0013, 0x0241 }, + { 0x0013, 0x0242 }, + { 0x0013, 0x0243 }, + { 0x0013, 0x0244 }, + { 0x0013, 0x0245 }, + { 0x0013, 0x0246 }, + { 0x0013, 0x0247 }, + { 0x0013, 0x0248 }, + { 0x0013, 0x0249 }, + { 0x0013, 0x024a }, + { 0x0013, 0x024b }, + { 0x0013, 0x024c }, + { 0x0013, 0x024d }, + { 0x0013, 0x024e }, + { 0x0013, 0x024f }, + { 0x0013, 0x0250 }, + { 0x0013, 0x0251 }, + { 0x0013, 0x0252 }, + { 0x0013, 0x0253 }, + { 0x0013, 0x0254 }, + { 0x0013, 0x0255 }, + { 0x0013, 0x0256 }, + { 0x0013, 0x0257 }, + { 0x0013, 0x0258 }, + { 0x0013, 0x0259 }, + { 0x0013, 0x025a }, + { 0x0013, 0x025b }, + { 0x0013, 0x025c }, + { 0x0013, 0x025d }, + { 0x0013, 0x025e }, + { 0x0013, 0x025f }, + { 0x0013, 0x0260 }, + { 0x0013, 0x0261 }, + { 0x0013, 0x0262 }, + { 0x0013, 0x0263 }, + { 0x0013, 0x0264 }, + { 0x0013, 0x0265 }, + { 0x0013, 0x0266 }, + { 0x0013, 0x0267 }, + { 0x0013, 0x0268 }, + { 0x0013, 0x0269 }, + { 0x0013, 0x026a }, + { 0x0013, 0x026b }, + { 0x0012, 0x013f }, + + }; + +const uint16_t c_aauiLCLDHuffEnc49[729][2] = + { + { 0x0002, 0x0003 }, + { 0x0003, 0x0003 }, + { 0x0005, 0x0007 }, + { 0x0007, 0x000a }, + { 0x0008, 0x0009 }, + { 0x0008, 0x000a }, + { 0x0009, 0x0009 }, + { 0x000b, 0x000d }, + { 0x000d, 0x0014 }, + { 0x000d, 0x0015 }, + { 0x0010, 0x0052 }, + { 0x0011, 0x0098 }, + { 0x0013, 0x0000 }, + { 0x0013, 0x0001 }, + { 0x0013, 0x0002 }, + { 0x0013, 0x0003 }, + { 0x0013, 0x0004 }, + { 0x0013, 0x0005 }, + { 0x0013, 0x0006 }, + { 0x0013, 0x0007 }, + { 0x0013, 0x0008 }, + { 0x0013, 0x0009 }, + { 0x0013, 0x000a }, + { 0x0013, 0x000b }, + { 0x0013, 0x000c }, + { 0x0013, 0x000d }, + { 0x0013, 0x000e }, + { 0x0003, 0x0004 }, + { 0x0003, 0x0005 }, + { 0x0005, 0x0008 }, + { 0x0006, 0x000a }, + { 0x0007, 0x000b }, + { 0x0008, 0x000b }, + { 0x0008, 0x000c }, + { 0x000a, 0x000a }, + { 0x000b, 0x000e }, + { 0x000d, 0x0016 }, + { 0x000f, 0x0031 }, + { 0x0010, 0x0053 }, + { 0x0012, 0x012a }, + { 0x0013, 0x000f }, + { 0x0013, 0x0010 }, + { 0x0013, 0x0011 }, + { 0x0013, 0x0012 }, + { 0x0013, 0x0013 }, + { 0x0013, 0x0014 }, + { 0x0013, 0x0015 }, + { 0x0013, 0x0016 }, + { 0x0013, 0x0017 }, + { 0x0013, 0x0018 }, + { 0x0013, 0x0019 }, + { 0x0013, 0x001a }, + { 0x0013, 0x001b }, + { 0x0013, 0x001c }, + { 0x0005, 0x0009 }, + { 0x0005, 0x000a }, + { 0x0005, 0x000b }, + { 0x0006, 0x000b }, + { 0x0007, 0x000c }, + { 0x0008, 0x000d }, + { 0x0009, 0x000a }, + { 0x000a, 0x000b }, + { 0x000c, 0x000f }, + { 0x000d, 0x0017 }, + { 0x000f, 0x0032 }, + { 0x0010, 0x0054 }, + { 0x0013, 0x001d }, + { 0x0013, 0x001e }, + { 0x0013, 0x001f }, + { 0x0013, 0x0020 }, + { 0x0013, 0x0021 }, + { 0x0013, 0x0022 }, + { 0x0013, 0x0023 }, + { 0x0013, 0x0024 }, + { 0x0013, 0x0025 }, + { 0x0013, 0x0026 }, + { 0x0013, 0x0027 }, + { 0x0013, 0x0028 }, + { 0x0013, 0x0029 }, + { 0x0013, 0x002a }, + { 0x0013, 0x002b }, + { 0x0007, 0x000d }, + { 0x0006, 0x000c }, + { 0x0006, 0x000d }, + { 0x0007, 0x000e }, + { 0x0007, 0x000f }, + { 0x0008, 0x000e }, + { 0x0009, 0x000b }, + { 0x000b, 0x000f }, + { 0x000c, 0x0010 }, + { 0x000e, 0x001d }, + { 0x000f, 0x0033 }, + { 0x0011, 0x0099 }, + { 0x0013, 0x002c }, + { 0x0013, 0x002d }, + { 0x0013, 0x002e }, + { 0x0013, 0x002f }, + { 0x0013, 0x0030 }, + { 0x0013, 0x0031 }, + { 0x0013, 0x0032 }, + { 0x0013, 0x0033 }, + { 0x0013, 0x0034 }, + { 0x0013, 0x0035 }, + { 0x0013, 0x0036 }, + { 0x0013, 0x0037 }, + { 0x0013, 0x0038 }, + { 0x0013, 0x0039 }, + { 0x0013, 0x003a }, + { 0x0008, 0x000f }, + { 0x0007, 0x0010 }, + { 0x0007, 0x0011 }, + { 0x0007, 0x0012 }, + { 0x0008, 0x0010 }, + { 0x0009, 0x000c }, + { 0x000a, 0x000c }, + { 0x000c, 0x0011 }, + { 0x000d, 0x0018 }, + { 0x000e, 0x001e }, + { 0x0011, 0x009a }, + { 0x0011, 0x009b }, + { 0x0013, 0x003b }, + { 0x0013, 0x003c }, + { 0x0013, 0x003d }, + { 0x0013, 0x003e }, + { 0x0013, 0x003f }, + { 0x0013, 0x0040 }, + { 0x0013, 0x0041 }, + { 0x0013, 0x0042 }, + { 0x0013, 0x0043 }, + { 0x0013, 0x0044 }, + { 0x0013, 0x0045 }, + { 0x0013, 0x0046 }, + { 0x0013, 0x0047 }, + { 0x0013, 0x0048 }, + { 0x0013, 0x0049 }, + { 0x0008, 0x0011 }, + { 0x0007, 0x0013 }, + { 0x0008, 0x0012 }, + { 0x0008, 0x0013 }, + { 0x0009, 0x000d }, + { 0x000a, 0x000d }, + { 0x000b, 0x0010 }, + { 0x000c, 0x0012 }, + { 0x000e, 0x001f }, + { 0x000e, 0x0020 }, + { 0x0010, 0x0055 }, + { 0x0011, 0x009c }, + { 0x0013, 0x004a }, + { 0x0013, 0x004b }, + { 0x0013, 0x004c }, + { 0x0013, 0x004d }, + { 0x0013, 0x004e }, + { 0x0013, 0x004f }, + { 0x0013, 0x0050 }, + { 0x0013, 0x0051 }, + { 0x0013, 0x0052 }, + { 0x0013, 0x0053 }, + { 0x0013, 0x0054 }, + { 0x0013, 0x0055 }, + { 0x0013, 0x0056 }, + { 0x0013, 0x0057 }, + { 0x0013, 0x0058 }, + { 0x0009, 0x000e }, + { 0x0009, 0x000f }, + { 0x0009, 0x0010 }, + { 0x0009, 0x0011 }, + { 0x000a, 0x000e }, + { 0x000b, 0x0011 }, + { 0x000c, 0x0013 }, + { 0x000d, 0x0019 }, + { 0x000e, 0x0021 }, + { 0x0010, 0x0056 }, + { 0x0010, 0x0057 }, + { 0x0013, 0x0059 }, + { 0x0013, 0x005a }, + { 0x0013, 0x005b }, + { 0x0013, 0x005c }, + { 0x0013, 0x005d }, + { 0x0013, 0x005e }, + { 0x0013, 0x005f }, + { 0x0013, 0x0060 }, + { 0x0013, 0x0061 }, + { 0x0013, 0x0062 }, + { 0x0013, 0x0063 }, + { 0x0013, 0x0064 }, + { 0x0013, 0x0065 }, + { 0x0013, 0x0066 }, + { 0x0013, 0x0067 }, + { 0x0013, 0x0068 }, + { 0x000b, 0x0012 }, + { 0x000a, 0x000f }, + { 0x000a, 0x0010 }, + { 0x000a, 0x0011 }, + { 0x000c, 0x0014 }, + { 0x000c, 0x0015 }, + { 0x000d, 0x001a }, + { 0x000e, 0x0022 }, + { 0x0010, 0x0058 }, + { 0x0010, 0x0059 }, + { 0x0013, 0x0069 }, + { 0x0013, 0x006a }, + { 0x0013, 0x006b }, + { 0x0013, 0x006c }, + { 0x0013, 0x006d }, + { 0x0013, 0x006e }, + { 0x0013, 0x006f }, + { 0x0013, 0x0070 }, + { 0x0013, 0x0071 }, + { 0x0013, 0x0072 }, + { 0x0013, 0x0073 }, + { 0x0013, 0x0074 }, + { 0x0013, 0x0075 }, + { 0x0013, 0x0076 }, + { 0x0013, 0x0077 }, + { 0x0013, 0x0078 }, + { 0x0013, 0x0079 }, + { 0x000c, 0x0016 }, + { 0x000b, 0x0013 }, + { 0x000c, 0x0017 }, + { 0x000c, 0x0018 }, + { 0x000c, 0x0019 }, + { 0x000e, 0x0023 }, + { 0x000e, 0x0024 }, + { 0x000f, 0x0034 }, + { 0x0010, 0x005a }, + { 0x0011, 0x009d }, + { 0x0013, 0x007a }, + { 0x0013, 0x007b }, + { 0x0013, 0x007c }, + { 0x0013, 0x007d }, + { 0x0013, 0x007e }, + { 0x0013, 0x007f }, + { 0x0013, 0x0080 }, + { 0x0013, 0x0081 }, + { 0x0013, 0x0082 }, + { 0x0013, 0x0083 }, + { 0x0013, 0x0084 }, + { 0x0013, 0x0085 }, + { 0x0013, 0x0086 }, + { 0x0013, 0x0087 }, + { 0x0013, 0x0088 }, + { 0x0013, 0x0089 }, + { 0x0013, 0x008a }, + { 0x000e, 0x0025 }, + { 0x000d, 0x001b }, + { 0x000d, 0x001c }, + { 0x000d, 0x001d }, + { 0x000e, 0x0026 }, + { 0x000f, 0x0035 }, + { 0x0010, 0x005b }, + { 0x0011, 0x009e }, + { 0x0011, 0x009f }, + { 0x0012, 0x012b }, + { 0x0013, 0x008b }, + { 0x0013, 0x008c }, + { 0x0013, 0x008d }, + { 0x0013, 0x008e }, + { 0x0013, 0x008f }, + { 0x0013, 0x0090 }, + { 0x0013, 0x0091 }, + { 0x0013, 0x0092 }, + { 0x0013, 0x0093 }, + { 0x0013, 0x0094 }, + { 0x0013, 0x0095 }, + { 0x0013, 0x0096 }, + { 0x0013, 0x0097 }, + { 0x0013, 0x0098 }, + { 0x0013, 0x0099 }, + { 0x0013, 0x009a }, + { 0x0013, 0x009b }, + { 0x0010, 0x005c }, + { 0x000f, 0x0036 }, + { 0x000e, 0x0027 }, + { 0x000f, 0x0037 }, + { 0x000f, 0x0038 }, + { 0x0010, 0x005d }, + { 0x0011, 0x00a0 }, + { 0x0013, 0x009c }, + { 0x0012, 0x012c }, + { 0x0013, 0x009d }, + { 0x0013, 0x009e }, + { 0x0013, 0x009f }, + { 0x0013, 0x00a0 }, + { 0x0013, 0x00a1 }, + { 0x0013, 0x00a2 }, + { 0x0013, 0x00a3 }, + { 0x0013, 0x00a4 }, + { 0x0013, 0x00a5 }, + { 0x0013, 0x00a6 }, + { 0x0013, 0x00a7 }, + { 0x0013, 0x00a8 }, + { 0x0013, 0x00a9 }, + { 0x0013, 0x00aa }, + { 0x0013, 0x00ab }, + { 0x0013, 0x00ac }, + { 0x0013, 0x00ad }, + { 0x0013, 0x00ae }, + { 0x0010, 0x005e }, + { 0x000f, 0x0039 }, + { 0x0010, 0x005f }, + { 0x0010, 0x0060 }, + { 0x0011, 0x00a1 }, + { 0x0010, 0x0061 }, + { 0x0013, 0x00af }, + { 0x0013, 0x00b0 }, + { 0x0012, 0x012d }, + { 0x0013, 0x00b1 }, + { 0x0013, 0x00b2 }, + { 0x0013, 0x00b3 }, + { 0x0013, 0x00b4 }, + { 0x0013, 0x00b5 }, + { 0x0013, 0x00b6 }, + { 0x0013, 0x00b7 }, + { 0x0013, 0x00b8 }, + { 0x0013, 0x00b9 }, + { 0x0013, 0x00ba }, + { 0x0013, 0x00bb }, + { 0x0013, 0x00bc }, + { 0x0013, 0x00bd }, + { 0x0013, 0x00be }, + { 0x0013, 0x00bf }, + { 0x0013, 0x00c0 }, + { 0x0013, 0x00c1 }, + { 0x0013, 0x00c2 }, + { 0x0012, 0x012e }, + { 0x0011, 0x00a2 }, + { 0x0011, 0x00a3 }, + { 0x0013, 0x00c3 }, + { 0x0013, 0x00c4 }, + { 0x0013, 0x00c5 }, + { 0x0013, 0x00c6 }, + { 0x0013, 0x00c7 }, + { 0x0013, 0x00c8 }, + { 0x0013, 0x00c9 }, + { 0x0013, 0x00ca }, + { 0x0013, 0x00cb }, + { 0x0013, 0x00cc }, + { 0x0013, 0x00cd }, + { 0x0013, 0x00ce }, + { 0x0013, 0x00cf }, + { 0x0013, 0x00d0 }, + { 0x0013, 0x00d1 }, + { 0x0013, 0x00d2 }, + { 0x0013, 0x00d3 }, + { 0x0013, 0x00d4 }, + { 0x0013, 0x00d5 }, + { 0x0013, 0x00d6 }, + { 0x0013, 0x00d7 }, + { 0x0013, 0x00d8 }, + { 0x0013, 0x00d9 }, + { 0x0013, 0x00da }, + { 0x0013, 0x00db }, + { 0x0013, 0x00dc }, + { 0x0013, 0x00dd }, + { 0x0013, 0x00de }, + { 0x0013, 0x00df }, + { 0x0012, 0x012f }, + { 0x0013, 0x00e0 }, + { 0x0013, 0x00e1 }, + { 0x0013, 0x00e2 }, + { 0x0013, 0x00e3 }, + { 0x0013, 0x00e4 }, + { 0x0013, 0x00e5 }, + { 0x0013, 0x00e6 }, + { 0x0013, 0x00e7 }, + { 0x0013, 0x00e8 }, + { 0x0013, 0x00e9 }, + { 0x0013, 0x00ea }, + { 0x0013, 0x00eb }, + { 0x0013, 0x00ec }, + { 0x0013, 0x00ed }, + { 0x0013, 0x00ee }, + { 0x0013, 0x00ef }, + { 0x0013, 0x00f0 }, + { 0x0013, 0x00f1 }, + { 0x0013, 0x00f2 }, + { 0x0013, 0x00f3 }, + { 0x0013, 0x00f4 }, + { 0x0013, 0x00f5 }, + { 0x0013, 0x00f6 }, + { 0x0013, 0x00f7 }, + { 0x0013, 0x00f8 }, + { 0x0013, 0x00f9 }, + { 0x0013, 0x00fa }, + { 0x0013, 0x00fb }, + { 0x0013, 0x00fc }, + { 0x0013, 0x00fd }, + { 0x0013, 0x00fe }, + { 0x0013, 0x00ff }, + { 0x0013, 0x0100 }, + { 0x0013, 0x0101 }, + { 0x0013, 0x0102 }, + { 0x0013, 0x0103 }, + { 0x0013, 0x0104 }, + { 0x0013, 0x0105 }, + { 0x0013, 0x0106 }, + { 0x0013, 0x0107 }, + { 0x0013, 0x0108 }, + { 0x0013, 0x0109 }, + { 0x0013, 0x010a }, + { 0x0013, 0x010b }, + { 0x0013, 0x010c }, + { 0x0013, 0x010d }, + { 0x0013, 0x010e }, + { 0x0013, 0x010f }, + { 0x0013, 0x0110 }, + { 0x0013, 0x0111 }, + { 0x0013, 0x0112 }, + { 0x0013, 0x0113 }, + { 0x0013, 0x0114 }, + { 0x0013, 0x0115 }, + { 0x0013, 0x0116 }, + { 0x0013, 0x0117 }, + { 0x0013, 0x0118 }, + { 0x0013, 0x0119 }, + { 0x0013, 0x011a }, + { 0x0013, 0x011b }, + { 0x0013, 0x011c }, + { 0x0013, 0x011d }, + { 0x0013, 0x011e }, + { 0x0013, 0x011f }, + { 0x0013, 0x0120 }, + { 0x0013, 0x0121 }, + { 0x0013, 0x0122 }, + { 0x0013, 0x0123 }, + { 0x0013, 0x0124 }, + { 0x0013, 0x0125 }, + { 0x0013, 0x0126 }, + { 0x0013, 0x0127 }, + { 0x0013, 0x0128 }, + { 0x0013, 0x0129 }, + { 0x0013, 0x012a }, + { 0x0013, 0x012b }, + { 0x0013, 0x012c }, + { 0x0013, 0x012d }, + { 0x0013, 0x012e }, + { 0x0013, 0x012f }, + { 0x0013, 0x0130 }, + { 0x0013, 0x0131 }, + { 0x0013, 0x0132 }, + { 0x0013, 0x0133 }, + { 0x0013, 0x0134 }, + { 0x0013, 0x0135 }, + { 0x0013, 0x0136 }, + { 0x0013, 0x0137 }, + { 0x0013, 0x0138 }, + { 0x0013, 0x0139 }, + { 0x0013, 0x013a }, + { 0x0013, 0x013b }, + { 0x0013, 0x013c }, + { 0x0013, 0x013d }, + { 0x0013, 0x013e }, + { 0x0013, 0x013f }, + { 0x0013, 0x0140 }, + { 0x0013, 0x0141 }, + { 0x0013, 0x0142 }, + { 0x0013, 0x0143 }, + { 0x0013, 0x0144 }, + { 0x0013, 0x0145 }, + { 0x0013, 0x0146 }, + { 0x0013, 0x0147 }, + { 0x0013, 0x0148 }, + { 0x0013, 0x0149 }, + { 0x0013, 0x014a }, + { 0x0013, 0x014b }, + { 0x0013, 0x014c }, + { 0x0013, 0x014d }, + { 0x0013, 0x014e }, + { 0x0013, 0x014f }, + { 0x0013, 0x0150 }, + { 0x0013, 0x0151 }, + { 0x0013, 0x0152 }, + { 0x0013, 0x0153 }, + { 0x0013, 0x0154 }, + { 0x0013, 0x0155 }, + { 0x0013, 0x0156 }, + { 0x0013, 0x0157 }, + { 0x0013, 0x0158 }, + { 0x0013, 0x0159 }, + { 0x0013, 0x015a }, + { 0x0013, 0x015b }, + { 0x0013, 0x015c }, + { 0x0013, 0x015d }, + { 0x0013, 0x015e }, + { 0x0013, 0x015f }, + { 0x0013, 0x0160 }, + { 0x0013, 0x0161 }, + { 0x0013, 0x0162 }, + { 0x0013, 0x0163 }, + { 0x0013, 0x0164 }, + { 0x0013, 0x0165 }, + { 0x0013, 0x0166 }, + { 0x0013, 0x0167 }, + { 0x0013, 0x0168 }, + { 0x0013, 0x0169 }, + { 0x0013, 0x016a }, + { 0x0013, 0x016b }, + { 0x0013, 0x016c }, + { 0x0013, 0x016d }, + { 0x0013, 0x016e }, + { 0x0013, 0x016f }, + { 0x0013, 0x0170 }, + { 0x0013, 0x0171 }, + { 0x0013, 0x0172 }, + { 0x0013, 0x0173 }, + { 0x0013, 0x0174 }, + { 0x0013, 0x0175 }, + { 0x0013, 0x0176 }, + { 0x0013, 0x0177 }, + { 0x0013, 0x0178 }, + { 0x0013, 0x0179 }, + { 0x0013, 0x017a }, + { 0x0013, 0x017b }, + { 0x0013, 0x017c }, + { 0x0013, 0x017d }, + { 0x0013, 0x017e }, + { 0x0013, 0x017f }, + { 0x0013, 0x0180 }, + { 0x0013, 0x0181 }, + { 0x0013, 0x0182 }, + { 0x0013, 0x0183 }, + { 0x0013, 0x0184 }, + { 0x0013, 0x0185 }, + { 0x0013, 0x0186 }, + { 0x0013, 0x0187 }, + { 0x0013, 0x0188 }, + { 0x0013, 0x0189 }, + { 0x0013, 0x018a }, + { 0x0013, 0x018b }, + { 0x0013, 0x018c }, + { 0x0013, 0x018d }, + { 0x0013, 0x018e }, + { 0x0013, 0x018f }, + { 0x0013, 0x0190 }, + { 0x0013, 0x0191 }, + { 0x0013, 0x0192 }, + { 0x0013, 0x0193 }, + { 0x0013, 0x0194 }, + { 0x0013, 0x0195 }, + { 0x0013, 0x0196 }, + { 0x0013, 0x0197 }, + { 0x0013, 0x0198 }, + { 0x0013, 0x0199 }, + { 0x0013, 0x019a }, + { 0x0013, 0x019b }, + { 0x0013, 0x019c }, + { 0x0013, 0x019d }, + { 0x0013, 0x019e }, + { 0x0013, 0x019f }, + { 0x0013, 0x01a0 }, + { 0x0013, 0x01a1 }, + { 0x0013, 0x01a2 }, + { 0x0013, 0x01a3 }, + { 0x0013, 0x01a4 }, + { 0x0013, 0x01a5 }, + { 0x0013, 0x01a6 }, + { 0x0013, 0x01a7 }, + { 0x0013, 0x01a8 }, + { 0x0013, 0x01a9 }, + { 0x0013, 0x01aa }, + { 0x0013, 0x01ab }, + { 0x0013, 0x01ac }, + { 0x0013, 0x01ad }, + { 0x0013, 0x01ae }, + { 0x0013, 0x01af }, + { 0x0013, 0x01b0 }, + { 0x0013, 0x01b1 }, + { 0x0013, 0x01b2 }, + { 0x0013, 0x01b3 }, + { 0x0013, 0x01b4 }, + { 0x0013, 0x01b5 }, + { 0x0013, 0x01b6 }, + { 0x0013, 0x01b7 }, + { 0x0013, 0x01b8 }, + { 0x0013, 0x01b9 }, + { 0x0013, 0x01ba }, + { 0x0013, 0x01bb }, + { 0x0013, 0x01bc }, + { 0x0013, 0x01bd }, + { 0x0013, 0x01be }, + { 0x0013, 0x01bf }, + { 0x0013, 0x01c0 }, + { 0x0013, 0x01c1 }, + { 0x0013, 0x01c2 }, + { 0x0013, 0x01c3 }, + { 0x0013, 0x01c4 }, + { 0x0013, 0x01c5 }, + { 0x0013, 0x01c6 }, + { 0x0013, 0x01c7 }, + { 0x0013, 0x01c8 }, + { 0x0013, 0x01c9 }, + { 0x0013, 0x01ca }, + { 0x0013, 0x01cb }, + { 0x0013, 0x01cc }, + { 0x0013, 0x01cd }, + { 0x0013, 0x01ce }, + { 0x0013, 0x01cf }, + { 0x0013, 0x01d0 }, + { 0x0013, 0x01d1 }, + { 0x0013, 0x01d2 }, + { 0x0013, 0x01d3 }, + { 0x0013, 0x01d4 }, + { 0x0013, 0x01d5 }, + { 0x0013, 0x01d6 }, + { 0x0013, 0x01d7 }, + { 0x0013, 0x01d8 }, + { 0x0013, 0x01d9 }, + { 0x0013, 0x01da }, + { 0x0013, 0x01db }, + { 0x0013, 0x01dc }, + { 0x0013, 0x01dd }, + { 0x0013, 0x01de }, + { 0x0013, 0x01df }, + { 0x0013, 0x01e0 }, + { 0x0013, 0x01e1 }, + { 0x0013, 0x01e2 }, + { 0x0013, 0x01e3 }, + { 0x0013, 0x01e4 }, + { 0x0013, 0x01e5 }, + { 0x0013, 0x01e6 }, + { 0x0013, 0x01e7 }, + { 0x0013, 0x01e8 }, + { 0x0013, 0x01e9 }, + { 0x0013, 0x01ea }, + { 0x0013, 0x01eb }, + { 0x0013, 0x01ec }, + { 0x0013, 0x01ed }, + { 0x0013, 0x01ee }, + { 0x0013, 0x01ef }, + { 0x0013, 0x01f0 }, + { 0x0013, 0x01f1 }, + { 0x0013, 0x01f2 }, + { 0x0013, 0x01f3 }, + { 0x0013, 0x01f4 }, + { 0x0013, 0x01f5 }, + { 0x0013, 0x01f6 }, + { 0x0013, 0x01f7 }, + { 0x0013, 0x01f8 }, + { 0x0013, 0x01f9 }, + { 0x0013, 0x01fa }, + { 0x0013, 0x01fb }, + { 0x0013, 0x01fc }, + { 0x0013, 0x01fd }, + { 0x0013, 0x01fe }, + { 0x0013, 0x01ff }, + { 0x0013, 0x0200 }, + { 0x0013, 0x0201 }, + { 0x0013, 0x0202 }, + { 0x0013, 0x0203 }, + { 0x0013, 0x0204 }, + { 0x0013, 0x0205 }, + { 0x0013, 0x0206 }, + { 0x0013, 0x0207 }, + { 0x0013, 0x0208 }, + { 0x0013, 0x0209 }, + { 0x0013, 0x020a }, + { 0x0013, 0x020b }, + { 0x0013, 0x020c }, + { 0x0013, 0x020d }, + { 0x0013, 0x020e }, + { 0x0013, 0x020f }, + { 0x0013, 0x0210 }, + { 0x0013, 0x0211 }, + { 0x0013, 0x0212 }, + { 0x0013, 0x0213 }, + { 0x0013, 0x0214 }, + { 0x0013, 0x0215 }, + { 0x0013, 0x0216 }, + { 0x0013, 0x0217 }, + { 0x0013, 0x0218 }, + { 0x0013, 0x0219 }, + { 0x0013, 0x021a }, + { 0x0013, 0x021b }, + { 0x0013, 0x021c }, + { 0x0013, 0x021d }, + { 0x0013, 0x021e }, + { 0x0013, 0x021f }, + { 0x0013, 0x0220 }, + { 0x0013, 0x0221 }, + { 0x0013, 0x0222 }, + { 0x0013, 0x0223 }, + { 0x0013, 0x0224 }, + { 0x0013, 0x0225 }, + { 0x0013, 0x0226 }, + { 0x0013, 0x0227 }, + { 0x0013, 0x0228 }, + { 0x0013, 0x0229 }, + { 0x0013, 0x022a }, + { 0x0013, 0x022b }, + { 0x0013, 0x022c }, + { 0x0013, 0x022d }, + { 0x0013, 0x022e }, + { 0x0013, 0x022f }, + { 0x0013, 0x0230 }, + { 0x0013, 0x0231 }, + { 0x0013, 0x0232 }, + { 0x0013, 0x0233 }, + { 0x0013, 0x0234 }, + { 0x0013, 0x0235 }, + { 0x0013, 0x0236 }, + { 0x0013, 0x0237 }, + { 0x0013, 0x0238 }, + { 0x0013, 0x0239 }, + { 0x0013, 0x023a }, + { 0x0013, 0x023b }, + { 0x0013, 0x023c }, + { 0x0013, 0x023d }, + { 0x0013, 0x023e }, + { 0x0013, 0x023f }, + { 0x0013, 0x0240 }, + { 0x0013, 0x0241 }, + { 0x0013, 0x0242 }, + { 0x0013, 0x0243 }, + { 0x0013, 0x0244 }, + { 0x0013, 0x0245 }, + { 0x0013, 0x0246 }, + { 0x0013, 0x0247 }, + { 0x0013, 0x0248 }, + { 0x0013, 0x0249 }, + { 0x0013, 0x024a }, + { 0x0013, 0x024b }, + { 0x0013, 0x024c }, + { 0x0013, 0x024d }, + { 0x0013, 0x024e }, + { 0x0013, 0x024f }, + { 0x0013, 0x0250 }, + { 0x0013, 0x0251 }, + { 0x0013, 0x0252 }, + { 0x0013, 0x0253 }, + + }; + +const uint16_t c_aauiLCLDHuffEnc50[28][2] = + { + { 0x0002, 0x0001 }, + { 0x0002, 0x0002 }, + { 0x0002, 0x0003 }, + { 0x0003, 0x0001 }, + { 0x0004, 0x0001 }, + { 0x0005, 0x0001 }, + { 0x0006, 0x0001 }, + { 0x0007, 0x0001 }, + { 0x0008, 0x0001 }, + { 0x0009, 0x0001 }, + { 0x000a, 0x0001 }, + { 0x000b, 0x0001 }, + { 0x000c, 0x0001 }, + { 0x000d, 0x0001 }, + { 0x000e, 0x0001 }, + { 0x000f, 0x0001 }, + { 0x0011, 0x0003 }, + { 0x0012, 0x0005 }, + { 0x0013, 0x0000 }, + { 0x0013, 0x0001 }, + { 0x0013, 0x0002 }, + { 0x0013, 0x0003 }, + { 0x0013, 0x0004 }, + { 0x0013, 0x0005 }, + { 0x0013, 0x0006 }, + { 0x0013, 0x0007 }, + { 0x0013, 0x0008 }, + { 0x0013, 0x0009 }, + + }; + +const uint16_t c_aauiLCLDHuffEnc51[29][2] = + { + { 0x0002, 0x0002 }, + { 0x0002, 0x0003 }, + { 0x0003, 0x0002 }, + { 0x0003, 0x0003 }, + { 0x0004, 0x0001 }, + { 0x0004, 0x0002 }, + { 0x0004, 0x0003 }, + { 0x0005, 0x0001 }, + { 0x0006, 0x0001 }, + { 0x0007, 0x0001 }, + { 0x0008, 0x0001 }, + { 0x0009, 0x0001 }, + { 0x000a, 0x0001 }, + { 0x000b, 0x0001 }, + { 0x000c, 0x0001 }, + { 0x000d, 0x0001 }, + { 0x000e, 0x0001 }, + { 0x0010, 0x0002 }, + { 0x0010, 0x0003 }, + { 0x0012, 0x0002 }, + { 0x0012, 0x0003 }, + { 0x0013, 0x0000 }, + { 0x0013, 0x0001 }, + { 0x0013, 0x0002 }, + { 0x0013, 0x0003 }, + { 0x0012, 0x0004 }, + { 0x0012, 0x0005 }, + { 0x0012, 0x0006 }, + { 0x0012, 0x0007 }, + + }; + +const uint16_t c_aauiLCLDHuffEnc52[32][2] = + { + { 0x0002, 0x0002 }, + { 0x0002, 0x0003 }, + { 0x0003, 0x0002 }, + { 0x0003, 0x0003 }, + { 0x0004, 0x0002 }, + { 0x0004, 0x0003 }, + { 0x0005, 0x0001 }, + { 0x0005, 0x0002 }, + { 0x0005, 0x0003 }, + { 0x0006, 0x0001 }, + { 0x0007, 0x0001 }, + { 0x0008, 0x0001 }, + { 0x0009, 0x0001 }, + { 0x000a, 0x0001 }, + { 0x000b, 0x0001 }, + { 0x000c, 0x0001 }, + { 0x000e, 0x0001 }, + { 0x000e, 0x0002 }, + { 0x000e, 0x0003 }, + { 0x000f, 0x0001 }, + { 0x0011, 0x0002 }, + { 0x0011, 0x0003 }, + { 0x0012, 0x0003 }, + { 0x0014, 0x0000 }, + { 0x0013, 0x0003 }, + { 0x0014, 0x0001 }, + { 0x0014, 0x0002 }, + { 0x0014, 0x0003 }, + { 0x0014, 0x0004 }, + { 0x0014, 0x0005 }, + { 0x0013, 0x0004 }, + { 0x0013, 0x0005 }, + }; + +const uint16_t c_aauiLCLDHuffEnc53[37][2] = + { + { 0x0002, 0x0002 }, + { 0x0002, 0x0003 }, + { 0x0003, 0x0002 }, + { 0x0003, 0x0003 }, + { 0x0004, 0x0002 }, + { 0x0004, 0x0003 }, + { 0x0005, 0x0002 }, + { 0x0005, 0x0003 }, + { 0x0006, 0x0002 }, + { 0x0006, 0x0003 }, + { 0x0007, 0x0001 }, + { 0x0007, 0x0002 }, + { 0x0007, 0x0003 }, + { 0x0008, 0x0001 }, + { 0x0009, 0x0001 }, + { 0x000b, 0x0002 }, + { 0x000b, 0x0003 }, + { 0x000c, 0x0002 }, + { 0x000c, 0x0003 }, + { 0x000d, 0x0002 }, + { 0x000d, 0x0003 }, + { 0x000e, 0x0002 }, + { 0x000e, 0x0003 }, + { 0x000f, 0x0002 }, + { 0x000f, 0x0003 }, + { 0x0011, 0x0004 }, + { 0x0010, 0x0003 }, + { 0x0011, 0x0005 }, + { 0x0013, 0x0000 }, + { 0x0013, 0x0001 }, + { 0x0012, 0x0001 }, + { 0x0012, 0x0002 }, + { 0x0012, 0x0003 }, + { 0x0012, 0x0004 }, + { 0x0012, 0x0005 }, + { 0x0012, 0x0006 }, + { 0x0012, 0x0007 }, + + }; + +const uint16_t c_aauiLCLDHuffEnc54[39][2] = + { + { 0x0002, 0x0002 }, + { 0x0002, 0x0003 }, + { 0x0003, 0x0002 }, + { 0x0003, 0x0003 }, + { 0x0004, 0x0003 }, + { 0x0005, 0x0003 }, + { 0x0005, 0x0004 }, + { 0x0005, 0x0005 }, + { 0x0006, 0x0002 }, + { 0x0006, 0x0003 }, + { 0x0006, 0x0004 }, + { 0x0006, 0x0005 }, + { 0x0007, 0x0002 }, + { 0x0007, 0x0003 }, + { 0x0008, 0x0001 }, + { 0x0008, 0x0002 }, + { 0x0008, 0x0003 }, + { 0x000a, 0x0002 }, + { 0x000a, 0x0003 }, + { 0x000b, 0x0002 }, + { 0x000b, 0x0003 }, + { 0x000c, 0x0002 }, + { 0x000c, 0x0003 }, + { 0x000d, 0x0002 }, + { 0x000d, 0x0003 }, + { 0x000e, 0x0002 }, + { 0x000e, 0x0003 }, + { 0x000f, 0x0002 }, + { 0x000f, 0x0003 }, + { 0x0011, 0x0002 }, + { 0x0010, 0x0002 }, + { 0x0010, 0x0003 }, + { 0x0011, 0x0003 }, + { 0x0012, 0x0002 }, + { 0x0012, 0x0003 }, + { 0x0013, 0x0000 }, + { 0x0013, 0x0001 }, + { 0x0013, 0x0002 }, + { 0x0013, 0x0003 }, + + }; + +const uint16_t c_aauiLCLDHuffEnc55[46][2] = + { + { 0x0003, 0x0003 }, + { 0x0002, 0x0003 }, + { 0x0003, 0x0004 }, + { 0x0003, 0x0005 }, + { 0x0004, 0x0003 }, + { 0x0004, 0x0004 }, + { 0x0004, 0x0005 }, + { 0x0005, 0x0003 }, + { 0x0005, 0x0004 }, + { 0x0005, 0x0005 }, + { 0x0006, 0x0003 }, + { 0x0006, 0x0004 }, + { 0x0006, 0x0005 }, + { 0x0007, 0x0002 }, + { 0x0007, 0x0003 }, + { 0x0007, 0x0004 }, + { 0x0007, 0x0005 }, + { 0x0008, 0x0002 }, + { 0x0008, 0x0003 }, + { 0x0009, 0x0002 }, + { 0x0009, 0x0003 }, + { 0x000a, 0x0002 }, + { 0x000a, 0x0003 }, + { 0x000b, 0x0002 }, + { 0x000b, 0x0003 }, + { 0x000c, 0x0002 }, + { 0x000c, 0x0003 }, + { 0x000d, 0x0002 }, + { 0x000d, 0x0003 }, + { 0x000e, 0x0002 }, + { 0x000e, 0x0003 }, + { 0x000f, 0x0003 }, + { 0x0010, 0x0002 }, + { 0x0010, 0x0003 }, + { 0x0010, 0x0004 }, + { 0x0010, 0x0005 }, + { 0x0011, 0x0003 }, + { 0x0012, 0x0003 }, + { 0x0012, 0x0004 }, + { 0x0012, 0x0005 }, + { 0x0013, 0x0000 }, + { 0x0013, 0x0001 }, + { 0x0013, 0x0002 }, + { 0x0013, 0x0003 }, + { 0x0013, 0x0004 }, + { 0x0013, 0x0005 }, + + }; + +const uint16_t c_aauiLCLDHuffEnc56[55][2] = + { + { 0x0003, 0x0003 }, + { 0x0002, 0x0003 }, + { 0x0003, 0x0004 }, + { 0x0003, 0x0005 }, + { 0x0004, 0x0004 }, + { 0x0004, 0x0005 }, + { 0x0005, 0x0003 }, + { 0x0005, 0x0004 }, + { 0x0005, 0x0005 }, + { 0x0005, 0x0006 }, + { 0x0005, 0x0007 }, + { 0x0006, 0x0003 }, + { 0x0006, 0x0004 }, + { 0x0006, 0x0005 }, + { 0x0007, 0x0003 }, + { 0x0007, 0x0004 }, + { 0x0007, 0x0005 }, + { 0x0008, 0x0002 }, + { 0x0008, 0x0003 }, + { 0x0008, 0x0004 }, + { 0x0008, 0x0005 }, + { 0x0009, 0x0002 }, + { 0x0009, 0x0003 }, + { 0x000a, 0x0002 }, + { 0x000a, 0x0003 }, + { 0x000b, 0x0003 }, + { 0x000c, 0x0003 }, + { 0x000c, 0x0004 }, + { 0x000c, 0x0005 }, + { 0x000d, 0x0003 }, + { 0x000d, 0x0004 }, + { 0x000d, 0x0005 }, + { 0x000e, 0x0003 }, + { 0x000e, 0x0004 }, + { 0x000e, 0x0005 }, + { 0x000f, 0x0004 }, + { 0x000f, 0x0005 }, + { 0x0010, 0x0002 }, + { 0x0010, 0x0003 }, + { 0x0010, 0x0004 }, + { 0x0010, 0x0005 }, + { 0x0010, 0x0006 }, + { 0x0010, 0x0007 }, + { 0x0013, 0x0000 }, + { 0x0011, 0x0003 }, + { 0x0012, 0x0005 }, + { 0x0013, 0x0001 }, + { 0x0013, 0x0002 }, + { 0x0013, 0x0003 }, + { 0x0013, 0x0004 }, + { 0x0013, 0x0005 }, + { 0x0013, 0x0006 }, + { 0x0013, 0x0007 }, + { 0x0013, 0x0008 }, + { 0x0013, 0x0009 }, + + }; + +const uint16_t c_aauiLCLDHuffEnc57[65][2] = + { + { 0x0003, 0x0004 }, + { 0x0002, 0x0003 }, + { 0x0003, 0x0005 }, + { 0x0004, 0x0004 }, + { 0x0004, 0x0005 }, + { 0x0004, 0x0006 }, + { 0x0004, 0x0007 }, + { 0x0005, 0x0004 }, + { 0x0005, 0x0005 }, + { 0x0005, 0x0006 }, + { 0x0005, 0x0007 }, + { 0x0006, 0x0004 }, + { 0x0006, 0x0005 }, + { 0x0006, 0x0006 }, + { 0x0006, 0x0007 }, + { 0x0007, 0x0003 }, + { 0x0007, 0x0004 }, + { 0x0007, 0x0005 }, + { 0x0007, 0x0006 }, + { 0x0007, 0x0007 }, + { 0x0008, 0x0003 }, + { 0x0008, 0x0004 }, + { 0x0008, 0x0005 }, + { 0x0009, 0x0003 }, + { 0x0009, 0x0004 }, + { 0x0009, 0x0005 }, + { 0x000a, 0x0003 }, + { 0x000a, 0x0004 }, + { 0x000a, 0x0005 }, + { 0x000b, 0x0003 }, + { 0x000b, 0x0004 }, + { 0x000b, 0x0005 }, + { 0x000c, 0x0003 }, + { 0x000c, 0x0004 }, + { 0x000d, 0x0003 }, + { 0x000c, 0x0005 }, + { 0x000d, 0x0004 }, + { 0x000d, 0x0005 }, + { 0x000e, 0x0003 }, + { 0x000e, 0x0004 }, + { 0x000e, 0x0005 }, + { 0x000f, 0x0003 }, + { 0x0010, 0x0003 }, + { 0x000f, 0x0004 }, + { 0x000f, 0x0005 }, + { 0x0010, 0x0004 }, + { 0x0010, 0x0005 }, + { 0x0013, 0x0000 }, + { 0x0011, 0x0005 }, + { 0x0013, 0x0001 }, + { 0x0013, 0x0002 }, + { 0x0012, 0x0007 }, + { 0x0013, 0x0003 }, + { 0x0013, 0x0004 }, + { 0x0012, 0x0008 }, + { 0x0012, 0x0009 }, + { 0x0013, 0x0005 }, + { 0x0013, 0x0006 }, + { 0x0013, 0x0007 }, + { 0x0013, 0x0008 }, + { 0x0013, 0x0009 }, + { 0x0013, 0x000a }, + { 0x0013, 0x000b }, + { 0x0013, 0x000c }, + { 0x0013, 0x000d }, + + }; + +const uint16_t c_aauiLCLDHuffEnc58[77][2] = + { + { 0x0004, 0x0005 }, + { 0x0003, 0x0005 }, + { 0x0003, 0x0006 }, + { 0x0003, 0x0007 }, + { 0x0004, 0x0006 }, + { 0x0004, 0x0007 }, + { 0x0004, 0x0008 }, + { 0x0004, 0x0009 }, + { 0x0005, 0x0005 }, + { 0x0005, 0x0006 }, + { 0x0005, 0x0007 }, + { 0x0005, 0x0008 }, + { 0x0005, 0x0009 }, + { 0x0006, 0x0004 }, + { 0x0006, 0x0005 }, + { 0x0006, 0x0006 }, + { 0x0006, 0x0007 }, + { 0x0006, 0x0008 }, + { 0x0006, 0x0009 }, + { 0x0007, 0x0004 }, + { 0x0007, 0x0005 }, + { 0x0007, 0x0006 }, + { 0x0007, 0x0007 }, + { 0x0008, 0x0003 }, + { 0x0008, 0x0004 }, + { 0x0008, 0x0005 }, + { 0x0008, 0x0006 }, + { 0x0008, 0x0007 }, + { 0x0009, 0x0003 }, + { 0x0009, 0x0004 }, + { 0x0009, 0x0005 }, + { 0x000a, 0x0003 }, + { 0x000a, 0x0004 }, + { 0x000a, 0x0005 }, + { 0x000b, 0x0004 }, + { 0x000b, 0x0005 }, + { 0x000c, 0x0004 }, + { 0x000c, 0x0005 }, + { 0x000c, 0x0006 }, + { 0x000c, 0x0007 }, + { 0x000d, 0x0004 }, + { 0x000d, 0x0005 }, + { 0x000d, 0x0006 }, + { 0x000d, 0x0007 }, + { 0x000e, 0x0004 }, + { 0x000e, 0x0005 }, + { 0x000e, 0x0006 }, + { 0x000e, 0x0007 }, + { 0x000f, 0x0004 }, + { 0x000f, 0x0005 }, + { 0x000f, 0x0006 }, + { 0x0010, 0x0004 }, + { 0x000f, 0x0007 }, + { 0x0010, 0x0005 }, + { 0x0010, 0x0006 }, + { 0x0010, 0x0007 }, + { 0x0013, 0x0000 }, + { 0x0013, 0x0001 }, + { 0x0012, 0x0006 }, + { 0x0011, 0x0007 }, + { 0x0013, 0x0002 }, + { 0x0013, 0x0003 }, + { 0x0013, 0x0004 }, + { 0x0013, 0x0005 }, + { 0x0012, 0x0007 }, + { 0x0013, 0x0006 }, + { 0x0013, 0x0007 }, + { 0x0013, 0x0008 }, + { 0x0013, 0x0009 }, + { 0x0013, 0x000a }, + { 0x0013, 0x000b }, + { 0x0012, 0x0008 }, + { 0x0012, 0x0009 }, + { 0x0012, 0x000a }, + { 0x0012, 0x000b }, + { 0x0012, 0x000c }, + { 0x0012, 0x000d }, + + }; + +const uint16_t c_aauiLCLDHuffEnc59[91][2] = + { + { 0x0003, 0x0005 }, + { 0x0003, 0x0006 }, + { 0x0003, 0x0007 }, + { 0x0004, 0x0006 }, + { 0x0004, 0x0007 }, + { 0x0004, 0x0008 }, + { 0x0004, 0x0009 }, + { 0x0005, 0x0006 }, + { 0x0005, 0x0007 }, + { 0x0005, 0x0008 }, + { 0x0005, 0x0009 }, + { 0x0005, 0x000a }, + { 0x0005, 0x000b }, + { 0x0006, 0x0006 }, + { 0x0006, 0x0007 }, + { 0x0006, 0x0008 }, + { 0x0006, 0x0009 }, + { 0x0006, 0x000a }, + { 0x0006, 0x000b }, + { 0x0007, 0x0005 }, + { 0x0007, 0x0006 }, + { 0x0007, 0x0007 }, + { 0x0007, 0x0008 }, + { 0x0007, 0x0009 }, + { 0x0007, 0x000a }, + { 0x0007, 0x000b }, + { 0x0008, 0x0003 }, + { 0x0008, 0x0004 }, + { 0x0008, 0x0005 }, + { 0x0008, 0x0006 }, + { 0x0008, 0x0007 }, + { 0x0008, 0x0008 }, + { 0x0008, 0x0009 }, + { 0x0009, 0x0004 }, + { 0x0009, 0x0005 }, + { 0x000a, 0x0004 }, + { 0x000a, 0x0005 }, + { 0x000a, 0x0006 }, + { 0x000a, 0x0007 }, + { 0x000b, 0x0004 }, + { 0x000b, 0x0005 }, + { 0x000b, 0x0006 }, + { 0x000b, 0x0007 }, + { 0x000c, 0x0004 }, + { 0x000c, 0x0005 }, + { 0x000c, 0x0006 }, + { 0x000c, 0x0007 }, + { 0x000d, 0x0003 }, + { 0x000d, 0x0004 }, + { 0x000d, 0x0005 }, + { 0x000d, 0x0006 }, + { 0x000d, 0x0007 }, + { 0x000e, 0x0003 }, + { 0x000e, 0x0004 }, + { 0x000e, 0x0005 }, + { 0x000f, 0x0003 }, + { 0x000f, 0x0004 }, + { 0x000f, 0x0005 }, + { 0x0011, 0x0008 }, + { 0x0011, 0x0009 }, + { 0x0013, 0x0000 }, + { 0x0011, 0x000a }, + { 0x0013, 0x0001 }, + { 0x0013, 0x0002 }, + { 0x0012, 0x000d }, + { 0x0012, 0x000e }, + { 0x0013, 0x0003 }, + { 0x0013, 0x0004 }, + { 0x0013, 0x0005 }, + { 0x0011, 0x000b }, + { 0x0013, 0x0006 }, + { 0x0013, 0x0007 }, + { 0x0013, 0x0008 }, + { 0x0013, 0x0009 }, + { 0x0013, 0x000a }, + { 0x0013, 0x000b }, + { 0x0013, 0x000c }, + { 0x0013, 0x000d }, + { 0x0013, 0x000e }, + { 0x0013, 0x000f }, + { 0x0013, 0x0010 }, + { 0x0013, 0x0011 }, + { 0x0013, 0x0012 }, + { 0x0013, 0x0013 }, + { 0x0013, 0x0014 }, + { 0x0013, 0x0015 }, + { 0x0013, 0x0016 }, + { 0x0013, 0x0017 }, + { 0x0013, 0x0018 }, + { 0x0013, 0x0019 }, + { 0x0012, 0x000f }, + + }; + +const uint16_t c_aauiLCLDHuffEnc60[109][2] = + { + { 0x0004, 0x0007 }, + { 0x0002, 0x0003 }, + { 0x0003, 0x0005 }, + { 0x0004, 0x0008 }, + { 0x0004, 0x0009 }, + { 0x0005, 0x0007 }, + { 0x0005, 0x0008 }, + { 0x0005, 0x0009 }, + { 0x0005, 0x000a }, + { 0x0005, 0x000b }, + { 0x0005, 0x000c }, + { 0x0005, 0x000d }, + { 0x0006, 0x0007 }, + { 0x0006, 0x0008 }, + { 0x0006, 0x0009 }, + { 0x0006, 0x000a }, + { 0x0006, 0x000b }, + { 0x0006, 0x000c }, + { 0x0006, 0x000d }, + { 0x0007, 0x0006 }, + { 0x0007, 0x0007 }, + { 0x0007, 0x0008 }, + { 0x0007, 0x0009 }, + { 0x0007, 0x000a }, + { 0x0007, 0x000b }, + { 0x0007, 0x000c }, + { 0x0007, 0x000d }, + { 0x0008, 0x0006 }, + { 0x0008, 0x0007 }, + { 0x0008, 0x0008 }, + { 0x0008, 0x0009 }, + { 0x0008, 0x000a }, + { 0x0008, 0x000b }, + { 0x0009, 0x0004 }, + { 0x0009, 0x0005 }, + { 0x0009, 0x0006 }, + { 0x0009, 0x0007 }, + { 0x0009, 0x0008 }, + { 0x0009, 0x0009 }, + { 0x0009, 0x000a }, + { 0x0009, 0x000b }, + { 0x000a, 0x0004 }, + { 0x000a, 0x0005 }, + { 0x000a, 0x0006 }, + { 0x000a, 0x0007 }, + { 0x000b, 0x0004 }, + { 0x000b, 0x0005 }, + { 0x000b, 0x0006 }, + { 0x000b, 0x0007 }, + { 0x000c, 0x0004 }, + { 0x000c, 0x0005 }, + { 0x000c, 0x0006 }, + { 0x000d, 0x0005 }, + { 0x000d, 0x0006 }, + { 0x000d, 0x0007 }, + { 0x000c, 0x0007 }, + { 0x000e, 0x0005 }, + { 0x000e, 0x0006 }, + { 0x000e, 0x0007 }, + { 0x000e, 0x0008 }, + { 0x000f, 0x0005 }, + { 0x000e, 0x0009 }, + { 0x000f, 0x0006 }, + { 0x0010, 0x0006 }, + { 0x000f, 0x0007 }, + { 0x000f, 0x0008 }, + { 0x000f, 0x0009 }, + { 0x0010, 0x0007 }, + { 0x0010, 0x0008 }, + { 0x0010, 0x0009 }, + { 0x0011, 0x000a }, + { 0x0013, 0x0000 }, + { 0x0011, 0x000b }, + { 0x0013, 0x0001 }, + { 0x0013, 0x0002 }, + { 0x0012, 0x0011 }, + { 0x0012, 0x0012 }, + { 0x0013, 0x0003 }, + { 0x0013, 0x0004 }, + { 0x0013, 0x0005 }, + { 0x0013, 0x0006 }, + { 0x0013, 0x0007 }, + { 0x0013, 0x0008 }, + { 0x0013, 0x0009 }, + { 0x0013, 0x000a }, + { 0x0013, 0x000b }, + { 0x0013, 0x000c }, + { 0x0013, 0x000d }, + { 0x0013, 0x000e }, + { 0x0013, 0x000f }, + { 0x0013, 0x0010 }, + { 0x0013, 0x0011 }, + { 0x0013, 0x0012 }, + { 0x0013, 0x0013 }, + { 0x0013, 0x0014 }, + { 0x0013, 0x0015 }, + { 0x0013, 0x0016 }, + { 0x0013, 0x0017 }, + { 0x0013, 0x0018 }, + { 0x0013, 0x0019 }, + { 0x0013, 0x001a }, + { 0x0013, 0x001b }, + { 0x0013, 0x001c }, + { 0x0013, 0x001d }, + { 0x0013, 0x001e }, + { 0x0013, 0x001f }, + { 0x0013, 0x0020 }, + { 0x0013, 0x0021 }, + { 0x0012, 0x0013 }, + + }; + +const uint16_t c_aauiLCLDHuffEnc61[129][2] = + { + { 0x0004, 0x0008 }, + { 0x0003, 0x0006 }, + { 0x0003, 0x0007 }, + { 0x0004, 0x0009 }, + { 0x0004, 0x000a }, + { 0x0004, 0x000b }, + { 0x0005, 0x0008 }, + { 0x0005, 0x0009 }, + { 0x0005, 0x000a }, + { 0x0005, 0x000b }, + { 0x0005, 0x000c }, + { 0x0005, 0x000d }, + { 0x0005, 0x000e }, + { 0x0005, 0x000f }, + { 0x0006, 0x0008 }, + { 0x0006, 0x0009 }, + { 0x0006, 0x000a }, + { 0x0006, 0x000b }, + { 0x0006, 0x000c }, + { 0x0006, 0x000d }, + { 0x0006, 0x000e }, + { 0x0006, 0x000f }, + { 0x0007, 0x0008 }, + { 0x0007, 0x0009 }, + { 0x0007, 0x000a }, + { 0x0007, 0x000b }, + { 0x0007, 0x000c }, + { 0x0007, 0x000d }, + { 0x0007, 0x000e }, + { 0x0007, 0x000f }, + { 0x0008, 0x0006 }, + { 0x0008, 0x0007 }, + { 0x0008, 0x0008 }, + { 0x0008, 0x0009 }, + { 0x0008, 0x000a }, + { 0x0008, 0x000b }, + { 0x0008, 0x000c }, + { 0x0008, 0x000d }, + { 0x0008, 0x000e }, + { 0x0008, 0x000f }, + { 0x0009, 0x0006 }, + { 0x0009, 0x0007 }, + { 0x0009, 0x0008 }, + { 0x0009, 0x0009 }, + { 0x0009, 0x000a }, + { 0x0009, 0x000b }, + { 0x000a, 0x0005 }, + { 0x000a, 0x0006 }, + { 0x000a, 0x0007 }, + { 0x000a, 0x0008 }, + { 0x000a, 0x0009 }, + { 0x000a, 0x000a }, + { 0x000a, 0x000b }, + { 0x000b, 0x0005 }, + { 0x000b, 0x0006 }, + { 0x000b, 0x0007 }, + { 0x000b, 0x0008 }, + { 0x000b, 0x0009 }, + { 0x000c, 0x0006 }, + { 0x000c, 0x0007 }, + { 0x000c, 0x0008 }, + { 0x000c, 0x0009 }, + { 0x000d, 0x0005 }, + { 0x000d, 0x0006 }, + { 0x000d, 0x0007 }, + { 0x000d, 0x0008 }, + { 0x000d, 0x0009 }, + { 0x000d, 0x000a }, + { 0x000e, 0x0008 }, + { 0x000d, 0x000b }, + { 0x000e, 0x0009 }, + { 0x000f, 0x0009 }, + { 0x000f, 0x000a }, + { 0x000f, 0x000b }, + { 0x000f, 0x000c }, + { 0x000f, 0x000d }, + { 0x000f, 0x000e }, + { 0x0010, 0x000c }, + { 0x0011, 0x0015 }, + { 0x0010, 0x000d }, + { 0x000f, 0x000f }, + { 0x0010, 0x000e }, + { 0x0010, 0x000f }, + { 0x0012, 0x0000 }, + { 0x0011, 0x0016 }, + { 0x0010, 0x0010 }, + { 0x0010, 0x0011 }, + { 0x0011, 0x0017 }, + { 0x0012, 0x0001 }, + { 0x0012, 0x0002 }, + { 0x0012, 0x0003 }, + { 0x0012, 0x0004 }, + { 0x0012, 0x0005 }, + { 0x0012, 0x0006 }, + { 0x0012, 0x0007 }, + { 0x0012, 0x0008 }, + { 0x0012, 0x0009 }, + { 0x0012, 0x000a }, + { 0x0012, 0x000b }, + { 0x0012, 0x000c }, + { 0x0012, 0x000d }, + { 0x0012, 0x000e }, + { 0x0012, 0x000f }, + { 0x0012, 0x0010 }, + { 0x0012, 0x0011 }, + { 0x0012, 0x0012 }, + { 0x0012, 0x0013 }, + { 0x0012, 0x0014 }, + { 0x0012, 0x0015 }, + { 0x0012, 0x0016 }, + { 0x0012, 0x0017 }, + { 0x0012, 0x0018 }, + { 0x0012, 0x0019 }, + { 0x0012, 0x001a }, + { 0x0012, 0x001b }, + { 0x0012, 0x001c }, + { 0x0012, 0x001d }, + { 0x0012, 0x001e }, + { 0x0012, 0x001f }, + { 0x0012, 0x0020 }, + { 0x0012, 0x0021 }, + { 0x0012, 0x0022 }, + { 0x0012, 0x0023 }, + { 0x0012, 0x0024 }, + { 0x0012, 0x0025 }, + { 0x0012, 0x0026 }, + { 0x0012, 0x0027 }, + { 0x0012, 0x0028 }, + { 0x0012, 0x0029 }, + + }; + +const uint16_t c_aauiLCLDHuffEnc62[153][2] = + { + { 0x0004, 0x0009 }, + { 0x0003, 0x0006 }, + { 0x0003, 0x0007 }, + { 0x0004, 0x000a }, + { 0x0004, 0x000b }, + { 0x0005, 0x000a }, + { 0x0005, 0x000b }, + { 0x0005, 0x000c }, + { 0x0005, 0x000d }, + { 0x0005, 0x000e }, + { 0x0005, 0x000f }, + { 0x0005, 0x0010 }, + { 0x0005, 0x0011 }, + { 0x0006, 0x000a }, + { 0x0006, 0x000b }, + { 0x0006, 0x000c }, + { 0x0006, 0x000d }, + { 0x0006, 0x000e }, + { 0x0006, 0x000f }, + { 0x0006, 0x0010 }, + { 0x0006, 0x0011 }, + { 0x0006, 0x0012 }, + { 0x0006, 0x0013 }, + { 0x0007, 0x0009 }, + { 0x0007, 0x000a }, + { 0x0007, 0x000b }, + { 0x0007, 0x000c }, + { 0x0007, 0x000d }, + { 0x0007, 0x000e }, + { 0x0007, 0x000f }, + { 0x0007, 0x0010 }, + { 0x0007, 0x0011 }, + { 0x0007, 0x0012 }, + { 0x0007, 0x0013 }, + { 0x0008, 0x0009 }, + { 0x0008, 0x000a }, + { 0x0008, 0x000b }, + { 0x0008, 0x000c }, + { 0x0008, 0x000d }, + { 0x0008, 0x000e }, + { 0x0008, 0x000f }, + { 0x0008, 0x0010 }, + { 0x0008, 0x0011 }, + { 0x0009, 0x0007 }, + { 0x0009, 0x0008 }, + { 0x0009, 0x0009 }, + { 0x0009, 0x000a }, + { 0x0009, 0x000b }, + { 0x0009, 0x000c }, + { 0x0009, 0x000d }, + { 0x0009, 0x000e }, + { 0x0009, 0x000f }, + { 0x0009, 0x0010 }, + { 0x0009, 0x0011 }, + { 0x000a, 0x0004 }, + { 0x000a, 0x0005 }, + { 0x000a, 0x0006 }, + { 0x000a, 0x0007 }, + { 0x000a, 0x0008 }, + { 0x000a, 0x0009 }, + { 0x000a, 0x000a }, + { 0x000a, 0x000b }, + { 0x000a, 0x000c }, + { 0x000a, 0x000d }, + { 0x000b, 0x0007 }, + { 0x000c, 0x0007 }, + { 0x000c, 0x0008 }, + { 0x000c, 0x0009 }, + { 0x000c, 0x000a }, + { 0x000c, 0x000b }, + { 0x000c, 0x000c }, + { 0x000d, 0x0007 }, + { 0x000c, 0x000d }, + { 0x000d, 0x0008 }, + { 0x000d, 0x0009 }, + { 0x000d, 0x000a }, + { 0x000d, 0x000b }, + { 0x000e, 0x0008 }, + { 0x000d, 0x000c }, + { 0x000d, 0x000d }, + { 0x000e, 0x0009 }, + { 0x000e, 0x000a }, + { 0x000e, 0x000b }, + { 0x000e, 0x000c }, + { 0x000f, 0x000c }, + { 0x000e, 0x000d }, + { 0x000f, 0x000d }, + { 0x000f, 0x000e }, + { 0x000f, 0x000f }, + { 0x0010, 0x000f }, + { 0x0010, 0x0010 }, + { 0x0011, 0x0019 }, + { 0x0010, 0x0011 }, + { 0x0010, 0x0012 }, + { 0x0010, 0x0013 }, + { 0x0010, 0x0014 }, + { 0x0010, 0x0015 }, + { 0x0012, 0x0000 }, + { 0x0010, 0x0016 }, + { 0x0011, 0x001a }, + { 0x0010, 0x0017 }, + { 0x0012, 0x0001 }, + { 0x0012, 0x0002 }, + { 0x0012, 0x0003 }, + { 0x0011, 0x001b }, + { 0x0012, 0x0004 }, + { 0x0012, 0x0005 }, + { 0x0012, 0x0006 }, + { 0x0012, 0x0007 }, + { 0x0012, 0x0008 }, + { 0x0012, 0x0009 }, + { 0x0012, 0x000a }, + { 0x0012, 0x000b }, + { 0x0012, 0x000c }, + { 0x0012, 0x000d }, + { 0x0012, 0x000e }, + { 0x0012, 0x000f }, + { 0x0012, 0x0010 }, + { 0x0012, 0x0011 }, + { 0x0012, 0x0012 }, + { 0x0012, 0x0013 }, + { 0x0012, 0x0014 }, + { 0x0012, 0x0015 }, + { 0x0012, 0x0016 }, + { 0x0012, 0x0017 }, + { 0x0012, 0x0018 }, + { 0x0011, 0x001c }, + { 0x0012, 0x0019 }, + { 0x0012, 0x001a }, + { 0x0012, 0x001b }, + { 0x0012, 0x001c }, + { 0x0012, 0x001d }, + { 0x0012, 0x001e }, + { 0x0012, 0x001f }, + { 0x0012, 0x0020 }, + { 0x0012, 0x0021 }, + { 0x0012, 0x0022 }, + { 0x0012, 0x0023 }, + { 0x0012, 0x0024 }, + { 0x0012, 0x0025 }, + { 0x0012, 0x0026 }, + { 0x0012, 0x0027 }, + { 0x0012, 0x0028 }, + { 0x0012, 0x0029 }, + { 0x0012, 0x002a }, + { 0x0012, 0x002b }, + { 0x0012, 0x002c }, + { 0x0012, 0x002d }, + { 0x0012, 0x002e }, + { 0x0012, 0x002f }, + { 0x0012, 0x0030 }, + { 0x0012, 0x0031 }, + { 0x0011, 0x001d }, + + }; + +const uint16_t c_aauiLCLDHuffEnc63[181][2] = + { + { 0x0004, 0x0008 }, + { 0x0003, 0x0005 }, + { 0x0002, 0x0003 }, + { 0x0004, 0x0009 }, + { 0x0005, 0x000c }, + { 0x0005, 0x000d }, + { 0x0005, 0x000e }, + { 0x0005, 0x000f }, + { 0x0006, 0x000c }, + { 0x0006, 0x000d }, + { 0x0006, 0x000e }, + { 0x0006, 0x000f }, + { 0x0006, 0x0010 }, + { 0x0006, 0x0011 }, + { 0x0006, 0x0012 }, + { 0x0006, 0x0013 }, + { 0x0006, 0x0014 }, + { 0x0006, 0x0015 }, + { 0x0006, 0x0016 }, + { 0x0006, 0x0017 }, + { 0x0007, 0x000b }, + { 0x0007, 0x000c }, + { 0x0007, 0x000d }, + { 0x0007, 0x000e }, + { 0x0007, 0x000f }, + { 0x0007, 0x0010 }, + { 0x0007, 0x0011 }, + { 0x0007, 0x0012 }, + { 0x0007, 0x0013 }, + { 0x0007, 0x0014 }, + { 0x0007, 0x0015 }, + { 0x0007, 0x0016 }, + { 0x0007, 0x0017 }, + { 0x0008, 0x000c }, + { 0x0008, 0x000d }, + { 0x0008, 0x000e }, + { 0x0008, 0x000f }, + { 0x0008, 0x0010 }, + { 0x0008, 0x0011 }, + { 0x0008, 0x0012 }, + { 0x0008, 0x0013 }, + { 0x0008, 0x0014 }, + { 0x0008, 0x0015 }, + { 0x0009, 0x0008 }, + { 0x0009, 0x0009 }, + { 0x0009, 0x000a }, + { 0x0009, 0x000b }, + { 0x0009, 0x000c }, + { 0x0009, 0x000d }, + { 0x0009, 0x000e }, + { 0x0009, 0x000f }, + { 0x0009, 0x0010 }, + { 0x0009, 0x0011 }, + { 0x0009, 0x0012 }, + { 0x0009, 0x0013 }, + { 0x0009, 0x0014 }, + { 0x0009, 0x0015 }, + { 0x000a, 0x0007 }, + { 0x0009, 0x0016 }, + { 0x0009, 0x0017 }, + { 0x000a, 0x0008 }, + { 0x000a, 0x0009 }, + { 0x000a, 0x000a }, + { 0x000a, 0x000b }, + { 0x000a, 0x000c }, + { 0x000a, 0x000d }, + { 0x000a, 0x000e }, + { 0x000b, 0x0008 }, + { 0x000b, 0x0009 }, + { 0x000b, 0x000a }, + { 0x000a, 0x000f }, + { 0x000b, 0x000b }, + { 0x000b, 0x000c }, + { 0x000b, 0x000d }, + { 0x000c, 0x0009 }, + { 0x000c, 0x000a }, + { 0x000c, 0x000b }, + { 0x000c, 0x000c }, + { 0x000c, 0x000d }, + { 0x000c, 0x000e }, + { 0x000c, 0x000f }, + { 0x000d, 0x0008 }, + { 0x000d, 0x0009 }, + { 0x000d, 0x000a }, + { 0x000d, 0x000b }, + { 0x000d, 0x000c }, + { 0x000d, 0x000d }, + { 0x000d, 0x000e }, + { 0x000d, 0x000f }, + { 0x000d, 0x0010 }, + { 0x000d, 0x0011 }, + { 0x000e, 0x0007 }, + { 0x000e, 0x0008 }, + { 0x000e, 0x0009 }, + { 0x000e, 0x000a }, + { 0x000e, 0x000b }, + { 0x000e, 0x000c }, + { 0x000e, 0x000d }, + { 0x000e, 0x000e }, + { 0x000e, 0x000f }, + { 0x000f, 0x0008 }, + { 0x000f, 0x0009 }, + { 0x000f, 0x000a }, + { 0x000f, 0x000b }, + { 0x000f, 0x000c }, + { 0x0010, 0x0009 }, + { 0x0010, 0x000a }, + { 0x000f, 0x000d }, + { 0x0010, 0x000b }, + { 0x0010, 0x000c }, + { 0x0010, 0x000d }, + { 0x0011, 0x000e }, + { 0x0011, 0x000f }, + { 0x0010, 0x000e }, + { 0x0011, 0x0010 }, + { 0x0011, 0x0011 }, + { 0x0012, 0x0014 }, + { 0x0014, 0x0000 }, + { 0x0010, 0x000f }, + { 0x0012, 0x0015 }, + { 0x0012, 0x0016 }, + { 0x0014, 0x0001 }, + { 0x0012, 0x0017 }, + { 0x0012, 0x0018 }, + { 0x0012, 0x0019 }, + { 0x0013, 0x0010 }, + { 0x0012, 0x001a }, + { 0x0014, 0x0002 }, + { 0x0012, 0x001b }, + { 0x0014, 0x0003 }, + { 0x0014, 0x0004 }, + { 0x0014, 0x0005 }, + { 0x0013, 0x0011 }, + { 0x0014, 0x0006 }, + { 0x0013, 0x0012 }, + { 0x0014, 0x0007 }, + { 0x0014, 0x0008 }, + { 0x0014, 0x0009 }, + { 0x0014, 0x000a }, + { 0x0014, 0x000b }, + { 0x0014, 0x000c }, + { 0x0014, 0x000d }, + { 0x0014, 0x000e }, + { 0x0013, 0x0013 }, + { 0x0014, 0x000f }, + { 0x0014, 0x0010 }, + { 0x0014, 0x0011 }, + { 0x0014, 0x0012 }, + { 0x0014, 0x0013 }, + { 0x0014, 0x0014 }, + { 0x0014, 0x0015 }, + { 0x0014, 0x0016 }, + { 0x0014, 0x0017 }, + { 0x0014, 0x0018 }, + { 0x0014, 0x0019 }, + { 0x0014, 0x001a }, + { 0x0014, 0x001b }, + { 0x0014, 0x001c }, + { 0x0014, 0x001d }, + { 0x0014, 0x001e }, + { 0x0014, 0x001f }, + { 0x0013, 0x0014 }, + { 0x0013, 0x0015 }, + { 0x0013, 0x0016 }, + { 0x0013, 0x0017 }, + { 0x0013, 0x0018 }, + { 0x0013, 0x0019 }, + { 0x0013, 0x001a }, + { 0x0013, 0x001b }, + { 0x0013, 0x001c }, + { 0x0013, 0x001d }, + { 0x0013, 0x001e }, + { 0x0013, 0x001f }, + { 0x0013, 0x0020 }, + { 0x0013, 0x0021 }, + { 0x0013, 0x0022 }, + { 0x0013, 0x0023 }, + { 0x0013, 0x0024 }, + { 0x0013, 0x0025 }, + { 0x0013, 0x0026 }, + { 0x0013, 0x0027 }, + + }; + +const uint16_t ( *c_apauiHuffEncTabels[2 * ALLOC_TABLE_SIZE] )[2] = + { + NULL, + c_aauiLCLDHuffEnc1, + c_aauiLCLDHuffEnc2, + c_aauiLCLDHuffEnc3, + c_aauiLCLDHuffEnc4, + c_aauiLCLDHuffEnc5, + c_aauiLCLDHuffEnc6, + c_aauiLCLDHuffEnc7, + c_aauiLCLDHuffEnc8, + c_aauiLCLDHuffEnc9, + c_aauiLCLDHuffEnc10, + c_aauiLCLDHuffEnc11, + c_aauiLCLDHuffEnc12, + c_aauiLCLDHuffEnc13, + c_aauiLCLDHuffEnc14, + c_aauiLCLDHuffEnc15, + c_aauiLCLDHuffEnc16, + c_aauiLCLDHuffEnc17, + c_aauiLCLDHuffEnc18, + c_aauiLCLDHuffEnc19, + c_aauiLCLDHuffEnc20, + c_aauiLCLDHuffEnc21, + c_aauiLCLDHuffEnc22, + c_aauiLCLDHuffEnc23, + c_aauiLCLDHuffEnc24, + c_aauiLCLDHuffEnc25, + c_aauiLCLDHuffEnc26, + c_aauiLCLDHuffEnc27, + c_aauiLCLDHuffEnc28, + c_aauiLCLDHuffEnc29, + c_aauiLCLDHuffEnc30, + c_aauiLCLDHuffEnc31, + NULL, + c_aauiLCLDHuffEnc33, + c_aauiLCLDHuffEnc34, + c_aauiLCLDHuffEnc35, + c_aauiLCLDHuffEnc36, + c_aauiLCLDHuffEnc37, + c_aauiLCLDHuffEnc38, + c_aauiLCLDHuffEnc39, + c_aauiLCLDHuffEnc40, + c_aauiLCLDHuffEnc41, + c_aauiLCLDHuffEnc42, + c_aauiLCLDHuffEnc43, + c_aauiLCLDHuffEnc44, + c_aauiLCLDHuffEnc45, + c_aauiLCLDHuffEnc46, + c_aauiLCLDHuffEnc47, + c_aauiLCLDHuffEnc48, + c_aauiLCLDHuffEnc49, + c_aauiLCLDHuffEnc50, + c_aauiLCLDHuffEnc51, + c_aauiLCLDHuffEnc52, + c_aauiLCLDHuffEnc53, + c_aauiLCLDHuffEnc54, + c_aauiLCLDHuffEnc55, + c_aauiLCLDHuffEnc56, + c_aauiLCLDHuffEnc57, + c_aauiLCLDHuffEnc58, + c_aauiLCLDHuffEnc59, + c_aauiLCLDHuffEnc60, + c_aauiLCLDHuffEnc61, + c_aauiLCLDHuffEnc62, + c_aauiLCLDHuffEnc63, + }; + +const uint32_t num_row_aauiLCLDHuff[2 * ALLOC_TABLE_SIZE] = { 0, 16, 16, 25, 36, 36, 49, 64, 81, 100, + 169, 196, 289, 324, 400, 576, 729, 729, 28, 29, + 32, 37, 39, 46, 55, 65, 77, 91, 109, 129, + 153, 181, 0, 16, 16, 25, 36, 36, 49, 64, 81, + 100, 169, 196, 289, 324, 400, 576, 729, 729, 28, + 29, 32, 37, 39, 46, 55, 65, 77, 91, 109, + 129, 153, 181 }; + +const int32_t c_aiLogAddTable[LOG_ADD_TABLE_LENGTH] = { + 0x40, + 0x40, + 0x3F, + 0x3F, + 0x3E, + 0x3E, + 0x3D, + 0x3D, + 0x3C, + 0x3C, + 0x3B, + 0x3B, + 0x3A, + 0x3A, + 0x39, + 0x39, + 0x38, + 0x38, + 0x37, + 0x37, + 0x37, + 0x36, + 0x36, + 0x35, + 0x35, + 0x34, + 0x34, + 0x33, + 0x33, + 0x33, + 0x32, + 0x32, + 0x31, + 0x31, + 0x31, + 0x30, + 0x30, + 0x2F, + 0x2F, + 0x2F, + 0x2E, + 0x2E, + 0x2D, + 0x2D, + 0x2D, + 0x2C, + 0x2C, + 0x2B, + 0x2B, + 0x2B, + 0x2A, + 0x2A, + 0x2A, + 0x29, + 0x29, + 0x29, + 0x28, + 0x28, + 0x27, + 0x27, + 0x27, + 0x26, + 0x26, + 0x26, + 0x25, + 0x25, + 0x25, + 0x24, + 0x24, + 0x24, + 0x23, + 0x23, + 0x23, + 0x23, + 0x22, + 0x22, + 0x22, + 0x21, + 0x21, + 0x21, + 0x20, + 0x20, + 0x20, + 0x20, + 0x1F, + 0x1F, + 0x1F, + 0x1E, + 0x1E, + 0x1E, + 0x1E, + 0x1D, + 0x1D, + 0x1D, + 0x1C, + 0x1C, + 0x1C, + 0x1C, + 0x1B, + 0x1B, + 0x1B, + 0x1B, + 0x1A, + 0x1A, + 0x1A, + 0x1A, + 0x19, + 0x19, + 0x19, + 0x19, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x17, + 0x17, + 0x17, + 0x17, + 0x16, + 0x16, + 0x16, + 0x16, + 0x16, + 0x15, + 0x15, + 0x15, + 0x15, + 0x15, + 0x14, + 0x14, + 0x14, + 0x14, + 0x14, + 0x13, + 0x13, + 0x13, + 0x13, + 0x13, + 0x13, + 0x12, + 0x12, + 0x12, + 0x12, + 0x12, + 0x11, + 0x11, + 0x11, + 0x11, + 0x11, + 0x11, + 0x10, + 0x10, + 0x10, + 0x10, + 0x10, + 0x10, + 0x0F, + 0x0F, + 0x0F, + 0x0F, + 0x0F, + 0x0F, + 0x0F, + 0x0E, + 0x0E, + 0x0E, + 0x0E, + 0x0E, + 0x0E, + 0x0E, + 0x0D, + 0x0D, + 0x0D, + 0x0D, + 0x0D, + 0x0D, + 0x0D, + 0x0D, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0B, + 0x0B, + 0x0B, + 0x0B, + 0x0B, + 0x0B, + 0x0B, + 0x0B, + 0x0B, + 0x0A, + 0x0A, + 0x0A, + 0x0A, + 0x0A, + 0x0A, + 0x0A, + 0x0A, + 0x0A, + 0x0A, + 0x09, + 0x09, + 0x09, + 0x09, + 0x09, + 0x09, + 0x09, + 0x09, + 0x09, + 0x09, + 0x08, + 0x08, + 0x08, + 0x08, + 0x08, + 0x08, + 0x08, + 0x08, + 0x08, + 0x08, + 0x08, + 0x08, + 0x08, + 0x07, + 0x07, + 0x07, + 0x07, + 0x07, + 0x07, + 0x07, + 0x07, + 0x07, + 0x07, + 0x07, + 0x07, + 0x07, + 0x06, + 0x06, + 0x06, + 0x06, + 0x06, + 0x06, + 0x06, + 0x06, + 0x06, + 0x06, + 0x06, + 0x06, + 0x06, + 0x06, + 0x06, + 0x06, + 0x05, + 0x05, + 0x05, + 0x05, + 0x05, + 0x05, + 0x05, + 0x05, + 0x05, + 0x05, + 0x05, + 0x05, + 0x05, + 0x05, + 0x05, + 0x05, + 0x05, + 0x05, + 0x05, + 0x04, + 0x04, + 0x04, + 0x04, + 0x04, + 0x04, + 0x04, + 0x04, + 0x04, + 0x04, + 0x04, + 0x04, + 0x04, + 0x04, + 0x04, + 0x04, + 0x04, + 0x04, + 0x04, + 0x04, + 0x04, + 0x04, + 0x04, + 0x04, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x03, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x02, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x01, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, +}; + +const int32_t c_aiBandwidthAdjust48[MAX_BANDS_48] = { + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 64, + 64, + 64, + 64, + 64, + 101, + 101, + 128, + 165, + 165, + 180, + 213, +}; + +const int32_t c_aiAbsoluteThresh48[MAX_BANDS_48] = { + -1787, + -1787, + -1787, + -1787, + -1787, + -1787, + -1787, + -1787, + -1782, + -1761, + -1737, + -1679, + -1638, + -1613, + -1590, + -1568, + -1516, + -1459, + -1395, + -1289, + -671, + -409, + -401, +}; + + +#if PERCEPTUAL_MODEL_SLGAIN_SHIFT == 4 +const int32_t c_aiDefaultTheta48[MAX_BANDS_48] = { + 7, + 7, + 6, + 5, + 5, + 4, + 4, + 4, + 4, + 4, + 4, + 4, + 4, + 4, + 4, + 4, + 4, + 4, + 4, + 4, + 4, + 4, + 4, +}; +#elif PERCEPTUAL_MODEL_SLGAIN_SHIFT == 8 +const int32_t c_aiDefaultTheta48[MAX_BANDS_48] = { + 112, + 112, + 96, + 80, + 80, + 64, + 64, + 64, + 64, + 64, + 64, + 64, + 64, + 64, + 64, + 64, + 64, + 64, + 64, + 64, + 64, + 64, + 64, +}; +#endif + +const int32_t c_aaiSpreadFunction48[MAX_BANDS_48 * MAX_BANDS_48] = { + 0, + -1561, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -289, + -4, + -1234, + -2295, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -569, + -229, + -8, + -905, + -1705, + -2324, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -789, + -445, + -173, + -16, + -656, + -1271, + -1765, + -2172, + -2520, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -961, + -616, + -340, + -136, + -28, + -488, + -976, + -1382, + -1729, + -2032, + -2305, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -1088, + -743, + -465, + -257, + -148, + -31, + -371, + -769, + -1114, + -1417, + -1689, + -2054, + -2483, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -1198, + -852, + -574, + -364, + -209, + -148, + -42, + -300, + -635, + -936, + -1207, + -1572, + -2000, + -2376, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -1293, + -948, + -669, + -458, + -301, + -183, + -145, + -56, + -258, + -547, + -816, + -1179, + -1606, + -1982, + -2311, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -1375, + -1029, + -750, + -539, + -381, + -260, + -180, + -142, + -68, + -231, + -487, + -846, + -1272, + -1647, + -1976, + -2261, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -1444, + -1099, + -820, + -608, + -449, + -328, + -233, + -194, + -138, + -77, + -213, + -555, + -978, + -1352, + -1681, + -1966, + -2268, + -2552, + -2552, + -2552, + -2552, + -2552, + -2552, + -1501, + -1155, + -876, + -665, + -505, + -383, + -287, + -210, + -193, + -130, + -79, + -298, + -711, + -1083, + -1411, + -1696, + -1997, + -2288, + -2550, + -2552, + -2552, + -2552, + -2552, + -1567, + -1221, + -942, + -730, + -570, + -448, + -351, + -272, + -206, + -189, + -151, + -72, + -349, + -713, + -1039, + -1324, + -1625, + -1915, + -2177, + -2448, + -2552, + -2552, + -2552, + -1650, + -1304, + -1025, + -813, + -653, + -530, + -432, + -352, + -285, + -227, + -177, + -163, + -69, + -297, + -613, + -895, + -1195, + -1485, + -1746, + -2017, + -2238, + -2401, + -2545, + -1727, + -1381, + -1102, + -890, + -730, + -607, + -509, + -428, + -360, + -301, + -249, + -180, + -153, + -72, + -257, + -527, + -824, + -1112, + -1373, + -1643, + -1865, + -2028, + -2171, + -1798, + -1452, + -1173, + -960, + -800, + -677, + -579, + -498, + -430, + -370, + -317, + -246, + -192, + -145, + -76, + -224, + -505, + -790, + -1050, + -1320, + -1540, + -1703, + -1847, + -1860, + -1514, + -1234, + -1022, + -862, + -738, + -640, + -559, + -490, + -430, + -377, + -306, + -224, + -197, + -136, + -81, + -242, + -515, + -771, + -1040, + -1260, + -1422, + -1566, + -1923, + -1577, + -1297, + -1085, + -925, + -801, + -703, + -621, + -553, + -492, + -439, + -367, + -284, + -213, + -198, + -144, + -83, + -235, + -479, + -744, + -963, + -1125, + -1268, + -1986, + -1640, + -1360, + -1148, + -988, + -864, + -766, + -684, + -615, + -555, + -501, + -429, + -345, + -273, + -211, + -204, + -146, + -89, + -216, + -465, + -680, + -841, + -984, + -2043, + -1697, + -1417, + -1205, + -1044, + -921, + -822, + -741, + -672, + -611, + -557, + -485, + -401, + -328, + -264, + -211, + -205, + -140, + -93, + -227, + -430, + -588, + -729, + -2104, + -1758, + -1479, + -1266, + -1106, + -982, + -884, + -802, + -733, + -673, + -619, + -546, + -461, + -388, + -324, + -269, + -212, + -211, + -151, + -100, + -195, + -336, + -472, + -2163, + -1817, + -1537, + -1324, + -1164, + -1040, + -942, + -860, + -791, + -731, + -676, + -604, + -519, + -445, + -380, + -325, + -268, + -226, + -219, + -147, + -114, + -167, + -280, + -2203, + -1857, + -1577, + -1365, + -1205, + -1081, + -982, + -901, + -831, + -771, + -717, + -644, + -559, + -485, + -420, + -364, + -306, + -252, + -239, + -206, + -132, + -122, + -163, + -2224, + -1878, + -1598, + -1386, + -1225, + -1102, + -1003, + -921, + -852, + -792, + -737, + -665, + -580, + -505, + -441, + -385, + -326, + -271, + -222, + -224, + -176, + -121, + -114, +}; +#endif diff --git a/lib_isar/isar_rom_lcld_tables.h b/lib_isar/isar_rom_lcld_tables.h new file mode 100644 index 0000000000000000000000000000000000000000..59e047ffa7109c26a00fcc16bb3d86a9a2bdf2be --- /dev/null +++ b/lib_isar/isar_rom_lcld_tables.h @@ -0,0 +1,197 @@ +/****************************************************************************************************** + + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#ifndef ISAR_ROM_LCLD_TABLES_H +#define ISAR_ROM_LCLD_TABLES_H + +#include +#include "options.h" + +#ifdef SPLIT_REND_WITH_HEAD_ROT +#ifndef M_PI + +#define M_PI 3.14159265358979323846264338327950288f + +#endif + +#define LCLD_BLOCKS_PER_FRAME ( 16 ) +#define LCLD_MAX_BLOCKS_PER_FRAME ( 16 ) +#define LCLD_BANDS ( 60 ) +#define LCLD_PRED_WIN_LEN ( 16 ) +#define LCLD_MAX_NUM_PRED_SUBSETS ( 8 ) +#define MAX_BANDS ( 23 ) +#define MAX_BANDS_48 ( 23 ) +#define DEF_BANDS_48 ( 22 ) + +#define ENV_MIN ( -64 ) +#define ENV_MAX ( 64 ) + +#define ENV0_BITS ( 7 ) + +#define ENV_DELTA_MIN ( -32 ) +#define ENV_DELTA_MAX ( 31 ) + +#define ENV_RECONSTRUCT_TABLE_SIZE ( 129 ) + +#define ENV_RECONSTRUCT_TABLE_CENTER ( 64 ) + +#define MIN_ALLOC ( 0 ) +#define MAX_ALLOC ( 31 ) + +#define ALLOC_OFFSET_SCALE ( 8 ) + +#define ALLOC_OFFSET_BITS ( 8 ) + +#define MIN_ALLOC_OFFSET ( -128 ) +#define MAX_ALLOC_OFFSET ( 127 ) +#define READ_LENGTH ( 4 ) + +#define ALLOC_TABLE_SIZE ( 32 ) + +#ifndef _PI_ +#define _PI_ ( 3.14159265358979f ) +#endif +#define PRED_MAX_VAL ( 12 ) +#define PRED_MIN_VAL ( -PRED_MAX_VAL ) +#define PRED_QUANT_FACTOR ( (float) PRED_MAX_VAL ) +#define PRED_BAND0_BITS ( 5 ) + +#define PHASE_MAX_VAL ( 12 ) +#define PHASE_MIN_VAL ( -PHASE_MAX_VAL ) +#define PHASE_QUANT_FACTOR ( (float) PHASE_MAX_VAL / _PI_ ) +#define PHASE_DIFF_DIM ( 2 ) +#define PHASE_BAND0_BITS ( 5 ) + +#define PERCEPTUAL_MODEL_SLGAIN_SHIFT ( 8 ) + +#define HUFF_DEC_TABLE_SIZE ( 16 ) + +extern const int32_t c_aiNumLcldBandsPerBand[MAX_BANDS_48]; +extern const int32_t c_aiBandIdPerLcldBand[LCLD_BANDS]; +extern const float c_afRotRealImag[PRED_MAX_VAL - PRED_MIN_VAL + 1][2]; +extern const int32_t c_aiDefaultTheta48[MAX_BANDS_48]; + +extern const float c_afScaleFactor[ALLOC_TABLE_SIZE]; +extern const float c_afInvScaleFactor[ALLOC_TABLE_SIZE]; +extern const float c_afRMSEnvReconstructTable[ENV_RECONSTRUCT_TABLE_SIZE]; +extern const int32_t c_aiQuantMaxValues[ALLOC_TABLE_SIZE]; +extern const int32_t c_aiHuffmanDim[ALLOC_TABLE_SIZE]; +extern const int32_t c_aiHuffmanMod[ALLOC_TABLE_SIZE]; +extern const int32_t c_aiHuffmanSize[ALLOC_TABLE_SIZE]; + + +#define LOG_ADD_TABLE_LENGTH ( 512 ) + +extern const int32_t c_aiBandwidths48[MAX_BANDS_48]; +extern const int32_t c_aiLogAddTable[LOG_ADD_TABLE_LENGTH]; +extern const int32_t c_aiBandwidthAdjust48[MAX_BANDS_48]; +extern const int32_t c_aiAbsoluteThresh48[MAX_BANDS_48]; +extern const int32_t c_aiDefaultTheta48[MAX_BANDS_48]; +extern const int32_t c_aaiSpreadFunction48[MAX_BANDS_48 * MAX_BANDS_48]; + + +#define PRED_QUNAT_FILTER_MAG_BITS ( 3 ) +#define PRED_QUANT_FILTER_PHASE_BITS ( 5 ) +#define PRED_QUANT_FILTER_MAG_MIN ( 0 ) +#define PRED_QUANT_FILTER_MAG_MAX ( 7 ) +#define PRED_QUANT_FILTER_PHASE_MIN ( -16 ) +#define PRED_QUANT_FILTER_PHASE_MAX ( 15 ) + +extern const uint16_t c_aauiLCLDHuffEnc1[16][2]; +extern const uint16_t c_aauiLCLDHuffEnc2[16][2]; +extern const uint16_t c_aauiLCLDHuffEnc3[25][2]; +extern const uint16_t c_aauiLCLDHuffEnc4[36][2]; +extern const uint16_t c_aauiLCLDHuffEnc5[36][2]; +extern const uint16_t c_aauiLCLDHuffEnc6[49][2]; +extern const uint16_t c_aauiLCLDHuffEnc7[64][2]; +extern const uint16_t c_aauiLCLDHuffEnc8[81][2]; +extern const uint16_t c_aauiLCLDHuffEnc9[100][2]; +extern const uint16_t c_aauiLCLDHuffEnc10[169][2]; +extern const uint16_t c_aauiLCLDHuffEnc11[196][2]; +extern const uint16_t c_aauiLCLDHuffEnc12[289][2]; +extern const uint16_t c_aauiLCLDHuffEnc13[324][2]; +extern const uint16_t c_aauiLCLDHuffEnc14[400][2]; +extern const uint16_t c_aauiLCLDHuffEnc15[576][2]; +extern const uint16_t c_aauiLCLDHuffEnc16[729][2]; +extern const uint16_t c_aauiLCLDHuffEnc17[729][2]; +extern const uint16_t c_aauiLCLDHuffEnc18[28][2]; +extern const uint16_t c_aauiLCLDHuffEnc19[29][2]; +extern const uint16_t c_aauiLCLDHuffEnc20[32][2]; +extern const uint16_t c_aauiLCLDHuffEnc21[37][2]; +extern const uint16_t c_aauiLCLDHuffEnc22[39][2]; +extern const uint16_t c_aauiLCLDHuffEnc23[46][2]; +extern const uint16_t c_aauiLCLDHuffEnc24[55][2]; +extern const uint16_t c_aauiLCLDHuffEnc25[65][2]; +extern const uint16_t c_aauiLCLDHuffEnc26[77][2]; +extern const uint16_t c_aauiLCLDHuffEnc27[91][2]; +extern const uint16_t c_aauiLCLDHuffEnc28[109][2]; +extern const uint16_t c_aauiLCLDHuffEnc29[129][2]; +extern const uint16_t c_aauiLCLDHuffEnc30[153][2]; +extern const uint16_t c_aauiLCLDHuffEnc31[181][2]; +extern const uint16_t c_aauiLCLDHuffEnc33[16][2]; +extern const uint16_t c_aauiLCLDHuffEnc34[16][2]; +extern const uint16_t c_aauiLCLDHuffEnc35[25][2]; +extern const uint16_t c_aauiLCLDHuffEnc36[36][2]; +extern const uint16_t c_aauiLCLDHuffEnc37[36][2]; +extern const uint16_t c_aauiLCLDHuffEnc38[49][2]; +extern const uint16_t c_aauiLCLDHuffEnc39[64][2]; +extern const uint16_t c_aauiLCLDHuffEnc40[81][2]; +extern const uint16_t c_aauiLCLDHuffEnc41[100][2]; +extern const uint16_t c_aauiLCLDHuffEnc42[169][2]; +extern const uint16_t c_aauiLCLDHuffEnc43[196][2]; +extern const uint16_t c_aauiLCLDHuffEnc44[289][2]; +extern const uint16_t c_aauiLCLDHuffEnc45[324][2]; +extern const uint16_t c_aauiLCLDHuffEnc46[400][2]; +extern const uint16_t c_aauiLCLDHuffEnc47[576][2]; +extern const uint16_t c_aauiLCLDHuffEnc48[729][2]; +extern const uint16_t c_aauiLCLDHuffEnc49[729][2]; +extern const uint16_t c_aauiLCLDHuffEnc50[28][2]; +extern const uint16_t c_aauiLCLDHuffEnc51[29][2]; +extern const uint16_t c_aauiLCLDHuffEnc52[32][2]; +extern const uint16_t c_aauiLCLDHuffEnc53[37][2]; +extern const uint16_t c_aauiLCLDHuffEnc54[39][2]; +extern const uint16_t c_aauiLCLDHuffEnc55[46][2]; +extern const uint16_t c_aauiLCLDHuffEnc56[55][2]; +extern const uint16_t c_aauiLCLDHuffEnc57[65][2]; +extern const uint16_t c_aauiLCLDHuffEnc58[77][2]; +extern const uint16_t c_aauiLCLDHuffEnc59[91][2]; +extern const uint16_t c_aauiLCLDHuffEnc60[109][2]; +extern const uint16_t c_aauiLCLDHuffEnc61[129][2]; +extern const uint16_t c_aauiLCLDHuffEnc62[153][2]; +extern const uint16_t c_aauiLCLDHuffEnc63[181][2]; +extern const uint16_t ( *c_apauiHuffEncTabels[2 * ALLOC_TABLE_SIZE] )[2]; +extern const uint32_t num_row_aauiLCLDHuff[2 * ALLOC_TABLE_SIZE]; +extern const uint32_t c_aaiRMSEnvHuffEnc[64][2]; +extern const uint32_t c_aaiRMSEnvHuffDec[13][HUFF_DEC_TABLE_SIZE]; +#endif /*SPLIT_REND_WITH_HEAD_ROT*/ + +#endif /* ISAR_ROM_LCLD_TABLES_H_ */ diff --git a/lib_isar/isar_rom_post_rend.c b/lib_isar/isar_rom_post_rend.c new file mode 100644 index 0000000000000000000000000000000000000000..1da467d36c2f290c7621448eefdab73ff7ede2d6 --- /dev/null +++ b/lib_isar/isar_rom_post_rend.c @@ -0,0 +1,182 @@ +/****************************************************************************************************** + + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#include +#include "options.h" +#ifdef DEBUGGING +#include "debug.h" +#endif +#include "isar_cnst.h" +#include "wmc_auto.h" + +/* clang-format off */ + + +#ifdef SPLIT_REND_WITH_HEAD_ROT +/*----------------------------------------------------------------------* + * Binuaral split rendering ROM tables + *-----------------------------------------------------------------------*/ + +/* rotations in this array are relative to ref rotation */ +const float isar_split_rend_relative_yaw_pos_angles[SPLIT_REND_MAX_YAW_ONLY_POSES] = {-15.0f, 15.0f}; +const float isar_split_rend_relative_pitch_pos_angles[SPLIT_REND_MAX_PITCH_ONLY_POSES] = {10.0f, 10.0f}; +const float isar_split_rend_relative_roll_pos_angles[SPLIT_REND_MAX_PITCH_ONLY_POSES] = {10.0f, 10.0f}; +const float isar_split_rend_relative_one_axis_pos_angles[SPLIT_REND_MAX_ONE_AXIS_MD_POSES] = {-15.0f, 15.0f}; + +const float isar_split_rend_relative_yaw_pos_angles_hq[SPLIT_REND_MAX_YAW_ONLY_POSES] = {-15.0f, 15.0f}; +const float isar_split_rend_relative_pitch_pos_angles_hq[SPLIT_REND_MAX_PITCH_ONLY_POSES] = {-15.0f, 15.0f}; +const float isar_split_rend_relative_roll_pos_angles_hq[SPLIT_REND_MAX_PITCH_ONLY_POSES] = {-15.0f, 15.0f}; +const float isar_split_rend_relative_one_axis_pos_angles_hq[SPLIT_REND_MAX_ONE_AXIS_MD_POSES] = {-15.0f, 15.0f}; + +const int16_t isar_split_rend_band_grouping[MAX_SPLIT_REND_MD_BANDS + 1] = +{ + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 20, 25, 30, 35, 40, 50, 60 +}; + +const int32_t isar_split_rend_huff_p_d_consts[ISAR_SPLIT_REND_D_QUANT_PNTS][3] = +{ + {0,8,252},{1,8,253},{2,7,124},{3,6,60},{4,5,28},{5,4,12}, + {6,3,4},{7,1,0},{8,3,5},{9,4,13},{10,5,29},{11,6,61}, + {12,7,125},{13,8,254},{14,8,255} +}; + +const int32_t isar_split_rend_huff_p_d_diff_consts[ISAR_SPLIT_REND_D_QUANT_PNTS][3] = +{ + { 0, 1, 0 },{ 1, 2, 2 },{ 2, 3, 6 },{ 3, 4, 14 }, + { 4, 5, 30 },{ 5, 6, 62 },{ 6, 7, 126 },{ 7, 8, 254 }, + { 8, 9, 510 },{ 9, 10, 1022 },{ 10, 11, 2046 },{ 11, 12, 4094 }, + { 12, 13, 8190 },{ 13, 14, 16382 },{ 14, 14, 16383 } +}; + +const int32_t isar_split_rend_huff_d_consts[ISAR_SPLIT_REND_D_QUANT_PNTS][3] = +{ + { 0, 1, 0 },{ 1, 2, 2 },{ 2, 3, 6 },{ 3, 4, 14 }, + { 4, 5, 30 },{ 5, 6, 62 },{ 6, 7, 126 },{ 7, 8, 254 }, + { 8, 9, 510 },{ 9, 10, 1022 },{ 10, 11, 2046 },{ 11, 12, 4094 }, + { 12, 13, 8190 },{ 13, 14, 16382 },{ 14, 14, 16383 } +}; + +const int32_t isar_split_rend_huff_pred63_consts[ISAR_SPLIT_REND_PRED_63QUANT_PNTS][3] = +{ + {-31,11,2040}, + {-30,11,2041}, + {-29,11,2042}, + {-28,11,2043}, + {-27,10,1012}, + {-26,10,1013}, + {-25,10,1014}, + {-24,10,1015}, + {-23,9,498}, + {-22,9,499}, + {-21,9,500}, + {-20,9,501}, + {-19,8,242}, + {-18,8,243}, + {-17,8,244}, + {-16,8,245}, + {-15,7,112}, + {-14,7,113}, + {-13,7,114}, + {-12,7,115}, + {-11,6,48}, + {-10,6,49}, + {-9,6,50}, + {-8,6,51}, + {-7,5,16}, + {-6,5,17}, + {-5,5,18}, + {-4,5,19}, + {-3,4,2}, + {-2,4,3}, + {-1,4,4}, + {0,3,0}, + {1,4,5}, + {2,4,6}, + {3,4,7}, + {4,5,20}, + {5,5,21}, + {6,5,22}, + {7,5,23}, + {8,6,52}, + {9,6,53}, + {10,6,54}, + {11,6,55}, + {12,7,116}, + {13,7,117}, + {14,7,118}, + {15,7,119}, + {16,7,120}, + {17,8,246}, + {18,8,247}, + {19,8,248}, + {20,9,502}, + {21,9,503}, + {22,9,504}, + {23,9,505}, + {24,10,1016}, + {25,10,1017}, + {26,10,1018}, + {27,10,1019}, + {28,11,2044}, + {29,11,2045}, + {30,11,2046}, + {31,11,2047}, +}; + +const int32_t isar_split_rend_huff_pred31_consts[ISAR_SPLIT_REND_PRED_31QUANT_PNTS][3] = +{ + {-15,10,1020},{-14,10,1021},{-13,9,506},{-12,9,507}, + {-11,8,250},{-10,8,251},{-9,7,120},{-8,7,121}, + {-7,6,56},{-6,6,57},{-5,5,24},{-4,5,25},{-3,4,8}, + {-2,4,9},{-1,3,2},{0,2,0},{1,3,3}, + {2,4,10},{3,4,11},{4,5,26},{5,5,27}, + {6,6,58},{7,6,59},{8,7,122},{9,7,123}, + {10,7,124},{11,8,252},{12,9,508},{13,9,509}, + {14,10,1022},{15,10,1023}, +}; + +const int32_t isar_split_rend_huff_roll_pred_consts[ISAR_SPLIT_REND_ROLL_PRED_QUANT_PNTS][3] = +{ + {-15,10,1020},{-14,10,1021},{-13,9,506},{-12,9,507}, + {-11,8,250},{-10,8,251},{-9,7,120},{-8,7,121}, + {-7,6,56},{-6,6,57},{-5,5,24},{-4,5,25},{-3,4,8}, + {-2,4,9},{-1,3,2},{0,2,0},{1,3,3}, + {2,4,10},{3,4,11},{4,5,26},{5,5,27}, + {6,6,58},{7,6,59},{8,7,122},{9,7,123}, + {10,7,124},{11,8,252},{12,9,508},{13,9,509}, +{14,10,1022},{15,10,1023}, +}; + +#endif + + +/* clang-format on */ diff --git a/lib_isar/isar_rom_post_rend.h b/lib_isar/isar_rom_post_rend.h new file mode 100644 index 0000000000000000000000000000000000000000..83b3e476fbc2a1020726196a1d85c753998b0907 --- /dev/null +++ b/lib_isar/isar_rom_post_rend.h @@ -0,0 +1,69 @@ +/****************************************************************************************************** + + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#ifndef ISAR_ROM_POST_REND_H +#define ISAR_ROM_POST_REND_H + +#include +#include "options.h" +#ifdef DEBUGGING +#include "debug.h" +#endif +#include "isar_cnst.h" + + +#ifdef SPLIT_REND_WITH_HEAD_ROT +/*----------------------------------------------------------------------* + * Binuaral split rendering ROM tables + *-----------------------------------------------------------------------*/ + +extern const float isar_split_rend_relative_yaw_pos_angles[SPLIT_REND_MAX_YAW_ONLY_POSES]; +extern const float isar_split_rend_relative_pitch_pos_angles[SPLIT_REND_MAX_PITCH_ONLY_POSES]; +extern const float isar_split_rend_relative_roll_pos_angles[SPLIT_REND_MAX_PITCH_ONLY_POSES]; +extern const float isar_split_rend_relative_one_axis_pos_angles[SPLIT_REND_MAX_ONE_AXIS_MD_POSES]; +extern const float isar_split_rend_relative_one_axis_pos_angles_hq[SPLIT_REND_MAX_ONE_AXIS_MD_POSES]; + +extern const float isar_split_rend_relative_yaw_pos_angles_hq[SPLIT_REND_MAX_YAW_ONLY_POSES]; +extern const float isar_split_rend_relative_pitch_pos_angles_hq[SPLIT_REND_MAX_PITCH_ONLY_POSES]; +extern const float isar_split_rend_relative_roll_pos_angles_hq[SPLIT_REND_MAX_PITCH_ONLY_POSES]; + +extern const float ivas_split_rend_relative_pos_angles[MAX_HEAD_ROT_POSES][3]; +extern const int16_t isar_split_rend_band_grouping[MAX_SPLIT_REND_MD_BANDS + 1]; +extern const int32_t isar_split_rend_huff_d_consts[ISAR_SPLIT_REND_D_QUANT_PNTS][3]; +extern const int32_t isar_split_rend_huff_pred63_consts[ISAR_SPLIT_REND_PRED_31QUANT_PNTS][3]; +extern const int32_t isar_split_rend_huff_pred31_consts[ISAR_SPLIT_REND_PRED_31QUANT_PNTS][3]; +extern const int32_t isar_split_rend_huff_roll_pred_consts[ISAR_SPLIT_REND_ROLL_PRED_QUANT_PNTS][3]; +extern const int32_t isar_split_rend_huff_p_d_consts[ISAR_SPLIT_REND_D_QUANT_PNTS][3]; +extern const int32_t isar_split_rend_huff_p_d_diff_consts[ISAR_SPLIT_REND_D_QUANT_PNTS][3]; +#endif + +#endif diff --git a/lib_isar/isar_splitRend_lcld_dec.c b/lib_isar/isar_splitRend_lcld_dec.c new file mode 100644 index 0000000000000000000000000000000000000000..939cdaa1ef6a70e9723d1f1c3f89dc89a82d0d70 --- /dev/null +++ b/lib_isar/isar_splitRend_lcld_dec.c @@ -0,0 +1,258 @@ +/****************************************************************************************************** + + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#include +#include "options.h" +#ifdef SPLIT_REND_WITH_HEAD_ROT +#include "isar_prot.h" +#include "ivas_prot.h" +#include "prot.h" +#ifdef DEBUGGING +#include "debug.h" +#endif +#include "wmc_auto.h" + + +/*------------------------------------------------------------------------- + * Function isar_splitBinLCLDDecOpen() + * + * + *------------------------------------------------------------------------*/ + +ivas_error isar_splitBinLCLDDecOpen( + ISAR_BIN_HR_SPLIT_LCLD_DEC_HANDLE *hSplitBinLCLDDec, + const int32_t iSampleRate, + const int16_t iChannels, + const int16_t iNumBlocks, + const int16_t iNumIterations ) +{ + int16_t n; + ISAR_BIN_HR_SPLIT_LCLD_DEC_HANDLE splitBinLCLDDec; + ivas_error error; + + if ( ( splitBinLCLDDec = (ISAR_BIN_HR_SPLIT_LCLD_DEC_HANDLE) malloc( sizeof( ISAR_BIN_HR_SPLIT_LCLD_DEC ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD decoder Module \n" ) ); + } + + splitBinLCLDDec->pLcld_dec = NULL; /* place holder for CLDFB decoder handle */ + + splitBinLCLDDec->iChannels = iChannels; + + if ( ( error = CreateLCLDDecoder( &splitBinLCLDDec->psLCLDDecoder, iSampleRate, iChannels, iNumBlocks, 0 ) ) != IVAS_ERR_OK ) + { + return error; + } + + if ( ( splitBinLCLDDec->pppfDecLCLDReal = (float ***) malloc( iChannels * sizeof( float ** ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD decoder Module \n" ) ); + } + if ( ( splitBinLCLDDec->pppfDecLCLDImag = (float ***) malloc( iChannels * sizeof( float ** ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD decoder Module \n" ) ); + } + + for ( n = 0; n < splitBinLCLDDec->iChannels; n++ ) + { + if ( ( splitBinLCLDDec->pppfDecLCLDReal[n] = (float **) malloc( CLDFB_NO_COL_MAX * sizeof( float * ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD decoder Module \n" ) ); + } + if ( ( splitBinLCLDDec->pppfDecLCLDImag[n] = (float **) malloc( CLDFB_NO_COL_MAX * sizeof( float * ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD decoder Module \n" ) ); + } + } + +#ifdef CLDFB_DEBUG + splitBinLCLDDec->numFrame = 0; + char cldfbFilename[50] = "cldfb_out.bin"; + if ( ( splitBinLCLDDec->cldfbOut = fopen( cldfbFilename, "wb" ) ) == NULL ) + { + fprintf( stderr, "Error: CLDFB bitstream file %s could not be opened\n\n", cldfbFilename ); + exit( -1 ); + } + int16_t num_bands = CLDFB_NO_CHANNELS_MAX; + fwrite( &iChannels, sizeof( int16_t ), 1, splitBinLCLDDec->cldfbOut ); + fwrite( &num_bands, sizeof( int16_t ), 1, splitBinLCLDDec->cldfbOut ); +#endif + + if ( ( error = isar_splitBinRendPLCOpen( &splitBinLCLDDec->hSplitRendPLC, GetNumSubSets( splitBinLCLDDec->psLCLDDecoder ) ) ) != IVAS_ERR_OK ) + { + return error; + } + splitBinLCLDDec->iNumBlocks = iNumBlocks; + splitBinLCLDDec->iNumIterations = iNumIterations; + + *hSplitBinLCLDDec = splitBinLCLDDec; + + return IVAS_ERR_OK; +} + + +/*------------------------------------------------------------------------- + * Function isar_splitBinLCLDDecClose() + * + * + *------------------------------------------------------------------------*/ + +void isar_splitBinLCLDDecClose( + ISAR_BIN_HR_SPLIT_LCLD_DEC_HANDLE *hSplitBinLCLDDec ) +{ + int16_t n; + + if ( ( *hSplitBinLCLDDec ) != NULL ) + { + if ( ( *hSplitBinLCLDDec )->psLCLDDecoder != NULL ) + { + DeleteLCLDDecoder( ( *hSplitBinLCLDDec )->psLCLDDecoder ); + } + + for ( n = 0; n < ( *hSplitBinLCLDDec )->iChannels; n++ ) + { + free( ( *hSplitBinLCLDDec )->pppfDecLCLDReal[n] ); + free( ( *hSplitBinLCLDDec )->pppfDecLCLDImag[n] ); + } + free( ( *hSplitBinLCLDDec )->pppfDecLCLDReal ); + free( ( *hSplitBinLCLDDec )->pppfDecLCLDImag ); + +#ifdef CLDFB_DEBUG + if ( ( *hSplitBinLCLDDec )->cldfbOut != NULL ) + { + fclose( ( *hSplitBinLCLDDec )->cldfbOut ); + } +#endif + isar_splitBinRendPLCClose( &( *hSplitBinLCLDDec )->hSplitRendPLC ); + + free( *hSplitBinLCLDDec ); + *hSplitBinLCLDDec = NULL; + } + + return; +} + + +/*------------------------------------------------------------------------- + * Function isar_splitBinLCLDDecProcess() + * + * + *------------------------------------------------------------------------*/ + +void isar_splitBinLCLDDecProcess( + ISAR_BIN_HR_SPLIT_LCLD_DEC_HANDLE hSplitBinLCLDDec, + ISAR_SPLIT_REND_BITS_HANDLE pBits, + float Cldfb_Out_Real[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + float Cldfb_Out_Imag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + const int16_t bfi ) +{ + int16_t k, n; + int16_t itr; + push_wmops( "isar_splitBinLCLDDecProcess" ); + + assert( hSplitBinLCLDDec != NULL ); + assert( Cldfb_Out_Real != NULL ); + assert( Cldfb_Out_Imag != NULL ); + assert( pBits != NULL ); + +#ifdef CLDFB_DEBUG + printf( "Bytes read = %d\n", iBytesWritten ); +#endif + if ( !bfi ) + { + for ( itr = 0; itr < hSplitBinLCLDDec->iNumIterations; itr++ ) + { + /* Initialized with zeros....... */ + for ( n = 0; n < hSplitBinLCLDDec->iChannels; n++ ) + { + for ( k = 0; k < hSplitBinLCLDDec->iNumBlocks; k++ ) + { + hSplitBinLCLDDec->pppfDecLCLDReal[n][k] = Cldfb_Out_Real[n][hSplitBinLCLDDec->iNumBlocks * itr + k]; + hSplitBinLCLDDec->pppfDecLCLDImag[n][k] = Cldfb_Out_Imag[n][hSplitBinLCLDDec->iNumBlocks * itr + k]; + set_f( hSplitBinLCLDDec->pppfDecLCLDReal[n][k], 0, CLDFB_NO_CHANNELS_MAX ); + set_f( hSplitBinLCLDDec->pppfDecLCLDImag[n][k], 0, CLDFB_NO_CHANNELS_MAX ); + } + } + + DecodeLCLDFrame( hSplitBinLCLDDec->psLCLDDecoder, pBits, hSplitBinLCLDDec->pppfDecLCLDReal, hSplitBinLCLDDec->pppfDecLCLDImag ); + +#ifdef CLDFB_DEBUG + printf( "Frame Decoded = %d\n", ++hSplitBinLCLDDec->numFrame ); + int16_t writeByte = 0; + for ( k = 0; k < CLDFB_NO_COL_MAX; k++ ) + { + for ( int16_t b = 0; b < CLDFB_NO_CHANNELS_MAX; b++ ) + { + for ( n = 0; n < hSplitBinLCLDDec->iChannels; n++ ) + { + writeByte = fwrite( &hSplitBinLCLDDec->pppfDecLCLDReal[n][k][b], sizeof( float ), 1, hSplitBinLCLDDec->cldfbOut ); + if ( writeByte != 1 ) + exit( -1 ); + writeByte = fwrite( &hSplitBinLCLDDec->pppfDecLCLDImag[n][k][b], sizeof( float ), 1, hSplitBinLCLDDec->cldfbOut ); + if ( writeByte != 1 ) + exit( -1 ); + } + } + } +#endif + if ( AnyDecodingFailed( hSplitBinLCLDDec->psLCLDDecoder ) ) + { + /* continue concealing */ + isar_splitBinRendPLC( hSplitBinLCLDDec->hSplitRendPLC, Cldfb_Out_Real, Cldfb_Out_Imag, (int16_t) hSplitBinLCLDDec->iChannels, hSplitBinLCLDDec->iNumBlocks, + hSplitBinLCLDDec->iNumIterations, GetDecodingFailedStatus( hSplitBinLCLDDec->psLCLDDecoder ) ); + } + if ( AnyDecodingFailedPrev( hSplitBinLCLDDec->psLCLDDecoder ) ) + { + /* cross-fade recovered frame into good frame */ + isar_splitBinRendPLC_xf( hSplitBinLCLDDec->hSplitRendPLC, Cldfb_Out_Real, Cldfb_Out_Imag, (int16_t) hSplitBinLCLDDec->iChannels, hSplitBinLCLDDec->iNumBlocks, + hSplitBinLCLDDec->iNumIterations, GetDecodingFailedStatus( hSplitBinLCLDDec->psLCLDDecoder ), GetDecodingFailedPrevStatus( hSplitBinLCLDDec->psLCLDDecoder ) ); + } + } + } + else + { + /* set states in decoder */ + SetDecodingUnresolved( hSplitBinLCLDDec->psLCLDDecoder ); + + /* do PLC for lost split renderer frame */ + isar_splitBinRendPLC( hSplitBinLCLDDec->hSplitRendPLC, Cldfb_Out_Real, Cldfb_Out_Imag, (int16_t) hSplitBinLCLDDec->iChannels, hSplitBinLCLDDec->iNumBlocks, + hSplitBinLCLDDec->iNumIterations, GetDecodingFailedStatus( hSplitBinLCLDDec->psLCLDDecoder ) ); + } + + /* save PLC state */ + isar_splitBinRendPLCsaveState( hSplitBinLCLDDec->hSplitRendPLC, Cldfb_Out_Real, Cldfb_Out_Imag, (int16_t) hSplitBinLCLDDec->iChannels, hSplitBinLCLDDec->iNumBlocks, hSplitBinLCLDDec->iNumIterations ); + + pop_wmops(); + + return; +} +#endif diff --git a/lib_isar/isar_splitRend_lcld_enc.c b/lib_isar/isar_splitRend_lcld_enc.c new file mode 100644 index 0000000000000000000000000000000000000000..a3c0ac6bd9d7346dae41b52a70f29cd2362b4b09 --- /dev/null +++ b/lib_isar/isar_splitRend_lcld_enc.c @@ -0,0 +1,242 @@ +/****************************************************************************************************** + + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#include +#include "options.h" +#ifdef SPLIT_REND_WITH_HEAD_ROT +#include "isar_prot.h" +#include "ivas_prot.h" +#ifdef DEBUGGING +#include "debug.h" +#endif +#include "wmc_auto.h" + + +/*------------------------------------------------------------------------- + * Function isar_splitBinLCLDEncOpen() + * + * + *------------------------------------------------------------------------*/ + +ivas_error isar_splitBinLCLDEncOpen( + ISAR_BIN_HR_SPLIT_LCLD_ENC_HANDLE *hSplitBinLCLDEnc, + const int32_t iSampleRate, + const int16_t iChannels, + const int32_t iDataRate, + const int16_t iNumBlocks, + const int16_t iNumIterations ) +{ + ISAR_BIN_HR_SPLIT_LCLD_ENC_HANDLE splitBinLCLDEnc; + ivas_error error; + + if ( ( splitBinLCLDEnc = (ISAR_BIN_HR_SPLIT_LCLD_ENC_HANDLE) malloc( sizeof( ISAR_BIN_HR_SPLIT_LCLD_ENC ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + + splitBinLCLDEnc->pLcld_enc = NULL; /* place holder for CLDFB encoder handle*/ + + splitBinLCLDEnc->iChannels = iChannels; + if ( ( error = CreateLCLDEncoder( &( splitBinLCLDEnc->psLCLDEncoder ), iSampleRate, iChannels, iDataRate, 1, iNumBlocks, (int16_t) CLDFB_NO_COL_MAX / iNumBlocks, 0 ) ) != IVAS_ERR_OK ) + { + return error; + } + + if ( ( splitBinLCLDEnc->pppfLCLDReal = (float ***) malloc( iChannels * sizeof( float ** ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + if ( ( splitBinLCLDEnc->pppfLCLDImag = (float ***) malloc( iChannels * sizeof( float ** ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + + for ( int16_t n = 0; n < splitBinLCLDEnc->iChannels; n++ ) + { + if ( ( splitBinLCLDEnc->pppfLCLDReal[n] = (float **) malloc( CLDFB_NO_COL_MAX * sizeof( float * ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + if ( ( splitBinLCLDEnc->pppfLCLDImag[n] = (float **) malloc( CLDFB_NO_COL_MAX * sizeof( float * ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); + } + } + + splitBinLCLDEnc->iNumIterations = iNumIterations; + splitBinLCLDEnc->iNumBlocks = iNumBlocks; + +#ifdef CLDFB_DEBUG + splitBinLCLDEnc->numFrame = 0; + char cldfbFilename[50] = "cldfb_in_ref.qmf"; + if ( ( splitBinLCLDEnc->cldfbIn = fopen( cldfbFilename, "rb" ) ) == NULL ) + { + fprintf( stderr, "Error: CLDFB bitstream file %s could not be opened\n\n", cldfbFilename ); + exit( -1 ); + } + int16_t chan, band; + fread( &chan, sizeof( int16_t ), 1, splitBinLCLDEnc->cldfbIn ); + fread( &band, sizeof( int16_t ), 1, splitBinLCLDEnc->cldfbIn ); +#endif + + *hSplitBinLCLDEnc = splitBinLCLDEnc; + + return IVAS_ERR_OK; +} + + +/*------------------------------------------------------------------------- + * Function isar_splitBinLCLDEncClose() + * + * + *------------------------------------------------------------------------*/ + +void isar_splitBinLCLDEncClose( + ISAR_BIN_HR_SPLIT_LCLD_ENC_HANDLE *hSplitBinLCLDEnc ) +{ + if ( ( *hSplitBinLCLDEnc ) != NULL ) + { + DeleteLCLDEncoder( ( *hSplitBinLCLDEnc )->psLCLDEncoder ); + + for ( int16_t n = 0; n < ( *hSplitBinLCLDEnc )->iChannels; n++ ) + { + free( ( *hSplitBinLCLDEnc )->pppfLCLDReal[n] ); + free( ( *hSplitBinLCLDEnc )->pppfLCLDImag[n] ); + } + free( ( *hSplitBinLCLDEnc )->pppfLCLDReal ); + free( ( *hSplitBinLCLDEnc )->pppfLCLDImag ); + +#ifdef CLDFB_DEBUG + if ( ( *hSplitBinLCLDEnc )->cldfbIn != NULL ) + { + fclose( ( *hSplitBinLCLDEnc )->cldfbIn ); + } +#endif + + free( *hSplitBinLCLDEnc ); + *hSplitBinLCLDEnc = NULL; + } + + return; +} + + +/*------------------------------------------------------------------------- + * Function isar_splitBinLCLDEncProcess() + * + * + *------------------------------------------------------------------------*/ + +void isar_splitBinLCLDEncProcess( + ISAR_BIN_HR_SPLIT_LCLD_ENC_HANDLE hSplitBinLCLDEnc, + float Cldfb_In_Real[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + float Cldfb_In_Imag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + const int32_t available_bits, + ISAR_SPLIT_REND_BITS_HANDLE pBits ) +{ + int32_t iBitsWritten, itr, available_bits_itr, rem_itr, available_bits_local; + push_wmops( "isar_splitBinLCLDEncProcess" ); + + assert( hSplitBinLCLDEnc != NULL ); + assert( Cldfb_In_Real != NULL ); + assert( Cldfb_In_Imag != NULL ); + assert( pBits != NULL ); + + available_bits_local = available_bits; + /* A conversion is needed for the 3d pointer interface here ........ */ + for ( itr = 0; itr < hSplitBinLCLDEnc->iNumIterations; itr++ ) + { + + rem_itr = hSplitBinLCLDEnc->iNumIterations - itr; + available_bits_itr = available_bits_local / rem_itr; + + for ( int32_t n = 0; n < hSplitBinLCLDEnc->iChannels; n++ ) + { + for ( int32_t k = 0; k < hSplitBinLCLDEnc->iNumBlocks; k++ ) + { + hSplitBinLCLDEnc->pppfLCLDReal[n][k] = Cldfb_In_Real[n][hSplitBinLCLDEnc->iNumBlocks * itr + k]; + hSplitBinLCLDEnc->pppfLCLDImag[n][k] = Cldfb_In_Imag[n][hSplitBinLCLDEnc->iNumBlocks * itr + k]; + } + } + +#ifdef CLDFB_DEBUG + int16_t readByte = 0; + for ( int16_t k = 0; k < hSplitBinLCLDEnc->iNumBlocks; k++ ) + { + for ( int16_t b = 0; b < CLDFB_NO_CHANNELS_MAX; b++ ) + { + for ( int16_t n = 0; n < hSplitBinLCLDEnc->iChannels; n++ ) + { + readByte = fread( &hSplitBinLCLDEnc->pppfLCLDReal[n][k][b], sizeof( float ), 1, hSplitBinLCLDEnc->cldfbIn ); + if ( readByte != 1 ) + break; + readByte = fread( &hSplitBinLCLDEnc->pppfLCLDReal[n][k][b], sizeof( float ), 1, hSplitBinLCLDEnc->cldfbIn ); + } + } + } + + if ( readByte == 1 ) + { + printf( "Frame Read = %d\n", ++hSplitBinLCLDEnc->numFrame ); + } + else + { + printf( "Writing zeroes...\n" ); + for ( int16_T k = 0; k < hSplitBinLCLDEnc->iNumBlocks; k++ ) + { + for ( int16_t b = 0; b < CLDFB_NO_CHANNELS_MAX; b++ ) + { + for ( int16_t n = 0; n < hSplitBinLCLDEnc->iChannels; n++ ) + { + hSplitBinLCLDEnc->pppfLCLDReal[n][k][b] = 0.f; + hSplitBinLCLDEnc->pppfLCLDImag[n][k][b] = 0.f; + } + } + } + } +#endif + EncodeLCLDFrame( hSplitBinLCLDEnc->psLCLDEncoder, hSplitBinLCLDEnc->pppfLCLDReal, hSplitBinLCLDEnc->pppfLCLDImag, &iBitsWritten, available_bits_itr, pBits ); + + available_bits_local -= iBitsWritten; +#ifdef DEBUGGING + assert( available_bits_local >= 0 ); +#endif + +#ifdef CLDFB_DEBUG + printf( "Bits written = %d\n", iBitsWritten ); +#endif + } + pop_wmops(); + + return; +} +#endif diff --git a/lib_isar/isar_splitRendererPLC.c b/lib_isar/isar_splitRendererPLC.c new file mode 100644 index 0000000000000000000000000000000000000000..5b682602d3b633ef2b6395aab81458ddcffa0361 --- /dev/null +++ b/lib_isar/isar_splitRendererPLC.c @@ -0,0 +1,543 @@ +/****************************************************************************************************** + + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#include +#include "options.h" +#ifdef SPLIT_REND_WITH_HEAD_ROT +#include +#include "ivas_prot.h" +#include "prot.h" +#include "ivas_cnst.h" +#include "isar_prot.h" +#ifdef DEBUGGING +#include "debug.h" +#endif +#include "wmc_auto.h" + + +/*------------------------------------------------------------------------- + * Local constants + *------------------------------------------------------------------------*/ + +#define START_VAL_AVG_LEN 2 +#define SR_PLC_FADE_START 10 /* start fading at this number of bad frames in row */ +#define SR_PLC_MUTE 30 /* Total mute at this number of bad frames in row */ +#define SR_PLC_FADE_DEGREE -3 /* fading degree per frame in dB */ +#define SRHO_THRESH ( 2.f / 3.f * 0.1f ) +#define STH_THRESH ( 2.f / 3.f * PI2 / 12 ) + + +/*------------------------------------------------------------------------- + * Function adaptive_polar_ext_plc() + * + * + *------------------------------------------------------------------------*/ + +static void adaptive_polar_ext_plc( + const float *prev_real, + const float *prev_imag, + float *rec_real, + float *rec_imag, + float xf_alp[CLDFB_PLC_XF], + float xf_bet[CLDFB_PLC_XF], + const int16_t iNumCols ) +{ + float uth[CLDFB_NO_COL_MAX], uthu[CLDFB_NO_COL_MAX], urh[CLDFB_NO_COL_MAX]; + float ph_adj, ph_diff, ph_adj_t, quot, drho, srho, diff, dth, sth, fac_real, fac_imag; + float Ruu_real[2], Ruu_imag[2]; + float start_real, start_imag, abs_fac, abs_fac_powj, comp_fac, fac_powj_real, fac_powj_imag, temp, abs2inv; + float fac_ph_real, fac_ph_imag, rat_real, rat_imag, abs_temp; + int32_t k, j; + + /* reset of accumulators */ + ph_adj = 0.0f; + drho = 0.0f; + srho = 0.0f; + dth = 0.0f; + sth = 0.0f; + + /* calculate per-sample phase and magnitude evolution in preceding frame */ + for ( k = 0; k < iNumCols; k++ ) + { + urh[k] = sqrtf( prev_imag[k] * prev_imag[k] + prev_real[k] * prev_real[k] ); + if ( urh[k] < EPSILON ) + { + /* zero encountered */ + break; + } + uth[k] = atan2f( prev_imag[k], prev_real[k] ); + + /* phase unwrap */ + if ( k == 0 ) + { + uthu[0] = uth[0]; + } + else + { + /* phase unwrap */ + ph_diff = uth[k] - uth[k - 1]; + uthu[k] = uth[k]; + if ( fabsf( ph_diff ) >= PI2 / 2 ) + { + ph_adj_t = ph_diff / PI2; + if ( fabsf( ph_adj_t - truncf( ph_adj_t ) ) == 0.5f ) + { + ph_adj_t = truncf( ph_adj_t ); + } + ph_adj = -PI2 * roundf( ph_adj_t ) + ph_adj; + } + uthu[k] += ph_adj; + /* unwrapped phase in uthu */ + + /* mean and stdev of per-sample magnitude ratios */ + quot = urh[k] / urh[k - 1]; + drho += quot; + srho += SQR( quot ); + /* mean and stdev of per-sample phase differences */ + diff = uthu[k] - uthu[k - 1]; /* the mean value calculation could be optimized */ + dth += diff; + sth += SQR( diff ); + } + } + + if ( k == iNumCols ) + { + /* mean and stdev of per-sample magnitude ratios */ + drho *= 1.0f / ( iNumCols - 1 ); + temp = srho - ( iNumCols - 1 ) * SQR( drho ); + if ( temp > 0 ) + { + srho = sqrtf( temp * ( 1.0f / ( iNumCols - 2 ) ) ); + } + else + { + srho = 0.0f; + } + + /* mean and stdev of per-sample phase differences */ + dth *= 1.0f / ( iNumCols - 1 ); + temp = sth - ( iNumCols - 1 ) * SQR( dth ); + if ( temp > 0 ) + { + sth = sqrtf( temp * ( 1.0f / ( iNumCols - 2 ) ) ); + } + else + { + sth = 0.0f; + } + + /* do phase extension only if the std deviations are small */ + if ( ( srho < SRHO_THRESH ) || ( sth < STH_THRESH ) ) + { + /* calculate complex evolution factor */ + fac_ph_real = cosf( dth ); + fac_ph_imag = sinf( dth ); + fac_real = min( 1, drho ) * fac_ph_real; + fac_imag = min( 1, drho ) * fac_ph_imag; + + /* Calculate start value for evolution from last samples of previous frame */ + fac_powj_real = fac_real; + fac_powj_imag = fac_imag; + start_real = prev_real[iNumCols - 1]; + start_imag = prev_imag[iNumCols - 1]; + for ( j = 1; j < START_VAL_AVG_LEN; j++ ) + { + start_real += fac_powj_real * prev_real[iNumCols - j - 1] - fac_powj_imag * prev_imag[iNumCols - j - 1]; + start_imag += fac_powj_imag * prev_real[iNumCols - j - 1] + fac_powj_real * prev_imag[iNumCols - j - 1]; + temp = fac_powj_real * fac_real - fac_powj_imag * fac_imag; + fac_powj_imag = fac_powj_imag * fac_real + fac_powj_real * fac_imag; + fac_powj_real = temp; + } + start_real *= 1.0f / START_VAL_AVG_LEN; + start_imag *= 1.0f / START_VAL_AVG_LEN; + + /* make evolution less static: apply per samples differences as in preceding frame */ + rat_real = ( prev_real[1] * prev_real[0] + prev_imag[1] * prev_imag[0] ); + rat_imag = ( -prev_real[1] * prev_imag[0] + prev_imag[1] * prev_real[0] ); + + /* only phase perturbation */ + abs_temp = sqrtf( SQR( rat_real ) + SQR( rat_imag ) ); + abs2inv = min( 1, drho ) / max( EPSILON, abs_temp ); + rat_real *= abs2inv; + rat_imag *= abs2inv; + + /* apply complex evolution for first substitution sample */ + rec_real[0] = rat_real * start_real - rat_imag * start_imag; + rec_imag[0] = rat_imag * start_real + rat_real * start_imag; + for ( j = 2; j < iNumCols; j++ ) + { + /* make evolution less static: apply per samples differences as in preceding frame */ + rat_real = ( prev_real[j] * prev_real[j - 1] + prev_imag[j] * prev_imag[j - 1] ); + rat_imag = ( -prev_real[j] * prev_imag[j - 1] + prev_imag[j] * prev_real[j - 1] ); + + /* only phase perturbation */ + abs_temp = sqrtf( SQR( rat_real ) + SQR( rat_imag ) ); + abs2inv = min( 1, drho ) / max( EPSILON, abs_temp ); + + rat_real *= abs2inv; + rat_imag *= abs2inv; + /* apply complex evolution for further substitution samples */ + rec_real[j - 1] = rat_real * rec_real[j - 2] - rat_imag * rec_imag[j - 2]; + rec_imag[j - 1] = rat_imag * rec_real[j - 2] + rat_real * rec_imag[j - 2]; + } + + /* do the same for samples of crossfade region */ + for ( j = 1; j < CLDFB_PLC_XF + 2; j++ ) + { + rat_real = ( prev_real[j] * prev_real[j - 1] + prev_imag[j] * prev_imag[j - 1] ); + rat_imag = ( -prev_real[j] * prev_imag[j - 1] + prev_imag[j] * prev_real[j - 1] ); + + abs_temp = sqrtf( SQR( rat_real ) + SQR( rat_imag ) ); + abs2inv = min( 1, drho ) / max( EPSILON, abs_temp ); + + rat_real *= abs2inv; + rat_imag *= abs2inv; + rec_real[j + iNumCols - 2] = rat_real * rec_real[j + iNumCols - 3] - rat_imag * rec_imag[j + iNumCols - 3]; + rec_imag[j + iNumCols - 2] = rat_imag * rec_real[j + iNumCols - 3] + rat_real * rec_imag[j + iNumCols - 3]; + } + + + /* apply crossfade */ + for ( j = 0; j < CLDFB_PLC_XF; j++ ) + { + rec_real[iNumCols + j] *= xf_alp[j]; + rec_imag[iNumCols + j] *= xf_alp[j]; + xf_bet[j] = 1 - xf_alp[j]; + } + } + else + { + /* do complex lpc combined with frame repetition */ + Ruu_real[0] = SQR( prev_real[0] ) + SQR( prev_imag[0] ); + Ruu_real[1] = 0; + Ruu_imag[1] = 0; + for ( j = 1; j < iNumCols; j++ ) + { + Ruu_real[0] += SQR( prev_real[j] ) + SQR( prev_imag[j] ); + Ruu_real[1] += prev_real[j] * prev_real[j - 1] + prev_imag[j] * prev_imag[j - 1]; + Ruu_imag[1] += prev_imag[j] * prev_real[j - 1] - prev_real[j] * prev_imag[j - 1]; + } + if ( Ruu_real[0] > EPSILON ) + { + /* prediction coefficient */ + fac_real = Ruu_real[1] / Ruu_real[0]; + fac_imag = Ruu_imag[1] / Ruu_real[0]; + } + else + { + fac_real = 0; + fac_imag = 0; + } + + /* apply prediction using last sample of preceding frame as start value and combine with previous frame samples */ + fac_powj_real = fac_real; + fac_powj_imag = fac_imag; + abs_fac = sqrtf( SQR( fac_real ) + SQR( fac_imag ) ); + abs_fac_powj = abs_fac; + for ( j = 0; j < iNumCols; j++ ) + { + comp_fac = 1 - abs_fac_powj; + rec_real[j] = prev_real[iNumCols - 1] * fac_powj_real - prev_imag[iNumCols - 1] * fac_powj_imag + + prev_real[j] * comp_fac; + rec_imag[j] = prev_real[iNumCols - 1] * fac_powj_imag + prev_imag[iNumCols - 1] * fac_powj_real + + prev_imag[j] * comp_fac; + abs_fac_powj = abs_fac_powj * abs_fac; + temp = fac_powj_real * fac_real - fac_powj_imag * fac_imag; + fac_powj_imag = fac_powj_real * fac_imag + fac_powj_imag * fac_real; + fac_powj_real = temp; + } + + /* prepare XF to next frame using prediction */ + fac_powj_real = fac_real; + fac_powj_imag = fac_imag; + abs_fac_powj = abs_fac; + for ( j = 0; j < CLDFB_PLC_XF; j++ ) + { + xf_bet[j] = 1 - abs_fac_powj; + rec_real[j + iNumCols] = rec_real[iNumCols - 1] * fac_powj_real - rec_imag[iNumCols - 1] * fac_powj_imag; + rec_imag[j + iNumCols] = rec_real[iNumCols - 1] * fac_powj_imag + rec_imag[iNumCols - 1] * fac_powj_real; + abs_fac_powj = abs_fac_powj * abs_fac; + temp = fac_powj_real * fac_real - fac_powj_imag * fac_imag; + fac_powj_imag = fac_powj_real * fac_imag + fac_powj_imag * fac_real; + fac_powj_real = temp; + } + } + } + else + { + for ( j = 0; j < iNumCols; j++ ) + { + rec_real[j] = prev_real[j]; + rec_imag[j] = prev_imag[j]; + } + for ( j = 0; j < CLDFB_PLC_XF; j++ ) + { + xf_bet[j] = 1; + rec_real[j + iNumCols] = 0; + rec_imag[j + iNumCols] = 0; + } + } + + return; +} + + +/*------------------------------------------------------------------------- + * Function isar_splitBinRendPLCOpen() + * + * + *------------------------------------------------------------------------*/ + +ivas_error isar_splitBinRendPLCOpen( + ISAR_SPLIT_REND_PLC_HANDLE *phSplitRendPLC, + const int16_t iNumSubSets ) +{ + ivas_error error; + ISAR_SPLIT_REND_PLC_HANDLE hSplitRendPLC; + + error = IVAS_ERR_OK; + if ( ( hSplitRendPLC = (ISAR_SPLIT_REND_PLC_HANDLE) malloc( sizeof( SPLIT_REND_PLC_STRUCT ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for bin split renderer PLC Module \n" ) ); + } + + hSplitRendPLC->prev_bfi = 0; + hSplitRendPLC->bf_count = 0; + hSplitRendPLC->iNumSubSets = iNumSubSets; + set_zero( &hSplitRendPLC->CldfbPLC_state.Cldfb_Prev_BinReal[0][0][0], 2 * ( CLDFB_NO_COL_MAX + CLDFB_PLC_XF ) * CLDFB_NO_CHANNELS_MAX ); + set_zero( &hSplitRendPLC->CldfbPLC_state.Cldfb_Prev_BinImag[0][0][0], 2 * ( CLDFB_NO_COL_MAX + CLDFB_PLC_XF ) * CLDFB_NO_CHANNELS_MAX ); + *phSplitRendPLC = hSplitRendPLC; + + return error; +} + + +/*------------------------------------------------------------------------- + * Function isar_splitBinRendPLCClose() + * + * + *------------------------------------------------------------------------*/ + +void isar_splitBinRendPLCClose( + ISAR_SPLIT_REND_PLC_HANDLE *phSplitRendPLC ) +{ + if ( ( *phSplitRendPLC ) != NULL ) + { + free( ( *phSplitRendPLC ) ); + ( *phSplitRendPLC ) = NULL; + } + + return; +} + + +/*------------------------------------------------------------------------- + * Function isar_splitBinRendPLCsaveState() + * + * + *------------------------------------------------------------------------*/ + +void isar_splitBinRendPLCsaveState( + ISAR_SPLIT_REND_PLC_HANDLE hSplitRendPLC, + float Cldfb_RealBuffer_Binaural[BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + float Cldfb_ImagBuffer_Binaural[BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + const int16_t num_chs, + const int16_t iNumBlocks, + const int16_t iNumIterations ) +{ + int16_t k, n; + + /* Save Cldfb frame */ + for ( k = 0; k < ( iNumBlocks * iNumIterations ); k++ ) + { + for ( n = 0; n < num_chs; n++ ) + { + mvr2r( &Cldfb_RealBuffer_Binaural[n][k][0], &hSplitRendPLC->CldfbPLC_state.Cldfb_Prev_BinReal[n][k][0], CLDFB_NO_CHANNELS_MAX ); + mvr2r( &Cldfb_ImagBuffer_Binaural[n][k][0], &hSplitRendPLC->CldfbPLC_state.Cldfb_Prev_BinImag[n][k][0], CLDFB_NO_CHANNELS_MAX ); + } + } + + return; +} + + +/*------------------------------------------------------------------------- + * Function isar_splitBinRendPLC_xf() + * + * Cross-fade of preceding bad frame into good frame + *------------------------------------------------------------------------*/ + +void isar_splitBinRendPLC_xf( + ISAR_SPLIT_REND_PLC_HANDLE hSplitRendPLC, + float Cldfb_RealBuffer_Binaural[BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + float Cldfb_ImagBuffer_Binaural[BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + const int16_t num_chs, + const int16_t iNumBlocks, + const int16_t iNumIterations, + int32_t **ppiDecodingFailed, + int32_t **ppiDecodingFailedPrev ) +{ + int16_t n, i, k; + + /* Indicate that next transition will be from a good frame */ + hSplitRendPLC->prev_bfi = 0; + + /* Reset bf conter */ + hSplitRendPLC->bf_count = 0; + + + /* Do the cross fade */ + for ( n = 0; n < num_chs; n++ ) + { + for ( i = 0; i < CLDFB_NO_CHANNELS_MAX; i++ ) + { + int16_t iSubSet = i % hSplitRendPLC->iNumSubSets; + if ( ppiDecodingFailedPrev[n][iSubSet] == 1 && ppiDecodingFailed[n][iSubSet] == 0 ) + { + for ( k = 0; k < CLDFB_PLC_XF; k++ ) + { + Cldfb_RealBuffer_Binaural[n][k][i] = hSplitRendPLC->CldfbPLC_state.xf_bet[n][i][k] * Cldfb_RealBuffer_Binaural[n][k][i] + hSplitRendPLC->CldfbPLC_state.Cldfb_Prev_BinReal[n][k + ( iNumBlocks * iNumIterations )][i]; + Cldfb_ImagBuffer_Binaural[n][k][i] = hSplitRendPLC->CldfbPLC_state.xf_bet[n][i][k] * Cldfb_ImagBuffer_Binaural[n][k][i] + hSplitRendPLC->CldfbPLC_state.Cldfb_Prev_BinImag[n][k + ( iNumBlocks * iNumIterations )][i]; + } + } + } + } + + return; +} + + +/*------------------------------------------------------------------------- + * Function isar_splitBinRendPLC() + * + * Conceal bad frame + *------------------------------------------------------------------------*/ + +void isar_splitBinRendPLC( + ISAR_SPLIT_REND_PLC_HANDLE hSplitRendPLC, + float Cldfb_RealBuffer_Binaural[BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + float Cldfb_ImagBuffer_Binaural[BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + const int16_t num_chs, + const int16_t iNumBlocks, + const int16_t iNumIterations, + int32_t **ppiDecodingFailed ) +{ + int32_t i, n, k; + float fade_fac; + float prev_real[CLDFB_NO_COL_MAX], prev_imag[CLDFB_NO_COL_MAX], rec_real[CLDFB_NO_COL_MAX + CLDFB_PLC_XF], rec_imag[CLDFB_NO_COL_MAX + CLDFB_PLC_XF]; + float xf_alp[CLDFB_PLC_XF]; + int16_t iNumCols, fade_start_cntr, mute_cntr, fade_val; + + iNumCols = iNumBlocks * iNumIterations; + + /* Indicate that next transition will be from a bad frame */ + hSplitRendPLC->prev_bfi = 1; + + for ( i = 0; i < CLDFB_PLC_XF; i++ ) + { + xf_alp[i] = 1.0f - ( i + 1.0f ) / ( CLDFB_PLC_XF + 1.0f ); + } + + for ( n = 0; n < num_chs; n++ ) + { + for ( i = 0; i < CLDFB_NO_CHANNELS_MAX; i++ ) + { + int32_t iSubSet = i % hSplitRendPLC->iNumSubSets; + for ( k = 0; k < iNumCols; k++ ) + { + prev_real[k] = hSplitRendPLC->CldfbPLC_state.Cldfb_Prev_BinReal[n][k][i]; + prev_imag[k] = hSplitRendPLC->CldfbPLC_state.Cldfb_Prev_BinImag[n][k][i]; + } + + adaptive_polar_ext_plc( prev_real, prev_imag, rec_real, rec_imag, + xf_alp, hSplitRendPLC->CldfbPLC_state.xf_bet[n][i], + iNumCols ); + + for ( k = 0; k < iNumCols; k++ ) + { + hSplitRendPLC->CldfbPLC_state.Cldfb_Prev_BinReal[n][k][i] = rec_real[k]; + hSplitRendPLC->CldfbPLC_state.Cldfb_Prev_BinImag[n][k][i] = rec_imag[k]; + + if ( ppiDecodingFailed[n][iSubSet] == 1 ) + { /* only then copy to output */ + Cldfb_RealBuffer_Binaural[n][k][i] = rec_real[k]; + Cldfb_ImagBuffer_Binaural[n][k][i] = rec_imag[k]; + } + } + + for ( k = iNumCols; k < iNumCols + CLDFB_PLC_XF; k++ ) + { + hSplitRendPLC->CldfbPLC_state.Cldfb_Prev_BinReal[n][k][i] = rec_real[k]; + hSplitRendPLC->CldfbPLC_state.Cldfb_Prev_BinImag[n][k][i] = rec_imag[k]; + } + } + } + + + /* Check bf counter */ + fade_start_cntr = SR_PLC_FADE_START * CLDFB_NO_COL_MAX / iNumCols; + mute_cntr = SR_PLC_MUTE * CLDFB_NO_COL_MAX / iNumCols; + + if ( hSplitRendPLC->bf_count++ >= fade_start_cntr ) + { + if ( hSplitRendPLC->bf_count < mute_cntr ) + { + fade_val = ( ( hSplitRendPLC->bf_count - fade_start_cntr ) * iNumCols ) / CLDFB_NO_COL_MAX; + fade_fac = powf( 10, fade_val * SR_PLC_FADE_DEGREE / 20.0f ); + + for ( n = 0; n < num_chs; n++ ) + { + for ( k = 0; k < iNumCols; k++ ) + { + v_multc( &Cldfb_RealBuffer_Binaural[n][k][0], fade_fac, &Cldfb_RealBuffer_Binaural[n][k][0], (int16_t) CLDFB_NO_CHANNELS_MAX ); + v_multc( &Cldfb_ImagBuffer_Binaural[n][k][0], fade_fac, &Cldfb_ImagBuffer_Binaural[n][k][0], (int16_t) CLDFB_NO_CHANNELS_MAX ); + } + } + } + else + { + for ( n = 0; n < num_chs; n++ ) + { + for ( k = 0; k < iNumCols; k++ ) + { + set_zero( &Cldfb_RealBuffer_Binaural[n][k][0], (int16_t) CLDFB_NO_CHANNELS_MAX ); + set_zero( &Cldfb_ImagBuffer_Binaural[n][k][0], (int16_t) CLDFB_NO_CHANNELS_MAX ); + } + } + hSplitRendPLC->bf_count = mute_cntr; + } + } + + return; +} + +#endif diff --git a/lib_isar/isar_splitRendererPost.c b/lib_isar/isar_splitRendererPost.c new file mode 100644 index 0000000000000000000000000000000000000000..f212e5f304ab3c0d53d97f872cfcc1092e2a132d --- /dev/null +++ b/lib_isar/isar_splitRendererPost.c @@ -0,0 +1,1910 @@ +/****************************************************************************************************** + + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#include +#include "options.h" +#ifdef SPLIT_REND_WITH_HEAD_ROT +#include +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG +#include +#endif +#include "ivas_prot.h" +#include "prot.h" +#include "isar_rom_post_rend.h" +#include "isar_prot.h" +#ifdef DEBUGGING +#include "debug.h" +#endif +#include "wmc_auto.h" + +/*---------------------------------------------------------------------* + * Local function declarations + *---------------------------------------------------------------------*/ + +static void isar_SplitRenderer_PostRenderer( + ISAR_BIN_HR_SPLIT_POST_REND_HANDLE hBinPostRenderer, /* i/o: binaural renderer handle */ + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + float Cldfb_RealBuffer_Ref_Binaural[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o : Reference/out Binaural signals */ + float Cldfb_ImagBuffer_Ref_Binaural[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o : Reference/out Binaural signals */ + const IVAS_QUATERNION Quaternion_act ); + + +/*------------------------------------------------------------------------- + * isar_splitBinPostRendOpen() + * + * + *------------------------------------------------------------------------*/ + +ivas_error isar_splitBinPostRendOpen( + ISAR_BIN_HR_SPLIT_POST_REND_HANDLE *hBinHrSplitPostRend, + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + const int32_t output_Fs ) +{ + ISAR_BIN_HR_SPLIT_POST_REND_HANDLE hBinRend; + ivas_error error; + int16_t ch; + + if ( ( hBinRend = (ISAR_BIN_HR_SPLIT_POST_REND_HANDLE) malloc( sizeof( ISAR_BIN_HR_SPLIT_POST_REND ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for bin split post renderer Module \n" ) ); + } + + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + hBinRend->cldfbSyn[ch] = NULL; + hBinRend->cldfbAna[ch] = NULL; + } +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG + for ( int16_t i = 0; i < MAX_HEAD_ROT_POSES; i++ ) + { + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + hBinRend->cldfbSynReconsBinDec[i][ch] = NULL; + } + } +#endif + + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + if ( ( error = openCldfb( &( hBinRend->cldfbSyn[ch] ), CLDFB_SYNTHESIS, output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) + { + return error; + } + if ( ( error = openCldfb( &( hBinRend->cldfbAna[ch] ), CLDFB_ANALYSIS, output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) + { + return error; + } + } + +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG + for ( int16_t i = 0; i < MAX_HEAD_ROT_POSES; i++ ) + { + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + if ( ( error = openCldfb( &( hBinRend->cldfbSynReconsBinDec[i][ch] ), CLDFB_SYNTHESIS, output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) + { + return error; + } + } + } +#endif + hBinRend->cf_flag = 0; + set_fix_rotation_mat( hBinRend->fix_pos_rot_mat, pMultiBinPoseData ); + set_pose_types( hBinRend->pose_type, pMultiBinPoseData ); + isar_split_rend_init_huff_cfg( &hBinRend->huff_cfg ); + *hBinHrSplitPostRend = hBinRend; + + return IVAS_ERR_OK; +} + + +/*------------------------------------------------------------------------- + * isar_splitBinPostRendClose() + * + * + *------------------------------------------------------------------------*/ + +void isar_splitBinPostRendClose( + ISAR_BIN_HR_SPLIT_POST_REND_HANDLE *hBinHrSplitPostRend ) +{ + int16_t ch; + + if ( ( *hBinHrSplitPostRend ) != NULL ) + { + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + if ( ( *hBinHrSplitPostRend )->cldfbSyn[ch] != NULL ) + { + deleteCldfb( &( ( *hBinHrSplitPostRend )->cldfbSyn[ch] ) ); + ( *hBinHrSplitPostRend )->cldfbSyn[ch] = NULL; + } + if ( ( *hBinHrSplitPostRend )->cldfbAna[ch] != NULL ) + { + deleteCldfb( &( ( *hBinHrSplitPostRend )->cldfbAna[ch] ) ); + ( *hBinHrSplitPostRend )->cldfbAna[ch] = NULL; + } + } +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG + for ( int16_t i = 0; i < MAX_HEAD_ROT_POSES; i++ ) + { + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + if ( ( *hBinHrSplitPostRend )->cldfbSynReconsBinDec[i][ch] != NULL ) + { + deleteCldfb( &( ( *hBinHrSplitPostRend )->cldfbSynReconsBinDec[i][ch] ) ); + ( *hBinHrSplitPostRend )->cldfbSynReconsBinDec[i][ch] = NULL; + } + } + } +#endif + + free( ( *hBinHrSplitPostRend ) ); + ( *hBinHrSplitPostRend ) = NULL; + } + + return; +} + + +/*-----------------------------------------------------------------------------------------* + * Function isar_split_rend_huffman_decode_opt() + * + * + *-----------------------------------------------------------------------------------------*/ + +static int16_t isar_split_rend_huffman_decode_opt( + isar_split_rend_huffman_cfg_t *huff_cfg, + ISAR_SPLIT_REND_BITS_HANDLE pBits, + const int16_t *idx_trav_list ) +{ + int32_t i, ind, code, num_bits, code_b, num_bits_read; + const int32_t *codebook; + + codebook = huff_cfg->codebook; + num_bits_read = 0; + ind = huff_cfg->codebook[0] - 1; + code = 0; + for ( i = 0; i < huff_cfg->sym_len; i++ ) + { + codebook = codebook + idx_trav_list[i] * 3; + num_bits = codebook[1]; + code_b = codebook[2]; + num_bits_read = num_bits - num_bits_read; + code = code << num_bits_read; + if ( num_bits_read > 0 ) + { + code |= ISAR_SPLIT_REND_BITStream_read_int32( pBits, num_bits_read ); + } + + if ( code == code_b ) + { + ind = codebook[0]; + break; + } + + num_bits_read = num_bits; + codebook = huff_cfg->codebook; + } + +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG + assert( ind >= huff_cfg->codebook[0] ); +#endif + return (int16_t) ind; +} + +/*-----------------------------------------------------------------------------------------* + * Function isar_split_rend_unquant_md() + * + * + *-----------------------------------------------------------------------------------------*/ + +static void isar_split_rend_unquant_md( + ISAR_BIN_HR_SPLIT_REND_MD_HANDLE hMd, + ISAR_SPLIT_REND_POSE_TYPE pose_type, + const int16_t real_only, + float fix_pos_rot_mat[][BINAURAL_CHANNELS], + const float pred_quant_step ) +{ + int16_t ch1, ch2; + int16_t gd_idx_min; + + if ( pose_type == PRED_ONLY || pose_type == PRED_ROLL_ONLY ) + { + float quantstep; + + quantstep = pred_quant_step; +#ifndef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS + for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + hMd->pred_mat_re[ch1][ch2] = hMd->pred_mat_re_idx[ch1][ch2] * quantstep; + hMd->pred_mat_re[ch1][ch2] = hMd->pred_mat_re[ch1][ch2] + fix_pos_rot_mat[ch1][ch2]; + } + } +#endif + if ( real_only ) + { +#ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS + for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + hMd->pred_mat_re[ch1][ch2] = hMd->pred_mat_re_idx[ch1][ch2] * quantstep; + hMd->pred_mat_re[ch1][ch2] = hMd->pred_mat_re[ch1][ch2] + ( ( ch1 == ch2 ) ? 1.0f : 0.0f ); + } + } +#endif + + for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + hMd->pred_mat_im[ch1][ch2] = 0.0f; + } + } + } + else + { +#ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS + for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + hMd->pred_mat_re[ch1][ch2] = hMd->pred_mat_re_idx[ch1][ch2] * quantstep; + hMd->pred_mat_re[ch1][ch2] = hMd->pred_mat_re[ch1][ch2] + fix_pos_rot_mat[ch1][ch2]; + } + } +#endif + + for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + hMd->pred_mat_im[ch1][ch2] = hMd->pred_mat_im_idx[ch1][ch2] * quantstep; + } + } + } + } + else if ( pose_type == COM_GAIN_ONLY ) + { + gd_idx_min = (int16_t) roundf( ISAR_SPLIT_REND_D_1BYQ_STEP * ISAR_SPLIT_REND_D_MIN_VAL ); + hMd->gd_idx += gd_idx_min; + hMd->gd = hMd->gd_idx * ISAR_SPLIT_REND_D_Q_STEP; + } + else if ( pose_type == LR_GAIN_ONLY ) + { + gd_idx_min = (int16_t) roundf( ISAR_SPLIT_REND_PITCH_G_1BYQ_STEP * ISAR_SPLIT_REND_PITCH_G_MIN_VAL ); + hMd->gd_idx += gd_idx_min; + hMd->gd = hMd->gd_idx * ISAR_SPLIT_REND_PITCH_G_Q_STEP; + + hMd->gd2_idx += gd_idx_min; + hMd->gd2 = hMd->gd2_idx * ISAR_SPLIT_REND_PITCH_G_Q_STEP; + } + else + { + hMd->gd = 0.0f; + } + + return; +} + + +/*-----------------------------------------------------------------------------------------* + * Function isar_splitBinPostRendMdBase2Dec() + * + * + *-----------------------------------------------------------------------------------------*/ + +static void isar_splitBinPostRendMdBase2Dec( + ISAR_SPLIT_REND_BITS_HANDLE pBits, + ISAR_BIN_HR_SPLIT_POST_REND_HANDLE hBinHrSplitPostRend, + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + const int16_t num_subframes, + const int16_t pred_real_bands_yaw, + const int16_t pred_imag_bands_yaw, + const int16_t pred_quant_pnts_yaw, + const int16_t d_bands_yaw, + const int16_t bands_pitch, + const int16_t pred_real_bands_roll, + const int16_t pred_imag_bands_roll ) +{ + int16_t sf_idx, pos_idx, b, ch1, ch2; + int16_t min_pred_idx, min_gd_idx, min_p_gd_idx, pred_code_len, gd_code_len, p_gd_code_len; + int16_t min_pred_roll_idx, pred_roll_code_len; + int16_t pred_cb_idx; + int16_t code; + ISAR_BIN_HR_SPLIT_REND_MD_HANDLE hMd; + ISAR_BIN_HR_SPLIT_REND_HUFF_HANDLE pHuff_cfg; + + pHuff_cfg = &hBinHrSplitPostRend->huff_cfg; + + if ( pred_quant_pnts_yaw == ISAR_SPLIT_REND_PRED_63QUANT_PNTS ) + { + pred_cb_idx = 1; + } + else + { + pred_cb_idx = 0; + } + min_pred_idx = (int16_t) pHuff_cfg->pred[pred_cb_idx].codebook[0]; + min_pred_roll_idx = (int16_t) pHuff_cfg->pred_roll.codebook[0]; + min_gd_idx = (int16_t) pHuff_cfg->gd.codebook[0]; + min_p_gd_idx = (int16_t) pHuff_cfg->p_gd.codebook[0]; + pred_code_len = pHuff_cfg->pred_base2_code_len[pred_cb_idx]; + pred_roll_code_len = pHuff_cfg->pred_roll_base2_code_len; + gd_code_len = pHuff_cfg->gd_base2_code_len; + p_gd_code_len = pHuff_cfg->p_gd_base2_code_len; + + for ( sf_idx = 0; sf_idx < num_subframes; sf_idx++ ) + { + for ( pos_idx = 0; pos_idx < pMultiBinPoseData->num_poses - 1; pos_idx++ ) + { + if ( hBinHrSplitPostRend->pose_type[pos_idx] == ANY_YAW ) + { +#ifndef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS + for ( b = 0; b < pred_real_bands_yaw; b++ ) + { + hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b]; + for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + code = (int16_t) ISAR_SPLIT_REND_BITStream_read_int32( pBits, pred_code_len ); + hMd->pred_mat_re_idx[ch1][ch2] = code + min_pred_idx; + } + } + } + for ( b = 0; b < pred_imag_bands_yaw; b++ ) + { + hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b]; + for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + code = (int16_t) ISAR_SPLIT_REND_BITStream_read_int32( pBits, pred_code_len ); + hMd->pred_mat_im_idx[ch1][ch2] = code + min_pred_idx; + } + } + } +#else + for ( b = 0; b < pred_imag_bands_yaw; b++ ) + { + hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b]; + for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + code = (int16_t) ISAR_SPLIT_REND_BITStream_read_int32( pBits, pred_code_len ); + hMd->pred_mat_re_idx[ch1][ch2] = code + min_pred_idx; + } + } + for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + code = (int16_t) ISAR_SPLIT_REND_BITStream_read_int32( pBits, pred_code_len ); + hMd->pred_mat_im_idx[ch1][ch2] = code + min_pred_idx; + } + } + } + + for ( ; b < pred_real_bands_yaw; b++ ) + { + hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b]; + for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + code = (int16_t) ISAR_SPLIT_REND_BITStream_read_int32( pBits, pred_code_len ); + hMd->pred_mat_re_idx[ch1][ch1] = code + min_pred_idx; + } + hMd->pred_mat_re_idx[0][1] = 0; + hMd->pred_mat_re_idx[1][0] = 0; + } +#endif + for ( b = 0; b < d_bands_yaw; b++ ) + { + hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b]; + code = (int16_t) ISAR_SPLIT_REND_BITStream_read_int32( pBits, gd_code_len ); + hMd->gd_idx = code + min_gd_idx; + } + } + else if ( hBinHrSplitPostRend->pose_type[pos_idx] == PITCH_ONLY ) + { + for ( b = 0; b < bands_pitch; b++ ) + { + hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b]; + code = (int16_t) ISAR_SPLIT_REND_BITStream_read_int32( pBits, p_gd_code_len ); + hMd->gd_idx = code + min_p_gd_idx; + code = (int16_t) ISAR_SPLIT_REND_BITStream_read_int32( pBits, p_gd_code_len ); + hMd->gd2_idx = code + min_p_gd_idx; + } + } + else + { +#ifndef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS + for ( b = 0; b < pred_real_bands_roll; b++ ) + { + hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b]; + for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + code = (int16_t) ISAR_SPLIT_REND_BITStream_read_int32( pBits, pred_roll_code_len ); + hMd->pred_mat_re_idx[ch1][ch2] = code + min_pred_roll_idx; + } + } + } + for ( b = 0; b < pred_imag_bands_roll; b++ ) + { + hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b]; + for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + code = (int16_t) ISAR_SPLIT_REND_BITStream_read_int32( pBits, pred_roll_code_len ); + hMd->pred_mat_im_idx[ch1][ch2] = code + min_pred_roll_idx; + } + } + } +#else + for ( b = 0; b < pred_imag_bands_roll; b++ ) + { + hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b]; + for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + code = (int16_t) ISAR_SPLIT_REND_BITStream_read_int32( pBits, pred_roll_code_len ); + hMd->pred_mat_re_idx[ch1][ch2] = code + min_pred_roll_idx; + } + } + for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + code = (int16_t) ISAR_SPLIT_REND_BITStream_read_int32( pBits, pred_roll_code_len ); + hMd->pred_mat_im_idx[ch1][ch2] = code + min_pred_roll_idx; + } + } + } + + for ( ; b < pred_real_bands_roll; b++ ) + { + hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b]; + for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + code = (int16_t) ISAR_SPLIT_REND_BITStream_read_int32( pBits, pred_roll_code_len ); + hMd->pred_mat_re_idx[ch1][ch1] = code + min_pred_roll_idx; + } + hMd->pred_mat_re_idx[0][1] = 0; + hMd->pred_mat_re_idx[1][0] = 0; + } +#endif + } + } + } + + return; +} + + +/*-----------------------------------------------------------------------------------------* + * Function isar_splitBinPostRendMdHuffDec() + * + * + *-----------------------------------------------------------------------------------------*/ + +static void isar_splitBinPostRendMdHuffDec( + ISAR_SPLIT_REND_BITS_HANDLE pBits, + ISAR_BIN_HR_SPLIT_POST_REND_HANDLE hBinHrSplitPostRend, + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + const int16_t num_subframes, + const int16_t pred_real_bands_yaw, + const int16_t pred_imag_bands_yaw, + const int16_t pred_quant_pnts_yaw, + const int16_t d_bands_yaw, + const int16_t bands_pitch, + const int16_t pred_real_bands_roll, + const int16_t pred_imag_bands_roll ) +{ + int16_t pos_idx, b, sf_idx; + int16_t ch1, ch2; + int16_t sym_adj_idx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + int16_t min_pred_idx, max_pred_idx; + int16_t min_pred_roll_idx, max_pred_roll_idx, pred_cb_idx; + ISAR_BIN_HR_SPLIT_REND_MD_HANDLE hMd; + ISAR_BIN_HR_SPLIT_REND_HUFF_HANDLE pHuff_cfg; + + pHuff_cfg = &hBinHrSplitPostRend->huff_cfg; + + if ( pred_quant_pnts_yaw == ISAR_SPLIT_REND_PRED_63QUANT_PNTS ) + { + pred_cb_idx = 1; + } + else + { + pred_cb_idx = 0; + } + min_pred_idx = (int16_t) pHuff_cfg->pred[pred_cb_idx].codebook[0]; + max_pred_idx = (int16_t) pHuff_cfg->pred[pred_cb_idx].codebook[( pred_quant_pnts_yaw - 1 ) * 3]; + + min_pred_roll_idx = (int16_t) pHuff_cfg->pred_roll.codebook[0]; + max_pred_roll_idx = (int16_t) pHuff_cfg->pred_roll.codebook[( ISAR_SPLIT_REND_ROLL_PRED_QUANT_PNTS - 1 ) * 3]; + + for ( sf_idx = 0; sf_idx < num_subframes; sf_idx++ ) + { + for ( pos_idx = 0; pos_idx < pMultiBinPoseData->num_poses - 1; pos_idx++ ) + { + if ( hBinHrSplitPostRend->pose_type[pos_idx] == ANY_YAW ) + { +#ifndef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS + for ( b = 0; b < pred_real_bands_yaw; b++ ) + { + hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b]; + for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + sym_adj_idx[ch1][ch2] = isar_split_rend_huffman_decode_opt( &pHuff_cfg->pred[pred_cb_idx], pBits, pHuff_cfg->pred_idx_trav[pred_cb_idx] ); + } + } + isar_SplitRenderer_getdiagdiff( sym_adj_idx, hMd->pred_mat_re_idx, 1, min_pred_idx, max_pred_idx ); + } + for ( b = 0; b < pred_imag_bands_yaw; b++ ) + { + hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b]; + for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + sym_adj_idx[ch1][ch2] = isar_split_rend_huffman_decode_opt( &pHuff_cfg->pred[pred_cb_idx], pBits, pHuff_cfg->pred_idx_trav[pred_cb_idx] ); + } + } + isar_SplitRenderer_getdiagdiff( sym_adj_idx, hMd->pred_mat_im_idx, -1, min_pred_idx, max_pred_idx ); + } +#else + for ( b = 0; b < pred_imag_bands_yaw; b++ ) + { + hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b]; + for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + sym_adj_idx[ch1][ch2] = isar_split_rend_huffman_decode_opt( &pHuff_cfg->pred[pred_cb_idx], pBits, pHuff_cfg->pred_idx_trav[pred_cb_idx] ); + } + } + isar_SplitRenderer_getdiagdiff( sym_adj_idx, hMd->pred_mat_re_idx, 1, min_pred_idx, max_pred_idx ); + for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + sym_adj_idx[ch1][ch2] = isar_split_rend_huffman_decode_opt( &pHuff_cfg->pred[pred_cb_idx], pBits, pHuff_cfg->pred_idx_trav[pred_cb_idx] ); + } + } + isar_SplitRenderer_getdiagdiff( sym_adj_idx, hMd->pred_mat_im_idx, -1, min_pred_idx, max_pred_idx ); + } + for ( ; b < pred_real_bands_yaw; b++ ) + { + hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b]; + for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + sym_adj_idx[ch1][ch1] = isar_split_rend_huffman_decode_opt( &pHuff_cfg->pred[pred_cb_idx], pBits, pHuff_cfg->pred_idx_trav[pred_cb_idx] ); + } + sym_adj_idx[1][0] = 0; + sym_adj_idx[0][1] = 0; + isar_SplitRenderer_getdiagdiff( sym_adj_idx, hMd->pred_mat_re_idx, -1, min_pred_idx, max_pred_idx ); + } +#endif + for ( b = 0; b < d_bands_yaw; b++ ) + { + hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b]; + hMd->gd_idx = isar_split_rend_huffman_decode_opt( &pHuff_cfg->gd, pBits, pHuff_cfg->gd_idx_trav ); + } + } + else if ( hBinHrSplitPostRend->pose_type[pos_idx] == PITCH_ONLY ) + { + for ( b = 0; b < bands_pitch; b++ ) + { + hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b]; + hMd->gd_idx = isar_split_rend_huffman_decode_opt( &pHuff_cfg->p_gd, pBits, pHuff_cfg->p_gd_idx_trav ); + + hMd->gd2_idx = isar_split_rend_huffman_decode_opt( &pHuff_cfg->p_gd, pBits, pHuff_cfg->p_gd_idx_trav ); + } + } + else + { +#ifndef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS + for ( b = 0; b < pred_real_bands_roll; b++ ) + { + hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b]; + + for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + sym_adj_idx[ch1][ch2] = isar_split_rend_huffman_decode_opt( &pHuff_cfg->pred_roll, pBits, pHuff_cfg->pred_roll_idx_trav ); + } + } + isar_SplitRenderer_getdiagdiff( sym_adj_idx, hMd->pred_mat_re_idx, 1, min_pred_roll_idx, max_pred_roll_idx ); + } + for ( b = 0; b < pred_imag_bands_roll; b++ ) + { + hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b]; + for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + sym_adj_idx[ch1][ch2] = isar_split_rend_huffman_decode_opt( &pHuff_cfg->pred_roll, pBits, pHuff_cfg->pred_roll_idx_trav ); + } + } + isar_SplitRenderer_getdiagdiff( sym_adj_idx, hMd->pred_mat_im_idx, -1, min_pred_roll_idx, max_pred_roll_idx ); + } +#else + for ( b = 0; b < pred_imag_bands_roll; b++ ) + { + hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b]; + + for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + sym_adj_idx[ch1][ch2] = isar_split_rend_huffman_decode_opt( &pHuff_cfg->pred_roll, pBits, pHuff_cfg->pred_roll_idx_trav ); + } + } + isar_SplitRenderer_getdiagdiff( sym_adj_idx, hMd->pred_mat_re_idx, 1, min_pred_roll_idx, max_pred_roll_idx ); + for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + sym_adj_idx[ch1][ch2] = isar_split_rend_huffman_decode_opt( &pHuff_cfg->pred_roll, pBits, pHuff_cfg->pred_roll_idx_trav ); + } + } + isar_SplitRenderer_getdiagdiff( sym_adj_idx, hMd->pred_mat_im_idx, -1, min_pred_roll_idx, max_pred_roll_idx ); + } + + for ( ; b < pred_real_bands_roll; b++ ) + { + hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b]; + + for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + sym_adj_idx[ch1][ch1] = isar_split_rend_huffman_decode_opt( &pHuff_cfg->pred_roll, pBits, pHuff_cfg->pred_roll_idx_trav ); + } + sym_adj_idx[1][0] = 0; + sym_adj_idx[0][1] = 0; + isar_SplitRenderer_getdiagdiff( sym_adj_idx, hMd->pred_mat_re_idx, -1, min_pred_roll_idx, max_pred_roll_idx ); + } +#endif + } + } + } + + return; +} + + +/*-----------------------------------------------------------------------------------------* + * Function isar_splitBinPostRendMdDec() + * + * + *-----------------------------------------------------------------------------------------*/ + +void isar_splitBinPostRendMdDec( + ISAR_SPLIT_REND_BITS_HANDLE pBits, + ISAR_BIN_HR_SPLIT_POST_REND_HANDLE hBinHrSplitPostRend, + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG + , + BIN_HR_SPLIT_PRE_REND_HANDLE hBinHrSplitPreRend +#endif +) +{ + int16_t pos_idx, b, sf_idx, num_subframes, ch1; + int16_t pred_real_bands_yaw[ISAR_SPLIT_REND_NUM_QUANT_STRATS], pred_real_bands_roll[ISAR_SPLIT_REND_NUM_QUANT_STRATS]; + int16_t pred_imag_bands_yaw[ISAR_SPLIT_REND_NUM_QUANT_STRATS], pred_imag_bands_roll[ISAR_SPLIT_REND_NUM_QUANT_STRATS]; + int16_t d_bands_yaw[ISAR_SPLIT_REND_NUM_QUANT_STRATS], bands_pitch[ISAR_SPLIT_REND_NUM_QUANT_STRATS]; +#ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS + int16_t num_quant_strats; +#else + int16_t num_complex_bands, num_quant_strats; +#endif + int32_t quant_strat_bits, is_huff_coding, quant_strat; + int16_t pred_quant_pnts_yaw[ISAR_SPLIT_REND_NUM_QUANT_STRATS]; + float pred_1byquantstep_yaw[ISAR_SPLIT_REND_NUM_QUANT_STRATS]; + float pred_quantstep_yaw[ISAR_SPLIT_REND_NUM_QUANT_STRATS]; +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG + int16_t ch1, ch2; +#endif + ISAR_BIN_HR_SPLIT_REND_MD_HANDLE hMd; + ISAR_SPLIT_REND_CONFIG_DATA split_rend_config; + ISAR_SPLIT_REND_ROT_AXIS rot_axis; +#ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS + int16_t ro_md_flag, num_bits, axis_code; +#endif + + hBinHrSplitPostRend->low_Res = 1; + + split_rend_config.dof = (int16_t) ISAR_SPLIT_REND_BITStream_read_int32( pBits, ISAR_SPLIT_REND_DOF_BITS ); + split_rend_config.hq_mode = (int16_t) ISAR_SPLIT_REND_BITStream_read_int32( pBits, ISAR_SPLIT_REND_HQ_MODE_BITS ); + +#ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS + num_bits = isar_renderSplitGetRot_axisNumBits( split_rend_config.dof ); + if ( num_bits > 0 ) + { + axis_code = (int16_t) ISAR_SPLIT_REND_BITStream_read_int32( pBits, (int32_t) num_bits ); + } + else + { + axis_code = 0; + } + rot_axis = isar_renderSplitGetRot_axisFromCode( split_rend_config.dof, axis_code ); + ro_md_flag = (int16_t) ISAR_SPLIT_REND_BITStream_read_int32( pBits, ISAR_SPLIT_REND_RO_FLAG_BITS ); +#else + rot_axis = (ISAR_SPLIT_REND_ROT_AXIS) ISAR_SPLIT_REND_BITStream_read_int32( pBits, ISAR_SPLIT_REND_ROT_AXIS_BITS ); +#endif + + isar_renderSplitGetMultiBinPoseData( &split_rend_config, pMultiBinPoseData, rot_axis ); + + set_fix_rotation_mat( hBinHrSplitPostRend->fix_pos_rot_mat, pMultiBinPoseData ); + set_pose_types( hBinHrSplitPostRend->pose_type, pMultiBinPoseData ); + + num_subframes = ( hBinHrSplitPostRend->low_Res == 0 ) ? MAX_PARAM_SPATIAL_SUBFRAMES : 1; + for ( sf_idx = 0; sf_idx < num_subframes; sf_idx++ ) + { + int16_t angle; + + hBinHrSplitPostRend->QuaternionsPre[sf_idx].w = -3.0f; + + angle = (int16_t) ISAR_SPLIT_REND_BITStream_read_int32( pBits, ISAR_SPLIT_REND_HEAD_POSE_BITS ); + angle -= 180; + hBinHrSplitPostRend->QuaternionsPre[sf_idx].x = (float) angle; + + angle = (int16_t) ISAR_SPLIT_REND_BITStream_read_int32( pBits, ISAR_SPLIT_REND_HEAD_POSE_BITS ); + angle -= 180; + hBinHrSplitPostRend->QuaternionsPre[sf_idx].y = (float) angle; + + angle = (int16_t) ISAR_SPLIT_REND_BITStream_read_int32( pBits, ISAR_SPLIT_REND_HEAD_POSE_BITS ); + angle -= 180; + hBinHrSplitPostRend->QuaternionsPre[sf_idx].z = (float) angle; + } + +#ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS + isar_split_rend_get_quant_params( + MAX_SPLIT_REND_MD_BANDS, + pred_real_bands_yaw, + pred_imag_bands_yaw, + pred_quant_pnts_yaw, + pred_quantstep_yaw, + pred_1byquantstep_yaw, + d_bands_yaw, + bands_pitch, + pred_real_bands_roll, + pred_imag_bands_roll, + ro_md_flag, + &num_quant_strats ); +#else + isar_split_rend_get_quant_params( + MAX_SPLIT_REND_MD_BANDS, + pred_real_bands_yaw, + pred_imag_bands_yaw, + pred_quant_pnts_yaw, + pred_quantstep_yaw, + pred_1byquantstep_yaw, + d_bands_yaw, + bands_pitch, + pred_real_bands_roll, + pred_imag_bands_roll, + &num_quant_strats, + &num_complex_bands ); +#endif + + quant_strat_bits = (int32_t) ceilf( log2f( num_quant_strats ) ); + is_huff_coding = ISAR_SPLIT_REND_BITStream_read_int32( pBits, 1 ); + quant_strat = ISAR_SPLIT_REND_BITStream_read_int32( pBits, quant_strat_bits ); + + if ( is_huff_coding == 0 ) + { + isar_splitBinPostRendMdBase2Dec( + pBits, hBinHrSplitPostRend, + pMultiBinPoseData, + num_subframes, + pred_real_bands_yaw[quant_strat], + pred_imag_bands_yaw[quant_strat], + pred_quant_pnts_yaw[quant_strat], + d_bands_yaw[quant_strat], + bands_pitch[quant_strat], + pred_real_bands_roll[quant_strat], + pred_imag_bands_roll[quant_strat] ); + } + else + { + isar_splitBinPostRendMdHuffDec( + pBits, hBinHrSplitPostRend, + pMultiBinPoseData, + num_subframes, + pred_real_bands_yaw[quant_strat], + pred_imag_bands_yaw[quant_strat], + pred_quant_pnts_yaw[quant_strat], + d_bands_yaw[quant_strat], + bands_pitch[quant_strat], + pred_real_bands_roll[quant_strat], + pred_imag_bands_roll[quant_strat] ); + } +#ifdef SPLIT_MD_CODING_DEBUG + for ( sf_idx = 0; sf_idx < num_subframes; sf_idx++ ) + { + int16_t val, ch2, val_ref; + char filename[200] = "split_md_debug_indices.bin"; + for ( pos_idx = 0; pos_idx < pMultiBinPoseData->num_poses - 1; pos_idx++ ) + { + if ( hBinHrSplitPostRend->pose_type[pos_idx] == ANY_YAW ) + { + for ( b = 0; b < pred_real_bands_yaw[quant_strat]; b++ ) + { + for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + val = hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b].pred_mat_re_idx[ch1][ch2]; + dbgread( &val_ref, sizeof( int16_t ), 1, filename ); + if ( abs( val_ref - val ) > 0 ) + { + assert( 0 ); + } + } + } + } + for ( b = 0; b < pred_imag_bands_yaw[quant_strat]; b++ ) + { + for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + val = hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b].pred_mat_im_idx[ch1][ch2]; + dbgread( &val_ref, sizeof( int16_t ), 1, filename ); + if ( abs( val_ref - val ) > 0 ) + { + assert( 0 ); + } + } + } + } + for ( b = 0; b < d_bands_yaw[quant_strat]; b++ ) + { + val = hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b].gd_idx; + dbgread( &val_ref, sizeof( int16_t ), 1, filename ); + if ( abs( val_ref - val ) > 0 ) + { + assert( 0 ); + } + } + } + else if ( hBinHrSplitPostRend->pose_type[pos_idx] == PITCH_ONLY ) + { + for ( b = 0; b < bands_pitch[quant_strat]; b++ ) + { + val = hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b].gd_idx; + dbgread( &val_ref, sizeof( int16_t ), 1, filename ); + if ( abs( val_ref - val ) > 0 ) + { + assert( 0 ); + } + val = hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b].gd2_idx; + dbgread( &val_ref, sizeof( int16_t ), 1, filename ); + if ( abs( val_ref - val ) > 0 ) + { + assert( 0 ); + } + } + } + else + { + for ( b = 0; b < pred_real_bands_roll[quant_strat]; b++ ) + { + for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + val = hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b].pred_mat_re_idx[ch1][ch2]; + dbgread( &val_ref, sizeof( int16_t ), 1, filename ); + if ( abs( val_ref - val ) > 0 ) + { + assert( 0 ); + } + } + } + } + for ( b = 0; b < pred_imag_bands_roll[quant_strat]; b++ ) + { + for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + val = hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b].pred_mat_im_idx[ch1][ch2]; + dbgread( &val_ref, sizeof( int16_t ), 1, filename ); + if ( abs( val_ref - val ) > 0 ) + { + assert( 0 ); + } + } + } + } + } + } + } +#endif + + for ( sf_idx = 0; sf_idx < num_subframes; sf_idx++ ) + { + for ( pos_idx = 0; pos_idx < pMultiBinPoseData->num_poses - 1; pos_idx++ ) + { + if ( hBinHrSplitPostRend->pose_type[pos_idx] == ANY_YAW ) + { + for ( b = 0; b < pred_imag_bands_yaw[quant_strat]; b++ ) + { + hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b]; + isar_split_rend_unquant_md( hMd, PRED_ONLY, 0, hBinHrSplitPostRend->fix_pos_rot_mat[pos_idx], pred_quantstep_yaw[quant_strat] ); + } + for ( ; b < pred_real_bands_yaw[quant_strat]; b++ ) + { + hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b]; + isar_split_rend_unquant_md( hMd, PRED_ONLY, 1, hBinHrSplitPostRend->fix_pos_rot_mat[pos_idx], pred_quantstep_yaw[quant_strat] ); + } + for ( ; b < MAX_SPLIT_REND_MD_BANDS; b++ ) + { + hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b]; + for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + set_zero( hMd->pred_mat_re[ch1], BINAURAL_CHANNELS ); + set_zero( hMd->pred_mat_im[ch1], BINAURAL_CHANNELS ); + hMd->pred_mat_re[ch1][ch1] = 1.0f; + } + } + for ( b = 0; b < d_bands_yaw[quant_strat]; b++ ) + { + hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b]; + isar_split_rend_unquant_md( hMd, COM_GAIN_ONLY, 1, hBinHrSplitPostRend->fix_pos_rot_mat[pos_idx], 0 ); + } + for ( ; b < MAX_SPLIT_REND_MD_BANDS; b++ ) + { + hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b]; + hMd->gd = 0.0f; + } + } + else if ( hBinHrSplitPostRend->pose_type[pos_idx] == PITCH_ONLY ) + { + for ( b = 0; b < bands_pitch[quant_strat]; b++ ) + { + hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b]; + isar_split_rend_unquant_md( hMd, LR_GAIN_ONLY, 1, hBinHrSplitPostRend->fix_pos_rot_mat[pos_idx], 0 ); + } + for ( ; b < MAX_SPLIT_REND_MD_BANDS; b++ ) + { + hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b]; + hMd->gd = 1.0f; + hMd->gd2 = 1.0f; + } + } + else + { + for ( b = 0; b < pred_imag_bands_roll[quant_strat]; b++ ) + { + hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b]; + isar_split_rend_unquant_md( hMd, PRED_ROLL_ONLY, 0, hBinHrSplitPostRend->fix_pos_rot_mat[pos_idx], ISAR_SPLIT_REND_PRED_ROLL_Q_STEP ); + } + for ( ; b < pred_real_bands_roll[quant_strat]; b++ ) + { + hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b]; + isar_split_rend_unquant_md( hMd, PRED_ROLL_ONLY, 1, hBinHrSplitPostRend->fix_pos_rot_mat[pos_idx], ISAR_SPLIT_REND_PRED_ROLL_Q_STEP ); + } + for ( ; b < MAX_SPLIT_REND_MD_BANDS; b++ ) + { + hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b]; + for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + set_zero( hMd->pred_mat_re[ch1], BINAURAL_CHANNELS ); + set_zero( hMd->pred_mat_im[ch1], BINAURAL_CHANNELS ); + hMd->pred_mat_re[ch1][ch1] = 1.0f; + } + } + } + } + } + +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG + for ( sf_idx = 0; sf_idx < num_subframes; sf_idx++ ) + { + float val; + for ( pos_idx = 0; pos_idx < pMultiBinPoseData->num_poses - 1; pos_idx++ ) + { + if ( hBinHrSplitPostRend->pose_type[pos_idx] == ANY_YAW ) + { + for ( b = 0; b < pred_real_bands_yaw[quant_strat]; b++ ) + { + for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + val = hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].pred_mat_re_idx[ch1][ch2]; + if ( fabsf( hMd->pred_mat_re_idx[ch1][ch2] - val ) > 1e-20 ) + { + assert( 0 ); + } + } + } + } + for ( b = 0; b < pred_imag_bands_yaw[quant_strat]; b++ ) + { + for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + val = hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].pred_mat_im_idx[ch1][ch2]; + if ( fabsf( hMd->pred_mat_im_idx[ch1][ch2] - val ) > 1e-20 ) + { + assert( 0 ); + } + } + } + } + for ( b = 0; b < d_bands_yaw[quant_strat]; b++ ) + { + val = hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].gd_idx; + if ( fabsf( hMd->gd_idx - val ) > 1e-20 ) + { + assert( 0 ); + } + } + } + else if ( hBinHrSplitPostRend->pose_type[pos_idx] == PITCH_ONLY ) + { + for ( b = 0; b < bands_pitch[quant_strat]; b++ ) + { + val = hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].gd_idx; + if ( fabsf( hMd->gd_idx - val ) > 1e-20 ) + { + assert( 0 ); + } + val = hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].gd2_idx; + if ( fabsf( hMd->gd2_idx - val ) > 1e-20 ) + { + assert( 0 ); + } + } + } + else + { + for ( b = 0; b < pred_real_bands_roll[quant_strat]; b++ ) + { + for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + val = hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].pred_mat_re_idx[ch1][ch2]; + if ( fabsf( hMd->pred_mat_re_idx[ch1][ch2] - val ) > 1e-20 ) + { + assert( 0 ); + } + } + } + } + for ( b = 0; b < pred_imag_bands_roll[quant_strat]; b++ ) + { + for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + val = hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].pred_mat_im_idx[ch1][ch2]; + if ( fabsf( hMd->pred_mat_im_idx[ch1][ch2] - val ) > 1e-20 ) + { + assert( 0 ); + } + } + } + } + } + } + } +#endif + + return; +} + + +/*-----------------------------------------------------------------------------------------* + * Function wrap_around_angle() + * + * + *-----------------------------------------------------------------------------------------*/ + +static void wrap_around_angle( + float *a ) +{ + if ( ( *a ) > 180.0f ) + { + ( *a ) = ( *a ) - 360; + } + else if ( ( *a ) < -180.0f ) + { + ( *a ) = ( *a ) + 360; + } + return; +} + + +/*-----------------------------------------------------------------------------------------* + * Function wrap_around_angle() + * + * + *-----------------------------------------------------------------------------------------*/ + +static void wrap_around_ypr( + IVAS_QUATERNION *Quaternions ) +{ + /*only if quat is actually yaw, pitch , roll angles*/ + if ( Quaternions->w == -3.0f ) + { + wrap_around_angle( &Quaternions->x ); + wrap_around_angle( &Quaternions->y ); + wrap_around_angle( &Quaternions->z ); + } + return; +} + + +/*-----------------------------------------------------------------------------------------* + * Function wrap_around_angle() + * + * + *-----------------------------------------------------------------------------------------*/ + +static float get_interp_fact( + float p[MAX_HEAD_ROT_POSES], + const float p_t, + const int16_t ind[2] ) +{ + float n, d, interp_fact; + + if ( ind[0] != ind[1] ) + { + n = p[ind[0]] - p[ind[1]]; + d = p[ind[0]] - p_t; + interp_fact = d / n; + if ( interp_fact < 0.0f ) + { + d = max( -1.0f * MAX_EXTRAPOLATION_ANGLE, ( min( MAX_EXTRAPOLATION_ANGLE, d ) ) ); + n = sinf( n * ( EVS_PI / 180.0f ) ); + d = sinf( d * ( EVS_PI / 180.0f ) ); + interp_fact = d / n; + } + } + else + { + interp_fact = 0.0f; + } + + return interp_fact; +} + + +/*-----------------------------------------------------------------------------------------* + * Function get_nearest_pose_ind() + * + * + *-----------------------------------------------------------------------------------------*/ + +static void get_nearest_pose_ind( + float p[MAX_HEAD_ROT_POSES], + const float p_t, + int16_t ind[2], + const int16_t num_poses ) +{ + float min_diff, diff; + int16_t pos_idx; + + ind[0] = 0; + ind[1] = 0; + min_diff = 360.0f; + + /*find the closest pose from assumed poses*/ + for ( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) + { + diff = fabsf( p_t - p[pos_idx] ); + if ( diff < min_diff ) + { + ind[0] = pos_idx; + min_diff = (float) diff; + } + } + + min_diff = 360.0; + for ( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) + { + diff = fabsf( p_t - p[pos_idx] ); + if ( ( diff < min_diff ) && + ( fabs( p[pos_idx] - p[ind[0]] ) > EPSILON ) ) + { + ind[1] = pos_idx; + min_diff = (float) diff; + } + } + + return; +} + + +/*-----------------------------------------------------------------------------------------* + * Function get_interpolation_vars() + * + * + *-----------------------------------------------------------------------------------------*/ + +static void get_interpolation_vars( + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + const IVAS_QUATERNION *Quaternions_ref, + const IVAS_QUATERNION *Quaternions_act, + int16_t interp_yaw_pose_idx[2], + int16_t interp_pitch_pose_idx[2], + int16_t interp_roll_pose_idx[2], + float *interp_yaw_fact, + float *interp_pitch_fact, + float *interp_roll_fact ) +{ + IVAS_QUATERNION quaternions_diff, quaternions_ref_euler, quaternions_act_euler; + float y[MAX_HEAD_ROT_POSES], p[MAX_HEAD_ROT_POSES], r[MAX_HEAD_ROT_POSES]; + int16_t pos_idx, num_poses; + + quaternions_diff.x = 0.0f; + quaternions_diff.y = 0.0f; + quaternions_diff.z = 0.0f; + + num_poses = pMultiBinPoseData->num_poses; + for ( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) + { + quaternions_diff.x = pMultiBinPoseData->relative_head_poses[pos_idx][0]; + quaternions_diff.y = pMultiBinPoseData->relative_head_poses[pos_idx][1]; + quaternions_diff.z = pMultiBinPoseData->relative_head_poses[pos_idx][2]; + y[pos_idx] = quaternions_diff.x; + p[pos_idx] = quaternions_diff.y; + r[pos_idx] = quaternions_diff.z; + } + + /*interpolation if actual pose is not same as one of assumed poses*/ + /*get the deviation*/ + Quat2EulerDegree( *Quaternions_ref, &quaternions_ref_euler.z, &quaternions_ref_euler.y, &quaternions_ref_euler.x ); /*order in Quat2Euler seems to be reversed ?*/ + Quat2EulerDegree( *Quaternions_act, &quaternions_act_euler.z, &quaternions_act_euler.y, &quaternions_act_euler.x ); /*order in Quat2Euler seems to be reversed ?*/ + quaternions_diff.w = -3.0f; /*euler*/ + quaternions_diff.x = quaternions_act_euler.x - quaternions_ref_euler.x; + quaternions_diff.y = quaternions_act_euler.y - quaternions_ref_euler.y; + quaternions_diff.z = quaternions_act_euler.z - quaternions_ref_euler.z; + wrap_around_ypr( &quaternions_diff ); + + interp_yaw_pose_idx[0] = 0; + interp_yaw_pose_idx[1] = 0; + if ( fabs( quaternions_diff.x ) > EPSILON ) + { + get_nearest_pose_ind( y, quaternions_diff.x, interp_yaw_pose_idx, num_poses ); + } + *interp_yaw_fact = get_interp_fact( y, quaternions_diff.x, interp_yaw_pose_idx ); + + interp_pitch_pose_idx[0] = 0; + interp_pitch_pose_idx[1] = 0; + if ( fabs( quaternions_diff.y ) > EPSILON ) + { + get_nearest_pose_ind( p, quaternions_diff.y, interp_pitch_pose_idx, num_poses ); + } + *interp_pitch_fact = get_interp_fact( p, quaternions_diff.y, interp_pitch_pose_idx ); + + interp_roll_pose_idx[0] = 0; + interp_roll_pose_idx[1] = 0; + if ( fabs( quaternions_diff.z ) > EPSILON ) + { + get_nearest_pose_ind( r, quaternions_diff.z, interp_roll_pose_idx, num_poses ); + } + *interp_roll_fact = get_interp_fact( r, quaternions_diff.z, interp_roll_pose_idx ); + + return; +} + + +/*-----------------------------------------------------------------------------------------* + * Function interpolate_pred_matrix() + * + * + *-----------------------------------------------------------------------------------------*/ + +static void interpolate_pred_matrix( + ISAR_BIN_HR_SPLIT_REND_MD rot_md[][MAX_SPLIT_MD_SUBFRAMES][MAX_SPLIT_REND_MD_BANDS], + const int16_t sf_idx, + const int16_t band_idx, + const int16_t ind[2], + const float interp_fact, + float mat_re[BINAURAL_CHANNELS][BINAURAL_CHANNELS], + float mat_im[BINAURAL_CHANNELS][BINAURAL_CHANNELS] ) +{ + int16_t ch_idx1, ch_idx2; + float diff; + ISAR_BIN_HR_SPLIT_REND_MD *pRot_md; + float mix_mat_re1[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + float mix_mat_im1[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + float mix_mat_re2[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + float mix_mat_im2[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + + for ( ch_idx1 = 0; ch_idx1 < BINAURAL_CHANNELS; ch_idx1++ ) + { + set_zero( mix_mat_re1[ch_idx1], BINAURAL_CHANNELS ); + set_zero( mix_mat_im1[ch_idx1], BINAURAL_CHANNELS ); + mix_mat_re1[ch_idx1][ch_idx1] = 1.0f; + + set_zero( mix_mat_re2[ch_idx1], BINAURAL_CHANNELS ); + set_zero( mix_mat_im2[ch_idx1], BINAURAL_CHANNELS ); + mix_mat_re2[ch_idx1][ch_idx1] = 1.0f; + } + + if ( ind[0] != 0 ) + { + pRot_md = &rot_md[ind[0] - 1][sf_idx][band_idx]; + + for ( ch_idx1 = 0; ch_idx1 < BINAURAL_CHANNELS; ch_idx1++ ) + { + for ( ch_idx2 = 0; ch_idx2 < BINAURAL_CHANNELS; ch_idx2++ ) + { + mix_mat_re1[ch_idx1][ch_idx2] = pRot_md->pred_mat_re[ch_idx1][ch_idx2]; + mix_mat_im1[ch_idx1][ch_idx2] = pRot_md->pred_mat_im[ch_idx1][ch_idx2]; + } + } + } + + if ( ind[1] != 0 ) + { + pRot_md = &rot_md[ind[1] - 1][sf_idx][band_idx]; + + for ( ch_idx1 = 0; ch_idx1 < BINAURAL_CHANNELS; ch_idx1++ ) + { + for ( ch_idx2 = 0; ch_idx2 < BINAURAL_CHANNELS; ch_idx2++ ) + { + mix_mat_re2[ch_idx1][ch_idx2] = pRot_md->pred_mat_re[ch_idx1][ch_idx2]; + mix_mat_im2[ch_idx1][ch_idx2] = pRot_md->pred_mat_im[ch_idx1][ch_idx2]; + } + } + } + + for ( ch_idx1 = 0; ch_idx1 < BINAURAL_CHANNELS; ch_idx1++ ) + { + for ( ch_idx2 = 0; ch_idx2 < BINAURAL_CHANNELS; ch_idx2++ ) + { + diff = mix_mat_re1[ch_idx1][ch_idx2] - mix_mat_re2[ch_idx1][ch_idx2]; + mat_re[ch_idx1][ch_idx2] = mix_mat_re1[ch_idx1][ch_idx2] - ( diff * interp_fact ); + + diff = mix_mat_im1[ch_idx1][ch_idx2] - mix_mat_im2[ch_idx1][ch_idx2]; + mat_im[ch_idx1][ch_idx2] = mix_mat_im1[ch_idx1][ch_idx2] - ( diff * interp_fact ); + } + } + + return; +} + + +/*-----------------------------------------------------------------------------------------* + * Function interpolate_rend_md() + * + * + *-----------------------------------------------------------------------------------------*/ + +static void interpolate_rend_md( + ISAR_BIN_HR_SPLIT_REND_MD rot_md[][MAX_SPLIT_MD_SUBFRAMES][MAX_SPLIT_REND_MD_BANDS], + float mix_mat_re[][BINAURAL_CHANNELS], + float mix_mat_im[][BINAURAL_CHANNELS], + float *gd_int, + const int16_t sf_idx, + const int16_t band_idx, + const int16_t interp_yaw_pose_idx[2], + const int16_t interp_pitch_pose_idx[2], + const int16_t interp_roll_pose_idx[2], + const float interp_yaw_fact, + const float interp_pitch_fact, + const float interp_roll_fact ) +{ + int16_t ch_idx1, idx1, idx2; + float mix_mat_re1[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + float mix_mat_im1[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + float mix_mat_re3[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + float mix_mat_im3[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + int16_t ch_idx2; + float gd1, gd2, gd3, gd4, diff, pitch_gain_r, pitch_gain_l; + + gd1 = 0.0f; + gd2 = 0.0f; + + idx1 = interp_yaw_pose_idx[0]; + idx2 = interp_yaw_pose_idx[1]; + if ( ( idx1 != 0 ) || ( idx2 != 0 ) ) + { + interpolate_pred_matrix( rot_md, sf_idx, band_idx, interp_yaw_pose_idx, interp_yaw_fact, mix_mat_re, mix_mat_im ); + + if ( idx1 != 0 ) + { + gd1 = rot_md[idx1 - 1][sf_idx][band_idx].gd; + } + + if ( idx2 != 0 ) + { + gd2 = rot_md[idx2 - 1][sf_idx][band_idx].gd; + } + + diff = gd1 - gd2; + *gd_int = gd1 - ( diff * interp_yaw_fact ); + } + else + { + /*P = P'*/ + for ( ch_idx1 = 0; ch_idx1 < BINAURAL_CHANNELS; ch_idx1++ ) + { + set_zero( mix_mat_re[ch_idx1], BINAURAL_CHANNELS ); + set_zero( mix_mat_im[ch_idx1], BINAURAL_CHANNELS ); + mix_mat_re[ch_idx1][ch_idx1] = 1.0f; + } + *gd_int = 0.0f; + } + + idx1 = interp_pitch_pose_idx[0]; + idx2 = interp_pitch_pose_idx[1]; + if ( ( idx1 != 0 ) || ( idx2 != 0 ) ) + { + gd1 = 1.0f; + gd2 = 1.0f; + + gd3 = 1.0f; + gd4 = 1.0f; + + if ( idx1 != 0 ) + { + gd1 = rot_md[idx1 - 1][sf_idx][band_idx].gd; + gd3 = rot_md[idx1 - 1][sf_idx][band_idx].gd2; + } + if ( idx2 != 0 ) + { + gd2 = rot_md[idx2 - 1][sf_idx][band_idx].gd; + gd4 = rot_md[idx2 - 1][sf_idx][band_idx].gd2; + } + diff = gd1 - gd2; + pitch_gain_l = gd1 - ( diff * interp_pitch_fact ); + pitch_gain_l = max( 0.0f, pitch_gain_l ); + + diff = gd3 - gd4; + pitch_gain_r = gd3 - ( diff * interp_pitch_fact ); + pitch_gain_r = max( 0.0f, pitch_gain_r ); + + for ( ch_idx1 = 0; ch_idx1 < BINAURAL_CHANNELS; ch_idx1++ ) + { + mix_mat_re[ch_idx1][0] *= pitch_gain_l; + mix_mat_re[ch_idx1][1] *= pitch_gain_r; + mix_mat_im[ch_idx1][0] *= pitch_gain_l; + mix_mat_im[ch_idx1][1] *= pitch_gain_r; + } + } + else + { + pitch_gain_l = 1.0f; + pitch_gain_r = 1.0f; + } + + idx1 = interp_roll_pose_idx[0]; + idx2 = interp_roll_pose_idx[1]; + if ( ( idx1 != 0 ) || ( idx2 != 0 ) ) + { + interpolate_pred_matrix( rot_md, sf_idx, band_idx, interp_roll_pose_idx, interp_roll_fact, mix_mat_re3, mix_mat_im3 ); + + isar_mat_mult_2by2_complex( mix_mat_re, mix_mat_im, mix_mat_re3, mix_mat_im3, mix_mat_re1, mix_mat_im1 ); + + for ( ch_idx1 = 0; ch_idx1 < BINAURAL_CHANNELS; ch_idx1++ ) + { + for ( ch_idx2 = 0; ch_idx2 < BINAURAL_CHANNELS; ch_idx2++ ) + { + mix_mat_re[ch_idx1][ch_idx2] = mix_mat_re1[ch_idx1][ch_idx2]; + mix_mat_im[ch_idx1][ch_idx2] = mix_mat_im1[ch_idx1][ch_idx2]; + } + } + } + + return; +} + + +/*-----------------------------------------------------------------------------------------* + * Function isar_SplitRenderer_PostRenderer() + * + * + *-----------------------------------------------------------------------------------------*/ + +static void isar_SplitRenderer_PostRenderer( + ISAR_BIN_HR_SPLIT_POST_REND_HANDLE hBinPostRenderer, /* i/o: binaural renderer handle */ + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + float Cldfb_RealBuffer_Ref_Binaural[][CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o : Reference/out Binaural signals */ + float Cldfb_ImagBuffer_Ref_Binaural[][CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o : Reference/out Binaural signals */ + const IVAS_QUATERNION Quaternion_act ) +{ + int16_t pos_idx, b, brange[2], ch_idx1; + int16_t num_md_bands, slot_idx, b2, num_slots, sf_idx_md; + float pred_out_re[BINAURAL_CHANNELS], pred_out_im[BINAURAL_CHANNELS], tmp_re, tmp_im, gd_int; +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG + ISAR_BIN_HR_SPLIT_REND_MD rot_md_act[MAX_HEAD_ROT_POSES][MAX_SPLIT_REND_MD_BANDS]; +#else + ISAR_BIN_HR_SPLIT_REND_MD rot_md_act[1][MAX_SPLIT_REND_MD_BANDS]; +#endif + int16_t interp_yaw_pose_idx[2], interp_pitch_pose_idx[2], interp_roll_pose_idx[2]; + float interp_yaw_fact, interp_pitch_fact, interp_roll_fact; + float mix_mat_re[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + float mix_mat_im[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG + float Cldfb_RealBuffer_Recons_Binaural[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + float Cldfb_ImagBuffer_Recons_Binaural[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; +#endif + float fade; + float *pMix_mat_re_prev[BINAURAL_CHANNELS]; + float *pMix_mat_im_prev[BINAURAL_CHANNELS]; + const int16_t *pBand_grouping = isar_split_rend_band_grouping; + + num_md_bands = MAX_SPLIT_REND_MD_BANDS; + + push_wmops( "isar_SplitRenderer_PostRenderer" ); + + num_slots = MAX_PARAM_SPATIAL_SUBFRAMES; +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG + pos_idx = MAX_HEAD_ROT_POSES - 1; +#else + pos_idx = 0; +#endif + + sf_idx_md = 0; + get_interpolation_vars( pMultiBinPoseData, &hBinPostRenderer->QuaternionsPre[sf_idx_md], &Quaternion_act, interp_yaw_pose_idx, interp_pitch_pose_idx, interp_roll_pose_idx, &interp_yaw_fact, &interp_pitch_fact, &interp_roll_fact ); + + for ( b = 0; b < num_md_bands; b++ ) + { + for ( ch_idx1 = 0; ch_idx1 < BINAURAL_CHANNELS; ch_idx1++ ) + { + set_zero( mix_mat_re[ch_idx1], BINAURAL_CHANNELS ); + set_zero( mix_mat_im[ch_idx1], BINAURAL_CHANNELS ); + mix_mat_re[ch_idx1][ch_idx1] = 1.0f; + } + gd_int = 0.0f; + interpolate_rend_md( hBinPostRenderer->rot_md, mix_mat_re, mix_mat_im, &gd_int, sf_idx_md, b, interp_yaw_pose_idx, interp_pitch_pose_idx, interp_roll_pose_idx, interp_yaw_fact, interp_pitch_fact, interp_roll_fact ); + + for ( ch_idx1 = 0; ch_idx1 < BINAURAL_CHANNELS; ch_idx1++ ) + { + /*update the prediction matrix with interpolated matrix*/ + rot_md_act[pos_idx][b].pred_mat_re[ch_idx1][0] = mix_mat_re[ch_idx1][0]; + rot_md_act[pos_idx][b].pred_mat_re[ch_idx1][1] = mix_mat_re[ch_idx1][1]; + rot_md_act[pos_idx][b].pred_mat_im[ch_idx1][0] = mix_mat_im[ch_idx1][0]; + rot_md_act[pos_idx][b].pred_mat_im[ch_idx1][1] = mix_mat_im[ch_idx1][1]; + rot_md_act[pos_idx][b].gd = gd_int; + } + } + + +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG + for ( pos_idx = 0; pos_idx < MAX_HEAD_ROT_POSES - 1; pos_idx++ ) + { + for ( b = 0; b < num_md_bands; b++ ) + { + if ( hBinPostRenderer->pose_type[pos_idx] == PITCH_ONLY ) + { + + for ( ch_idx1 = 0; ch_idx1 < BINAURAL_CHANNELS; ch_idx1++ ) + { + set_zero( hBinPostRenderer->rot_md[pos_idx][sf_idx][b].pred_mat_re[ch_idx1], BINAURAL_CHANNELS ); + set_zero( hBinPostRenderer->rot_md[pos_idx][sf_idx][b].pred_mat_im[ch_idx1], BINAURAL_CHANNELS ); + hBinPostRenderer->rot_md[pos_idx][sf_idx][b].pred_mat_re[ch_idx1][ch_idx1] = 1.0f; + } + hBinPostRenderer->rot_md[pos_idx][sf_idx][b].pred_mat_re[0][0] *= hBinPostRenderer->rot_md[pos_idx][sf_idx][b].gd; + hBinPostRenderer->rot_md[pos_idx][sf_idx][b].pred_mat_re[1][1] *= hBinPostRenderer->rot_md[pos_idx][sf_idx][b].gd2; + hBinPostRenderer->rot_md[pos_idx][sf_idx][b].gd = 0.0f; + } + else if ( hBinPostRenderer->pose_type[pos_idx] == ANY_ROLL ) + { + hBinPostRenderer->rot_md[pos_idx][sf_idx][b].gd = 0.0f; + } + + for ( ch_idx1 = 0; ch_idx1 < BINAURAL_CHANNELS; ch_idx1++ ) + { + + /*update the prediction matrix with interpolated matrix*/ + rot_md_act[pos_idx][b].pred_mat_re[ch_idx1][0] = hBinPostRenderer->rot_md[pos_idx][sf_idx][b].pred_mat_re[ch_idx1][0]; + rot_md_act[pos_idx][b].pred_mat_re[ch_idx1][1] = hBinPostRenderer->rot_md[pos_idx][sf_idx][b].pred_mat_re[ch_idx1][1]; + rot_md_act[pos_idx][b].pred_mat_im[ch_idx1][0] = hBinPostRenderer->rot_md[pos_idx][sf_idx][b].pred_mat_im[ch_idx1][0]; + rot_md_act[pos_idx][b].pred_mat_im[ch_idx1][1] = hBinPostRenderer->rot_md[pos_idx][sf_idx][b].pred_mat_im[ch_idx1][1]; + rot_md_act[pos_idx][b].gd = hBinPostRenderer->rot_md[pos_idx][sf_idx][b].gd; + } + } + } + +#endif + +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG + for ( pos_idx = 0; pos_idx < MAX_HEAD_ROT_POSES; pos_idx++ ) +#else + pos_idx = 0; +#endif + { + for ( slot_idx = 0; slot_idx < num_slots; slot_idx++ ) + { + fade = ( (float) slot_idx + 1.0f ) / MAX_PARAM_SPATIAL_SUBFRAMES; + fade = min( fade, 1.0f ); + for ( b = 0; b < num_md_bands; b++ ) + { + for ( ch_idx1 = 0; ch_idx1 < BINAURAL_CHANNELS; ch_idx1++ ) + { + if ( hBinPostRenderer->cf_flag ) + { + pMix_mat_re_prev[ch_idx1] = hBinPostRenderer->mixer_mat_re[pos_idx][b][ch_idx1]; + pMix_mat_im_prev[ch_idx1] = hBinPostRenderer->mixer_mat_im[pos_idx][b][ch_idx1]; + mix_mat_re[ch_idx1][0] = fade * ( rot_md_act[pos_idx][b].pred_mat_re[ch_idx1][0] ) + + ( 1.0f - fade ) * pMix_mat_re_prev[ch_idx1][0]; + mix_mat_re[ch_idx1][1] = fade * ( rot_md_act[pos_idx][b].pred_mat_re[ch_idx1][1] ) + + ( 1.0f - fade ) * pMix_mat_re_prev[ch_idx1][1]; + + mix_mat_im[ch_idx1][0] = fade * ( rot_md_act[pos_idx][b].pred_mat_im[ch_idx1][0] ) + + ( 1.0f - fade ) * pMix_mat_im_prev[ch_idx1][0]; + mix_mat_im[ch_idx1][1] = fade * ( rot_md_act[pos_idx][b].pred_mat_im[ch_idx1][1] ) + + ( 1.0f - fade ) * pMix_mat_im_prev[ch_idx1][1]; + } + else + { + mix_mat_re[ch_idx1][0] = rot_md_act[pos_idx][b].pred_mat_re[ch_idx1][0]; + mix_mat_re[ch_idx1][1] = rot_md_act[pos_idx][b].pred_mat_re[ch_idx1][1]; + mix_mat_im[ch_idx1][0] = rot_md_act[pos_idx][b].pred_mat_im[ch_idx1][0]; + mix_mat_im[ch_idx1][1] = rot_md_act[pos_idx][b].pred_mat_im[ch_idx1][1]; + } + } + + brange[0] = pBand_grouping[b]; + brange[1] = pBand_grouping[b + 1]; + for ( b2 = brange[0]; b2 < brange[1]; b2++ ) + { + for ( ch_idx1 = 0; ch_idx1 < BINAURAL_CHANNELS; ch_idx1++ ) + { + /* Apply prediction matrix */ + IVAS_CMULT_FLOAT( Cldfb_RealBuffer_Ref_Binaural[0][slot_idx][b2], + Cldfb_ImagBuffer_Ref_Binaural[0][slot_idx][b2], + mix_mat_re[0][ch_idx1], + mix_mat_im[0][ch_idx1], + tmp_re, + tmp_im ); + pred_out_re[ch_idx1] = tmp_re; + pred_out_im[ch_idx1] = tmp_im; + + IVAS_CMULT_FLOAT( Cldfb_RealBuffer_Ref_Binaural[1][slot_idx][b2], + Cldfb_ImagBuffer_Ref_Binaural[1][slot_idx][b2], + mix_mat_re[1][ch_idx1], + mix_mat_im[1][ch_idx1], + tmp_re, + tmp_im ); + pred_out_re[ch_idx1] += tmp_re; + pred_out_im[ch_idx1] += tmp_im; + } + + + for ( ch_idx1 = 0; ch_idx1 < BINAURAL_CHANNELS; ch_idx1++ ) + { +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG + Cldfb_RealBuffer_Recons_Binaural[pos_idx][ch_idx1][slot_idx][b2] = pred_out_re[ch_idx1]; + Cldfb_ImagBuffer_Recons_Binaural[pos_idx][ch_idx1][slot_idx][b2] = pred_out_im[ch_idx1]; +#else + Cldfb_RealBuffer_Ref_Binaural[ch_idx1][slot_idx][b2] = pred_out_re[ch_idx1]; + Cldfb_ImagBuffer_Ref_Binaural[ch_idx1][slot_idx][b2] = pred_out_im[ch_idx1]; +#endif + } + } + } + } + } + +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG + for ( pos_idx = 0; pos_idx < MAX_HEAD_ROT_POSES; pos_idx++ ) +#else + pos_idx = 0; +#endif + { + for ( b = 0; b < num_md_bands; b++ ) + { + for ( ch_idx1 = 0; ch_idx1 < BINAURAL_CHANNELS; ch_idx1++ ) + { + hBinPostRenderer->mixer_mat_re[pos_idx][b][ch_idx1][0] = rot_md_act[pos_idx][b].pred_mat_re[ch_idx1][0]; + hBinPostRenderer->mixer_mat_re[pos_idx][b][ch_idx1][1] = rot_md_act[pos_idx][b].pred_mat_re[ch_idx1][1]; + hBinPostRenderer->mixer_mat_im[pos_idx][b][ch_idx1][0] = rot_md_act[pos_idx][b].pred_mat_im[ch_idx1][0]; + hBinPostRenderer->mixer_mat_im[pos_idx][b][ch_idx1][1] = rot_md_act[pos_idx][b].pred_mat_im[ch_idx1][1]; + } + hBinPostRenderer->gd_mem[pos_idx][b] = rot_md_act[pos_idx][b].gd; + } + } + hBinPostRenderer->cf_flag = 1; + +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG + { + int16_t num_cldfb_bands; + num_cldfb_bands = CLDFB_NO_CHANNELS_MAX; + for ( slot_idx = 0; slot_idx < num_slots; slot_idx++ ) + { + index_slot = sf_idx * num_slots + slot_idx; + for ( ch_idx1 = 0; ch_idx1 < BINAURAL_CHANNELS; ch_idx1++ ) + { + mvr2r( Cldfb_RealBuffer_Recons_Binaural[MAX_HEAD_ROT_POSES - 1][ch_idx1][index_slot], Cldfb_RealBuffer_Ref_Binaural[ch_idx1][index_slot], num_cldfb_bands ); + mvr2r( Cldfb_ImagBuffer_Recons_Binaural[MAX_HEAD_ROT_POSES - 1][ch_idx1][index_slot], Cldfb_ImagBuffer_Ref_Binaural[ch_idx1][index_slot], num_cldfb_bands ); + } + } + + for ( pos_idx = 0; pos_idx < MAX_HEAD_ROT_POSES; pos_idx++ ) + { + char fname[200] = "recons_out_pos"; + char tag[2]; + tag[0] = (char) ( '0' + pos_idx ); + tag[1] = '\0'; + strcat( fname, tag ); + strcat( fname, ".wav" ); + isar_log_cldfb2wav_data( + Cldfb_RealBuffer_Recons_Binaural[pos_idx], + Cldfb_ImagBuffer_Recons_Binaural[pos_idx], + hBinPostRenderer->cldfbSynReconsBinDec[pos_idx], + BINAURAL_CHANNELS, + num_cldfb_bands, + 48000, + num_slots, + sf_idx * num_slots, + fname ); + } + } +#endif + + pop_wmops(); + return; +} + + +/*-----------------------------------------------------------------------------------------* + * Function isar_rend_CldfbSplitPostRendProcessTdIn() + * + * + *-----------------------------------------------------------------------------------------*/ + +static void isar_rend_CldfbSplitPostRendProcessTdIn( + ISAR_BIN_HR_SPLIT_POST_REND_HANDLE hBinHrSplitPostRend, + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + const IVAS_QUATERNION QuaternionPost, + float output[][L_FRAME48k] ) +{ + int16_t ch_idx, slot_idx, num_cldfb_bands; + float Cldfb_RealBuffer_Binaural[BINAURAL_CHANNELS][CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; + float Cldfb_ImagBuffer_Binaural[BINAURAL_CHANNELS][CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; + num_cldfb_bands = hBinHrSplitPostRend->cldfbSyn[0]->no_channels; + + /* Implement CLDFB analysis */ + for ( ch_idx = 0; ch_idx < BINAURAL_CHANNELS; ch_idx++ ) + { + for ( slot_idx = 0; slot_idx < CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES; slot_idx++ ) + { + cldfbAnalysis_ts( &( output[ch_idx][num_cldfb_bands * slot_idx] ), + Cldfb_RealBuffer_Binaural[ch_idx][slot_idx], + Cldfb_ImagBuffer_Binaural[ch_idx][slot_idx], + num_cldfb_bands, + hBinHrSplitPostRend->cldfbAna[ch_idx] ); + } + } + + isar_SplitRenderer_PostRenderer( hBinHrSplitPostRend, pMultiBinPoseData, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, QuaternionPost ); + + /* Implement CLDFB synthesis */ + for ( ch_idx = 0; ch_idx < BINAURAL_CHANNELS; ch_idx++ ) + { + float *RealBuffer[CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES]; + float *ImagBuffer[CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES]; + + for ( slot_idx = 0; slot_idx < CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES; slot_idx++ ) + { + RealBuffer[slot_idx] = Cldfb_RealBuffer_Binaural[ch_idx][slot_idx]; + ImagBuffer[slot_idx] = Cldfb_ImagBuffer_Binaural[ch_idx][slot_idx]; + } + + cldfbSynthesis( RealBuffer, ImagBuffer, &( output[ch_idx][0] ), num_cldfb_bands * CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, hBinHrSplitPostRend->cldfbSyn[ch_idx] ); + } + + return; +} + + +/*-----------------------------------------------------------------------------------------* + * Function isar_rend_CldfbSplitPostRendProcess() + * + * + *-----------------------------------------------------------------------------------------*/ + +void isar_rend_CldfbSplitPostRendProcess( + ISAR_BIN_HR_SPLIT_POST_REND_HANDLE hBinHrSplitPostRend, + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + const IVAS_QUATERNION QuaternionPost, + float Cldfb_RealBuffer_Binaural[][CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], + float Cldfb_ImagBuffer_Binaural[][CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], + float output[][L_FRAME48k], + const int16_t cldfb_in_flag ) +{ + int16_t ch_idx, slot_idx, num_cldfb_bands; + + push_wmops( "isar_rend_CldfbSplitPostRendProcess" ); + + num_cldfb_bands = hBinHrSplitPostRend->cldfbSyn[0]->no_channels; + + if ( cldfb_in_flag == 0 ) + { + isar_rend_CldfbSplitPostRendProcessTdIn( hBinHrSplitPostRend, pMultiBinPoseData, QuaternionPost, output ); + pop_wmops(); + return; + } + + isar_SplitRenderer_PostRenderer( hBinHrSplitPostRend, pMultiBinPoseData, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, QuaternionPost ); + + /* Implement CLDFB synthesis */ + for ( ch_idx = 0; ch_idx < BINAURAL_CHANNELS; ch_idx++ ) + { + float *RealBuffer[CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES]; + float *ImagBuffer[CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES]; + + for ( slot_idx = 0; slot_idx < CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES; slot_idx++ ) + { + RealBuffer[slot_idx] = Cldfb_RealBuffer_Binaural[ch_idx][slot_idx]; + ImagBuffer[slot_idx] = Cldfb_ImagBuffer_Binaural[ch_idx][slot_idx]; + } + + cldfbSynthesis( RealBuffer, ImagBuffer, &( output[ch_idx][0] ), num_cldfb_bands * CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, hBinHrSplitPostRend->cldfbSyn[ch_idx] ); + } + + pop_wmops(); + return; +} + + +/*-----------------------------------------------------------------------------------------* + * Function isar_init_split_post_rend_handles() + * + * + *-----------------------------------------------------------------------------------------*/ + +void isar_init_split_post_rend_handles( + ISAR_SPLIT_POST_REND_WRAPPER *hSplitRendWrapper ) +{ + hSplitRendWrapper->hBinHrSplitPostRend = NULL; + hSplitRendWrapper->hSplitBinLCLDDec = NULL; + hSplitRendWrapper->hLc3plusDec = NULL; + isar_init_multi_bin_pose_data( &hSplitRendWrapper->multiBinPoseData ); + hSplitRendWrapper->first_good_frame_received = 0; + + return; +} +#endif diff --git a/lib_isar/isar_splitRendererPre.c b/lib_isar/isar_splitRendererPre.c new file mode 100644 index 0000000000000000000000000000000000000000..5c2f787a8dc10e1519aa5abad2c9e3d3a0cb2de6 --- /dev/null +++ b/lib_isar/isar_splitRendererPre.c @@ -0,0 +1,2340 @@ +/****************************************************************************************************** + + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#include +#include "options.h" +#ifdef SPLIT_REND_WITH_HEAD_ROT +#include +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG +#include +#endif +#include "ivas_prot.h" +#include "prot.h" +#include "isar_rom_post_rend.h" +#include "lib_isar_pre_rend.h" +#include "isar_prot.h" +#ifdef DEBUGGING +#include "debug.h" +#endif +#include "wmc_auto.h" +#ifdef DBG_WAV_WRITER +#include "string.h" +#endif + +/*---------------------------------------------------------------------* + * Local function declarations + *---------------------------------------------------------------------*/ + +static void isar_SplitRenderer_GetRotMd( + ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE hBinHrSplitPreRend, /* i/o: binaural renderer handle */ + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + float Cldfb_RealBuffer_Ref_Binaural[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* o : Reference Binaural signals */ + float Cldfb_ImagBuffer_Ref_Binaural[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* o : Reference Binaural signals */ + const int16_t low_res, + const int16_t ro_md_flag ); + +/*------------------------------------------------------------------------- + * Local functions + * + * + *------------------------------------------------------------------------*/ + +static void isar_calc_mat_det_2by2_complex( + float in_re[BINAURAL_CHANNELS][BINAURAL_CHANNELS], + float in_im[BINAURAL_CHANNELS][BINAURAL_CHANNELS], + float *det_re, + float *det_im ) +{ + float re1, im1, re2, im2; + + IVAS_CMULT_FLOAT( in_re[0][0], in_im[0][0], in_re[1][1], in_im[1][1], re1, im1 ); + IVAS_CMULT_FLOAT( in_re[0][1], in_im[0][1], in_re[1][0], in_im[1][0], re2, im2 ); + *det_re = re1 - re2; + *det_im = im1 - im2; + + return; +} + + +static int16_t isar_is_mat_inv_2by2_complex( + float in_re[BINAURAL_CHANNELS][BINAURAL_CHANNELS], + float in_im[BINAURAL_CHANNELS][BINAURAL_CHANNELS] ) +{ + int16_t is_det_zero = 1; + float det, det_re, det_im; + + isar_calc_mat_det_2by2_complex( in_re, in_im, &det_re, &det_im ); + + det = ( ( det_re * det_re ) + ( det_im * det_im ) ); + + if ( det < EPSILON ) + { + is_det_zero = 0; + } + + return is_det_zero; +} + + +static void isar_calc_mat_inv_2by2_complex( + float in_re[BINAURAL_CHANNELS][BINAURAL_CHANNELS], + float in_im[BINAURAL_CHANNELS][BINAURAL_CHANNELS], + float out_re[BINAURAL_CHANNELS][BINAURAL_CHANNELS], + float out_im[BINAURAL_CHANNELS][BINAURAL_CHANNELS] ) +{ + float det_re, det_im; + float re, im, det; + + isar_calc_mat_det_2by2_complex( in_re, in_im, &det_re, &det_im ); + + det = ( det_re * det_re ) + ( det_im * det_im ); + +#ifdef DEBUGGING + /* assert to catch cases when input is singular matrix */ + assert( det > 0 ); +#endif + det = 1 / det; + + IVAS_CMULT_FLOAT( det_re, -det_im, in_re[1][1], in_im[1][1], re, im ); + out_re[0][0] = re * det; + out_im[0][0] = im * det; + + IVAS_CMULT_FLOAT( det_re, -det_im, in_re[0][1], in_im[0][1], re, im ); + out_re[0][1] = -re * det; + out_im[0][1] = -im * det; + + IVAS_CMULT_FLOAT( det_re, -det_im, in_re[1][0], in_im[1][0], re, im ); + out_re[1][0] = -re * det; + out_im[1][0] = -im * det; + + IVAS_CMULT_FLOAT( det_re, -det_im, in_re[0][0], in_im[0][0], re, im ); + out_re[1][1] = re * det; + out_im[1][1] = im * det; + + return; +} + + +static void ComputePredMat( + float cov_ii_re[][BINAURAL_CHANNELS], + float cov_ii_im[][BINAURAL_CHANNELS], + float cov_io_re[][BINAURAL_CHANNELS], + float cov_io_im[][BINAURAL_CHANNELS], + float pred_mat_re[][BINAURAL_CHANNELS], + float pred_mat_im[][BINAURAL_CHANNELS], + const int16_t num_chs, + const int16_t real_only ) +{ + float cov_ii_local_re[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + float cov_ii_inv_re[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + float cov_ii_inv_im[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + float trace_cov; + int16_t i, j; + + trace_cov = 0.0f; + for ( i = 0; i < num_chs; i++ ) + { + trace_cov += cov_ii_re[i][i]; + } + + trace_cov = max( 0.0f, trace_cov ); + + if ( trace_cov < EPSILON ) + { + for ( i = 0; i < num_chs; i++ ) + { + /* protection from cases when variance of ref channels is very small */ + set_zero( pred_mat_re[i], BINAURAL_CHANNELS ); + set_zero( pred_mat_im[i], BINAURAL_CHANNELS ); + } + return; + } + + for ( i = 0; i < num_chs; i++ ) + { + mvr2r( cov_ii_re[i], cov_ii_local_re[i], num_chs ); + } + + for ( i = 0; i < num_chs; i++ ) + { + cov_ii_local_re[i][i] = cov_ii_re[i][i] + ( trace_cov * 0.0001f ); + } + + if ( isar_is_mat_inv_2by2_complex( cov_ii_local_re, cov_ii_im ) ) + { + isar_calc_mat_inv_2by2_complex( cov_ii_local_re, cov_ii_im, cov_ii_inv_re, cov_ii_inv_im ); + isar_mat_mult_2by2_complex( cov_ii_inv_re, cov_ii_inv_im, cov_io_re, cov_io_im, pred_mat_re, pred_mat_im ); + } + else + { + int16_t max_var_idx; + for ( i = 0; i < num_chs; i++ ) + { + set_zero( pred_mat_re[i], BINAURAL_CHANNELS ); + set_zero( pred_mat_im[i], BINAURAL_CHANNELS ); + } + + max_var_idx = 0; + if ( cov_ii_local_re[1][1] > cov_ii_local_re[0][0] ) + { + max_var_idx = 1; + } + + if ( cov_ii_local_re[max_var_idx][max_var_idx] > EPSILON ) + { + for ( j = 0; j < num_chs; j++ ) + { + pred_mat_re[max_var_idx][j] = cov_io_re[max_var_idx][j] / cov_ii_local_re[max_var_idx][max_var_idx]; + pred_mat_im[max_var_idx][j] = cov_io_im[max_var_idx][j] / cov_ii_local_re[max_var_idx][max_var_idx]; + } + } + } + + if ( real_only ) + { + for ( i = 0; i < num_chs; i++ ) + { + set_zero( pred_mat_im[i], BINAURAL_CHANNELS ); + } + } + + return; +} + + +static void ComputePostPredCov( + float cov_ii_re[][BINAURAL_CHANNELS], + float cov_ii_im[][BINAURAL_CHANNELS], + float pred_mat_re[][BINAURAL_CHANNELS], + float pred_mat_im[][BINAURAL_CHANNELS], + float postpred_cov_re[][BINAURAL_CHANNELS], + const int16_t num_chs ) +{ + int16_t i, j; + float dmx_mat_conj_re[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + float dmx_mat_conj_im[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + float temp_mat_re[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + float temp_mat_im[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + float postpred_cov_im[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + + assert( num_chs == BINAURAL_CHANNELS ); + for ( i = 0; i < num_chs; i++ ) + { + for ( j = 0; j < num_chs; j++ ) + { + dmx_mat_conj_re[i][j] = pred_mat_re[j][i]; + dmx_mat_conj_im[i][j] = -pred_mat_im[j][i]; + + temp_mat_re[i][j] = pred_mat_re[i][j]; + temp_mat_im[i][j] = pred_mat_im[i][j]; + } + set_zero( postpred_cov_re[i], BINAURAL_CHANNELS ); + } + + /* 2x2 mult */ + isar_mat_mult_2by2_complex( dmx_mat_conj_re, dmx_mat_conj_im, cov_ii_re, cov_ii_im, temp_mat_re, temp_mat_im ); + isar_mat_mult_2by2_complex( temp_mat_re, temp_mat_im, pred_mat_re, pred_mat_im, postpred_cov_re, postpred_cov_im ); + + for ( i = 0; i < BINAURAL_CHANNELS; i++ ) + { + for ( j = 0; j < i; j++ ) + { + postpred_cov_re[i][j] = postpred_cov_re[j][i]; + } + } + + return; +} + + +static void ComputeBandedCrossCov( + float Cldfb_RealBuffer1[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + float Cldfb_ImagBuffer1[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + const int16_t ch_start_idx1, + float Cldfb_RealBuffer2[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + float Cldfb_ImagBuffer2[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + const int16_t ch_start_idx2, + float out_cov_re[BINAURAL_CHANNELS][BINAURAL_CHANNELS], + float out_cov_im[BINAURAL_CHANNELS][BINAURAL_CHANNELS], + const int16_t num_chs, + const int16_t *pBand_grouping, + const int16_t num_slots, + const int16_t start_slot_idx, + const int16_t md_band_idx, + const int16_t real_only ) +{ + int16_t sf, cldfb_band_idx, ch_idx1, ch_idx2; + int16_t brange[2]; + + for ( ch_idx1 = 0; ch_idx1 < num_chs; ch_idx1++ ) + { + set_f( out_cov_re[ch_idx1], 0.0f, num_chs ); + set_f( out_cov_im[ch_idx1], 0.0f, num_chs ); + } + + brange[0] = pBand_grouping[md_band_idx]; + brange[1] = pBand_grouping[md_band_idx + 1]; + + for ( ch_idx1 = 0; ch_idx1 < num_chs; ch_idx1++ ) + { + for ( ch_idx2 = 0; ch_idx2 < num_chs; ch_idx2++ ) + { + if ( real_only == 0 ) + { + for ( sf = start_slot_idx; sf < start_slot_idx + num_slots; sf++ ) + { + for ( cldfb_band_idx = brange[0]; cldfb_band_idx < brange[1]; cldfb_band_idx++ ) + { + out_cov_re[ch_idx1][ch_idx2] += + Cldfb_RealBuffer1[ch_start_idx1 + ch_idx1][sf][cldfb_band_idx] * Cldfb_RealBuffer2[ch_start_idx2 + ch_idx2][sf][cldfb_band_idx] + + Cldfb_ImagBuffer1[ch_start_idx1 + ch_idx1][sf][cldfb_band_idx] * Cldfb_ImagBuffer2[ch_start_idx2 + ch_idx2][sf][cldfb_band_idx]; + + out_cov_im[ch_idx1][ch_idx2] += + Cldfb_RealBuffer1[ch_start_idx1 + ch_idx1][sf][cldfb_band_idx] * Cldfb_ImagBuffer2[ch_start_idx2 + ch_idx2][sf][cldfb_band_idx] - + Cldfb_ImagBuffer1[ch_start_idx1 + ch_idx1][sf][cldfb_band_idx] * Cldfb_RealBuffer2[ch_start_idx2 + ch_idx2][sf][cldfb_band_idx]; + } + } + } + else + { + for ( sf = start_slot_idx; sf < start_slot_idx + num_slots; sf++ ) + { + for ( cldfb_band_idx = brange[0]; cldfb_band_idx < brange[1]; cldfb_band_idx++ ) + { + out_cov_re[ch_idx1][ch_idx2] += + Cldfb_RealBuffer1[ch_start_idx1 + ch_idx1][sf][cldfb_band_idx] * Cldfb_RealBuffer2[ch_start_idx2 + ch_idx2][sf][cldfb_band_idx] + + Cldfb_ImagBuffer1[ch_start_idx1 + ch_idx1][sf][cldfb_band_idx] * Cldfb_ImagBuffer2[ch_start_idx2 + ch_idx2][sf][cldfb_band_idx]; + + out_cov_im[ch_idx1][ch_idx2] = 0.0f; + } + } + } + } + } + + return; +} + + +static void ComputeBandedCov( + float Cldfb_RealBuffer[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + float Cldfb_ImagBuffer[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + const int16_t ch_start_idx, + float out_cov_re[][BINAURAL_CHANNELS], + float out_cov_im[][BINAURAL_CHANNELS], + const int16_t num_chs, + const int16_t *pBand_grouping, + const int16_t num_slots, + const int16_t start_slot_idx, + const int16_t md_band_idx, + const int16_t real_only ) +{ + int16_t sf, cldfb_band_idx, ch_idx1, ch_idx2; + int16_t brange[2]; + + for ( ch_idx1 = 0; ch_idx1 < num_chs; ch_idx1++ ) + { + set_f( out_cov_re[ch_idx1], 0.0f, num_chs ); + set_f( out_cov_im[ch_idx1], 0.0f, num_chs ); + } + + brange[0] = pBand_grouping[md_band_idx]; + brange[1] = pBand_grouping[md_band_idx + 1]; + + for ( ch_idx1 = 0; ch_idx1 < num_chs; ch_idx1++ ) + { + for ( ch_idx2 = 0; ch_idx2 <= ch_idx1; ch_idx2++ ) + { + if ( ( ch_idx2 != ch_idx1 ) && ( real_only == 0 ) ) + { + for ( sf = start_slot_idx; sf < start_slot_idx + num_slots; sf++ ) + { + for ( cldfb_band_idx = brange[0]; cldfb_band_idx < brange[1]; cldfb_band_idx++ ) + { + out_cov_re[ch_idx1][ch_idx2] += + Cldfb_RealBuffer[ch_start_idx + ch_idx1][sf][cldfb_band_idx] * Cldfb_RealBuffer[ch_start_idx + ch_idx2][sf][cldfb_band_idx] + + Cldfb_ImagBuffer[ch_start_idx + ch_idx1][sf][cldfb_band_idx] * Cldfb_ImagBuffer[ch_start_idx + ch_idx2][sf][cldfb_band_idx]; + + out_cov_im[ch_idx1][ch_idx2] += + Cldfb_RealBuffer[ch_start_idx + ch_idx1][sf][cldfb_band_idx] * Cldfb_ImagBuffer[ch_start_idx + ch_idx2][sf][cldfb_band_idx] - + Cldfb_ImagBuffer[ch_start_idx + ch_idx1][sf][cldfb_band_idx] * Cldfb_RealBuffer[ch_start_idx + ch_idx2][sf][cldfb_band_idx]; + } + } + } + else + { + for ( sf = start_slot_idx; sf < start_slot_idx + num_slots; sf++ ) + { + for ( cldfb_band_idx = brange[0]; cldfb_band_idx < brange[1]; cldfb_band_idx++ ) + { + out_cov_re[ch_idx1][ch_idx2] += + Cldfb_RealBuffer[ch_start_idx + ch_idx1][sf][cldfb_band_idx] * Cldfb_RealBuffer[ch_start_idx + ch_idx2][sf][cldfb_band_idx] + + Cldfb_ImagBuffer[ch_start_idx + ch_idx1][sf][cldfb_band_idx] * Cldfb_ImagBuffer[ch_start_idx + ch_idx2][sf][cldfb_band_idx]; + + out_cov_im[ch_idx1][ch_idx2] = 0.0f; + } + } + } + } + } + + for ( ch_idx1 = 0; ch_idx1 < num_chs; ch_idx1++ ) + { + for ( ch_idx2 = ch_idx1 + 1; ch_idx2 < num_chs; ch_idx2++ ) + { + out_cov_re[ch_idx1][ch_idx2] = out_cov_re[ch_idx2][ch_idx1]; + out_cov_im[ch_idx1][ch_idx2] = -out_cov_im[ch_idx2][ch_idx1]; + } + } + + return; +} + + +static float GetNormFact( + float cov_ii_re[][BINAURAL_CHANNELS], + float cov_ii_im[][BINAURAL_CHANNELS], + float cov_io_re[][BINAURAL_CHANNELS], + float cov_io_im[][BINAURAL_CHANNELS], + float cov_oo_re[][BINAURAL_CHANNELS] ) +{ + int16_t i, j; + float norm_fact, abs_val; + + norm_fact = 0.0f; + for ( i = 0; i < BINAURAL_CHANNELS; i++ ) + { + for ( j = 0; j < BINAURAL_CHANNELS; j++ ) + { + IVAS_CALCULATE_ABS( cov_ii_re[i][j], cov_ii_im[i][j], abs_val ); + norm_fact = max( norm_fact, abs_val ); + + IVAS_CALCULATE_ABS( cov_io_re[i][j], cov_io_im[i][j], abs_val ); + norm_fact = max( norm_fact, abs_val ); + + IVAS_CALCULATE_RABS( cov_oo_re[i][j], abs_val ); + norm_fact = max( norm_fact, abs_val ); + } + } + + norm_fact = ( norm_fact > EPSILON ) ? norm_fact : 1.0f; + + norm_fact = PCM16_TO_FLT_FAC / norm_fact; + + return norm_fact; +} + + +static void isar_split_rend_huffman_encode( + isar_split_rend_huffman_cfg_t *huff_cfg, + const int16_t in, + int32_t *hcode, + int32_t *hlen ) +{ + int32_t min_sym_val; + const int32_t *codebook; + + min_sym_val = huff_cfg->codebook[0]; + + codebook = &huff_cfg->codebook[3 * ( in - min_sym_val )]; + *hlen = codebook[1]; + *hcode = codebook[2]; + + return; +} + + +static void isar_split_rend_quant_md( + ISAR_BIN_HR_SPLIT_REND_MD_HANDLE hMd, + const ISAR_SPLIT_REND_POSE_TYPE pose_type, + const int16_t real_only, + float fix_pos_rot_mat[][BINAURAL_CHANNELS], + const float pred_1byquantstep ) +{ + int16_t ch1, ch2; + int16_t gd_idx_min; +#ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS + float quant_val; +#else + float sign, quant_val; +#endif + + if ( pose_type == PRED_ONLY || pose_type == PRED_ROLL_ONLY ) + { + float onebyquantstep; + + onebyquantstep = pred_1byquantstep; + if ( real_only == 1 ) + { +#ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS + for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + hMd->pred_mat_re[ch1][ch1] = hMd->pred_mat_re2[ch1]; + } + hMd->pred_mat_re[1][0] = 0.0f; + hMd->pred_mat_re[0][1] = 0.0f; + + for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + quant_val = hMd->pred_mat_re[ch1][ch2] - ( ( ch1 == ch2 ) ? 1.0f : 0.0f ); + quant_val = min( ISAR_SPLIT_REND_PRED_MAX_VAL, max( quant_val, ISAR_SPLIT_REND_PRED_MIN_VAL ) ); + hMd->pred_mat_re_idx[ch1][ch2] = (int16_t) roundf( onebyquantstep * quant_val ); + } + } +#else + for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + sign = ( hMd->pred_mat_re[ch1][ch2] >= 0.0f ) ? 1.0f : -1.0f; + IVAS_CALCULATE_ABS( hMd->pred_mat_re[ch1][ch2], hMd->pred_mat_im[ch1][ch2], hMd->pred_mat_re[ch1][ch2] ); + hMd->pred_mat_re[ch1][ch2] *= sign; + hMd->pred_mat_im[ch1][ch2] = 0.0f; + } + } +#endif + } +#ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS + else + { +#endif + for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + quant_val = hMd->pred_mat_re[ch1][ch2] - fix_pos_rot_mat[ch1][ch2]; + quant_val = min( ISAR_SPLIT_REND_PRED_MAX_VAL, max( quant_val, ISAR_SPLIT_REND_PRED_MIN_VAL ) ); + hMd->pred_mat_re_idx[ch1][ch2] = (int16_t) roundf( onebyquantstep * quant_val ); + } + } +#ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS + } +#endif + + if ( real_only == 0 ) + { + for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + quant_val = min( ISAR_SPLIT_REND_PRED_MAX_VAL, max( hMd->pred_mat_im[ch1][ch2], ISAR_SPLIT_REND_PRED_MIN_VAL ) ); + hMd->pred_mat_im_idx[ch1][ch2] = (int16_t) roundf( onebyquantstep * quant_val ); + } + } + } + } + else if ( pose_type == COM_GAIN_ONLY ) + { + quant_val = min( ISAR_SPLIT_REND_D_MAX_VAL, max( hMd->gd, ISAR_SPLIT_REND_D_MIN_VAL ) ); + gd_idx_min = (int16_t) roundf( ISAR_SPLIT_REND_D_1BYQ_STEP * ISAR_SPLIT_REND_D_MIN_VAL ); + hMd->gd_idx = (int16_t) roundf( ISAR_SPLIT_REND_D_1BYQ_STEP * quant_val ); + hMd->gd = hMd->gd_idx * ISAR_SPLIT_REND_D_Q_STEP; + hMd->gd_idx = hMd->gd_idx - gd_idx_min; + } + else if ( pose_type == LR_GAIN_ONLY ) + { + quant_val = min( ISAR_SPLIT_REND_PITCH_G_MAX_VAL, max( hMd->gd, ISAR_SPLIT_REND_PITCH_G_MIN_VAL ) ); + gd_idx_min = (int16_t) roundf( ISAR_SPLIT_REND_PITCH_G_1BYQ_STEP * ISAR_SPLIT_REND_PITCH_G_MIN_VAL ); + hMd->gd_idx = (int16_t) roundf( ISAR_SPLIT_REND_PITCH_G_1BYQ_STEP * quant_val ); + hMd->gd_idx = hMd->gd_idx - gd_idx_min; + + quant_val = min( ISAR_SPLIT_REND_PITCH_G_MAX_VAL, max( hMd->gd2, ISAR_SPLIT_REND_PITCH_G_MIN_VAL ) ); + hMd->gd2_idx = (int16_t) roundf( ISAR_SPLIT_REND_PITCH_G_1BYQ_STEP * quant_val ); + hMd->gd2_idx = hMd->gd2_idx - gd_idx_min; + } + + return; +} + +#ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS +static void get_lr_gains( float cov_in[][BINAURAL_CHANNELS], + float cov_out[][BINAURAL_CHANNELS], + float gains[BINAURAL_CHANNELS] ) +{ + int16_t i; + for ( i = 0; i < BINAURAL_CHANNELS; i++ ) + { + gains[i] = cov_in[i][i]; + if ( gains[i] < EPSILON ) + { + gains[i] = 1.0f; + } + else + { + gains[i] = ( cov_out[i][i] ) / gains[i]; + gains[i] = sqrtf( gains[i] ); + } + } + return; +} +#endif + +static void ComputeCoeffs( + float cov_ii_re[][BINAURAL_CHANNELS], + float cov_ii_im[][BINAURAL_CHANNELS], + float cov_io_re[][BINAURAL_CHANNELS], + float cov_io_im[][BINAURAL_CHANNELS], + float cov_oo_re[][BINAURAL_CHANNELS], + ISAR_BIN_HR_SPLIT_REND_MD_HANDLE hMd, + const ISAR_SPLIT_REND_POSE_TYPE pose_type, + const int16_t real_only ) +{ + float postpred_cov_re[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + float cov_ii_norm_re[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + float cov_ii_norm_im[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + float cov_io_norm_re[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + float cov_io_norm_im[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + float cov_oo_norm_re[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + float sigma_d, gd, gd2, gl2, gr2, cov_norm_fact; + int16_t i, j; + + if ( pose_type == PITCH_ONLY ) + { + float gd_tmp[BINAURAL_CHANNELS]; +#ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS + get_lr_gains( cov_ii_re, cov_oo_re, gd_tmp ); +#else + for ( i = 0; i < BINAURAL_CHANNELS; i++ ) + { + gd_tmp[i] = cov_ii_re[i][i]; + if ( gd_tmp[i] < EPSILON ) + { + gd_tmp[i] = 1.0f; + } + else + { + gd_tmp[i] = ( cov_oo_re[i][i] ) / gd_tmp[i]; + gd_tmp[i] = sqrtf( gd_tmp[i] ); + } + } +#endif + hMd->gd = gd_tmp[0]; + hMd->gd2 = gd_tmp[1]; + } + else + { + if ( real_only ) + { + float gd_tmp[BINAURAL_CHANNELS]; +#ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS + get_lr_gains( cov_ii_re, cov_oo_re, gd_tmp ); + for ( i = 0; i < BINAURAL_CHANNELS; i++ ) + { + hMd->pred_mat_re[i][i] = gd_tmp[i]; + hMd->pred_mat_re2[i] = gd_tmp[i]; + set_zero( hMd->pred_mat_im[i], BINAURAL_CHANNELS ); + } +#else + for ( i = 0; i < BINAURAL_CHANNELS; i++ ) + { + gd_tmp[i] = cov_ii_re[i][i]; + if ( gd_tmp[i] < EPSILON ) + { + gd_tmp[i] = 1.0f; + } + else + { + gd_tmp[i] = ( cov_oo_re[i][i] ) / gd_tmp[i]; + gd_tmp[i] = sqrtf( gd_tmp[i] ); + } + hMd->pred_mat_re[i][i] = gd_tmp[i]; + set_zero( hMd->pred_mat_im[i], BINAURAL_CHANNELS ); + } +#endif + hMd->pred_mat_re[1][0] = 0.0f; + hMd->pred_mat_re[0][1] = 0.0f; + } + else + { +#ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS + get_lr_gains( cov_ii_re, cov_oo_re, hMd->pred_mat_re2 ); +#endif + cov_norm_fact = GetNormFact( cov_ii_re, cov_ii_im, cov_io_re, cov_io_im, cov_oo_re ); + + /* normalize the covariance */ + for ( i = 0; i < BINAURAL_CHANNELS; i++ ) + { + for ( j = 0; j < BINAURAL_CHANNELS; j++ ) + { + cov_ii_norm_re[i][j] = cov_ii_re[i][j] * cov_norm_fact; + cov_ii_norm_im[i][j] = cov_ii_im[i][j] * cov_norm_fact; + cov_io_norm_re[i][j] = cov_io_re[i][j] * cov_norm_fact; + cov_io_norm_im[i][j] = cov_io_im[i][j] * cov_norm_fact; + cov_oo_norm_re[i][j] = cov_oo_re[i][j] * cov_norm_fact; + } + } + + ComputePredMat( cov_ii_norm_re, cov_ii_norm_im, cov_io_norm_re, cov_io_norm_im, hMd->pred_mat_re, hMd->pred_mat_im, BINAURAL_CHANNELS, real_only ); + + ComputePostPredCov( cov_ii_norm_re, cov_ii_norm_im, hMd->pred_mat_re, hMd->pred_mat_im, postpred_cov_re, BINAURAL_CHANNELS ); + + /* normalize everything to +-1 range */ + gd = 1.0f / ( PCM16_TO_FLT_FAC ); + for ( i = 0; i < BINAURAL_CHANNELS; i++ ) + { + for ( j = 0; j < BINAURAL_CHANNELS; j++ ) + { + postpred_cov_re[i][j] *= gd; + cov_ii_norm_re[i][j] = cov_ii_norm_re[i][j] * gd; + cov_oo_norm_re[i][j] = cov_oo_norm_re[i][j] * gd; + } + } + + gd2 = 0.0f; + sigma_d = 0.0f; + hMd->gd = 0.0f; + + if ( postpred_cov_re[0][0] > EPSILON ) + { + gl2 = ( cov_oo_norm_re[0][0] - ( gd2 * sigma_d ) ) / max( EPSILON, postpred_cov_re[0][0] ); + gl2 = max( gl2, 1.0f ); + gl2 = sqrtf( gl2 ); + } + else + { + gl2 = 1.0f; + } + + if ( postpred_cov_re[1][1] > EPSILON ) + { + gr2 = ( cov_oo_norm_re[1][1] - ( gd2 * sigma_d ) ) / max( EPSILON, postpred_cov_re[1][1] ); + gr2 = max( gr2, 1.0f ); + gr2 = sqrtf( gr2 ); + } + else + { + gr2 = 1.0f; + } + + for ( i = 0; i < BINAURAL_CHANNELS; i++ ) + { + hMd->pred_mat_re[i][0] *= gl2; + hMd->pred_mat_re[i][1] *= gr2; + } + + if ( real_only == 0 ) + { + for ( i = 0; i < BINAURAL_CHANNELS; i++ ) + { + hMd->pred_mat_im[i][0] *= gl2; + hMd->pred_mat_im[i][1] *= gr2; + } + } + } + } + + return; +} + + +static void get_base2_bits( + const ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE hBinHrSplitPreRend, + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + const int16_t num_subframes, + const int16_t num_quant_strats, + const int16_t pred_real_bands_yaw[ISAR_SPLIT_REND_NUM_QUANT_STRATS], + const int16_t pred_imag_bands_yaw[ISAR_SPLIT_REND_NUM_QUANT_STRATS], + int16_t pred_quant_pnts_yaw[ISAR_SPLIT_REND_NUM_QUANT_STRATS], + const int16_t d_bands_yaw[ISAR_SPLIT_REND_NUM_QUANT_STRATS], + const int16_t bands_pitch[ISAR_SPLIT_REND_NUM_QUANT_STRATS], + const int16_t pred_real_bands_roll[ISAR_SPLIT_REND_NUM_QUANT_STRATS], + const int16_t pred_imag_bands_roll[ISAR_SPLIT_REND_NUM_QUANT_STRATS], + int32_t base2bits[ISAR_SPLIT_REND_NUM_QUANT_STRATS] ) +{ + int16_t pred_roll_bits; + int16_t d_gain_bits, pitch_gain_bits, pose_idx, q; + int16_t pred_yaw_bits[ISAR_SPLIT_REND_NUM_QUANT_STRATS]; + + ISAR_SPLIT_REND_POSE_TYPE pose_type; + + for ( q = 0; q < num_quant_strats; q++ ) + { + pred_yaw_bits[q] = (int16_t) ceilf( log2f( pred_quant_pnts_yaw[q] ) ); + } + pred_roll_bits = (int16_t) ceilf( log2f( ISAR_SPLIT_REND_ROLL_PRED_QUANT_PNTS ) ); + + d_gain_bits = (int16_t) ceilf( log2f( ISAR_SPLIT_REND_D_QUANT_PNTS ) ); + pitch_gain_bits = d_gain_bits; + + for ( q = 0; q < num_quant_strats; q++ ) + { + base2bits[q] = 0; + } + + for ( q = 0; q < num_quant_strats; q++ ) + { + for ( pose_idx = 0; pose_idx < pMultiBinPoseData->num_poses - 1; pose_idx++ ) + { + pose_type = hBinHrSplitPreRend->pose_type[pose_idx]; + if ( pose_type == ANY_YAW ) + { +#ifndef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS + base2bits[q] += pred_yaw_bits[q] * pred_real_bands_yaw[q] * num_subframes * BINAURAL_CHANNELS * BINAURAL_CHANNELS; + base2bits[q] += pred_yaw_bits[q] * pred_imag_bands_yaw[q] * num_subframes * BINAURAL_CHANNELS * BINAURAL_CHANNELS; +#else + base2bits[q] += pred_yaw_bits[q] * pred_real_bands_yaw[q] * num_subframes * BINAURAL_CHANNELS; + base2bits[q] += pred_yaw_bits[q] * pred_imag_bands_yaw[q] * num_subframes * BINAURAL_CHANNELS; + base2bits[q] += pred_yaw_bits[q] * pred_imag_bands_yaw[q] * num_subframes * BINAURAL_CHANNELS * BINAURAL_CHANNELS; +#endif + base2bits[q] += d_gain_bits * d_bands_yaw[q] * num_subframes; + } + else if ( pose_type == PITCH_ONLY ) + { + base2bits[q] += pitch_gain_bits * bands_pitch[q] * num_subframes; + base2bits[q] += pitch_gain_bits * bands_pitch[q] * num_subframes; + } + else + { +#ifndef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS + base2bits[q] += pred_roll_bits * pred_real_bands_roll[q] * num_subframes * BINAURAL_CHANNELS * BINAURAL_CHANNELS; + base2bits[q] += pred_roll_bits * pred_imag_bands_roll[q] * num_subframes * BINAURAL_CHANNELS * BINAURAL_CHANNELS; +#else + base2bits[q] += pred_roll_bits * pred_real_bands_roll[q] * num_subframes * BINAURAL_CHANNELS; + base2bits[q] += pred_roll_bits * pred_imag_bands_roll[q] * num_subframes * BINAURAL_CHANNELS; + base2bits[q] += pred_roll_bits * pred_imag_bands_roll[q] * num_subframes * BINAURAL_CHANNELS * BINAURAL_CHANNELS; +#endif + } + } + } + + return; +} + + +static void isar_SplitRenderer_code_md_base2( + const ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE hBinHrSplitPreRend, + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + const int16_t num_subframes, + const int16_t pred_real_bands_yaw, + const int16_t pred_imag_bands_yaw, + const int16_t pred_quant_pnts_yaw, + const int16_t d_bands_yaw, + const int16_t bands_pitch, + const int16_t pred_real_bands_roll, + const int16_t pred_imag_bands_roll, + ISAR_SPLIT_REND_BITS_HANDLE pBits ) +{ + int16_t pos_idx, b, ch1, ch2, sf_idx; + int16_t min_pred_idx, min_gd_idx, min_p_gd_idx, pred_code_len, gd_code_len, p_gd_code_len, num_poses; + int16_t min_pred_roll_idx, pred_roll_code_len; + int16_t pred_cb_idx; + int32_t code; + ISAR_BIN_HR_SPLIT_REND_MD_HANDLE hMd; + ISAR_BIN_HR_SPLIT_REND_HUFF_HANDLE pHuff_cfg; + + pHuff_cfg = &hBinHrSplitPreRend->huff_cfg; + if ( pred_quant_pnts_yaw == ISAR_SPLIT_REND_PRED_63QUANT_PNTS ) + { + pred_cb_idx = 1; + } + else + { + pred_cb_idx = 0; + } + min_pred_idx = (int16_t) pHuff_cfg->pred[pred_cb_idx].codebook[0]; + min_pred_roll_idx = (int16_t) pHuff_cfg->pred_roll.codebook[0]; + min_gd_idx = (int16_t) pHuff_cfg->gd.codebook[0]; + min_p_gd_idx = (int16_t) pHuff_cfg->p_gd.codebook[0]; + + pred_code_len = pHuff_cfg->pred_base2_code_len[pred_cb_idx]; + pred_roll_code_len = pHuff_cfg->pred_roll_base2_code_len; + gd_code_len = pHuff_cfg->gd_base2_code_len; + p_gd_code_len = pHuff_cfg->p_gd_base2_code_len; + + num_poses = pMultiBinPoseData->num_poses; + + for ( sf_idx = 0; sf_idx < num_subframes; sf_idx++ ) + { + for ( pos_idx = 0; pos_idx < num_poses - 1; pos_idx++ ) + { + if ( hBinHrSplitPreRend->pose_type[pos_idx] == ANY_YAW ) + { +#ifndef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS + for ( b = 0; b < pred_real_bands_yaw; b++ ) + { + hMd = &hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b]; + for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + code = hMd->pred_mat_re_idx[ch1][ch2] - min_pred_idx; + ISAR_SPLIT_REND_BITStream_write_int32( pBits, code, pred_code_len ); + } + } + } + + for ( b = 0; b < pred_imag_bands_yaw; b++ ) + { + hMd = &hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b]; + for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + code = hMd->pred_mat_im_idx[ch1][ch2] - min_pred_idx; + ISAR_SPLIT_REND_BITStream_write_int32( pBits, code, pred_code_len ); + } + } + } +#else + + for ( b = 0; b < pred_imag_bands_yaw; b++ ) + { + hMd = &hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b]; + for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + code = hMd->pred_mat_re_idx[ch1][ch2] - min_pred_idx; + ISAR_SPLIT_REND_BITStream_write_int32( pBits, code, pred_code_len ); + } + } + + for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + code = hMd->pred_mat_im_idx[ch1][ch2] - min_pred_idx; + ISAR_SPLIT_REND_BITStream_write_int32( pBits, code, pred_code_len ); + } + } + } + + for ( ; b < pred_real_bands_yaw; b++ ) + { + hMd = &hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b]; + for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + code = hMd->pred_mat_re_idx[ch1][ch1] - min_pred_idx; + ISAR_SPLIT_REND_BITStream_write_int32( pBits, code, pred_code_len ); + } + } +#endif + for ( b = 0; b < d_bands_yaw; b++ ) + { + hMd = &hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b]; + code = hMd->gd_idx - min_gd_idx; + ISAR_SPLIT_REND_BITStream_write_int32( pBits, code, gd_code_len ); + } + } + else if ( hBinHrSplitPreRend->pose_type[pos_idx] == PITCH_ONLY ) + { + for ( b = 0; b < bands_pitch; b++ ) + { + hMd = &hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b]; + code = hMd->gd_idx - min_p_gd_idx; + ISAR_SPLIT_REND_BITStream_write_int32( pBits, code, p_gd_code_len ); + + code = hMd->gd2_idx - min_p_gd_idx; + ISAR_SPLIT_REND_BITStream_write_int32( pBits, code, p_gd_code_len ); + } + } + else + { +#ifndef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS + for ( b = 0; b < pred_real_bands_roll; b++ ) + { + hMd = &hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b]; + for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + code = hMd->pred_mat_re_idx[ch1][ch2] - min_pred_roll_idx; + ISAR_SPLIT_REND_BITStream_write_int32( pBits, code, pred_roll_code_len ); + } + } + } + + for ( b = 0; b < pred_imag_bands_roll; b++ ) + { + hMd = &hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b]; + for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + code = hMd->pred_mat_im_idx[ch1][ch2] - min_pred_roll_idx; + ISAR_SPLIT_REND_BITStream_write_int32( pBits, code, pred_roll_code_len ); + } + } + } +#else + for ( b = 0; b < pred_imag_bands_roll; b++ ) + { + hMd = &hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b]; + for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + code = hMd->pred_mat_re_idx[ch1][ch2] - min_pred_roll_idx; + ISAR_SPLIT_REND_BITStream_write_int32( pBits, code, pred_roll_code_len ); + } + } + for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + code = hMd->pred_mat_im_idx[ch1][ch2] - min_pred_roll_idx; + ISAR_SPLIT_REND_BITStream_write_int32( pBits, code, pred_roll_code_len ); + } + } + } + + for ( ; b < pred_real_bands_roll; b++ ) + { + hMd = &hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b]; + for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + code = hMd->pred_mat_re_idx[ch1][ch1] - min_pred_roll_idx; + ISAR_SPLIT_REND_BITStream_write_int32( pBits, code, pred_roll_code_len ); + } + } +#endif + } + } + } + +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG + { + static int16_t num_bits = 0; + static int16_t cntr = 0; + float fnum_bits; + + cntr++; + + num_bits += pBits->bits_written; + /* collect bits for every second */ + if ( cntr == 50 ) + { + cntr = 0; + fnum_bits = (float) num_bits / 1000.0f; + dbgwrite_txt( &fnum_bits, 1, "split_rend_MD_bitrate.txt", "MD bitrate (kbps)" ); + num_bits = 0; + } + } +#endif + return; +} + + +static void isar_SplitRenderer_code_md_huff( + const ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE hBinHrSplitPreRend, + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + const int16_t num_subframes, + const int16_t pred_real_bands_yaw, + const int16_t pred_imag_bands_yaw, + const int16_t pred_quant_pnts_yaw, + const int16_t d_bands_yaw, + const int16_t bands_pitch, + const int16_t pred_real_bands_roll, + const int16_t pred_imag_bands_roll, + ISAR_SPLIT_REND_BITS_HANDLE pBits ) +{ + int16_t pos_idx, b, ch1, ch2, sf_idx, num_poses; + int16_t sym_adj_idx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + int16_t min_pred_idx, max_pred_idx; + int16_t min_pred_roll_idx, max_pred_roll_idx, pred_cb_idx; + int32_t code, len; + ISAR_BIN_HR_SPLIT_REND_MD_HANDLE hMd; + ISAR_BIN_HR_SPLIT_REND_HUFF_HANDLE pHuff_cfg; + + pHuff_cfg = &hBinHrSplitPreRend->huff_cfg; + + if ( pred_quant_pnts_yaw == ISAR_SPLIT_REND_PRED_63QUANT_PNTS ) + { + pred_cb_idx = 1; + } + else + { + pred_cb_idx = 0; + } + + min_pred_idx = (int16_t) pHuff_cfg->pred[pred_cb_idx].codebook[0]; + max_pred_idx = (int16_t) pHuff_cfg->pred[pred_cb_idx].codebook[( pred_quant_pnts_yaw - 1 ) * 3]; + min_pred_roll_idx = (int16_t) pHuff_cfg->pred_roll.codebook[0]; + max_pred_roll_idx = (int16_t) pHuff_cfg->pred_roll.codebook[( ISAR_SPLIT_REND_ROLL_PRED_QUANT_PNTS - 1 ) * 3]; + + num_poses = pMultiBinPoseData->num_poses; + + for ( sf_idx = 0; sf_idx < num_subframes; sf_idx++ ) + { + for ( pos_idx = 0; pos_idx < num_poses - 1; pos_idx++ ) + { + if ( hBinHrSplitPreRend->pose_type[pos_idx] == ANY_YAW ) + { +#ifndef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS + for ( b = 0; b < pred_real_bands_yaw; b++ ) + { + hMd = &hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b]; + isar_SplitRenderer_getdiagdiff( hMd->pred_mat_re_idx, sym_adj_idx, -1, min_pred_idx, max_pred_idx ); + for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + isar_split_rend_huffman_encode( &pHuff_cfg->pred[pred_cb_idx], sym_adj_idx[ch1][ch2], &code, &len ); + ISAR_SPLIT_REND_BITStream_write_int32( pBits, code, len ); + } + } + } + for ( b = 0; b < pred_imag_bands_yaw; b++ ) + { + hMd = &hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b]; + isar_SplitRenderer_getdiagdiff( hMd->pred_mat_im_idx, sym_adj_idx, 1, min_pred_idx, max_pred_idx ); + for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + + isar_split_rend_huffman_encode( &pHuff_cfg->pred[pred_cb_idx], sym_adj_idx[ch1][ch2], &code, &len ); + + ISAR_SPLIT_REND_BITStream_write_int32( pBits, code, len ); + } + } + } +#else + for ( b = 0; b < pred_imag_bands_yaw; b++ ) + { + hMd = &hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b]; + isar_SplitRenderer_getdiagdiff( hMd->pred_mat_re_idx, sym_adj_idx, -1, min_pred_idx, max_pred_idx ); + for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + isar_split_rend_huffman_encode( &pHuff_cfg->pred[pred_cb_idx], sym_adj_idx[ch1][ch2], &code, &len ); + ISAR_SPLIT_REND_BITStream_write_int32( pBits, code, len ); + } + } + + isar_SplitRenderer_getdiagdiff( hMd->pred_mat_im_idx, sym_adj_idx, 1, min_pred_idx, max_pred_idx ); + for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + isar_split_rend_huffman_encode( &pHuff_cfg->pred[pred_cb_idx], sym_adj_idx[ch1][ch2], &code, &len ); + ISAR_SPLIT_REND_BITStream_write_int32( pBits, code, len ); + } + } + } + + for ( ; b < pred_real_bands_yaw; b++ ) + { + hMd = &hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b]; + isar_SplitRenderer_getdiagdiff( hMd->pred_mat_re_idx, sym_adj_idx, 1, min_pred_idx, max_pred_idx ); + for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + isar_split_rend_huffman_encode( &pHuff_cfg->pred[pred_cb_idx], sym_adj_idx[ch1][ch1], &code, &len ); + ISAR_SPLIT_REND_BITStream_write_int32( pBits, code, len ); + } + } +#endif + for ( b = 0; b < d_bands_yaw; b++ ) + { + hMd = &hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b]; + isar_split_rend_huffman_encode( &pHuff_cfg->gd, hMd->gd_idx, &code, &len ); + ISAR_SPLIT_REND_BITStream_write_int32( pBits, code, len ); + } + } + else if ( hBinHrSplitPreRend->pose_type[pos_idx] == PITCH_ONLY ) + { + for ( b = 0; b < bands_pitch; b++ ) + { + hMd = &hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b]; + isar_split_rend_huffman_encode( &pHuff_cfg->p_gd, hMd->gd_idx, &code, &len ); + ISAR_SPLIT_REND_BITStream_write_int32( pBits, code, len ); + + isar_split_rend_huffman_encode( &pHuff_cfg->p_gd, hMd->gd2_idx, &code, &len ); + ISAR_SPLIT_REND_BITStream_write_int32( pBits, code, len ); + } + } + else + { +#ifndef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS + for ( b = 0; b < pred_real_bands_roll; b++ ) + { + hMd = &hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b]; + isar_SplitRenderer_getdiagdiff( hMd->pred_mat_re_idx, sym_adj_idx, -1, min_pred_roll_idx, max_pred_roll_idx ); + for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + isar_split_rend_huffman_encode( &pHuff_cfg->pred_roll, sym_adj_idx[ch1][ch2], &code, &len ); + ISAR_SPLIT_REND_BITStream_write_int32( pBits, code, len ); + } + } + } + for ( b = 0; b < pred_imag_bands_roll; b++ ) + { + hMd = &hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b]; + isar_SplitRenderer_getdiagdiff( hMd->pred_mat_im_idx, sym_adj_idx, 1, min_pred_roll_idx, max_pred_roll_idx ); + for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + isar_split_rend_huffman_encode( &pHuff_cfg->pred_roll, sym_adj_idx[ch1][ch2], &code, &len ); + ISAR_SPLIT_REND_BITStream_write_int32( pBits, code, len ); + } + } + } +#else + for ( b = 0; b < pred_imag_bands_roll; b++ ) + { + hMd = &hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b]; + isar_SplitRenderer_getdiagdiff( hMd->pred_mat_re_idx, sym_adj_idx, -1, min_pred_roll_idx, max_pred_roll_idx ); + for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + isar_split_rend_huffman_encode( &pHuff_cfg->pred_roll, sym_adj_idx[ch1][ch2], &code, &len ); + ISAR_SPLIT_REND_BITStream_write_int32( pBits, code, len ); + } + } + + isar_SplitRenderer_getdiagdiff( hMd->pred_mat_im_idx, sym_adj_idx, 1, min_pred_roll_idx, max_pred_roll_idx ); + for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + isar_split_rend_huffman_encode( &pHuff_cfg->pred_roll, sym_adj_idx[ch1][ch2], &code, &len ); + ISAR_SPLIT_REND_BITStream_write_int32( pBits, code, len ); + } + } + } + + for ( ; b < pred_real_bands_roll; b++ ) + { + hMd = &hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b]; + isar_SplitRenderer_getdiagdiff( hMd->pred_mat_re_idx, sym_adj_idx, 1, min_pred_roll_idx, max_pred_roll_idx ); + for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + isar_split_rend_huffman_encode( &pHuff_cfg->pred_roll, sym_adj_idx[ch1][ch1], &code, &len ); + ISAR_SPLIT_REND_BITStream_write_int32( pBits, code, len ); + } + } +#endif + } + } + } + +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG + { + static int16_t num_bits = 0; + static int16_t cntr = 0; + float fnum_bits; + + cntr++; + num_bits += pBits->bits_written; + /* collect bits for every second */ + if ( cntr == 50 ) + { + cntr = 0; + fnum_bits = (float) num_bits / 1000.0f; + dbgwrite_txt( &fnum_bits, 1, "split_rend_MD_bitrate.txt", "MD bitrate (kbps)" ); + num_bits = 0; + } + } +#endif + return; +} + + +static void isar_SplitRenderer_quant_code( + const ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE hBinHrSplitPreRend, + const IVAS_QUATERNION headPosition, + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + ISAR_SPLIT_REND_BITS_HANDLE pBits, + const int16_t low_res_pre_rend_rot, +#ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS + const int16_t ro_md_flag, +#endif + const int32_t target_md_bits ) +{ +#ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS + int16_t q, num_subframes, sf_idx, pos_idx, b, num_quant_strats; +#else + int16_t num_complex_bands, q, num_subframes, sf_idx, pos_idx, b, num_quant_strats; +#endif + int32_t overhead_bits, quant_strat_bits, huff_bits, start_bit; + int16_t pred_real_bands_yaw[ISAR_SPLIT_REND_NUM_QUANT_STRATS], pred_real_bands_roll[ISAR_SPLIT_REND_NUM_QUANT_STRATS]; + int16_t pred_imag_bands_yaw[ISAR_SPLIT_REND_NUM_QUANT_STRATS], pred_imag_bands_roll[ISAR_SPLIT_REND_NUM_QUANT_STRATS]; + int16_t d_bands_yaw[ISAR_SPLIT_REND_NUM_QUANT_STRATS], bands_pitch[ISAR_SPLIT_REND_NUM_QUANT_STRATS]; + int32_t base2bits[ISAR_SPLIT_REND_NUM_QUANT_STRATS]; + int16_t pred_quant_pnts_yaw[ISAR_SPLIT_REND_NUM_QUANT_STRATS]; + float pred_1byquantstep_yaw[ISAR_SPLIT_REND_NUM_QUANT_STRATS]; + float pred_quantstep_yaw[ISAR_SPLIT_REND_NUM_QUANT_STRATS]; + ISAR_BIN_HR_SPLIT_REND_MD_HANDLE hMd; +#ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS + int16_t rot_axis_code, num_bits; +#endif + + if ( low_res_pre_rend_rot ) + { + num_subframes = 1; + } + else + { + num_subframes = MAX_PARAM_SPATIAL_SUBFRAMES; + } + + overhead_bits = pBits->bits_written; + + ISAR_SPLIT_REND_BITStream_write_int32( pBits, pMultiBinPoseData->dof, ISAR_SPLIT_REND_DOF_BITS ); + ISAR_SPLIT_REND_BITStream_write_int32( pBits, pMultiBinPoseData->hq_mode, ISAR_SPLIT_REND_HQ_MODE_BITS ); +#ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS + rot_axis_code = isar_renderSplitGetCodeFromRot_axis( pMultiBinPoseData->dof, pMultiBinPoseData->rot_axis, &num_bits ); + if ( num_bits > 0 ) + { + ISAR_SPLIT_REND_BITStream_write_int32( pBits, (int32_t) rot_axis_code, num_bits ); + } + ISAR_SPLIT_REND_BITStream_write_int32( pBits, (int32_t) ro_md_flag, ISAR_SPLIT_REND_RO_FLAG_BITS ); +#else + ISAR_SPLIT_REND_BITStream_write_int32( pBits, (int32_t) pMultiBinPoseData->rot_axis, ISAR_SPLIT_REND_ROT_AXIS_BITS ); +#endif + + /* code ref pose*/ + for ( sf_idx = 0; sf_idx < num_subframes; sf_idx++ ) + { + int16_t angle; + IVAS_QUATERNION head_pos_euler; + + Quat2EulerDegree( headPosition, &head_pos_euler.z, &head_pos_euler.y, &head_pos_euler.x ); + angle = (int16_t) roundf( head_pos_euler.x ); + angle += 180; + ISAR_SPLIT_REND_BITStream_write_int32( pBits, angle, ISAR_SPLIT_REND_HEAD_POSE_BITS ); + + angle = (int16_t) roundf( head_pos_euler.y ); + angle += 180; + ISAR_SPLIT_REND_BITStream_write_int32( pBits, angle, ISAR_SPLIT_REND_HEAD_POSE_BITS ); + + angle = (int16_t) roundf( head_pos_euler.z ); + angle += 180; + + ISAR_SPLIT_REND_BITStream_write_int32( pBits, angle, ISAR_SPLIT_REND_HEAD_POSE_BITS ); + } + +#ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS + isar_split_rend_get_quant_params( MAX_SPLIT_REND_MD_BANDS, pred_real_bands_yaw, pred_imag_bands_yaw, + pred_quant_pnts_yaw, pred_quantstep_yaw, pred_1byquantstep_yaw, + d_bands_yaw, bands_pitch, pred_real_bands_roll, pred_imag_bands_roll, ro_md_flag, &num_quant_strats ); +#else + isar_split_rend_get_quant_params( MAX_SPLIT_REND_MD_BANDS, pred_real_bands_yaw, pred_imag_bands_yaw, + pred_quant_pnts_yaw, pred_quantstep_yaw, pred_1byquantstep_yaw, + d_bands_yaw, bands_pitch, pred_real_bands_roll, pred_imag_bands_roll, &num_quant_strats, &num_complex_bands ); +#endif + quant_strat_bits = (int32_t) ceilf( log2f( num_quant_strats ) ); + + overhead_bits = pBits->bits_written - overhead_bits + quant_strat_bits + 1; /* 1 for base2 vs huff */ + + get_base2_bits( hBinHrSplitPreRend, pMultiBinPoseData, num_subframes, num_quant_strats, pred_real_bands_yaw, pred_imag_bands_yaw, + pred_quant_pnts_yaw, + d_bands_yaw, bands_pitch, pred_real_bands_roll, pred_imag_bands_roll, base2bits ); + + for ( q = 0; q < num_quant_strats; q++ ) + { + for ( sf_idx = 0; sf_idx < num_subframes; sf_idx++ ) + { + for ( pos_idx = 0; pos_idx < pMultiBinPoseData->num_poses - 1; pos_idx++ ) + { + if ( hBinHrSplitPreRend->pose_type[pos_idx] == ANY_YAW ) + { + for ( b = 0; b < pred_imag_bands_yaw[q]; b++ ) + { + hMd = &hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b]; + + isar_split_rend_quant_md( hMd, PRED_ONLY, 0, hBinHrSplitPreRend->fix_pos_rot_mat[pos_idx], pred_1byquantstep_yaw[q] ); + } + for ( ; b < pred_real_bands_yaw[q]; b++ ) + { + hMd = &hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b]; + + isar_split_rend_quant_md( hMd, PRED_ONLY, 1, hBinHrSplitPreRend->fix_pos_rot_mat[pos_idx], pred_1byquantstep_yaw[q] ); + } + + for ( b = 0; b < d_bands_yaw[q]; b++ ) + { + hMd = &hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b]; + + isar_split_rend_quant_md( hMd, COM_GAIN_ONLY, 1, hBinHrSplitPreRend->fix_pos_rot_mat[pos_idx], 0 ); + } + } + else if ( hBinHrSplitPreRend->pose_type[pos_idx] == PITCH_ONLY ) + { + for ( b = 0; b < bands_pitch[q]; b++ ) + { + hMd = &hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b]; + isar_split_rend_quant_md( hMd, LR_GAIN_ONLY, 1, hBinHrSplitPreRend->fix_pos_rot_mat[pos_idx], 0 ); + } + } + else + { + for ( b = 0; b < pred_imag_bands_roll[q]; b++ ) + { + hMd = &hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b]; + isar_split_rend_quant_md( hMd, PRED_ROLL_ONLY, 0, hBinHrSplitPreRend->fix_pos_rot_mat[pos_idx], ISAR_SPLIT_REND_PRED_ROLL_1BYQ_STEP ); + } + for ( ; b < pred_real_bands_roll[q]; b++ ) + { + hMd = &hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b]; + isar_split_rend_quant_md( hMd, PRED_ROLL_ONLY, 1, hBinHrSplitPreRend->fix_pos_rot_mat[pos_idx], ISAR_SPLIT_REND_PRED_ROLL_1BYQ_STEP ); + } + } + } + } + + /*get base2 bits and check if its within target. if yes then code with base2 to save complexity on post renderer*/ + start_bit = pBits->bits_written; + + ISAR_SPLIT_REND_BITStream_write_int32( pBits, 1, 1 ); + ISAR_SPLIT_REND_BITStream_write_int32( pBits, q, quant_strat_bits ); + + huff_bits = pBits->bits_written; + isar_SplitRenderer_code_md_huff( + hBinHrSplitPreRend, + pMultiBinPoseData, + num_subframes, + pred_real_bands_yaw[q], + pred_imag_bands_yaw[q], + pred_quant_pnts_yaw[q], + d_bands_yaw[q], + bands_pitch[q], + pred_real_bands_roll[q], + pred_imag_bands_roll[q], + pBits ); + + huff_bits = pBits->bits_written - huff_bits; + + if ( ( target_md_bits >= ( base2bits[q] + overhead_bits ) ) || ( target_md_bits >= ( huff_bits + overhead_bits ) ) || ( q == ( num_quant_strats - 1 ) ) ) + { + if ( huff_bits > base2bits[q] ) + { + pBits->bits_written = start_bit; + + ISAR_SPLIT_REND_BITStream_write_int32( pBits, 0, 1 ); + ISAR_SPLIT_REND_BITStream_write_int32( pBits, q, quant_strat_bits ); + + isar_SplitRenderer_code_md_base2( hBinHrSplitPreRend, pMultiBinPoseData, num_subframes, pred_real_bands_yaw[q], pred_imag_bands_yaw[q], + pred_quant_pnts_yaw[q], + d_bands_yaw[q], bands_pitch[q], pred_real_bands_roll[q], pred_imag_bands_roll[q], pBits ); + } + break; + } + + pBits->bits_written = start_bit; + } + +#ifdef SPLIT_MD_CODING_DEBUG + for ( sf_idx = 0; sf_idx < num_subframes; sf_idx++ ) + { + int16_t val, quant_strat, ch1, ch2; + char filename[200] = "split_md_debug_indices.bin"; + quant_strat = q; + for ( pos_idx = 0; pos_idx < pMultiBinPoseData->num_poses - 1; pos_idx++ ) + { + if ( hBinHrSplitPreRend->pose_type[pos_idx] == ANY_YAW ) + { + for ( b = 0; b < pred_real_bands_yaw[quant_strat]; b++ ) + { + for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + val = hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].pred_mat_re_idx[ch1][ch2]; + dbgwrite( &val, sizeof( int16_t ), 1, 1, filename ); + } + } + } + for ( b = 0; b < pred_imag_bands_yaw[quant_strat]; b++ ) + { + for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + val = hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].pred_mat_im_idx[ch1][ch2]; + dbgwrite( &val, sizeof( int16_t ), 1, 1, filename ); + } + } + } + for ( b = 0; b < d_bands_yaw[quant_strat]; b++ ) + { + val = hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].gd_idx; + dbgwrite( &val, sizeof( int16_t ), 1, 1, filename ); + } + } + else if ( hBinHrSplitPreRend->pose_type[pos_idx] == PITCH_ONLY ) + { + for ( b = 0; b < bands_pitch[quant_strat]; b++ ) + { + val = hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].gd_idx; + dbgwrite( &val, sizeof( int16_t ), 1, 1, filename ); + val = hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].gd2_idx; + dbgwrite( &val, sizeof( int16_t ), 1, 1, filename ); + } + } + else + { + for ( b = 0; b < pred_real_bands_roll[quant_strat]; b++ ) + { + for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + val = hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].pred_mat_re_idx[ch1][ch2]; + dbgwrite( &val, sizeof( int16_t ), 1, 1, filename ); + } + } + } + for ( b = 0; b < pred_imag_bands_roll[quant_strat]; b++ ) + { + for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + val = hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].pred_mat_im_idx[ch1][ch2]; + dbgwrite( &val, sizeof( int16_t ), 1, 1, filename ); + } + } + } + } + } + } +#endif + + return; +} + + +/*------------------------------------------------------------------------- + * Function isar_SplitRenderer_GetRotMd() + * + * + *------------------------------------------------------------------------*/ + +static void isar_SplitRenderer_GetRotMd( + ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE hBinHrSplitPreRend, /* i/o: binaural renderer handle */ + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + float Cldfb_RealBuffer_Ref_Binaural[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* o : Reference Binaural signals */ + float Cldfb_ImagBuffer_Ref_Binaural[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* o : Reference Binaural signals */ + const int16_t low_res, + const int16_t ro_md_flag ) +{ + float cov_ii_re[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + float cov_oo_re[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + float cov_io_re[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + float cov_ii_im[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + float cov_oo_im[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + float cov_io_im[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + int16_t real_only = 0; + int16_t pos_idx, b, sf_idx, start_slot_idx, num_slots, num_subframes, ch_s_idx1, ch_s_idx2; + int16_t num_md_bands, num_poses; + const int16_t *pBand_grouping = isar_split_rend_band_grouping; + + push_wmops( "isar_SplitRenderer_GetRotMd" ); + + num_md_bands = MAX_SPLIT_REND_MD_BANDS; + num_poses = pMultiBinPoseData->num_poses; + + if ( low_res ) + { + num_slots = CLDFB_NO_COL_MAX; + num_subframes = 1; + } + else + { + num_slots = MAX_PARAM_SPATIAL_SUBFRAMES; + num_subframes = MAX_PARAM_SPATIAL_SUBFRAMES; + } + + /* compute reference signal covariance */ + for ( sf_idx = 0; sf_idx < num_subframes; sf_idx++ ) + { + start_slot_idx = sf_idx * num_slots; + for ( b = 0; b < num_md_bands; b++ ) + { + if ( ( b < SPLIT_REND_RO_MD_BAND_THRESH ) || ( !ro_md_flag && b < COMPLEX_MD_BAND_THRESH ) ) + { + real_only = 0; + } + else + { + real_only = 1; + } + + ch_s_idx1 = 0; + ComputeBandedCov( Cldfb_RealBuffer_Ref_Binaural, Cldfb_ImagBuffer_Ref_Binaural, ch_s_idx1, cov_ii_re, cov_ii_im, BINAURAL_CHANNELS, pBand_grouping, num_slots, start_slot_idx, b, real_only ); + + /* compute rotated signal covariance */ + for ( pos_idx = 0; pos_idx < num_poses - 1; pos_idx++ ) + { + if ( hBinHrSplitPreRend->pose_type[pos_idx] == ANY_ROLL ) + { + if ( b >= SPLIT_REND_RO_MD_BAND_THRESH ) + { + real_only = 1; + } + } + ch_s_idx2 = ( pos_idx + 1 ) * BINAURAL_CHANNELS; + ComputeBandedCrossCov( Cldfb_RealBuffer_Ref_Binaural, Cldfb_ImagBuffer_Ref_Binaural, ch_s_idx1, Cldfb_RealBuffer_Ref_Binaural, Cldfb_ImagBuffer_Ref_Binaural, ch_s_idx2, cov_io_re, cov_io_im, BINAURAL_CHANNELS, pBand_grouping, num_slots, start_slot_idx, b, real_only ); + + ComputeBandedCov( Cldfb_RealBuffer_Ref_Binaural, Cldfb_ImagBuffer_Ref_Binaural, ch_s_idx2, cov_oo_re, cov_oo_im, BINAURAL_CHANNELS, pBand_grouping, num_slots, start_slot_idx, b, real_only ); + + ComputeCoeffs( cov_ii_re, cov_ii_im, cov_io_re, cov_io_im, cov_oo_re, &hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b], hBinHrSplitPreRend->pose_type[pos_idx], real_only ); + } + } + } + + pop_wmops(); + return; +} + + +/*------------------------------------------------------------------------- + * Function isar_rend_CldfbSplitPreRendProcess() + * + * + *------------------------------------------------------------------------*/ + +void isar_rend_CldfbSplitPreRendProcess( + const ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE hBinHrSplitPreRend, + const IVAS_QUATERNION headPosition, + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + float Cldfb_In_BinReal[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + float Cldfb_In_BinImag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + ISAR_SPLIT_REND_BITS_HANDLE pBits, + const int32_t target_md_bits, + const int16_t low_res_pre_rend_rot, + const int16_t ro_md_flag ) +{ + push_wmops( "isar_rend_CldfbSplitPreRendProcess" ); + + isar_SplitRenderer_GetRotMd( hBinHrSplitPreRend, pMultiBinPoseData, Cldfb_In_BinReal, Cldfb_In_BinImag, low_res_pre_rend_rot, ro_md_flag ); + +#ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS + isar_SplitRenderer_quant_code( hBinHrSplitPreRend, headPosition, pMultiBinPoseData, pBits, low_res_pre_rend_rot, ro_md_flag, target_md_bits ); +#else + isar_SplitRenderer_quant_code( hBinHrSplitPreRend, headPosition, pMultiBinPoseData, pBits, low_res_pre_rend_rot, target_md_bits ); +#endif + +#ifdef SPLIT_POSE_CORRECTION_DEBUG + float tmpCrendBuffer[2][L_FRAME48k], quant_val, step, minv, maxv; + IVAS_QUATERNION QuaternionsPost[MAX_PARAM_SPATIAL_SUBFRAMES], head_pos_euler; + float Cldfb_RealBuffer_Binaural_5ms[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; + float Cldfb_ImagBuffer_Binaural_5ms[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; + int16_t sf_idx, pos_idx, b, ch1, ch2; + int32_t read_off, write_off; + for ( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ ) + { + QuaternionsPost[sf_idx].w = -3.0f; + QuaternionsPost[sf_idx].x = 0.0f; + QuaternionsPost[sf_idx].y = 0.0f; + QuaternionsPost[sf_idx].z = 0.0f; + } + + hBinHrSplitPreRend->hBinHrSplitPostRend->low_Res = 1; + set_fix_rotation_mat( hBinHrSplitPreRend->hBinHrSplitPostRend->fix_pos_rot_mat, pMultiBinPoseData ); + set_pose_types( hBinHrSplitPreRend->hBinHrSplitPostRend->pose_type, pMultiBinPoseData ); + for ( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ ) + { + Quat2EulerDegree( headPosition, &head_pos_euler.z, &head_pos_euler.y, &head_pos_euler.x ); + hBinHrSplitPreRend->hBinHrSplitPostRend->QuaternionsPre[sf_idx].w = -3.0f; + hBinHrSplitPreRend->hBinHrSplitPostRend->QuaternionsPre[sf_idx].x = roundf( head_pos_euler.x ); + hBinHrSplitPreRend->hBinHrSplitPostRend->QuaternionsPre[sf_idx].y = roundf( head_pos_euler.y ); + hBinHrSplitPreRend->hBinHrSplitPostRend->QuaternionsPre[sf_idx].z = roundf( head_pos_euler.z ); + } + for ( sf_idx = 0; sf_idx < 1; sf_idx++ ) + { + for ( pos_idx = 0; pos_idx < pMultiBinPoseData->num_poses - 1; pos_idx++ ) + { + for ( b = 0; b < MAX_SPLIT_REND_MD_BANDS; b++ ) + { + hBinHrSplitPreRend->hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b] = hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b]; + BIN_HR_SPLIT_REND_MD_HANDLE hMd; + hMd = &hBinHrSplitPreRend->hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b]; + minv = -1.4f; + maxv = 1.4f; + step = ( maxv - minv ) / 62.0f; + if ( b >= 20 ) + { + float sign; + for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + sign = ( hMd->pred_mat_re[ch1][ch2] >= 0.0f ) ? 1.0f : -1.0f; + IVAS_CALCULATE_ABS( hMd->pred_mat_re[ch1][ch2], hMd->pred_mat_im[ch1][ch2], hMd->pred_mat_re[ch1][ch2] ); + hMd->pred_mat_re[ch1][ch2] *= sign; + hMd->pred_mat_im[ch1][ch2] = 0.0f; + } + } + } + + for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) + { + for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) + { + quant_val = hMd->pred_mat_re[ch1][ch2] - hBinHrSplitPreRend->fix_pos_rot_mat[pos_idx][ch1][ch2]; + quant_val = min( maxv, max( quant_val, minv ) ); + quant_val = (int16_t) roundf( quant_val / step ); + hMd->pred_mat_re[ch1][ch2] = quant_val * step; + hMd->pred_mat_re[ch1][ch2] += hBinHrSplitPreRend->fix_pos_rot_mat[pos_idx][ch1][ch2]; + + quant_val = hMd->pred_mat_im[ch1][ch2]; + quant_val = min( maxv, max( quant_val, minv ) ); + quant_val = (int16_t) roundf( quant_val / step ); + hMd->pred_mat_im[ch1][ch2] = quant_val * step; + } + } + } + } + } + + for ( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ ) + { + mvr2r( (float *) Cldfb_In_BinReal[0][sf_idx * MAX_PARAM_SPATIAL_SUBFRAMES], (float *) Cldfb_RealBuffer_Binaural_5ms[0], MAX_PARAM_SPATIAL_SUBFRAMES * CLDFB_NO_CHANNELS_MAX ); + mvr2r( (float *) Cldfb_In_BinReal[1][sf_idx * MAX_PARAM_SPATIAL_SUBFRAMES], (float *) Cldfb_RealBuffer_Binaural_5ms[1], MAX_PARAM_SPATIAL_SUBFRAMES * CLDFB_NO_CHANNELS_MAX ); + mvr2r( (float *) Cldfb_In_BinImag[0][sf_idx * MAX_PARAM_SPATIAL_SUBFRAMES], (float *) Cldfb_ImagBuffer_Binaural_5ms[0], MAX_PARAM_SPATIAL_SUBFRAMES * CLDFB_NO_CHANNELS_MAX ); + mvr2r( (float *) Cldfb_In_BinImag[1][sf_idx * MAX_PARAM_SPATIAL_SUBFRAMES], (float *) Cldfb_ImagBuffer_Binaural_5ms[1], MAX_PARAM_SPATIAL_SUBFRAMES * CLDFB_NO_CHANNELS_MAX ); + isar_rend_CldfbSplitPostRendProcess( hBinHrSplitPreRend->hBinHrSplitPostRend, pMultiBinPoseData, QuaternionsPost[0], Cldfb_RealBuffer_Binaural_5ms, Cldfb_ImagBuffer_Binaural_5ms, tmpCrendBuffer, 1 ); + + { + float *pOut[2]; + char fname[200] = "ref_act_pos.wav"; + pOut[0] = tmpCrendBuffer[0]; + pOut[1] = tmpCrendBuffer[1]; + dbgwrite_wav( pOut, CLDFB_NO_COL_MAX * hBinHrSplitPreRend->hBinHrSplitPostRend->cldfbSyn[0]->no_channels, fname, 48000, 2 ); + } + } +#endif + + pop_wmops(); + return; +} + + +/*------------------------------------------------------------------------- + * Function isar_splitBinPreRendOpen() + * + * + *------------------------------------------------------------------------*/ + +ivas_error isar_splitBinPreRendOpen( + ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE *hBinHrSplitPreRend, + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG + , + const int32_t output_Fs +#endif +) +{ + ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE hBinRend; +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG + ivas_error error; + int16_t ch; +#endif + int16_t pos_idx, sf_idx, bandIdx; + + if ( ( hBinRend = (ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE) malloc( sizeof( ISAR_BIN_HR_SPLIT_PRE_REND ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for bin split pre renderer Module \n" ) ); + } + +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG + for ( int16_t i = 0; i < MAX_HEAD_ROT_POSES + 1; i++ ) + { + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + hBinRend->cldfbSynRotBinDec[i][ch] = NULL; + } + } + + for ( int16_t i = 0; i < MAX_HEAD_ROT_POSES + 1; i++ ) + { + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + if ( ( error = openCldfb( &( hBinRend->cldfbSynRotBinDec[i][ch] ), CLDFB_SYNTHESIS, output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) + { + return error; + } + } + } +#endif + + for ( pos_idx = 0; pos_idx < pMultiBinPoseData->num_poses - 1; pos_idx++ ) + { + for ( sf_idx = 0; sf_idx < MAX_SPLIT_MD_SUBFRAMES; sf_idx++ ) + { + for ( bandIdx = 0; bandIdx < MAX_SPLIT_REND_MD_BANDS; bandIdx++ ) + { + hBinRend->rot_md[pos_idx][sf_idx][bandIdx].gd = 0.0f; + } + } + } + + set_fix_rotation_mat( hBinRend->fix_pos_rot_mat, pMultiBinPoseData ); + + set_pose_types( hBinRend->pose_type, pMultiBinPoseData ); + + isar_split_rend_init_huff_cfg( &hBinRend->huff_cfg ); + +#ifdef SPLIT_POSE_CORRECTION_DEBUG + ivas_error error; + if ( ( error = isar_splitBinPostRendOpen( &hBinRend->hBinHrSplitPostRend, pMultiBinPoseData, 48000 ) ) != IVAS_ERR_OK ) + { + return error; + } +#endif + + *hBinHrSplitPreRend = hBinRend; + + return IVAS_ERR_OK; +} + + +/*------------------------------------------------------------------------- + * Function isar_splitBinPreRendClose() + * + * + *------------------------------------------------------------------------*/ + +void isar_splitBinPreRendClose( + ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE *hBinHrSplitPreRend ) +{ + if ( ( *hBinHrSplitPreRend ) != NULL ) + { +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG + { + int16_t i, n; + for ( i = 0; i < MAX_HEAD_ROT_POSES + 1; i++ ) + { + for ( n = 0; n < BINAURAL_CHANNELS; n++ ) + { + if ( ( *hBinHrSplitPreRend )->cldfbSynRotBinDec[i][n] != NULL ) + { + deleteCldfb( &( ( *hBinHrSplitPreRend )->cldfbSynRotBinDec[i][n] ) ); + ( *hBinHrSplitPreRend )->cldfbSynRotBinDec[i][n] = NULL; + } + } + } + } +#endif +#ifdef SPLIT_POSE_CORRECTION_DEBUG + isar_splitBinPostRendClose( &( *hBinHrSplitPreRend )->hBinHrSplitPostRend ); +#endif + + free( ( *hBinHrSplitPreRend ) ); + ( *hBinHrSplitPreRend ) = NULL; + } + + return; +} + + +/*-------------------------------------------------------------------------* + * isar_set_split_rend_ht_setup() + * + * + *-------------------------------------------------------------------------*/ + +void isar_set_split_rend_ht_setup( + SPLIT_REND_WRAPPER *hSplitrend, + IVAS_QUATERNION Quaternions[MAX_PARAM_SPATIAL_SUBFRAMES], + float Rmat[MAX_PARAM_SPATIAL_SUBFRAMES][3][3] ) +{ + int16_t sf, i, j; + if ( hSplitrend->multiBinPoseData.poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) + { + for ( sf = 1; sf < MAX_PARAM_SPATIAL_SUBFRAMES; sf++ ) + { + Quaternions[sf] = Quaternions[0]; + + for ( i = 0; i < 3; i++ ) + { + for ( j = 0; j < 3; j++ ) + { + Rmat[sf][i][j] = Rmat[0][i][j]; + } + } + } + } + + return; +} + + +/*------------------------------------------------------------------------- + * Function isar_init_split_rend_handles() + * + * + *------------------------------------------------------------------------*/ + +void isar_init_split_rend_handles( + SPLIT_REND_WRAPPER *hSplitRendWrapper ) +{ + int16_t i; + + hSplitRendWrapper->hBinHrSplitPreRend = NULL; + hSplitRendWrapper->hCldfbHandles = NULL; + hSplitRendWrapper->hSplitBinLCLDEnc = NULL; + hSplitRendWrapper->hLc3plusEnc = NULL; + + for ( i = 0; i < MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS; ++i ) + { + hSplitRendWrapper->lc3plusDelayBuffers[i] = NULL; + } + hSplitRendWrapper->lc3plusDelaySamples = 0; + + isar_init_multi_bin_pose_data( &hSplitRendWrapper->multiBinPoseData ); + + return; +} + +/*------------------------------------------------------------------------- + * Function split_renderer_open_lc3plus() + * + * + *------------------------------------------------------------------------*/ + +ivas_error split_renderer_open_lc3plus( + SPLIT_REND_WRAPPER *hSplitRendWrapper, + const ISAR_SPLIT_REND_CONFIG_DATA *pSplitRendConfig, + const int32_t OutSampleRate, +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + const IVAS_RENDER_FRAMESIZE isar_frame_size +#else + const int16_t num_subframes +#endif +) +{ + ivas_error error; + int16_t i, delayBufferLength; + LC3PLUS_CONFIG config; +#if defined ISAR_BITSTREAM_UPDATE_LC3PLUS + int16_t isar_frame_size_ms; + + if ( ( error = isar_framesize_to_ms( isar_frame_size, &isar_frame_size_ms ) ) != IVAS_ERR_OK ) + { + return error; + } +#endif + +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + /* Check configuration validity */ + if ( isar_frame_size_ms < pSplitRendConfig->codec_frame_size_ms ) + { + return IVAS_ERROR( IVAS_ERR_INVALID_SPLIT_REND_CONFIG, "SR codec frame doesn't fit in one output frame" ); + } +#endif + + config.lc3plus_frame_duration_us = pSplitRendConfig->codec_frame_size_ms * 1000; +#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS + config.isar_frame_duration_us = ( pSplitRendConfig->dof == 0 ) ? config.lc3plus_frame_duration_us * num_subframes : 20000; +#endif + config.samplerate = OutSampleRate; + +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + config.isar_frame_duration_us = isar_frame_size_ms * 1000; +#endif + +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + config.high_res_mode_enabled = ( pSplitRendConfig->lc3plus_highres != 0 ); +#endif + config.channels = BINAURAL_CHANNELS; + + if ( ( error = ISAR_LC3PLUS_ENC_Open( config, +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + isar_get_lcld_bitrate( pSplitRendConfig->splitRendBitRate, pSplitRendConfig->poseCorrectionMode ), +#else + isar_get_lc3plus_bitrate( pSplitRendConfig->splitRendBitRate, pSplitRendConfig->poseCorrectionMode, (int16_t) ( config.isar_frame_duration_us / 1000 ) ), +#endif + &hSplitRendWrapper->hLc3plusEnc ) ) != IVAS_ERR_OK ) + { + return error; + } + + /* This returns delay of entire LC3plus chain (enc + dec) */ + if ( ( error = ISAR_LC3PLUS_ENC_GetDelay( hSplitRendWrapper->hLc3plusEnc, &hSplitRendWrapper->lc3plusDelaySamples ) ) != IVAS_ERR_OK ) + { + return error; + } + + /* Alocate buffers for delay compensation */ + if ( pSplitRendConfig->codec == ISAR_SPLIT_REND_CODEC_LC3PLUS ) + { + delayBufferLength = (int16_t) ( OutSampleRate / (int32_t) FRAMES_PER_SECOND + hSplitRendWrapper->lc3plusDelaySamples ); + for ( i = 0; i < hSplitRendWrapper->multiBinPoseData.num_poses * BINAURAL_CHANNELS; ++i ) + { + if ( ( hSplitRendWrapper->lc3plusDelayBuffers[i] = malloc( delayBufferLength * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for multiBinPoseData handle\n" ) ); + } + + set_zero( hSplitRendWrapper->lc3plusDelayBuffers[i], delayBufferLength ); + } + } + else + { + /* Delay is always expected to be exactly 2 CLDFB columns */ + assert( hSplitRendWrapper->lc3plusDelaySamples % ( OutSampleRate / FRAMES_PER_SEC / CLDFB_NO_COL_MAX ) == 0 ); + assert( hSplitRendWrapper->lc3plusDelaySamples / ( OutSampleRate / FRAMES_PER_SEC / CLDFB_NO_COL_MAX ) == 2 ); + + delayBufferLength = 2 /* Columns */ * 2 /* real and imag */ * CLDFB_NO_CHANNELS_MAX; + for ( i = 0; i < hSplitRendWrapper->multiBinPoseData.num_poses * BINAURAL_CHANNELS; ++i ) + { + if ( ( hSplitRendWrapper->lc3plusDelayBuffers[i] = malloc( delayBufferLength * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for multiBinPoseData handle\n" ) ); + } + + set_zero( hSplitRendWrapper->lc3plusDelayBuffers[i], delayBufferLength ); + } + } + + return IVAS_ERR_OK; +} + + +/*------------------------------------------------------------------------- + * Function splitRendLc3plusEncodeAndWrite() + * + * + *------------------------------------------------------------------------*/ + +ivas_error splitRendLc3plusEncodeAndWrite( + SPLIT_REND_WRAPPER *hSplitBin, + ISAR_SPLIT_REND_BITS_HANDLE pBits, +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + const int32_t available_bits, +#endif +#else + const int32_t SplitRendBitRate, +#endif + float *in[] ) +{ + ivas_error error; + int16_t i; + int32_t lc3plusBitstreamSize; + float *channel_ptrs[MAX_HEAD_ROT_POSES * 2]; + assert( hSplitBin->hLc3plusEnc != NULL ); + + /* Find next byte boundary and zero-pad to it */ + while ( pBits->bits_written % 8 != 0 ) + { + ISAR_SPLIT_REND_BITStream_write_int32( pBits, 0L, 1 ); + } + + for ( i = 0; i < BINAURAL_CHANNELS * hSplitBin->multiBinPoseData.num_poses; ++i ) + { + channel_ptrs[i] = in[i]; + } + +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + if ( ( error = IVAS_LC3PLUS_ENC_SetBitrate( hSplitBin->hLc3plusEnc, available_bits * FRAMES_PER_SEC ) ) != IVAS_ERR_OK ) + { + return error; + } +#endif + + if ( ( error = ISAR_LC3PLUS_ENC_GetOutputBitstreamSize( hSplitBin->hLc3plusEnc, &lc3plusBitstreamSize ) ) != IVAS_ERR_OK ) + { + return error; + } + +#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS + ISAR_SPLIT_REND_BITStream_write_int32( pBits, isar_get_lc3plus_bitrate_id( SplitRendBitRate ), 8 ); +#endif + + /* Write bitstream */ +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + if ( ( error = ISAR_LC3PLUS_ENC_Encode( hSplitBin->hLc3plusEnc, channel_ptrs, &pBits->bits_buf[pBits->bits_written / 8], lc3plusBitstreamSize ) ) != IVAS_ERR_OK ) +#else + if ( ( error = ISAR_LC3PLUS_ENC_Encode( hSplitBin->hLc3plusEnc, channel_ptrs, &pBits->bits_buf[pBits->bits_written / 8] ) ) != IVAS_ERR_OK ) +#endif + { + return error; + } + + pBits->bits_written += 8 * lc3plusBitstreamSize; + pBits->codec = ISAR_SPLIT_REND_CODEC_LC3PLUS; + pBits->pose_correction = hSplitBin->multiBinPoseData.poseCorrectionMode; + pBits->codec_frame_size_ms = (int16_t) ( hSplitBin->hLc3plusEnc->config.lc3plus_frame_duration_us / 1000 ); +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + pBits->isar_frame_size_ms = (int16_t) ( hSplitBin->hLc3plusEnc->config.isar_frame_duration_us / 1000 ); +#endif + return IVAS_ERR_OK; +} + +/*------------------------------------------------------------------------- + * Function isar_renderMultiTDBinToSplitBinaural() + * + * + *------------------------------------------------------------------------*/ + +ivas_error isar_renderMultiTDBinToSplitBinaural( + SPLIT_REND_WRAPPER *hSplitBin, + const IVAS_QUATERNION headPosition, + const int32_t SplitRendBitRate, +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + const int16_t isar_frame_size_ms, +#endif + const int16_t codec_frame_size_ms, + ISAR_SPLIT_REND_BITS_HANDLE pBits, + const int16_t max_bands, + float *in[], + const int16_t low_res_pre_rend_rot, + const int16_t pcm_out_flag, + const int16_t ro_md_flag ) +{ + ivas_error error; +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + int32_t bit_len, available_bits, target_md_bits; +#else + int32_t bit_len, available_bits, target_md_bits, actual_md_bits; +#endif + int16_t num_cldfb_bands, ch, slot_idx, pos_idx, num_poses; + float Cldfb_In_BinReal[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + float Cldfb_In_BinImag[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + uint8_t useLc3plus; + float *in_delayed[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS]; + int16_t i; + int32_t num_slots; + + push_wmops( "isar_renderMultiTDBinToSplitBinaural" ); + + error = IVAS_ERR_OK; + num_poses = hSplitBin->multiBinPoseData.num_poses; + + useLc3plus = hSplitBin->hLc3plusEnc != NULL; + + if ( useLc3plus ) + { + /*this should always have the time resolution of pose correction MD. Note that this does not change frame size of LC3plus*/ + int16_t frame_size = (int16_t) ( hSplitBin->hLc3plusEnc->config.samplerate / (int32_t) FRAMES_PER_SECOND ); + + for ( i = 0; i < num_poses * BINAURAL_CHANNELS; ++i ) + { + /* Artificially delay input to head pose correction analysis by LC3plus coding delay, so that audio and metadata are in sync after decoding */ + mvr2r( hSplitBin->lc3plusDelayBuffers[i] + frame_size, hSplitBin->lc3plusDelayBuffers[i], (int16_t) hSplitBin->lc3plusDelaySamples ); + in_delayed[i] = hSplitBin->lc3plusDelayBuffers[i]; + mvr2r( in[i], hSplitBin->lc3plusDelayBuffers[i] + hSplitBin->lc3plusDelaySamples, frame_size ); + } + } + else + { + for ( i = 0; i < num_poses * BINAURAL_CHANNELS; ++i ) + { + in_delayed[i] = in[i]; + } + } + +#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS + actual_md_bits = pBits->bits_written; +#endif + if ( ( hSplitBin->multiBinPoseData.poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) || ( !useLc3plus && !pcm_out_flag ) ) + { + num_slots = ( hSplitBin->multiBinPoseData.poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) ? CLDFB_NO_COL_MAX : ( hSplitBin->hSplitBinLCLDEnc->iNumBlocks * hSplitBin->hSplitBinLCLDEnc->iNumIterations ); + num_cldfb_bands = hSplitBin->hCldfbHandles->cldfbAna[0]->no_channels; + + /* CLDFB Analysis*/ + for ( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) + { +#ifdef SPLIT_POSE_CORRECTION_DEBUG + { + float *pOut[2]; + char fname[200] = "ref_out_pos"; + char tag[2]; + tag[0] = (char) ( '0' + pos_idx ); + tag[1] = '\0'; + strcat( fname, tag ); + strcat( fname, ".wav" ); + + pOut[0] = in_delayed[2 * pos_idx]; + pOut[1] = in_delayed[2 * pos_idx + 1]; + dbgwrite_wav( pOut, CLDFB_NO_COL_MAX * max_bands, fname, 48000, 2 ); + } + +#endif + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + for ( slot_idx = 0; slot_idx < num_slots; slot_idx++ ) + { + cldfbAnalysis_ts( &( in_delayed[pos_idx * BINAURAL_CHANNELS + ch][num_cldfb_bands * slot_idx] ), + Cldfb_In_BinReal[pos_idx * BINAURAL_CHANNELS + ch][slot_idx], Cldfb_In_BinImag[pos_idx * BINAURAL_CHANNELS + ch][slot_idx], + max_bands, hSplitBin->hCldfbHandles->cldfbAna[pos_idx * BINAURAL_CHANNELS + ch] ); + } + } + } + } + + if ( hSplitBin->multiBinPoseData.poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) + { + target_md_bits = isar_get_split_rend_md_target_brate( SplitRendBitRate, pcm_out_flag ) * L_FRAME48k / 48000; + +#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS + actual_md_bits = pBits->bits_written; +#endif + + isar_rend_CldfbSplitPreRendProcess( hSplitBin->hBinHrSplitPreRend, headPosition, &hSplitBin->multiBinPoseData, Cldfb_In_BinReal, Cldfb_In_BinImag, pBits, target_md_bits, low_res_pre_rend_rot, ro_md_flag ); + } + + if ( pcm_out_flag == 0 ) + { + pBits->pose_correction = hSplitBin->multiBinPoseData.poseCorrectionMode; + pBits->codec = useLc3plus ? ISAR_SPLIT_REND_CODEC_LC3PLUS : ISAR_SPLIT_REND_CODEC_LCLD; + + if ( !useLc3plus ) + { + available_bits = ( SplitRendBitRate * hSplitBin->hSplitBinLCLDEnc->iNumBlocks * hSplitBin->hSplitBinLCLDEnc->iNumIterations ) / ( 16 * FRAMES_PER_SEC ); +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + available_bits -= pBits->bits_written; +#else + actual_md_bits = pBits->bits_written - actual_md_bits; + available_bits -= actual_md_bits; +#endif + pBits->codec_frame_size_ms = codec_frame_size_ms; +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + pBits->isar_frame_size_ms = isar_frame_size_ms; +#endif + + isar_splitBinLCLDEncProcess( hSplitBin->hSplitBinLCLDEnc, Cldfb_In_BinReal, Cldfb_In_BinImag, available_bits, pBits ); + } + else + { +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + available_bits = ( SplitRendBitRate / FRAMES_PER_SEC ) - pBits->bits_written; + if ( ( error = splitRendLc3plusEncodeAndWrite( hSplitBin, pBits, available_bits, in ) ) != IVAS_ERR_OK ) +#else + available_bits = ( SplitRendBitRate / FRAMES_PER_SEC ) - pBits->bits_written; + if ( ( error = splitRendLc3plusEncodeAndWrite( hSplitBin, pBits, in ) ) != IVAS_ERR_OK ) +#endif +#else + if ( ( error = splitRendLc3plusEncodeAndWrite( hSplitBin, pBits, SplitRendBitRate, in ) ) != IVAS_ERR_OK ) +#endif + { + return error; + } + } + } + else + { + pBits->pose_correction = hSplitBin->multiBinPoseData.poseCorrectionMode; + pBits->codec = ISAR_SPLIT_REND_CODEC_NONE; + } + + /*zero pad*/ + if ( pcm_out_flag ) + { + bit_len = SplitRendBitRate / FRAMES_PER_SEC; + } + else + { + if ( !useLc3plus ) + { + bit_len = ( SplitRendBitRate * hSplitBin->hSplitBinLCLDEnc->iNumBlocks * hSplitBin->hSplitBinLCLDEnc->iNumIterations ) / ( 16 * FRAMES_PER_SEC ); + } + else + { + bit_len = hSplitBin->hLc3plusEnc->config.isar_frame_duration_us / 1000; + bit_len = SplitRendBitRate * bit_len / 1000; + } + } + + while ( pBits->bits_written < bit_len ) + { + ISAR_SPLIT_REND_BITStream_write_int32( pBits, 0L, 1 ); + } + + pop_wmops(); + + return error; +} + + +/*------------------------------------------------------------------------- + * Function lc3plusTimeAlignCldfbPoseCorr() + * + * + *------------------------------------------------------------------------*/ + +void lc3plusTimeAlignCldfbPoseCorr( + SPLIT_REND_WRAPPER *hSplitBin, + float Cldfb_In_BinReal[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + float Cldfb_In_BinImag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX] ) +{ + float Cldfb_In_BinReal_tmp[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][2][CLDFB_NO_CHANNELS_MAX]; + float Cldfb_In_BinImag_tmp[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][2][CLDFB_NO_CHANNELS_MAX]; + int16_t pose, ch, slot_idx; + float *bufRead, *bufWrite; + + for ( pose = 0; pose < hSplitBin->multiBinPoseData.num_poses; ++pose ) + { + for ( ch = 0; ch < BINAURAL_CHANNELS; ++ch ) + { + bufRead = hSplitBin->lc3plusDelayBuffers[pose * BINAURAL_CHANNELS + ch]; + bufWrite = bufRead; + + /* Save last 2 columns for next frame */ + for ( slot_idx = 0; slot_idx < 2; ++slot_idx ) + { + mvr2r( Cldfb_In_BinReal[pose * BINAURAL_CHANNELS + ch][CLDFB_NO_COL_MAX - 2 + slot_idx], Cldfb_In_BinReal_tmp[pose][ch][slot_idx], CLDFB_NO_CHANNELS_MAX ); + mvr2r( Cldfb_In_BinImag[pose * BINAURAL_CHANNELS + ch][CLDFB_NO_COL_MAX - 2 + slot_idx], Cldfb_In_BinImag_tmp[pose][ch][slot_idx], CLDFB_NO_CHANNELS_MAX ); + } + + /* Delay existing columns by 2 slots */ + for ( slot_idx = CLDFB_NO_COL_MAX - 2 - 1; slot_idx >= 0; --slot_idx ) + { + mvr2r( Cldfb_In_BinReal[pose * BINAURAL_CHANNELS + ch][slot_idx], Cldfb_In_BinReal[pose * BINAURAL_CHANNELS + ch][slot_idx + 2], CLDFB_NO_CHANNELS_MAX ); + mvr2r( Cldfb_In_BinImag[pose * BINAURAL_CHANNELS + ch][slot_idx], Cldfb_In_BinImag[pose * BINAURAL_CHANNELS + ch][slot_idx + 2], CLDFB_NO_CHANNELS_MAX ); + } + + /* Fill 2 first columns from buffer */ + for ( slot_idx = 0; slot_idx < 2; ++slot_idx ) + { + mvr2r( bufRead, Cldfb_In_BinReal[pose * BINAURAL_CHANNELS + ch][slot_idx], CLDFB_NO_CHANNELS_MAX ); + bufRead += CLDFB_NO_CHANNELS_MAX; + mvr2r( bufRead, Cldfb_In_BinImag[pose * BINAURAL_CHANNELS + ch][slot_idx], CLDFB_NO_CHANNELS_MAX ); + bufRead += CLDFB_NO_CHANNELS_MAX; + } + + /* Copy last 2 columns to buffer */ + for ( slot_idx = 0; slot_idx < 2; ++slot_idx ) + { + mvr2r( Cldfb_In_BinReal_tmp[pose][ch][slot_idx], bufWrite, CLDFB_NO_CHANNELS_MAX ); + bufWrite += CLDFB_NO_CHANNELS_MAX; + mvr2r( Cldfb_In_BinImag_tmp[pose][ch][slot_idx], bufWrite, CLDFB_NO_CHANNELS_MAX ); + bufWrite += CLDFB_NO_CHANNELS_MAX; + } + } + } + + return; +} +#endif diff --git a/lib_isar/isar_splitRenderer_utils.c b/lib_isar/isar_splitRenderer_utils.c new file mode 100644 index 0000000000000000000000000000000000000000..a1910bf9f67f94b00b18f0e30dcafdf9bea97e31 --- /dev/null +++ b/lib_isar/isar_splitRenderer_utils.c @@ -0,0 +1,1289 @@ +/****************************************************************************************************** + + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#include +#include "options.h" +#ifdef SPLIT_REND_WITH_HEAD_ROT +#include +#include "ivas_prot.h" +#include "isar_rom_post_rend.h" +#include "lib_isar_post_rend.h" +#include "isar_prot.h" +#ifdef DEBUGGING +#include "debug.h" +#endif +#include "wmc_auto.h" + + +/*------------------------------------------------------------------------- + * Function isar_mat_mult_2by2_complex() + * + * + *------------------------------------------------------------------------*/ + +void isar_mat_mult_2by2_complex( + float in_re1[2][2], + float in_im1[2][2], + float in_re2[2][2], + float in_im2[2][2], + float out_re2[2][2], + float out_im2[2][2] ) +{ + int16_t i, j; + float tmp_re, tmp_im; + + for ( i = 0; i < 2; i++ ) + { + for ( j = 0; j < 2; j++ ) + { + IVAS_CMULT_FLOAT( in_re1[i][0], in_im1[i][0], in_re2[0][j], in_im2[0][j], tmp_re, tmp_im ); + out_re2[i][j] = tmp_re; + out_im2[i][j] = tmp_im; + + IVAS_CMULT_FLOAT( in_re1[i][1], in_im1[i][1], in_re2[1][j], in_im2[1][j], tmp_re, tmp_im ); + out_re2[i][j] += tmp_re; + out_im2[i][j] += tmp_im; + } + } + + return; +} + + +/*------------------------------------------------------------------------- + * Function ISAR_SPLIT_REND_BITStream_init() + * + * + *------------------------------------------------------------------------*/ + +void ISAR_SPLIT_REND_BITStream_init( + ISAR_SPLIT_REND_BITS_HANDLE pBits, + const int32_t buf_len_bytes, + uint8_t *pbuf ) +{ + pBits->bits_buf = pbuf; + pBits->buf_len = buf_len_bytes; + pBits->bits_read = 0; + pBits->bits_written = 0; + + return; +} + + +/*------------------------------------------------------------------------- + * Function isar_split_rend_huffman_dec_init_min_max_len() + * + * + *------------------------------------------------------------------------*/ + +void isar_split_rend_huffman_dec_init_min_max_len( + isar_split_rend_huffman_cfg_t *p_huff_cfg ) +{ + int16_t i, code_len; + const int32_t *codebook; + + codebook = p_huff_cfg->codebook; + + p_huff_cfg->min_len = p_huff_cfg->sym_len; + p_huff_cfg->max_len = 0; + + for ( i = 0; i < p_huff_cfg->sym_len; i++ ) + { + code_len = (int16_t) codebook[1]; + if ( p_huff_cfg->min_len > code_len ) + { + p_huff_cfg->min_len = code_len; + } + if ( p_huff_cfg->max_len < code_len ) + { + p_huff_cfg->max_len = code_len; + } + codebook = codebook + 3; + } + + return; +} + + +/*------------------------------------------------------------------------- + * Function is_idx_present() + * + * + *------------------------------------------------------------------------*/ + +static int16_t is_idx_present( + int16_t *idx_list, + const int16_t idx, + const int16_t len ) +{ + int16_t i; + + for ( i = 0; i < len; i++ ) + { + if ( idx_list[i] == idx ) + { + return 1; + } + } + + return 0; +} + + +/*------------------------------------------------------------------------- + * Function isar_split_huff_get_idx_trav_list() + * + * + *------------------------------------------------------------------------*/ + +static void isar_split_huff_get_idx_trav_list( + int16_t *idx_list, + isar_split_rend_huffman_cfg_t *p_huff_cfg ) +{ + int16_t i, j, min_idx; + int32_t min_bits; + const int32_t *codebook; + + for ( i = 0; i < p_huff_cfg->sym_len; i++ ) + { + idx_list[i] = -1; + } + + for ( i = 0; i < p_huff_cfg->sym_len; i++ ) + { + codebook = p_huff_cfg->codebook; + min_bits = p_huff_cfg->max_len; + min_idx = -1; + for ( j = 0; j < p_huff_cfg->sym_len; j++ ) + { + if ( ( min_bits >= codebook[1] ) && ( is_idx_present( idx_list, j, i + 1 ) == 0 ) ) + { + min_bits = codebook[1]; + min_idx = j; + } + codebook += 3; + } + idx_list[i] = min_idx; + } + + return; +} + + +/*------------------------------------------------------------------------- + * Function isar_split_rend_init_huff_cfg() + * + * + *------------------------------------------------------------------------*/ + +void isar_split_rend_init_huff_cfg( + ISAR_BIN_HR_SPLIT_REND_HUFF_HANDLE pHuff_cfg ) +{ + pHuff_cfg->pred[0].codebook = &isar_split_rend_huff_pred31_consts[0][0]; + pHuff_cfg->pred[0].sym_len = ISAR_SPLIT_REND_PRED_31QUANT_PNTS; + isar_split_rend_huffman_dec_init_min_max_len( &pHuff_cfg->pred[0] ); + isar_split_huff_get_idx_trav_list( pHuff_cfg->pred_idx_trav[0], &pHuff_cfg->pred[0] ); + pHuff_cfg->pred_base2_code_len[0] = (int16_t) ceilf( log2f( pHuff_cfg->pred[0].sym_len ) ); + + pHuff_cfg->pred[1].codebook = &isar_split_rend_huff_pred63_consts[0][0]; + pHuff_cfg->pred[1].sym_len = ISAR_SPLIT_REND_PRED_63QUANT_PNTS; + isar_split_rend_huffman_dec_init_min_max_len( &pHuff_cfg->pred[1] ); + isar_split_huff_get_idx_trav_list( pHuff_cfg->pred_idx_trav[1], &pHuff_cfg->pred[1] ); + pHuff_cfg->pred_base2_code_len[1] = (int16_t) ceilf( log2f( pHuff_cfg->pred[1].sym_len ) ); + + + pHuff_cfg->pred_roll.codebook = &isar_split_rend_huff_roll_pred_consts[0][0]; + pHuff_cfg->pred_roll.sym_len = ISAR_SPLIT_REND_ROLL_PRED_QUANT_PNTS; + isar_split_rend_huffman_dec_init_min_max_len( &pHuff_cfg->pred_roll ); + isar_split_huff_get_idx_trav_list( pHuff_cfg->pred_roll_idx_trav, &pHuff_cfg->pred_roll ); + pHuff_cfg->pred_roll_base2_code_len = (int16_t) ceilf( log2f( pHuff_cfg->pred_roll.sym_len ) ); + + pHuff_cfg->gd.codebook = &isar_split_rend_huff_d_consts[0][0]; + pHuff_cfg->gd.sym_len = ISAR_SPLIT_REND_D_QUANT_PNTS; + isar_split_rend_huffman_dec_init_min_max_len( &pHuff_cfg->gd ); + isar_split_huff_get_idx_trav_list( pHuff_cfg->gd_idx_trav, &pHuff_cfg->gd ); + pHuff_cfg->gd_base2_code_len = (int16_t) ceilf( log2f( pHuff_cfg->gd.sym_len ) ); + + pHuff_cfg->p_gd.codebook = &isar_split_rend_huff_p_d_consts[0][0]; + pHuff_cfg->p_gd.sym_len = ISAR_SPLIT_REND_D_QUANT_PNTS; + isar_split_rend_huffman_dec_init_min_max_len( &pHuff_cfg->p_gd ); + isar_split_huff_get_idx_trav_list( pHuff_cfg->p_gd_idx_trav, &pHuff_cfg->p_gd ); + pHuff_cfg->p_gd_base2_code_len = (int16_t) ceilf( log2f( pHuff_cfg->p_gd.sym_len ) ); + + pHuff_cfg->p_gd_diff.codebook = &isar_split_rend_huff_p_d_diff_consts[0][0]; + pHuff_cfg->p_gd_diff.sym_len = ISAR_SPLIT_REND_D_QUANT_PNTS; + isar_split_rend_huffman_dec_init_min_max_len( &pHuff_cfg->p_gd_diff ); + isar_split_huff_get_idx_trav_list( pHuff_cfg->p_gd_diff_idx_trav, &pHuff_cfg->p_gd_diff ); + pHuff_cfg->p_gd_diff_base2_code_len = (int16_t) ceilf( log2f( pHuff_cfg->p_gd_diff.sym_len ) ); + + return; +} + + +/*------------------------------------------------------------------------- + * Function set_fix_rotation_mat() + * + * + *------------------------------------------------------------------------*/ + +void set_fix_rotation_mat( + float fix_pos_rot_mat[][BINAURAL_CHANNELS][BINAURAL_CHANNELS], + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData ) +{ + float yaw_a, cos_yaw, sin_yaw; + int16_t pos_idx; + yaw_a = 0.0f; + + for ( pos_idx = 0; pos_idx < pMultiBinPoseData->num_poses - 1; pos_idx++ ) + { + yaw_a = pMultiBinPoseData->relative_head_poses[pos_idx + 1][0]; + cos_yaw = cosf( EVS_PI * yaw_a / 180.0f ); + sin_yaw = sinf( EVS_PI * yaw_a / 180.0f ); + sin_yaw = 0.0f; + fix_pos_rot_mat[pos_idx][0][0] = cos_yaw; + fix_pos_rot_mat[pos_idx][1][1] = cos_yaw; + fix_pos_rot_mat[pos_idx][0][1] = sin_yaw; + fix_pos_rot_mat[pos_idx][1][0] = -1.0f * sin_yaw; + } + + return; +} + + +/*------------------------------------------------------------------------- + * Function set_pose_types() + * + * + *------------------------------------------------------------------------*/ + +void set_pose_types( + ISAR_SPLIT_REND_POSE_TYPE pose_type[MAX_HEAD_ROT_POSES - 1], + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData ) +{ + int16_t pos_idx; + + for ( pos_idx = 0; pos_idx < pMultiBinPoseData->num_poses - 1; pos_idx++ ) + { + if ( fabs( pMultiBinPoseData->relative_head_poses[pos_idx + 1][0] ) > EPSILON ) + { + pose_type[pos_idx] = ANY_YAW; + } + else if ( fabs( pMultiBinPoseData->relative_head_poses[pos_idx + 1][2] ) > EPSILON ) + { + pose_type[pos_idx] = ANY_ROLL; + } + else + { + pose_type[pos_idx] = PITCH_ONLY; + } + } + + return; +} + + +/*------------------------------------------------------------------------- + * Function wrap_a() + * + * + *------------------------------------------------------------------------*/ + +int16_t wrap_a( + int16_t val, + const int16_t min_val, + const int16_t max_val ) +{ + if ( val < min_val ) + { + val = max_val - min_val + val + 1; + } + + if ( val > max_val ) + { + val = min_val + val - max_val - 1; + } + + return val; +} + + +/*------------------------------------------------------------------------- + * Function isar_SplitRenderer_getdiagdiff() + * + * + *------------------------------------------------------------------------*/ + +void isar_SplitRenderer_getdiagdiff( + int16_t in_idx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], + int16_t out_idx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], + const int16_t sign, + const int16_t min_val, + const int16_t max_val ) +{ + out_idx[0][0] = in_idx[0][0]; + out_idx[0][1] = in_idx[0][1]; + out_idx[1][1] = in_idx[1][1] + sign * out_idx[0][0]; + out_idx[1][1] = wrap_a( out_idx[1][1], min_val, max_val ); + out_idx[1][0] = in_idx[1][0] + sign * out_idx[0][1]; + out_idx[1][0] = wrap_a( out_idx[1][0], min_val, max_val ); + + return; +} + + +/*------------------------------------------------------------------------- + * Function ISAR_SPLIT_REND_BITStream_read_int32() + * + * + *------------------------------------------------------------------------*/ + +int32_t ISAR_SPLIT_REND_BITStream_read_int32( + ISAR_SPLIT_REND_BITS_HANDLE pBits, + const int32_t bits ) +{ + int32_t val, k, bit_val; + +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG + assert( ( pBits->bits_written - pBits->bits_read ) >= bits ); + assert( bits <= 32 ); +#endif + + /* write bit by bit */ + val = 0; + for ( k = bits - 1; k >= 0; k-- ) + { + bit_val = ( pBits->bits_buf[pBits->bits_read >> 3] & ( 1 << ( pBits->bits_read & 7 ) ) ) != 0; + val |= bit_val << k; + pBits->bits_read++; + } + + return val; +} + + +/*------------------------------------------------------------------------- + * Function ISAR_SPLIT_REND_BITStream_write_int32() + * + * + *------------------------------------------------------------------------*/ + +void ISAR_SPLIT_REND_BITStream_write_int32( + ISAR_SPLIT_REND_BITS_HANDLE pBits, + const int32_t val, + const int32_t bits ) +{ + int32_t mask, k; + +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG + /*protection check*/ + if ( ( pBits->buf_len << 3 ) < ( pBits->bits_written + bits ) ) + { + assert( 0 ); + } +#endif + + mask = 1 << ( bits - 1 ); + /* write bit by bit */ + for ( k = 0; k < bits; k++ ) + { + if ( val & mask ) + { + pBits->bits_buf[pBits->bits_written >> 3] |= ( 1 << ( pBits->bits_written & 7 ) ); + } + else + { + pBits->bits_buf[pBits->bits_written >> 3] &= ~( 1 << ( pBits->bits_written & 7 ) ); + } + pBits->bits_written++; + mask >>= 1; + } + + return; +} + + +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG +/*------------------------------------------------------------------------- + * isar_log_cldfb2wav_data() + * + * + *------------------------------------------------------------------------*/ + +void isar_log_cldfb2wav_data( + float Cldfb_In_Real[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + float Cldfb_In_Imag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + HANDLE_CLDFB_FILTER_BANK *cldfbSyn, + const int16_t num_chs, + const int16_t num_freq_bands, + const int32_t output_Fs, + const int16_t num_slots, + const int16_t start_slot_idx, + const char *filename ) +{ + float *RealBuffer[CLDFB_NO_COL_MAX]; + float *ImagBuffer[CLDFB_NO_COL_MAX]; + float pcm_out[BINAURAL_CHANNELS][L_FRAME48k]; + float *pPcm[BINAURAL_CHANNELS]; + float Cldfb_local_Real[BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + float Cldfb_local_Imag[BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + int16_t sf, ch; + + assert( num_chs <= BINAURAL_CHANNELS ); + for ( ch = 0; ch < num_chs; ch++ ) + { + for ( sf = start_slot_idx; sf < start_slot_idx + num_slots; sf++ ) + { + mvr2r( Cldfb_In_Real[ch][sf], Cldfb_local_Real[ch][sf], num_freq_bands ); + mvr2r( Cldfb_In_Imag[ch][sf], Cldfb_local_Imag[ch][sf], num_freq_bands ); + RealBuffer[sf - start_slot_idx] = Cldfb_local_Real[ch][sf]; + ImagBuffer[sf - start_slot_idx] = Cldfb_local_Imag[ch][sf]; + } + cldfbSynthesis( RealBuffer, ImagBuffer, &( pcm_out[ch][0] ), num_freq_bands * num_slots, cldfbSyn[ch] ); + pPcm[ch] = pcm_out[ch]; + } + dbgwrite_wav( pPcm, num_freq_bands * num_slots, filename, output_Fs, num_chs ); + + return; +} +#endif + + +/*------------------------------------------------------------------------- + * Function isar_get_split_rend_md_target_brate() + * + * + *------------------------------------------------------------------------*/ + +int32_t isar_get_split_rend_md_target_brate( + const int32_t SplitRendBitRate, + const int16_t pcm_out_flag ) +{ + int32_t md_bitrate; + + if ( pcm_out_flag == 1 ) + { + md_bitrate = SplitRendBitRate; + } + else + { + switch ( SplitRendBitRate ) + { + case SPLIT_REND_768k: + { + md_bitrate = 256000; + break; + } + case SPLIT_REND_512k: + { + md_bitrate = 128000; + break; + } + case SPLIT_REND_384k: + { + md_bitrate = 128000; + break; + } + default: + { + return -1; + } + } + } + + return md_bitrate; +} + + +/*------------------------------------------------------------------------- + * Function isar_get_lcld_bitrate() + * + * + *------------------------------------------------------------------------*/ + +int32_t isar_get_lcld_bitrate( + const int32_t SplitRendBitRate, + const ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrectionMode ) +{ + if ( poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) + { + switch ( SplitRendBitRate ) + { + case SPLIT_REND_768k: + { + return IVAS_512k; + } + case SPLIT_REND_512k: + { + return IVAS_384k; + } + case SPLIT_REND_384k: + { + return IVAS_256k; + } + default: + { + assert( 0 ); + } + } + } + else + { + return SplitRendBitRate; + } + + return -1; +} + + +#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS +/*------------------------------------------------------------------------- + * Function isar_get_lc3plus_bitrate() + * + * + *------------------------------------------------------------------------*/ + +int32_t isar_get_lc3plus_bitrate( + const int32_t SplitRendBitRate, + ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrectionMode, + const int16_t split_prerender_frame_size_ms ) +{ + if ( poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) + { + int32_t inBandMdBps = (int32_t) ( 8 * 1000 / split_prerender_frame_size_ms ); + return isar_get_lcld_bitrate( SplitRendBitRate, poseCorrectionMode ) - inBandMdBps; + } + + if ( poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE ) + { + return SplitRendBitRate; + } + + /* Should not be reached */ + assert( 0 ); + return -1; +} + + +/*------------------------------------------------------------------------- + * Function isar_get_lc3plus_bitrate_id() + * + * + *------------------------------------------------------------------------*/ + +int8_t isar_get_lc3plus_bitrate_id( + const int32_t SplitRendBitRate ) +{ + switch ( SplitRendBitRate ) + { + case SPLIT_REND_768k: + { + return 4; + } + case SPLIT_REND_512k: + { + return 3; + } + case SPLIT_REND_384k: + { + return 2; + } + case SPLIT_REND_320k: + { + return 1; + } + case SPLIT_REND_256k: + { + return 0; + } + default: + { + break; + } + } + + return -1; +} + + +/*------------------------------------------------------------------------- + * Function isar_get_lc3plus_size_from_id() + * + * + *------------------------------------------------------------------------*/ + +int32_t isar_get_lc3plus_size_from_id( + const int8_t SplitRendBitRateId, + const ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrectionMode, + const int16_t split_prerender_frame_size_ms ) +{ + int32_t bitrate; + + switch ( SplitRendBitRateId ) + { + case 4: + { + bitrate = SPLIT_REND_768k; + break; + } + case 3: + { + bitrate = SPLIT_REND_512k; + break; + } + case 2: + { + bitrate = SPLIT_REND_384k; + break; + } + case 1: + { + bitrate = SPLIT_REND_320k; + break; + } + case 0: + { + bitrate = SPLIT_REND_256k; + break; + } + default: + { + bitrate = -1; + break; + } + } + + bitrate = isar_get_lc3plus_bitrate( bitrate, poseCorrectionMode, split_prerender_frame_size_ms ); + + /* Return size in bytes */ + return (int32_t) ( bitrate * split_prerender_frame_size_ms / 1000 / 8 ); +} +#endif + + +/*------------------------------------------------------------------------- + * Function isar_split_rend_validate_config() + * + * + *------------------------------------------------------------------------*/ + +ivas_error isar_split_rend_validate_config( + const ISAR_SPLIT_REND_CONFIG_DATA *pSplitRendConfig, + const int16_t is_pcm_out ) +{ + /* Valid DOF range is 0-3 */ + if ( pSplitRendConfig->dof < 0 || pSplitRendConfig->dof > 3 ) + { + return IVAS_ERROR( IVAS_ERR_INVALID_SPLIT_REND_CONFIG, "Valid DOF range is 0-3" ); + } + + /* Only CLDFB pose correction supports HQ mode */ + if ( pSplitRendConfig->poseCorrectionMode != ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB && pSplitRendConfig->hq_mode != 0 ) + { + return IVAS_ERROR( IVAS_ERR_INVALID_SPLIT_REND_CONFIG, "Only CLDFB pose correction supports HQ mode" ); + } + + /* Split rendering with no pose correction - 0 DOF and pose correction NONE must only ever be set together */ + if ( ( pSplitRendConfig->poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE && pSplitRendConfig->dof != 0 ) || + ( pSplitRendConfig->poseCorrectionMode != ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE && pSplitRendConfig->dof == 0 ) ) + { + return IVAS_ERROR( IVAS_ERR_INVALID_SPLIT_REND_CONFIG, "0 DOF and pose correction NONE must only ever be set together" ); + } + + if ( pSplitRendConfig->codec_frame_size_ms != 0 ) /* 0 means "default for current codec", will be set to actual value at a later stage */ + { + if ( pSplitRendConfig->codec == ISAR_SPLIT_REND_CODEC_LCLD && pSplitRendConfig->codec_frame_size_ms != 5 && pSplitRendConfig->codec_frame_size_ms != 10 && pSplitRendConfig->codec_frame_size_ms != 20 ) + { + return IVAS_ERROR( IVAS_ERR_INVALID_SPLIT_REND_CONFIG, "Invalid framing for LCLD codec" ); + } + + if ( pSplitRendConfig->codec == ISAR_SPLIT_REND_CODEC_LC3PLUS && ( pSplitRendConfig->codec_frame_size_ms != 5 && pSplitRendConfig->codec_frame_size_ms != 10 ) ) + { + return IVAS_ERROR( IVAS_ERR_INVALID_SPLIT_REND_CONFIG, "Invalid framing for LC3plus codec" ); + } + } + + /* Validate bitrate */ + if ( is_pcm_out == 0 ) + { + switch ( pSplitRendConfig->splitRendBitRate ) + { + case SPLIT_REND_256k: + if ( pSplitRendConfig->dof != 0 ) + { + return IVAS_ERROR( IVAS_ERR_INVALID_SPLIT_REND_CONFIG, "Bitrates of 320 kbps and lower are only valid with 0 DOF" ); + } + break; + case SPLIT_REND_320k: + /* Only valid with 0 DOF */ + if ( pSplitRendConfig->dof != 0 ) + { + return IVAS_ERROR( IVAS_ERR_INVALID_SPLIT_REND_CONFIG, "Bitrates of 320 kbps and lower are only valid with 0 DOF" ); + } + break; + case SPLIT_REND_384k: + case SPLIT_REND_512k: +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + case SPLIT_REND_768k: +#endif + /* Always valid */ + break; +#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS + case SPLIT_REND_768k: + if ( pSplitRendConfig->dof == 0 && pSplitRendConfig->codec == ISAR_SPLIT_REND_CODEC_LC3PLUS ) + { + return IVAS_ERROR( IVAS_ERR_INVALID_SPLIT_REND_CONFIG, "Bitrate is too high for LC3plus with 0 DOF" ); + } + break; +#endif + default: + return IVAS_ERR_LC3PLUS_INVALID_BITRATE; + } + } + else + { + if ( pSplitRendConfig->dof == 1 ) + { +#ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS + if ( pSplitRendConfig->splitRendBitRate < 34000 ) + { + return IVAS_ERROR( IVAS_ERR_INVALID_SPLIT_REND_CONFIG, "1DOF metadata needs atleast 34 kbps" ); + } +#else + if ( pSplitRendConfig->splitRendBitRate < 50000 ) + { + return IVAS_ERROR( IVAS_ERR_INVALID_SPLIT_REND_CONFIG, "1DOF metadata needs atleast 50 kbps" ); + } +#endif + } + else if ( pSplitRendConfig->dof == 2 ) + { +#ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS + if ( pSplitRendConfig->splitRendBitRate < 50000 ) + { + return IVAS_ERROR( IVAS_ERR_INVALID_SPLIT_REND_CONFIG, "2DOF metadata needs atleast 50 kbps" ); + } +#else + if ( pSplitRendConfig->splitRendBitRate < 66000 ) + { + return IVAS_ERROR( IVAS_ERR_INVALID_SPLIT_REND_CONFIG, "2DOF metadata needs atleast 66 kbps" ); + } +#endif + } + else if ( pSplitRendConfig->dof == 3 ) + { +#ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS + if ( pSplitRendConfig->splitRendBitRate < 82000 ) + { + return IVAS_ERROR( IVAS_ERR_INVALID_SPLIT_REND_CONFIG, "3DOF metadata needs atleast 82 kbps" ); + } +#else + if ( pSplitRendConfig->splitRendBitRate < 128000 ) + { + return IVAS_ERROR( IVAS_ERR_INVALID_SPLIT_REND_CONFIG, "3DOF metadata needs atleast 128 kbps" ); + } +#endif + } + } + + return IVAS_ERR_OK; +} + + +/*------------------------------------------------------------------------- + * Function isar_split_rend_get_quant_params() + * + * + *------------------------------------------------------------------------*/ + +void isar_split_rend_get_quant_params( + const int16_t num_md_bands, + int16_t pred_real_bands_yaw[ISAR_SPLIT_REND_NUM_QUANT_STRATS], + int16_t pred_imag_bands_yaw[ISAR_SPLIT_REND_NUM_QUANT_STRATS], + int16_t pred_quant_pnts_yaw[ISAR_SPLIT_REND_NUM_QUANT_STRATS], + float pred_quantstep_yaw[ISAR_SPLIT_REND_NUM_QUANT_STRATS], + float pred_1byquantstep_yaw[ISAR_SPLIT_REND_NUM_QUANT_STRATS], + int16_t d_bands_yaw[ISAR_SPLIT_REND_NUM_QUANT_STRATS], + int16_t bands_pitch[ISAR_SPLIT_REND_NUM_QUANT_STRATS], + int16_t pred_real_bands_roll[ISAR_SPLIT_REND_NUM_QUANT_STRATS], + int16_t pred_imag_bands_roll[ISAR_SPLIT_REND_NUM_QUANT_STRATS], +#ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS + const int16_t ro_flag, +#endif + int16_t *num_quant_strats +#ifndef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS + , + int16_t *num_complex_bands +#endif +) +{ + int16_t q; + + *num_quant_strats = ISAR_SPLIT_REND_NUM_QUANT_STRATS; +#ifndef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS + *num_complex_bands = COMPLEX_MD_BAND_THRESH_LOW; + assert( *num_complex_bands <= num_md_bands ); +#endif + + pred_quant_pnts_yaw[0] = ISAR_SPLIT_REND_PRED_63QUANT_PNTS; + pred_quantstep_yaw[0] = ISAR_SPLIT_REND_PRED63_Q_STEP; + pred_1byquantstep_yaw[0] = ISAR_SPLIT_REND_PRED63_1BYQ_STEP; + for ( q = 1; q < *num_quant_strats; q++ ) + { + pred_quant_pnts_yaw[q] = ISAR_SPLIT_REND_PRED_31QUANT_PNTS; + pred_quantstep_yaw[q] = ISAR_SPLIT_REND_PRED31_Q_STEP; + pred_1byquantstep_yaw[q] = ISAR_SPLIT_REND_PRED31_1BYQ_STEP; + } + + for ( q = 0; q < *num_quant_strats; q++ ) + { + pred_real_bands_yaw[q] = num_md_bands; + pred_real_bands_roll[q] = num_md_bands; + } + +#ifndef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS + pred_imag_bands_yaw[0] = num_md_bands; + pred_imag_bands_roll[0] = num_md_bands; + pred_imag_bands_yaw[1] = num_md_bands; + pred_imag_bands_roll[1] = num_md_bands; + for ( q = 2; q < *num_quant_strats; q++ ) + { + pred_imag_bands_yaw[q] = ( q < ( *num_quant_strats - 1 ) ) ? num_md_bands : *num_complex_bands; + pred_imag_bands_roll[q] = *num_complex_bands; + } +#else + if ( ro_flag ) + { + for ( q = 0; q < *num_quant_strats; q++ ) + { + pred_imag_bands_yaw[q] = SPLIT_REND_RO_MD_BAND_THRESH; + } + } + else + { + for ( q = 0; q < *num_quant_strats - 2; q++ ) + { + pred_imag_bands_yaw[q] = num_md_bands; + } + pred_imag_bands_yaw[( *num_quant_strats - 2 )] = COMPLEX_MD_BAND_THRESH_HIGH; + pred_imag_bands_yaw[( *num_quant_strats - 1 )] = COMPLEX_MD_BAND_THRESH_LOW; + } + + for ( q = 0; q < *num_quant_strats; q++ ) + { + pred_imag_bands_roll[q] = SPLIT_REND_RO_MD_BAND_THRESH; + } +#endif + + for ( q = 0; q < *num_quant_strats; q++ ) + { + d_bands_yaw[q] = 0; + bands_pitch[q] = num_md_bands; + } + + return; +} + +#ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS +/*------------------------------------------------------------------------- + * Function isar_renderSplitGetRot_axisNumBits() + * + * + *------------------------------------------------------------------------*/ + +int16_t isar_renderSplitGetRot_axisNumBits( + const int16_t dof ) +{ + int16_t num_bits; + if ( dof < 3 ) + { + num_bits = 2; + } + else + { + num_bits = 0; + } + return num_bits; +} + +/*------------------------------------------------------------------------- + * Function isar_renderSplitGetRot_axisFromCode() + * + * + *------------------------------------------------------------------------*/ + +ISAR_SPLIT_REND_ROT_AXIS isar_renderSplitGetRot_axisFromCode( + const int16_t dof, + const int16_t code ) +{ + ISAR_SPLIT_REND_ROT_AXIS rot_axis; + + if ( dof == 1 ) + { + rot_axis = (ISAR_SPLIT_REND_ROT_AXIS) code; + } + else if ( dof == 2 ) + { + if ( code == 0 ) + { + rot_axis = (ISAR_SPLIT_REND_ROT_AXIS) code; + } + else + { + rot_axis = (ISAR_SPLIT_REND_ROT_AXIS) ( code - 1 ) + YAW_PITCH; + } + } + else + { + rot_axis = (ISAR_SPLIT_REND_ROT_AXIS) DEFAULT_AXIS; + } + + return rot_axis; +} + +/*------------------------------------------------------------------------- + * Function isar_renderSplitGetCodeFromRot_axis() + * + * + *------------------------------------------------------------------------*/ + +int16_t isar_renderSplitGetCodeFromRot_axis( + const int16_t dof, + const ISAR_SPLIT_REND_ROT_AXIS rot_axis, + int16_t *num_bits ) +{ + int16_t code = 0; + if ( dof == 1 ) + { + code = (int16_t) rot_axis; + } + else if ( dof == 2 ) + { + if ( rot_axis == DEFAULT_AXIS ) + { + code = (int16_t) rot_axis; + } + else + { + code = (int16_t) ( rot_axis - YAW_PITCH ) + 1; + } + } + else + { + code = (int16_t) DEFAULT_AXIS; + } + *num_bits = isar_renderSplitGetRot_axisNumBits( dof ); + + return code; +} +#endif + +/*------------------------------------------------------------------------- + * Function isar_renderSplitGetMultiBinPoseData() + * + * + *------------------------------------------------------------------------*/ + +void isar_renderSplitGetMultiBinPoseData( + const ISAR_SPLIT_REND_CONFIG_DATA *pSplit_rend_config, + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + const ISAR_SPLIT_REND_ROT_AXIS rot_axis ) +{ + int16_t pos_idx, num_yaw_poses, num_pitch_poses, num_roll_poses; + const float *relative_yaw_angles; + const float *relative_pitch_angles; + const float *relative_roll_angles; + + for ( pos_idx = 0; pos_idx < MAX_HEAD_ROT_POSES; pos_idx++ ) + { + pMultiBinPoseData->relative_head_poses[pos_idx][0] = 0.0f; + pMultiBinPoseData->relative_head_poses[pos_idx][1] = 0.0f; + pMultiBinPoseData->relative_head_poses[pos_idx][2] = 0.0f; + } + + /* 0 DOF defaults */ + num_yaw_poses = 0; + num_pitch_poses = 0; + num_roll_poses = 0; + + /* defaults for all DOF except 3DOF HQ */ + relative_yaw_angles = isar_split_rend_relative_yaw_pos_angles_hq; + relative_pitch_angles = isar_split_rend_relative_pitch_pos_angles_hq; + relative_roll_angles = isar_split_rend_relative_roll_pos_angles_hq; + + if ( pSplit_rend_config->dof == 1 ) + { + switch ( rot_axis ) + { + case DEFAULT_AXIS: + case YAW: + { + num_yaw_poses = SPLIT_REND_MAX_YAW_ONLY_POSES; + break; + } + case PITCH: + { + num_pitch_poses = SPLIT_REND_MAX_PITCH_ONLY_POSES; + break; + } + case ROLL: + { + num_roll_poses = SPLIT_REND_MAX_ROLL_ONLY_POSES; + break; + } + default: + { + assert( 0 && "unsupported rotation axis value" ); + } + } + } + else if ( pSplit_rend_config->dof == 2 ) + { + switch ( rot_axis ) + { + case DEFAULT_AXIS: +#ifndef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS + case YAW: + case PITCH: +#endif + case YAW_PITCH: + { + num_yaw_poses = SPLIT_REND_MAX_YAW_ONLY_POSES; + num_pitch_poses = SPLIT_REND_MAX_PITCH_ONLY_POSES; + break; + } +#ifndef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS + case ROLL: +#endif + case YAW_ROLL: + { + num_yaw_poses = SPLIT_REND_MAX_YAW_ONLY_POSES; + num_roll_poses = SPLIT_REND_MAX_ROLL_ONLY_POSES; + break; + } + case PITCH_ROLL: + { + num_pitch_poses = SPLIT_REND_MAX_PITCH_ONLY_POSES; + num_roll_poses = SPLIT_REND_MAX_ROLL_ONLY_POSES; + break; + } + default: + { + assert( 0 && "unsupported rotation axis value" ); + } + } + } + else if ( pSplit_rend_config->dof == 3 ) + { + if ( pSplit_rend_config->hq_mode == 1 ) + { + relative_yaw_angles = isar_split_rend_relative_yaw_pos_angles_hq; + relative_pitch_angles = isar_split_rend_relative_pitch_pos_angles_hq; + relative_roll_angles = isar_split_rend_relative_roll_pos_angles_hq; + num_yaw_poses = SPLIT_REND_MAX_YAW_ONLY_POSES; + num_pitch_poses = SPLIT_REND_MAX_PITCH_ONLY_POSES; + num_roll_poses = SPLIT_REND_MAX_ROLL_ONLY_POSES; + } + else + { + relative_yaw_angles = isar_split_rend_relative_yaw_pos_angles; + relative_pitch_angles = isar_split_rend_relative_pitch_pos_angles; + relative_roll_angles = isar_split_rend_relative_roll_pos_angles; + num_yaw_poses = SPLIT_REND_MAX_YAW_ONLY_POSES; + num_pitch_poses = 1; + num_roll_poses = 1; + } + } + + pMultiBinPoseData->num_poses = num_yaw_poses + num_pitch_poses + num_roll_poses + 1; + assert( pMultiBinPoseData->num_poses <= MAX_HEAD_ROT_POSES ); + + for ( pos_idx = 0; pos_idx < num_yaw_poses; pos_idx++ ) + { + pMultiBinPoseData->relative_head_poses[pos_idx + 1][0] = relative_yaw_angles[pos_idx]; + } + + for ( pos_idx = 0; pos_idx < num_pitch_poses; pos_idx++ ) + { + pMultiBinPoseData->relative_head_poses[pos_idx + num_yaw_poses + 1][1] = relative_pitch_angles[pos_idx]; + } + + for ( pos_idx = 0; pos_idx < num_roll_poses; pos_idx++ ) + { + pMultiBinPoseData->relative_head_poses[pos_idx + num_yaw_poses + num_pitch_poses + 1][2] = relative_roll_angles[pos_idx]; + } + pMultiBinPoseData->dof = pSplit_rend_config->dof; + pMultiBinPoseData->hq_mode = pSplit_rend_config->hq_mode; + pMultiBinPoseData->rot_axis = rot_axis; + pMultiBinPoseData->poseCorrectionMode = pSplit_rend_config->poseCorrectionMode; + + return; +} + + +/*------------------------------------------------------------------------- + * Function isar_renderSplitUpdateNoCorrectionPoseData() + * + * + *------------------------------------------------------------------------*/ + +void isar_renderSplitUpdateNoCorrectionPoseData( + const ISAR_SPLIT_REND_CONFIG_DATA *pSplit_rend_config, + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData ) +{ + pMultiBinPoseData->num_poses = 1; + assert( pSplit_rend_config->dof == 0 ); + pMultiBinPoseData->dof = pSplit_rend_config->dof; + assert( pSplit_rend_config->poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE ); + pMultiBinPoseData->poseCorrectionMode = pSplit_rend_config->poseCorrectionMode; + + return; +} + + +/*------------------------------------------------------------------------- + * Function isar_init_multi_bin_pose_data() + * + * + *------------------------------------------------------------------------*/ + +void isar_init_multi_bin_pose_data( + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData ) +{ + int16_t pos_idx; + + for ( pos_idx = 0; pos_idx < MAX_HEAD_ROT_POSES; pos_idx++ ) + { + pMultiBinPoseData->relative_head_poses[pos_idx][0] = 0.0f; + pMultiBinPoseData->relative_head_poses[pos_idx][1] = 0.0f; + pMultiBinPoseData->relative_head_poses[pos_idx][2] = 0.0f; + } + pMultiBinPoseData->num_poses = 1; + pMultiBinPoseData->dof = 3; + pMultiBinPoseData->hq_mode = 0; + pMultiBinPoseData->rot_axis = DEFAULT_AXIS; + + return; +} + +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS +ivas_error isar_framesize_to_ms( + const IVAS_RENDER_FRAMESIZE frame_size, /* i : frame size enum */ + int16_t *ms /* o : frame size in ms */ +) +{ + switch ( frame_size ) + { + case IVAS_RENDER_FRAMESIZE_5MS: + *ms = 5; + break; + case IVAS_RENDER_FRAMESIZE_10MS: + *ms = 10; + break; + case IVAS_RENDER_FRAMESIZE_20MS: + *ms = 20; + break; + default: + return IVAS_ERROR( IVAS_ERR_INTERNAL, "Unsupported ISAR frame size" ); + } + + return IVAS_ERR_OK; +} +#endif + + +/*------------------------------------------------------------------------- + * Function isar_split_rend_choose_default_codec() + * + * + *------------------------------------------------------------------------*/ + +ivas_error isar_split_rend_choose_default_codec( + ISAR_SPLIT_REND_CODEC *pCodec, /* i/o: pointer to codec setting */ +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + int16_t *pIsar_frame_size_ms, /* i/o: pointer to isar frame size setting */ +#endif + int16_t *pCodec_frame_size_ms, /* i/o: pointer to codec frame size setting */ + const int16_t cldfb_in_flag, /* i : flag indicating rendering in TD */ + const int16_t pcm_out_flag, /* i : flag to indicate PCM output */ + const int16_t num_subframes /* i : number of subframes */ +) +{ + if ( pcm_out_flag == 0 ) + { + if ( *pCodec == ISAR_SPLIT_REND_CODEC_DEFAULT ) + { + *pCodec = cldfb_in_flag ? ISAR_SPLIT_REND_CODEC_LCLD : ISAR_SPLIT_REND_CODEC_LC3PLUS; + } + } + else + { + *pCodec = ISAR_SPLIT_REND_CODEC_NONE; + } + + if ( *pCodec_frame_size_ms == 0 ) /* codec frame size hasn't been set yet - use default for current configuration */ + { + switch ( *pCodec ) + { + case ISAR_SPLIT_REND_CODEC_LCLD: + *pCodec_frame_size_ms = num_subframes * 5; + break; + case ISAR_SPLIT_REND_CODEC_LC3PLUS: + case ISAR_SPLIT_REND_CODEC_NONE: + *pCodec_frame_size_ms = 5; + break; + default: + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Unknown split codec value" ); + } + } +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + if ( *pIsar_frame_size_ms == 0 ) /* isar frame size hasn't been set yet - use default for current configuration */ + { + *pIsar_frame_size_ms = 20; + } +#endif + return IVAS_ERR_OK; +} + +/*-------------------------------------------------------------------* + * Function get_bit() + * + * + *-------------------------------------------------------------------*/ + +int32_t get_bit( + const int32_t state, + const int32_t bit_id ) +{ + return ( state & ( 1 << bit_id ) ); +} + +#endif diff --git a/lib_isar/isar_stat.h b/lib_isar/isar_stat.h new file mode 100644 index 0000000000000000000000000000000000000000..65376ea191f05b5ebb78e4843df84680e14c5edf --- /dev/null +++ b/lib_isar/isar_stat.h @@ -0,0 +1,259 @@ +/****************************************************************************************************** + + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#ifndef ISAR_STAT_H +#define ISAR_STAT_H + + +#include +#include "options.h" +#include "stat_com.h" +#include "ivas_stat_com.h" +#ifdef SPLIT_REND_WITH_HEAD_ROT +#include "isar_lcld_prot.h" +#include "isar_lc3plus_enc.h" +#include "isar_lc3plus_dec.h" +#include "isar_cnst.h" + + +/*-------------------------------------------------------------------* + * ISAR post rend constants + *-------------------------------------------------------------------*/ + +#define MAX_CLDFB_BUFFER_LENGTH_PER_CHANNEL ( MAX_BUFFER_LENGTH_PER_CHANNEL * 2 ) +#define MAX_CLDFB_BUFFER_LENGTH ( MAX_CLDFB_BUFFER_LENGTH_PER_CHANNEL * MAX_INPUT_CHANNELS ) +#define MAX_BIN_BUFFER_LENGTH ( MAX_BUFFER_LENGTH_PER_CHANNEL * BINAURAL_CHANNELS ) +#define MAX_CLDFB_BIN_BUFFER_LENGTH ( MAX_CLDFB_BUFFER_LENGTH_PER_CHANNEL * BINAURAL_CHANNELS ) + +/*-------------------------------------------------------------------* + * ISAR post rend structs + *-------------------------------------------------------------------*/ + +typedef struct +{ + int8_t headRotEnabled; + IVAS_QUATERNION headPositions[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES]; + IVAS_VECTOR3 Pos[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES]; + float crossfade[L_FRAME48k / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES]; + ISAR_SPLIT_REND_ROT_AXIS sr_pose_pred_axis; + +} ISAR_POST_REND_HeadRotData; + +typedef struct +{ +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG + HANDLE_CLDFB_FILTER_BANK cldfbAna[( 1 + MAX_HEAD_ROT_POSES ) * BINAURAL_CHANNELS]; +#else + HANDLE_CLDFB_FILTER_BANK cldfbAna[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS]; +#endif + HANDLE_CLDFB_FILTER_BANK cldfbSyn[BINAURAL_CHANNELS]; + +} CLDFB_HANDLES_WRAPPER, *CLDFB_HANDLES_WRAPPER_HANDLE; + +typedef struct isar_split_rend_huffman_cfg_t +{ + const int32_t *codebook; + int16_t min_len; + int16_t max_len; + int16_t sym_len; + +} isar_split_rend_huffman_cfg_t; + +typedef struct isar_binaural_head_rot_split_rendering_huff_struct +{ + isar_split_rend_huffman_cfg_t pred[2]; + int16_t pred_idx_trav[2][ISAR_SPLIT_REND_PRED_63QUANT_PNTS]; + int16_t pred_base2_code_len[2]; + isar_split_rend_huffman_cfg_t pred_roll; + int16_t pred_roll_idx_trav[ISAR_SPLIT_REND_ROLL_PRED_QUANT_PNTS]; + int16_t pred_roll_base2_code_len; + isar_split_rend_huffman_cfg_t gd; + int16_t gd_base2_code_len; + int16_t gd_idx_trav[ISAR_SPLIT_REND_D_QUANT_PNTS]; + isar_split_rend_huffman_cfg_t p_gd; + int16_t p_gd_base2_code_len; + int16_t p_gd_idx_trav[ISAR_SPLIT_REND_D_QUANT_PNTS]; + isar_split_rend_huffman_cfg_t p_gd_diff; + int16_t p_gd_diff_base2_code_len; + int16_t p_gd_diff_idx_trav[ISAR_SPLIT_REND_D_QUANT_PNTS]; + +} ISAR_BIN_HR_SPLIT_REND_HUFF, *ISAR_BIN_HR_SPLIT_REND_HUFF_HANDLE; + +/* binaural split rendering head rotation data structure */ +typedef struct isar_binaural_head_rot_split_rendering_md_struct +{ + float pred_mat_re[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + float pred_mat_im[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; +#ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS + float pred_mat_re2[BINAURAL_CHANNELS]; +#endif + float gd; + float gd2; + int16_t pred_mat_re_idx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + int16_t pred_mat_im_idx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + int16_t gd_idx; + int16_t gd2_idx; + +} ISAR_BIN_HR_SPLIT_REND_MD, *ISAR_BIN_HR_SPLIT_REND_MD_HANDLE; + +typedef struct isar_binaural_head_rot_split_pre_rendering_struct +{ + ISAR_BIN_HR_SPLIT_REND_MD rot_md[MAX_HEAD_ROT_POSES - 1][MAX_SPLIT_MD_SUBFRAMES][MAX_SPLIT_REND_MD_BANDS]; + float fix_pos_rot_mat[MAX_HEAD_ROT_POSES - 1][BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + ISAR_SPLIT_REND_POSE_TYPE pose_type[MAX_HEAD_ROT_POSES - 1]; + ISAR_BIN_HR_SPLIT_REND_HUFF huff_cfg; +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG + HANDLE_CLDFB_FILTER_BANK cldfbSynRotBinDec[MAX_HEAD_ROT_POSES + 1][BINAURAL_CHANNELS]; +#endif + +#ifdef SPLIT_POSE_CORRECTION_DEBUG + BIN_HR_SPLIT_POST_REND_HANDLE hBinHrSplitPostRend; +#endif + +} ISAR_BIN_HR_SPLIT_PRE_REND, *ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE; + +/*----------------------------------------------------------------------------------* + * Output configuration for renderer (e.g. DirAC, MASA, Binaural Renderer...) + *----------------------------------------------------------------------------------*/ + +typedef struct isar_binaural_head_rot_split_rendering_lcld_enc_struct +{ + void *pLcld_enc; + int16_t iChannels; + LCLDEncoder *psLCLDEncoder; + float ***pppfLCLDReal; + float ***pppfLCLDImag; +#ifdef CLDFB_DEBUG + FILE *cldfbIn; + int16_t numFrame; +#endif + int16_t iNumIterations; + int16_t iNumBlocks; + +} ISAR_BIN_HR_SPLIT_LCLD_ENC, *ISAR_BIN_HR_SPLIT_LCLD_ENC_HANDLE; + +typedef struct +{ + float Cldfb_Prev_BinReal[BINAURAL_CHANNELS][CLDFB_NO_COL_MAX + CLDFB_PLC_XF][CLDFB_NO_CHANNELS_MAX]; + float Cldfb_Prev_BinImag[BINAURAL_CHANNELS][CLDFB_NO_COL_MAX + CLDFB_PLC_XF][CLDFB_NO_CHANNELS_MAX]; + float xf_bet[2][CLDFB_NO_CHANNELS_MAX][CLDFB_PLC_XF]; +} ISAR_CLDFB_PLC, *ISAR_CLDFB_PLC_HANDLE; + +typedef struct +{ + ISAR_CLDFB_PLC CldfbPLC_state; + int16_t prev_bfi; + int16_t bf_count; + int16_t iNumSubSets; + +} ISAR_SPLIT_REND_PLC_STRUCT, *ISAR_SPLIT_REND_PLC_HANDLE; + +typedef struct isar_binaural_head_rot_split_rendering_lcld_dec_struct +{ + void *pLcld_dec; + int32_t iChannels; + LCLDDecoder *psLCLDDecoder; + float ***pppfDecLCLDReal; + float ***pppfDecLCLDImag; +#ifdef CLDFB_DEBUG + FILE *cldfbOut; + int16_t numFrame; +#endif + ISAR_SPLIT_REND_PLC_HANDLE hSplitRendPLC; + + int16_t iNumBlocks; + int16_t iNumIterations; + +} ISAR_BIN_HR_SPLIT_LCLD_DEC, *ISAR_BIN_HR_SPLIT_LCLD_DEC_HANDLE; + +typedef struct isar_binaural_head_rot_split_post_rendering_struct +{ + ISAR_BIN_HR_SPLIT_REND_MD rot_md[MAX_HEAD_ROT_POSES][MAX_SPLIT_MD_SUBFRAMES][MAX_SPLIT_REND_MD_BANDS]; + IVAS_QUATERNION QuaternionsPre[MAX_PARAM_SPATIAL_SUBFRAMES]; + int16_t low_Res; + + float fix_pos_rot_mat[MAX_HEAD_ROT_POSES - 1][BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + ISAR_SPLIT_REND_POSE_TYPE pose_type[MAX_HEAD_ROT_POSES - 1]; + ISAR_BIN_HR_SPLIT_REND_HUFF huff_cfg; +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG + float mixer_mat_re[MAX_HEAD_ROT_POSES][MAX_SPLIT_REND_MD_BANDS][BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + float mixer_mat_im[MAX_HEAD_ROT_POSES][MAX_SPLIT_REND_MD_BANDS][BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + float gd_mem[MAX_HEAD_ROT_POSES][MAX_SPLIT_REND_MD_BANDS]; +#else + float mixer_mat_re[1][MAX_SPLIT_REND_MD_BANDS][BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + float mixer_mat_im[1][MAX_SPLIT_REND_MD_BANDS][BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + float gd_mem[1][MAX_SPLIT_REND_MD_BANDS]; +#endif + int16_t cf_flag; + HANDLE_CLDFB_FILTER_BANK cldfbAna[BINAURAL_CHANNELS]; + HANDLE_CLDFB_FILTER_BANK cldfbSyn[BINAURAL_CHANNELS]; +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG + HANDLE_CLDFB_FILTER_BANK cldfbSynReconsBinDec[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS]; +#endif + +} ISAR_BIN_HR_SPLIT_POST_REND, *ISAR_BIN_HR_SPLIT_POST_REND_HANDLE; + +typedef struct +{ + int16_t num_poses; + float relative_head_poses[MAX_HEAD_ROT_POSES][3]; + int16_t dof; + int16_t hq_mode; + ISAR_SPLIT_REND_ROT_AXIS rot_axis; + ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrectionMode; + +} MULTI_BIN_REND_POSE_DATA; + +typedef struct +{ + MULTI_BIN_REND_POSE_DATA multiBinPoseData; + ISAR_BIN_HR_SPLIT_POST_REND_HANDLE hBinHrSplitPostRend; + ISAR_BIN_HR_SPLIT_LCLD_DEC_HANDLE hSplitBinLCLDDec; + int16_t first_good_frame_received; + ISAR_LC3PLUS_DEC_HANDLE hLc3plusDec; + +} ISAR_SPLIT_POST_REND_WRAPPER; + +typedef struct +{ + MULTI_BIN_REND_POSE_DATA multiBinPoseData; + ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE hBinHrSplitPreRend; + ISAR_BIN_HR_SPLIT_LCLD_ENC_HANDLE hSplitBinLCLDEnc; + CLDFB_HANDLES_WRAPPER_HANDLE hCldfbHandles; + ISAR_LC3PLUS_ENC_HANDLE hLc3plusEnc; + float *lc3plusDelayBuffers[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS]; /* Used to time-align head pose correction metadata with LC3plus-coded reference audio */ + int32_t lc3plusDelaySamples; + +} SPLIT_REND_WRAPPER; +#endif + +#endif /* ISAR_STAT_H */ diff --git a/lib_isar/lib_isar_post_rend.c b/lib_isar/lib_isar_post_rend.c new file mode 100644 index 0000000000000000000000000000000000000000..80b17c499ec9fa974a55636e31158eb4f44a86e4 --- /dev/null +++ b/lib_isar/lib_isar_post_rend.c @@ -0,0 +1,1911 @@ +/****************************************************************************************************** + + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + + +#include "options.h" +#include "lib_isar_post_rend.h" +#include "isar_stat.h" +#include "isar_prot.h" +#include "prot.h" +#include "ivas_prot.h" + +#ifndef SPLIT_REND_WITH_HEAD_ROT + +int32_t ISAR_POST_REND_void_func( void ) +{ + return 0; +} + +#else + +#include "ivas_prot_rend.h" +#include +#include +#include "wmc_auto.h" + + +/*-------------------------------------------------------------------* + * Local constants + *-------------------------------------------------------------------*/ + +/*-------------------------------------------------------------------* + * Local types + *-------------------------------------------------------------------*/ + +/* EFAP wrapper to simplify writing panning gains to a vector that includes LFE channels */ +typedef struct +{ + EFAP_HANDLE hEfap; + AUDIO_CONFIG speakerConfig; + const LSSETUP_CUSTOM_STRUCT *pCustomLsSetup; /* Pointer to main custom LS struct from renderer handle - doesn't need freeing */ +} EFAP_WRAPPER; + +/* Lightweight helper struct that gathers all information required for rendering + * any config to any other config. Used to simplify signatures of rendering functions. + * + * This struct should store ONLY CONST POINTERS to data existing elsewhere. + * Storing pointers instead of data itself ensures that no additional updates + * are required when any of these are changed in the renderer. Making the pointers + * const ensures that this data is only read, but not modified by the rendering functions. */ +typedef struct +{ + const int32_t *pOutSampleRate; + const AUDIO_CONFIG *pOutConfig; +#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS + const LSSETUP_CUSTOM_STRUCT *pCustomLsOut; + const EFAP_WRAPPER *pEfapOutWrapper; +#endif + const ISAR_POST_REND_HeadRotData *pHeadRotData; +#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS + const RENDER_CONFIG_HANDLE *hhRendererConfig; +#endif + const int16_t *pSplitRendBFI; +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + const ISAR_SPLIT_REND_CONFIG_DATA *pSplitRenderConfig; +#endif +} rendering_context; + +/* Common base for input structs */ +typedef struct +{ + AUDIO_CONFIG inConfig; + ISAR_POST_REND_InputId id; + IVAS_REND_AudioBuffer inputBuffer; + float gain; /* Linear, not in dB */ + rendering_context ctx; + int32_t numNewSamplesPerChannel; /* Used to keep track how much new audio was fed before rendering current frame */ +} input_base; + +typedef struct +{ + input_base base; + ISAR_SPLIT_POST_REND_WRAPPER splitPostRendWrapper; + float *bufferData; + int16_t numCachedSamples; /* Number of decoded samples in bufferData that have not yet been played out */ + ISAR_POST_REND_BitstreamBuffer *hBits; +} input_split_post_rend; + +struct ISAR_POST_REND +{ + int32_t sampleRateOut; + + IVAS_LIMITER_HANDLE hLimiter; +#ifdef DEBUGGING + int32_t numClipping; /* Counter of clipped output samples */ +#endif + + input_split_post_rend inputsSplitPost[RENDERER_MAX_BIN_INPUTS]; + + AUDIO_CONFIG inputConfig; + AUDIO_CONFIG outputConfig; + + ISAR_POST_REND_HeadRotData headRotData; + int16_t splitRendBFI; + + int8_t rendererConfigEnabled; + ISAR_SPLIT_REND_CONFIG_DATA splitRenderConfig; + + int16_t num_subframes; +}; + +/*-------------------------------------------------------------------* + * getAudioConfigType() + * + * + *-------------------------------------------------------------------*/ + +ISAR_POST_REND_AudioConfigType isar_getAudioConfigType( + const AUDIO_CONFIG config ) +{ + ISAR_POST_REND_AudioConfigType type; + + switch ( config ) + { + case IVAS_AUDIO_CONFIG_BINAURAL: + case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM: + case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED: + type = ISAR_POST_REND_AUDIO_CONFIG_TYPE_BINAURAL; + break; + default: + type = ISAR_POST_REND_AUDIO_CONFIG_TYPE_UNKNOWN; + break; + } + + return type; +} + + +/*-------------------------------------------------------------------* + * Local function prototypes + *-------------------------------------------------------------------*/ + +/*-------------------------------------------------------------------* + * Local functions + *-------------------------------------------------------------------*/ + +static ivas_error allocateInputBaseBufferData( + float **data, + const int16_t data_size ) +{ + *data = (float *) malloc( data_size * sizeof( float ) ); + if ( *data == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for input base buffer data" ); + } + + return IVAS_ERR_OK; +} + +static void freeInputBaseBufferData( + float **data ) +{ + if ( *data != NULL ) + { + free( *data ); + *data = NULL; + } + + return; +} + + +static IVAS_QUATERNION quaternionInit( + void ) +{ + IVAS_QUATERNION q; + q.w = 1.0f; + q.x = q.y = q.z = 0.0f; + return q; +} + +static void convertBitsBufferToInternalBitsBuff( + const ISAR_POST_REND_BitstreamBuffer outBits, + ISAR_SPLIT_REND_BITS_HANDLE hBits ) +{ + hBits->bits_buf = outBits.bits; + hBits->bits_read = outBits.config.bitsRead; + hBits->bits_written = outBits.config.bitsWritten; + hBits->buf_len = outBits.config.bufLenInBytes; + hBits->codec = outBits.config.codec; + hBits->pose_correction = outBits.config.poseCorrection; + hBits->codec_frame_size_ms = outBits.config.codec_frame_size_ms; +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + hBits->isar_frame_size_ms = outBits.config.isar_frame_size_ms; + hBits->lc3plus_highres = outBits.config.lc3plusHighRes; +#endif + + return; +} + +static void convertInternalBitsBuffToBitsBuffer( + ISAR_POST_REND_BitstreamBuffer *hOutBits, + const ISAR_SPLIT_REND_BITS_DATA bits ) +{ + hOutBits->bits = bits.bits_buf; + hOutBits->config.bitsRead = bits.bits_read; + hOutBits->config.bitsWritten = bits.bits_written; + hOutBits->config.bufLenInBytes = bits.buf_len; + hOutBits->config.codec = bits.codec; + hOutBits->config.poseCorrection = bits.pose_correction; + hOutBits->config.codec_frame_size_ms = bits.codec_frame_size_ms; +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + hOutBits->config.isar_frame_size_ms = bits.isar_frame_size_ms; + hOutBits->config.lc3plusHighRes = bits.lc3plus_highres; +#endif + + return; +} + +static void copyBufferTo2dArray( + const IVAS_REND_AudioBuffer buffer, + float array[][L_FRAME48k] ) +{ + uint32_t smplIdx; + uint32_t chnlIdx; + const float *readPtr; + + assert( ( buffer.config.is_cldfb == 0 ) && "for CLDFB input call copyBufferToCLDFBarray()" ); + readPtr = buffer.data; + + for ( chnlIdx = 0; chnlIdx < (uint32_t) buffer.config.numChannels; ++chnlIdx ) + { + for ( smplIdx = 0; smplIdx < (uint32_t) buffer.config.numSamplesPerChannel; ++smplIdx ) + { + array[chnlIdx][smplIdx] = *readPtr++; + } + } + + return; +} + +static void accumulate2dArrayToBuffer( + float array[][L_FRAME48k], + const IVAS_REND_AudioBuffer *buffer ) +{ + int16_t smplIdx, chnlIdx; + float *writePtr; + + writePtr = buffer->data; + for ( chnlIdx = 0; chnlIdx < buffer->config.numChannels; ++chnlIdx ) + { + for ( smplIdx = 0; smplIdx < buffer->config.numSamplesPerChannel; ++smplIdx ) + { + *writePtr++ += array[chnlIdx][smplIdx]; + } + } + + return; +} + +/*-------------------------------------------------------------------* + * limitRendererOutput() + * + * In-place saturation control for multichannel buffers with adaptive release time + *-------------------------------------------------------------------*/ + +#ifndef DISABLE_LIMITER +/*! r: number of clipped output samples */ +static int32_t limitRendererOutput( + IVAS_LIMITER_HANDLE hLimiter, /* i/o: limiter struct handle */ + float *output, /* i/o: I/O buffer */ + const int16_t output_frame, /* i : number of samples per channel in the buffer */ + const float threshold /* i : signal amplitude above which limiting starts to be applied */ +) +{ + int16_t i; + float **channels; + int16_t num_channels; + int32_t numClipping = 0; + + /* return early if given bad parameters */ + if ( hLimiter == NULL || output == NULL || output_frame <= 0 ) + { + return 0; + } + + channels = hLimiter->channel_ptrs; + num_channels = hLimiter->num_channels; + + for ( i = 0; i < num_channels; ++i ) + { + channels[i] = output + i * output_frame; + } + + limiter_process( hLimiter, output_frame, threshold, 0, NULL ); + + /* Apply clipping to buffer in case the limiter let through some samples > 1.0f */ + for ( i = 0; i < output_frame * num_channels; ++i ) + { +#ifdef DEBUGGING + if ( output[i] < INT16_MIN || output[i] > INT16_MAX ) + { + ++numClipping; + } +#endif + + output[i] = min( max( INT16_MIN, output[i] ), INT16_MAX ); + } + + return numClipping; +} +#endif + + +/*-------------------------------------------------------------------* + * validateOutputSampleRate() + * + * + *-------------------------------------------------------------------*/ + +static ivas_error validateOutputSampleRate( + const int32_t sampleRate, + const AUDIO_CONFIG outConfig ) +{ + if ( ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) && sampleRate != 48000 ) + { + return IVAS_ERROR( IVAS_ERR_INVALID_SAMPLING_RATE, "Error: Only 48kHz output sampling rate is supported for split rendering." ); + } + else + { + /* Otherwise rendering to binaural, support the same set as IVAS decoder */ + switch ( sampleRate ) + { + case 8000: + case 16000: + case 32000: + case 48000: + return IVAS_ERR_OK; + } + + return IVAS_ERR_INVALID_SAMPLING_RATE; + } +} + + +/*-------------------------------------------------------------------* + * Local functions + *-------------------------------------------------------------------*/ + +static ivas_error initLimiter( + IVAS_LIMITER_HANDLE *phLimiter, + const int16_t numChannels, + const int32_t sampleRate ) +{ + ivas_error error; + + /* If re-initializing with unchanged values, return early */ + if ( *phLimiter != NULL && ( *phLimiter )->num_channels == numChannels && ( *phLimiter )->sampling_rate == sampleRate ) + { + return IVAS_ERR_OK; + } + + /* Support re-init: close if already allocated */ + if ( *phLimiter != NULL ) + { + ivas_limiter_close( phLimiter ); + } + + if ( ( error = ivas_limiter_open( phLimiter, numChannels, sampleRate ) ) != IVAS_ERR_OK ) + { + return error; + } + + return IVAS_ERR_OK; +} + + +static ivas_error initHeadRotation( + ISAR_POST_REND_HANDLE hIvasRend ) +{ + int16_t i, crossfade_len; + float tmp; + + /* Head rotation is enabled by default */ + hIvasRend->headRotData.headRotEnabled = 1; + + /* Initialize 5ms crossfade */ + crossfade_len = L_FRAME48k / MAX_PARAM_SPATIAL_SUBFRAMES; + tmp = 1.f / ( crossfade_len - 1 ); + for ( i = 0; i < crossfade_len; i++ ) + { + hIvasRend->headRotData.crossfade[i] = i * tmp; + } + + /* Initialize with unit quaternions */ + for ( i = 0; i < hIvasRend->num_subframes; ++i ) + { + hIvasRend->headRotData.headPositions[i] = quaternionInit(); + } + + hIvasRend->headRotData.sr_pose_pred_axis = DEFAULT_AXIS; + + return IVAS_ERR_OK; +} + + +static void initRendInputBase( + input_base *inputBase, + const AUDIO_CONFIG inConfig, + const IVAS_REND_InputId id, + const rendering_context rendCtx, + float *dataBuf, + const int16_t dataBufSize ) +{ + inputBase->inConfig = inConfig; + inputBase->id = id; + inputBase->gain = 1.0f; + inputBase->ctx = rendCtx; + inputBase->numNewSamplesPerChannel = 0; + + inputBase->inputBuffer.config.numSamplesPerChannel = 0; + inputBase->inputBuffer.config.numChannels = 0; + inputBase->inputBuffer.data = dataBuf; + if ( inputBase->inputBuffer.data != NULL ) + { + set_zero( inputBase->inputBuffer.data, dataBufSize ); + } + + return; +} + + +static rendering_context getRendCtx( + ISAR_POST_REND_HANDLE hIvasRend ) +{ + rendering_context ctx; + + /* Note: when refactoring this, always take the ADDRESS of a member of the + * renderer struct, so that the context stores a POINTER to the member, even + * if the member is a pointer or handle itself. */ + ctx.pOutConfig = &hIvasRend->outputConfig; + ctx.pOutSampleRate = &hIvasRend->sampleRateOut; + ctx.pHeadRotData = &hIvasRend->headRotData; + ctx.pSplitRendBFI = &hIvasRend->splitRendBFI; +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + ctx.pSplitRenderConfig = &hIvasRend->splitRenderConfig; +#endif + + return ctx; +} + + +static ivas_error getRendInputNumChannels( + const void *rendInput, + int16_t *numInChannels ) +{ + /* Using a void pointer for this function to be reusable for any input type (input_ism, input_mc, input_sba). + Assumptions: - input_base is always the first member in the input struct */ + (void) rendInput; + + *numInChannels = 2; + + return IVAS_ERR_OK; +} + + +static ivas_error updateSplitPostRendPanGains( + input_split_post_rend *inputSplitPostRend, + const AUDIO_CONFIG outConfig, + ISAR_SPLIT_REND_CONFIG_DATA *hRendCfg +#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS + , + int16_t num_subframes +#endif +) +{ + ivas_error error; + rendering_context rendCtx; + LC3PLUS_CONFIG config; + int16_t iNumBlocksPerFrame, iNumLCLDIterationsPerFrame; + + (void) outConfig; + + rendCtx = inputSplitPostRend->base.ctx; + isar_renderSplitGetMultiBinPoseData( hRendCfg, &inputSplitPostRend->splitPostRendWrapper.multiBinPoseData, rendCtx.pHeadRotData->sr_pose_pred_axis ); + +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + config.high_res_mode_enabled = ( hRendCfg->lc3plus_highres != 0 ); +#endif + config.lc3plus_frame_duration_us = hRendCfg->codec_frame_size_ms * 1000; +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + config.isar_frame_duration_us = hRendCfg->isar_frame_size_ms * 1000; +#else + if ( num_subframes != MAX_PARAM_SPATIAL_SUBFRAMES ) + { + if ( hRendCfg->codec == ISAR_SPLIT_REND_CODEC_LC3PLUS ) + { + config.isar_frame_duration_us = ( hRendCfg->poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE ) ? config.lc3plus_frame_duration_us * num_subframes : 20000; + } + else + { + config.isar_frame_duration_us = ( hRendCfg->poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE ) ? config.lc3plus_frame_duration_us : 20000; + } + iNumLCLDIterationsPerFrame = 1; + } + else + { + config.isar_frame_duration_us = 20000; + } +#endif + + if ( hRendCfg->codec_frame_size_ms > 0 ) + { + iNumLCLDIterationsPerFrame = (int16_t) config.isar_frame_duration_us / ( 1000 * hRendCfg->codec_frame_size_ms ); + iNumLCLDIterationsPerFrame = max( 1, iNumLCLDIterationsPerFrame ); + iNumBlocksPerFrame = CLDFB_NO_COL_MAX * hRendCfg->codec_frame_size_ms / 20; + } + else + { + iNumLCLDIterationsPerFrame = 1; + iNumBlocksPerFrame = CLDFB_NO_COL_MAX; + } + + config.channels = BINAURAL_CHANNELS; + config.samplerate = *inputSplitPostRend->base.ctx.pOutSampleRate; + + if ( hRendCfg->codec == ISAR_SPLIT_REND_CODEC_LCLD ) + { + if ( ( error = isar_splitBinLCLDDecOpen( &inputSplitPostRend->splitPostRendWrapper.hSplitBinLCLDDec, *inputSplitPostRend->base.ctx.pOutSampleRate, BINAURAL_CHANNELS, iNumBlocksPerFrame, iNumLCLDIterationsPerFrame ) ) != IVAS_ERR_OK ) + { + return error; + } + } + else if ( hRendCfg->codec == ISAR_SPLIT_REND_CODEC_LC3PLUS ) + { + if ( ( error = ISAR_LC3PLUS_DEC_Open( config, + &inputSplitPostRend->splitPostRendWrapper.hLc3plusDec ) ) != IVAS_ERR_OK ) + { + return error; + } + } + + if ( ( error = isar_splitBinPostRendOpen( &inputSplitPostRend->splitPostRendWrapper.hBinHrSplitPostRend, &inputSplitPostRend->splitPostRendWrapper.multiBinPoseData, *rendCtx.pOutSampleRate ) ) != IVAS_ERR_OK ) + { + return error; + } + + return IVAS_ERR_OK; +} + + +static ivas_error setRendInputActiveSplitPostRend( + void *input, + const AUDIO_CONFIG inConfig, + const IVAS_REND_InputId id, + ISAR_SPLIT_REND_CONFIG_DATA *hRendCfg +#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS + , + const int16_t num_subframes +#endif +) +{ + ivas_error error; + rendering_context rendCtx; + AUDIO_CONFIG outConfig; + input_split_post_rend *inputSplitPostRend; + + inputSplitPostRend = (input_split_post_rend *) input; + rendCtx = inputSplitPostRend->base.ctx; + outConfig = *rendCtx.pOutConfig; + + if ( ( error = allocateInputBaseBufferData( &inputSplitPostRend->bufferData, MAX_CLDFB_BIN_BUFFER_LENGTH ) ) != IVAS_ERR_OK ) + { + return error; + } + + initRendInputBase( &inputSplitPostRend->base, inConfig, id, rendCtx, inputSplitPostRend->bufferData, MAX_CLDFB_BIN_BUFFER_LENGTH ); + inputSplitPostRend->numCachedSamples = 0; + + if ( ( error = updateSplitPostRendPanGains( inputSplitPostRend, outConfig, hRendCfg +#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS + , + num_subframes +#endif + ) ) != IVAS_ERR_OK ) + { + return error; + } + + return IVAS_ERR_OK; +} + + +static void clearInputSplitRend( + input_split_post_rend *inputSplitRend ) +{ + rendering_context rendCtx; + + rendCtx = inputSplitRend->base.ctx; + + freeInputBaseBufferData( &inputSplitRend->bufferData ); + + initRendInputBase( &inputSplitRend->base, IVAS_AUDIO_CONFIG_INVALID, 0, rendCtx, NULL, 0 ); + + if ( inputSplitRend->splitPostRendWrapper.hBinHrSplitPostRend != NULL ) + { + isar_splitBinPostRendClose( &inputSplitRend->splitPostRendWrapper.hBinHrSplitPostRend ); + } + + if ( inputSplitRend->splitPostRendWrapper.hSplitBinLCLDDec != NULL ) + { + isar_splitBinLCLDDecClose( &inputSplitRend->splitPostRendWrapper.hSplitBinLCLDDec ); + } + + if ( inputSplitRend->splitPostRendWrapper.hLc3plusDec != NULL ) + { + ISAR_LC3PLUS_DEC_Close( &inputSplitRend->splitPostRendWrapper.hLc3plusDec ); + } + + return; +} + + +/*------------------------------------------------------------------------- + * ISAR_POST_REND_open() + * + * + *------------------------------------------------------------------------*/ + +ivas_error ISAR_POST_REND_open( + ISAR_POST_REND_HANDLE *phIvasRend, /* i/o: Pointer to renderer handle */ + const int32_t outputSampleRate, /* i : output sampling rate */ + const IVAS_AUDIO_CONFIG outConfig, /* i : output audio config */ + const bool asHrtfBinary, /* i : load hrtf binary file */ + const int16_t nonDiegeticPan, /* i : non-diegetic object flag */ + const float nonDiegeticPanGain, /* i : non-diegetic panning gain */ + const int16_t num_subframes /* i : number of subframes */ +) +{ + int16_t i; + ISAR_POST_REND_HANDLE hIvasRend; + ivas_error error; + int16_t numOutChannels; + + (void) asHrtfBinary; + (void) nonDiegeticPan; + (void) nonDiegeticPanGain; + + /* Validate function arguments */ + if ( phIvasRend == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + if ( ( error = validateOutputSampleRate( outputSampleRate, outConfig ) ) != IVAS_ERR_OK ) + { + return error; + } + + *phIvasRend = (ISAR_POST_REND_HANDLE) malloc( sizeof( struct ISAR_POST_REND ) ); + if ( *phIvasRend == NULL ) + { + return IVAS_ERR_FAILED_ALLOC; + } + + hIvasRend = *phIvasRend; + hIvasRend->sampleRateOut = outputSampleRate; + hIvasRend->outputConfig = outConfig; + hIvasRend->hLimiter = NULL; + hIvasRend->num_subframes = 1; +#ifdef DEBUGGING + hIvasRend->numClipping = 0; +#endif + hIvasRend->num_subframes = num_subframes; + + /* Initialize limiter */ + if ( ( error = ISAR_POST_REND_NumOutChannels( hIvasRend, &numOutChannels ) ) != IVAS_ERR_OK ) + { + return error; + } + + if ( ( error = initLimiter( &hIvasRend->hLimiter, numOutChannels, outputSampleRate ) ) != IVAS_ERR_OK ) + { + return error; + } + + /* Initialize headrotation data */ + if ( ( error = initHeadRotation( hIvasRend ) ) != IVAS_ERR_OK ) + { + return error; + } + + /* Initialize inputs */ + + for ( i = 0; i < RENDERER_MAX_BIN_INPUTS; ++i ) + { + initRendInputBase( &hIvasRend->inputsSplitPost[i].base, IVAS_AUDIO_CONFIG_INVALID, 0, getRendCtx( hIvasRend ), NULL, 0 ); + + isar_init_split_post_rend_handles( &hIvasRend->inputsSplitPost[i].splitPostRendWrapper ); + + hIvasRend->splitRendBFI = 0; + hIvasRend->inputsSplitPost[i].bufferData = NULL; + } + + return IVAS_ERR_OK; +} + + +/*-------------------------------------------------------------------* + * ISAR_POST_REND_NumOutChannels() + * + * + *-------------------------------------------------------------------*/ + +ivas_error ISAR_POST_REND_NumOutChannels( + ISAR_POST_REND_CONST_HANDLE hIvasRend, /* i : Renderer handle */ + int16_t *numOutChannels /* o : number of output channels */ +) +{ + /* Validate function arguments */ + if ( hIvasRend == NULL || numOutChannels == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + *numOutChannels = 2; + + return IVAS_ERR_OK; +} + + +static IVAS_REND_InputId makeInputId( + AUDIO_CONFIG config, + const int32_t inputIndex ) +{ + /* Put config type in second byte (from LSB), put index + 1 in first byte + * + * Index is incremented here so that a valid ID can never be 0. */ + return (IVAS_REND_InputId) ( ( ( (uint32_t) isar_getAudioConfigType( config ) ) << 8 ) | ( inputIndex + 1 ) ); +} + + +static ivas_error getInputById( + ISAR_POST_REND_HANDLE hIvasRend, + const IVAS_REND_InputId inputId, + void **ppInput ) +{ + int32_t inputIndex; + IVAS_REND_AudioConfigType configType; + input_base *pInputBase; + + /* Reverse makeInputId() */ + inputIndex = ( inputId & 0xFF ) - 1; + configType = ( inputId & 0xFF00 ) >> 8; + + /* Validate values derived from input ID */ + if ( inputIndex < 0 ) + { + return IVAS_ERR_INVALID_INPUT_ID; + } + switch ( configType ) + { + case ISAR_POST_REND_AUDIO_CONFIG_TYPE_BINAURAL: + if ( inputIndex > RENDERER_MAX_BIN_INPUTS ) + { + return IVAS_ERR_INVALID_INPUT_ID; + } + pInputBase = &hIvasRend->inputsSplitPost[inputIndex].base; + break; + default: + return IVAS_ERR_INVALID_INPUT_ID; + } + + /* Ensure input ID matches and that input is active */ + if ( pInputBase->id != inputId || pInputBase->inConfig == IVAS_AUDIO_CONFIG_INVALID ) + { + return IVAS_ERR_INVALID_INPUT_ID; + } + + /* Validation done, set value via output parameter */ + *ppInput = pInputBase; + + return IVAS_ERR_OK; +} + +/*-------------------------------------------------------------------* + * ISAR_POST_REND_SetInputGain() + * + * + *-------------------------------------------------------------------*/ + +ivas_error ISAR_POST_REND_SetInputGain( + ISAR_POST_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + const ISAR_POST_REND_InputId inputId, /* i : ID of the input */ + const float gain /* i : linear gain (not in dB) */ +) +{ + input_base *inputBase; + ivas_error error; + + /* Validate function arguments */ + if ( hIvasRend == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + if ( ( error = getInputById( hIvasRend, inputId, (void **) &inputBase ) ) != IVAS_ERR_OK ) + { + printf( "Hoo\n" ); + return error; + } + + inputBase->gain = gain; + + return IVAS_ERR_OK; +} + +static ivas_error getConstInputById( + ISAR_POST_REND_CONST_HANDLE hIvasRend, + const ISAR_POST_REND_InputId inputId, + const void **ppInput ) +{ + int32_t inputIndex; + IVAS_REND_AudioConfigType configType; + const input_base *pInputBase; + + /* Reverse makeInputId() */ + inputIndex = ( inputId & 0xFF ) - 1; + configType = ( inputId & 0xFF00 ) >> 8; + + /* Validate values derived from input ID */ + if ( inputIndex < 0 ) + { + return IVAS_ERR_INVALID_INPUT_ID; + } + switch ( configType ) + { + case ISAR_POST_REND_AUDIO_CONFIG_TYPE_BINAURAL: + if ( inputIndex > RENDERER_MAX_BIN_INPUTS ) + { + return IVAS_ERR_INVALID_INPUT_ID; + } + pInputBase = &hIvasRend->inputsSplitPost[inputIndex].base; + break; + default: + return IVAS_ERR_INVALID_INPUT_ID; + } + + /* Ensure input ID matches and that input is active */ + if ( pInputBase->id != inputId || pInputBase->inConfig == IVAS_AUDIO_CONFIG_INVALID ) + { + return IVAS_ERR_INVALID_INPUT_ID; + } + + /* Validation done, set value via output parameter */ + *ppInput = pInputBase; + + return IVAS_ERR_OK; +} + + +static ivas_error findFreeInputSlot( + const void *inputs, + const int32_t inputStructSize, + const int32_t maxInputs, + int32_t *inputIndex ) +{ + /* Using a void pointer and a separately provided size is a hack for this function + to be reusable for arrays of any input type (input_ism, input_mc, input_sba, input_masa). + Assumptions: + - input_base is always the first member in the input struct + - provided size is correct + */ + + int32_t i; + bool canAddInput; + const uint8_t *pByte; + const input_base *pInputBase; + + canAddInput = false; + + /* Find first unused input in array */ + for ( i = 0, pByte = inputs; i < maxInputs; ++i, pByte += inputStructSize ) + { + pInputBase = (const input_base *) pByte; + + if ( pInputBase->inConfig == IVAS_AUDIO_CONFIG_INVALID ) + { + *inputIndex = i; + canAddInput = true; + break; + } + } + + if ( !canAddInput ) + { + return IVAS_ERR_TOO_MANY_INPUTS; + } + + return IVAS_ERR_OK; +} + + +/*-------------------------------------------------------------------* + * ISAR_POST_REND_AddInput() + * + * + *-------------------------------------------------------------------*/ + +ivas_error ISAR_POST_REND_AddInput( + ISAR_POST_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + const IVAS_AUDIO_CONFIG inConfig, /* i : audio config for a new input */ + ISAR_POST_REND_InputId *inputId /* o : ID of the new input */ +) +{ + ivas_error error; + int32_t maxNumInputsOfType; + void *inputsArray; + int32_t inputStructSize; + ivas_error ( *activateInput )( void *, AUDIO_CONFIG, IVAS_REND_InputId, ISAR_SPLIT_REND_CONFIG_DATA * +#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS + , + int16_t +#endif + ); + int32_t inputIndex; + + /* Validate function arguments */ + if ( hIvasRend == NULL || inputId == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + switch ( isar_getAudioConfigType( inConfig ) ) + { + case ISAR_POST_REND_AUDIO_CONFIG_TYPE_BINAURAL: + maxNumInputsOfType = RENDERER_MAX_BIN_INPUTS; + inputsArray = hIvasRend->inputsSplitPost; + inputStructSize = sizeof( *hIvasRend->inputsSplitPost ); + activateInput = setRendInputActiveSplitPostRend; + break; + default: + return IVAS_ERR_INVALID_INPUT_FORMAT; + } + + /* Find first free input in array corresponding to input type */ + if ( ( error = findFreeInputSlot( inputsArray, inputStructSize, maxNumInputsOfType, &inputIndex ) ) != IVAS_ERR_OK ) + { + return error; + } + + *inputId = makeInputId( inConfig, inputIndex ); + if ( ( error = activateInput( (uint8_t *) inputsArray + inputStructSize * inputIndex, inConfig, *inputId, &hIvasRend->splitRenderConfig +#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS + , + hIvasRend->num_subframes +#endif + ) ) != IVAS_ERR_OK ) + { + return error; + } + + return IVAS_ERR_OK; +} + + +/*-------------------------------------------------------------------* + * ISAR_POST_REND_GetInputNumChannels() + * + * + *-------------------------------------------------------------------*/ + +ivas_error ISAR_POST_REND_GetInputNumChannels( + ISAR_POST_REND_CONST_HANDLE hIvasRend, /* i : Renderer handle */ + const ISAR_POST_REND_InputId inputId, /* i : ID of the input */ + int16_t *numChannels /* o : number of channels of the input */ +) +{ + ivas_error error; + const input_base *pInput; + + /* Validate function arguments */ + if ( hIvasRend == NULL || numChannels == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + if ( ( error = getConstInputById( hIvasRend, inputId, (const void **) &pInput ) ) != IVAS_ERR_OK ) + { + return error; + } + + if ( ( error = getRendInputNumChannels( pInput, numChannels ) ) != IVAS_ERR_OK ) + { + return error; + } + + return IVAS_ERR_OK; +} + + +/*-------------------------------------------------------------------* + * ISAR_POST_REND_GetDelay() + * + * + *-------------------------------------------------------------------*/ + +ivas_error ISAR_POST_REND_GetDelay( + ISAR_POST_REND_CONST_HANDLE hIvasRend, /* i : Renderer state */ + int16_t *nSamples, /* o : Renderer delay in samples */ + int32_t *timeScale /* o : Time scale of the delay, equal to renderer output sampling rate */ +) +{ + int16_t i; + int32_t latency_ns; + int32_t max_latency_ns; + + /* Validate function arguments */ + if ( hIvasRend == NULL || nSamples == NULL || timeScale == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + *timeScale = hIvasRend->sampleRateOut; + *nSamples = 0; + max_latency_ns = 0; + + /* Compute the maximum delay across all inputs */ + for ( i = 0; i < RENDERER_MAX_BIN_INPUTS; i++ ) + { + if ( hIvasRend->inputsSplitPost[i].base.inConfig != IVAS_AUDIO_CONFIG_INVALID ) + { + latency_ns = 0; + if ( hIvasRend->inputsSplitPost[i].splitPostRendWrapper.hLc3plusDec != NULL ) + { + int32_t lc3plusDelaySamples; + ISAR_LC3PLUS_DEC_GetDelay( hIvasRend->inputsSplitPost[i].splitPostRendWrapper.hLc3plusDec, &lc3plusDelaySamples ); + latency_ns = (int32_t) roundf( lc3plusDelaySamples * 1000000000.f / *timeScale ); + } + if ( hIvasRend->inputsSplitPost[i].splitPostRendWrapper.multiBinPoseData.poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) + { + latency_ns += IVAS_FB_DEC_DELAY_NS; + } + else if ( hIvasRend->inputsSplitPost[i].splitPostRendWrapper.hSplitBinLCLDDec != NULL ) + { + latency_ns += IVAS_FB_DEC_DELAY_NS; + } + max_latency_ns = max( max_latency_ns, latency_ns ); + } + } + + *nSamples = (int16_t) roundf( (float) max_latency_ns * *timeScale / 1000000000.f ); + + return IVAS_ERR_OK; +} + + +/*-------------------------------------------------------------------* + * ISAR_POST_REND_FeedInputAudio() + * + * + *-------------------------------------------------------------------*/ + +ivas_error ISAR_POST_REND_FeedInputAudio( + ISAR_POST_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + const ISAR_POST_REND_InputId inputId, /* i : ID of the input */ + const ISAR_POST_REND_ReadOnlyAudioBuffer inputAudio /* i : buffer with input audio */ +) +{ + ivas_error error; + input_base *inputBase; + int16_t numInputChannels; + int16_t cldfb2tdSampleFact; + + /* Validate function arguments */ + if ( hIvasRend == NULL || inputAudio.data == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + cldfb2tdSampleFact = ( inputAudio.config.is_cldfb ) ? 2 : 1; + + if ( inputAudio.config.numSamplesPerChannel <= 0 || ( MAX_BUFFER_LENGTH_PER_CHANNEL < inputAudio.config.numSamplesPerChannel && inputAudio.config.is_cldfb == 0 ) || + ( ( MAX_BUFFER_LENGTH_PER_CHANNEL * cldfb2tdSampleFact ) < inputAudio.config.numSamplesPerChannel && inputAudio.config.is_cldfb == 1 ) ) + { + return IVAS_ERROR( IVAS_ERR_INVALID_BUFFER_SIZE, "Buffer size outside of supported range" ); + } + + if ( inputAudio.config.numChannels <= 0 || MAX_INPUT_CHANNELS < inputAudio.config.numChannels ) + { + return IVAS_ERR_WRONG_NUM_CHANNELS; + } + + if ( isar_getAudioConfigType( hIvasRend->outputConfig ) == ISAR_POST_REND_AUDIO_CONFIG_TYPE_BINAURAL && + hIvasRend->outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && + hIvasRend->outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM && + ( inputAudio.config.numSamplesPerChannel * 1000 / cldfb2tdSampleFact ) != ( BINAURAL_RENDERING_FRAME_SIZE_MS * hIvasRend->num_subframes ) * hIvasRend->sampleRateOut ) + { + return IVAS_ERROR( IVAS_ERR_INVALID_BUFFER_SIZE, "Binaural rendering requires specific frame size" ); + } + + if ( ( error = getInputById( hIvasRend, inputId, (void **) &inputBase ) ) != IVAS_ERR_OK ) + { + printf( "Foo\n" ); + return error; + } + + if ( ( error = getRendInputNumChannels( inputBase, &numInputChannels ) ) != IVAS_ERR_OK ) + { + return error; + } + + if ( numInputChannels != inputAudio.config.numChannels ) + { + return IVAS_ERR_WRONG_NUM_CHANNELS; + } + + inputBase->inputBuffer.config = inputAudio.config; + + mvr2r( inputAudio.data, inputBase->inputBuffer.data, inputAudio.config.numSamplesPerChannel * inputAudio.config.numChannels ); + + inputBase->numNewSamplesPerChannel = inputAudio.config.numSamplesPerChannel / cldfb2tdSampleFact; + + return IVAS_ERR_OK; +} + + +/*-------------------------------------------------------------------* + * ISAR_POST_REND_InitConfig() + * + * + *-------------------------------------------------------------------*/ + +ivas_error ISAR_POST_REND_InitConfig( + ISAR_POST_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + const AUDIO_CONFIG outAudioConfig /* i : output audioConfig */ +) +{ + bool rendererConfigEnabled; + + rendererConfigEnabled = ( isar_getAudioConfigType( outAudioConfig ) == ISAR_POST_REND_AUDIO_CONFIG_TYPE_BINAURAL ); + + if ( rendererConfigEnabled ) + { + hIvasRend->rendererConfigEnabled = 1; + } + else + { + hIvasRend->rendererConfigEnabled = 0; + } + + if ( rendererConfigEnabled ) + { + hIvasRend->splitRenderConfig.splitRendBitRate = SPLIT_REND_768k; + hIvasRend->splitRenderConfig.dof = 3; + hIvasRend->splitRenderConfig.hq_mode = 0; + hIvasRend->splitRenderConfig.codec_delay_ms = 0; + hIvasRend->splitRenderConfig.codec_frame_size_ms = 0; /* 0 means "use default for selected codec" */ +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + hIvasRend->splitRenderConfig.isar_frame_size_ms = 0; /* 0 means "use default for selected codec" */ +#endif + hIvasRend->splitRenderConfig.codec = ISAR_SPLIT_REND_CODEC_DEFAULT; + hIvasRend->splitRenderConfig.poseCorrectionMode = ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB; + hIvasRend->splitRenderConfig.rendererSelection = ISAR_SPLIT_REND_RENDERER_SELECTION_DEFAULT; + } + + return IVAS_ERR_OK; +} + + +/*-------------------------------------------------------------------* + * ISAR_POST_REND_GetRenderConfig() + * + * + *-------------------------------------------------------------------*/ + +int16_t ISAR_POST_REND_GetRenderConfig( + ISAR_POST_REND_HANDLE hIvasRend, /* i/o: IVAS decoder handle */ + const ISAR_SPLIT_REND_CONFIG_HANDLE splitRenderConfig /* o : Render configuration handle */ +) +{ + ISAR_SPLIT_REND_CONFIG_DATA hRCin; + + if ( hIvasRend == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + hRCin = hIvasRend->splitRenderConfig; + + splitRenderConfig->splitRendBitRate = SPLIT_REND_768k; + splitRenderConfig->dof = 3; + splitRenderConfig->hq_mode = 0; + splitRenderConfig->codec_delay_ms = 0; + splitRenderConfig->codec_frame_size_ms = 0; /* 0 means "use default for selected codec" */ +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + splitRenderConfig->isar_frame_size_ms = 0; /* 0 means "use default for selected codec" */ +#endif + splitRenderConfig->codec = ISAR_SPLIT_REND_CODEC_DEFAULT; + splitRenderConfig->poseCorrectionMode = ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB; + splitRenderConfig->rendererSelection = hRCin.rendererSelection; + + return IVAS_ERR_OK; +} + +/*-------------------------------------------------------------------* + * ISAR_POST_REND_FeedSplitBinauralBitstream() + * + * + *-------------------------------------------------------------------*/ + +ivas_error ISAR_POST_REND_FeedSplitBinauralBitstream( + ISAR_POST_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + const IVAS_REND_InputId inputId, /* i : ID of the input */ + ISAR_POST_REND_BitstreamBuffer *hBits /* i : buffer for input bitstream */ +) +{ + ivas_error error; + input_base *inputBase; + input_split_post_rend *inputSplitPostRend; + + /* Validate function arguments */ + if ( hIvasRend == NULL || hBits == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + if ( ( error = getInputById( hIvasRend, inputId, (void **) &inputBase ) ) != IVAS_ERR_OK ) + { + printf( "Goo\n" ); + return error; + } + + inputSplitPostRend = (input_split_post_rend *) inputBase; + inputSplitPostRend->hBits = hBits; + + return IVAS_ERR_OK; +} + + +/*-------------------------------------------------------------------* + * ISAR_POST_REND_SetHeadRotation() + * + * + *-------------------------------------------------------------------*/ + +ivas_error ISAR_POST_REND_SetHeadRotation( + ISAR_POST_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + const IVAS_QUATERNION headRot, /* i : head orientations for next rendering call */ + const IVAS_VECTOR3 Pos, /* i : listener positions for next rendering call */ + const ISAR_SPLIT_REND_ROT_AXIS rot_axis, /* i : external control for rotation axis for split rendering */ + const int16_t sf_idx /* i : subframe index */ +) +{ + IVAS_QUATERNION rotQuat; + + /* Validate function arguments */ + if ( hIvasRend == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + if ( isar_getAudioConfigType( hIvasRend->outputConfig ) != ISAR_POST_REND_AUDIO_CONFIG_TYPE_BINAURAL ) + { + /* Head rotation can be set only with binaural output */ + return IVAS_ERR_INVALID_OUTPUT_FORMAT; + } + + hIvasRend->headRotData.headRotEnabled = 1; + + /* check for Euler angle signaling */ + if ( headRot.w == -3.0f ) + { + Euler2Quat( deg2rad( headRot.x ), deg2rad( headRot.y ), deg2rad( headRot.z ), &rotQuat ); + } + else + { + rotQuat = headRot; + } + + hIvasRend->headRotData.headPositions[sf_idx] = rotQuat; + hIvasRend->headRotData.Pos[sf_idx] = Pos; + hIvasRend->headRotData.sr_pose_pred_axis = rot_axis; + + return IVAS_ERR_OK; +} + + +/*-------------------------------------------------------------------* + * ISAR_POST_REND_SetSplitRendBFI() + * + * + *-------------------------------------------------------------------*/ + +ivas_error ISAR_POST_REND_SetSplitRendBFI( + ISAR_POST_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + const int16_t bfi /* i: BFI flag */ +) +{ + hIvasRend->splitRendBFI = bfi; + + return IVAS_ERR_OK; +} + + +/*-------------------------------------------------------------------* + * Local functions + *-------------------------------------------------------------------*/ + + +static ivas_error splitBinLc3plusDecode( + ISAR_SPLIT_POST_REND_WRAPPER *hSplitBin, + ISAR_SPLIT_REND_BITS_HANDLE bits, + float outputBuffer[BINAURAL_CHANNELS][L_FRAME48k], +#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS + ISAR_SPLIT_REND_POSE_CORRECTION_MODE pose_correction, +#endif + const int16_t SplitRendBFI ) +{ + ivas_error error; + float *channel_ptrs[MAX_HEAD_ROT_POSES * 2]; +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + int32_t lc3plusBitstreamSize; +#else + int32_t lc3plusBitrateId, lc3plusBitstreamSize; +#endif + + push_wmops( "splitBinLc3plusDecode" ); + assert( hSplitBin->hLc3plusDec != NULL ); + + for ( int16_t i = 0; i < BINAURAL_CHANNELS * hSplitBin->multiBinPoseData.num_poses; ++i ) + { + channel_ptrs[i] = outputBuffer[i]; + } + + if ( SplitRendBFI == 0 ) + { + /* Find next byte boundary */ + while ( bits->bits_read % 8 != 0 ) + { + ++bits->bits_read; + } +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + /* Size is in bytes */ + assert( ( bits->bits_written - bits->bits_read ) % 8 == 0 ); + lc3plusBitstreamSize = ( bits->bits_written - bits->bits_read ) / 8; +#else + /* Read LC3plus bitstream size info */ + lc3plusBitrateId = ISAR_SPLIT_REND_BITStream_read_int32( bits, 8 ); + lc3plusBitstreamSize = isar_get_lc3plus_size_from_id( (int8_t) lc3plusBitrateId, pose_correction, (int16_t) ( hSplitBin->hLc3plusDec->config.isar_frame_duration_us / 1000 ) ); +#endif + + if ( ( error = ISAR_LC3PLUS_DEC_Decode( hSplitBin->hLc3plusDec, &bits->bits_buf[bits->bits_read / 8], lc3plusBitstreamSize, channel_ptrs ) ) != IVAS_ERR_OK ) + { + return error; + } + } + else + { + if ( ( error = ISAR_LC3PLUS_DEC_Conceal( hSplitBin->hLc3plusDec, channel_ptrs ) ) != IVAS_ERR_OK ) + { + return error; + } + } + + pop_wmops(); + return IVAS_ERR_OK; +} + + +static ivas_error renderSplitBinauralWithPostRot( + input_split_post_rend *splitBinInput, + IVAS_REND_AudioBuffer outAudio, + const int16_t SplitRendBFI, + const int16_t num_subframes ) +{ + float Cldfb_RealBuffer_Binaural[BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + float Cldfb_ImagBuffer_Binaural[BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + ivas_error error; + float Cldfb_RealBuffer_Binaural_5ms[MAX_PARAM_SPATIAL_SUBFRAMES][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; + float Cldfb_ImagBuffer_Binaural_5ms[MAX_PARAM_SPATIAL_SUBFRAMES][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; + IVAS_QUATERNION QuaternionsPost[MAX_PARAM_SPATIAL_SUBFRAMES]; + int16_t sf_idx, ch_idx; + ISAR_SPLIT_REND_BITS_DATA bits; + float tmpCrendBuffer[BINAURAL_CHANNELS][L_FRAME48k]; + float tmpCrendBuffer_sf[BINAURAL_CHANNELS][L_FRAME48k]; + ISAR_SPLIT_POST_REND_WRAPPER *hSplitBin; + int8_t isPostRendInputCldfb; + int16_t chnlIdx, slotIdx, smplIdx; + int16_t preRendFrameSize_ms; + int16_t outBufNumSamplesPerChannel, outBufNumColPerChannel; + int16_t numSamplesPerChannelCacheSize, numColPerChannelCacheSize; + float *readPtr, *writePtr; +#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS + uint32_t ivas_frame_duration_us; +#endif + int16_t iNumBlocksPerFrame, iNumLCLDIterationsPerFrame; + const ISAR_POST_REND_HeadRotData *pHeadRotData; + + isPostRendInputCldfb = 0; + push_wmops( "renderSplitBinauralWithPostRot" ); + error = IVAS_ERR_OK; + +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + if ( outAudio.config.numSamplesPerChannel / *splitBinInput->base.ctx.pOutSampleRate > splitBinInput->hBits->config.isar_frame_size_ms ) + { + return IVAS_ERR_INTERNAL_FATAL; + } +#endif + + pHeadRotData = splitBinInput->base.ctx.pHeadRotData; + hSplitBin = &splitBinInput->splitPostRendWrapper; + convertBitsBufferToInternalBitsBuff( *splitBinInput->hBits, &bits ); + +#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS + ivas_frame_duration_us = 20000; + if ( splitBinInput->splitPostRendWrapper.hLc3plusDec != NULL ) + { + ivas_frame_duration_us = splitBinInput->splitPostRendWrapper.hLc3plusDec->config.isar_frame_duration_us; + } +#endif + + iNumLCLDIterationsPerFrame = 1; + iNumBlocksPerFrame = CLDFB_NO_COL_MAX; + if ( splitBinInput->splitPostRendWrapper.hSplitBinLCLDDec != NULL ) + { + iNumBlocksPerFrame = splitBinInput->splitPostRendWrapper.hSplitBinLCLDDec->iNumBlocks; + iNumLCLDIterationsPerFrame = splitBinInput->splitPostRendWrapper.hSplitBinLCLDDec->iNumIterations; + } + + outBufNumSamplesPerChannel = outAudio.config.numSamplesPerChannel / num_subframes; + for ( sf_idx = 0; sf_idx < num_subframes; sf_idx++ ) + { + QuaternionsPost[sf_idx] = pHeadRotData->headPositions[sf_idx]; + } + + if ( !SplitRendBFI ) + { + hSplitBin->first_good_frame_received = 1; + } + + if ( hSplitBin->first_good_frame_received == 1 ) + { + if ( bits.pose_correction == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) + { + if ( !SplitRendBFI ) + { +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG + isar_splitBinPostRendMdDec( &bits, hSplitBin->hBinHrSplitPostRend, &hSplitBin->multiBinPoseData, hSplitBin->hBinHrSplitPreRend ); +#else + isar_splitBinPostRendMdDec( &bits, hSplitBin->hBinHrSplitPostRend, &hSplitBin->multiBinPoseData ); +#endif + } + } + + /*copy pose correction after MD is parsed*/ + hSplitBin->multiBinPoseData.poseCorrectionMode = bits.pose_correction; + + /* decode audio */ + if ( splitBinInput->base.inConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) + { + if ( bits.codec == ISAR_SPLIT_REND_CODEC_LCLD ) + { + isPostRendInputCldfb = 1; + } +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + numSamplesPerChannelCacheSize = (int16_t) ( *splitBinInput->base.ctx.pOutSampleRate * bits.isar_frame_size_ms / 1000 ) - outBufNumSamplesPerChannel; +#else + preRendFrameSize_ms = (int16_t) ( ivas_frame_duration_us ) / 1000; + + numSamplesPerChannelCacheSize = (int16_t) ( *splitBinInput->base.ctx.pOutSampleRate * ( preRendFrameSize_ms - bits.codec_frame_size_ms ) / 1000 ); +#endif + + outBufNumColPerChannel = MAX_PARAM_SPATIAL_SUBFRAMES; + numColPerChannelCacheSize = ( iNumBlocksPerFrame * iNumLCLDIterationsPerFrame ) - outBufNumColPerChannel; + + for ( sf_idx = 0; sf_idx < num_subframes; sf_idx++ ) + { + if ( splitBinInput->numCachedSamples == 0 ) + { + if ( bits.codec == ISAR_SPLIT_REND_CODEC_LCLD ) + { + isar_splitBinLCLDDecProcess( hSplitBin->hSplitBinLCLDDec, &bits, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, SplitRendBFI ); + + /* copy data over to 5ms buffer */ + for ( chnlIdx = 0; chnlIdx < BINAURAL_CHANNELS; ++chnlIdx ) + { + for ( slotIdx = 0; slotIdx < CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES; ++slotIdx ) + { + mvr2r( Cldfb_RealBuffer_Binaural[chnlIdx][slotIdx], Cldfb_RealBuffer_Binaural_5ms[sf_idx][chnlIdx][slotIdx], CLDFB_NO_CHANNELS_MAX ); + mvr2r( Cldfb_ImagBuffer_Binaural[chnlIdx][slotIdx], Cldfb_ImagBuffer_Binaural_5ms[sf_idx][chnlIdx][slotIdx], CLDFB_NO_CHANNELS_MAX ); + } + } + + /* cache the remaining 15ms */ + splitBinInput->numCachedSamples = numColPerChannelCacheSize; + writePtr = splitBinInput->bufferData; + for ( slotIdx = CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES; slotIdx < ( iNumBlocksPerFrame * iNumLCLDIterationsPerFrame ); ++slotIdx ) + { + for ( chnlIdx = 0; chnlIdx < BINAURAL_CHANNELS; ++chnlIdx ) + { + for ( smplIdx = 0; smplIdx < CLDFB_NO_CHANNELS_MAX; ++smplIdx ) + { + *writePtr++ = Cldfb_RealBuffer_Binaural[chnlIdx][slotIdx][smplIdx]; + } + for ( smplIdx = 0; smplIdx < CLDFB_NO_CHANNELS_MAX; ++smplIdx ) + { + *writePtr++ = Cldfb_ImagBuffer_Binaural[chnlIdx][slotIdx][smplIdx]; + } + } + } + } + else + { + if ( ( error = splitBinLc3plusDecode( hSplitBin, &bits, tmpCrendBuffer, +#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS + bits.pose_correction, +#endif + SplitRendBFI ) ) != IVAS_ERR_OK ) + { + return error; + } + + /* cache the remaining decoded audio */ + splitBinInput->numCachedSamples = numSamplesPerChannelCacheSize; + mvr2r( &tmpCrendBuffer[0][outBufNumSamplesPerChannel], splitBinInput->bufferData, numSamplesPerChannelCacheSize ); + mvr2r( &tmpCrendBuffer[1][outBufNumSamplesPerChannel], splitBinInput->bufferData + numSamplesPerChannelCacheSize, numSamplesPerChannelCacheSize ); + } + } + else + { + /* copy from cache */ + if ( bits.codec == ISAR_SPLIT_REND_CODEC_LCLD ) + { + int16_t readOffset = ( numColPerChannelCacheSize - splitBinInput->numCachedSamples ); + readPtr = splitBinInput->bufferData; + isPostRendInputCldfb = 1; + + readPtr += 2 * readOffset * CLDFB_NO_CHANNELS_MAX * BINAURAL_CHANNELS; + for ( slotIdx = 0; slotIdx < CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES; ++slotIdx ) + { + for ( chnlIdx = 0; chnlIdx < BINAURAL_CHANNELS; ++chnlIdx ) + { + for ( smplIdx = 0; smplIdx < CLDFB_NO_CHANNELS_MAX; ++smplIdx ) + { + Cldfb_RealBuffer_Binaural_5ms[sf_idx][chnlIdx][slotIdx][smplIdx] = *readPtr++; + } + for ( smplIdx = 0; smplIdx < CLDFB_NO_CHANNELS_MAX; ++smplIdx ) + { + Cldfb_ImagBuffer_Binaural_5ms[sf_idx][chnlIdx][slotIdx][smplIdx] = *readPtr++; + } + } + } + + splitBinInput->numCachedSamples -= outBufNumColPerChannel; + } + else + { + int16_t readOffset = numSamplesPerChannelCacheSize - splitBinInput->numCachedSamples; + mvr2r( splitBinInput->bufferData + readOffset, &tmpCrendBuffer[0][sf_idx * outBufNumSamplesPerChannel], outBufNumSamplesPerChannel ); + mvr2r( splitBinInput->bufferData + readOffset + numSamplesPerChannelCacheSize, &tmpCrendBuffer[1][sf_idx * outBufNumSamplesPerChannel], outBufNumSamplesPerChannel ); + splitBinInput->numCachedSamples -= outBufNumSamplesPerChannel; + } + } + } + } + else + { + copyBufferTo2dArray( splitBinInput->base.inputBuffer, tmpCrendBuffer ); + if ( splitBinInput->numCachedSamples == 0 ) + { +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + preRendFrameSize_ms = splitBinInput->base.ctx.pSplitRenderConfig->isar_frame_size_ms; +#else + preRendFrameSize_ms = (int16_t) ( ivas_frame_duration_us ) / 1000; +#endif + numSamplesPerChannelCacheSize = (int16_t) ( *splitBinInput->base.ctx.pOutSampleRate * preRendFrameSize_ms / 1000 ); + numSamplesPerChannelCacheSize -= outAudio.config.numSamplesPerChannel; + splitBinInput->numCachedSamples = numSamplesPerChannelCacheSize; + } + else + { + splitBinInput->numCachedSamples -= outAudio.config.numSamplesPerChannel; + } + } + + /* apply pose correction if enabled */ + for ( sf_idx = 0; sf_idx < num_subframes; sf_idx++ ) + { + if ( bits.pose_correction == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE && isPostRendInputCldfb ) + { + /* 0DOF with LCLD codec requires CLDFB synthesis */ + int16_t slot_idx; + + for ( ch_idx = 0; ch_idx < BINAURAL_CHANNELS; ch_idx++ ) + { + float *RealBuffer[CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES]; + float *ImagBuffer[CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES]; + + for ( slot_idx = 0; slot_idx < CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES; slot_idx++ ) + { + RealBuffer[slot_idx] = Cldfb_RealBuffer_Binaural_5ms[sf_idx][ch_idx][slot_idx]; + ImagBuffer[slot_idx] = Cldfb_ImagBuffer_Binaural_5ms[sf_idx][ch_idx][slot_idx]; + } + + cldfbSynthesis( RealBuffer, + ImagBuffer, + &( tmpCrendBuffer[ch_idx][sf_idx * outBufNumSamplesPerChannel] ), + hSplitBin->hBinHrSplitPostRend->cldfbSyn[0]->no_channels * CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, + hSplitBin->hBinHrSplitPostRend->cldfbSyn[ch_idx] ); + } + } + else if ( bits.pose_correction == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) + { + mvr2r( &tmpCrendBuffer[0][sf_idx * outBufNumSamplesPerChannel], tmpCrendBuffer_sf[0], outBufNumSamplesPerChannel ); + mvr2r( &tmpCrendBuffer[1][sf_idx * outBufNumSamplesPerChannel], tmpCrendBuffer_sf[1], outBufNumSamplesPerChannel ); + + isar_rend_CldfbSplitPostRendProcess( hSplitBin->hBinHrSplitPostRend, &hSplitBin->multiBinPoseData, QuaternionsPost[sf_idx], Cldfb_RealBuffer_Binaural_5ms[sf_idx], Cldfb_ImagBuffer_Binaural_5ms[sf_idx], tmpCrendBuffer_sf, isPostRendInputCldfb ); + + mvr2r( tmpCrendBuffer_sf[0], &tmpCrendBuffer[0][sf_idx * outBufNumSamplesPerChannel], outBufNumSamplesPerChannel ); + mvr2r( tmpCrendBuffer_sf[1], &tmpCrendBuffer[1][sf_idx * outBufNumSamplesPerChannel], outBufNumSamplesPerChannel ); + } + } + } + else + { + if ( splitBinInput->base.inConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) + { + for ( ch_idx = 0; ch_idx < BINAURAL_CHANNELS; ch_idx++ ) + { + set_zero( tmpCrendBuffer[ch_idx], outAudio.config.numSamplesPerChannel ); + } + } + else + { + copyBufferTo2dArray( splitBinInput->base.inputBuffer, tmpCrendBuffer ); + } + } + + convertInternalBitsBuffToBitsBuffer( splitBinInput->hBits, bits ); + accumulate2dArrayToBuffer( tmpCrendBuffer, &outAudio ); + + pop_wmops(); + return error; +} + +static ivas_error renderInputSplitBin( + input_split_post_rend *splitBinInput, + const AUDIO_CONFIG outConfig, + IVAS_REND_AudioBuffer outAudio, + const int16_t SplitRendBFI, + const int16_t num_subframes ) +{ + ivas_error error; + IVAS_REND_AudioBuffer inAudio; + + inAudio = splitBinInput->base.inputBuffer; + + splitBinInput->base.numNewSamplesPerChannel = 0; + + /* Apply input gain to new audio */ + v_multc( inAudio.data, + splitBinInput->base.gain, + inAudio.data, + inAudio.config.numSamplesPerChannel * inAudio.config.numChannels ); + switch ( outConfig ) + { + case IVAS_AUDIO_CONFIG_BINAURAL: + error = renderSplitBinauralWithPostRot( splitBinInput, outAudio, SplitRendBFI, num_subframes ); + break; + default: + return IVAS_ERR_INVALID_OUTPUT_FORMAT; + } + + return error; +} + +static ivas_error renderActiveInputsSplitBin( + ISAR_POST_REND_HANDLE hIvasRend, + IVAS_REND_AudioBuffer outAudio ) +{ + int16_t i; + input_split_post_rend *pCurrentInput; + ivas_error error; + + for ( i = 0, pCurrentInput = hIvasRend->inputsSplitPost; i < RENDERER_MAX_BIN_INPUTS; ++i, ++pCurrentInput ) + { + if ( pCurrentInput->base.inConfig == IVAS_AUDIO_CONFIG_INVALID ) + { + /* Skip inactive inputs */ + continue; + } + + if ( ( error = renderInputSplitBin( pCurrentInput, hIvasRend->outputConfig, outAudio, hIvasRend->splitRendBFI, hIvasRend->num_subframes ) ) != IVAS_ERR_OK ) + { + return error; + } + } + + return IVAS_ERR_OK; +} + + +/*-------------------------------------------------------------------* + * ISAR_POST_REND_getSamples() + * + * + *-------------------------------------------------------------------*/ + +ivas_error ISAR_POST_REND_getSamples( + ISAR_POST_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + IVAS_REND_AudioBuffer outAudio /* i/o: buffer for output audio */ +) +{ + ivas_error error; + int16_t numOutChannels; + int16_t cldfb2tdSampleFact; + + /* Validate function arguments */ + if ( hIvasRend == NULL || outAudio.data == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + cldfb2tdSampleFact = ( outAudio.config.is_cldfb ) ? 2 : 1; + + if ( outAudio.config.numSamplesPerChannel <= 0 || ( MAX_BUFFER_LENGTH_PER_CHANNEL < outAudio.config.numSamplesPerChannel && outAudio.config.is_cldfb == 0 ) || + ( ( MAX_BUFFER_LENGTH_PER_CHANNEL * cldfb2tdSampleFact ) < outAudio.config.numSamplesPerChannel && outAudio.config.is_cldfb == 1 ) ) + { + return IVAS_ERR_INVALID_BUFFER_SIZE; + } + + if ( outAudio.config.numChannels <= 0 || MAX_OUTPUT_CHANNELS < outAudio.config.numChannels ) + { + return IVAS_ERR_WRONG_NUM_CHANNELS; + } + + if ( isar_getAudioConfigType( hIvasRend->outputConfig ) == ISAR_POST_REND_AUDIO_CONFIG_TYPE_BINAURAL && + ( outAudio.config.numSamplesPerChannel * 1000 / cldfb2tdSampleFact ) != ( hIvasRend->num_subframes * BINAURAL_RENDERING_FRAME_SIZE_MS ) * hIvasRend->sampleRateOut ) + { + return IVAS_ERROR( IVAS_ERR_INVALID_BUFFER_SIZE, "Binaural rendering requires specific frame size" ); + } + + if ( ( error = ISAR_POST_REND_NumOutChannels( hIvasRend, &numOutChannels ) ) != IVAS_ERR_OK ) + { + return error; + } + + if ( numOutChannels != outAudio.config.numChannels && hIvasRend->outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && hIvasRend->outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + { + return IVAS_ERR_WRONG_NUM_CHANNELS; + } + + /* Clear original output buffer */ + set_zero( outAudio.data, outAudio.config.numChannels * outAudio.config.numSamplesPerChannel ); + + if ( ( error = renderActiveInputsSplitBin( hIvasRend, outAudio ) ) != IVAS_ERR_OK ) + { + return error; + } + +#ifndef DISABLE_LIMITER +#ifdef DEBUGGING + hIvasRend->numClipping += +#endif + limitRendererOutput( hIvasRend->hLimiter, outAudio.data, outAudio.config.numSamplesPerChannel, IVAS_LIMITER_THRESHOLD ); +#endif + + return IVAS_ERR_OK; +} + +/*-------------------------------------------------------------------* + * ISAR_POST_REND_GetSplitBinauralSamples() + * + * + *-------------------------------------------------------------------*/ + +ivas_error ISAR_POST_REND_GetSplitBinauralSamples( + ISAR_POST_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + IVAS_REND_AudioBuffer outAudio, /* i/o: buffer for output audio */ + bool *needNewFrame ) +{ + ivas_error error; + + if ( ( error = ISAR_POST_REND_getSamples( hIvasRend, outAudio ) ) != IVAS_ERR_OK ) + { + return error; + } + *needNewFrame = hIvasRend->inputsSplitPost[0].numCachedSamples == 0; + + return IVAS_ERR_OK; +} + + +/*-------------------------------------------------------------------* + * ISAR_POST_REND_Close() + * + * + *-------------------------------------------------------------------*/ + +void ISAR_POST_REND_Close( + ISAR_POST_REND_HANDLE *phIvasRend /* i/o: Pointer to renderer handle */ +) +{ + uint16_t i; + ISAR_POST_REND_HANDLE hIvasRend; + + /* Validate function arguments */ + if ( phIvasRend == NULL || *phIvasRend == NULL ) + { + return; + } + hIvasRend = *phIvasRend; + + for ( i = 0; i < RENDERER_MAX_BIN_INPUTS; ++i ) + { + clearInputSplitRend( &hIvasRend->inputsSplitPost[i] ); + } + + ivas_limiter_close( &hIvasRend->hLimiter ); + + free( hIvasRend ); + *phIvasRend = NULL; + + return; +} + + +ivas_error ISAR_REND_SetSplitRendBitstreamHeader( + ISAR_POST_REND_HANDLE hIvasRend, /* i/o: IVAS renderer handle */ + const ISAR_SPLIT_REND_CODEC codec, /* o: codec setting */ + const ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrection, /* o: pose correction mode */ + const int16_t codec_frame_size_ms /* i: codec frame size setting */ +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + , + const int16_t isar_frame_size_ms, /* i: isar codec frame size setting */ + const int16_t lc3plus_highres /* i: LC3plus Hig-Res setting. Ignored if codec is not LC3plus */ +#endif +) +{ + if ( hIvasRend == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + hIvasRend->splitRenderConfig.codec = codec; +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + hIvasRend->splitRenderConfig.isar_frame_size_ms = isar_frame_size_ms; +#endif + hIvasRend->splitRenderConfig.codec_frame_size_ms = codec_frame_size_ms; + hIvasRend->splitRenderConfig.poseCorrectionMode = poseCorrection; +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + hIvasRend->splitRenderConfig.lc3plus_highres = lc3plus_highres; +#endif + return IVAS_ERR_OK; +} + +#ifdef DEBUGGING +/*-------------------------------------------------------------------* + * ISAR_POST_REND_GetNoCLipping() + * + * + *-------------------------------------------------------------------*/ + +int32_t ISAR_POST_REND_GetNoCLipping( + ISAR_POST_REND_HANDLE hIvasRend ) +{ + return hIvasRend->numClipping; +} + +int32_t ISAR_POST_REND_GetCntFramesLimited( + ISAR_POST_REND_CONST_HANDLE hIvasRend ) +{ + if ( hIvasRend->hLimiter == NULL ) + { + return 0; + } + + return hIvasRend->hLimiter->cnt_frames_limited; +} +#endif + + +#endif diff --git a/lib_isar/lib_isar_post_rend.h b/lib_isar/lib_isar_post_rend.h new file mode 100644 index 0000000000000000000000000000000000000000..992b23704c586d9cad3711ef8b6ac0f61ec02510 --- /dev/null +++ b/lib_isar/lib_isar_post_rend.h @@ -0,0 +1,231 @@ +/****************************************************************************************************** + + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#ifndef LIB_ISAR_POST_REND_H +#define LIB_ISAR_POST_REND_H + +#include +#include "common_api_types.h" + + +#ifndef SPLIT_REND_WITH_HEAD_ROT + +int32_t ISAR_POST_REND_void_func( void ); + +#else + +/*---------------------------------------------------------------------* + * Renderer constants + *---------------------------------------------------------------------*/ + +#define RENDERER_MAX_ISAR_MD_INPUTS 1 +#define RENDERER_MAX_BIN_INPUTS 1 + +/*---------------------------------------------------------------------* + * Renderer structures + *---------------------------------------------------------------------*/ + +typedef struct +{ + int32_t bufLenInBytes; + int32_t bitsWritten; + int32_t bitsRead; + ISAR_SPLIT_REND_CODEC codec; + ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrection; + int16_t codec_frame_size_ms; +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + int16_t isar_frame_size_ms; + int16_t lc3plusHighRes; +#endif +} ISAR_POST_REND_BitstreamBufferConfig; + +typedef struct +{ + ISAR_POST_REND_BitstreamBufferConfig config; + uint8_t *bits; +} ISAR_POST_REND_BitstreamBuffer; + +typedef enum +{ + ISAR_POST_REND_AUDIO_CONFIG_TYPE_BINAURAL = 0, + ISAR_POST_REND_AUDIO_CONFIG_TYPE_UNKNOWN, +} ISAR_POST_REND_AudioConfigType; + +typedef struct +{ + IVAS_REND_AudioBufferConfig config; + const float *data; +} ISAR_POST_REND_ReadOnlyAudioBuffer; + +typedef struct ISAR_POST_REND *ISAR_POST_REND_HANDLE; +typedef struct ISAR_POST_REND const *ISAR_POST_REND_CONST_HANDLE; + +typedef uint16_t ISAR_POST_REND_InputId; + +typedef enum _ISAR_POST_REND_COMPLEXITY_LEVEL +{ + ISAR_POST_REND_COMPLEXITY_LEVEL_ONE = 1, + ISAR_POST_REND_COMPLEXITY_LEVEL_TWO = 2, + ISAR_POST_REND_COMPLEXITY_LEVEL_THREE = 3 +} ISAR_POST_REND_COMPLEXITY_LEVEL; + + +/* clang-format off */ +/*----------------------------------------------------------------------------------* + * Renderer function prototypes + *----------------------------------------------------------------------------------*/ + +/* Functions to be called before rendering */ + +ivas_error ISAR_POST_REND_open( + ISAR_POST_REND_HANDLE *phIvasRend, /* i/o: Pointer to renderer handle */ + const int32_t outputSampleRate, /* i : output sampling rate */ + const IVAS_AUDIO_CONFIG outConfig, /* i : output audio config */ + const bool asHrtfBinary, /* i : load hrtf binary file */ + const int16_t nonDiegeticPan, /* i : non-diegetic object flag */ + const float nonDiegeticPanGain, /* i : non-diegetic panning gain */ + const int16_t num_subframes /* i : number of subframes */ +); + +/* Functions to be called before/during rendering */ + +ivas_error ISAR_POST_REND_NumOutChannels( + ISAR_POST_REND_CONST_HANDLE hIvasRend, /* i : Renderer handle */ + int16_t *numOutChannels /* o : number of output channels */ +); + +ivas_error ISAR_POST_REND_AddInput( + ISAR_POST_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + const IVAS_AUDIO_CONFIG inConfig, /* i : audio config for a new input */ + ISAR_POST_REND_InputId *inputId /* o : ID of the new input */ +); + +ivas_error ISAR_POST_REND_SetInputGain( + ISAR_POST_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + const ISAR_POST_REND_InputId inputId, /* i : ID of the input */ + const float gain /* i : linear gain (not in dB) */ +); + +ivas_error ISAR_POST_REND_GetInputNumChannels( + ISAR_POST_REND_CONST_HANDLE hIvasRend, /* i : Renderer handle */ + const ISAR_POST_REND_InputId inputId, /* i : ID of the input */ + int16_t *numChannels /* o : number of channels of the input */ +); + +ivas_error ISAR_POST_REND_GetDelay( + ISAR_POST_REND_CONST_HANDLE hIvasRend, /* i : Renderer handle */ + int16_t *nSamples, /* o : Renderer delay in samples */ + int32_t *timeScale /* o : Time scale of the delay, equal to renderer output sampling rate */ +); + +/* Functions to be called during rendering */ + +ivas_error ISAR_POST_REND_FeedInputAudio( + ISAR_POST_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + const ISAR_POST_REND_InputId inputId, /* i : ID of the input */ + const ISAR_POST_REND_ReadOnlyAudioBuffer inputAudio /* i : buffer with input audio */ +); + +ivas_error ISAR_POST_REND_InitConfig( + ISAR_POST_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + const IVAS_AUDIO_CONFIG outAudioConfig /* i : output audioConfig */ +); + +int16_t ISAR_POST_REND_GetRenderConfig( + ISAR_POST_REND_HANDLE hIvasRend, /* i/o: IVAS decoder handle */ + const ISAR_SPLIT_REND_CONFIG_HANDLE splitRenderConfig /* o : Render configuration handle */ +); + +ivas_error ISAR_POST_REND_FeedSplitBinauralBitstream( + ISAR_POST_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + const ISAR_POST_REND_InputId inputId, /* i : ID of the input */ + ISAR_POST_REND_BitstreamBuffer *hBits /* i : buffer for input bitstream */ +); + +ivas_error ISAR_POST_REND_GetSplitBinauralSamples( + ISAR_POST_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + IVAS_REND_AudioBuffer outAudio, /* i/o: buffer for output audio */ + bool* needNewFrame +); + +ivas_error ISAR_POST_REND_SetHeadRotation( + ISAR_POST_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + const IVAS_QUATERNION headRot, /* i : head orientations for next rendering call */ + const IVAS_VECTOR3 Pos, /* i : listener positions for next rendering call */ + const ISAR_SPLIT_REND_ROT_AXIS rot_axis, /* i : external control for rotation axis for split rendering*/ + const int16_t sf_idx /* i : subframe index */ +); + +ivas_error ISAR_POST_REND_SetSplitRendBFI( + ISAR_POST_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + const int16_t bfi /* i: BFI flag */ +); + + +ivas_error ISAR_POST_REND_getSamples( + ISAR_POST_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + IVAS_REND_AudioBuffer outAudio /* i/o: buffer for output audio */ +); + +/* Functions to be called after rendering */ + +void ISAR_POST_REND_Close( + ISAR_POST_REND_HANDLE* phIvasRend /* i/o: Pointer to renderer handle */ +); + +ivas_error ISAR_REND_SetSplitRendBitstreamHeader( + ISAR_POST_REND_HANDLE hIvasRend, /* i/o: IVAS renderer handle */ + const ISAR_SPLIT_REND_CODEC codec, /* o: codec setting */ + const ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrection, /* o: pose correction mode */ + const int16_t codec_frame_size_ms /* i: codec frame size setting */ +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + , + const int16_t isar_frame_size_ms, /* i: isar frame size setting */ + const int16_t lc3plus_highres /* i: LC3plus Hig-Res setting. Ignored if codec is not LC3plus */ +#endif +); + +#ifdef DEBUGGING +int32_t ISAR_POST_REND_GetNoCLipping( + ISAR_POST_REND_HANDLE hIvasRend /* i : Renderer handle */ +); + +int32_t ISAR_POST_REND_GetCntFramesLimited( + ISAR_POST_REND_CONST_HANDLE hIvasRend /* i : Renderer handle */ +); +#endif + +#endif /* SPLIT_REND_WITH_HEAD_ROT */ + +/* clang-format on */ + +#endif /* LIB_ISAR_POST_REND_H */ diff --git a/lib_isar/lib_isar_pre_rend.c b/lib_isar/lib_isar_pre_rend.c new file mode 100644 index 0000000000000000000000000000000000000000..01baba8ba70387851c348584c157940829d67144 --- /dev/null +++ b/lib_isar/lib_isar_pre_rend.c @@ -0,0 +1,497 @@ +/****************************************************************************************************** + + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + + +#include +#include "options.h" +#include +#include "ivas_prot.h" +#include "prot.h" +#include "ivas_cnst.h" +#include "isar_rom_post_rend.h" +#include "lib_isar_pre_rend.h" +#include "isar_prot.h" +#ifdef DEBUGGING +#include "debug.h" +#endif +#include "wmc_auto.h" + + +#ifndef SPLIT_REND_WITH_HEAD_ROT +int32_t ISAR_PRE_REND_void_func( void ) +{ + return 0; +} + +#else + +/*-------------------------------------------------------------------* + * Local constants + *-------------------------------------------------------------------*/ + +/*-------------------------------------------------------------------* + * Local types + *-------------------------------------------------------------------*/ + +/*-------------------------------------------------------------------* + * Local function prototypes + *-------------------------------------------------------------------*/ + +/*-------------------------------------------------------------------* + * Local functions + *-------------------------------------------------------------------*/ + +/*------------------------------------------------------------------------- + * Function ISAR_PRE_REND_open() + * + * + *------------------------------------------------------------------------*/ + +ivas_error ISAR_PRE_REND_open( + SPLIT_REND_WRAPPER *hSplitBinRend, /* i/o: Split renderer pre-renerer handle */ + ISAR_SPLIT_REND_CONFIG_DATA *pSplitRendConfig, /* i/o: Split renderer pre-renerer config */ + const int32_t output_Fs, /* i: output sampling rate */ + const int16_t cldfb_in_flag, /* i: Flag to indicate CLDFB or time doamin input */ + const int16_t pcm_out_flag, /* i: Flag to indicate PCM output */ +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + const IVAS_RENDER_FRAMESIZE ivas_frame_size, /* i: IVAS frame size */ +#else + const int16_t num_subframes, /* i: number of subframes */ +#endif + const int16_t mixed_td_cldfb_flag /* i: Flag to indicate combined TD and CLDFB input */ +) +{ + ivas_error error, ch, num_ch; + uint8_t isCldfbNeeded = 0; + + int16_t cldfb_in_flag_local = cldfb_in_flag; + + if ( ( error = isar_split_rend_choose_default_codec( &( pSplitRendConfig->codec ), +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + &pSplitRendConfig->isar_frame_size_ms, +#endif + &pSplitRendConfig->codec_frame_size_ms, + cldfb_in_flag_local, + pcm_out_flag, (int16_t) +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + ivas_frame_size +#else + num_subframes +#endif + ) ) != IVAS_ERR_OK ) + { + return error; + } + + if ( mixed_td_cldfb_flag ) + { + cldfb_in_flag_local = 0; + } + + if ( ( error = isar_split_rend_validate_config( pSplitRendConfig, pcm_out_flag ) ) != IVAS_ERR_OK ) + { + return error; + } + + if ( cldfb_in_flag_local == 0 ) + { + isCldfbNeeded = 1; + } + else if ( pSplitRendConfig->codec == ISAR_SPLIT_REND_CODEC_LC3PLUS && cldfb_in_flag_local ) + { + isCldfbNeeded = 1; + } + else if ( pcm_out_flag && cldfb_in_flag_local ) + { + isCldfbNeeded = 1; + } + + hSplitBinRend->hCldfbHandles = NULL; + + if ( isCldfbNeeded ) + { + if ( ( hSplitBinRend->hCldfbHandles = (CLDFB_HANDLES_WRAPPER_HANDLE) malloc( sizeof( CLDFB_HANDLES_WRAPPER ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for CLDFB handles\n" ) ); + } + num_ch = MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS; + for ( ch = 0; ch < num_ch; ch++ ) + { + hSplitBinRend->hCldfbHandles->cldfbAna[ch] = NULL; + } + + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + hSplitBinRend->hCldfbHandles->cldfbSyn[ch] = NULL; + } + + num_ch = hSplitBinRend->multiBinPoseData.num_poses * BINAURAL_CHANNELS; + + for ( ch = 0; ch < num_ch; ch++ ) + { + if ( ( error = openCldfb( &( hSplitBinRend->hCldfbHandles->cldfbAna[ch] ), + CLDFB_ANALYSIS, + output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) + { + return error; + } + } + + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + if ( ( error = openCldfb( &( hSplitBinRend->hCldfbHandles->cldfbSyn[ch] ), CLDFB_SYNTHESIS, output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) + { + return error; + } + } + } + + if ( pSplitRendConfig->poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) + { + if ( ( error = isar_splitBinPreRendOpen( &hSplitBinRend->hBinHrSplitPreRend, &hSplitBinRend->multiBinPoseData +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG + , + OutSampleRate +#endif + ) ) != IVAS_ERR_OK ) + { + return error; + } + } + + if ( pcm_out_flag == 0 ) + { + if ( pSplitRendConfig->codec == ISAR_SPLIT_REND_CODEC_LC3PLUS ) + { + if ( ( error = split_renderer_open_lc3plus( hSplitBinRend, pSplitRendConfig, output_Fs, +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + ivas_frame_size +#else + num_subframes +#endif + ) ) != IVAS_ERR_OK ) + { + return error; + } + } + else + { + int16_t iNumBlocksPerFrame; + iNumBlocksPerFrame = ( CLDFB_NO_COL_MAX * pSplitRendConfig->codec_frame_size_ms ) / 20; + + if ( ( error = isar_splitBinLCLDEncOpen( &hSplitBinRend->hSplitBinLCLDEnc, output_Fs, BINAURAL_CHANNELS, isar_get_lcld_bitrate( pSplitRendConfig->splitRendBitRate, hSplitBinRend->multiBinPoseData.poseCorrectionMode ), iNumBlocksPerFrame, 1 ) ) != IVAS_ERR_OK ) + { + return error; + } + } + } + + return IVAS_ERR_OK; +} + +/*------------------------------------------------------------------------- + * Function ISAR_PRE_REND_close() + * + * + *------------------------------------------------------------------------*/ + +void ISAR_PRE_REND_close( + SPLIT_REND_WRAPPER *hSplitBinRend, /* i/o: Split renderer pre-renerer handle */ + IVAS_REND_AudioBuffer *pSplitRendEncBuffer /* i/o: Split renderer data buffer */ +) +{ + int16_t i; + + if ( hSplitBinRend->hBinHrSplitPreRend != NULL ) + { + isar_splitBinPreRendClose( &hSplitBinRend->hBinHrSplitPreRend ); + } + + if ( hSplitBinRend->hSplitBinLCLDEnc != NULL ) + { + isar_splitBinLCLDEncClose( &hSplitBinRend->hSplitBinLCLDEnc ); + } + + if ( hSplitBinRend->hCldfbHandles != NULL ) + { + int16_t num_ch, ch; + num_ch = MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS; + for ( ch = 0; ch < num_ch; ch++ ) + { + if ( hSplitBinRend->hCldfbHandles->cldfbAna[ch] != NULL ) + { + deleteCldfb( &hSplitBinRend->hCldfbHandles->cldfbAna[ch] ); + hSplitBinRend->hCldfbHandles->cldfbAna[ch] = NULL; + } + } + + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + if ( hSplitBinRend->hCldfbHandles->cldfbSyn[ch] != NULL ) + { + deleteCldfb( &hSplitBinRend->hCldfbHandles->cldfbSyn[ch] ); + hSplitBinRend->hCldfbHandles->cldfbSyn[ch] = NULL; + } + } + + free( hSplitBinRend->hCldfbHandles ); + hSplitBinRend->hCldfbHandles = NULL; + } + + if ( hSplitBinRend->hLc3plusEnc != NULL ) + { + ISAR_LC3PLUS_ENC_Close( &hSplitBinRend->hLc3plusEnc ); + } + + for ( i = 0; i < MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS; ++i ) + { + if ( hSplitBinRend->lc3plusDelayBuffers[i] != NULL ) + { + free( hSplitBinRend->lc3plusDelayBuffers[i] ); + hSplitBinRend->lc3plusDelayBuffers[i] = NULL; + } + } + + if ( pSplitRendEncBuffer != NULL ) + { + + if ( pSplitRendEncBuffer->data != NULL ) + { + free( pSplitRendEncBuffer->data ); + pSplitRendEncBuffer->data = NULL; + } + + pSplitRendEncBuffer->config.numChannels = 0; + pSplitRendEncBuffer->config.numSamplesPerChannel = 0; + } + + return; +} + +/*-------------------------------------------------------------------------* + * ISAR_PRE_REND_GetMultiBinPoseData() + * + * + *-------------------------------------------------------------------------*/ + +void ISAR_PRE_REND_GetMultiBinPoseData( + const ISAR_SPLIT_REND_CONFIG_DATA *pSplit_rend_config, /* i: Split renderer pre-renerer config */ + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, /* i/o: pose correction data handle */ + const ISAR_SPLIT_REND_ROT_AXIS rot_axis /* i: Rotation axis */ +) +{ + isar_renderSplitGetMultiBinPoseData( pSplit_rend_config, pMultiBinPoseData, rot_axis ); +} + +/*------------------------------------------------------------------------- + * Function ISAR_PRE_REND_MultiBinToSplitBinaural() + * + * + *------------------------------------------------------------------------*/ + +ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( + SPLIT_REND_WRAPPER *hSplitBin, /* i/o: Split renderer pre-renerer handle */ + const IVAS_QUATERNION headPosition, /* i: head rotation QUATERNION */ + const int32_t SplitRendBitRate, /* i: Split renderer bitrate */ + ISAR_SPLIT_REND_CODEC splitCodec, /* i/o: Split renderer codec */ +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + const int16_t isar_frame_size_ms, /* i: ISAR framesize */ +#endif + int16_t codec_frame_size_ms, /* i/o: ISAR transport codec framesize */ + ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i/o: ISAR bits struct handle */ + float Cldfb_In_BinReal[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: CLDFB real buffer */ + float Cldfb_In_BinImag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: CLDFB imag buffer */ + const int16_t max_bands, /* i: CLDFB bands */ + float *output[], /* i/o: PCM in/out buffer */ + const int16_t low_res_pre_rend_rot, /* i: low time resolution pre-renderer flag */ + const int16_t cldfb_in_flag, /* i: Flag to indicate CLDFB or time doamin input */ + const int16_t pcm_out_flag, /* i: Flag to indicate PCM output */ + const int16_t ro_md_flag /* i: Flag to indicate real only metadata for yaw */ +) +{ + ivas_error error; +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + int32_t bit_len, target_md_bits, available_bits; +#else + int32_t bit_len, target_md_bits, actual_md_bits, available_bits; +#endif + + error = IVAS_ERR_OK; + push_wmops( "isar_pre_rend_MultiBinToSplitBinaural" ); + + if ( hSplitBin->multiBinPoseData.poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) + { + set_fix_rotation_mat( hSplitBin->hBinHrSplitPreRend->fix_pos_rot_mat, &hSplitBin->multiBinPoseData ); + set_pose_types( hSplitBin->hBinHrSplitPreRend->pose_type, &hSplitBin->multiBinPoseData ); + } + + if ( cldfb_in_flag == 0 ) + { + /*TD input*/ + /*if CLDFB handles have been allocated then assume valid multi binaural input in out[][] buffer and perform CLDFB analysis*/ + error = isar_renderMultiTDBinToSplitBinaural( hSplitBin, + headPosition, + SplitRendBitRate, +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + isar_frame_size_ms, +#endif + codec_frame_size_ms, + pBits, + max_bands, + output, + low_res_pre_rend_rot, + pcm_out_flag, + ro_md_flag ); + + pop_wmops(); + return error; + } + + if ( splitCodec == ISAR_SPLIT_REND_CODEC_LC3PLUS && hSplitBin->multiBinPoseData.poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) + { + /* Time-align pose correction to delay of LC3plus */ + lc3plusTimeAlignCldfbPoseCorr( hSplitBin, Cldfb_In_BinReal, Cldfb_In_BinImag ); + } + +#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS + actual_md_bits = pBits->bits_written; +#endif + if ( hSplitBin->multiBinPoseData.poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) + { + target_md_bits = isar_get_split_rend_md_target_brate( SplitRendBitRate, pcm_out_flag ) * L_FRAME48k / 48000; + +#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS + actual_md_bits = pBits->bits_written; +#endif + + isar_rend_CldfbSplitPreRendProcess( hSplitBin->hBinHrSplitPreRend, headPosition, &hSplitBin->multiBinPoseData, Cldfb_In_BinReal, Cldfb_In_BinImag, pBits, target_md_bits, low_res_pre_rend_rot, ro_md_flag ); + } + + if ( pcm_out_flag == 0 ) + { + pBits->codec = splitCodec; + pBits->pose_correction = hSplitBin->multiBinPoseData.poseCorrectionMode; + + if ( splitCodec == ISAR_SPLIT_REND_CODEC_LCLD ) + { + available_bits = ( SplitRendBitRate * hSplitBin->hSplitBinLCLDEnc->iNumBlocks * hSplitBin->hSplitBinLCLDEnc->iNumIterations ) / ( 16 * FRAMES_PER_SEC ); +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + available_bits -= pBits->bits_written; +#else + actual_md_bits = pBits->bits_written - actual_md_bits; + available_bits -= actual_md_bits; +#endif + pBits->codec_frame_size_ms = codec_frame_size_ms; + isar_splitBinLCLDEncProcess( hSplitBin->hSplitBinLCLDEnc, Cldfb_In_BinReal, Cldfb_In_BinImag, available_bits, pBits ); + } + else + { + int16_t ch, slot_idx, num_slots, ivas_fs; + ivas_fs = (int16_t) hSplitBin->hLc3plusEnc->config.isar_frame_duration_us / 1000; + num_slots = (int16_t) ( CLDFB_NO_COL_MAX * ivas_fs ) / 20; + /* CLDFB synthesis of main pose */ + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + float *Cldfb_In_BinReal_p[CLDFB_NO_COL_MAX]; + float *Cldfb_In_BinImag_p[CLDFB_NO_COL_MAX]; + + for ( slot_idx = 0; slot_idx < num_slots; slot_idx++ ) + { + Cldfb_In_BinReal_p[slot_idx] = Cldfb_In_BinReal[ch][slot_idx]; + Cldfb_In_BinImag_p[slot_idx] = Cldfb_In_BinImag[ch][slot_idx]; + } + + cldfbSynthesis( Cldfb_In_BinReal_p, Cldfb_In_BinImag_p, output[ch], hSplitBin->hCldfbHandles->cldfbSyn[0]->no_channels * num_slots, hSplitBin->hCldfbHandles->cldfbSyn[ch] ); + } + +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + available_bits = ( SplitRendBitRate / FRAMES_PER_SEC ) - pBits->bits_written; + if ( ( error = splitRendLc3plusEncodeAndWrite( hSplitBin, pBits, available_bits, output ) ) != IVAS_ERR_OK ) +#else + if ( ( error = splitRendLc3plusEncodeAndWrite( hSplitBin, pBits, SplitRendBitRate, output ) ) != IVAS_ERR_OK ) +#endif + { + return error; + } + } + } + else + { + int16_t ch, slot_idx; + /* CLDFB synthesis of main pose */ + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + float *Cldfb_In_BinReal_p[CLDFB_NO_COL_MAX]; + float *Cldfb_In_BinImag_p[CLDFB_NO_COL_MAX]; + + for ( slot_idx = 0; slot_idx < CLDFB_NO_COL_MAX; slot_idx++ ) + { + Cldfb_In_BinReal_p[slot_idx] = Cldfb_In_BinReal[ch][slot_idx]; + Cldfb_In_BinImag_p[slot_idx] = Cldfb_In_BinImag[ch][slot_idx]; + } + + cldfbSynthesis( Cldfb_In_BinReal_p, Cldfb_In_BinImag_p, output[ch], hSplitBin->hCldfbHandles->cldfbSyn[0]->no_channels * CLDFB_NO_COL_MAX, hSplitBin->hCldfbHandles->cldfbSyn[ch] ); + } + + pBits->pose_correction = hSplitBin->multiBinPoseData.poseCorrectionMode; + pBits->codec = ISAR_SPLIT_REND_CODEC_NONE; + } + + /*zero pad*/ + if ( pcm_out_flag ) + { + bit_len = SplitRendBitRate / FRAMES_PER_SEC; + } + else + { + if ( splitCodec == ISAR_SPLIT_REND_CODEC_LCLD ) + { + bit_len = ( SplitRendBitRate * hSplitBin->hSplitBinLCLDEnc->iNumBlocks * hSplitBin->hSplitBinLCLDEnc->iNumIterations ) / ( 16 * FRAMES_PER_SEC ); + } + else + { + bit_len = hSplitBin->hLc3plusEnc->config.isar_frame_duration_us / 1000; + bit_len = SplitRendBitRate * bit_len / 1000; + } + } + + while ( pBits->bits_written < bit_len ) + { + ISAR_SPLIT_REND_BITStream_write_int32( pBits, 0L, 1 ); + } + + pop_wmops(); + + return error; +} + +#endif diff --git a/lib_isar/lib_isar_pre_rend.h b/lib_isar/lib_isar_pre_rend.h new file mode 100644 index 0000000000000000000000000000000000000000..a8cfdaf61c586060cadeeca0ca115017fe92db41 --- /dev/null +++ b/lib_isar/lib_isar_pre_rend.h @@ -0,0 +1,91 @@ +/****************************************************************************************************** + + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#ifndef LIB_ISAR_PRE_REND_H +#define LIB_ISAR_PRE_REND_H + +#include "isar_stat.h" +#include "isar_prot.h" + +#ifndef SPLIT_REND_WITH_HEAD_ROT + +int32_t ISAR_PRE_REND_void_func( void ); + +#else + +ivas_error ISAR_PRE_REND_open( + SPLIT_REND_WRAPPER *hSplitBinRend, /* i/o: Split renderer pre-renerer handle */ + ISAR_SPLIT_REND_CONFIG_DATA *pSplitRendConfig, /* i/o: Split renderer pre-renerer config */ + const int32_t output_Fs, /* i: output sampling rate */ + const int16_t cldfb_in_flag, /* i: Flag to indicate CLDFB or time doamin input */ + const int16_t pcm_out_flag, /* i: Flag to indicate PCM output */ +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + const IVAS_RENDER_FRAMESIZE ivas_frame_size, /* i: IVAS frame size */ +#else + const int16_t num_subframes, /* i: number of subframes */ +#endif + const int16_t mixed_td_cldfb_flag /* i: Flag to indicate combined TD and CLDFB input */ +); + +void ISAR_PRE_REND_close( + SPLIT_REND_WRAPPER *hSplitBinRend, /* i/o: Split renderer pre-renerer handle */ + IVAS_REND_AudioBuffer *pSplitRendEncBuffer /* i/o: Split renderer data buffer */ +); + +void ISAR_PRE_REND_GetMultiBinPoseData( + const ISAR_SPLIT_REND_CONFIG_DATA *pSplit_rend_config, /* i: Split renderer pre-renerer config */ + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, /* i/o: pose correction data handle */ + const ISAR_SPLIT_REND_ROT_AXIS rot_axis /* i: Rotation axis */ +); + +ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( + SPLIT_REND_WRAPPER *hSplitBin, /* i/o: Split renderer pre-renerer handle */ + const IVAS_QUATERNION headPosition, /* i: head rotation QUATERNION */ + const int32_t SplitRendBitRate, /* i: Split renderer bitrate */ + ISAR_SPLIT_REND_CODEC splitCodec, /* i/o: Split renderer codec */ +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + const int16_t isar_frame_size_ms, /* i: ISAR framesize */ +#endif + int16_t codec_frame_size_ms, /* i/o: ISAR transport codec framesize */ + ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i/o: ISAR bits struct handle */ + float Cldfb_In_BinReal[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: CLDFB real buffer */ + float Cldfb_In_BinImag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: CLDFB imag buffer */ + const int16_t max_bands, /* i: CLDFB bands */ + float *output[], /* i/o: PCM in/out buffer */ + const int16_t low_res_pre_rend_rot, /* i: low time resolution pre-renderer flag */ + const int16_t cldfb_in_flag, /* i: Flag to indicate CLDFB or time doamin input */ + const int16_t pcm_out_flag, /* i: Flag to indicate PCM output */ + const int16_t ro_md_flag /* i: Flag to indicate real only metadata for yaw */ +); + +#endif +#endif /* LIB_ISAR_PRE_REND_H */ diff --git a/lib_lc3plus/.clang-format b/lib_lc3plus/.clang-format new file mode 100644 index 0000000000000000000000000000000000000000..47a38a93f2dbdd6d944f9dddc3465e3fb65aec29 --- /dev/null +++ b/lib_lc3plus/.clang-format @@ -0,0 +1,2 @@ +DisableFormat: true +SortIncludes: Never diff --git a/lib_lc3plus/adjust_global_gain.c b/lib_lc3plus/adjust_global_gain.c new file mode 100644 index 0000000000000000000000000000000000000000..24eb596c87a18bad0fb67f4c391e2b6e6be10549 --- /dev/null +++ b/lib_lc3plus/adjust_global_gain.c @@ -0,0 +1,97 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.3 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + + +#include "options.h" +#include "wmc_auto.h" +#include "functions.h" + +void processAdjustGlobalGain_fl(LC3_INT* gg_idx, LC3_INT gg_idx_min, LC3_INT gg_idx_off, LC3_FLOAT* gain, LC3_INT target, LC3_INT nBits, LC3_INT* gainChange, LC3_INT fs_idx + , LC3_INT16 hrmode, LC3_INT16 frame_dms + ) +{ + LC3_FLOAT delta; + LC3_INT delta2; + LC3_INT gg_idx_inc; +#ifdef CR8_G_ADD_75MS + LC3_FLOAT factor; +#else + LC3_INT factor; +#endif + + if (frame_dms == 25) + { + if (target < 520) + { + factor = 3; + } else { + factor = 4; + } + } else if (frame_dms == 50) + { + factor = 2; + } +#ifdef CR8_G_ADD_75MS + else if (frame_dms == 75) + { + factor = 1.2; + } +#endif + else + { + factor = 1; + } + + if (nBits < gg_p1[fs_idx]) { + delta = (nBits + 48.0) / 16.0; + } else if (nBits < gg_p2[fs_idx]) { + delta = (nBits + gg_d[fs_idx]) * gg_c[fs_idx]; + } else if (nBits < gg_p3[fs_idx]) { + delta = nBits / 48.0; + } else { + delta = gg_p3[fs_idx] / 48.0; + } + + delta = round(delta); + delta2 = delta + 2; + + *gainChange = 0; + + if (*gg_idx == 255 && nBits > target) { + *gainChange = 1; + } + + if ((*gg_idx < 255 && nBits > target) || (*gg_idx > 0 && nBits < target - delta2)) { + if (hrmode) + { + if (nBits > target) { + gg_idx_inc = (int) (factor * (((nBits - target)/ delta) + 1)); + gg_idx_inc = MIN(gg_idx_inc, 10 * factor); + + *gg_idx += gg_idx_inc; + } + + *gg_idx = MIN(*gg_idx, 255); + } + else + { + if (nBits < target - delta2) { + *gg_idx = *gg_idx - 1; + } else if (*gg_idx == 254 || nBits < target + delta) { + *gg_idx = *gg_idx + 1; + } else { + *gg_idx = *gg_idx + 2; + } + } + + *gg_idx = MAX(*gg_idx, gg_idx_min - gg_idx_off); + *gain = LC3_POW(10, (LC3_FLOAT)(*gg_idx + gg_idx_off) / 28); + *gainChange = 1; + } +} diff --git a/lib_lc3plus/al_fec_fl.c b/lib_lc3plus/al_fec_fl.c new file mode 100644 index 0000000000000000000000000000000000000000..92861d65b218af071ef33b355b0347fd12e33656 --- /dev/null +++ b/lib_lc3plus/al_fec_fl.c @@ -0,0 +1,2330 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.3 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + + +#include "options.h" +#include "wmc_auto.h" +#include "stdint.h" +#include +#include +#include + +#include "functions.h" + + +/* channel coder specific constants and macros */ +#define RS16_CW_LEN_MAX 15 + +#define FEC_N_MODES 4 +#define FEC_N_SYNDROMES_MAX 6 +#define FEC_N_ERR_POS_MAX 3 +#define FEC_N_ELP_COEFF_MAX 4 +#define FEC_N_ERR_SYMB_MAX 3 +#define FEC_N_MODE_DETECTION_CW 6 + +#define SYNDROME_IDX(mode_index, cw_index) (((mode_index)*FEC_N_MODE_DETECTION_CW + (cw_index)) * FEC_N_SYNDROMES_MAX) +#define ELP_IDX(mode_index, cw_index) (((mode_index)*FEC_N_MODE_DETECTION_CW + (cw_index)) * FEC_N_ELP_COEFF_MAX) +#define ERR_POS_IDX(mode_index, cw_index) (((mode_index)*FEC_N_MODE_DETECTION_CW + (cw_index)) * FEC_N_ERR_POS_MAX) +#define ERR_SYMB_IDX(mode_index, cw_index) (((mode_index)*FEC_N_MODE_DETECTION_CW + (cw_index)) * FEC_N_ERR_SYMB_MAX) +#define DEG_ELP_IDX(mode_index, cw_index) ((mode_index)*FEC_N_MODE_DETECTION_CW + (cw_index)) + +#define FEC_TOTAL_SYNDROME_SIZE (FEC_N_SYNDROMES_MAX * FEC_N_MODES * FEC_N_MODE_DETECTION_CW) +#define FEC_TOTAL_ELP_SIZE (FEC_N_ELP_COEFF_MAX * FEC_N_MODES * FEC_N_MODE_DETECTION_CW) +#define FEC_TOTAL_ERR_POS_SIZE (FEC_N_ERR_POS_MAX * FEC_N_MODES * FEC_N_MODE_DETECTION_CW) +#define FEC_TOTAL_ERROR_SIZE (FEC_N_ERR_SYMB_MAX * FEC_N_MODES * FEC_N_MODE_DETECTION_CW) +#define FEC_TOTAL_DEG_ELP_SIZE (FEC_N_MODES * FEC_N_MODE_DETECTION_CW) + +#define ERROR_REPORT_BEC_MASK ((0x0FFF)>>1) +#define ERROR_REPORT_EP1_OK ((0x1000)>>1) +#define ERROR_REPORT_EP2_OK ((0x2000)>>1) +#define ERROR_REPORT_EP3_OK ((0x4000)>>1) +#define ERROR_REPORT_EP4_OK ((0x8000)>>1) +#define ERROR_REPORT_ALL_OK (ERROR_REPORT_EP1_OK | ERROR_REPORT_EP2_OK | ERROR_REPORT_EP3_OK | ERROR_REPORT_EP4_OK) + +/* debugging switches */ + +/* constants concerning mode detection */ +#define EP_RISK_THRESH_NS_M 21990 +#define EP_RISK_THRESH_NS_E -23 +#define EP_RISK_THRESH_OS_M 25166 +#define EP_RISK_THRESH_OS_E -10 + +#define SIMPLE_FLOAT_1_MANTISSA 16384 + +#define FEC_STATIC static + +/* DISCLAIMER: Strict instrumentation of GF16 arithmetic would have to take into account + * the initial conversion of the arguments from LC3_UINT8 to LC3_INT16 (one move16() per argument). + * Behind this is the assumption that one would store GF16 elements in LC3_INT16 for strict BASOP + * implementation. + */ +#define GF16_MUL(a, b) gf16_mult_table[(a) | (b << 4)] +#define GF16_MUL0(a, b) gf16_mult_table[(a) | (b)] +#define GF16_ADD(a, b) ((a) ^ (b)) + +/* tables for finite field arithmetic */ +/* tables for arithmetic in GF(16) * + * generator polynomial: 19 + * unit group generator (g): 2 + */ + +static const LC3_UINT8 gf16_mult_table[256] = { + /* gf16_mult_table[a | (b << 4)] contains the product of a and b in GF(16) */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, + 13, 14, 15, 0, 2, 4, 6, 8, 10, 12, 14, 3, 1, 7, 5, 11, 9, 15, 13, 0, 3, 6, 5, 12, 15, 10, 9, 11, 8, + 13, 14, 7, 4, 1, 2, 0, 4, 8, 12, 3, 7, 11, 15, 6, 2, 14, 10, 5, 1, 13, 9, 0, 5, 10, 15, 7, 2, 13, + 8, 14, 11, 4, 1, 9, 12, 3, 6, 0, 6, 12, 10, 11, 13, 7, 1, 5, 3, 9, 15, 14, 8, 2, 4, 0, 7, 14, 9, + 15, 8, 1, 6, 13, 10, 3, 4, 2, 5, 12, 11, 0, 8, 3, 11, 6, 14, 5, 13, 12, 4, 15, 7, 10, 2, 9, 1, 0, + 9, 1, 8, 2, 11, 3, 10, 4, 13, 5, 12, 6, 15, 7, 14, 0, 10, 7, 13, 14, 4, 9, 3, 15, 5, 8, 2, 1, 11, + 6, 12, 0, 11, 5, 14, 10, 1, 15, 4, 7, 12, 2, 9, 13, 6, 8, 3, 0, 12, 11, 7, 5, 9, 14, 2, 10, 6, 1, + 13, 15, 3, 4, 8, 0, 13, 9, 4, 1, 12, 8, 5, 2, 15, 11, 6, 3, 14, 10, 7, 0, 14, 15, 1, 13, 3, 2, 12, + 9, 7, 6, 8, 4, 10, 11, 5, 0, 15, 13, 2, 9, 6, 4, 11, 1, 14, 12, 3, 8, 7, 5, 10, +}; + +static const LC3_UINT8 rs16_elp_deg2_table[256] = { + /* If the polynomial x^2 + ax + b has distinct non-zero roots z1 and z2 in GF(16), * + * then table entry a + 16*b contains log_g(z1) | log_g(z2) << 4, and otherwise it * + * contains 0. */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 165, 0, 0, 0, 0, + 105, 195, 0, 210, 0, 225, 0, 180, 120, 0, 0, 121, 0, 16, 0, 211, 0, 0, 181, 0, 0, 106, + 196, 226, 0, 0, 0, 214, 64, 0, 199, 0, 0, 0, 0, 0, 49, 184, 0, 154, 0, 229, 0, 227, + 182, 0, 0, 32, 0, 0, 0, 197, 0, 0, 122, 0, 212, 152, 0, 203, 0, 158, 128, 0, 0, 0, + 98, 113, 218, 0, 0, 0, 53, 0, 0, 65, 0, 0, 185, 110, 215, 80, 0, 0, 200, 0, 50, 0, + 0, 0, 0, 130, 205, 115, 0, 0, 160, 190, 145, 0, 0, 0, 0, 0, 0, 100, 0, 0, 168, 198, + 0, 183, 33, 0, 0, 48, 228, 213, 0, 0, 0, 0, 0, 0, 0, 0, 164, 0, 179, 0, 224, 104, + 0, 194, 149, 0, 0, 209, 0, 0, 0, 189, 99, 84, 0, 129, 0, 0, 0, 144, 0, 0, 234, 114, + 0, 0, 82, 0, 0, 0, 0, 217, 202, 0, 112, 52, 232, 0, 97, 0, 0, 0, 126, 0, 81, 201, + 0, 36, 216, 186, 0, 0, 0, 96, 0, 0, 0, 0, 0, 88, 0, 0, 0, 103, 0, 148, 178, 0, + 208, 193, 0, 58, 0, 0, 0, 0, 0, 161, 206, 0, 116, 0, 101, 0, 0, 56, 146, 176, 0, 0, + 147, 162, 222, 0, 132, 0, 0, 0, 0, 0, 177, 117, 192, 0, +}; + +static const LC3_UINT16 rs16_elp_deg3_table[256] = { + /* If the polynomial x^3 + ax + b has distinct roots z1, z2 and z3 in GF(16), * + * then table entry a + 16*b contains z1) | z2 << 4 | z3 << 8, and otherwise it * + * contains 0. */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1889, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2977, 0, 0, 0, 0, 0, 3990, 1859, 0, + 0, 0, 0, 0, 0, 0, 3521, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1874, 0, 3718, 0, 0, 0, + 0, 0, 0, 2433, 0, 0, 1619, 0, 0, 0, 0, 3495, 0, 0, 0, 0, 0, 0, 4065, 0, 0, 0, + 0, 0, 0, 3255, 0, 0, 0, 1602, 0, 3735, 0, 0, 0, 0, 3238, 801, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 3510, 0, 0, 0, 0, 1345, 3975, 0, 0, 0, 0, 0, 0, 0, 0, 3778, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2947, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 3476, 0, 4005, 0, 3461, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 3748, 0, 0, 2962, 0, 0, 0, 0, 4035, 0, 0, 4020, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3221, 0, 0, 0, 0, 0, 0, 2690, + 0, 0, 0, 3795, 0, 0, 0, 4050, 0, 0, 0, 0, 0, 3204, 3765, 0, 0, 0, 0, 0, 2707, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +}; + +static const LC3_UINT8 gf16_g_pow[16] = {1, 2, 4, 8, 3, 6, 12, 11, 5, 10, 7, 14, 15, 13, 9, 1}; +/* g_pow[i] contains g^i*/ + +static const LC3_UINT8 gf16_log_g[16] = {255, 0, 1, 4, 2, 8, 5, 10, 3, 14, 9, 7, 6, 13, 11, 12}; +/* log_g[n] contains contains the value i such that g^i = n for n=1, 2, ..., 15, log_g[0] is set to 255 */ + +static const LC3_UINT8 gf16_inv_table[16] = {255, 1, 9, 14, 13, 11, 7, 6, 15, 2, 12, 5, 10, 4, 3, 8}; +/* gf16_inv_table[n] contains the multiplicative inverse of n in GF(16) (1/0 is set to 255)*/ + +/* RS16 generating polynomials (from lowest to highest coefficient without leading 1)*/ + +static const LC3_UINT8 rs16_gp_d3[] = {8, 6}; +static const LC3_UINT8 rs16_gp_d5[] = {7, 8, 12, 13}; +static const LC3_UINT8 rs16_gp_d7[] = {12, 10, 12, 3, 9, 7}; + +/* FEC mode signaling polynomials */ + +#define EP_SIG_POLY_DEG 12 + +static const LC3_UINT8 sig_polys[4][15] = {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {7, 15, 5, 6, 14, 9, 1, 3, 12, 10, 13, 3, 2, 0, 0}, + {7, 11, 14, 1, 2, 3, 12, 11, 6, 15, 7, 6, 12, 0, 0}, + {6, 15, 12, 2, 9, 15, 2, 8, 12, 3, 10, 5, 4, 0, 0}}; + +static const LC3_UINT8 sig_poly_syndr[4][6] = { + {0, 0, 0, 0, 0, 0}, {0, 4, 5, 11, 5, 8}, {0, 5, 9, 0, 1, 7}, {0, 12, 5, 12, 9, 8}}; + +/* bit count table for error report (0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111) */ + +static const LC3_UINT8 rs16_bit_count_table[] = {0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4}; + +/* List of RS16 generators by Hamming distance */ + +static const LC3_UINT8 *const rs16_gp_by_hd[8] = {NULL, NULL, NULL, rs16_gp_d3, NULL, rs16_gp_d5, NULL, rs16_gp_d7}; + +/* fec config data */ + +static const LC3_UINT8 hamming_distance_by_mode0[] = {1, 3, 3, 5, 7}; +static const LC3_UINT8 hamming_distance_by_mode1[] = {1, 1, 3, 5, 7}; + +static const LC3_UINT8 crc1_bytes_by_mode0[] = {0, 3, 2, 2, 2}; +static const LC3_UINT8 crc1_bytes_by_mode1[] = {0, 3, 3, 3, 3}; +static const LC3_UINT8 crc2_bytes_by_mode[] = {0, 0, 2, 2, 2}; + +/* fec mode risk table */ +typedef struct +{ + LC3_UINT32 mantissa; + LC3_INT16 exponent; +} simple_float; + +static const simple_float risk_table_f[4][4] = {{{16384, 0}, {16384, 0}, {16384, 0}, {16384, 0}}, + {{16384, -8}, {26880, -1}, {16384, 0}, {16384, 0}}, + {{16384, -16}, {26880, -9}, {20475, -2}, {16384, 0}}, + {{16384, -24}, {26880, -17}, {20475, -10}, {19195, -4}}}; +/* bit error limits for slot size 40 */ +static LC3_INT16 const low_br_max_bit_errors_by_mode[] = {0, 0, 3, 9, 18}; + +/* +corresponding float values: + {1.f, 1.f, 1.f, 1.f}, + {0.00390625f, 0.820312f, 1.f, 1.f}, + {1.52588e-05f, 0.00320435f, 0.312424f, 1.f}, + {5.96046e-08f, 1.2517e-05f, 0.00122041f, 0.0732243f} +*/ + +/* internal encoder routines */ + +FEC_STATIC void fec_interleave_pack(LC3_UINT8 *out, LC3_UINT8 *in, LC3_INT16 n_nibbles, LC3_INT16 n_codewords); + +FEC_STATIC void rs16_enc(LC3_UINT8 *iobuf, LC3_INT16 codeword_length, LC3_INT16 hamming_distance, LC3_INT16 fec_mode, + LC3_INT16 signal_mode); + +/* internal decoder routines */ + +FEC_STATIC void fec_deinterleave_unpack(LC3_UINT8 *out, LC3_UINT8 *in, LC3_INT16 n_nibbles, LC3_INT16 n_codewords); + +FEC_STATIC LC3_INT16 fec_data_preproc(LC3_INT16 mode, LC3_INT16 epmr, LC3_UINT8 *iobuf, LC3_UINT8 *cw_buf, LC3_INT16 data_bytes, + LC3_INT16 slot_bytes, LC3_INT16 pc_split); + +FEC_STATIC void fec_data_postproc(LC3_INT16 mode, LC3PLUS_EpModeRequest *epmr, LC3_UINT8 *iobuf, LC3_INT16 data_bytes, LC3_UINT8 *cw_buf, + LC3_INT16 slot_bytes, LC3_INT16 pc_split, LC3_INT32 *bfi); + +FEC_STATIC LC3_INT32 rs16_detect_and_correct(LC3_UINT8 *iobuf, LC3_INT32 n_symb, LC3_INT32 n_codewords, LC3PLUS_EpModeRequest *epmr, LC3_INT16 *error_report, + LC3_INT32 *bfi, LC3_UINT8 *array_of_trust, LC3_INT32 ccc_flag_flag, LC3_INT16 *n_pccw); + +FEC_STATIC void rs16_calculate_six_syndromes(LC3_UINT8 *syndromes, LC3_UINT8 *cw, LC3_INT32 cw_poly_deg); + +FEC_STATIC void rs16_calculate_four_syndromes(LC3_UINT8 *syndromes, LC3_UINT8 *cw, LC3_INT32 cw_poly_deg); + +FEC_STATIC void rs16_calculate_two_syndromes(LC3_UINT8 *syndromes, LC3_UINT8 *cw, LC3_INT32 cw_poly_deg); + +FEC_STATIC LC3_INT8 rs16_calculate_elp(LC3_UINT8 *elp, LC3_UINT8 *syndromes, LC3_INT16 hamming_distance); + +FEC_STATIC LC3_INT16 rs16_factorize_elp(LC3_UINT8 *error_locations, LC3_UINT8 *elp, LC3_INT16 deg_elp, LC3_INT16 max_pos); + +FEC_STATIC void rs16_calculate_errors(LC3_UINT8 *errors, LC3_UINT8 *err_pos, LC3_UINT8 *syndromes, LC3_INT8 deg_elp, LC3_INT8 t); + +/* auxiliary routines */ + +FEC_STATIC LC3_INT16 crc1(LC3_UINT8 *data, LC3_INT16 data_size, LC3_INT16 epmr, LC3_UINT8 *hash_val, LC3_INT16 hash_size, LC3_INT16 check); + +FEC_STATIC LC3PLUS_EpModeRequest fec_estimate_epmr_from_cw0(LC3_UINT8 *cw0, LC3_INT8 *t, LC3_UINT8 *syndromes, LC3_UINT8 *elp, LC3_INT8 *deg_elp, + LC3_UINT8 *err_pos, LC3_UINT8 *err_symb, LC3_INT16 n_codewords, LC3_INT16 n_symb); + +FEC_STATIC void dw0_bitswap(LC3_UINT8 *dw0, LC3_INT16 mode, LC3_INT16 slot_bytes); + +FEC_STATIC LC3PLUS_EpModeRequest cw0_get_epmr(LC3_UINT8 *cw0, LC3_INT16 epmr_position); + +FEC_STATIC LC3PLUS_EpModeRequest dw0_get_epmr(LC3_UINT8 *dw0, LC3_INT16 mode, LC3_INT16 slot_size); + +FEC_STATIC LC3_INT16 crc2(LC3_UINT8 *data, LC3_INT16 data_size, LC3_UINT8 *hash_val, LC3_INT16 hash_size, LC3_INT16 check); + +FEC_STATIC simple_float simple_float_mul(simple_float op1, simple_float op2); + +FEC_STATIC LC3_INT16 simple_float_cmp(simple_float op1, simple_float op2); + +FEC_STATIC LC3_INT16 get_total_crc_size(LC3_INT16 slot_bytes, LC3_INT16 fec_mode, LC3_INT16 pc_split); + +FEC_STATIC LC3_INT16 get_n_codewords(LC3_INT16 slot_bytes); + +FEC_STATIC LC3_INT16 get_codeword_length(LC3_INT16 n_codewords, LC3_INT16 slot_nibbles, LC3_INT16 codeword_index); + + + +LC3_INT16 fec_get_n_pccw(LC3_INT16 slot_bytes, LC3_INT16 fec_mode, LC3_INT16 ccc_flag) +{ + LC3_INT16 n_pccw; + + if (fec_mode == 3) + { + n_pccw = (LC3_INT16) (0.080447761194030 * slot_bytes - 1.791044776119394 + 0.5); + } + else if (fec_mode == 4) + { + n_pccw = (LC3_INT16) (0.066492537313433 * slot_bytes - 1.970149253731338 + 0.5); + } + else + { + n_pccw = 0; + } + + if (ccc_flag == 1 || slot_bytes < 80) + { + n_pccw = 0; + } + + return n_pccw; +} + +FEC_STATIC LC3_INT16 get_total_crc_size(LC3_INT16 slot_bytes, LC3_INT16 fec_mode, LC3_INT16 pc_split) +{ + LC3_INT16 n_crc; + + n_crc = crc1_bytes_by_mode1[fec_mode]; + if (slot_bytes == 40) + { + n_crc = crc1_bytes_by_mode0[fec_mode]; + } + + if (pc_split > 0) + { + n_crc = n_crc + crc2_bytes_by_mode[fec_mode]; + } + + + + return n_crc; +} + +FEC_STATIC LC3_INT16 get_n_codewords(LC3_INT16 slot_bytes) +{ + return (2*slot_bytes + 14)/15; +} + +FEC_STATIC LC3_INT16 get_codeword_length(LC3_INT16 n_codewords, LC3_INT16 slot_nibbles, LC3_INT16 codeword_index) +{ + return (slot_nibbles - codeword_index - 1) / n_codewords + 1; +} + +/* Encoder */ + +LC3_INT16 fec_get_data_size(LC3_INT16 fec_mode, LC3_INT16 ccc_flag, LC3_INT16 slot_bytes) +/* not time critical */ +{ + LC3_INT16 n_codewords, payload_size; + + n_codewords = get_n_codewords(slot_bytes); + + assert(n_codewords == (2 * slot_bytes + RS16_CW_LEN_MAX - 1) / RS16_CW_LEN_MAX); + payload_size = slot_bytes; + + if (fec_mode > 0) + { + if (fec_mode == 1) + { + payload_size --; + } + else + { + payload_size -= (fec_mode - 1) * n_codewords; + } + if (slot_bytes == 40) + { + payload_size -= crc1_bytes_by_mode0[fec_mode]; + } + else + { + payload_size -= crc1_bytes_by_mode1[fec_mode]; + } + + if (ccc_flag == 0 && fec_mode > 2 && slot_bytes >= 80) + { + payload_size -= crc2_bytes_by_mode[fec_mode]; + } + } + + + + return payload_size; +} + +LC3_INT16 fec_get_n_pc(LC3_INT16 fec_mode, LC3_INT16 n_pccw, LC3_INT16 slot_bytes) +/* not time critical */ +{ + LC3_INT16 n_codewords, pc_split; + LC3_INT32 i; + + n_codewords = get_n_codewords(slot_bytes); + + assert(n_codewords == (2 * slot_bytes + RS16_CW_LEN_MAX - 1) / RS16_CW_LEN_MAX); + + pc_split = - 2*n_pccw*(fec_mode - 1); + + if (fec_mode == 1 || slot_bytes < 80) + { + pc_split = 0; + } + else + { + for (i = 0; i < n_pccw; i++) + { + pc_split += (2 * slot_bytes + i) / n_codewords; + } + } + + + + return pc_split; +} + +/* functions for EPMR handling */ +FEC_STATIC void dw0_bitswap(LC3_UINT8 *dw0, LC3_INT16 mode, LC3_INT16 slot_bytes) +/* swap epmr bits with bits that will be positioned at 30 and 32 in code word 0 */ +{ + LC3_UINT8 tmp; + LC3_INT32 ind0, ind1, position; + + position = get_codeword_length(get_n_codewords(slot_bytes), 2*slot_bytes, 0) - 1; + + if (slot_bytes == 40) + { + ind0 = 2*crc1_bytes_by_mode0[mode] - 1; + } + else + { + ind0 = 2*crc1_bytes_by_mode1[mode] - 1; + } + + ind1 = position - hamming_distance_by_mode0[mode] + 1; + + /* swap bits 2 and 3 of dw0[ind0] with bits 0 and 1 of dw0[ind1] */ + tmp = (dw0[ind0] >> 2) & 3; + dw0[ind0] = dw0[ind0] & 3; + dw0[ind0] = dw0[ind0] | ((dw0[ind1] & 3) << 2); + dw0[ind1] = dw0[ind1] & 12; + dw0[ind1] = dw0[ind1] | tmp; + + +} + +FEC_STATIC LC3PLUS_EpModeRequest cw0_get_epmr(LC3_UINT8 *cw0, LC3_INT16 position) +{ + return (LC3PLUS_EpModeRequest)(cw0[position] & 3); +} + +FEC_STATIC LC3PLUS_EpModeRequest dw0_get_epmr(LC3_UINT8 *dw0, LC3_INT16 mode, LC3_INT16 slot_size) +{ + LC3_INT32 ncrc1; + LC3PLUS_EpModeRequest epmr; + + ncrc1 = crc1_bytes_by_mode1[mode]; + + if (slot_size == 40) + { + ncrc1 = crc1_bytes_by_mode0[mode]; + } + + epmr = (LC3PLUS_EpModeRequest)(dw0[2 * ncrc1 - 1] >> 2); + + + + return epmr; +} + + +FEC_STATIC LC3_INT16 fec_data_preproc(LC3_INT16 mode, LC3_INT16 epmr, LC3_UINT8 *iobuf, LC3_UINT8 *cw_buf, LC3_INT16 data_bytes, + LC3_INT16 slot_bytes, LC3_INT16 pc_split) +{ + LC3_INT16 data_offset, n_crc1, n_crc2; + LC3_INT32 i, j; + + data_offset = 2*(slot_bytes - data_bytes); + + /* extract and reverse data*/ + j = 2*slot_bytes - 1; + for (i = 0; i < data_bytes; i++) + { + cw_buf[j--] = iobuf[i] & 15; + cw_buf[j--] = iobuf[i] >> 4; + } + + /* add crc hashes */ + if (slot_bytes == 40) + { + n_crc1 = crc1_bytes_by_mode0[mode]; + } + else + { + n_crc1 = crc1_bytes_by_mode1[mode]; + } + + if (pc_split > 0 && mode > 1) + { + n_crc2 = crc2_bytes_by_mode[mode]; + } + else + { + n_crc2 = 0; + } + + if (n_crc2) + { + crc2(cw_buf + data_offset + 2 * data_bytes - pc_split, pc_split, cw_buf + data_offset - 2 * n_crc2, n_crc2, 0); + } + if (n_crc1) + { + crc1(cw_buf + data_offset, 2 * data_bytes - pc_split, epmr, cw_buf + data_offset - 2 * (n_crc1 + n_crc2), n_crc1, + 0); + } + + data_offset -= 2* (n_crc1 + n_crc2); + + dw0_bitswap(cw_buf + data_offset, mode, slot_bytes); + + + + return data_offset; +} + +void fec_encoder(LC3_INT16 mode, LC3_INT16 epmr, LC3_UINT8 *iobuf, LC3_INT16 data_bytes, LC3_INT16 slot_bytes, LC3_INT16 n_pccw) +{ + LC3_INT16 n_codewords, codeword_length, hd, redundancy_nibbles, cw_offset, dw_offset, pc_split; + LC3_INT32 i, j; + LC3_UINT8 cw_buf[2 * FEC_SLOT_BYTES_MAX]; + + cw_offset = 0; + dw_offset = 0; + pc_split = 0; + + n_codewords = get_n_codewords(slot_bytes); + + /* some sanity checks */ + { + LC3_INT32 tmp = slot_bytes; + + assert((slot_bytes >= FEC_SLOT_BYTES_MIN && slot_bytes <= FEC_SLOT_BYTES_MAX) && + "fec_encoder: slot_bytes out of range"); + tmp -= mode == 1 ? 1 : n_codewords * (mode - 1); // reed solomon redundancy + tmp -= slot_bytes == 40 ? crc1_bytes_by_mode0[mode] : crc1_bytes_by_mode1[mode]; // crc1 + tmp -= (n_pccw > 0) && (mode > 1) ? crc2_bytes_by_mode[mode] : 0; // crc2 + assert(data_bytes == tmp && "fec_encoder: inconsistent payload size"); + assert(n_codewords - n_pccw >= 6); + } + + /* data preproc: re-ordering and hash extension */ + pc_split = fec_get_n_pc(mode, n_pccw, slot_bytes); + + dw_offset = fec_data_preproc(mode, epmr, iobuf, cw_buf, data_bytes, slot_bytes, pc_split); + + /* encoding of first data word*/ + hd = hamming_distance_by_mode0[mode]; + redundancy_nibbles = hd - 1; + codeword_length = get_codeword_length(n_codewords, 2 * slot_bytes, 0); + + assert(codeword_length == (2 * slot_bytes - 1) / n_codewords + 1); + + for (j = redundancy_nibbles; j < codeword_length; (j++, dw_offset++)) + { + cw_buf[j] = cw_buf[dw_offset]; + } + + rs16_enc(cw_buf, codeword_length, hd, mode, 1); + + cw_offset += codeword_length; + + /* encoding of remaining data words */ + hd = hamming_distance_by_mode1[mode]; + redundancy_nibbles = hd - 1; + + for (i = 1; i < n_codewords; i++) + { + codeword_length = get_codeword_length(n_codewords, 2*slot_bytes, i); + + for (j = redundancy_nibbles; j < codeword_length; (j++, dw_offset++)) + { + cw_buf[cw_offset + j] = cw_buf[dw_offset]; + } + + rs16_enc(cw_buf + cw_offset, codeword_length, hd, mode, i < 6); + + cw_offset += codeword_length; + } + + assert(cw_offset == 2 * slot_bytes && dw_offset == 2 * slot_bytes); + + fec_interleave_pack(iobuf, cw_buf, 2 * slot_bytes, n_codewords); + + +} + +FEC_STATIC void rs16_enc(LC3_UINT8 *iobuf, LC3_INT16 codeword_length, LC3_INT16 hamming_distance, LC3_INT16 fec_mode, + LC3_INT16 signal_mode) +/* expects (data polynomial) * x^(hamming_distance - 1) in iobuf */ +{ + LC3_UINT8 const *gp; + LC3_UINT8 shift_buffer[RS16_CW_LEN_MAX + 1], lc; + LC3_INT32 i, j, deg_gp; + + memset(shift_buffer, 0, sizeof(shift_buffer)); + gp = rs16_gp_by_hd[hamming_distance]; + deg_gp = hamming_distance - 1; + + if (hamming_distance > 1) + { + assert(codeword_length > deg_gp); + + /* initialize redundancy part to zero */ + memset(iobuf, 0, deg_gp); + + /* initialize shift_buffer */ + memmove(shift_buffer + 1, iobuf + codeword_length - deg_gp, deg_gp); + + /* calculate remainder */ + for (i = codeword_length - deg_gp - 1; i >= 0; i--) + { + shift_buffer[0] = iobuf[i]; + lc = shift_buffer[deg_gp] << 4; + + for (j = deg_gp - 1; j >= 0; j--) + { + shift_buffer[j + 1] = GF16_ADD(shift_buffer[j], GF16_MUL0(gp[j], lc)); + } + } + + /* add remainder to shifted data polynomial */ + for (i = 0; i < deg_gp; i++) + { + iobuf[i] = shift_buffer[i + 1]; + } + + /* add signaling polynomial */ + if (signal_mode) + { + assert(codeword_length > EP_SIG_POLY_DEG); + for (i = 0; i <= EP_SIG_POLY_DEG; i++) + { + iobuf[i] = GF16_ADD(iobuf[i], sig_polys[fec_mode - 1][i]); + } + } + } + + +} + +FEC_STATIC void fec_interleave_pack(LC3_UINT8 *out, LC3_UINT8 *in, LC3_INT16 n_nibbles, LC3_INT16 n_codewords) +{ + LC3_INT16 out_offset, cw_offset, codeword_length; + LC3_INT32 i, j; + + out_offset = 0; + cw_offset = 0; + + /* initialize output buffer to zero */ + memset(out, 0, n_nibbles >> 1); + + /* interleave and pack codewords */ + for (i = 0; i < n_codewords; i++) + { + codeword_length = get_codeword_length(n_codewords, n_nibbles, i); + + for (j = 0; j < codeword_length; j++) + { + out_offset = n_nibbles - 1 - j*n_codewords - i; + out[out_offset >> 1] |= in[cw_offset] << ((out_offset & 1) << 2); + cw_offset = cw_offset + 1; + } + } + + + assert(cw_offset == n_nibbles); +} + +/* Decoder */ +FEC_STATIC void fec_data_postproc(LC3_INT16 mode, LC3PLUS_EpModeRequest *epmr, LC3_UINT8 *obuf, LC3_INT16 data_bytes, LC3_UINT8 *cw_buf, + LC3_INT16 slot_bytes, LC3_INT16 pc_split, LC3_INT32 *bfi) +{ + LC3_INT16 i; + LC3_INT16 n_crc1, n_crc2; + LC3_INT16 cw_buf_len; + LC3PLUS_EpModeRequest tmp_epmr; + + n_crc1 = crc1_bytes_by_mode1[mode]; + if (slot_bytes == 40) + { + n_crc1 = crc1_bytes_by_mode0[mode]; + } + + n_crc2 = 0; + if (pc_split > 0) + { + n_crc2 = crc2_bytes_by_mode[mode]; + } + + assert(n_crc1 == (slot_bytes == 40 ? crc1_bytes_by_mode0[mode] : crc1_bytes_by_mode1[mode])); + assert(n_crc2 == ((pc_split > 0) && (mode > 1) ? crc2_bytes_by_mode[mode] : 0)); + + cw_buf_len = 2 * (data_bytes + n_crc1 + n_crc2); + + if ((mode - 1)) + { + /* reverse bit-swap */ + dw0_bitswap(cw_buf, mode, slot_bytes); + tmp_epmr = dw0_get_epmr(cw_buf, mode, slot_bytes); + + if (crc1(cw_buf + ((n_crc1 + n_crc2) << 1), ((data_bytes << 1) - pc_split), tmp_epmr, cw_buf, n_crc1, 1)) + { + *bfi = 1; + + return; + } + else + { + *epmr = tmp_epmr; + } + } + + if (pc_split > 0 && *bfi != 2) + { + if (crc2(cw_buf + (((data_bytes + (n_crc1 + n_crc2)) << 1) - pc_split), pc_split, + cw_buf + (n_crc1 << 1), n_crc2, 1)) + { + *bfi = 2; + } + } + + for (i = 0; i < data_bytes; i++) + { + obuf[i] = (LC3_UINT8)(cw_buf[cw_buf_len - 2 * i - 1] | (cw_buf[cw_buf_len - 2 * i - 2] << 4)); + } + + +} + +LC3_INT32 fec_decoder(LC3_UINT8 *iobuf, LC3_INT16 slot_bytes, LC3_INT32 *data_bytes, LC3PLUS_EpModeRequest *epmr, LC3_INT16 ccc_flag, LC3_INT16 *n_pccw, + LC3_INT32 *bfi, LC3_INT16 *be_bp_left, LC3_INT16 *be_bp_right, LC3_INT16 *n_pc, LC3_INT16 *m_fec) +{ + LC3_UINT8 cw_buf[2 * FEC_SLOT_BYTES_MAX]; + LC3_UINT8 array_of_trust[MAX_LEN]; + LC3_INT16 i, j; + LC3_INT16 cw_offset, dw_offset; + LC3_INT16 n_codewords, redundancy_nibbles, codeword_length; + LC3_INT16 mode, error_report; + LC3_INT16 n_crc; + LC3_INT16 first_bad_cw; + LC3_INT16 pc_split; + + UNUSED(n_crc); + + + if (*bfi == 1) + { + + return ERROR_REPORT_BEC_MASK; + } + + if (slot_bytes < FEC_SLOT_BYTES_MIN || slot_bytes > FEC_SLOT_BYTES_MAX) + { + *bfi = 1; + + return ERROR_REPORT_BEC_MASK; + } + + if (ccc_flag == 0) + { + *be_bp_left = -1; + *be_bp_right = -1; + } + + n_codewords = get_n_codewords(slot_bytes); + + /* extract and de-interleave nibbles */ + fec_deinterleave_unpack(cw_buf, iobuf, 2 * slot_bytes, n_codewords); + + /* mode detection and error correction */ + mode = rs16_detect_and_correct(cw_buf, 2 * slot_bytes, n_codewords, epmr, &error_report, bfi, array_of_trust, + ccc_flag, n_pccw); + + /* for normal slots the maximal number of bit errors is limited */ +#ifndef APPLY_MAX_ERRORS + if (slot_bytes == 40 && mode > 0) + { + if ((error_report & ERROR_REPORT_BEC_MASK) > low_br_max_bit_errors_by_mode[mode]) + { + error_report &= ERROR_REPORT_BEC_MASK; + mode = -1; + *bfi = 1; + } + else + { + if ((error_report & ERROR_REPORT_BEC_MASK) > low_br_max_bit_errors_by_mode[2]) + { + error_report &= ~ERROR_REPORT_EP2_OK; + } + if ((error_report & ERROR_REPORT_BEC_MASK) > low_br_max_bit_errors_by_mode[3]) + { + error_report &= ~ERROR_REPORT_EP3_OK; + } + } + } +#endif + + if (*bfi == 1) + { + *data_bytes = 0; + + + return error_report; + } + + /* initialization for decoding */ + *data_bytes = fec_get_data_size(mode, ccc_flag, slot_bytes); + pc_split = fec_get_n_pc(mode, *n_pccw, slot_bytes); + n_crc = get_total_crc_size(slot_bytes, mode, pc_split); + + /* decoding of first code word */ + redundancy_nibbles = hamming_distance_by_mode0[mode] - 1; + codeword_length = get_codeword_length(n_codewords, slot_bytes + slot_bytes, 0); + + dw_offset = 0; + cw_offset = 0; + + for (j = redundancy_nibbles; j < codeword_length; j++) + { + cw_buf[dw_offset++] = cw_buf[j]; + } + cw_offset = cw_offset + codeword_length; + + /* decoding of remaining code words */ + redundancy_nibbles = hamming_distance_by_mode1[mode] - 1; + + for (i = 1; i < n_codewords; i++) + { + codeword_length = get_codeword_length(n_codewords, slot_bytes + slot_bytes, i); + + for (j = redundancy_nibbles; j < codeword_length; j++) + { + cw_buf[dw_offset++] = cw_buf[j + cw_offset]; + } + + cw_offset = cw_offset + codeword_length; + } + + /* data postproc: hash validation and re-ordering */ + + fec_data_postproc(mode, epmr, iobuf, *data_bytes, cw_buf, slot_bytes, pc_split, bfi); + + if (*bfi == 1) + { + *data_bytes = 0; + + error_report &= ERROR_REPORT_BEC_MASK; + + + return error_report; + } + + if (*bfi == 2) + { + first_bad_cw = 0; + array_of_trust[*n_pccw] = 0; + while (array_of_trust[first_bad_cw] != 0) + { + first_bad_cw = first_bad_cw + 1; + } + if (first_bad_cw == *n_pccw) + { + /* this is the case when CRC failed */ + *be_bp_left = 0; + } + else + { + *be_bp_left = 4*fec_get_n_pc(mode, first_bad_cw, slot_bytes); + } + + for (i = *n_pccw - 1; i >= 0; i--) + { + if (!array_of_trust[i]) + { + break; + } + } + if (i < 0) + { + i = *n_pccw - 1; + } + *be_bp_right = 4*fec_get_n_pc(mode, i + 1, slot_bytes) - 1; + } + + if (ccc_flag == 0) + { + *n_pc = pc_split; + *m_fec = mode; + } + + + return error_report; +} + +FEC_STATIC void fec_deinterleave_unpack(LC3_UINT8 *out, LC3_UINT8 *in, LC3_INT16 n_nibbles, LC3_INT16 n_codewords) +{ + LC3_INT16 in_offset, out_offset, codeword_length; + LC3_INT32 i, j; + + in_offset = 0; + out_offset = 0; + + /* unpack nibbles in input buffer and deinterleave codewords */ + for (i = 0; i < n_codewords; i++) + { + codeword_length = get_codeword_length(n_codewords, n_nibbles, i); + for (j = 0; j < codeword_length; (j++, out_offset++)) + { + in_offset = n_nibbles - 1 - j*n_codewords - i; + out[out_offset] = (in[in_offset >> 1] >> ((in_offset & 1) << 2)) & 15; + } + } + + + assert(out_offset == n_nibbles); + +} + +FEC_STATIC LC3PLUS_EpModeRequest fec_estimate_epmr_from_cw0(LC3_UINT8 *cw0, LC3_INT8 *t, LC3_UINT8 *syndromes, LC3_UINT8 *elp, LC3_INT8 *deg_elp, + LC3_UINT8 *err_pos, LC3_UINT8 *err_symb, LC3_INT16 n_codewords, LC3_INT16 n_symb) +{ + LC3_INT32 epmr_lowest_risk_exp; + LC3_INT32 start, inc, i, n_candidates; + LC3_INT32 first_codeword_length; + LC3_INT32 mode_counter; + LC3PLUS_EpModeRequest epmr; + + epmr_lowest_risk_exp = 0; + first_codeword_length = get_codeword_length(n_codewords, n_symb, 0); + start = 2; + inc = 1; + n_candidates = 0; + + /* test if first code word decodes in mode 0 or 1 without error correction */ + if ((syndromes[SYNDROME_IDX(0, 0)] | syndromes[SYNDROME_IDX(0, 0) + 1]) == 0 || + (syndromes[SYNDROME_IDX(1, 0)] | syndromes[SYNDROME_IDX(1, 0) + 1]) == 0) + { + epmr_lowest_risk_exp = risk_table_f[1][0].exponent; + } + /* test if first code word decodes in mode 2 or 3 with lower risk */ + if (deg_elp[DEG_ELP_IDX(2, 0)] <= t[2]) + { + if (risk_table_f[2][deg_elp[DEG_ELP_IDX(2, 0)]].exponent <= -8) + { + n_candidates++; + start = 2; + } + } + + if (deg_elp[DEG_ELP_IDX(3, 0)] <= t[3]) + { + if (risk_table_f[3][deg_elp[DEG_ELP_IDX(3, 0)]].exponent <= -8) + { + n_candidates++; + start = 3; + } + } + + if (n_candidates > 1) + { + /* decide on order if mode 2 and 3 are considered */ + if (simple_float_cmp(risk_table_f[2][deg_elp[DEG_ELP_IDX(2, 0)]], risk_table_f[3][deg_elp[DEG_ELP_IDX(3, 0)]]) < + 0) + { + start = 2; + inc = 1; + } + else + { + start = 3; + inc = -1; + } + } + + for (mode_counter = start, i = 0; i < n_candidates; mode_counter += inc, i++) + { + if (risk_table_f[mode_counter][deg_elp[DEG_ELP_IDX(mode_counter, 0)]].exponent < epmr_lowest_risk_exp) + { + if (!rs16_factorize_elp(err_pos + ERR_POS_IDX(mode_counter, 0), elp + ELP_IDX(mode_counter, 0), + deg_elp[DEG_ELP_IDX(mode_counter, 0)], first_codeword_length - 1)) + { + /* code word is decodable with error correction */ + epmr_lowest_risk_exp = risk_table_f[mode_counter][deg_elp[DEG_ELP_IDX(mode_counter, 0)]].exponent; + + rs16_calculate_errors(err_symb + ERR_SYMB_IDX(mode_counter, 0), err_pos + ERR_POS_IDX(mode_counter, 0), + syndromes + SYNDROME_IDX(mode_counter, 0), deg_elp[DEG_ELP_IDX(mode_counter, 0)], + t[mode_counter]); + + for (i = 0; i < deg_elp[DEG_ELP_IDX(mode_counter, 0)]; i++) + { + cw0[err_pos[ERR_POS_IDX(mode_counter, 0) + i]] = GF16_ADD( + cw0[err_pos[ERR_POS_IDX(mode_counter, 0) + i]], err_symb[ERR_SYMB_IDX(mode_counter, 0) + i]); + } + break; + } + } + } + + epmr = cw0_get_epmr(cw0, first_codeword_length - 1); + + if (epmr_lowest_risk_exp > -16) + { + epmr += 4; + } + if (epmr_lowest_risk_exp > -8) + { + epmr += 4; + } + + + return epmr; +} + +FEC_STATIC LC3_INT32 rs16_detect_and_correct(LC3_UINT8 *iobuf, LC3_INT32 n_symb, LC3_INT32 n_codewords, LC3PLUS_EpModeRequest *epmr, LC3_INT16 *error_report, + LC3_INT32 *bfi, LC3_UINT8 *array_of_trust, LC3_INT32 ccc_flag, LC3_INT16 *n_pccw) +{ + + LC3_INT16 mode_broken[4]; + LC3_INT16 error_report_ep_ok[4]; + LC3_INT16 i, cw_counter, mode_counter, cw_offset; + LC3_INT16 codeword_length; + LC3_INT16 mode; + LC3_INT16 mode_candidates[4]; + LC3_INT16 n_mode_candidates; + LC3_INT16 broken_cw, n_broken_cw; + LC3_INT16 j, idx_min; + LC3_INT16 n_pccw0; + simple_float val_min_f; + LC3_INT16 tmp; + LC3_INT16 epmr_position; + simple_float dec_risk_f[FEC_N_MODES]; + simple_float risk_min_f; + simple_float ep_risk_thresh; + LC3_INT32 epmr_dec_fail_increment; + LC3_UINT8 const *hamming_distance; + LC3_UINT8 syndromes[FEC_TOTAL_SYNDROME_SIZE]; + LC3_UINT8 elp[FEC_TOTAL_ELP_SIZE]; + LC3_UINT8 err_pos[FEC_TOTAL_ERR_POS_SIZE]; + LC3_UINT8 err_symb[FEC_TOTAL_ERROR_SIZE]; + LC3_INT8 t[FEC_N_MODES]; + LC3_INT8 deg_elp[FEC_TOTAL_DEG_ELP_SIZE]; + LC3_UINT8 blacklist[FEC_N_MODES]; + LC3_INT32 rop; + + void (*syndr_calc[3])(LC3_UINT8 *, LC3_UINT8 *, LC3_INT32); + rop = 0; + + /* initialization */ + blacklist[0] = 0; + blacklist[1] = 0; + blacklist[2] = 0; + blacklist[3] = 0; + mode_broken[0] = 0; + mode_broken[1] = 0; + mode_broken[2] = 0; + mode_broken[3] = 0; + error_report_ep_ok[0] = ERROR_REPORT_EP1_OK; + error_report_ep_ok[1] = ERROR_REPORT_EP2_OK; + error_report_ep_ok[2] = ERROR_REPORT_EP3_OK; + error_report_ep_ok[3] = ERROR_REPORT_EP4_OK; + hamming_distance = &hamming_distance_by_mode0[1]; + mode = -1; + n_mode_candidates = 0; + risk_min_f.mantissa = SIMPLE_FLOAT_1_MANTISSA; + risk_min_f.exponent = 0; + + if (n_symb <= 80) + { + ep_risk_thresh.mantissa = EP_RISK_THRESH_NS_M; + ep_risk_thresh.exponent = EP_RISK_THRESH_NS_E; + } + else + { + ep_risk_thresh.mantissa = EP_RISK_THRESH_OS_M; + ep_risk_thresh.exponent = EP_RISK_THRESH_OS_E; + } + + syndr_calc[0] = &rs16_calculate_two_syndromes; + syndr_calc[1] = &rs16_calculate_four_syndromes; + syndr_calc[2] = &rs16_calculate_six_syndromes; + + for (i = 0; i < FEC_N_MODES; i++) + { + t[i] = (hamming_distance[i] -1)/2; + } + + *error_report = 0; + *bfi = 0; + + /* mode detection (stage 1) */ + codeword_length = get_codeword_length(n_codewords, n_symb, 0); + + epmr_position = codeword_length - 1; + + rs16_calculate_two_syndromes(syndromes + SYNDROME_IDX(0, 0), iobuf, codeword_length - 1); + + if ((syndromes[0 + SYNDROME_IDX(0, 0)] | syndromes[1 + SYNDROME_IDX(0, 0)]) == 0) + { + + /* data validation for fec mode 1 */ + *epmr = cw0_get_epmr(iobuf, epmr_position); + + dw0_bitswap(iobuf + 2, 1, n_symb / 2); + + if (!crc1(iobuf + 8, n_symb - 8, *epmr, iobuf + 2, 3, 1)) + { + *error_report |= ERROR_REPORT_ALL_OK; + mode = 0; + + + rop = mode + 1; + goto CLEANUP; + } + else + { + /* reverse bit swap */ + dw0_bitswap(iobuf + 2, 1, n_symb / 2); + + *epmr += 4; + } + } + + blacklist[0] = 1; + + /* mode detection (stage 2) */ + + /* calculate syndromes of code words 0 to 5 and modes 1 to 3 */ + cw_offset = 0; + + for (cw_counter = 0; cw_counter < 6; cw_counter++) + { + codeword_length = get_codeword_length(n_codewords, n_symb, cw_counter); + + rs16_calculate_six_syndromes(syndromes + SYNDROME_IDX(1, cw_counter), iobuf + cw_offset, + codeword_length - 1); + + cw_offset += codeword_length; + + for (mode_counter = FEC_N_MODES - 1; mode_counter >= 1; mode_counter--) + { + for (i = 0; i < hamming_distance[mode_counter] - 1; i++) + { + syndromes[SYNDROME_IDX(mode_counter, cw_counter) + i] = GF16_ADD( + syndromes[SYNDROME_IDX(1, cw_counter) + i], sig_poly_syndr[mode_counter][i]); + } + } + } + + /* check for valid code words */ + for (mode_counter = 1; mode_counter < FEC_N_MODES; mode_counter++) + { + n_broken_cw = 0; + for (cw_counter = 0; cw_counter < 6; cw_counter++) + { + broken_cw = 0; + for (i = 0; i < hamming_distance[mode_counter] - 1; i++) + { + broken_cw |= syndromes[SYNDROME_IDX(mode_counter, cw_counter) + i]; + } + if (broken_cw != 0) + { + n_broken_cw ++; + } + } + + if (n_broken_cw == 0) + { + mode = mode_counter; + cw_offset = 0; + + *epmr = cw0_get_epmr(iobuf, epmr_position); + + for (cw_counter = 0; cw_counter < 6; cw_counter++) + { + codeword_length = get_codeword_length(n_codewords, n_symb, cw_counter); + for (i = 0; i <= EP_SIG_POLY_DEG; i++) + { + iobuf[cw_offset + i] = GF16_ADD(iobuf[cw_offset + i], sig_polys[mode][i]); + } + cw_offset += codeword_length; + } + } + } + + if (mode < 0) /* mode hasn't been detected so far -> errors occurred in transmission */ + { + /* calculate error locator polynomials for code words 0 to 5 */ + for (mode_counter = 1; mode_counter < FEC_N_MODES; mode_counter++) + { + for (cw_counter = 0; cw_counter < 6; cw_counter++) + { + deg_elp[DEG_ELP_IDX(mode_counter, cw_counter)] = rs16_calculate_elp( + elp + ELP_IDX(mode_counter, cw_counter), syndromes + SYNDROME_IDX(mode_counter, cw_counter), + t[mode_counter]); + if (deg_elp[DEG_ELP_IDX(mode_counter, cw_counter)] > t[mode_counter]) + { + blacklist[mode_counter] = 1; + break; + } + } + } + + /* risk analysis for mode candidate selection */ + for (mode_counter = 1; mode_counter < FEC_N_MODES; mode_counter++) + { + dec_risk_f[mode_counter].mantissa = SIMPLE_FLOAT_1_MANTISSA; + dec_risk_f[mode_counter].exponent = 0; + + if (blacklist[mode_counter] == 0) + { + for (cw_counter = 0; cw_counter < 6; cw_counter++) + { + dec_risk_f[mode_counter] = simple_float_mul( + dec_risk_f[mode_counter], + risk_table_f[mode_counter][deg_elp[DEG_ELP_IDX(mode_counter, cw_counter)]]); + } + + if (simple_float_cmp(dec_risk_f[mode_counter], ep_risk_thresh) <= 0) + { + mode_candidates[n_mode_candidates++] = mode_counter; + } + + if (simple_float_cmp(dec_risk_f[mode_counter], risk_min_f) < 0) + { + risk_min_f = dec_risk_f[mode_counter]; + } + } + } + assert(n_mode_candidates <= 4); // suppress false gcc warning when OPTIM=3 + + /* sort mode candidates by risk */ + for (i = 0; i < n_mode_candidates; i++) + { + idx_min = i; + val_min_f = dec_risk_f[mode_candidates[i]]; + + for (j = i + 1; j < n_mode_candidates; j++) + { + if (simple_float_cmp(dec_risk_f[mode_candidates[j]], val_min_f) < 0) + { + val_min_f = dec_risk_f[mode_candidates[j]]; + idx_min = j; + } + } + + if (idx_min > i) + { + tmp = mode_candidates[i]; + mode_candidates[i] = mode_candidates[idx_min]; + mode_candidates[idx_min] = tmp; + } + } + + /* try out candidate modes */ + for (i = 0; i < n_mode_candidates; i++) + { + mode = mode_candidates[i]; + + for (cw_counter = 0; cw_counter < 6; cw_counter++) + { + codeword_length = get_codeword_length(n_codewords, n_symb, cw_counter); + + if (deg_elp[DEG_ELP_IDX(mode, cw_counter)]) + { + if (rs16_factorize_elp(err_pos + ERR_POS_IDX(mode, cw_counter), elp + ELP_IDX(mode, cw_counter), + deg_elp[DEG_ELP_IDX(mode, cw_counter)], codeword_length - 1)) + { + /* elp did not split into distinct linear factors or error position was out of range */ + mode = -1; + break; + } + } + } + if (mode > 0) + { + /* decodable mode with lowest risk has been found */ + break; + } + } + + if (mode < 0) + { + /* no decodable mode has been found */ + *error_report = ERROR_REPORT_BEC_MASK; + *bfi = 1; + mode = -1; + + *epmr = fec_estimate_epmr_from_cw0(iobuf, t, syndromes, elp, deg_elp, err_pos, err_symb, n_codewords, + n_symb); + + + rop = mode; + goto CLEANUP; + } + + /* perform error correction */ + cw_offset = 0; + *error_report = 0; + for (cw_counter = 0; cw_counter < 6; cw_counter++) + { + codeword_length = get_codeword_length(n_codewords, n_symb, cw_counter); + + if (deg_elp[DEG_ELP_IDX(mode, cw_counter)]) + { + rs16_calculate_errors( + err_symb + ERR_SYMB_IDX(mode, cw_counter), err_pos + ERR_POS_IDX(mode, cw_counter), + syndromes + SYNDROME_IDX(mode, cw_counter), deg_elp[DEG_ELP_IDX(mode, cw_counter)], t[mode]); + + /* correct errors and sum up number of corrected bits */ + for (i = 0; i < deg_elp[DEG_ELP_IDX(mode, cw_counter)]; i++) + { + iobuf[err_pos[ERR_POS_IDX(mode, cw_counter) + i] + cw_offset] = + GF16_ADD(iobuf[err_pos[ERR_POS_IDX(mode, cw_counter) + i] + cw_offset], + err_symb[ERR_SYMB_IDX(mode, cw_counter) + i]); + *error_report += rs16_bit_count_table[err_symb[ERR_SYMB_IDX(mode, cw_counter) + i]]; + } + + for (i = 0; i < mode; i ++) + { + if(deg_elp[DEG_ELP_IDX(mode, cw_counter)] > i) + { + mode_broken[i] = 1; + } + } + + } + + for (i = 0; i <= EP_SIG_POLY_DEG; i++) + { + iobuf[cw_offset + i] = GF16_ADD(iobuf[cw_offset + i], sig_polys[mode][i]); + } + cw_offset += codeword_length; + } + + /* set epmr according to risk value of cw0 */ + epmr_dec_fail_increment = 8; + + if (risk_table_f[mode][deg_elp[DEG_ELP_IDX(mode, 0)]].exponent <= -8) + { + epmr_dec_fail_increment -= 4; + } + if (risk_table_f[mode][deg_elp[DEG_ELP_IDX(mode, 0)]].exponent <= -16) + { + epmr_dec_fail_increment -= 4; + } + + *epmr = (LC3PLUS_EpModeRequest)(cw0_get_epmr(iobuf, epmr_position) + epmr_dec_fail_increment); + } + + /* mode has been successfully detected -> now check and try to correct remaining code words*/ + *n_pccw = fec_get_n_pccw(n_symb / 2, mode + 1, ccc_flag); + if (ccc_flag == 0) + { + n_pccw0 = fec_get_n_pccw(n_symb / 2, mode + 1, ccc_flag); + *n_pccw = n_pccw0; + } + else + { + n_pccw0 = 0; + } + + for (cw_counter = 6; cw_counter < n_codewords; cw_counter++) + { + /* usual error correction scheme: syndromes -> elp's, errors, etc. */ + codeword_length = get_codeword_length(n_codewords, n_symb, cw_counter); + array_of_trust[n_codewords - 1 - cw_counter] = 1; + + syndr_calc[t[mode] - 1](syndromes, iobuf + cw_offset, codeword_length -1); + + deg_elp[0] = rs16_calculate_elp(elp, syndromes, t[mode]); + + for (i = 0; i < mode; i ++) + { + if (deg_elp[0] > i) + { + mode_broken[i] = 1; + } + } + + if (deg_elp[0] > t[mode]) + { + for (i = 0; i < 4; i ++) + { + mode_broken[i] = 1; + } + cw_offset += codeword_length; + if (cw_counter < n_codewords - n_pccw0) + { + *error_report = ERROR_REPORT_BEC_MASK; + mode = -1; + *bfi = 1; + break; + } + else + { + *bfi = 2; + array_of_trust[n_codewords - 1 - cw_counter] = 0; + continue; + } + } + + if (deg_elp[0]) + { + if (rs16_factorize_elp(err_pos, elp, deg_elp[0], codeword_length - 1)) + { + cw_offset += codeword_length; + for (i = 0; i < 4; i ++) + { + mode_broken[i] = 1; + } + if (cw_counter < n_codewords - n_pccw0) + { + *error_report = ERROR_REPORT_BEC_MASK; + mode = -1; + *bfi = 1; + + break; + } + else + { + *bfi = 2; + array_of_trust[n_codewords - 1 - cw_counter] = 0; + continue; + } + } + + rs16_calculate_errors(err_symb, err_pos, syndromes, deg_elp[0], t[mode]); + + /* correct errors and sum up number of corrected bits */ + for (i = 0; i < deg_elp[0]; i++) + { + iobuf[err_pos[i] + cw_offset] = GF16_ADD(iobuf[err_pos[i] + cw_offset], err_symb[i]); + *error_report += rs16_bit_count_table[err_symb[i]]; + } + } + cw_offset += codeword_length; + if (risk_table_f[mode][deg_elp[0]].exponent > -16) + { + array_of_trust[n_codewords - 1 - cw_counter] = 0; + } + } + + *error_report &= ERROR_REPORT_BEC_MASK; + for (i = 0; i < 4; i ++) + { + if (!mode_broken[i]) + { + *error_report |= error_report_ep_ok[i]; + } + } + + if (mode >= 0) + { + rop = mode + 1; + } else { + rop = -1; + } + + + +CLEANUP: + return rop; +} + +FEC_STATIC void rs16_calculate_six_syndromes(LC3_UINT8 *syndromes, LC3_UINT8 *cw, LC3_INT32 cw_poly_deg) +{ + LC3_INT32 i; + LC3_UINT8 buffer[15]; + + assert(cw_poly_deg >= 12); + + for (i = 0; i <= cw_poly_deg; i++) + { + buffer[i] = cw[i]; + } + + syndromes[0] = buffer[0]; + syndromes[1] = buffer[0]; + syndromes[2] = buffer[0]; + syndromes[3] = buffer[0]; + syndromes[4] = buffer[0]; + syndromes[5] = buffer[0]; + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[1], 32)); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[1], 64)); + syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[1], 128)); + syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[1], 48)); + syndromes[4] = GF16_ADD(syndromes[4], GF16_MUL0(buffer[1], 96)); + syndromes[5] = GF16_ADD(syndromes[5], GF16_MUL0(buffer[1], 192)); + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[2], 64)); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[2], 48)); + syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[2], 192)); + syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[2], 80)); + syndromes[4] = GF16_ADD(syndromes[4], GF16_MUL0(buffer[2], 112)); + syndromes[5] = GF16_ADD(syndromes[5], GF16_MUL0(buffer[2], 240)); + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[3], 128)); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[3], 192)); + syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[3], 160)); + syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[3], 240)); + syndromes[4] = GF16_ADD(syndromes[4], GF16_MUL0(buffer[3], 16)); + syndromes[5] = GF16_ADD(syndromes[5], GF16_MUL0(buffer[3], 128)); + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[4], 48)); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[4], 80)); + syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[4], 240)); + syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[4], 32)); + syndromes[4] = GF16_ADD(syndromes[4], GF16_MUL0(buffer[4], 96)); + syndromes[5] = GF16_ADD(syndromes[5], GF16_MUL0(buffer[4], 160)); + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[5], 96)); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[5], 112)); + syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[5], 16)); + syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[5], 96)); + syndromes[4] = GF16_ADD(syndromes[4], GF16_MUL0(buffer[5], 112)); + syndromes[5] = GF16_ADD(syndromes[5], GF16_MUL0(buffer[5], 16)); + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[6], 192)); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[6], 240)); + syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[6], 128)); + syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[6], 160)); + syndromes[4] = GF16_ADD(syndromes[4], GF16_MUL0(buffer[6], 16)); + syndromes[5] = GF16_ADD(syndromes[5], GF16_MUL0(buffer[6], 192)); + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[7], 176)); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[7], 144)); + syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[7], 192)); + syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[7], 208)); + syndromes[4] = GF16_ADD(syndromes[4], GF16_MUL0(buffer[7], 96)); + syndromes[5] = GF16_ADD(syndromes[5], GF16_MUL0(buffer[7], 240)); + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[8], 80)); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[8], 32)); + syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[8], 160)); + syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[8], 64)); + syndromes[4] = GF16_ADD(syndromes[4], GF16_MUL0(buffer[8], 112)); + syndromes[5] = GF16_ADD(syndromes[5], GF16_MUL0(buffer[8], 128)); + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[9], 160)); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[9], 128)); + syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[9], 240)); + syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[9], 192)); + syndromes[4] = GF16_ADD(syndromes[4], GF16_MUL0(buffer[9], 16)); + syndromes[5] = GF16_ADD(syndromes[5], GF16_MUL0(buffer[9], 160)); + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[10], 112)); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[10], 96)); + syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[10], 16)); + syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[10], 112)); + syndromes[4] = GF16_ADD(syndromes[4], GF16_MUL0(buffer[10], 96)); + syndromes[5] = GF16_ADD(syndromes[5], GF16_MUL0(buffer[10], 16)); + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[11], 224)); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[11], 176)); + syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[11], 128)); + syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[11], 144)); + syndromes[4] = GF16_ADD(syndromes[4], GF16_MUL0(buffer[11], 112)); + syndromes[5] = GF16_ADD(syndromes[5], GF16_MUL0(buffer[11], 192)); + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[12], 240)); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[12], 160)); + syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[12], 192)); + syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[12], 128)); + syndromes[4] = GF16_ADD(syndromes[4], GF16_MUL0(buffer[12], 16)); + syndromes[5] = GF16_ADD(syndromes[5], GF16_MUL0(buffer[12], 240)); + + if (cw_poly_deg >= 13) + { + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[13], 208)); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[13], 224)); + syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[13], 160)); + syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[13], 176)); + syndromes[4] = GF16_ADD(syndromes[4], GF16_MUL0(buffer[13], 96)); + syndromes[5] = GF16_ADD(syndromes[5], GF16_MUL0(buffer[13], 128)); + } + + if (cw_poly_deg >= 14) + { + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[14], 144)); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[14], 208)); + syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[14], 240)); + syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[14], 224)); + syndromes[4] = GF16_ADD(syndromes[4], GF16_MUL0(buffer[14], 112)); + syndromes[5] = GF16_ADD(syndromes[5], GF16_MUL0(buffer[14], 160)); + } + + +} + +FEC_STATIC void rs16_calculate_four_syndromes(LC3_UINT8 *syndromes, LC3_UINT8 *cw, LC3_INT32 cw_poly_deg) +{ + LC3_INT32 i; + LC3_UINT8 buffer[15]; + + assert(cw_poly_deg >= 12); + + for (i = 0; i <= cw_poly_deg; i++) + { + buffer[i] = cw[i]; + } + + syndromes[0] = buffer[0]; + syndromes[1] = buffer[0]; + syndromes[2] = buffer[0]; + syndromes[3] = buffer[0]; + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[1], 32)); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[1], 64)); + syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[1], 128)); + syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[1], 48)); + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[2], 64)); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[2], 48)); + syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[2], 192)); + syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[2], 80)); + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[3], 128)); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[3], 192)); + syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[3], 160)); + syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[3], 240)); + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[4], 48)); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[4], 80)); + syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[4], 240)); + syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[4], 32)); + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[5], 96)); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[5], 112)); + syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[5], 16)); + syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[5], 96)); + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[6], 192)); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[6], 240)); + syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[6], 128)); + syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[6], 160)); + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[7], 176)); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[7], 144)); + syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[7], 192)); + syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[7], 208)); + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[8], 80)); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[8], 32)); + syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[8], 160)); + syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[8], 64)); + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[9], 160)); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[9], 128)); + syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[9], 240)); + syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[9], 192)); + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[10], 112)); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[10], 96)); + syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[10], 16)); + syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[10], 112)); + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[11], 224)); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[11], 176)); + syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[11], 128)); + syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[11], 144)); + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[12], 240)); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[12], 160)); + syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[12], 192)); + syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[12], 128)); + + if (cw_poly_deg >= 13) + { + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[13], 208)); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[13], 224)); + syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[13], 160)); + syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[13], 176)); + } + + if (cw_poly_deg >= 14) + { + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[14], 144)); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[14], 208)); + syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[14], 240)); + syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[14], 224)); + } + + +} + +FEC_STATIC void rs16_calculate_two_syndromes(LC3_UINT8 *syndromes, LC3_UINT8 *cw, LC3_INT32 cw_poly_deg) +{ + LC3_INT32 i; + LC3_UINT8 buffer[15]; + + assert(cw_poly_deg >= 12); + + for (i = 0; i <= cw_poly_deg; i++) + { + buffer[i] = cw[i]; + } + + syndromes[0] = buffer[0]; + syndromes[1] = buffer[0]; + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[1], 32)); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[1], 64)); + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[2], 64)); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[2], 48)); + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[3], 128)); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[3], 192)); + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[4], 48)); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[4], 80)); + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[5], 96)); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[5], 112)); + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[6], 192)); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[6], 240)); + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[7], 176)); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[7], 144)); + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[8], 80)); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[8], 32)); + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[9], 160)); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[9], 128)); + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[10], 112)); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[10], 96)); + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[11], 224)); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[11], 176)); + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[12], 240)); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[12], 160)); + + if (cw_poly_deg >= 13) + { + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[13], 208)); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[13], 224)); + } + + if (cw_poly_deg >= 14) + { + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[14], 144)); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[14], 208)); + } + + +} + +FEC_STATIC LC3_INT8 rs16_calculate_elp(LC3_UINT8 *elp, LC3_UINT8 *syndromes, LC3_INT16 t) +/* calculates error locator polynomial vie Petterson's algorithm */ +{ + LC3_INT8 ret; + LC3_UINT8 det, det_inv, aux, all_s, *s; + LC3_UINT8 s22, s33, s44, s13, s14, s15; + LC3_UINT8 s23, s24, s25, s34, s35; + LC3_UINT8 a, b, c, d, e, f; + + ret = 0; + all_s = 0; + s = syndromes; + elp[0] = 1; + memset(elp + 1, 0, 3); + + switch (t) + { + case 3: + { + /* check for errors */ + all_s = s[0] | s[1] | s[2] | s[3] | s[4] | s[5]; + + if (all_s == 0) + { + break; + } + + /* assume 3 errors */ + s22 = GF16_MUL(s[1], s[1]); + s33 = GF16_MUL(s[2], s[2]); + s44 = GF16_MUL(s[3], s[3]); + s13 = GF16_MUL(s[0], s[2]); + + det = GF16_ADD(GF16_ADD(GF16_MUL(s13, s[4]), GF16_MUL(s44, s[0])), + GF16_ADD(GF16_MUL(s22, s[4]), GF16_MUL(s33, s[2]))); + + if (det) + { + det_inv = gf16_inv_table[det] << 4; + + s14 = GF16_MUL(s[0], s[3]); + s15 = GF16_MUL(s[0], s[4]); + + s23 = GF16_MUL(s[1], s[2]); + s24 = GF16_MUL(s[1], s[3]); + s25 = GF16_MUL(s[1], s[4]); + + s34 = GF16_MUL(s[2], s[3]); + s35 = GF16_MUL(s[2], s[4]); + + a = GF16_ADD(s35, s44) << 4; + b = GF16_ADD(s15, s33) << 4; + c = GF16_ADD(s13, s22) << 4; + d = GF16_ADD(s34, s25) << 4; + e = GF16_ADD(s23, s14) << 4; + f = GF16_ADD(s24, s33) << 4; + + aux = GF16_ADD(GF16_ADD(GF16_MUL0(a, s[3]), GF16_MUL0(d, s[4])), GF16_MUL0(f, s[5])); + elp[3] = GF16_MUL0(aux, det_inv); + + aux = GF16_ADD(GF16_ADD(GF16_MUL0(d, s[3]), GF16_MUL0(b, s[4])), GF16_MUL0(e, s[5])); + elp[2] = GF16_MUL0(aux, det_inv); + + aux = GF16_ADD(GF16_ADD(GF16_MUL0(f, s[3]), GF16_MUL0(e, s[4])), GF16_MUL0(c, s[5])); + elp[1] = GF16_MUL0(aux, det_inv); + + if (elp[3] == 0) + { + ret = t+1; + } + else + { + ret = 3; + } + break; + } + + /* assume two errors */ + det = GF16_ADD(GF16_MUL(syndromes[0], syndromes[2]), GF16_MUL(syndromes[1], syndromes[1])); + + if (det) + { + det_inv = gf16_inv_table[det] << 4; + + aux = GF16_ADD(GF16_MUL(syndromes[1], syndromes[2]), GF16_MUL(syndromes[0], syndromes[3])); + elp[1] = GF16_MUL0(aux, det_inv); + + aux = GF16_ADD(GF16_MUL(syndromes[2], syndromes[2]), GF16_MUL(syndromes[1], syndromes[3])); + elp[2] = GF16_MUL0(aux, det_inv); + + /* check remaining LSF relations */ + aux = GF16_ADD(GF16_ADD(GF16_MUL(elp[2], s[2]), GF16_MUL(elp[1], s[3])), s[4]) + | GF16_ADD(GF16_ADD(GF16_MUL(elp[2], s[3]), GF16_MUL(elp[1], s[4])), s[5]); + + aux |= elp[2] == 0; + + if (aux != 0) + { + ret = t + 1; + } + else + { + ret = 2; + } + break; + } + + /* assume one error */ + if (syndromes[0] != 0) + { + elp[1] = GF16_MUL(syndromes[1], gf16_inv_table[syndromes[0]]); + + /* check remaining LSF relations */ + aux = GF16_ADD(GF16_MUL(elp[1], s[1]), s[2]) + | GF16_ADD(GF16_MUL(elp[1], s[2]), s[3]) + | GF16_ADD(GF16_MUL(elp[1], s[3]), s[4]) + | GF16_ADD(GF16_MUL(elp[1], s[4]), s[5]); + + aux |= elp[1] == 0; + + if (aux != 0) + { + ret = t + 1; + } + else + { + ret = 1; + } + break; + } + + ret = t + 1; + break; + } + case 2: + { + all_s = s[0] | s[1] | s[2] | s[3]; + + if (all_s == 0) + { + break; + } + + /* assume two errors */ + det = GF16_ADD(GF16_MUL(syndromes[0], syndromes[2]), GF16_MUL(syndromes[1], syndromes[1])); + + if (det) + { + det_inv = gf16_inv_table[det] << 4; + + aux = GF16_ADD(GF16_MUL(syndromes[1], syndromes[2]), GF16_MUL(syndromes[0], syndromes[3])); + elp[1] = GF16_MUL0(aux, det_inv); + + aux = GF16_ADD(GF16_MUL(syndromes[2], syndromes[2]), GF16_MUL(syndromes[1], syndromes[3])); + elp[2] = GF16_MUL0(aux, det_inv); + + if (elp[2] == 0) + { + ret = t + 1; + } + else + { + ret = 2; + } + break; + } + + /* assume one error */ + if (syndromes[0] != 0) + { + elp[1] = GF16_MUL(syndromes[1], gf16_inv_table[syndromes[0]]); + + /* check remaining LSF relation */ + aux = GF16_ADD(GF16_MUL(elp[1], s[1]), s[2]) | GF16_ADD(GF16_MUL(elp[1], s[2]), s[3]); + aux |= elp[1] == 0; + + if (aux != 0) + { + ret = t + 1; + } + else + { + ret = 1; + } + break; + } + + ret = t + 1; + break; + } + case 1: + { + all_s = s[0] | s[1]; + + if (all_s == 0) + { + break; + } + + if (syndromes[0] != 0) + { + elp[1] = GF16_MUL(syndromes[1], gf16_inv_table[syndromes[0]]); + if (elp[1] == 0) + { + ret = t + 1; + } + else + { + ret = 1; + } + break; + } + + ret = t + 1; + break; + } + default: assert(0 && "calculating elp of this degree not implemented"); + } + + + return ret; +} + +FEC_STATIC LC3_INT16 rs16_factorize_elp(LC3_UINT8 *err_pos, LC3_UINT8 *elp, LC3_INT16 deg_elp, LC3_INT16 max_pos) +{ + LC3_UINT8 beta, gamma; + LC3_INT16 zeros, err_pos0, err_pos1, err_pos2, ret; + + beta = 0; + gamma = 0; + zeros = 0; + ret = 0; + + switch (deg_elp) + { + case 0: break; + + case 1: + err_pos0 = gf16_log_g[elp[1]]; + if (err_pos0 > max_pos) + { + ret = 1; + break; + } + + err_pos[0] = (LC3_UINT8)err_pos0; + break; + + case 2: + zeros = rs16_elp_deg2_table[elp[1] | (elp[2] << 4)]; + if (zeros == 0) + { + + return 1; + } + + err_pos0 = zeros & 15; + err_pos1 = (zeros >> 4) & 15; + + if (err_pos0 > max_pos || err_pos1 > max_pos) + { + ret = 1; + break; + } + + err_pos[0] = (LC3_UINT8)err_pos0; + err_pos[1] = (LC3_UINT8)err_pos1; + break; + + case 3: + /* beta = a*a + b, gamma = a*b + c */ + beta = GF16_ADD(GF16_MUL(elp[1], elp[1]), elp[2]); + gamma = GF16_ADD(GF16_MUL(elp[1], elp[2]), elp[3]); + zeros = rs16_elp_deg3_table[beta | gamma << 4]; + + if (zeros == 0) + /* elp does not split over GF(16) or has multiple zeros */ + { + ret = 1; + break; + } + + /* remove shift from zeros */ + err_pos0 = GF16_ADD(zeros & 15, elp[1]); + err_pos1 = GF16_ADD((zeros >> 4) & 15, elp[1]); + err_pos2 = GF16_ADD((zeros >> 8) & 15, elp[1]); + + if (err_pos0 == 0 || err_pos1 == 0 || err_pos2 == 0) + { + + return 1; + } + + err_pos0 = gf16_log_g[err_pos0]; + err_pos1 = gf16_log_g[err_pos1]; + err_pos2 = gf16_log_g[err_pos2]; + + if (err_pos0 > max_pos || err_pos1 > max_pos || err_pos2 > max_pos) + { + ret = 1; + break; + } + + err_pos[0] = (LC3_UINT8)err_pos0; + err_pos[1] = (LC3_UINT8)err_pos1; + err_pos[2] = (LC3_UINT8)err_pos2; + + break; + + default: assert(0 && "invalid degree in rs16_error_locator"); + } + + + return ret; +} + +FEC_STATIC void rs16_calculate_errors(LC3_UINT8 *err_symb, LC3_UINT8 *err_pos, LC3_UINT8 *syndromes, LC3_INT8 deg_elp, LC3_INT8 t) +{ + LC3_UINT8 det_inv; + LC3_UINT8 x0, x1, x2; + LC3_UINT8 x0sq, x1sq, x2sq; + LC3_UINT8 c0, c1, c2; + LC3_UINT8 s0, s1, s2; + LC3_UINT8 tmp; + + UNUSED(t); + + assert(deg_elp <= t); + + switch (deg_elp) + { + case 0: break; + + case 1: + err_symb[0] = GF16_MUL(gf16_g_pow[15 - err_pos[0]], syndromes[0]); + + break; + + case 2: + s0 = (LC3_UINT8) (syndromes[0] << 4); + s1 = (LC3_UINT8) (syndromes[1] << 4); + + x0 = gf16_g_pow[err_pos[0]]; + x1 = gf16_g_pow[err_pos[1]]; + + x0sq = GF16_MUL(x0, x0); + x1sq = GF16_MUL(x1, x1); + + tmp = GF16_ADD(GF16_MUL(x0sq, x1), GF16_MUL(x1sq, x0)); + det_inv = gf16_inv_table[tmp] << 4; + + tmp = GF16_ADD(GF16_MUL0(x1sq, s0), GF16_MUL0(x1, s1)); + err_symb[0] = GF16_MUL0(tmp, det_inv); + + tmp = GF16_ADD(GF16_MUL0(x0sq, s0), GF16_MUL0(x0, s1)); + err_symb[1] = GF16_MUL0(tmp, det_inv); + + break; + + case 3: + s0 = syndromes[0] << 4; + s1 = syndromes[1] << 4; + s2 = syndromes[2] << 4; + + x0 = gf16_g_pow[err_pos[0]]; + x1 = gf16_g_pow[err_pos[1]]; + x2 = gf16_g_pow[err_pos[2]]; + + x0sq = GF16_MUL(x0, x0); + x1sq = GF16_MUL(x1, x1); + x2sq = GF16_MUL(x2, x2); + + tmp = GF16_MUL(GF16_ADD(x1, x0), GF16_ADD(x2, x0)); + tmp = GF16_MUL(GF16_ADD(x2, x1), tmp); + det_inv = gf16_inv_table[tmp] << 4; + + c0 = GF16_ADD(GF16_MUL(x1, x2sq), GF16_MUL(x2, x1sq)); + c1 = GF16_ADD(x2sq, x1sq); + c2 = GF16_ADD(x2, x1); + + err_symb[0] = GF16_ADD(GF16_ADD(GF16_MUL0(c0, s0), GF16_MUL0(c1, s1)), GF16_MUL0(c2, s2)); + + c0 = GF16_ADD(GF16_MUL(x0, x2sq), GF16_MUL(x2, x0sq)); + c1 = GF16_ADD(x2sq, x0sq); + c2 = GF16_ADD(x2, x0); + + err_symb[1] = GF16_ADD(GF16_ADD(GF16_MUL0(c0, s0), GF16_MUL0(c1, s1)), GF16_MUL0(c2, s2)); + + c0 = GF16_ADD(GF16_MUL(x0, x1sq), GF16_MUL(x1, x0sq)); + c1 = GF16_ADD(x1sq, x0sq); + c2 = GF16_ADD(x1, x0); + + err_symb[2] = GF16_ADD(GF16_ADD(GF16_MUL0(c0, s0), GF16_MUL0(c1, s1)), GF16_MUL0(c2, s2)); + + tmp = GF16_MUL0(err_symb[0], det_inv); + err_symb[0] = GF16_MUL(tmp, gf16_inv_table[x0]); + + tmp = GF16_MUL0(err_symb[1], det_inv); + err_symb[1] = GF16_MUL(tmp, gf16_inv_table[x1]); + + tmp = GF16_MUL0(err_symb[2], det_inv); + err_symb[2] = GF16_MUL(tmp, gf16_inv_table[x2]); + + break; + + default: assert(0 && "method not implemented\n"); break; + } + + +} + +/* hash functions for data validation */ + +/* hamming distance 4 */ +static const LC3_UINT32 crc14_mask[16] = {0, 17989, 35978, 51919, 71956, 89937, 103838, 119771, + 143912, 160877, 179874, 194791, 207676, 224633, 239542, 254451}; + +/* hamming distance 4 */ +static const LC3_UINT32 crc22_mask[16] = {0, 4788009, 9576018, 14356859, 19152036, 23933837, 28713718, 33500639, + 33650273, 38304072, 43214899, 47867674, 52775621, 57427436, 62346391, 67001278}; + +FEC_STATIC LC3_INT16 crc1(LC3_UINT8 *data, LC3_INT16 data_size, LC3_INT16 epmr, LC3_UINT8 *hash_val, LC3_INT16 hash_size, LC3_INT16 check) +{ + LC3_UINT32 const *mask; + LC3_INT32 shift, i, fail; + LC3_UINT32 rem; + + fail = 0; + rem = 0; + + assert(hash_size > 0); + + switch (hash_size) + { + case 2: + shift = 14; + mask = crc14_mask; + break; + case 3: + shift = 22; + mask = crc22_mask; + break; + default: + shift = 0; + mask = 0; + assert(0 && "crc hash size not implemented"); + } + + /* data array contains 4-bit words */ + for (i = data_size - 1; i >= 0; i--) + { + rem = (rem << 4) ^ data[i]; + rem ^= mask[(rem >> shift) & 15]; + } + + rem = (rem << 4) ^ (epmr << 2); + rem ^= mask[(rem >> shift) & 15]; + + for (i = 0; i < 2 * hash_size - 1; i++) + { + rem <<= 4; + rem ^= mask[(rem >> shift) & 15]; + } + + rem ^= ((LC3_UINT32) epmr) << shift; + + if (check) + { + /* test hash value */ + for (i = 0; i < 2 * hash_size; i++) + { + fail |= hash_val[i] ^ ((rem >> (4*i)) & 15); + } + } + else + { + /* write hash value */ + for (i = 0; i < 2 * hash_size; i++) + { + hash_val[i] = (LC3_UINT8) ((rem >> (4*i)) & 15); + } + } + + + return fail; +} + +/* hamming distance = 4 */ +static const LC3_UINT32 crc16_mask[16] = {0, 107243, 190269, 214486, 289937, 380538, 428972, 469319, + 579874, 621513, 671263, 761076, 832947, 857944, 938638, 1044581}; + +FEC_STATIC LC3_INT16 crc2(LC3_UINT8 *data, LC3_INT16 data_size, LC3_UINT8 *hash_val, LC3_INT16 hash_size, LC3_INT16 check) +{ + LC3_UINT32 const *mask; + LC3_INT32 shift, i, fail; + LC3_UINT32 rem; + + fail = 0; + rem = 0; + + assert(hash_size > 0); + + switch (hash_size) + { + case 2: + shift = 16; + mask = crc16_mask; + break; + default: + shift = 0; + mask = 0; + assert(0 && "crc hash size not implemented"); + } + + /* data array contains 4-bit words */ + for (i = data_size - 1; i >= 0; i--) + { + rem = (rem << 4) ^ data[i]; + rem ^= mask[(rem >> shift) & 15]; + } + + for (i = 0; i < 2 * hash_size; i++) + { + rem <<= 4; + rem ^= mask[(rem >> shift) & 15]; + } + + if (check) + { + /* test hash value */ + for (i = 0; i < 2 * hash_size; i++) + { + fail |= hash_val[i] ^ ((rem >> (4*i)) & 15); + } + } + else + { + /* write hash value */ + for (i = 0; i < 2 * hash_size; i++) + { + hash_val[i] = (LC3_UINT8) ((rem >> (4*i)) & 15); + } + } + + + return fail; +} + +/* simple float implementation */ +FEC_STATIC simple_float simple_float_mul(simple_float op1, simple_float op2) +{ + simple_float rop; + LC3_INT32 aux; + + aux = (op1.mantissa * op2.mantissa) >> 14; + rop.exponent = op1.exponent + op2.exponent; + if (aux & 32768L) + { + aux >>= 1; + rop.exponent ++; + } + rop.mantissa = (LC3_INT16) aux; + + + return rop; +} + +/* Auxiliary */ + +FEC_STATIC LC3_INT16 simple_float_cmp(simple_float op1, simple_float op2) +/* returns 1 if op1 > op2, 0 if op1 = op2, and -1 if op1 < op2 */ +{ + LC3_INT16 rval; + LC3_INT16 mdiff; + LC3_INT16 ediff; + + rval = 0; + + ediff = op1.exponent - op2.exponent; + mdiff = (LC3_INT16) op1.mantissa - (LC3_INT16) op2.mantissa; + + if (ediff == 0) + { + if (mdiff > 0) + { + rval = 1; + } + if (mdiff < 0) + { + rval = -1; + } + } + else + { + if (ediff > 0) + { + rval = 1; + } + if (ediff < 0) + { + rval = -1; + } + } + + + return rval; +} + diff --git a/lib_lc3plus/apply_global_gain.c b/lib_lc3plus/apply_global_gain.c new file mode 100644 index 0000000000000000000000000000000000000000..450997e20efdff6c3941e373aafdb79ce0fff2a0 --- /dev/null +++ b/lib_lc3plus/apply_global_gain.c @@ -0,0 +1,22 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.3 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + + +#include "options.h" +#include "wmc_auto.h" +#include "functions.h" + +void processApplyGlobalGain_fl(LC3_FLOAT x[], LC3_INT xLen, LC3_INT global_gain_idx, LC3_INT global_gain_off) +{ + LC3_FLOAT gg; + + gg = LC3_POW(10, (LC3_FLOAT)(global_gain_idx + global_gain_off) / 28); + + mult_const(x, gg, xLen); +} diff --git a/lib_lc3plus/ari_codec.c b/lib_lc3plus/ari_codec.c new file mode 100644 index 0000000000000000000000000000000000000000..23a540e91158b49cfabab0d350ba245c402e1359 --- /dev/null +++ b/lib_lc3plus/ari_codec.c @@ -0,0 +1,1776 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.3 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + + +#include "options.h" +#include "wmc_auto.h" +#include "functions.h" + +static void ac_shift_fl(Encoder_State_fl* st); +static void ac_encode_fl(Encoder_State_fl* st, LC3_INT sym_freq, LC3_INT cum_freq); +static void ac_finalize_fl(Encoder_State_fl* st); +static void write_uint_forward_fl(Encoder_State_fl* st, LC3_INT val, LC3_INT numbits); +static void ari_enc_init(Encoder_State_fl* st, LC3_UINT8* bytes, LC3_INT* bp_side, LC3_INT* mask_side); +static LC3_INT sign(LC3_INT x); + +#ifdef CR9_SIMPLIFY_ARI_DECODER +static void read_bit_fl(LC3_UINT8* ptr, LC3_INT* mask_side, LC3_INT* bp_side, LC3_INT* bit); +#else +static void read_bit_fl(LC3_UINT8* ptr, LC3_INT* mask_side, LC3_INT* bp_side, LC3_INT* bit, LC3_INT *bp, Decoder_State_fl* st_fl, LC3_INT from_left); +#endif + +#ifdef CR9_SIMPLIFY_ARI_DECODER +static void ac_dec_init_fl(LC3_UINT8* ptr, LC3_INT* bp, Decoder_State_fl* st_fl, LC3_INT from_left, LC3_INT mask_side, LC3_INT *bp_side); +#else +static void ac_dec_init_fl(LC3_UINT8* ptr, LC3_INT* bp, Decoder_State_fl* st_fl, LC3_INT from_left, LC3_INT mask_side, LC3_INT *bp_side); +#endif + +#ifdef CR9_SIMPLIFY_ARI_DECODER +static LC3_INT32 ac_decode_fl(Decoder_State_fl* st, const LC3_INT16* sym_freq, LC3_INT32 num_sym, LC3_UINT8* ptr, LC3_INT32* bp, LC3_INT32 from_left, LC3_INT32 mask_side, LC3_INT32 *bp_side, LC3_INT16 cur_bin); +#else +static LC3_INT ac_decode_fl(Decoder_State_fl* st, LC3_INT* sym_freq, LC3_INT* cum_freq, LC3_INT num_sym, LC3_UINT8* ptr, LC3_INT* bp, LC3_INT from_left, LC3_INT mask_side, LC3_INT *bp_side); +#endif + +#ifdef CR9_SIMPLIFY_ARI_DECODER +static LC3_INT16 pc_check_bytes(LC3_INT32* bp, Decoder_State_fl* st_fl, LC3_INT32 from_left, LC3_INT32 mask_side, LC3_INT32 *bp_side, LC3_INT16 cur_bin); +#else +static void pc_check_bytes(LC3_INT32* bp, Decoder_State_fl* st_fl, LC3_INT32 from_left, LC3_INT32 mask_side, LC3_INT32 *bp_side); +#endif + +static void calculate_nfseed(LC3_INT *x, LC3_INT L_spec, LC3_INT *nf_seed); +static void findNonZero(LC3_INT* in, LC3_INT len, LC3_INT* outLen); + +#ifndef CR9_SIMPLIFY_ARI_DECODER +static void ac_freq(LC3_INT pki, LC3_INT* symfreq, LC3_INT* cumfreq, LC3_INT* numsym); + +static void tns_coef_freq(LC3_INT k, LC3_INT* symfreq, LC3_INT* cumfreq, LC3_INT* numsym); + +static void tns_order_freq(LC3_INT enable_lpc_weighting, LC3_INT* symfreq, LC3_INT* cumfreq, LC3_INT* numsym); + +void ac_freq(LC3_INT pki, LC3_INT* symfreq, LC3_INT* cumfreq, LC3_INT* numsym) +{ + LC3_INT i = 0, j = 0; + + *numsym = 18 - 1; + + j = 0; + for (i = 1; i <= *numsym; i++) { + symfreq[j] = ari_spec_cumfreq_fl[pki][i]; + j++; + } + + for (i = 0; i < *numsym; i++) { + symfreq[i] -= ari_spec_cumfreq_fl[pki][i]; + } + + for (i = 0; i < *numsym; i++) { + cumfreq[i] = ari_spec_cumfreq_fl[pki][i]; + } +} + +void tns_coef_freq(LC3_INT k, LC3_INT* symfreq, LC3_INT* cumfreq, LC3_INT* numsym) +{ + LC3_INT i = 0, j = 0; + + *numsym = 18 - 1; + + j = 0; + for (i = 1; i <= *numsym; i++) { + symfreq[j] = ari_tns_freq_cf[k][i]; + j++; + } + + for (i = 0; i < *numsym; i++) { + symfreq[i] -= ari_tns_freq_cf[k][i]; + } + + for (i = 0; i < *numsym; i++) { + cumfreq[i] = ari_tns_freq_cf[k][i]; + } +} + +void tns_order_freq(LC3_INT enable_lpc_weighting, LC3_INT* symfreq, LC3_INT* cumfreq, LC3_INT* numsym) +{ + LC3_INT i = 0, j = 0; + + *numsym = 8; + + j = 0; + for (i = 1; i < 9; i++) { + symfreq[j] = ari_tns_order_cf[enable_lpc_weighting][i]; + j++; + } + + for (i = 0; i < *numsym; i++) { + symfreq[i] -= ari_tns_order_cf[enable_lpc_weighting][i]; + } + + for (i = 0; i < *numsym; i++) { + cumfreq[i] = ari_tns_order_cf[enable_lpc_weighting][i]; + } +} + +#endif + +void findNonZero(LC3_INT* in, LC3_INT len, LC3_INT* outLen) +{ + LC3_INT i = 0, j = 0; + + for (i = 0; i < len; i++) { + if (in[i] != 0) { + j++; + } + } + + *outLen = j; +} + +void calculate_nfseed(LC3_INT *x, LC3_INT L_spec, LC3_INT *nf_seed) +{ + LC3_INT k; + + *nf_seed = 0; + + for (k = 0; k < L_spec; k++) { + *nf_seed = *nf_seed + (abs(x[k]) & 32767) * k; + } + *nf_seed = *nf_seed & 65535; + + if (*nf_seed >= 32768) { + *nf_seed = *nf_seed - 65536; + } +} + +#ifdef CR9_SIMPLIFY_ARI_DECODER +static LC3_INT16 pc_check_bytes(LC3_INT32* bp, Decoder_State_fl* st_fl, LC3_INT32 from_left, LC3_INT32 mask_side, LC3_INT32 *bp_side, LC3_INT16 cur_bin) +{ + LC3_INT32 bp_local, bp_side_local, offset; +#ifdef WMOPS + push_wmops("pc_check_bytes"); +#endif + + if (st_fl->pc_bytes > 0) + { + if (!from_left && mask_side != 1) + { + return 0; + } + + if (st_fl->pc_c_bp_side > 0 && *bp_side < 0) + { + assert(mask_side == 1); + assert(st_fl->pc_b_right != -1); + *bp_side = st_fl->pc_b_right; + + return 0; + } + + bp_local = *bp; + bp_side_local = *bp_side; + + if (from_left) + { + if (mask_side == 1) + { + bp_side_local = bp_side_local + 1; + } + } else { + bp_local = bp_local - 1; + } + + if (st_fl->pc_b_right == -1) + { + offset = -1; + if (!st_fl->pc_enc) + { + offset = offset + st_fl->pc_bytes; + } + + if ((bp_side_local + offset - bp_local) == st_fl->pc_bytes) + { + st_fl->pc_b_left = bp_local + 1; + st_fl->pc_b_right = bp_side_local - 1; + + if (st_fl->pc_enc) + { + assert(st_fl->pc_b_right - st_fl->pc_b_left + 1 == st_fl->pc_bytes); + return 1; + } + } + } + + if (!st_fl->pc_enc && st_fl->pc_b_right > -1) + { + if (from_left && *bp == st_fl->pc_b_left) + { + *bp = 0; + st_fl->pc_c_bp = 1; + } + + if (!from_left && bp_side_local == st_fl->pc_b_right) + { + *bp_side = st_fl->pc_bytes - 1; + st_fl->pc_c_bp_side = 1; + } + + if (st_fl->pc_bfi == 2) + { + + if ((st_fl->pc_c_bp && (*bp + 1) >= st_fl->pc_be_bp_left) || (st_fl->pc_c_bp_side && (*bp_side + 1) <= st_fl->pc_be_bp_right)) + { + st_fl->pc_inv_bin = cur_bin; + return 1; + } else if ((st_fl->pc_c_bp && *bp >= 0) || (st_fl->pc_c_bp_side && *bp_side <= (st_fl->pc_bytes - 1))) + { + st_fl->pc_inv_bin = MIN(st_fl->pc_inv_bin, cur_bin); + return 0; + } + } + } + } + +#ifdef WMOPS + pop_wmops(); +#endif + return 0; +} + +#else + +static void pc_check_bytes(LC3_INT32* bp, Decoder_State_fl* st_fl, LC3_INT32 from_left, LC3_INT32 mask_side, LC3_INT32 *bp_side) +{ + LC3_INT32 bp_local, bp_side_local, offset; + + if (st_fl->pc_bytes > 0) + { + if (!from_left && mask_side != 1) + { + return; + } + + if (st_fl->pc_c_bp_side > 0 && *bp_side < 0) + { + assert(mask_side == 1); + assert(st_fl->pc_b_right != -1); + *bp_side = st_fl->pc_b_right; + return; + } + + bp_local = *bp; + bp_side_local = *bp_side; + + if (from_left) + { + if (mask_side == 1) + { + bp_side_local = bp_side_local + 1; + } + } else { + bp_local = bp_local - 1; + } + + if (st_fl->pc_b_right == -1) + { + offset = -1; + if (!st_fl->pc_enc) + { + offset = offset + st_fl->pc_bytes; + } + + if ((bp_side_local + offset - bp_local) == st_fl->pc_bytes) + { + st_fl->pc_b_left = bp_local + 1; + st_fl->pc_b_right = bp_side_local - 1; + + if (st_fl->pc_enc) + { + st_fl->pc_return = 1; + return; + } + } + } + + if (!st_fl->pc_enc && st_fl->pc_b_right > -1) + { + if (from_left && *bp == st_fl->pc_b_left) + { + *bp = 0; + st_fl->pc_c_bp = 1; + } + + if (!from_left && bp_side_local == st_fl->pc_b_right) + { + *bp_side = st_fl->pc_bytes - 1; + st_fl->pc_c_bp_side = 1; + } + + if (st_fl->pc_bfi == 2) + { + + if ((st_fl->pc_c_bp && (*bp + 1) >= st_fl->pc_be_bp_left) || (st_fl->pc_c_bp_side && (*bp_side + 1) <= st_fl->pc_be_bp_right)) + { + st_fl->pc_bbi = 2; + } else if ((st_fl->pc_c_bp && *bp >= 0) || (st_fl->pc_c_bp_side && *bp_side <= (st_fl->pc_bytes - 1))) + { + st_fl->pc_bbi = 1; + } + } + } + } + + return; +} + +#endif + +#ifdef CR9_SIMPLIFY_ARI_DECODER +void ac_dec_init_fl(LC3_UINT8* ptr, LC3_INT* bp, Decoder_State_fl* st_fl, LC3_INT from_left, LC3_INT mask_side, LC3_INT *bp_side) +{ + LC3_INT i; + + if (!st_fl->pc_enc) + { + *bp = *bp + st_fl->pc_bytes; + } + + st_fl->ac_low_fl = 0; + + st_fl->ac_range_fl = (LC3_UINT32) 16777215; /* 2^24 -1 */ + for (i = 0; i < 3; i++) { + if(pc_check_bytes(bp, st_fl, from_left, mask_side, bp_side, 0) != 0) + { + return; + } + + st_fl->ac_low_fl = (st_fl->ac_low_fl << 8) + (LC3_UINT32)ptr[*bp]; + *bp = *bp + 1; + } + + st_fl->BER_detect = 0; +} + +#else + +void ac_dec_init_fl(LC3_UINT8* ptr, LC3_INT* bp, Decoder_State_fl* st_fl, LC3_INT from_left, LC3_INT mask_side, LC3_INT *bp_side) +{ + LC3_INT i = 0; + + if (!st_fl->pc_enc) + { + *bp = *bp + st_fl->pc_bytes; + } + + st_fl->ac_low_fl = 0; + + st_fl->ac_range_fl = (LC3_UINT32)pow(2, 24) - (LC3_UINT32)1; + for (i = 0; i < 3; i++) { + pc_check_bytes(bp, st_fl, from_left, mask_side, bp_side); + + st_fl->ac_low_fl = (st_fl->ac_low_fl << 8) + (LC3_UINT32)ptr[*bp]; + *bp = *bp + 1; + } + + st_fl->BER_detect = 0; +} + +#endif + +/* Returns val */ +#ifdef CR9_SIMPLIFY_ARI_DECODER +LC3_INT32 ac_decode_fl(Decoder_State_fl* st, const LC3_INT16* freq, LC3_INT32 num_sym, LC3_UINT8* ptr, LC3_INT32* bp, LC3_INT32 from_left, LC3_INT32 mask_side, LC3_INT32 *bp_side, LC3_INT16 cur_bin) +{ + LC3_INT val, tmp, symfreq_loc; +#ifdef WMOPS + push_wmops("ac_decode_fl"); +#endif + + tmp = st->ac_range_fl >> 10; + + if (st->ac_low_fl >= (LC3_UINT32)(tmp << 10)) { + st->BER_detect = 1; + } + + val = num_sym - 1; + + while (st->ac_low_fl < (LC3_UINT32)(tmp * freq[val])) { + val--; + } + + symfreq_loc = freq[val + 1] - freq[val]; + + st->ac_low_fl = st->ac_low_fl - tmp * freq[val]; + st->ac_range_fl = tmp * symfreq_loc; + + while (st->ac_range_fl < 65536) { + st->ac_low_fl = ((LC3_INT32)st->ac_low_fl) & ((LC3_INT32)(16777215)); + + if(pc_check_bytes(bp, st, from_left, mask_side, bp_side, cur_bin) != 0) + { + st->BER_detect = 1; + return 1; + } + + st->ac_low_fl = st->ac_low_fl << 8; + st->ac_low_fl = st->ac_low_fl + ptr[*bp]; + *bp = *bp + 1; + st->ac_range_fl = st->ac_range_fl << 8; + } + +#ifdef WMOPS + pop_wmops(); +#endif + return val; +} + +#else + +LC3_INT ac_decode_fl(Decoder_State_fl* st, LC3_INT* sym_freq, LC3_INT* cum_freq, LC3_INT num_sym, LC3_UINT8* ptr, LC3_INT* bp, LC3_INT from_left, LC3_INT mask_side, LC3_INT *bp_side) +{ + LC3_INT val = 0, tmp = 0; + + + tmp = st->ac_range_fl >> 10; + + if (st->ac_low_fl >= (LC3_UINT32)(tmp << 10)) { + st->BER_detect = 1; + } + + val = num_sym - 1; + + while (st->ac_low_fl < (LC3_UINT32)(tmp * cum_freq[val])) { + val--; + } + + st->ac_low_fl = st->ac_low_fl - tmp * cum_freq[val]; + st->ac_range_fl = tmp * sym_freq[val]; + + while (st->ac_range_fl < pow(2, 16)) { + st->ac_low_fl = st->ac_low_fl << 8; + st->ac_low_fl = ((LC3_INT)st->ac_low_fl) & ((LC3_INT)(pow(2, 24) - 1)); + + pc_check_bytes(bp, st, from_left, mask_side, bp_side); + + st->ac_low_fl = st->ac_low_fl + ptr[*bp]; + *bp = *bp + 1; + st->ac_range_fl = st->ac_range_fl << 8; + } + + return val; +} + + +#endif + +#ifdef CR9_SIMPLIFY_ARI_DECODER +void read_bit_fl(LC3_UINT8* ptr, LC3_INT* mask_side, LC3_INT* bp_side, LC3_INT* bit) +{ + if (ptr[*bp_side] & *mask_side) { + *bit = 1; + } else { + *bit = 0; + } + + if (*mask_side == 128) { + *mask_side = 1; + *bp_side = *bp_side - 1; + } else { + *mask_side = *mask_side * 2; + } +} + +#else + +void read_bit_fl(LC3_UINT8* ptr, LC3_INT* mask_side, LC3_INT* bp_side, LC3_INT* bit, LC3_INT *bp, Decoder_State_fl* st_fl, LC3_INT from_left) +{ + *bit = 0; + + UNUSED(bp); + UNUSED(st_fl); + UNUSED(from_left); + + if (ptr[*bp_side] & *mask_side) { + *bit = 1; + } else { + *bit = 0; + } + + if (*mask_side == 128) { + *mask_side = 1; + *bp_side = *bp_side - 1; + } else { + *mask_side = *mask_side * 2; + } +} + +#endif + +#ifdef CR9_SIMPLIFY_ARI_DECODER +void processAriDecoder_fl(LC3_UINT8* bytes, LC3_INT bp_side, LC3_INT mask_side, LC3_INT L_spec, LC3_INT fs_idx, LC3_INT enable_lpc_weighting, + LC3_INT tns_numfilters, LC3_INT lsbMode, LC3_INT lastnz, LC3_INT* bfi, LC3_INT* tns_order, LC3_INT fac_ns_idx, + LC3_INT gg_idx, uint8_t * resBits, LC3_INT* x, LC3_INT* nf_seed, LC3_INT* tns_idx, LC3_INT* zero_frame, LC3_INT numbytes, + LC3_INT* nbits_residual, LC3_INT* residualPresent, LC3_INT frame_dms, + LC3_INT32 n_pc, LC3_INT32 be_bp_left, LC3_INT32 be_bp_right, LC3_INT32 enc, LC3_INT32 *b_left, LC3_INT32 *spec_inv_idx, + LC3_INT hrmode +) +{ + Decoder_State_fl st; + LC3_INT a, b, t, bp; + LC3_INT c; + LC3_INT nbits_side, extra_bits; + LC3_UINT8* ptr; + LC3_INT n, k, lev; + LC3_INT max_lev, tmp; + LC3_INT bit, lev1, pki, sym, save_lev[MAX_LEN], idx_len, total_bits, nbits_ari, rateFlag; + +#ifdef WMOPS + push_wmops("processAriDecoder_fl"); +#endif + + total_bits = 8 * numbytes; + rateFlag = 0; + + memset(&st, 0, sizeof(st)); + + st.pc_bytes = (n_pc + 1) >> 1; + st.pc_b_left = numbytes + 1; + st.pc_b_right = -1; + st.pc_enc = enc; + st.pc_bfi = *bfi; + st.pc_be_bp_left = floor(be_bp_left / 8); + st.pc_be_bp_right = floor(be_bp_right / 8) - 1; + *spec_inv_idx = L_spec + 1; + assert(st.pc_be_bp_right < st.pc_bytes || st.pc_bytes == 0); + + /* Rate flag */ + if (fs_idx != 5) + { + if (total_bits > (160 + fs_idx * 160)) { + rateFlag = 512; + } + } + + /* Init */ + c = 0; + t = 0; + bp = 0; + + *b_left = -1; + + ptr = bytes; + + /* Start Decoding */ + ac_dec_init_fl(ptr, &bp, &st, 1, mask_side, &bp_side); + + /* Decode TNS data */ + tmp = MAXLAG; + + + if (frame_dms <= 50) + { + tmp /= 2; + } + + /* Decode TNS data */ + for (n = 0; n < tns_numfilters; n++) { + + if (tns_order[n] > 0) { + tns_order[n] = ac_decode_fl(&st, &ari_tns_order_cf[enable_lpc_weighting][0], 8, ptr, &bp, 1, mask_side, &bp_side, 0); + + tns_order[n] = tns_order[n] + 1; + + if (tns_order[n] > tmp || st.BER_detect > 0) + { + goto ber_detect; + } + + for (k = 0; k < tns_order[n]; k++) { + if (bp_side < bp) + { + *bfi = 1; + return; + } + + tns_idx[n * 8 + k] = ac_decode_fl(&st, &ari_tns_freq_cf[k][0], 17, ptr, &bp, 1, mask_side, &bp_side, 0); + + if (st.BER_detect > 0) + { + goto ber_detect; + } + } + } + } + + /* Spectral data */ + for (k = 0; k < lastnz; k = k + 2) { + /* Context */ + t = c + rateFlag; + + if (k > (L_spec >> 1)) { + t = t + 256; + } + + /* Decode amplitude */ + x[k] = 0; + x[k + 1] = 0; + + if (hrmode == 1) { + max_lev = 13 + 8; + } else { + max_lev = 13; + } + + for (lev = 0; lev <= max_lev; lev++) { + lev1 = MIN(lev, 3); + pki = ari_spec_lookup_fl[t + lev1 * 1024]; + + sym = ac_decode_fl(&st, &ari_spec_cumfreq_fl[pki][0], 17, ptr, &bp, 1, mask_side, &bp_side, k); + + if (sym < 16) { + break; + } + + if (lsbMode == 0 || lev > 0) { + if(pc_check_bytes(&bp, &st, 0, mask_side, &bp_side, k) != 0) + { + goto ber_detect; + } + read_bit_fl(ptr, &mask_side, &bp_side, &bit); + + x[k] = x[k] + (bit << lev); + if(pc_check_bytes(&bp, &st, 0, mask_side, &bp_side, k) != 0) + { + goto ber_detect; + } + read_bit_fl(ptr, &mask_side, &bp_side, &bit); + + x[k + 1] = x[k + 1] + (bit << lev); + } + } + + if ((lev - 1) == 13 && sym == 16) + { + goto ber_detect; + } + + if (hrmode == 0) { + lev = MIN(lev, 13); + } + + if (lsbMode == 1) { + save_lev[k] = lev; + } + + a = sym & 3; + b = sym >> 2; + + x[k] = x[k] + (a << lev); + x[k + 1] = x[k + 1] + (b << lev); + + /* Decode signs */ + if (x[k] > 0) { + if(pc_check_bytes(&bp, &st, 0, mask_side, &bp_side, k) != 0) + { + goto ber_detect; + } + read_bit_fl(ptr, &mask_side, &bp_side, &bit); + + if (bit == 1) { + x[k] = -x[k]; + } + } + + if (x[k + 1] > 0) { + if(pc_check_bytes(&bp, &st, 0, mask_side, &bp_side, k) != 0) + { + goto ber_detect; + } + read_bit_fl(ptr, &mask_side, &bp_side, &bit); + + if (bit == 1) { + x[k + 1] = -x[k + 1]; + } + } + + /* Context */ + lev1 = MIN(lev, 3); + if (lev1 <= 1) { + t = 1 + (a + b) * (lev1 + 1); + } else { + t = 12 + lev1; + } + + c = (c & 15) * 16 + t; + + if (((bp - bp_side) > 3 && (st.pc_c_bp == st.pc_c_bp_side))) { + + if ((0 < *spec_inv_idx) && (*spec_inv_idx < (L_spec + 1))) + { + *bfi = 2; + calculate_nfseed(x, k, nf_seed); + return; + } + + *bfi = 1; + return; + } + + if (st.BER_detect > 0) + { + goto ber_detect; + } + } + + /* Residual bits */ + nbits_side = total_bits - (8 * bp_side + 8 - (31 - clz_func(mask_side))); + nbits_ari = (bp - 3) * 8; + extra_bits = 25 - (31 - clz_func(st.ac_range_fl)); + + if (enc == 0) + { + if (st.pc_c_bp == 0) + { + nbits_ari = (bp - st.pc_bytes - 3) * 8; + } else { + nbits_ari = (bp + st.pc_b_left - st.pc_bytes - 3) * 8; + } + + if (st.pc_c_bp_side != 0) + { + nbits_side = total_bits - 8 * (st.pc_b_left) + 8 * (st.pc_bytes - bp_side) - (8 - LC3_LOGTWO(mask_side)); + } + } + + + *nbits_residual = total_bits - (nbits_side + nbits_ari + extra_bits); + + if (*nbits_residual < 0) { + if ((0 < *spec_inv_idx) && (*spec_inv_idx < (L_spec + 1))) + { + *bfi = 2; + calculate_nfseed(x, k, nf_seed); + return; + } + + *bfi = 1; + return; + } + + if (lsbMode == 0) { + findNonZero(x, L_spec, &idx_len); + + if (hrmode) + { + idx_len *= EXT_RES_ITER_MAX; + } + *nbits_residual = MIN(*nbits_residual, idx_len); + *residualPresent = 1; + + memset(resBits, 0, MAX_RESBITS_LEN); + + for (k = 0; k < *nbits_residual; k++) { + if(pc_check_bytes(&bp, &st, 0, mask_side, &bp_side, k) != 0) + { + goto ber_detect_res; + } + read_bit_fl(ptr, &mask_side, &bp_side, &tmp); + + resBits[k >> 3] |= tmp << (k & 7); + } + } else { + for (k = 0; k < lastnz; k = k + 2) { + if (save_lev[k] > 0) { + if (*nbits_residual == 0) { + break; + } + + if(pc_check_bytes(&bp, &st, 0, mask_side, &bp_side, k) != 0) + { + goto ber_detect_res; + } + read_bit_fl(ptr, &mask_side, &bp_side, &bit); + + *nbits_residual = *nbits_residual - 1; + + if (bit == 1) { + if (x[k] > 0) { + x[k] = x[k] + 1; + } else if (x[k] < 0) { + x[k] = x[k] - 1; + } else { + if (*nbits_residual == 0) { + break; + } + + if(pc_check_bytes(&bp, &st, 0, mask_side, &bp_side, k) != 0) + { + goto ber_detect_res; + } + read_bit_fl(ptr, &mask_side, &bp_side, &bit); + + *nbits_residual = *nbits_residual - 1; + + if (bit == 0) { + x[k] = 1; + } else { + x[k] = -1; + } + } + } + + if (*nbits_residual == 0) { + break; + } + + if(pc_check_bytes(&bp, &st, 0, mask_side, &bp_side, k) != 0) + { + goto ber_detect_res; + } + read_bit_fl(ptr, &mask_side, &bp_side, &bit); + + *nbits_residual = *nbits_residual - 1; + + if (bit == 1) { + if (x[k + 1] > 0) { + x[k + 1] = x[k + 1] + 1; + } else if (x[k + 1] < 0) { + x[k + 1] = x[k + 1] - 1; + } else { + if (*nbits_residual == 0) { + break; + } + + if(pc_check_bytes(&bp, &st, 0, mask_side, &bp_side, k) != 0) + { + goto ber_detect_res; + } + read_bit_fl(ptr, &mask_side, &bp_side, &bit); + + *nbits_residual = *nbits_residual - 1; + + if (bit == 0) { + x[k + 1] = 1; + } else { + x[k + 1] = -1; + } + } + } + } + } + } + + /* Noise-filling seed */ + calculate_nfseed(x, L_spec, nf_seed); + + /* Zero frame flag */ + if (lastnz == 2 && x[0] == 0 && x[1] == 0 && gg_idx == 0 && fac_ns_idx == 7) { + *zero_frame = 1; + } else { + *zero_frame = 0; + } + + if (enc) + { + if (st.pc_bytes > 0) + { + if (st.pc_b_left > numbytes) + { + *b_left = bp_side - st.pc_bytes; + } + } + } else { + if (st.pc_bytes > 0) + { + if (st.pc_b_left > numbytes) + { + *b_left = bp_side; + } + } + } + + if ((*bfi == 2) && (*spec_inv_idx == (L_spec + 1))) + { + *bfi = 0; + } + + *spec_inv_idx = *spec_inv_idx - 1; + + goto bail; + +/* goto for bit error handling */ +ber_detect: + *bfi = 1; + *b_left = st.pc_b_left; + + if (st.pc_inv_bin > 0 && (st.pc_inv_bin - L_spec) <= 0) + { + *spec_inv_idx = st.pc_inv_bin; + *bfi = 2; + *resBits = 0; + *zero_frame = 0; + /* Noise Filling seed */ + calculate_nfseed(x, *spec_inv_idx, nf_seed); + } + goto bail; + +/* goto for bit error handling in residual signal */ +ber_detect_res: + *b_left = st.pc_b_left; + *resBits = 0; + *bfi = 0; + *zero_frame = 0; + /* Noise Filling seed */ + calculate_nfseed(x, *spec_inv_idx, nf_seed); + goto bail; + +/* goto, because of dynmem out */ +bail: + +#ifdef WMOPS + pop_wmops(); +#endif + /* Avoid warning "label at end of compound statement" when WMOPS is inactive */ + (void)0; +} + +#else + + +void processAriDecoder_fl(LC3_UINT8* bytes, LC3_INT bp_side, LC3_INT mask_side, LC3_INT L_spec, LC3_INT fs_idx, LC3_INT enable_lpc_weighting, + LC3_INT tns_numfilters, LC3_INT lsbMode, LC3_INT lastnz, LC3_INT* bfi, LC3_INT* tns_order, LC3_INT fac_ns_idx, + LC3_INT gg_idx, uint8_t * resBits, LC3_INT* x, LC3_INT* nf_seed, LC3_INT* tns_idx, LC3_INT* zero_frame, LC3_INT numbytes, + LC3_INT* nbits_residual, LC3_INT* residualPresent, LC3_INT frame_dms, + LC3_INT32 n_pc, LC3_INT32 be_bp_left, LC3_INT32 be_bp_right, LC3_INT32 enc, LC3_INT32 *b_left, LC3_INT32 *spec_inv_idx, + LC3_INT hrmode +) +{ + Decoder_State_fl st; + LC3_INT a = 0, b = 0, t = 0, bp = 0; + LC3_INT c = 0; + LC3_INT nbits_side = 0, extra_bits = 0; + LC3_UINT8* ptr = NULL; + LC3_INT n = 0, k = 0, lev = 0; + LC3_INT max_lev = 0, tmp = 0; + LC3_INT sym_freq[MAX_LEN] = {0}, cum_freq[MAX_LEN] = {0}, numsym = 0, bit = 0, lev1 = 0, pki = 0, sym = 0, + save_lev[MAX_LEN] = {0}, idx_len = 0, total_bits = 0, nbits_ari = 0, rateFlag = 0; + + total_bits = 8 * numbytes; + + memset(&st, 0, sizeof(st)); + + + st.pc_bytes = (n_pc + 1) >> 1; + st.pc_b_left = numbytes + 1; + st.pc_b_right = -1; + st.pc_enc = enc; + st.pc_bfi = *bfi; + st.pc_be_bp_left = floor(be_bp_left / 8); + st.pc_be_bp_right = floor(be_bp_right / 8) - 1; + *spec_inv_idx = L_spec + 1; + assert(st.pc_be_bp_right < st.pc_bytes || st.pc_bytes == 0); + + /* Rate flag */ + if (fs_idx != 5) + { + if (total_bits > (160 + fs_idx * 160)) { + rateFlag = 512; + } + } + + /* Init */ + c = 0; + t = 0; + bp = 0; + + *b_left = -1; + + ptr = bytes; + + /* Start Decoding */ + ac_dec_init_fl(ptr, &bp, &st, 1, mask_side, &bp_side); + + /* Decode TNS data */ + tmp = MAXLAG; + if (frame_dms == 25) + { + tmp /= 2; + } + if (frame_dms == 50) + { + tmp /= 2; + } + + /* Decode TNS data */ + for (n = 0; n < tns_numfilters; n++) { + + if (tns_order[n] > 0) { + tns_order_freq(enable_lpc_weighting, sym_freq, cum_freq, &numsym); + + tns_order[n] = ac_decode_fl(&st, sym_freq, cum_freq, numsym, ptr, &bp, 1, mask_side, &bp_side); + + if (st.pc_return) + { + *b_left = st.pc_b_left; + return; + } + + tns_order[n] = tns_order[n] + 1; + + if (tns_order[n] > tmp) + { + st.BER_detect = 1; + } + + if (st.pc_bbi == 1) + { + spec_inv_idx = 0; + } else if (st.pc_bbi == 2) + { + st.BER_detect = 1; + } + + for (k = 0; k < tns_order[n]; k++) { + if (bp_side < bp) + { + *bfi = 1; + return; + } + + tns_coef_freq(k, sym_freq, cum_freq, &numsym); + tns_idx[n * 8 + k] = ac_decode_fl(&st, sym_freq, cum_freq, numsym, ptr, &bp, 1, mask_side, &bp_side); + + if (st.pc_return) + { + *b_left = st.pc_b_left; + return; + } + + if (st.pc_bbi == 1) + { + spec_inv_idx = 0; + } else if (st.pc_bbi == 2) + { + st.BER_detect = 1; + } + } + } + } + + if (st.BER_detect > 0) { + *bfi = 1; + return; + } + + /* Spectral data */ + for (k = 0; k < lastnz; k = k + 2) { + /* Context */ + t = c + rateFlag; + + if (k > L_spec / 2) { + t = t + 256; + } + + /* Decode amplitude */ + x[k] = 0; + x[k + 1] = 0; + + if (hrmode == 1) { + max_lev = 13 + 8; + } else { + max_lev = 13; + } + + for (lev = 0; lev <= max_lev; lev++) { + lev1 = MIN(lev, 3); + pki = ari_spec_lookup_fl[t + lev1 * 1024]; + ac_freq(pki, sym_freq, cum_freq, &numsym); + sym = ac_decode_fl(&st, sym_freq, cum_freq, numsym, ptr, &bp, 1, mask_side, &bp_side); + + if (st.pc_return) + { + *b_left = st.pc_b_left; + return; + } + + if (st.pc_bbi == 1) + { + *spec_inv_idx = MIN(*spec_inv_idx, k); + } else if (st.pc_bbi == 2) + { + *spec_inv_idx = k; + x[k] = 0; + x[k + 1] = 0; + calculate_nfseed(x, k, nf_seed); + return; + } + + if (sym < 16) { + break; + } + + if (lsbMode == 0 || lev > 0) { + pc_check_bytes(&bp, &st, 0, mask_side, &bp_side); + read_bit_fl(ptr, &mask_side, &bp_side, &bit, &bp, &st, 0); + + if (st.pc_return) + { + *b_left = st.pc_b_left; + return; + } + + if (st.pc_bbi == 2) + { + *spec_inv_idx = k; + x[k] = 0; + x[k + 1] = 0; + calculate_nfseed(x, k, nf_seed); + return; + } + + x[k] = x[k] + (bit << lev); + pc_check_bytes(&bp, &st, 0, mask_side, &bp_side); + read_bit_fl(ptr, &mask_side, &bp_side, &bit, &bp, &st, 0); + + if (st.pc_return) + { + *b_left = st.pc_b_left; + return; + } + + if (st.pc_bbi == 2) + { + *spec_inv_idx = k; + x[k] = 0; + x[k + 1] = 0; + calculate_nfseed(x, k, nf_seed); + return; + } + + x[k + 1] = x[k + 1] + (bit << lev); + } + } + + if ((lev - 1) == 13 && sym == 16) + { + st.BER_detect = 1; + } + + if (hrmode == 0) { + lev = MIN(lev, 13); + } + + if (lsbMode == 1) { + save_lev[k] = lev; + } + + a = sym & 3; + b = sym >> 2; + + x[k] = x[k] + (a << lev); + x[k + 1] = x[k + 1] + (b << lev); + + /* Decode signs */ + if (x[k] > 0) { + pc_check_bytes(&bp, &st, 0, mask_side, &bp_side); + read_bit_fl(ptr, &mask_side, &bp_side, &bit, &bp, &st, 0); + + if (st.pc_return) + { + *b_left = st.pc_b_left; + return; + } + + if (st.pc_bbi == 2) + { + *spec_inv_idx = k; + x[k] = 0; + x[k + 1] = 0; + calculate_nfseed(x, k, nf_seed); + return; + } + + if (bit == 1) { + x[k] = -x[k]; + } + } + + if (x[k + 1] > 0) { + pc_check_bytes(&bp, &st, 0, mask_side, &bp_side); + read_bit_fl(ptr, &mask_side, &bp_side, &bit, &bp, &st, 0); + + if (st.pc_return) + { + *b_left = st.pc_b_left; + return; + } + + if (st.pc_bbi == 2) + { + *spec_inv_idx = k + 1; + x[k + 1] = 0; + calculate_nfseed(x, k, nf_seed); + return; + } + + if (bit == 1) { + x[k + 1] = -x[k + 1]; + } + } + + /* Context */ + lev1 = MIN(lev, 3); + if (lev1 <= 1) { + t = 1 + (a + b) * (lev1 + 1); + } else { + t = 12 + lev1; + } + + c = (c & 15) * 16 + t; + + if (((bp - bp_side) > 3 && (st.pc_c_bp == st.pc_c_bp_side))) { + + if ((0 < *spec_inv_idx) && (*spec_inv_idx < (L_spec + 1))) + { + *bfi = 2; + calculate_nfseed(x, k, nf_seed); + return; + } + + *bfi = 1; + return; + } + + if (st.BER_detect > 0) + { + if ((0 < *spec_inv_idx) && (*spec_inv_idx < (L_spec + 1))) + { + *bfi = 2; + calculate_nfseed(x, k, nf_seed); + return; + } + + *bfi = 1; + return; + } + } + + /* Residual bits */ + nbits_side = total_bits - (8 * bp_side + 8 - (31 - clz_func(mask_side))); + nbits_ari = (bp - 3) * 8; + extra_bits = 25 - (31 - clz_func(st.ac_range_fl)); + + if (enc == 0) + { + if (st.pc_c_bp == 0) + { + nbits_ari = (bp - st.pc_bytes - 3) * 8; + } else { + nbits_ari = (bp + st.pc_b_left - st.pc_bytes - 3) * 8; + } + + if (st.pc_c_bp_side != 0) + { + nbits_side = total_bits - 8 * (st.pc_b_left) + 8 * (st.pc_bytes - bp_side) - (8 - LC3_LOGTWO(mask_side)); + } + } + + + *nbits_residual = total_bits - (nbits_side + nbits_ari + extra_bits); + + if (*nbits_residual < 0) { + if ((0 < *spec_inv_idx) && (*spec_inv_idx < (L_spec + 1))) + { + *bfi = 2; + calculate_nfseed(x, k, nf_seed); + return; + } + + *bfi = 1; + return; + } + + if (lsbMode == 0) { + findNonZero(x, L_spec, &idx_len); + if (hrmode) + { + idx_len *= EXT_RES_ITER_MAX; + } + *nbits_residual = MIN(*nbits_residual, idx_len); + *residualPresent = 1; + + memset(resBits, 0, MAX_RESBITS_LEN); + + for (k = 0; k < *nbits_residual; k++) { + pc_check_bytes(&bp, &st, 0, mask_side, &bp_side); + read_bit_fl(ptr, &mask_side, &bp_side, &tmp, &bp, &st, 0); + + if (st.pc_return) + { + *b_left = st.pc_b_left; + return; + } + + if (st.pc_bbi == 2) + { + *bfi = 0; + memset(resBits, 0, sizeof(uint8_t) * (*nbits_residual)); + calculate_nfseed(x, k, nf_seed); + return; + } + + resBits[k >> 3] |= tmp << (k & 7); + } + } else { + for (k = 0; k < lastnz; k = k + 2) { + if (save_lev[k] > 0) { + if (*nbits_residual == 0) { + break; + } + + pc_check_bytes(&bp, &st, 0, mask_side, &bp_side); + read_bit_fl(ptr, &mask_side, &bp_side, &bit, &bp, &st, 0); + + if (st.pc_return) + { + *b_left = st.pc_b_left; + return; + } + + if (st.pc_bbi == 2) + { + *bfi = 0; + memset(resBits, 0, sizeof(LC3_INT32) * (*nbits_residual)); + calculate_nfseed(x, k, nf_seed); + return; + } + + *nbits_residual = *nbits_residual - 1; + + if (bit == 1) { + if (x[k] > 0) { + x[k] = x[k] + 1; + } else if (x[k] < 0) { + x[k] = x[k] - 1; + } else { + if (*nbits_residual == 0) { + break; + } + + pc_check_bytes(&bp, &st, 0, mask_side, &bp_side); + read_bit_fl(ptr, &mask_side, &bp_side, &bit, &bp, &st, 0); + + if (st.pc_return) + { + *b_left = st.pc_b_left; + return; + } + + if (st.pc_bbi == 2) + { + *bfi = 0; + memset(resBits, 0, sizeof(LC3_INT32) * (*nbits_residual)); + calculate_nfseed(x, k, nf_seed); + return; + } + + *nbits_residual = *nbits_residual - 1; + + if (bit == 0) { + x[k] = 1; + } else { + x[k] = -1; + } + } + } + + if (*nbits_residual == 0) { + break; + } + + pc_check_bytes(&bp, &st, 0, mask_side, &bp_side); + read_bit_fl(ptr, &mask_side, &bp_side, &bit, &bp, &st, 0); + + if (st.pc_return) + { + *b_left = st.pc_b_left; + return; + } + + if (st.pc_bbi == 2) + { + *bfi = 0; + memset(resBits, 0, sizeof(LC3_INT32) * (*nbits_residual)); + calculate_nfseed(x, k, nf_seed); + return; + } + + *nbits_residual = *nbits_residual - 1; + + if (bit == 1) { + if (x[k + 1] > 0) { + x[k + 1] = x[k + 1] + 1; + } else if (x[k + 1] < 0) { + x[k + 1] = x[k + 1] - 1; + } else { + if (*nbits_residual == 0) { + break; + } + + pc_check_bytes(&bp, &st, 0, mask_side, &bp_side); + read_bit_fl(ptr, &mask_side, &bp_side, &bit, &bp, &st, 0); + + if (st.pc_return) + { + *b_left = st.pc_b_left; + return; + } + + if (st.pc_bbi == 2) + { + *bfi = 0; + memset(resBits, 0, sizeof(LC3_INT32) * (*nbits_residual)); + calculate_nfseed(x, k, nf_seed); + return; + } + + *nbits_residual = *nbits_residual - 1; + + if (bit == 0) { + x[k + 1] = 1; + } else { + x[k + 1] = -1; + } + } + } + } + } + } + + /* Noise-filling seed */ + calculate_nfseed(x, L_spec, nf_seed); + + /* Zero frame flag */ + if (lastnz == 2 && x[0] == 0 && x[1] == 0 && gg_idx == 0 && fac_ns_idx == 7) { + *zero_frame = 1; + } else { + *zero_frame = 0; + } + + if (enc) + { + if (st.pc_bytes > 0) + { + if (st.pc_b_left > numbytes) + { + *b_left = bp_side - st.pc_bytes; + } + } + } + + if ((*bfi == 2) && (*spec_inv_idx == (L_spec + 1))) + { + *bfi = 0; + } + + *spec_inv_idx = *spec_inv_idx - 1; +} + +#endif + +void ac_encode_fl(Encoder_State_fl* st, LC3_INT sym_freq, LC3_INT cum_freq) +{ + LC3_INT r; + + r = st->range >> 10; + st->low += r * cum_freq; + + if ((st->low >> 24) == 1) { + st->carry = 1; + } + + st->low &= (16777215); /* 2^24 -1 */ + st->range = r * sym_freq; + + while (st->range < 65536) { /* 2^16 */ + st->range <<= 8; + ac_shift_fl(st); + } +} + +void ac_shift_fl(Encoder_State_fl* st) +{ + if (st->low < 16711680 || st->carry == 1) { + if (st->cache >= 0) { + st->ptr[st->bp] = st->cache + st->carry; + st->bp = st->bp + 1; + } + + while (st->carry_count > 0) { + st->ptr[st->bp] = (st->carry + 255) & 255; + st->bp = st->bp + 1; + st->carry_count = st->carry_count - 1; + } + + st->cache = st->low >> 16; + st->carry = 0; + } else { + st->carry_count = st->carry_count + 1; + } + + st->low = st->low << 8; + st->low = (st->low) & (16777215); /* 2^24 - 1 */ +} + + +void ac_finalize_fl(Encoder_State_fl* st) +{ + LC3_INT bits = 0, mask = 0, val = 0, over1 = 0, high = 0, over2 = 0, c = 0, b = 0; + + bits = 24 - (31 - clz_func(st->range)); + mask = 16777215 >> bits; + val = st->low + mask; + over1 = val >> 24; + + val = (val) & 16777215; + high = st->low + st->range; + over2 = high >> 24; + high = high & 16777215; + val = val & (16777215 - mask); + + if (over1 == over2) { + if (val + mask >= high) { + bits = bits + 1; + mask = mask >> 1; + val = ((st->low + mask) & (16777215)) & (16777215 - mask); + } + + if (val < st->low) { + st->carry = 1; + } + } + + st->low = val; + + b = bits; + + if (bits > 8) { + for (; b >= 1; b = b - 8) { + ac_shift_fl(st); + } + } else { + ac_shift_fl(st); + } + + bits = b; + if (bits < 0) { + bits += 8; + } + + if (st->carry_count > 0) { + st->ptr[st->bp] = st->cache; + st->bp = st->bp + 1; + + for (c = st->carry_count; c >= 2; c--) { + st->ptr[st->bp] = 255; + st->bp = st->bp + 1; + } + + write_uint_forward_fl(st, 255 << (bits - 8), bits); + } else { + write_uint_forward_fl(st, st->cache, bits); + } +} + +void write_uint_forward_fl(Encoder_State_fl* st, LC3_INT val, LC3_INT numbits) +{ + LC3_INT k, bit, mask = 128; + + for (k = 0; k < numbits; k++) { + bit = val & mask; + + if (bit == 0) { + st->ptr[st->bp] = st->ptr[st->bp] & (255 - mask); + } else { + st->ptr[st->bp] = st->ptr[st->bp] | mask; + } + + mask = mask >> 1; + } +} + +void ari_enc_init(Encoder_State_fl* st, LC3_UINT8* bytes, LC3_INT* bp_side, LC3_INT* mask_side) +{ + st->ptr = bytes; + st->bp_side = bp_side; + st->mask_side = mask_side; + st->bp = 0; + st->low = 0; + st->range = 16777215; + st->cache = -1; + st->carry = 0; + st->carry_count = 0; +} + +LC3_INT sign(LC3_INT x) +{ + if (x > 0) + return 1; + + if (x < 0) + return -1; + + return 0; +} + +void processAriEncoder_fl(LC3_UINT8* bytes, LC3_INT bp_side, LC3_INT mask_side, LC3_INT* x, LC3_INT* tns_order, LC3_INT tns_numfilters, + LC3_INT* tns_idx, LC3_INT lastnz, LC3_INT* codingdata, uint8_t* res_bits, LC3_INT resBitsLen, LC3_INT lsbMode, + LC3_INT nbbits, LC3_INT enable_lpc_weighting) +{ + LC3_INT total_bits, cumfreq, symfreq, k, i, j, lev, lev1; + LC3_INT bit1, bit2, lsb1, lsb2, a, b, bit, pki, nbits_side; + LC3_INT nbits_residual_enc, nbits_ari, lsbs[MAX_LEN], lsbsLen = 0; + LC3_INT abs_x_k, abs_x_kp1; + Encoder_State_fl st; + +#ifdef WMOPS + push_wmops("processAriEncoder_fl"); +#endif + + ari_enc_init(&st, bytes, &bp_side, &mask_side); + + total_bits = nbbits; + + /* TNS data */ + for (i = 0; i < tns_numfilters; i++) { + if (tns_order[i] > 0) { + symfreq = tns_freq_cf[enable_lpc_weighting][tns_order[i]] - tns_freq_cf[enable_lpc_weighting][tns_order[i] - 1]; + cumfreq = tns_freq_cf[enable_lpc_weighting][tns_order[i] - 1]; + ac_encode_fl(&st, symfreq, cumfreq); + + for (j = 0; j < tns_order[i]; j++) { + symfreq = tns_cf[j][tns_idx[i * 8 + j] + 1] - tns_cf[j][tns_idx[i * 8 + j]]; + cumfreq = tns_cf[j][tns_idx[i * 8 + j]]; + ac_encode_fl(&st, symfreq, cumfreq); + } + } + } + + /* Spectral data */ + for (k = 0; k < lastnz; k = k + 2) { + abs_x_k = abs(x[k]); + abs_x_kp1 = abs(x[k + 1]); + for (lev = 0; lev < codingdata[1]; lev++) { + lev1 = MIN(lev, 3); + pki = ari_spec_lookup_fl[codingdata[0] + lev1 * 1024]; + symfreq = ari_spec_cumfreq_fl[pki][17] - ari_spec_cumfreq_fl[pki][16]; + cumfreq = ari_spec_cumfreq_fl[pki][16]; + + ac_encode_fl(&st, symfreq, cumfreq); + bit1 = (abs_x_k >> lev) & 1; + bit2 = (abs_x_kp1 >> lev) & 1; + + + if (lsbMode == 1 && lev == 0) { + lsb1 = bit1; + lsb2 = bit2; + } else { + write_bit_backward_fl(st.ptr, st.bp_side, st.mask_side, bit1); + write_bit_backward_fl(st.ptr, st.bp_side, st.mask_side, bit2); + } + } + + lev1 = MIN(MAX(codingdata[1], 0), 3); + pki = ari_spec_lookup_fl[codingdata[0] + lev1 * 1024]; + + symfreq = ari_spec_cumfreq_fl[pki][codingdata[2] + 1] - ari_spec_cumfreq_fl[pki][codingdata[2]]; + cumfreq = ari_spec_cumfreq_fl[pki][codingdata[2]]; + ac_encode_fl(&st, symfreq, cumfreq); + + a = abs_x_k; + b = abs_x_kp1; + + if (lsbMode == 1 && codingdata[1] > 0) { + a = a >> 1; + lsbs[lsbsLen] = lsb1; + lsbsLen++; + + if (a == 0 && x[k] != 0) { + bit = MAX(0, -sign(x[k])); + lsbs[lsbsLen] = bit; + lsbsLen++; + } + + b = b >> 1; + lsbs[lsbsLen] = lsb2; + lsbsLen++; + + if (b == 0 && x[k + 1] != 0) { + bit = MAX(0, -sign(x[k + 1])); + lsbs[lsbsLen] = bit; + lsbsLen++; + } + } + + if (a != 0) { + bit = MAX(0, -sign(x[k])); + write_bit_backward_fl(st.ptr, st.bp_side, st.mask_side, bit); + } + + if (b != 0) { + bit = MAX(0, -sign(x[k + 1])); + write_bit_backward_fl(st.ptr, st.bp_side, st.mask_side, bit); + } + + codingdata += 3; + } + + /* Residual bits */ + nbits_side = total_bits - (8 * (*(st.bp_side) + 1) + 8 - (31 - clz_func(*(st.mask_side)))); + nbits_ari = 8 * (st.bp + 1) + 25 - (31 - clz_func(st.range )) ; + + if (st.cache >= 0) { + nbits_ari = nbits_ari + 8; + } + + if (st.carry_count > 0) { + nbits_ari = nbits_ari + st.carry_count * 8; + } + + nbits_residual_enc = MAX(total_bits - (nbits_side + nbits_ari), 0); + /* the max operation avoids in very rare cases, that + * nbits_residual_enc becomes negative; having overwritten + * the last bit(s) of the side information is in this case + * assumed to be not critical, since no spectral data bits + * were written */ + + if (lsbMode == 0) { + nbits_residual_enc = MIN(nbits_residual_enc, resBitsLen); + for (k = 0; k < nbits_residual_enc; k++) { + if (res_bits[k >> 3] & (1 << (k & 7))) + { + write_bit_backward_fl(st.ptr, st.bp_side, st.mask_side, 1); + } + else + { + write_bit_backward_fl(st.ptr, st.bp_side, st.mask_side, 0); + } + } + } else { + nbits_residual_enc = MIN(nbits_residual_enc, lsbsLen); + + for (k = 0; k < nbits_residual_enc; k++) { + write_bit_backward_fl(st.ptr, st.bp_side, st.mask_side, lsbs[k]); + } + } + + ac_finalize_fl(&st); +#ifdef WMOPS + pop_wmops(); +#endif +} + diff --git a/lib_lc3plus/attack_detector.c b/lib_lc3plus/attack_detector.c new file mode 100644 index 0000000000000000000000000000000000000000..59af3abfdcf9e8fd6c3f553d688cb1f05718eedd --- /dev/null +++ b/lib_lc3plus/attack_detector.c @@ -0,0 +1,92 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.3 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + + +#include "options.h" +#include "wmc_auto.h" +#include "functions.h" + +void attack_detector_fl(LC3_FLOAT* in, LC3_INT frame_size, LC3_INT fs, LC3_INT* lastAttackPosition, LC3_FLOAT* accNrg, LC3_INT* attackFlag, + LC3_FLOAT* attdec_filter_mem, LC3_INT attackHandlingOn, LC3_INT attdec_nblocks, LC3_INT attdec_hangover_threshold) +{ + LC3_FLOAT f_sig[160], block_nrg[4], sum, tmpEne, *ptr, tmp[162]; + LC3_INT i, j, attackPosition; + LC3_FLOAT mval; + LC3_INT frame_size_16k; + + if (attackHandlingOn) { + + mval = 0; j = 0; + frame_size_16k = attdec_nblocks * 40; + ptr = &tmp[2]; + + /* Decimate 48 and 32 kHz signals to 16 kHz */ + if (fs == 48000) { + j = 0; + for (i = 0; i < frame_size;) { + ptr[j] = (in[i] + in[i + 1] + in[i + 2]); + i = i + 3; + j++; + } + } else if (fs == 32000) { + j = 0; + for (i = 0; i < frame_size;) { + ptr[j] = (in[i] + in[i + 1]); + i = i + 2; + j++; + } + } + + /* Filter */ + ptr[-2] = (LC3_FLOAT)attdec_filter_mem[0]; + ptr[-1] = (LC3_FLOAT)attdec_filter_mem[1]; + + attdec_filter_mem[0] = ptr[frame_size_16k - 2]; + attdec_filter_mem[1] = ptr[frame_size_16k - 1]; + + for (i = 159; i >= 0; i--) { + tmpEne = 0; + + tmpEne += ptr[i] * 0.375; + tmpEne += ptr[i - 1] * (-0.5); + tmpEne += ptr[i - 2] * (0.125); + + f_sig[i] = tmpEne; + } + + for (i = 0; i < attdec_nblocks; i++) { + sum = 0; + for (j = 0; j < 40; j++) { + sum += f_sig[j + i * 40] * f_sig[j + i * 40]; + } + + block_nrg[i] = sum; + } + + *attackFlag = 0; + attackPosition = -1; + + for (i = 0; i < attdec_nblocks; i++) { + tmpEne = block_nrg[i] / 8.5; + + if (tmpEne > MAX(*accNrg, mval)) { + *attackFlag = 1; + attackPosition = i + 1; + } + + *accNrg = MAX(block_nrg[i], 0.25 * (*accNrg)); + } + + if (*lastAttackPosition > attdec_hangover_threshold) { + *attackFlag = 1; + } + + *lastAttackPosition = attackPosition; + } +} diff --git a/lib_lc3plus/clib.h b/lib_lc3plus/clib.h new file mode 100644 index 0000000000000000000000000000000000000000..44e70de788c2d2a20d00500dcb4551204de37c5a --- /dev/null +++ b/lib_lc3plus/clib.h @@ -0,0 +1,29 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.3 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + + +#ifndef CLIB_H +#define CLIB_H + +#include "options.h" +#include "wmc_auto.h" +#include +#include +#include +#include +#include +#include +#include +#ifndef _MSC_VER +#include "strings.h" +#else +#include +#endif + +#endif diff --git a/lib_lc3plus/constants.c b/lib_lc3plus/constants.c new file mode 100644 index 0000000000000000000000000000000000000000..3709a3f5a48c068d3d60a570e024bb1c71701453 --- /dev/null +++ b/lib_lc3plus/constants.c @@ -0,0 +1,6336 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.3 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + + +#include "options.h" +#include "wmc_auto.h" +#include "functions.h" + +/* DCT */ +#define ENTRY_DCT2_1 {0.353553, 0.000000} +#define ENTRY_DCT2_2 {0.351851, -0.034654} +#define ENTRY_DCT2_3 {0.346760, -0.068975} +#define ENTRY_DCT2_4 {0.338329, -0.102631} +#define ENTRY_DCT2_5 {0.326641, -0.135299} +#define ENTRY_DCT2_6 {0.311806, -0.166664} +#define ENTRY_DCT2_7 {0.293969, -0.196424} +#define ENTRY_DCT2_8 {0.273300, -0.224292} +#define ENTRY_DCT2_9 {0.250000, -0.250000} +#define ENTRY_DCT2_10 {0.224292, -0.273300} +#define ENTRY_DCT2_11 {0.196424, -0.293969} +#define ENTRY_DCT2_12 {0.166664, -0.311806} +#define ENTRY_DCT2_13 {0.135299, -0.326641} +#define ENTRY_DCT2_14 {0.102631, -0.338329} +#define ENTRY_DCT2_15 {0.068975, -0.346760} +#define ENTRY_DCT2_16 {0.034654, -0.351851} + +const Complex dct2_16[16] = { +ENTRY_DCT2_1, +ENTRY_DCT2_2, +ENTRY_DCT2_3, +ENTRY_DCT2_4, +ENTRY_DCT2_5, +ENTRY_DCT2_6, +ENTRY_DCT2_7, +ENTRY_DCT2_8, +ENTRY_DCT2_9, +ENTRY_DCT2_10, +ENTRY_DCT2_11, +ENTRY_DCT2_12, +ENTRY_DCT2_13, +ENTRY_DCT2_14, +ENTRY_DCT2_15, +ENTRY_DCT2_16 +}; + +const LC3_INT16 ari_tns_order_cf[2][9] = {{0, 3, 12, 35, 89, 200, 390, 658, 1024}, + {0, 14, 56, 156, 313, 494, 672, 839, 1024}}; + +const LC3_INT16 ari_tns_freq_cf[8][18] = { + {0, 1, 6, 21, 52, 106, 192, 289, 409, 568, 720, 831, 935, 994, 1016, 1022, 1023, 1024}, + {0, 1, 2, 3, 4, 17, 60, 154, 293, 466, 626, 780, 911, 989, 1016, 1022, 1023, 1024}, + {0, 1, 2, 3, 4, 13, 56, 162, 361, 578, 788, 929, 1003, 1020, 1021, 1022, 1023, 1024}, + {0, 1, 2, 3, 4, 6, 17, 66, 270, 555, 852, 972, 1011, 1020, 1021, 1022, 1023, 1024}, + {0, 1, 2, 3, 4, 5, 12, 54, 295, 636, 950, 1008, 1017, 1020, 1021, 1022, 1023, 1024}, + {0, 1, 2, 3, 4, 5, 6, 19, 224, 590, 967, 1014, 1019, 1020, 1021, 1022, 1023, 1024}, + {0, 1, 2, 3, 4, 5, 6, 19, 300, 630, 1001, 1018, 1019, 1020, 1021, 1022, 1023, 1024}, + {0, 1, 2, 3, 4, 5, 6, 11, 308, 309, 991, 1017, 1019, 1020, 1021, 1022, 1023, 1024}}; + +const LC3_INT ari_spec_lookup_fl[4096] = { + 0x01, 0x27, 0x07, 0x19, 0x16, 0x16, 0x1C, 0x16, 0x16, 0x16, 0x16, 0x1C, 0x1C, 0x1C, 0x22, 0x1F, 0x1F, 0x28, 0x2B, + 0x2E, 0x31, 0x34, 0x0E, 0x11, 0x24, 0x24, 0x24, 0x26, 0x00, 0x39, 0x26, 0x16, 0x00, 0x08, 0x09, 0x0B, 0x2F, 0x0E, + 0x0E, 0x11, 0x24, 0x24, 0x24, 0x26, 0x3B, 0x3B, 0x26, 0x16, 0x16, 0x1A, 0x2E, 0x1D, 0x1E, 0x20, 0x21, 0x23, 0x24, + 0x24, 0x24, 0x26, 0x00, 0x3B, 0x17, 0x16, 0x2E, 0x2E, 0x2D, 0x2F, 0x30, 0x32, 0x32, 0x12, 0x36, 0x36, 0x36, 0x26, + 0x3B, 0x3B, 0x3B, 0x16, 0x00, 0x3E, 0x3F, 0x03, 0x21, 0x02, 0x02, 0x3D, 0x14, 0x14, 0x14, 0x15, 0x3B, 0x3B, 0x27, + 0x1C, 0x1C, 0x3F, 0x3F, 0x03, 0x21, 0x02, 0x02, 0x3D, 0x26, 0x26, 0x26, 0x15, 0x3B, 0x3B, 0x27, 0x1C, 0x1C, 0x06, + 0x06, 0x06, 0x02, 0x12, 0x3D, 0x14, 0x15, 0x15, 0x15, 0x3B, 0x27, 0x27, 0x07, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, + 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x33, 0x33, 0x33, 0x35, 0x36, 0x14, 0x26, + 0x26, 0x39, 0x27, 0x27, 0x27, 0x07, 0x18, 0x22, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x38, 0x26, 0x39, 0x39, 0x3B, 0x07, 0x07, 0x07, 0x2A, + 0x2A, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x05, 0x04, 0x04, 0x05, 0x15, 0x15, 0x3B, 0x07, 0x07, 0x07, 0x07, 0x19, 0x19, 0x19, 0x22, 0x04, 0x04, 0x04, 0x04, + 0x05, 0x17, 0x17, 0x27, 0x07, 0x07, 0x07, 0x2A, 0x19, 0x19, 0x16, 0x1F, 0x1F, 0x27, 0x27, 0x27, 0x27, 0x07, 0x07, + 0x2A, 0x00, 0x19, 0x16, 0x16, 0x16, 0x1C, 0x22, 0x1F, 0x37, 0x37, 0x37, 0x37, 0x37, 0x37, 0x37, 0x37, 0x37, 0x37, + 0x37, 0x37, 0x37, 0x37, 0x37, 0x37, 0x37, 0x37, 0x28, 0x08, 0x09, 0x31, 0x31, 0x34, 0x11, 0x11, 0x11, 0x04, 0x00, + 0x14, 0x11, 0x3C, 0x28, 0x28, 0x08, 0x2B, 0x1B, 0x31, 0x31, 0x0E, 0x11, 0x11, 0x11, 0x24, 0x2A, 0x2A, 0x11, 0x39, + 0x39, 0x28, 0x08, 0x1A, 0x1B, 0x31, 0x0C, 0x0E, 0x11, 0x11, 0x11, 0x24, 0x00, 0x26, 0x24, 0x01, 0x08, 0x08, 0x2B, + 0x09, 0x0B, 0x31, 0x0C, 0x0E, 0x0E, 0x21, 0x32, 0x32, 0x32, 0x3D, 0x24, 0x27, 0x08, 0x08, 0x2B, 0x2E, 0x31, 0x34, + 0x1E, 0x0E, 0x0E, 0x21, 0x32, 0x32, 0x32, 0x32, 0x12, 0x19, 0x08, 0x08, 0x2B, 0x2E, 0x31, 0x34, 0x1E, 0x0E, 0x0E, + 0x12, 0x05, 0x05, 0x05, 0x3D, 0x12, 0x17, 0x2B, 0x2B, 0x2B, 0x09, 0x31, 0x34, 0x03, 0x0E, 0x0E, 0x32, 0x32, 0x32, + 0x32, 0x3D, 0x11, 0x18, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, + 0x2B, 0x2B, 0x2B, 0x2B, 0x09, 0x0B, 0x34, 0x34, 0x0E, 0x0E, 0x11, 0x3D, 0x3D, 0x3D, 0x36, 0x11, 0x27, 0x2D, 0x2D, + 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2C, 0x1B, 0x1D, + 0x34, 0x30, 0x34, 0x34, 0x11, 0x11, 0x11, 0x11, 0x02, 0x11, 0x07, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, + 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x09, 0x1B, 0x1B, 0x0C, 0x34, 0x0E, 0x0E, 0x3A, 0x29, + 0x29, 0x29, 0x06, 0x11, 0x25, 0x09, 0x09, 0x09, 0x1B, 0x0B, 0x31, 0x0C, 0x34, 0x0E, 0x0E, 0x0E, 0x32, 0x00, 0x35, + 0x11, 0x1C, 0x34, 0x34, 0x31, 0x34, 0x0C, 0x34, 0x1E, 0x0E, 0x0E, 0x11, 0x02, 0x02, 0x02, 0x26, 0x26, 0x22, 0x1F, + 0x22, 0x22, 0x1F, 0x1F, 0x1F, 0x1F, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x1F, 0x13, 0x2C, 0x2C, 0x3E, 0x1E, + 0x20, 0x3A, 0x23, 0x24, 0x24, 0x26, 0x00, 0x3B, 0x07, 0x07, 0x27, 0x22, 0x22, 0x2D, 0x2F, 0x30, 0x21, 0x23, 0x23, + 0x24, 0x26, 0x26, 0x26, 0x3B, 0x07, 0x07, 0x27, 0x22, 0x22, 0x3E, 0x1E, 0x0F, 0x32, 0x35, 0x35, 0x36, 0x15, 0x15, + 0x15, 0x3B, 0x07, 0x07, 0x07, 0x22, 0x1E, 0x1E, 0x30, 0x21, 0x3A, 0x12, 0x12, 0x38, 0x17, 0x17, 0x17, 0x3B, 0x07, + 0x07, 0x18, 0x22, 0x22, 0x06, 0x06, 0x3A, 0x35, 0x36, 0x36, 0x15, 0x3B, 0x3B, 0x3B, 0x27, 0x07, 0x07, 0x2A, 0x22, + 0x06, 0x06, 0x21, 0x3A, 0x35, 0x36, 0x3D, 0x15, 0x3B, 0x3B, 0x3B, 0x27, 0x07, 0x07, 0x2A, 0x22, 0x22, 0x33, 0x33, + 0x35, 0x36, 0x38, 0x38, 0x39, 0x27, 0x27, 0x27, 0x07, 0x2A, 0x2A, 0x19, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, + 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x04, 0x04, 0x04, 0x05, 0x17, 0x17, 0x27, 0x07, + 0x07, 0x07, 0x2A, 0x19, 0x19, 0x16, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, + 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x05, 0x05, 0x05, 0x05, 0x39, 0x39, 0x27, 0x18, 0x18, 0x18, 0x2A, 0x16, 0x16, 0x1C, + 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x29, + 0x29, 0x29, 0x29, 0x27, 0x27, 0x07, 0x2A, 0x2A, 0x2A, 0x19, 0x1C, 0x1C, 0x1C, 0x1F, 0x1F, 0x29, 0x29, 0x29, 0x29, + 0x27, 0x27, 0x18, 0x19, 0x19, 0x19, 0x16, 0x1C, 0x1C, 0x22, 0x1F, 0x1F, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x1C, + 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x1F, 0x13, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x09, 0x0B, 0x2F, 0x20, 0x32, 0x12, 0x12, 0x14, 0x15, 0x15, 0x15, 0x27, + 0x3B, 0x22, 0x1A, 0x1A, 0x1B, 0x1D, 0x1E, 0x21, 0x32, 0x12, 0x12, 0x14, 0x39, 0x39, 0x39, 0x3B, 0x3B, 0x22, 0x1B, + 0x1B, 0x0B, 0x0C, 0x30, 0x32, 0x3A, 0x3D, 0x3D, 0x38, 0x39, 0x39, 0x39, 0x3B, 0x27, 0x22, 0x2D, 0x2D, 0x0C, 0x1E, + 0x20, 0x02, 0x02, 0x3D, 0x26, 0x26, 0x26, 0x39, 0x00, 0x3B, 0x27, 0x22, 0x3F, 0x3F, 0x03, 0x20, 0x3A, 0x12, 0x12, + 0x14, 0x15, 0x15, 0x15, 0x3B, 0x27, 0x27, 0x07, 0x1F, 0x1F, 0x03, 0x03, 0x21, 0x3A, 0x12, 0x12, 0x14, 0x15, 0x15, + 0x15, 0x3B, 0x07, 0x07, 0x07, 0x1F, 0x06, 0x06, 0x33, 0x33, 0x35, 0x36, 0x36, 0x26, 0x39, 0x39, 0x39, 0x27, 0x07, + 0x07, 0x2A, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, + 0x1F, 0x33, 0x35, 0x35, 0x36, 0x38, 0x38, 0x39, 0x3B, 0x3B, 0x3B, 0x07, 0x18, 0x18, 0x19, 0x1F, 0x1F, 0x1F, 0x1F, + 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x04, 0x04, 0x04, 0x36, 0x15, + 0x15, 0x39, 0x27, 0x27, 0x27, 0x07, 0x2A, 0x2A, 0x16, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, + 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x05, 0x05, 0x05, 0x05, 0x17, 0x17, 0x3B, 0x07, 0x07, 0x07, 0x2A, + 0x16, 0x16, 0x1C, 0x1F, 0x1F, 0x04, 0x04, 0x04, 0x05, 0x17, 0x17, 0x27, 0x18, 0x18, 0x18, 0x19, 0x1C, 0x1C, 0x22, + 0x1F, 0x1F, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x1C, 0x22, 0x22, 0x22, 0x1F, 0x1F, 0x1F, 0x1F, 0x13, 0x0D, 0x0D, + 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x3C, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x0D, 0x0D, 0x0D, 0x3C, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, + 0x0D, 0x3C, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x3C, 0x3C, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x3C, 0x3C, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, + 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, + 0x3C, 0x3C, 0x3C, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x3C, + 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x3C, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, + 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, + 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x0D, 0x00, + 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x00, 0x3C, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x3C, 0x3C, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x3C, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x0D, 0x3C, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x0D, 0x0D, 0x0D, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x0D, 0x00, + 0x0D, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x0D, 0x00, 0x00, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, + 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x3C, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x10, + 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x25, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, + 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, + 0x0D, 0x0D, 0x0D, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, + 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x3C, 0x10, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x3C, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x3C, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, + 0x0D, 0x0D, 0x0D, 0x3C, 0x10, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, + 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x3C, 0x3C, 0x10, 0x0D, + 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, + 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x3C, 0x3C, 0x10, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, + 0x0D, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x10, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, + 0x10, 0x10, 0x10, 0x10, 0x10, 0x25, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x0D, 0x10, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x0D, 0x0D, 0x10, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, + 0x0D, 0x0D, 0x0D, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x3C, + 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x3C, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x00, 0x0D, + 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x3C, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, + 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x3C, 0x3C, + 0x3C, 0x10, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x10, 0x10, 0x10, + 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x25, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x0D, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, + 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x0D, + 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, + 0x0D, 0x0D, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x0D, 0x0D, 0x0D, 0x00, 0x0D, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, + 0x0D, 0x0D, 0x0D, 0x00, 0x0D, 0x0D, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x00, 0x00, 0x00, + 0x00, 0x0D, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x0D, 0x00, 0x0D, 0x0D, + 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x00, 0x13, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, + 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x13, 0x0D, 0x0D, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x0D, + 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x0D, 0x0D, 0x0D, 0x0D, + 0x0D, 0x0D, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x0D, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, + 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x3C, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x3C, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, + 0x3C, 0x3C, 0x3C, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, + 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x0D, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x0D, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x3C, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x0D, 0x0D, 0x0D, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x3C, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x3C, 0x0D, 0x0D, 0x0D, + 0x0D, 0x0D, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x0D, 0x0D, 0x00, + 0x00, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, + 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, + 0x0D, 0x0D, 0x0D, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x3C, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + +const LC3_INT16 ari_spec_cumfreq_fl[64][18] = { + {0, 1, 2, 177, 225, 226, 227, 336, 372, 543, 652, 699, 719, 768, 804, 824, 834, 1024}, + {0, 18, 44, 61, 71, 98, 135, 159, 175, 197, 229, 251, 265, 282, 308, 328, 341, 1024}, + {0, 71, 163, 212, 237, 318, 420, 481, 514, 556, 613, 652, 675, 697, 727, 749, 764, 1024}, + {0, 160, 290, 336, 354, 475, 598, 653, 677, 722, 777, 808, 823, 842, 866, 881, 890, 1024}, + {0, 71, 144, 177, 195, 266, 342, 385, 411, 445, 489, 519, 539, 559, 586, 607, 622, 1024}, + {0, 48, 108, 140, 159, 217, 285, 327, 354, 385, 427, 457, 478, 497, 524, 545, 561, 1024}, + {0, 138, 247, 290, 308, 419, 531, 584, 609, 655, 710, 742, 759, 780, 807, 825, 836, 1024}, + {0, 16, 40, 62, 79, 103, 139, 170, 195, 215, 245, 270, 290, 305, 327, 346, 362, 1024}, + {0, 579, 729, 741, 743, 897, 970, 980, 982, 996, 1007, 1010, 1011, 1014, 1017, 1018, 1019, 1024}, + {0, 398, 582, 607, 612, 788, 902, 925, 931, 956, 979, 987, 990, 996, 1002, 1005, 1007, 1024}, + {0, 13, 34, 52, 63, 83, 112, 134, 149, 163, 183, 199, 211, 221, 235, 247, 257, 1024}, + {0, 281, 464, 501, 510, 681, 820, 857, 867, 902, 938, 953, 959, 968, 978, 984, 987, 1024}, + {0, 198, 362, 408, 421, 575, 722, 773, 789, 832, 881, 905, 915, 928, 944, 954, 959, 1024}, + {0, 1, 2, 95, 139, 140, 141, 213, 251, 337, 407, 450, 475, 515, 551, 576, 592, 1024}, + {0, 133, 274, 338, 366, 483, 605, 664, 691, 730, 778, 807, 822, 837, 857, 870, 878, 1024}, + {0, 128, 253, 302, 320, 443, 577, 636, 659, 708, 767, 799, 814, 833, 857, 872, 881, 1024}, + {0, 1, 2, 25, 42, 43, 44, 67, 85, 105, 126, 144, 159, 174, 191, 205, 217, 1024}, + {0, 70, 166, 229, 267, 356, 468, 533, 569, 606, 653, 685, 705, 722, 745, 762, 774, 1024}, + {0, 55, 130, 175, 200, 268, 358, 416, 449, 488, 542, 581, 606, 628, 659, 683, 699, 1024}, + {0, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 1024}, + {0, 34, 85, 123, 147, 196, 265, 317, 352, 386, 433, 470, 497, 518, 549, 574, 593, 1024}, + {0, 30, 73, 105, 127, 170, 229, 274, 305, 335, 377, 411, 436, 455, 483, 506, 524, 1024}, + {0, 9, 24, 38, 51, 65, 87, 108, 126, 139, 159, 177, 193, 204, 221, 236, 250, 1024}, + {0, 30, 74, 105, 125, 166, 224, 266, 294, 322, 361, 391, 413, 431, 457, 478, 494, 1024}, + {0, 15, 38, 58, 73, 95, 128, 156, 178, 196, 222, 245, 263, 276, 296, 314, 329, 1024}, + {0, 11, 28, 44, 57, 74, 100, 123, 142, 157, 179, 199, 216, 228, 246, 262, 276, 1024}, + {0, 448, 619, 639, 643, 821, 926, 944, 948, 971, 991, 998, 1000, 1005, 1010, 1012, 1013, 1024}, + {0, 332, 520, 549, 555, 741, 874, 903, 910, 940, 970, 981, 985, 991, 998, 1002, 1004, 1024}, + {0, 8, 21, 34, 45, 58, 78, 96, 112, 124, 141, 157, 170, 180, 194, 207, 219, 1024}, + {0, 239, 415, 457, 468, 631, 776, 820, 833, 872, 914, 933, 940, 951, 964, 971, 975, 1024}, + {0, 165, 310, 359, 375, 513, 652, 707, 727, 774, 828, 856, 868, 884, 904, 916, 923, 1024}, + {0, 3, 8, 13, 18, 23, 30, 37, 44, 48, 55, 62, 68, 72, 78, 84, 90, 1024}, + {0, 115, 237, 289, 311, 422, 547, 608, 635, 680, 737, 771, 788, 807, 832, 849, 859, 1024}, + {0, 107, 221, 272, 293, 399, 521, 582, 610, 656, 714, 749, 767, 787, 813, 831, 842, 1024}, + {0, 6, 16, 26, 35, 45, 60, 75, 89, 98, 112, 125, 137, 145, 157, 168, 178, 1024}, + {0, 72, 160, 210, 236, 320, 422, 482, 514, 555, 608, 644, 665, 685, 712, 732, 745, 1024}, + {0, 45, 108, 153, 183, 244, 327, 385, 421, 455, 502, 536, 559, 578, 605, 626, 641, 1024}, + {0, 1, 2, 9, 16, 17, 18, 26, 34, 40, 48, 55, 62, 68, 75, 82, 88, 1024}, + {0, 29, 73, 108, 132, 174, 236, 284, 318, 348, 391, 426, 452, 471, 500, 524, 543, 1024}, + {0, 20, 51, 76, 93, 123, 166, 200, 225, 247, 279, 305, 326, 342, 365, 385, 401, 1024}, + {0, 742, 845, 850, 851, 959, 997, 1001, 1002, 1009, 1014, 1016, 1017, 1019, 1020, 1021, 1022, 1024}, + {0, 42, 94, 121, 137, 186, 244, 280, 303, 330, 366, 392, 410, 427, 451, 470, 484, 1024}, + {0, 13, 33, 51, 66, 85, 114, 140, 161, 178, 203, 225, 243, 256, 275, 292, 307, 1024}, + {0, 501, 670, 689, 693, 848, 936, 952, 956, 975, 991, 997, 999, 1004, 1008, 1010, 1011, 1024}, + {0, 445, 581, 603, 609, 767, 865, 888, 895, 926, 954, 964, 968, 977, 986, 991, 993, 1024}, + {0, 285, 442, 479, 489, 650, 779, 818, 830, 870, 912, 930, 937, 949, 963, 971, 975, 1024}, + {0, 349, 528, 561, 569, 731, 852, 883, 892, 923, 953, 965, 970, 978, 987, 992, 994, 1024}, + {0, 199, 355, 402, 417, 563, 700, 750, 767, 811, 860, 884, 894, 909, 926, 936, 942, 1024}, + {0, 141, 275, 325, 343, 471, 606, 664, 686, 734, 791, 822, 836, 854, 877, 891, 899, 1024}, + {0, 243, 437, 493, 510, 649, 775, 820, 836, 869, 905, 923, 931, 941, 953, 960, 964, 1024}, + {0, 91, 197, 248, 271, 370, 487, 550, 580, 625, 684, 721, 741, 761, 788, 807, 819, 1024}, + {0, 107, 201, 242, 262, 354, 451, 503, 531, 573, 626, 660, 680, 701, 730, 751, 765, 1024}, + {0, 168, 339, 407, 432, 553, 676, 731, 755, 789, 830, 854, 866, 879, 895, 906, 912, 1024}, + {0, 67, 147, 191, 214, 290, 384, 441, 472, 513, 567, 604, 627, 648, 678, 700, 715, 1024}, + {0, 46, 109, 148, 171, 229, 307, 359, 391, 427, 476, 513, 537, 558, 588, 612, 629, 1024}, + {0, 848, 918, 920, 921, 996, 1012, 1013, 1014, 1016, 1017, 1018, 1019, 1020, 1021, 1022, 1023, 1024}, + {0, 36, 88, 123, 145, 193, 260, 308, 340, 372, 417, 452, 476, 496, 525, 548, 565, 1024}, + {0, 24, 61, 90, 110, 145, 196, 237, 266, 292, 330, 361, 385, 403, 430, 453, 471, 1024}, + {0, 85, 182, 230, 253, 344, 454, 515, 545, 590, 648, 685, 706, 727, 756, 776, 789, 1024}, + {0, 22, 55, 82, 102, 135, 183, 222, 252, 278, 315, 345, 368, 385, 410, 431, 448, 1024}, + {0, 1, 2, 56, 89, 90, 91, 140, 172, 221, 268, 303, 328, 358, 388, 412, 430, 1024}, + {0, 45, 109, 152, 177, 239, 320, 376, 411, 448, 499, 537, 563, 585, 616, 640, 658, 1024}, + {0, 247, 395, 433, 445, 599, 729, 771, 785, 829, 875, 896, 905, 920, 937, 946, 951, 1024}, + {0, 231, 367, 408, 423, 557, 676, 723, 742, 786, 835, 860, 872, 889, 909, 921, 928, 1024}}; + +const LC3_INT ari_spec_bits_fl[64][17] = { + {20480, 20480, 5220, 9042, 20480, 20480, 6619, 9892, 5289, 6619, 9105, 11629, 8982, 9892, 11629, 13677, 4977}, + {11940, 10854, 12109, 13677, 10742, 9812, 11090, 12288, 11348, 10240, 11348, 12683, 12109, 10854, 11629, 12902, + 1197}, + {7886, 7120, 8982, 10970, 7496, 6815, 8334, 10150, 9437, 8535, 9656, 11216, 11348, 10431, 11348, 12479, 4051}, + {5485, 6099, 9168, 11940, 6311, 6262, 8640, 11090, 9233, 8640, 10334, 12479, 11781, 11090, 12479, 13988, 6009}, + {7886, 7804, 10150, 11940, 7886, 7685, 9368, 10854, 10061, 9300, 10431, 11629, 11629, 10742, 11485, 12479, 2763}, + {9042, 8383, 10240, 11781, 8483, 8013, 9437, 10742, 10334, 9437, 10431, 11485, 11781, 10742, 11485, 12288, 2346}, + {5922, 6619, 9368, 11940, 6566, 6539, 8750, 10970, 9168, 8640, 10240, 12109, 11485, 10742, 11940, 13396, 5009}, + {12288, 11090, 11348, 12109, 11090, 9892, 10334, 10970, 11629, 10431, 10970, 11629, 12479, 11348, 11781, 12288, + 1289}, + {1685, 5676, 13138, 18432, 5598, 7804, 13677, 18432, 12683, 13396, 17234, 20480, 17234, 17234, 20480, 20480, 15725}, + {2793, 5072, 10970, 15725, 5204, 6487, 11216, 15186, 10970, 11216, 14336, 17234, 15186, 15186, 17234, 18432, 12109}, + {12902, 11485, 11940, 13396, 11629, 10531, 11348, 12479, 12683, 11629, 12288, 13138, 13677, 12683, 13138, 13677, + 854}, + {3821, 5088, 9812, 13988, 5289, 5901, 9812, 13677, 9976, 9892, 12479, 15186, 13988, 13677, 15186, 17234, 9812}, + {4856, 5412, 9168, 12902, 5598, 5736, 8863, 12288, 9368, 8982, 11090, 13677, 12902, 12288, 13677, 15725, 8147}, + {20480, 20480, 7088, 9300, 20480, 20480, 7844, 9733, 7320, 7928, 9368, 10970, 9581, 9892, 10970, 12288, 2550}, + {6031, 5859, 8192, 10635, 6410, 6286, 8433, 10742, 9656, 9042, 10531, 12479, 12479, 11629, 12902, 14336, 5756}, + {6144, 6215, 8982, 11940, 6262, 6009, 8433, 11216, 8982, 8433, 10240, 12479, 11781, 11090, 12479, 13988, 5817}, + {20480, 20480, 11216, 12109, 20480, 20480, 11216, 11940, 11629, 11485, 11940, 12479, 12479, 12109, 12683, 13138, + 704}, + {7928, 6994, 8239, 9733, 7218, 6539, 8147, 9892, 9812, 9105, 10240, 11629, 12109, 11216, 12109, 13138, 4167}, + {8640, 7724, 9233, 10970, 8013, 7185, 8483, 10150, 9656, 8694, 9656, 10970, 11348, 10334, 11090, 12288, 3391}, + {20480, 18432, 18432, 18432, 18432, 18432, 18432, 18432, 18432, 18432, 18432, 18432, 18432, 18432, 18432, 18432, + 91}, + {10061, 8863, 9733, 11090, 8982, 7970, 8806, 9976, 10061, 9105, 9812, 10742, 11485, 10334, 10970, 11781, 2557}, + {10431, 9368, 10240, 11348, 9368, 8433, 9233, 10334, 10431, 9437, 10061, 10970, 11781, 10635, 11216, 11940, 2119}, + {13988, 12479, 12683, 12902, 12683, 11348, 11485, 11940, 12902, 11629, 11940, 12288, 13396, 12109, 12479, 12683, + 828}, + {10431, 9300, 10334, 11629, 9508, 8483, 9437, 10635, 10635, 9656, 10431, 11348, 11940, 10854, 11485, 12288, 1946}, + {12479, 11216, 11629, 12479, 11348, 10150, 10635, 11348, 11940, 10854, 11216, 11940, 12902, 11629, 11940, 12479, + 1146}, + {13396, 12109, 12288, 12902, 12109, 10854, 11216, 11781, 12479, 11348, 11629, 12109, 13138, 11940, 12288, 12683, + 928}, + {2443, 5289, 11629, 16384, 5170, 6730, 11940, 16384, 11216, 11629, 14731, 18432, 15725, 15725, 18432, 20480, 13396}, + {3328, 5009, 10531, 15186, 5040, 6031, 10531, 14731, 10431, 10431, 13396, 16384, 15186, 14731, 16384, 18432, 11629}, + {14336, 12902, 12902, 13396, 12902, 11629, 11940, 12288, 13138, 12109, 12288, 12902, 13677, 12683, 12902, 13138, + 711}, + {4300, 5204, 9437, 13396, 5430, 5776, 9300, 12902, 9656, 9437, 11781, 14731, 13396, 12902, 14731, 16384, 8982}, + {5394, 5776, 8982, 12288, 5922, 5901, 8640, 11629, 9105, 8694, 10635, 13138, 12288, 11629, 13138, 14731, 6844}, + {17234, 15725, 15725, 15725, 15725, 14731, 14731, 14731, 16384, 14731, 14731, 15186, 16384, 15186, 15186, 15186, + 272}, + {6461, 6286, 8806, 11348, 6566, 6215, 8334, 10742, 9233, 8535, 10061, 12109, 11781, 10970, 12109, 13677, 5394}, + {6674, 6487, 8863, 11485, 6702, 6286, 8334, 10635, 9168, 8483, 9976, 11940, 11629, 10854, 11940, 13396, 5105}, + {15186, 13677, 13677, 13988, 13677, 12479, 12479, 12683, 13988, 12683, 12902, 13138, 14336, 13138, 13396, 13677, + 565}, + {7844, 7252, 8922, 10854, 7389, 6815, 8383, 10240, 9508, 8750, 9892, 11485, 11629, 10742, 11629, 12902, 3842}, + {9233, 8239, 9233, 10431, 8334, 7424, 8483, 9892, 10061, 9105, 10061, 11216, 11781, 10742, 11485, 12479, 2906}, + {20480, 20480, 14731, 14731, 20480, 20480, 14336, 14336, 15186, 14336, 14731, 14731, 15186, 14731, 14731, 15186, + 266}, + {10531, 9300, 9976, 11090, 9437, 8286, 9042, 10061, 10431, 9368, 9976, 10854, 11781, 10531, 11090, 11781, 2233}, + {11629, 10334, 10970, 12109, 10431, 9368, 10061, 10970, 11348, 10240, 10854, 11485, 12288, 11216, 11629, 12288, + 1469}, + {952, 6787, 15725, 20480, 6646, 9733, 16384, 20480, 14731, 15725, 18432, 20480, 18432, 20480, 20480, 20480, 18432}, + {9437, 8806, 10742, 12288, 8982, 8483, 9892, 11216, 10742, 9892, 10854, 11940, 12109, 11090, 11781, 12683, 1891}, + {12902, 11629, 11940, 12479, 11781, 10531, 10854, 11485, 12109, 10970, 11348, 11940, 12902, 11781, 12109, 12479, + 1054}, + {2113, 5323, 11781, 16384, 5579, 7252, 12288, 16384, 11781, 12288, 15186, 18432, 15725, 16384, 18432, 20480, 12902}, + {2463, 5965, 11348, 15186, 5522, 6934, 11216, 14731, 10334, 10635, 13677, 16384, 13988, 13988, 15725, 18432, 10334}, + {3779, 5541, 9812, 13677, 5467, 6122, 9656, 13138, 9581, 9437, 11940, 14731, 13138, 12683, 14336, 16384, 8982}, + {3181, 5154, 10150, 14336, 5448, 6311, 10334, 13988, 10334, 10431, 13138, 15725, 14336, 13988, 15725, 18432, 10431}, + {4841, 5560, 9105, 12479, 5756, 5944, 8922, 12109, 9300, 8982, 11090, 13677, 12479, 12109, 13677, 15186, 7460}, + {5859, 6009, 8922, 11940, 6144, 5987, 8483, 11348, 9042, 8535, 10334, 12683, 11940, 11216, 12683, 14336, 6215}, + {4250, 4916, 8587, 12109, 5901, 6191, 9233, 12288, 10150, 9892, 11940, 14336, 13677, 13138, 14731, 16384, 8383}, + {7153, 6702, 8863, 11216, 6904, 6410, 8239, 10431, 9233, 8433, 9812, 11629, 11629, 10742, 11781, 13138, 4753}, + {6674, 7057, 9508, 11629, 7120, 6964, 8806, 10635, 9437, 8750, 10061, 11629, 11485, 10531, 11485, 12683, 4062}, + {5341, 5289, 8013, 10970, 6311, 6262, 8640, 11090, 10061, 9508, 11090, 13138, 12902, 12288, 13396, 15186, 6539}, + {8057, 7533, 9300, 11216, 7685, 7057, 8535, 10334, 9508, 8694, 9812, 11216, 11485, 10431, 11348, 12479, 3541}, + {9168, 8239, 9656, 11216, 8483, 7608, 8806, 10240, 9892, 8982, 9812, 11090, 11485, 10431, 11090, 12109, 2815}, + {558, 7928, 18432, 20480, 7724, 12288, 20480, 20480, 18432, 20480, 20480, 20480, 20480, 20480, 20480, 20480, 20480}, + {9892, 8806, 9976, 11348, 9042, 8057, 9042, 10240, 10240, 9233, 9976, 11090, 11629, 10531, 11216, 12109, 2371}, + {11090, 9812, 10531, 11629, 9976, 8863, 9508, 10531, 10854, 9733, 10334, 11090, 11940, 10742, 11216, 11940, 1821}, + {7354, 6964, 9042, 11216, 7153, 6592, 8334, 10431, 9233, 8483, 9812, 11485, 11485, 10531, 11629, 12902, 4349}, + {11348, 10150, 10742, 11629, 10150, 9042, 9656, 10431, 10854, 9812, 10431, 11216, 12109, 10970, 11485, 12109, 1700}, + {20480, 20480, 8694, 10150, 20480, 20480, 8982, 10240, 8982, 9105, 9976, 10970, 10431, 10431, 11090, 11940, 1610}, + {9233, 8192, 9368, 10970, 8286, 7496, 8587, 9976, 9812, 8863, 9733, 10854, 11348, 10334, 11090, 11940, 3040}, + {4202, 5716, 9733, 13138, 5598, 6099, 9437, 12683, 9300, 9168, 11485, 13988, 12479, 12109, 13988, 15725, 7804}, + {4400, 5965, 9508, 12479, 6009, 6360, 9105, 11781, 9300, 8982, 10970, 13138, 12109, 11629, 13138, 14731, 6994}}; + +const LC3_FLOAT sns_LFCB[8][32] = { + {2.26283365592678, 2.94516479191376, -2.18610707009979, 0.693688236528920, -1.29752132315296, 0.914652037830672, + -2.51428812578962, -0.922188404812385, 0.790322288369266, 1.44775580178724, 0.793354526417474, 2.72425347385034, + -0.530830198375400, 1.68728410845006, -2.95183272801858, 0.101878342785628, 2.68254575498426, 4.82697923680403, + 0.0878419936470335, 1.39102308204326, 0.384585893889182, 1.93227399441719, 0.175080462899884, -1.18817020250556, + 2.53322203327061, 3.99889837485606, 0.507902593186381, 3.16856825107569, 1.89414766731764, 0.948880604517188, + -1.88026757045628, 0.246375746277129}, + {0.813311269061339, 2.41143317956679, -1.97152135675228, 0.955609857158220, -0.740369057177853, + 1.74293043435257, -2.89175271384373, 0.632495141440552, 0.628401261876199, 2.72399951674952, + 0.0143931185523454, 2.95947572404824, -0.212690682812164, 2.43614509237656, -1.59393496773345, + 0.589857324228917, 1.32738010899420, 3.11947804492488, -0.569586840238501, 1.98146479199466, + -0.160588785536510, 3.01030180412057, -0.750522832248985, 0.366792873662636, 2.11274642695908, + 4.07901751451956, 1.58838449789527, 3.25853458159407, 1.25108694609232, 2.13239439249982, + -1.26431072758705, 0.955621773393099}, + {-0.530193494871436, 0.960455106400727, -1.78718619681006, 0.575230787038733, -0.345372483642106, + 1.90906626859986, -2.00450666759434, 1.08736431254641, 0.393117923540450, 2.31083268737528, + -0.567834844729679, 1.84953559268461, 0.00576613628377097, 2.33019429078225, -0.109918772878022, + 0.619047646793466, 0.130185273804048, 1.39513671385178, -1.14506015668811, 1.11265796388770, + -0.539366809557710, 3.06543893826204, -1.03943893342231, 1.30957830409096, 1.26288411502064, + 2.82285661102496, 1.72899023869209, 2.42230591328599, 0.590451210720628, 2.72345350344278, + 0.311424976968699, 1.52046776741766}, + {-1.35664835903442, -0.443226488076917, -1.91865895685577, -0.114603419462889, -0.313285696247940, + 1.54408483842665, -0.750912273903127, 0.608628624535820, 0.480007710866901, 0.935051269566529, + -0.654760467916745, 0.563284922322364, 0.424871484383745, 1.77983777835091, 0.388609072919257, + 1.26731313851796, -0.338533088511347, 0.250295315918722, -1.66968488172598, -0.220107509420743, + -0.529309078789857, 2.50110160870008, -1.13577508937648, 1.68330687280491, 0.761513512430427, + 1.72607212849580, 1.00692230241726, 1.79446077643261, 0.608358583293714, 2.76986076866588, + 1.83670210306430, 1.97647400419457}, + {-1.59952176563196, -1.22913612425590, -1.79399121836596, -0.646050637436029, -0.402977242824477, + 1.09344960761455, 0.441202104904691, 0.131174567547348, 0.447815138050143, -0.274743911383688, + -0.479458998475743, 0.139917088125072, 0.473128952158668, 1.44411295390082, 0.512932649517584, + 2.41961047769804, -0.368219235899667, -0.393613839379793, -1.84534417603682, -0.774965611552366, + 0.190433547437932, 1.93089592978934, -1.04197903837494, 1.25100924225127, 0.522117937976170, + 0.647144377348619, 0.377121231816382, 1.52177910653089, 0.878171010011082, 2.54286973254946, + 2.25634191839874, 1.94043867177462}, + {-1.44098768430095, -1.55590039118170, -1.35738404257288, -0.952351370449625, -0.372020853465227, + 0.647479549518278, 1.20190987601009, -0.296149157743752, 0.209734214552234, -0.902077696828602, + -0.173894661902889, 0.359641093366222, 0.858894199321281, 1.51995177009730, 0.628112597063497, + 2.25174252572187, -0.191689946715961, -0.643458173054701, -1.56468027328802, -0.594063874149117, + 2.56062918106522, 0.572153810961837, -0.0152060098993382, 0.942375751628615, 0.118680069757121, + -0.331148521217238, 0.476370766899498, 1.17196706537602, 1.11912510950950, 2.02046263825019, + 2.04818998463474, 2.23375847282686}, + {-1.14381648305821, -1.49688655952376, -0.705444279353869, -1.07405247226150, -0.0783414177323738, + 0.0361790752449642, 1.32742857257290, -0.207013516525629, 0.00656691996428021, -0.940681511945404, + 0.0680162705515438, 0.689461354774589, 1.19111160854435, 1.47199393750425, 0.822621796430634, + 0.526537030991201, -0.154782377153908, -0.642570736856943, -1.11746759076420, 0.136937680628923, + 2.81896398245248, -0.811741794081091, 2.07048391716707, 0.826250483374133, -0.452346827507370, + -0.884042570848749, 1.08754740372170, 0.489394596980695, 1.01857661550342, 0.830045859400910, + 2.19526837458568, 1.98835977758407}, + {-0.755203767909064, -1.11689986501469, -0.0478172944777711, -0.758087707094905, 0.0970441303992295, + -0.297092807178889, 1.22049081140984, 0.134924916642080, -0.0861242342061857, -0.633697038974310, + 0.295125948369794, 0.639790176833105, 0.996189669638358, 0.977682473891761, 0.875891424655081, + -0.396591513227999, -0.234207177774392, -0.723193223444072, -0.533981663366786, 0.818242891264338, + 0.656670875696161, -1.17641810861903, 3.42948918081689, 0.439952741120956, -0.700352426161103, + -1.12697340645478, 1.08756266099221, -0.0622795715718769, 0.620453891011724, -0.0275569173888263, + 2.02659613836619, 1.27232672554701}}; + +const LC3_FLOAT sns_HFCB[8][32] = { + {0.232028419124465, -1.29503936673618, 0.139285716045803, -0.316513102185725, 0.879518405226496, + -0.296701922455375, 0.340981100469697, -1.41229759077597, -0.228839511827379, -1.07148628544449, + -0.590988511188051, -0.848434098836164, 1.14069145562382, -0.376283237967464, 0.665004120598402, + -0.826265953982679, 1.41008326832173, 0.361386817574348, 0.437469239330329, 0.648100318996503, + 1.11919833091304, 0.141847497087176, 0.504046955390252, -0.501076050479357, 3.74970982709642, + -1.15258990980549, 1.02827246422140, 0.128831971707817, 1.34033030334757, 2.13843105419313, + 0.564830487355396, -0.422460547586087}, + {-1.00890270604455, -1.79929965384339, -0.258185126171752, -0.477747657209805, 0.298340096007189, + -0.975004919174553, 0.268899788946055, -1.48522119349852, -0.333719069784662, -1.41767015456261, + -0.0711737758537628, -0.583226810708889, 0.964016892398293, 0.0425675462096105, 1.09790764690795, + -0.671181232766603, 0.754441907835468, -0.0219991705427826, 0.305440419605961, 0.682299133640680, + 1.23465532536005, -0.110660070633151, 0.826982162959097, -0.325678006081417, 1.52342611847045, + -1.10800885906241, 1.09770519389828, 0.689439395264878, 1.38996825067789, 4.24711267303104, + 1.59184977958743, 0.326149625049801}, + {-2.14223502789471, -1.88703147531519, -0.650804572670110, -0.551162075879755, -0.915386396405710, + -1.35857500246993, 0.0563335684828033, -1.18603579834700, -0.809321359324656, -1.54891762265441, + 0.345719522947313, 0.0900423688142873, 0.381461205984798, 0.516547696592306, 1.38342667112079, + -0.228495592779472, -1.30550584958631, -0.579368833633824, -0.00738786566478374, 0.253247464332976, + 0.589170238085318, -0.282824592543629, 1.11981236291828, 0.0280798194947077, -0.457715661897855, + -0.562615116512472, 0.768645545764776, 1.12346905009575, 1.04467921708883, 2.89734109830439, + 2.39771699015146, 1.39171313342261}, + {-2.37533813570664, -1.80991659687332, -1.06815731781969, -0.484788283381197, -2.20645974739762, + -0.983721105837444, 0.0499114046826685, -0.625001634441352, -1.63587876923797, -1.45296062475530, + 0.300549460996251, 0.845025007556886, -0.482849340608998, 0.251716881864630, 1.34327358628285, + 0.518980852551937, -1.87133711350971, -0.879427960941070, -0.495649854710252, 0.0735842143788469, + -1.37192459653166, -0.00659813474614194, 1.17914044332734, 0.262054554763133, -0.798711008243192, + -0.220562123765675, 0.206081977740766, 1.30934523106594, 0.635822746244367, 0.932730658026815, + 3.03697343600704, 2.23146614636474}, + {-2.23041933049655, -1.76340038479206, -1.61928741524302, -0.238388394455814, -2.74142180959951, + -0.652956939100809, -0.0954130727414369, 0.153902497468304, -1.88486397330982, -1.03182970062270, + -1.11865218295857, 1.06572384501716, -1.81632721260589, -0.216179967524303, 0.822978836855922, + 1.36721896340278, -1.24008685156305, -0.850685023408119, -0.806651271118393, 0.314216709389010, + -2.37095707241577, 0.285929279627216, 1.07987429197260, 0.360590806085767, -0.386819329309100, + -0.349842880336644, -0.342805735091998, 1.35511964713935, -0.274733755518482, -0.292822249729810, + 2.66424350337151, 2.61179442169688}, + {-2.17595881223696, -1.83418428467950, -2.18762566441756, -0.143024507285504, -2.86139074276891, + -0.989986992921811, -0.760166146083885, 0.576386497810755, -1.64496691316356, -0.690642640272584, + -2.44089151148049, 0.737582999377756, -2.80279512728555, -0.534074091124504, 0.215876798515679, + 2.18023038253092, -1.26712924866274, -0.779397050155816, -1.22431891984401, 0.234729880923679, + -2.00779782682360, 0.0460445529952971, 0.697536239067500, 0.635623722053700, -0.375901062231203, + -0.753432770250495, -0.754939404625340, 1.42311381470799, -1.54923372430695, -0.810404296853182, + 1.39304485032606, 2.66540340196570}, + {-2.29065913541000, -1.80480980687405, -2.63757586939054, 0.0683186673649074, -2.88841597105271, + -1.61467224598900, -2.32758120177007, 0.795092603798871, -1.40515778046612, -0.428843804532171, + -2.22854732450735, 0.256590452459912, -3.23385724833864, -0.640786096262196, -0.404925753080293, + 2.53596092750107, -2.03670813003907, -0.732182927291826, -1.70157770043181, 0.144600134479837, + -1.66688540224395, -0.602596415577886, -0.912548817371081, 0.959012467178154, -0.657836899930538, + -0.988596593396384, -1.04196177632000, 1.15706449190905, -2.44239710278007, -0.788868098756483, + 0.403834023595745, 2.40103554105707}, + {-2.53286397979846, -1.73679545317401, -2.97897749575096, 0.0883061717288066, -2.95182608262521, + -2.40712302385116, -3.77155485385656, 0.596564632144913, -1.46666471326146, -0.494960215408874, + -1.89509228210853, -0.491963359762378, -3.45908714491473, -0.869745032374135, -1.07025605870523, + 2.20121098860036, -2.89685162242381, -0.888348514821255, -2.24491913755611, -0.0682120178880174, + -1.92631846258406, -2.26568728632575, -3.57684747062773, 1.30745156688653, -1.28163964243603, + -1.28790471791471, -1.50335652955529, 0.406319437516838, -3.02457606944550, -0.935353148761338, + -0.656270971328114, 1.75920379670881}}; + +const LC3_INT pvq_enc_A[16][11] = {{0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, + {0, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19}, + {0, 1, 5, 13, 25, 41, 61, 85, 113, 145, 181}, + {0, 1, 7, 25, 63, 129, 231, 377, 575, 833, 1159}, + {0, 1, 9, 41, 129, 321, 681, 1289, 2241, 3649, 5641}, + {0, 1, 11, 61, 231, 681, 1683, 3653, 7183, 13073, 22363}, + {0, 1, 13, 85, 377, 1289, 3653, 8989, 19825, 40081, 75517}, + {0, 1, 15, 113, 575, 2241, 7183, 19825, 48639, 108545, 224143}, + {0, 1, 17, 145, 833, 3649, 13073, 40081, 108545, 265729, 598417}, + {0, 1, 19, 181, 1159, 5641, 22363, 75517, 224143, 598417, 1462563}, + {0, 1, 21, 221, 1561, 8361, 36365, 134245, 433905, 1256465, 3317445}, + {0, 1, 23, 265, 2047, 11969, 56695, 227305, 795455, 2485825, 7059735}, + {0, 1, 25, 313, 2625, 16641, 85305, 369305, 1392065, 4673345, 14218905}, + {0, 1, 27, 365, 3303, 22569, 124515, 579125, 2340495, 8405905, 27298155}, + {0, 1, 29, 421, 4089, 29961, 177045, 880685, 3800305, 14546705, 50250765}, + {0, 1, 31, 481, 4991, 39041, 246047, 1303777, 5984767, 24331777, 89129247}}; + +const LC3_FLOAT lp_scale_factors[6] = {1, 1, 0.6666666666666666, .5, 0.3333333333333333, 0.16666666666666666}; + + +/* 12.8 kHz resampler */ +const LC3_FLOAT highpass50_filt_b[3] = {0.9827947082978771, -1.965589416595754, 0.9827947082978771}; +const LC3_FLOAT highpass50_filt_a[3] = {1, -1.9652933726226904, 0.9658854605688177}; + +const LC3_INT32 resamp_params[][4] = { + {24, 5, 0, 15}, + {12, 10, 1, 3}, + {8, 15, 1, 7}, + {6, 20, 2, 3}, + {4, 30, 3, 3}, + {2, 60, 7, 1} +}; + + +const LC3_FLOAT lp_filter_8[240] = {0.0065408750, 0.0127360141, -0.0320970677, -0.1382038444, 0.8005587459, -0.1382038444, -0.0320970677, 0.0127360141, 0.0065408750, 0.0000000000, 0.0064595463, 0.0084537705, -0.0391003005, -0.1198658869, 0.7945935130, -0.1519452035, -0.0230523963, 0.0167804975, 0.0063002659, -0.0002451667, 0.0060938913, 0.0041435249, -0.0439039879, -0.0980933905, 0.7768620253, -0.1600013375, -0.0122310519, 0.0203715712, 0.0057131811, -0.0005356151, 0.0054914863, 0.0000000000, -0.0464562289, -0.0740769655, 0.7478516698, -0.1614013463, 0.0000000000, 0.0232978407, 0.0047708568, -0.0008596397, 0.0047065411, -0.0038048958, -0.0468063876, -0.0489920303, 0.7083564401, -0.1553338468, 0.0131809860, 0.0253629088, 0.0034824028, -0.0012012133, 0.0037965439, -0.0071282135, -0.0450960808, -0.0239577144, 0.6594504118, -0.1411849856, 0.0267735831, 0.0263961889, 0.0018761361, -0.0015404741, 0.0028190494, -0.0098603060, -0.0415467210, -0.0000000000, 0.6024519205, -0.1185704023, 0.0401797108, 0.0262632743, -0.0000000000, -0.0018545259, 0.0018287648, -0.0119272992, -0.0364444591, 0.0219798349, 0.5388799906, -0.0873604342, 0.0527642742, 0.0248753466, -0.0020790326, -0.0021185349, 0.0008750616, -0.0132916924, -0.0301232301, 0.0412303619, 0.4704038501, -0.0476967618, 0.0638811216, 0.0221970305, -0.0042766319, -0.0023070835, 0.0000000000, -0.0139512215, -0.0229468606, 0.0571681485, 0.3987891078, 0.0000000000, 0.0729012638, 0.0182522610, -0.0064938627, -0.0023957258, -0.0007630716, -0.0139361415, -0.0152910165, 0.0693885013, 0.3258404732, 0.0550325289, 0.0792422444, 0.0131276902, -0.0086209681, -0.0023626641, -0.0013903243, -0.0133052040, -0.0075258445, 0.0776687115, 0.2533447146, 0.1164389849, 0.0823974460, 0.0069732964, -0.0105420630, -0.0021904600, -0.0018676731, -0.0121405739, -0.0000000000, 0.0819641128, 0.1830149740, 0.1830149740, 0.0819641128, -0.0000000000, -0.0121405739, -0.0018676731, -0.0021904600, -0.0105420630, 0.0069732964, 0.0823974460, 0.1164389849, 0.2533447146, 0.0776687115, -0.0075258445, -0.0133052040, -0.0013903243, -0.0023626641, -0.0086209681, 0.0131276902, 0.0792422444, 0.0550325289, 0.3258404732, 0.0693885013, -0.0152910165, -0.0139361415, -0.0007630716, -0.0023957258, -0.0064938627, 0.0182522610, 0.0729012638, 0.0000000000, 0.3987891078, 0.0571681485, -0.0229468606, -0.0139512215, 0.0000000000, -0.0023070835, -0.0042766319, 0.0221970305, 0.0638811216, -0.0476967618, 0.4704038501, 0.0412303619, -0.0301232301, -0.0132916924, 0.0008750616, -0.0021185349, -0.0020790326, 0.0248753466, 0.0527642742, -0.0873604342, 0.5388799906, 0.0219798349, -0.0364444591, -0.0119272992, 0.0018287648, -0.0018545259, -0.0000000000, 0.0262632743, 0.0401797108, -0.1185704023, 0.6024519205, -0.0000000000, -0.0415467210, -0.0098603060, 0.0028190494, -0.0015404741, 0.0018761361, 0.0263961889, 0.0267735831, -0.1411849856, 0.6594504118, -0.0239577144, -0.0450960808, -0.0071282135, 0.0037965439, -0.0012012133, 0.0034824028, 0.0253629088, 0.0131809860, -0.1553338468, 0.7083564401, -0.0489920303, -0.0468063876, -0.0038048958, 0.0047065411, -0.0008596397, 0.0047708568, 0.0232978407, 0.0000000000, -0.1614013463, 0.7478516698, -0.0740769655, -0.0464562289, 0.0000000000, 0.0054914863, -0.0005356151, 0.0057131811, 0.0203715712, -0.0122310519, -0.1600013375, 0.7768620253, -0.0980933905, -0.0439039879, 0.0041435249, 0.0060938913, -0.0002451667, 0.0063002659, 0.0167804975, -0.0230523963, -0.1519452035, 0.7945935130, -0.1198658869, -0.0391003005, 0.0084537705, 0.0064595463}; + +const LC3_FLOAT lp_filter_16[240] = { +-0.0018676731, 0.0065408750, -0.0121405739, 0.0127360141, -0.0000000000, -0.0320970677, 0.0819641128, -0.1382038444, 0.1830149740, 0.8005587459, 0.1830149740, -0.1382038444, 0.0819641128, -0.0320970677, -0.0000000000, 0.0127360141, -0.0121405739, 0.0065408750, -0.0018676731, 0.0000000000, -0.0021904600, 0.0064595463, -0.0105420630, 0.0084537705, 0.0069732964, -0.0391003005, 0.0823974460, -0.1198658869, 0.1164389849, 0.7945935130, 0.2533447146, -0.1519452035, 0.0776687115, -0.0230523963, -0.0075258445, 0.0167804975, -0.0133052040, 0.0063002659, -0.0013903243, -0.0002451667, -0.0023626641, 0.0060938913, -0.0086209681, 0.0041435249, 0.0131276902, -0.0439039879, 0.0792422444, -0.0980933905, 0.0550325289, 0.7768620253, 0.3258404732, -0.1600013375, 0.0693885013, -0.0122310519, -0.0152910165, 0.0203715712, -0.0139361415, 0.0057131811, -0.0007630716, -0.0005356151, -0.0023957258, 0.0054914863, -0.0064938627, 0.0000000000, 0.0182522610, -0.0464562289, 0.0729012638, -0.0740769655, 0.0000000000, 0.7478516698, 0.3987891078, -0.1614013463, 0.0571681485, 0.0000000000, -0.0229468606, 0.0232978407, -0.0139512215, 0.0047708568, 0.0000000000, -0.0008596397, -0.0023070835, 0.0047065411, -0.0042766319, -0.0038048958, 0.0221970305, -0.0468063876, 0.0638811216, -0.0489920303, -0.0476967618, 0.7083564401, 0.4704038501, -0.1553338468, 0.0412303619, 0.0131809860, -0.0301232301, 0.0253629088, -0.0132916924, 0.0034824028, 0.0008750616, -0.0012012133, -0.0021185349, 0.0037965439, -0.0020790326, -0.0071282135, 0.0248753466, -0.0450960808, 0.0527642742, -0.0239577144, -0.0873604342, 0.6594504118, 0.5388799906, -0.1411849856, 0.0219798349, 0.0267735831, -0.0364444591, 0.0263961889, -0.0119272992, 0.0018761361, 0.0018287648, -0.0015404741, -0.0018545259, 0.0028190494, -0.0000000000, -0.0098603060, 0.0262632743, -0.0415467210, 0.0401797108, -0.0000000000, -0.1185704023, 0.6024519205, 0.6024519205, -0.1185704023, -0.0000000000, 0.0401797108, -0.0415467210, 0.0262632743, -0.0098603060, -0.0000000000, 0.0028190494, -0.0018545259, -0.0015404741, 0.0018287648, 0.0018761361, -0.0119272992, 0.0263961889, -0.0364444591, 0.0267735831, 0.0219798349, -0.1411849856, 0.5388799906, 0.6594504118, -0.0873604342, -0.0239577144, 0.0527642742, -0.0450960808, 0.0248753466, -0.0071282135, -0.0020790326, 0.0037965439, -0.0021185349, -0.0012012133, 0.0008750616, 0.0034824028, -0.0132916924, 0.0253629088, -0.0301232301, 0.0131809860, 0.0412303619, -0.1553338468, 0.4704038501, 0.7083564401, -0.0476967618, -0.0489920303, 0.0638811216, -0.0468063876, 0.0221970305, -0.0038048958, -0.0042766319, 0.0047065411, -0.0023070835, -0.0008596397, 0.0000000000, 0.0047708568, -0.0139512215, 0.0232978407, -0.0229468606, 0.0000000000, 0.0571681485, -0.1614013463, 0.3987891078, 0.7478516698, 0.0000000000, -0.0740769655, 0.0729012638, -0.0464562289, 0.0182522610, 0.0000000000, -0.0064938627, 0.0054914863, -0.0023957258, -0.0005356151, -0.0007630716, 0.0057131811, -0.0139361415, 0.0203715712, -0.0152910165, -0.0122310519, 0.0693885013, -0.1600013375, 0.3258404732, 0.7768620253, 0.0550325289, -0.0980933905, 0.0792422444, -0.0439039879, 0.0131276902, 0.0041435249, -0.0086209681, 0.0060938913, -0.0023626641, -0.0002451667, -0.0013903243, 0.0063002659, -0.0133052040, 0.0167804975, -0.0075258445, -0.0230523963, 0.0776687115, -0.1519452035, 0.2533447146, 0.7945935130, 0.1164389849, -0.1198658869, 0.0823974460, -0.0391003005, 0.0069732964, 0.0084537705, -0.0105420630, 0.0064595463, -0.0021904600 +}; + +const LC3_FLOAT lp_filter_24[240] = { +-0.0015380557, 0.0005833744, 0.0043605831, -0.0028510878, -0.0088611282, 0.0084906761, 0.0147980200, -0.0200821534, -0.0213980451, 0.0425874144, 0.0274869073, -0.0921358988, -0.0317978412, 0.3136025667, 0.5337058306, 0.3136025667, -0.0317978412, -0.0921358988, 0.0274869073, 0.0425874144, -0.0213980451, -0.0200821534, 0.0147980200, 0.0084906761, -0.0088611282, -0.0028510878, 0.0043605831, 0.0005833744, -0.0015380557, 0.0000000000, -0.0014123565, 0.0000000000, 0.0043063643, -0.0013860217, -0.0093008140, 0.0056358469, 0.0165835638, -0.0152979074, -0.0260668676, 0.0351761840, 0.0381121002, -0.0799105912, -0.0582402907, 0.2658593953, 0.5297290087, 0.3592533171, 0.0000000000, -0.1012968048, 0.0146532226, 0.0486008413, -0.0153682642, -0.0242963061, 0.0121681746, 0.0111869983, -0.0079515325, -0.0043292418, 0.0042001773, 0.0012191766, -0.0015971506, -0.0001634445, -0.0012363506, -0.0005087144, 0.0040625944, -0.0000000000, -0.0092907613, 0.0027623500, 0.0175088495, -0.0101940110, -0.0292693246, 0.0267864745, 0.0462590009, -0.0653955936, -0.0790469348, 0.2172269821, 0.5179080367, 0.4016346335, 0.0366883539, -0.1066675633, -0.0000000000, 0.0528281629, -0.0081540346, -0.0276978146, 0.0087517938, 0.0135810468, -0.0065735374, -0.0057473122, 0.0038087873, 0.0018793662, -0.0015751094, -0.0003570767, -0.0010269828, -0.0009268829, 0.0036609909, 0.0012507574, -0.0088701360, 0.0000000000, 0.0175974593, -0.0050172298, -0.0309708193, 0.0178490561, 0.0517791398, -0.0493846424, -0.0941233262, 0.1688964665, 0.4985677898, 0.4396336079, 0.0776259899, -0.1076008976, -0.0159718096, 0.0549316332, 0.0000000000, -0.0300640538, 0.0046488643, 0.0155318938, -0.0047521424, -0.0070280419, 0.0031805711, 0.0025310293, -0.0014603067, -0.0005730931, -0.0008008089, -0.0012451154, 0.0031376940, 0.0023216018, -0.0080937156, -0.0025365972, 0.0169086065, -0.0000000000, -0.0312042590, 0.0087873237, 0.0546427406, -0.0326613523, -0.1035559028, 0.1220099851, 0.4722376168, 0.4722376168, 0.1220099851, -0.1035559028, -0.0326613523, 0.0546427406, 0.0087873237, -0.0312042590, -0.0000000000, 0.0169086065, -0.0025365972, -0.0080937156, 0.0023216018, 0.0031376940, -0.0012451154, -0.0008008089, -0.0005730931, -0.0014603067, 0.0025310293, 0.0031805711, -0.0070280419, -0.0047521424, 0.0155318938, 0.0046488643, -0.0300640538, 0.0000000000, 0.0549316332, -0.0159718096, -0.1076008976, 0.0776259899, 0.4396336079, 0.4985677898, 0.1688964665, -0.0941233262, -0.0493846424, 0.0517791398, 0.0178490561, -0.0309708193, -0.0050172298, 0.0175974593, 0.0000000000, -0.0088701360, 0.0012507574, 0.0036609909, -0.0009268829, -0.0010269828, -0.0003570767, -0.0015751094, 0.0018793662, 0.0038087873, -0.0057473122, -0.0065735374, 0.0135810468, 0.0087517938, -0.0276978146, -0.0081540346, 0.0528281629, -0.0000000000, -0.1066675633, 0.0366883539, 0.4016346335, 0.5179080367, 0.2172269821, -0.0790469348, -0.0653955936, 0.0462590009, 0.0267864745, -0.0292693246, -0.0101940110, 0.0175088495, 0.0027623500, -0.0092907613, -0.0000000000, 0.0040625944, -0.0005087144, -0.0012363506, -0.0001634445, -0.0015971506, 0.0012191766, 0.0042001773, -0.0043292418, -0.0079515325, 0.0111869983, 0.0121681746, -0.0242963061, -0.0153682642, 0.0486008413, 0.0146532226, -0.1012968048, 0.0000000000, 0.3592533171, 0.5297290087, 0.2658593953, -0.0582402907, -0.0799105912, 0.0381121002, 0.0351761840, -0.0260668676, -0.0152979074, 0.0165835638, 0.0056358469, -0.0093008140, -0.0013860217, 0.0043063643, 0.0000000000, -0.0014123565 +}; + +const LC3_FLOAT lp_filter_32[240] = { +-0.0009272629, -0.0009338366, 0.0014095247, 0.0032704375, -0.0000000000, -0.0060702870, -0.0049301530, 0.0063680070, 0.0131316371, -0.0000000000, -0.0207733605, -0.0160485338, 0.0200898554, 0.0409820564, -0.0000000000, -0.0691019222, -0.0592852011, 0.0915074870, 0.3012259603, 0.4002793729, 0.3012259603, 0.0915074870, -0.0592852011, -0.0691019222, -0.0000000000, 0.0409820564, 0.0200898554, -0.0160485338, -0.0207733605, -0.0000000000, 0.0131316371, 0.0063680070, -0.0049301530, -0.0060702870, -0.0000000000, 0.0032704375, 0.0014095247, -0.0009338366, -0.0009272629, 0.0000000000, -0.0007702371, -0.0010952300, 0.0009143824, 0.0032297731, 0.0009380680, -0.0052710315, -0.0059636496, 0.0042268853, 0.0131980944, 0.0034866482, -0.0182222296, -0.0195501503, 0.0133867916, 0.0411987230, 0.0109899174, -0.0599329434, -0.0705924928, 0.0582194924, 0.2694399953, 0.3972967565, 0.3297252059, 0.1266723573, -0.0436802171, -0.0759726018, -0.0119788572, 0.0388343558, 0.0263821371, -0.0115261981, -0.0225480404, -0.0037629222, 0.0124376733, 0.0083902488, -0.0035641068, -0.0066526020, -0.0010395163, 0.0031501330, 0.0018982720, -0.0006951622, -0.0010592674, -0.0001225834, -0.0006006067, -0.0011813320, 0.0004375308, 0.0030469457, 0.0017412014, -0.0043104840, -0.0066458462, 0.0020717625, 0.0126814544, 0.0065638451, -0.0150616150, -0.0219519939, 0.0065904930, 0.0396211222, 0.0206151810, -0.0490466952, -0.0776669234, 0.0275162645, 0.2352019250, 0.3884310126, 0.3541782200, 0.1629202366, -0.0238483809, -0.0800006688, -0.0244960152, 0.0346942507, 0.0319405608, -0.0061155260, -0.0234031938, -0.0076455083, 0.0110985152, 0.0101857856, -0.0019024479, -0.0069680708, -0.0021383159, 0.0028565906, 0.0023532705, -0.0003815358, -0.0011535417, -0.0002678075, -0.0004298199, -0.0011978629, 0.0000000000, 0.0027457431, 0.0023854284, -0.0032469314, -0.0069756107, 0.0000000000, 0.0116489204, 0.0091261305, -0.0114734303, -0.0232281145, 0.0000000000, 0.0364506319, 0.0285840742, -0.0370384827, -0.0807006732, 0.0000000000, 0.1993945539, 0.3739258349, 0.3739258349, 0.1993945539, 0.0000000000, -0.0807006732, -0.0370384827, 0.0285840742, 0.0364506319, 0.0000000000, -0.0232281145, -0.0114734303, 0.0091261305, 0.0116489204, 0.0000000000, -0.0069756107, -0.0032469314, 0.0023854284, 0.0027457431, 0.0000000000, -0.0011978629, -0.0004298199, -0.0002678075, -0.0011535417, -0.0003815358, 0.0023532705, 0.0028565906, -0.0021383159, -0.0069680708, -0.0019024479, 0.0101857856, 0.0110985152, -0.0076455083, -0.0234031938, -0.0061155260, 0.0319405608, 0.0346942507, -0.0244960152, -0.0800006688, -0.0238483809, 0.1629202366, 0.3541782200, 0.3884310126, 0.2352019250, 0.0275162645, -0.0776669234, -0.0490466952, 0.0206151810, 0.0396211222, 0.0065904930, -0.0219519939, -0.0150616150, 0.0065638451, 0.0126814544, 0.0020717625, -0.0066458462, -0.0043104840, 0.0017412014, 0.0030469457, 0.0004375308, -0.0011813320, -0.0006006067, -0.0001225834, -0.0010592674, -0.0006951622, 0.0018982720, 0.0031501330, -0.0010395163, -0.0066526020, -0.0035641068, 0.0083902488, 0.0124376733, -0.0037629222, -0.0225480404, -0.0115261981, 0.0263821371, 0.0388343558, -0.0119788572, -0.0759726018, -0.0436802171, 0.1266723573, 0.3297252059, 0.3972967565, 0.2694399953, 0.0582194924, -0.0705924928, -0.0599329434, 0.0109899174, 0.0411987230, 0.0133867916, -0.0195501503, -0.0182222296, 0.0034866482, 0.0131980944, 0.0042268853, -0.0059636496, -0.0052710315, 0.0009380680, 0.0032297731, 0.0009143824, -0.0010952300, -0.0007702371 +}; + +const LC3_FLOAT lp_filter_48[240] = { +-0.0004004044, -0.0007690279, -0.0006225577, 0.0002916872, 0.0015688470, 0.0021802916, 0.0011608009, -0.0014255439, -0.0040468578, -0.0044305641, -0.0012682986, 0.0042453380, 0.0084543033, 0.0073990100, -0.0000000000, -0.0100410767, -0.0156021295, -0.0106990226, 0.0043936619, 0.0212937072, 0.0273213703, 0.0137434537, -0.0163306762, -0.0460679494, -0.0517779514, -0.0158989206, 0.0610049926, 0.1568012834, 0.2361188084, 0.2668529153, 0.2361188084, 0.1568012834, 0.0610049926, -0.0158989206, -0.0517779514, -0.0460679494, -0.0163306762, 0.0137434537, 0.0273213703, 0.0212937072, 0.0043936619, -0.0106990226, -0.0156021295, -0.0100410767, -0.0000000000, 0.0073990100, 0.0084543033, 0.0042453380, -0.0012682986, -0.0044305641, -0.0040468578, -0.0014255439, 0.0011608009, 0.0021802916, 0.0015688470, 0.0002916872, -0.0006225577, -0.0007690279, -0.0004004044, 0.0000000000, -0.0002865466, -0.0007061783, -0.0007301533, 0.0000000000, 0.0012655146, 0.0021531822, 0.0015902856, -0.0006930109, -0.0035140209, -0.0046504070, -0.0023760712, 0.0028179234, 0.0077659469, 0.0082917819, 0.0023244321, -0.0076489537, -0.0150320269, -0.0130334338, 0.0000000000, 0.0175880920, 0.0274658166, 0.0190560501, -0.0079859048, -0.0399552956, -0.0538004488, -0.0291201454, 0.0388129950, 0.1329296976, 0.2198168039, 0.2648645043, 0.2492838949, 0.1796266586, 0.0844482332, 0.0000000000, -0.0470616631, -0.0506484024, -0.0246923212, 0.0073266113, 0.0258895699, 0.0243004207, 0.0089245280, -0.0076841321, -0.0154854096, -0.0121481530, -0.0025086149, 0.0060840873, 0.0087987296, 0.0055934992, 0.0000000000, -0.0039757662, -0.0044350680, -0.0021646209, 0.0006253787, 0.0021000886, 0.0018304954, 0.0006095883, -0.0004634415, -0.0007985753, -0.0005134914, -0.0000817222, -0.0001785384, -0.0006181753, -0.0007875547, -0.0002543572, 0.0009396831, 0.0020312972, 0.0019043937, -0.0000000000, -0.0028736561, -0.0046453807, -0.0032867687, 0.0013811750, 0.0067905234, 0.0087544248, 0.0043758969, -0.0050970055, -0.0138489073, -0.0146346623, -0.0040770173, 0.0133932373, 0.0264140815, 0.0231295004, -0.0000000000, -0.0326977968, -0.0533337817, -0.0395234674, 0.0183441769, 0.1086134911, 0.2008173168, 0.2589540184, 0.2589540184, 0.2008173168, 0.1086134911, 0.0183441769, -0.0395234674, -0.0533337817, -0.0326977968, -0.0000000000, 0.0231295004, 0.0264140815, 0.0133932373, -0.0040770173, -0.0146346623, -0.0138489073, -0.0050970055, 0.0043758969, 0.0087544248, 0.0067905234, 0.0013811750, -0.0032867687, -0.0046453807, -0.0028736561, -0.0000000000, 0.0019043937, 0.0020312972, 0.0009396831, -0.0002543572, -0.0007875547, -0.0006181753, -0.0001785384, -0.0000817222, -0.0005134914, -0.0007985753, -0.0004634415, 0.0006095883, 0.0018304954, 0.0021000886, 0.0006253787, -0.0021646209, -0.0044350680, -0.0039757662, 0.0000000000, 0.0055934992, 0.0087987296, 0.0060840873, -0.0025086149, -0.0121481530, -0.0154854096, -0.0076841321, 0.0089245280, 0.0243004207, 0.0258895699, 0.0073266113, -0.0246923212, -0.0506484024, -0.0470616631, 0.0000000000, 0.0844482332, 0.1796266586, 0.2492838949, 0.2648645043, 0.2198168039, 0.1329296976, 0.0388129950, -0.0291201454, -0.0538004488, -0.0399552956, -0.0079859048, 0.0190560501, 0.0274658166, 0.0175880920, 0.0000000000, -0.0130334338, -0.0150320269, -0.0076489537, 0.0023244321, 0.0082917819, 0.0077659469, 0.0028179234, -0.0023760712, -0.0046504070, -0.0035140209, -0.0006930109, 0.0015902856, 0.0021531822, 0.0012655146, 0.0000000000, -0.0007301533, -0.0007061783, -0.0002865466 +}; + +const LC3_FLOAT lp_filter_96[240] = { +-0.0000892692, -0.0002002022, -0.0003090877, -0.0003845139, -0.0003937774, -0.0003112789, -0.0001271786, 0.0001458436, 0.0004698416, 0.0007844235, 0.0010156486, 0.0010901458, 0.0009521968, 0.0005804005, -0.0000000000, -0.0007127720, -0.0014368281, -0.0020234289, -0.0023226903, -0.0022152821, -0.0016433843, -0.0006341493, 0.0006905875, 0.0021226690, 0.0033952617, 0.0042271516, 0.0043772124, 0.0036995050, 0.0021879484, -0.0000000000, -0.0025485028, -0.0050205383, -0.0069244537, -0.0078010648, -0.0073173312, -0.0053495113, -0.0020385087, 0.0021968309, 0.0066966186, 0.0106468536, 0.0132070407, 0.0136606852, 0.0115647502, 0.0068717268, -0.0000000000, -0.0081653381, -0.0163488984, -0.0230339747, -0.0266668908, -0.0258889757, -0.0197617337, -0.0079494603, 0.0091720885, 0.0305024963, 0.0543067455, 0.0784006417, 0.1004086584, 0.1180594042, 0.1294770092, 0.1334264576, 0.1294770092, 0.1180594042, 0.1004086584, 0.0784006417, 0.0543067455, 0.0305024963, 0.0091720885, -0.0079494603, -0.0197617337, -0.0258889757, -0.0266668908, -0.0230339747, -0.0163488984, -0.0081653381, -0.0000000000, 0.0068717268, 0.0115647502, 0.0136606852, 0.0132070407, 0.0106468536, 0.0066966186, 0.0021968309, -0.0020385087, -0.0053495113, -0.0073173312, -0.0078010648, -0.0069244537, -0.0050205383, -0.0025485028, -0.0000000000, 0.0021879484, 0.0036995050, 0.0043772124, 0.0042271516, 0.0033952617, 0.0021226690, 0.0006905875, -0.0006341493, -0.0016433843, -0.0022152821, -0.0023226903, -0.0020234289, -0.0014368281, -0.0007127720, -0.0000000000, 0.0005804005, 0.0009521968, 0.0010901458, 0.0010156486, 0.0007844235, 0.0004698416, 0.0001458436, -0.0001271786, -0.0003112789, -0.0003937774, -0.0003845139, -0.0003090877, -0.0002002022, -0.0000892692, 0.0000000000, -0.0000408611, -0.0001432733, -0.0002567457, -0.0003530891, -0.0003992876, -0.0003650767, -0.0002317207, 0.0000000000, 0.0003047941, 0.0006327573, 0.0009152477, 0.0010765911, 0.0010500443, 0.0007951428, 0.0003126893, -0.0003465054, -0.0010823105, -0.0017570105, -0.0022175340, -0.0023252035, -0.0019878831, -0.0011880356, 0.0000000000, 0.0014089617, 0.0027967496, 0.0038829735, 0.0043993648, 0.0041458909, 0.0030420437, 0.0011622161, -0.0012543075, -0.0038244769, -0.0060740765, -0.0075160135, -0.0077427048, -0.0065167169, -0.0038420660, 0.0000000000, 0.0044622640, 0.0087940460, 0.0121502103, 0.0137329083, 0.0129447849, 0.0095280251, 0.0036633057, -0.0039929524, -0.0123461606, -0.0199776478, -0.0253242012, -0.0269002244, -0.0235308316, -0.0145600727, 0.0000000000, 0.0194064975, 0.0422241166, 0.0664648488, 0.0898133293, 0.1099084020, 0.1246419474, 0.1324322522, 0.1324322522, 0.1246419474, 0.1099084020, 0.0898133293, 0.0664648488, 0.0422241166, 0.0194064975, 0.0000000000, -0.0145600727, -0.0235308316, -0.0269002244, -0.0253242012, -0.0199776478, -0.0123461606, -0.0039929524, 0.0036633057, 0.0095280251, 0.0129447849, 0.0137329083, 0.0121502103, 0.0087940460, 0.0044622640, 0.0000000000, -0.0038420660, -0.0065167169, -0.0077427048, -0.0075160135, -0.0060740765, -0.0038244769, -0.0012543075, 0.0011622161, 0.0030420437, 0.0041458909, 0.0043993648, 0.0038829735, 0.0027967496, 0.0014089617, 0.0000000000, -0.0011880356, -0.0019878831, -0.0023252035, -0.0022175340, -0.0017570105, -0.0010823105, -0.0003465054, 0.0003126893, 0.0007951428, 0.0010500443, 0.0010765911, 0.0009152477, 0.0006327573, 0.0003047941, 0.0000000000, -0.0002317207, -0.0003650767, -0.0003992876, -0.0003530891, -0.0002567457, -0.0001432733, -0.0000408611 +}; + +const LC3_FLOAT *lp_filter[] = {lp_filter_8, lp_filter_16, lp_filter_24, lp_filter_32, lp_filter_48, lp_filter_96}; + +const LC3_INT up_fac[6] = {24, 12, 8, 6, 4, 2}; + +/* TNS */ +const LC3_INT huff_bits_tns[8][17] = { + {20480, 15725, 12479, 10334, 8694, 7320, 6964, 6335, 5504, 5637, 6566, 6758, 8433, 11348, 15186, 20480, 20480}, + {20480, 20480, 20480, 20480, 12902, 9368, 7057, 5901, 5254, 5485, 5598, 6076, 7608, 10742, 15186, 20480, 20480}, + {20480, 20480, 20480, 20480, 13988, 9368, 6702, 4841, 4585, 4682, 5859, 7764, 12109, 20480, 20480, 20480, 20480}, + {20480, 20480, 20480, 20480, 18432, 13396, 8982, 4767, 3779, 3658, 6335, 9656, 13988, 20480, 20480, 20480, 20480}, + {20480, 20480, 20480, 20480, 20480, 14731, 9437, 4275, 3249, 3493, 8483, 13988, 17234, 20480, 20480, 20480, 20480}, + {20480, 20480, 20480, 20480, 20480, 20480, 12902, 4753, 3040, 2953, 9105, 15725, 20480, 20480, 20480, 20480, 20480}, + {20480, 20480, 20480, 20480, 20480, 20480, 12902, 3821, 3346, 3000, 12109, 20480, 20480, 20480, 20480, 20480, + 20480}, + {20480, 20480, 20480, 20480, 20480, 20480, 15725, 3658, 20480, 1201, 10854, 18432, 20480, 20480, 20480, 20480, + 20480}}; + +const LC3_INT order1_tns[8] = {17234, 13988, 11216, 8694, 6566, 4977, 3961, 3040}; +const LC3_INT order2_tns[8] = {12683, 9437, 6874, 5541, 5121, 5170, 5359, 5056}; + +const LC3_FLOAT lagw_tns[9] = {1, + 0.998028026020383, + 0.992135405511397, + 0.982391584470799, + 0.968910791191297, + 0.951849807369274, + 0.931404933402306, + 0.907808229996959, + 0.881323136669471}; + +const LC3_FLOAT quants_pts_tns[17] = { -0.995727539062500, -0.961822509765625, -0.895172119140625, + -0.798004150390625, -0.673706054687500, -0.526428222656250, + -0.361236572265625, -0.183746337890625, 0.000000000000000, + 0.183746337890625, 0.361236572265625, 0.526428222656250, + 0.673706054687500, 0.798004150390625, 0.895172119140625, + 0.961822509765625, 0.995727539062500}; + +const LC3_FLOAT quants_thr_tns[18] = {-1, + -0.982973099683902, + -0.932472229404356, + -0.850217135729614, + -0.739008917220659, + -0.602634636379256, + -0.445738355776538, + -0.273662990072083, + -0.0922683594633020, + 0.0922683594633020, + 0.273662990072083, + 0.445738355776538, + 0.602634636379256, + 0.739008917220659, + 0.850217135729614, + 0.932472229404356, + 0.982973099683902, + 1}; + +/* SNS */ +const LC3_FLOAT sns_W[6] = {0.0833333333333333, 0.166666666666667, 0.250000000000000, 0.250000000000000, 0.166666666666667, 0.0833333333333333}; + +const LC3_FLOAT sns_preemph_8[64] = {1, 1.05250028527773, 1.10775685050971, 1.16591440117983, 1.22712523985119, 1.29154966501488, 1.35935639087853, 1.43072298919376, 1.50583635427984, 1.58489319246111, 1.66810053720006, 1.75567629127500, 1.84784979742229, 1.94486243893736, 2.04696827180752, 2.15443469003188, 2.26754312587080, 2.38658978685858, 2.51188643150958, 2.64376118574910, 2.78255940220713, 2.92864456462524, 3.08239923974514, 3.24422607917163, 3.41454887383360, 3.59381366380463, 3.78248990638938, 3.98107170553497, 4.19007910578667, 4.41005945417674, 4.64158883361278, 4.88527357151939, 5.14175182768393, 5.41169526546464, 5.69581081073769, 5.99484250318941, 6.30957344480193, 6.64082785063484, 6.98947320727349, 7.35642254459641, 7.74263682681127, 8.14912746902074, 8.57695898590894, 9.02725177948457, 9.50118507318144, 10, 10.5250028527773, 11.0775685050971, 11.6591440117983, 12.2712523985119, 12.9154966501488, 13.5935639087853, 14.3072298919376, 15.0583635427984, 15.8489319246111, 16.6810053720006, 17.5567629127500, 18.4784979742229, 19.4486243893736, 20.4696827180752, 21.5443469003188, 22.6754312587080, 23.8658978685858, 25.1188643150958}; + +const LC3_FLOAT sns_preemph_16[64] = {1, 1.06800043251458, 1.14062492385132, 1.21818791201012, 1.30102521691083, 1.38949549437314, 1.48398178896757, 1.58489319246111, 1.69266661503788, 1.80776867696343, 1.93069772888325, 2.06198600950222, 2.20220194998738, 2.35195263507096, 2.51188643150958, 2.68269579527973, 2.86512026966378, 3.05994968720720, 3.26802758941013, 3.49025487895958, 3.72759372031494, 3.98107170553497, 4.25178630338289, 4.54090961097248, 4.84969342852820, 5.17947467923121, 5.53168119761723, 5.90783791158795, 6.30957344480193, 6.73862716803095, 7.19685673001152, 7.68624610039774, 8.20891415963826, 8.76712387296868, 9.36329208823941, 10, 10.6800043251458, 11.4062492385132, 12.1818791201012, 13.0102521691083, 13.8949549437314, 14.8398178896756, 15.8489319246111, 16.9266661503788, 18.0776867696343, 19.3069772888325, 20.6198600950222, 22.0220194998738, 23.5195263507096, 25.1188643150958, 26.8269579527973, 28.6512026966378, 30.5994968720720, 32.6802758941013, 34.9025487895958, 37.2759372031494, 39.8107170553497, 42.5178630338289, 45.4090961097248, 48.4969342852820, 51.7947467923121, 55.3168119761723, 59.0783791158795, 63.0957344480193}; + +const LC3_FLOAT sns_preemph_24[64] = {1, 1.08372885005949, 1.17446822045126, 1.27280509398106, 1.37937560084995, 1.49486913370923, 1.62003280726413, 1.75567629127500, 1.90267704822016, 2.06198600950222, 2.23463372691659, 2.42173703917547, 2.62450629661210, 2.84425319080132, 3.08239923974514, 3.34048498351325, 3.62017994982380, 3.92329345403096, 4.25178630338289, 4.60778348126382, 4.99358789347315, 5.41169526546464, 5.86481028691437, 6.35586410805477, 6.88803330095657, 7.46476040841712, 8.08977621338348, 8.76712387296868, 9.50118507318144, 10.2967083735613, 11.1588399250775, 12.0931567600021, 13.1057028691062, 14.2030282995578, 15.3922315264422, 16.6810053720006, 18.0776867696343, 19.5913106945915, 21.2316686102078, 23.0093718077846, 24.9359200498416, 27.0237759607902, 29.2864456462524, 31.7385660625428, 34.3959997014966, 37.2759372031494, 40.3970085600588, 43.7794036326358, 47.4450027550866, 51.4175182768393, 55.7226479550717, 60.3882411906196, 65.4444791826252, 70.9240701673285, 76.8624610039774, 83.2980664765827, 90.2725177948458, 97.8309319017829, 106.022203330167, 114.899320495775, 124.519708473503, 134.945600473732, 146.244440421985, 158.489319246111}; + +const LC3_FLOAT sns_preemph_32[64] = {1, 1.09968889964399, 1.20931567600021, 1.32987102506290, 1.46244440421985, 1.60823387766704, 1.76855694330186, 1.94486243893736, 2.13874363543396, 2.35195263507096, 2.58641620527597, 2.84425319080132, 3.12779366170121, 3.43959997014966, 3.78248990638938, 4.15956216307185, 4.57422433810926, 5.03022372910014, 5.53168119761723, 6.08312840938905, 6.68954878691415, 7.35642254459641, 8.08977621338348, 8.89623710246182, 9.78309319017829, 10.7583589854218, 11.8308479546535, 13.0102521691083, 14.3072298919376, 15.7335018968185, 17.3019573884589, 19.0267704822017, 20.9235282953511, 23.0093718077846, 25.3031507648021, 27.8255940220712, 30.5994968720720, 33.6499270449086, 37.0044512451161, 40.6933842716715, 44.7500629725045, 49.2111475092328, 54.1169526546464, 59.5118121168741, 65.4444791826252, 71.9685673001152, 79.1430345832182, 87.0327166153056, 95.7089123677128, 105.250028527773, 115.742288059206, 127.280509398106, 139.968963326130, 153.922315264422, 169.266661503788, 186.140668735512, 204.696827180752, 225.102828643018, 247.543081937190, 272.220379389991, 299.357729472049, 329.200372123041, 362.017994982380, 398.107170553497}; + +const LC3_FLOAT sns_preemph_48[64] = {1, 1.11588399250775, 1.24519708473503, 1.38949549437314, 1.55051577983262, 1.73019573884589, 1.93069772888325, 2.15443469003188, 2.40409918350997, 2.68269579527973, 2.99357729472049, 3.34048498351325, 3.72759372031494, 4.15956216307185, 4.64158883361278, 5.17947467923121, 5.77969288415331, 6.44946677103762, 7.19685673001152, 8.03085722139151, 8.96150501946605, 10, 11.1588399250775, 12.4519708473503, 13.8949549437314, 15.5051577983262, 17.3019573884589, 19.3069772888325, 21.5443469003188, 24.0409918350997, 26.8269579527973, 29.9357729472049, 33.4048498351324, 37.2759372031494, 41.5956216307185, 46.4158883361278, 51.7947467923121, 57.7969288415332, 64.4946677103762, 71.9685673001152, 80.3085722139151, 89.6150501946605, 100, 111.588399250775, 124.519708473503, 138.949549437314, 155.051577983263, 173.019573884589, 193.069772888325, 215.443469003188, 240.409918350997, 268.269579527972, 299.357729472049, 334.048498351324, 372.759372031494, 415.956216307185, 464.158883361278, 517.947467923121, 577.969288415331, 644.946677103762, 719.685673001152, 803.085722139151, 896.150501946605, 1000}; + +const LC3_FLOAT sns_preemph_96[64] = {1, 1.13231759012767, 1.28214312491253, 1.45179321339972, 1.64389099276047, 1.86140668735512, 2.10770353447348, 2.38658978685858, 2.70237759607902, 3.05994968720720, 3.46483485573037, 3.92329345403096, 4.44241418923200, 5.03022372910014, 5.69581081073769, 6.44946677103762, 7.30284467178980, 8.26913947983772, 9.36329208823941, 10.6022203330167, 12.0050805774841, 13.5935639087853, 15.3922315264422, 17.4288945087081, 19.7350438286898, 22.3463372691659, 25.3031507648021, 28.6512026966378, 32.4422607917163, 36.7349425579696, 41.5956216307185, 47.0994540447575, 53.3315403002887, 60.3882411906196, 68.3786677370108, 77.4263682681127, 87.6712387296868, 99.2716857619066, 112.407075989833, 127.280509398106, 144.121959671886, 163.191830060146, 184.784979742229, 209.235282953511, 236.920791363601, 268.269579527972, 303.766363795677, 343.959997014966, 389.471954920307, 441.005945417674, 499.358789347315, 565.432740962822, 640.249438626305, 724.965701425931, 820.891415963825, 929.509789880649, 1052.50028527773, 1191.76458663437, 1349.45600473732, 1528.01277126748, 1730.19573884589, 1959.13106945914, 2218.35857131422, 2511.88643150958}; + +const LC3_FLOAT *sns_preemph_all[6] = {sns_preemph_8, sns_preemph_16, sns_preemph_24, sns_preemph_32, sns_preemph_48, sns_preemph_96}; + +const LC3_FLOAT sns_vq_far_adj_gains_fl[8] = {1.05859375000000, 1.23706054687500, 1.43920898437500, 1.98950195312500, + 2.49877929687500, 3.13110351562500, 4.11816406250000, 4.85400390625000}; + +const LC3_FLOAT sns_vq_near_adj_gains_fl[4] = {1.73315429687500, 2.22949218750000, 2.74731445312500, 3.61523437500000}; + +const LC3_FLOAT sns_vq_reg_lf_adj_gains_fl[4] = {1.52465820312500, 3.67260742187500, 4.36059570312500, + 5.13037109375000}; + +const LC3_FLOAT q_g_sns[6] = {2.17651367187500, 2.94287109375000, 1.52465820312500, + 3.67260742187500, 4.36059570312500, 5.13037109375000}; + +const LC3_FLOAT sns_vq_reg_adj_gains_fl[2] = {2.17651367187500, 2.94287109375000}; + +/* First element in each row is multiplied with norm2 = 1 / sqrt(2) */ +const LC3_FLOAT idct_lookup[M][M] = { + {0.707106781186547, 0.995184726672197, 0.980785280403230, 0.956940335732209, 0.923879532511287, 0.881921264348355, 0.831469612302545, 0.773010453362737, 0.707106781186548, 0.634393284163646, 0.555570233019602, 0.471396736825998, 0.382683432365090, 0.290284677254462, 0.195090322016128, 0.0980171403295608}, + {0.707106781186547, 0.956940335732209, 0.831469612302545, 0.634393284163646, 0.382683432365090, 0.0980171403295608, -0.195090322016128, -0.471396736825998, -0.707106781186548, -0.881921264348355, -0.980785280403230, -0.995184726672197, -0.923879532511287, -0.773010453362737, -0.555570233019602, -0.290284677254462}, + {0.707106781186547, 0.881921264348355, 0.555570233019602, 0.0980171403295608, -0.382683432365090, -0.773010453362737, -0.980785280403230, -0.956940335732209, -0.707106781186548, -0.290284677254462, 0.195090322016128, 0.634393284163646, 0.923879532511287, 0.995184726672197, 0.831469612302546, 0.471396736825998}, + {0.707106781186547, 0.773010453362737, 0.195090322016128, -0.471396736825998, -0.923879532511287, -0.956940335732209, -0.555570233019602, 0.0980171403295601, 0.707106781186547, 0.995184726672197, 0.831469612302546, 0.290284677254463, -0.382683432365090, -0.881921264348355, -0.980785280403231, -0.634393284163645}, + {0.707106781186547, 0.634393284163646, -0.195090322016128, -0.881921264348355, -0.923879532511287, -0.290284677254462, 0.555570233019602, 0.995184726672197, 0.707106781186548, -0.0980171403295600, -0.831469612302545, -0.956940335732209, -0.382683432365091, 0.471396736825997, 0.980785280403230, 0.773010453362738}, + {0.707106781186547, 0.471396736825998, -0.555570233019602, -0.995184726672197, -0.382683432365090, 0.634393284163645, 0.980785280403231, 0.290284677254463, -0.707106781186547, -0.956940335732209, -0.195090322016130, 0.773010453362736, 0.923879532511287, 0.0980171403295626, -0.831469612302544, -0.881921264348356}, + {0.707106781186547, 0.290284677254462, -0.831469612302545, -0.773010453362737, 0.382683432365090, 0.995184726672197, 0.195090322016128, -0.881921264348356, -0.707106781186547, 0.471396736825997, 0.980785280403230, 0.0980171403295591, -0.923879532511287, -0.634393284163646, 0.555570233019604, 0.956940335732208}, + {0.707106781186547, 0.0980171403295608, -0.980785280403230, -0.290284677254463, 0.923879532511287, 0.471396736825998, -0.831469612302544, -0.634393284163647, 0.707106781186547, 0.773010453362738, -0.555570233019602, -0.881921264348356, 0.382683432365086, 0.956940335732209, -0.195090322016125, -0.995184726672197}, + {0.707106781186547, -0.0980171403295607, -0.980785280403230, 0.290284677254463, 0.923879532511287, -0.471396736825998, -0.831469612302545, 0.634393284163646, 0.707106781186547, -0.773010453362737, -0.555570233019603, 0.881921264348356, 0.382683432365088, -0.956940335732209, -0.195090322016127, 0.995184726672197}, + {0.707106781186547, -0.290284677254462, -0.831469612302546, 0.773010453362737, 0.382683432365090, -0.995184726672197, 0.195090322016127, 0.881921264348356, -0.707106781186547, -0.471396736825998, 0.980785280403230, -0.0980171403295577, -0.923879532511288, 0.634393284163644, 0.555570233019606, -0.956940335732208}, + {0.707106781186547, -0.471396736825998, -0.555570233019602, 0.995184726672197, -0.382683432365090, -0.634393284163645, 0.980785280403230, -0.290284677254463, -0.707106781186547, 0.956940335732209, -0.195090322016129, -0.773010453362737, 0.923879532511287, -0.0980171403295610, -0.831469612302545, 0.881921264348355}, + {0.707106781186547, -0.634393284163645, -0.195090322016129, 0.881921264348355, -0.923879532511286, 0.290284677254461, 0.555570233019603, -0.995184726672197, 0.707106781186547, 0.0980171403295628, -0.831469612302547, 0.956940335732208, -0.382683432365089, -0.471396736825999, 0.980785280403231, -0.773010453362733}, + {0.707106781186547, -0.773010453362737, 0.195090322016128, 0.471396736825998, -0.923879532511287, 0.956940335732209, -0.555570233019602, -0.0980171403295592, 0.707106781186548, -0.995184726672197, 0.831469612302546, -0.290284677254462, -0.382683432365091, 0.881921264348355, -0.980785280403231, 0.634393284163644}, + {0.707106781186547, -0.881921264348355, 0.555570233019602, -0.0980171403295600, -0.382683432365091, 0.773010453362738, -0.980785280403231, 0.956940335732208, -0.707106781186546, 0.290284677254462, 0.195090322016130, -0.634393284163649, 0.923879532511288, -0.995184726672197, 0.831469612302542, -0.471396736825993}, + {0.707106781186547, -0.956940335732209, 0.831469612302545, -0.634393284163645, 0.382683432365090, -0.0980171403295615, -0.195090322016130, 0.471396736825998, -0.707106781186548, 0.881921264348355, -0.980785280403230, 0.995184726672197, -0.923879532511285, 0.773010453362735, -0.555570233019601, 0.290284677254462}, + {0.707106781186547, -0.995184726672197, 0.980785280403230, -0.956940335732209, 0.923879532511286, -0.881921264348355, 0.831469612302544, -0.773010453362736, 0.707106781186546, -0.634393284163644, 0.555570233019601, -0.471396736825994, 0.382683432365086, -0.290284677254458, 0.195090322016124, -0.0980171403295567} +}; + +const LC3_FLOAT sns_dec_gains[4][8] = { + {2.17651367187500, 2.94287109375000, 0, 0, 0, 0, 0, 0}, + {1.52465820312500, 3.67260742187500, 4.36059570312500, 5.13037109375000, 0, 0, 0, 0}, + {1.73315429687500, 2.22949218750000, 2.74731445312500, 3.61523437500000, 0, 0, 0, 0}, + {1.05859375000000, 1.23706054687500, 1.43920898437500, 1.98950195312500, 2.49877929687500, 3.13110351562500, + 4.11816406250000, 4.85400390625000}}; + +/* Global Gain */ +const LC3_INT gg_p1[6] = {80, 230, 380, 530, 680, 830}; +const LC3_INT gg_p2[6] = {500, 1025, 1550, 2075, 2600, 3125}; +const LC3_INT gg_p3[6] = {850, 1700, 2550, 3400, 4250, 5100}; + +const LC3_FLOAT gg_c[6] = {0.00575396825396825, 0.00500524109014675, 0.00473646723646723, + 0.00459816612729234, 0.00451388888888889, 0.004457153231663}; +const LC3_FLOAT gg_d[6] = {1310.34482758621, 3241.36125654450, 5267.66917293233, + 7326.39296187684, 9400.00000000000, 11481.67006109979}; + +/* Olpa */ +const LC3_FLOAT olpa_down2[5] = {0.1236796411180537, 0.2353512128364889, 0.2819382920909148, 0.2353512128364889, + 0.1236796411180537}; + +const LC3_FLOAT olpa_acw[98] = {1.0, + 0.994845360824742, + 0.989690721649485, + 0.984536082474227, + 0.979381443298969, + 0.974226804123711, + 0.969072164948454, + 0.963917525773196, + 0.958762886597938, + 0.953608247422680, + 0.948453608247423, + 0.943298969072165, + 0.938144329896907, + 0.932989690721650, + 0.927835051546392, + 0.922680412371134, + 0.917525773195876, + 0.912371134020619, + 0.907216494845361, + 0.902061855670103, + 0.896907216494845, + 0.891752577319588, + 0.886597938144330, + 0.881443298969072, + 0.876288659793814, + 0.871134020618557, + 0.865979381443299, + 0.860824742268041, + 0.855670103092784, + 0.850515463917526, + 0.845360824742268, + 0.840206185567010, + 0.835051546391753, + 0.829896907216495, + 0.824742268041237, + 0.819587628865979, + 0.814432989690722, + 0.809278350515464, + 0.804123711340206, + 0.798969072164949, + 0.793814432989691, + 0.788659793814433, + 0.783505154639175, + 0.778350515463918, + 0.773195876288660, + 0.768041237113402, + 0.762886597938144, + 0.757731958762887, + 0.752577319587629, + 0.747422680412371, + 0.742268041237113, + 0.737113402061856, + 0.731958762886598, + 0.726804123711340, + 0.721649484536083, + 0.716494845360825, + 0.711340206185567, + 0.706185567010309, + 0.701030927835052, + 0.695876288659794, + 0.690721649484536, + 0.685567010309278, + 0.680412371134021, + 0.675257731958763, + 0.670103092783505, + 0.664948453608247, + 0.659793814432990, + 0.654639175257732, + 0.649484536082474, + 0.644329896907216, + 0.639175257731959, + 0.634020618556701, + 0.628865979381443, + 0.623711340206186, + 0.618556701030928, + 0.613402061855670, + 0.608247422680412, + 0.603092783505155, + 0.597938144329897, + 0.592783505154639, + 0.587628865979382, + 0.582474226804124, + 0.577319587628866, + 0.572164948453608, + 0.567010309278351, + 0.561855670103093, + 0.556701030927835, + 0.551546391752577, + 0.546391752577320, + 0.541237113402062, + 0.536082474226804, + 0.530927835051546, + 0.525773195876289, + 0.520618556701031, + 0.515463917525773, + 0.510309278350515, + 0.505154639175258, + 0.500000000000000}; + +/* LTPF */ +const LC3_FLOAT conf_tilt_filter_16[4][3] = {{6.023618207009578e-01, 4.197609261363617e-01, -1.883424527883687e-02}, + {5.994768582584314e-01, 4.197609261363620e-01, -1.594928283631041e-02}, + {5.967764663733787e-01, 4.197609261363617e-01, -1.324889095125780e-02}, + {5.942410120098895e-01, 4.197609261363618e-01, -1.071343658776831e-02}}; + +const LC3_FLOAT conf_tilt_filter_24[4][5] = {{3.989695588963494e-01, 5.142508607708275e-01, 1.004382966157454e-01, + -1.278893956818042e-02, -1.572280075461383e-03}, + {3.948634911286333e-01, 5.123819208048688e-01, 1.043194926386267e-01, + -1.091999960222166e-02, -1.347408330627317e-03}, + {3.909844475885914e-01, 5.106053522688359e-01, 1.079832524685944e-01, + -9.143431066188848e-03, -1.132124620551895e-03}, + {3.873093888199928e-01, 5.089122083363975e-01, 1.114517380217371e-01, + -7.450287133750717e-03, -9.255514050963111e-04}}; + +const LC3_FLOAT conf_tilt_filter_32[4][7] = { + {2.982379446702096e-01, 4.652809203721290e-01, 2.105997428614279e-01, 3.766780380806063e-02, -1.015696155796564e-02, + -2.535880996101096e-03, -3.182946168719958e-04}, + {2.943834154510240e-01, 4.619294002718798e-01, 2.129465770091844e-01, 4.066175002688857e-02, -8.693272297010050e-03, + -2.178307114679820e-03, -2.742888063983188e-04}, + {2.907439213122688e-01, 4.587461910960279e-01, 2.151456974108970e-01, 4.350104772529774e-02, -7.295495347716925e-03, + -1.834395637237086e-03, -2.316920186482416e-04}, + {2.872975852589158e-01, 4.557148886861379e-01, 2.172126950911401e-01, 4.620088878229615e-02, -5.957463802125952e-03, + -1.502934284345198e-03, -1.903851911308866e-04}}; + +const LC3_FLOAT conf_tilt_filter_48[4][11] = { + {1.981363739883217e-01, 3.524494903964904e-01, 2.513695269649414e-01, 1.424146237314458e-01, 5.704731023952599e-02, + 9.293366241586384e-03, -7.226025368953745e-03, -3.172679890356356e-03, -1.121835963567014e-03, + -2.902957238400140e-04, -4.270815593769240e-05}, + {1.950709426598375e-01, 3.484660408341632e-01, 2.509988459466574e-01, 1.441167412482088e-01, 5.928947317677285e-02, + 1.108923827452231e-02, -6.192908108653504e-03, -2.726705509251737e-03, -9.667125826217151e-04, + -2.508100923165204e-04, -3.699938766131869e-05}, + {1.921810055196015e-01, 3.446945561091513e-01, 2.506220094626024e-01, 1.457102447664837e-01, 6.141132133664525e-02, + 1.279941396562798e-02, -5.203721087886321e-03, -2.297324511109085e-03, -8.165608133217555e-04, + -2.123855748277408e-04, -3.141271330981649e-05}, + {1.894485314175868e-01, 3.411139251108252e-01, 2.502406876894361e-01, 1.472065631098081e-01, 6.342477229539051e-02, + 1.443203434150312e-02, -4.254449144657098e-03, -1.883081472613493e-03, -6.709619060722140e-04, + -1.749363341966872e-04, -2.593864735284285e-05}}; + +const LC3_FLOAT conf_inter_filter_16[4][4] = { + {2.098804630681809e-01, 5.835275754221211e-01, 2.098804630681809e-01, 0.000000000000000e+00}, + {1.069991860896389e-01, 5.500750019177116e-01, 3.356906254147840e-01, 6.698858366939680e-03}, + {3.967114782344967e-02, 4.592209296082350e-01, 4.592209296082350e-01, 3.967114782344967e-02}, + {6.698858366939680e-03, 3.356906254147840e-01, 5.500750019177116e-01, 1.069991860896389e-01}}; + +const LC3_FLOAT conf_inter_filter_24[4][6] = {{6.322231627323796e-02, 2.507309606013235e-01, 3.713909428901578e-01, + 2.507309606013235e-01, 6.322231627323796e-02, 0.000000000000000e+00}, + {3.459272174099855e-02, 1.986515602645028e-01, 3.626411726581452e-01, + 2.986750548992179e-01, 1.013092873505928e-01, 4.263543712369752e-03}, + {1.535746784963907e-02, 1.474344878058222e-01, 3.374259553990717e-01, + 3.374259553990717e-01, 1.474344878058222e-01, 1.535746784963907e-02}, + {4.263543712369752e-03, 1.013092873505928e-01, 2.986750548992179e-01, + 3.626411726581452e-01, 1.986515602645028e-01, 3.459272174099855e-02}}; + +const LC3_FLOAT conf_inter_filter_32[4][8] = { + {2.900401878228730e-02, 1.129857420560927e-01, 2.212024028097570e-01, 2.723909472446145e-01, 2.212024028097570e-01, + 1.129857420560927e-01, 2.900401878228730e-02, 0.000000000000000e+00}, + {1.703153418385261e-02, 8.722503785537784e-02, 1.961407762232199e-01, 2.689237982237257e-01, 2.424999102756389e-01, + 1.405773364650031e-01, 4.474877169485788e-02, 3.127030243100724e-03}, + {8.563673748488349e-03, 6.426222944493845e-02, 1.687676705918012e-01, 2.587445937795505e-01, 2.587445937795505e-01, + 1.687676705918012e-01, 6.426222944493845e-02, 8.563673748488349e-03}, + {3.127030243100724e-03, 4.474877169485788e-02, 1.405773364650031e-01, 2.424999102756389e-01, 2.689237982237257e-01, + 1.961407762232199e-01, 8.722503785537784e-02, 1.703153418385261e-02}}; + +const LC3_FLOAT conf_inter_filter_48[4][12] = { + {1.082359386659387e-02, 3.608969221303979e-02, 7.676401468099964e-02, 1.241530577501703e-01, 1.627596438300696e-01, + 1.776771417779109e-01, 1.627596438300696e-01, 1.241530577501703e-01, 7.676401468099964e-02, 3.608969221303979e-02, + 1.082359386659387e-02, 0.000000000000000e+00}, + {7.041404930459358e-03, 2.819702319820420e-02, 6.547044935127551e-02, 1.124647986743299e-01, 1.548418956489015e-01, + 1.767122381341857e-01, 1.691507213057663e-01, 1.352901577989766e-01, 8.851425011427483e-02, 4.499353848562444e-02, + 1.557613714732002e-02, 2.039721956502016e-03}, + {4.146998467444788e-03, 2.135757310741917e-02, 5.482735584552816e-02, 1.004971444643720e-01, 1.456060342830002e-01, + 1.738439838565869e-01, 1.738439838565869e-01, 1.456060342830002e-01, 1.004971444643720e-01, 5.482735584552816e-02, + 2.135757310741917e-02, 4.146998467444788e-03}, + {2.039721956502016e-03, 1.557613714732002e-02, 4.499353848562444e-02, 8.851425011427483e-02, 1.352901577989766e-01, + 1.691507213057663e-01, 1.767122381341857e-01, 1.548418956489015e-01, 1.124647986743299e-01, 6.547044935127551e-02, + 2.819702319820420e-02, 7.041404930459358e-03}}; + +const LC3_FLOAT inter4_1[33] = {0, + -2.874561161519444e-03, + -3.001251025861499e-03, + +2.745471654059321e-03, + +1.535727698935322e-02, + +2.868234046665657e-02, + +2.950385026557377e-02, + +4.598334491135473e-03, + -4.729632459043440e-02, + -1.058359163062837e-01, + -1.303050213607112e-01, + -7.544046357555201e-02, + +8.357885725250529e-02, + +3.301825710764459e-01, + +6.032970076366158e-01, + +8.174886856243178e-01, + +8.986382851273982e-01, + +8.174886856243178e-01, + +6.032970076366158e-01, + +3.301825710764459e-01, + +8.357885725250529e-02, + -7.544046357555201e-02, + -1.303050213607112e-01, + -1.058359163062837e-01, + -4.729632459043440e-02, + +4.598334491135473e-03, + +2.950385026557377e-02, + +2.868234046665657e-02, + +1.535727698935322e-02, + +2.745471654059321e-03, + -3.001251025861499e-03, + -2.874561161519444e-03, + 0}; + +const LC3_FLOAT enc_inter_filter[4][4] = { + {+2.098804630681809e-01, +5.835275754221211e-01, +2.098804630681809e-01, 0}, + {+1.069991860896389e-01, +5.500750019177116e-01, +3.356906254147840e-01, +6.698858366939680e-03}, + {+3.967114782344967e-02, +4.592209296082350e-01, +4.592209296082350e-01, +3.967114782344967e-02}, + {+6.698858366939680e-03, +3.356906254147840e-01, +5.500750019177116e-01, +1.069991860896389e-01}}; + +/* Bandwidth Detector */ +const LC3_INT threshold_quiet[4] = {20, 10, 10, 10}; +const LC3_INT threshold_brickwall[4] = {15, 23, 20, 20}; +const LC3_INT brickwall_dist[4] = {4, 4, 3, 1}; +const LC3_INT BW_warp_idx_start_16k[4] = {53, 0, 0, 0}; +const LC3_INT BW_warp_idx_stop_16k[4] = {63, 0, 0, 0}; +const LC3_INT BW_warp_idx_start_24k[4] = {47, 59, 0, 0}; +const LC3_INT BW_warp_idx_stop_24k[4] = {56, 63, 0, 0}; +const LC3_INT BW_warp_idx_start_32k[4] = {44, 54, 60, 0}; +const LC3_INT BW_warp_idx_stop_32k[4] = {52, 59, 63, 0}; +const LC3_INT BW_warp_idx_start_48k[4] = {41, 51, 57, 61}; +const LC3_INT BW_warp_idx_stop_48k[4] = {49, 55, 60, 63}; +const LC3_INT* BW_warp_idx_start_all[4] = {BW_warp_idx_start_16k, BW_warp_idx_start_24k, BW_warp_idx_start_32k, + BW_warp_idx_start_48k}; +const LC3_INT* BW_warp_idx_stop_all[4] = {BW_warp_idx_stop_16k, BW_warp_idx_stop_24k, BW_warp_idx_stop_32k, + BW_warp_idx_stop_48k}; + +const LC3_INT BW_warp_idx_start_16k_2_5ms[4] = {24, 0, 0, 0}; +const LC3_INT BW_warp_idx_stop_16k_2_5ms[4] = {34, 0, 0, 0}; +const LC3_INT BW_warp_idx_start_24k_2_5ms[4] = {24, 35, 0, 0}; +const LC3_INT BW_warp_idx_stop_24k_2_5ms[4] = {32, 39, 0, 0}; +const LC3_INT BW_warp_idx_start_32k_2_5ms[4] = {24, 33, 39, 0}; +const LC3_INT BW_warp_idx_stop_32k_2_5ms[4] = {31, 38, 42, 0}; +const LC3_INT BW_warp_idx_start_48k_2_5ms[4] = {22, 31, 37, 41}; +const LC3_INT BW_warp_idx_stop_48k_2_5ms[4] = {29, 35, 40, 43}; + +const LC3_INT* BW_warp_idx_start_all_2_5ms[4] = {BW_warp_idx_start_16k_2_5ms, BW_warp_idx_start_24k_2_5ms, + BW_warp_idx_start_32k_2_5ms, BW_warp_idx_start_48k_2_5ms}; +const LC3_INT* BW_warp_idx_stop_all_2_5ms[4] = {BW_warp_idx_stop_16k_2_5ms, BW_warp_idx_stop_24k_2_5ms, + BW_warp_idx_stop_32k_2_5ms, BW_warp_idx_stop_48k_2_5ms}; + +const LC3_INT bands_number_2_5ms_HR[6] = {20, 35, 40, 43, 45, 49}; + +const LC3_INT bands_number_2_5ms[5] = {20, 35, 40, 43, 44}; + + +const LC3_INT BW_warp_idx_start_16k_5ms[4] = {39, 0, 0, 0}; +const LC3_INT BW_warp_idx_stop_16k_5ms[4] = {49, 0, 0, 0}; +const LC3_INT BW_warp_idx_start_24k_5ms[4] = {35, 47, 0, 0}; +const LC3_INT BW_warp_idx_stop_24k_5ms[4] = {44, 51, 0, 0}; +const LC3_INT BW_warp_idx_start_32k_5ms[4] = {34, 44, 50, 0}; +const LC3_INT BW_warp_idx_stop_32k_5ms[4] = {42, 49, 53, 0}; +const LC3_INT BW_warp_idx_start_48k_5ms[4] = {32, 42, 48, 52}; +const LC3_INT BW_warp_idx_stop_48k_5ms[4] = {40, 46, 51, 54}; + +const LC3_INT* BW_warp_idx_start_all_5ms[4] = {BW_warp_idx_start_16k_5ms, BW_warp_idx_start_24k_5ms, + BW_warp_idx_start_32k_5ms, BW_warp_idx_start_48k_5ms}; +const LC3_INT* BW_warp_idx_stop_all_5ms[4] = {BW_warp_idx_stop_16k_5ms, BW_warp_idx_stop_24k_5ms, + BW_warp_idx_stop_32k_5ms, BW_warp_idx_stop_48k_5ms}; + +const LC3_INT bands_number_5ms[6] = {39, 50, 52, 54, 55, 58}; + + +const LC3_INT BW_cutoff_bin_all[MAX_BW_BANDS_NUMBER] = {80, 160, 240, 320, 400, 400}; +const LC3_INT BW_cutoff_bits_all[MAX_BW_BANDS_NUMBER] = {0, 1, 2, 2, 3, 0}; + +const LC3_INT BW_cutoff_bin_all_5ms[MAX_BW_BANDS_NUMBER] = {40, 80, 120, 160, 200, 200}; +const LC3_INT BW_cutoff_bin_all_2_5ms[MAX_BW_BANDS_NUMBER] = {20, 40, 60, 80, 100, 100}; + +#ifdef CR8_G_ADD_75MS +const LC3_INT BW_cutoff_bin_all_7_5ms[] = {60, 120, 180, 240, 300, 300}; +const LC3_INT bands_number_7_5ms_HR [] = {60, 64, 64, 64, 64, 64}; +const LC3_INT bands_number_7_5ms [] = {60, 64, 64, 64, 64}; + +const LC3_INT BW_warp_idx_start_16k_7_5ms[4] = {51, 0, 0, 0}; +const LC3_INT BW_warp_idx_stop_16k_7_5ms[4] = {63, 0, 0, 0}; + +const LC3_INT BW_warp_idx_start_24k_7_5ms[4] = {45, 58, 0, 0}; +const LC3_INT BW_warp_idx_stop_24k_7_5ms[4] = {55, 63, 0, 0}; + +const LC3_INT BW_warp_idx_start_32k_7_5ms[4] = {42, 53, 60, 0}; +const LC3_INT BW_warp_idx_stop_32k_7_5ms[4] = {51, 58, 63, 0}; + +const LC3_INT BW_warp_idx_start_48k_7_5ms[4] = {40, 51, 57, 61}; +const LC3_INT BW_warp_idx_stop_48k_7_5ms[4] = {48, 55, 60, 63}; + +const LC3_INT brickwall_dist_7_5ms[4] = {4, 4, 3, 2}; + +const LC3_INT* BW_warp_idx_start_all_7_5ms[4] = {BW_warp_idx_start_16k_7_5ms, BW_warp_idx_start_24k_7_5ms, + BW_warp_idx_start_32k_7_5ms, BW_warp_idx_start_48k_7_5ms}; +const LC3_INT* BW_warp_idx_stop_all_7_5ms[4] = {BW_warp_idx_stop_16k_7_5ms, BW_warp_idx_stop_24k_7_5ms, + BW_warp_idx_stop_32k_7_5ms, BW_warp_idx_stop_48k_7_5ms}; +#endif + +/* Arithmetic coding */ +const LC3_INT tns_cf[8][18] = {{0, 1, 6, 21, 52, 106, 192, 289, 409, 568, 720, 831, 935, 994, 1016, 1022, 1023, 1024}, + {0, 1, 2, 3, 4, 17, 60, 154, 293, 466, 626, 780, 911, 989, 1016, 1022, 1023, 1024}, + {0, 1, 2, 3, 4, 13, 56, 162, 361, 578, 788, 929, 1003, 1020, 1021, 1022, 1023, 1024}, + {0, 1, 2, 3, 4, 6, 17, 66, 270, 555, 852, 972, 1011, 1020, 1021, 1022, 1023, 1024}, + {0, 1, 2, 3, 4, 5, 12, 54, 295, 636, 950, 1008, 1017, 1020, 1021, 1022, 1023, 1024}, + {0, 1, 2, 3, 4, 5, 6, 19, 224, 590, 967, 1014, 1019, 1020, 1021, 1022, 1023, 1024}, + {0, 1, 2, 3, 4, 5, 6, 19, 300, 630, 1001, 1018, 1019, 1020, 1021, 1022, 1023, 1024}, + {0, 1, 2, 3, 4, 5, 6, 11, 308, 309, 991, 1017, 1019, 1020, 1021, 1022, 1023, 1024}}; + +const LC3_INT tns_freq_cf[2][9] = {{0, 3, 12, 35, 89, 200, 390, 658, 1024}, {0, 14, 56, 156, 313, 494, 672, 839, 1024}}; + +/* MDCT Windows */ + + +#ifdef CR8_G_ADD_75MS + +const LC3_FLOAT MDCT_HRA_WINDOW_480_7_5ms[720] = { + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 6.809599915345237e-08, 2.716186708704376e-07, 6.424371293934969e-07, + 1.260808101892957e-06, 2.229378921489615e-06, 3.679074029772919e-06, 5.774505277720125e-06, 8.719889849723028e-06, + 1.276556063788606e-05, 1.821508881356302e-05, 2.543302196376427e-05, 3.485323086760931e-05, 4.698784831976895e-05, + 6.243677337396717e-05, 8.189770380196378e-05, 1.061766484618177e-04, 1.361988597286949e-04, 1.730201142776986e-04, + 2.178382584565609e-04, 2.720049223973359e-04, 3.370372950540977e-04, 4.146298406925523e-04, 5.066658261806472e-04, + 6.152285179265661e-04, 7.426118976760646e-04, 8.913307378108167e-04, 1.064129869478226e-03, 1.263992471022180e-03, + 1.494147199957892e-03, 1.758073989316892e-03, 2.059508328742228e-03, 2.402443852384859e-03, 2.791133059566779e-03, + 3.230086000439834e-03, 3.724066767561293e-03, 4.278087645481125e-03, 4.897400784114414e-03, 5.587487277846723e-03, + 6.354043550947961e-03, 7.202964970873775e-03, 8.140326634299601e-03, 9.172361296110928e-03, 1.030543443887801e-02, + 1.154601650935216e-02, 1.290065237897715e-02, 1.437592811702264e-02, 1.597843519739845e-02, 1.771473229314812e-02, + 1.959130484567766e-02, 2.161452262855616e-02, 2.379059555782150e-02, 2.612552803171593e-02, 2.862507211224012e-02, + 3.129467988842215e-02, 3.413945538633399e-02, 3.716410641324389e-02, 4.037289674248027e-02, 4.376959906123697e-02, + 4.735744911533900e-02, 5.113910149261011e-02, 5.511658748968899e-02, 5.929127550571237e-02, 6.366383440006920e-02, + 6.823420024032127e-02, 7.300154685033973e-02, 7.796426054773728e-02, 8.311991943385708e-02, 8.846527756905853e-02, + 9.399625433100661e-02, 9.970792921440458e-02, 1.055945422874181e-01, 1.116495004733158e-01, 1.178654910777398e-01, + 1.242343970754217e-01, 1.307472697698447e-01, 1.373944835632858e-01, 1.441657329773458e-01, 1.510500827600614e-01, + 1.580360226424669e-01, 1.651115279124688e-01, 1.722641255794418e-01, 1.794809657536407e-01, 1.867488977915941e-01, + 1.940545506994020e-01, 2.013844172328433e-01, 2.087249410855671e-01, 2.160626065146083e-01, 2.233840297164879e-01, + 2.306760512375861e-01, 2.379258286796330e-01, 2.451209289452065e-01, 2.522494192591140e-01, 2.592999561994307e-01, + 2.662618719765588e-01, 2.731252572097561e-01, 2.798810394677779e-01, 2.865210568632502e-01, 2.930381260187334e-01, + 2.994261037557683e-01, 3.056799418961772e-01, 3.117957346072421e-01, 3.177707577688937e-01, 3.236034998916132e-01, + 3.292936841683654e-01, 3.348422813026286e-01, 3.402515128176158e-01, 3.455248446193337e-01, 3.506669706583936e-01, + 3.556837866127393e-01, 3.605823535957678e-01, 3.653708519817664e-01, 3.700585255329578e-01, 3.746556161093967e-01, + 3.791732893437698e-01, 3.836235517669143e-01, 3.880191599752360e-01, 3.923735225365686e-01, 3.967005954344419e-01, + 4.010147719499705e-01, 4.053307679732117e-01, 4.096635038192941e-01, 4.140279836962412e-01, 4.184391740286457e-01, + 4.229118818818259e-01, 4.274606347526876e-01, 4.320995629945984e-01, 4.368422861229869e-01, 4.417018042055877e-01, + 4.466903954763946e-01, 4.518195212263102e-01, 4.570997389177666e-01, 4.625406243474134e-01, 4.681507035432432e-01, + 4.739373949335071e-01, 4.799069621682588e-01, 4.860644778142650e-01, 4.924137979843949e-01, 4.989575478073994e-01, + 5.056971174969224e-01, 5.126326686429926e-01, 5.197631502279640e-01, 5.270863237641458e-01, 5.345987968637925e-01, + 5.422960644846202e-01, 5.501725570458306e-01, 5.582216945803693e-01, 5.664359460778171e-01, 5.748068931775395e-01, + 5.833252973915712e-01, 5.919811700691291e-01, 6.007638443572958e-01, 6.096620484629849e-01, 6.186639795774059e-01, + 6.277573778837434e-01, 6.369296001295948e-01, 6.461676923061090e-01, 6.554584610342162e-01, 6.647885433136285e-01, + 6.741444743414929e-01, 6.835127531540456e-01, 6.928799058859592e-01, 7.022325464781733e-01, 7.115574346958600e-01, + 7.208415313440352e-01, 7.300720505895358e-01, 7.392365093150189e-01, 7.483227734438597e-01, 7.573191011847887e-01, + 7.662141831523945e-01, 7.749971793247219e-01, 7.836577528026495e-01, 7.921861003379914e-01, 8.005729795988183e-01, + 8.088097331417404e-01, 8.168883090622450e-01, 8.248012782960292e-01, 8.325418485469714e-01, 8.401038748212752e-01, + 8.474818665528070e-01, 8.546709913119690e-01, 8.616670751000000e-01, 8.684665992426276e-01, 8.750666939117441e-01, + 8.814651283214563e-01, 8.876602976655703e-01, 8.936512068873075e-01, 8.994374513987017e-01, 9.050191948964271e-01, + 9.103971444522861e-01, 9.155725230896603e-01, 9.205470400910444e-01, 9.253228593153561e-01, 9.299025658359243e-01, + 9.342891312395554e-01, 9.384858779525852e-01, 9.424964429799174e-01, 9.463247414564011e-01, 9.499749304154305e-01, + 9.534513731762839e-01, 9.567586047388893e-01, 9.599012985520849e-01, 9.628842349891718e-01, 9.657122718232282e-01, + 9.683903169452684e-01, 9.709233035123621e-01, 9.733161676521148e-01, 9.755738287865520e-01, 9.777011725747500e-01, + 9.797030364119408e-01, 9.815841973655319e-01, 9.833493623777330e-01, 9.850031605220572e-01, 9.865501370683191e-01, + 9.879947490888552e-01, 9.893413623279752e-01, 9.905942490570202e-01, 9.917575866483249e-01, 9.928354566216883e-01, + 9.938318439453252e-01, 9.947506364078684e-01, 9.955956239169538e-01, 9.963704976211798e-01, 9.970788487938620e-01, + 9.977241674570765e-01, 9.983098407613983e-01, 9.988391511690631e-01, 9.993152745149454e-01, 9.997412780400421e-01, + 1.000120118505655e+00, 1.000454640503141e+00, 1.000747575074179e+00, 1.001001538750552e+00, 1.001219033111063e+00, + 1.001402444937498e+00, 1.001554047032278e+00, 1.001675999738891e+00, 1.001770353183267e+00, 1.001839050231077e+00, + 1.001883930133431e+00, 1.001906732812431e+00, 1.001909103719272e+00, 1.001892599181639e+00, 1.001858692144366e+00, + 1.001808778198111e+00, 1.001744181785080e+00, 1.001666162468790e+00, 1.001575921156133e+00, 1.001474606164513e+00, + 1.001363319034069e+00, 1.001243119994661e+00, 1.001115033008877e+00, 1.000980050325283e+00, 1.000839136490102e+00, + 1.000693231779806e+00, 1.000543255031507e+00, 1.000390105861922e+00, 1.000234666278804e+00, 1.000077801700791e+00, + 9.999203614123487e-01, 9.997631784897281e-01, 9.996070692418051e-01, 9.994528322168238e-01, 9.993012468388005e-01, + 9.991530718675707e-01, 9.990090391528494e-01, 9.988698631596843e-01, 9.987362319429512e-01, 9.986087958497237e-01, + 9.984881744259831e-01, 9.983749534239558e-01, 9.982696819855041e-01, 9.981728700145615e-01, 9.980849857504854e-01, + 9.980064535530436e-01, 9.979376519085494e-01, 9.978789116654476e-01, 9.978305145064250e-01, 9.977926916628833e-01, + 9.977656228763698e-01, 9.977494356103552e-01, 9.977442045145120e-01, 9.977499511424820e-01, 9.977666439229387e-01, + 9.977941983826280e-01, 9.978324776189644e-01, 9.978812930187096e-01, 9.979404052182159e-01, 9.980095252997591e-01, + 9.980883162175314e-01, 9.981763944459758e-01, 9.982733318422902e-01, 9.983786577141155e-01, 9.984918610826710e-01, + 9.986123931308583e-01, 9.987396698251857e-01, 9.988730746997222e-01, 9.990119617896823e-01, 9.991556587016854e-01, + 9.993034698072086e-01, 9.994546795452566e-01, 9.996085558198406e-01, 9.997643534774231e-01, 9.999213178491362e-01, + 1.000078688342232e+00, 1.000235702064949e+00, 1.000391597468710e+00, 1.000545617991395e+00, 1.000697015685261e+00, + 1.000845054812993e+00, 1.000989015395319e+00, 1.001128196693676e+00, 1.001261920611439e+00, 1.001389534997449e+00, + 1.001510416835741e+00, 1.001623975305719e+00, 1.001729654697400e+00, 1.001826937166789e+00, 1.001915345317049e+00, + 1.001994444591742e+00, 1.002063845467139e+00, 1.002123205431461e+00, 1.002172230739781e+00, 1.002210677934335e+00, + 1.002238355121073e+00, 1.002255122994435e+00, 1.002260895603584e+00, 1.002255640854628e+00, 1.002239380744737e+00, + 1.002212191325473e+00, 1.002174202394129e+00, 1.002125596913369e+00, 1.002066610160972e+00, 1.001997528613025e+00, + 1.001918688565458e+00, 1.001830474500286e+00, 1.001733317204479e+00, 1.001627691650788e+00, 1.001514114651268e+00, + 1.001393142295620e+00, 1.001265367187681e+00, 1.001131415494648e+00, 1.000991943824643e+00, 1.000847635949292e+00, + 1.000699199388794e+00, 1.000547361877802e+00, 1.000392867731002e+00, 1.000236474127865e+00, 1.000078947336370e+00, + 9.999210588958194e-01, 9.997635817789274e-01, 9.996072865534386e-01, 9.994529375633210e-01, 9.993012891494056e-01, + 9.991530819289113e-01, 9.990090391528497e-01, 9.988698631596844e-01, 9.987362319429512e-01, 9.986087958497240e-01, + 9.984881744259831e-01, 9.983749534239558e-01, 9.982696819855044e-01, 9.981728700145615e-01, 9.980849857504854e-01, + 9.980064535530438e-01, 9.979376519085497e-01, 9.978789116654476e-01, 9.978305145064252e-01, 9.977926916628833e-01, + 9.977656228763698e-01, 9.977494356103552e-01, 9.977442045145120e-01, 9.977499511424820e-01, 9.977666439229387e-01, + 9.977941983826278e-01, 9.978324776189643e-01, 9.978812930187095e-01, 9.979404052182158e-01, 9.980095252997588e-01, + 9.980883162175312e-01, 9.981763944459756e-01, 9.982733318422901e-01, 9.983786577141153e-01, 9.984918610826709e-01, + 9.986123931308580e-01, 9.987396698251855e-01, 9.988730746997220e-01, 9.990119617896820e-01, 9.991556587016851e-01, + 9.993034698072083e-01, 9.994546795452562e-01, 9.996085558198403e-01, 9.997643534774228e-01, 9.999213178491358e-01, + 1.000078688342232e+00, 1.000235702064949e+00, 1.000391597468709e+00, 1.000545617991395e+00, 1.000697015685261e+00, + 1.000845054812992e+00, 1.000989015395319e+00, 1.001128196693676e+00, 1.001261920611439e+00, 1.001389534997449e+00, + 1.001510416835740e+00, 1.001623975305719e+00, 1.001729654697400e+00, 1.001826937166789e+00, 1.001915345317049e+00, + 1.001994444591742e+00, 1.002063845467139e+00, 1.002123205431461e+00, 1.002172230739781e+00, 1.002210677934335e+00, + 1.002238355121073e+00, 1.002255122994435e+00, 1.002260895603584e+00, 1.002255640854628e+00, 1.002239380744737e+00, + 1.002212191325473e+00, 1.002174202394129e+00, 1.002125596913369e+00, 1.002066610160972e+00, 1.001997528613026e+00, + 1.001918688565458e+00, 1.001830474500286e+00, 1.001733317204480e+00, 1.001627691650788e+00, 1.001514114651269e+00, + 1.001393142295620e+00, 1.001265367187681e+00, 1.001131415494648e+00, 1.000991943824644e+00, 1.000847625870882e+00, + 1.000699157018909e+00, 1.000547256415431e+00, 1.000392650246594e+00, 1.000236070641674e+00, 1.000078249725773e+00, + 9.999199133992033e-01, 9.997617746889341e-01, 9.996045266479927e-01, 9.994488347910435e-01, 9.992953290608048e-01, + 9.991445953265840e-01, 9.989971664237720e-01, 9.988535127515954e-01, 9.987140324557005e-01, 9.985790412319091e-01, + 9.984487617975299e-01, 9.983233130864525e-01, 9.982026992336113e-01, 9.980867984227458e-01, 9.979753516783147e-01, + 9.978679516874593e-01, 9.977640317406775e-01, 9.976628548799390e-01, 9.975635033400763e-01, 9.974648683632181e-01, + 9.973656404566504e-01, 9.972643001519088e-01, 9.971591093072504e-01, 9.970481029773169e-01, 9.969290818533281e-01, + 9.967996052552075e-01, 9.966569846345418e-01, 9.964982775252248e-01, 9.963202818581681e-01, 9.961195305388424e-01, + 9.958922861728758e-01, 9.956345358167873e-01, 9.953419856293327e-01, 9.950100553049441e-01, 9.946338721852209e-01, + 9.942082649678485e-01, 9.937277569649872e-01, 9.931865589047922e-01, 9.925785613196768e-01, 9.918973266220812e-01, + 9.911360810312226e-01, 9.902877065805247e-01, 9.893447335026750e-01, 9.882993333547356e-01, 9.871433133064559e-01, + 9.858681120677728e-01, 9.844647979734713e-01, 9.829240697712801e-01, 9.812362606719703e-01, 9.793913462143841e-01, + 9.773789564736696e-01, 9.751883930968924e-01, 9.728086515871036e-01, 9.702284491761823e-01, 9.674362585304656e-01, + 9.644203474241703e-01, 9.611688243973939e-01, 9.576696902919403e-01, 9.539108954335166e-01, 9.498804021071905e-01, + 9.455662518583811e-01, 9.409566370477763e-01, 9.360399759985500e-01, 9.308049910005284e-01, 9.252407883802984e-01, + 9.193369398095318e-01, 9.130835640061534e-01, 9.064714079838252e-01, 8.994919270231900e-01, 8.921373625716933e-01, + 8.844008173252615e-01, 8.762763268021769e-01, 8.677589267845028e-01, 8.588447160727389e-01, 8.495309140724763e-01, + 8.398159128053756e-01, 8.296993230087498e-01, 8.191820140566964e-01, 8.082661474997362e-01, 7.969552040782567e-01, + 7.852540041171052e-01, 7.731687212540459e-01, 7.607068894934714e-01, 7.478774036088883e-01, 7.346905129436833e-01, + 7.211578086800342e-01, 7.072922046612431e-01, 6.931079118639383e-01, 6.786204066243602e-01, 6.638463927281081e-01, + 6.488037574761728e-01, 6.335115218426407e-01, 6.179897848420400e-01, 6.022596622277155e-01, 5.863432196477422e-01, + 5.702634003925362e-01, 5.540439478792599e-01, 5.377093230331162e-01, 5.212846167453395e-01, 5.047954576127168e-01, + 4.882679151942771e-01, 4.717283990576996e-01, 4.552035539311637e-01, 4.387201513257116e-01, 4.223049780484175e-01, + 4.059847220871455e-01, 3.897858564125437e-01, 3.737345213109408e-01, 3.578564059314520e-01, 3.421766298000327e-01, + 3.267196251203117e-01, 3.115090207434621e-01, 2.965675287446095e-01, 2.819168345887702e-01, 2.675774919024606e-01, + 2.535688228855250e-01, 2.399088253991666e-01, 2.266140877488131e-01, 2.136997121429473e-01, 2.011792477505556e-01, + 1.890646342002475e-01, 1.773661562639070e-01, 1.660924103481652e-01, 1.552502832800154e-01, 1.448449437210769e-01, + 1.348798463815727e-01, 1.253567490336474e-01, 1.162757421482153e-01, 1.076352908043133e-01, 9.943228834915691e-02, + 9.166212112492260e-02, 8.431874342855604e-02, 7.739476173713079e-02, 7.088152711641457e-02, 6.476923463670382e-02, + 5.904702854937628e-02, 5.370311193097759e-02, 4.872485947931735e-02, 4.409893214762228e-02, 3.981139232728093e-02, + 3.584781833555012e-02, 3.219341702973252e-02, 2.883313345136149e-02, 2.575175650013100e-02, 2.293401974481060e-02, + 2.036469659423059e-02, 1.802868917267256e-02, 1.591111036782373e-02, 1.399735864319379e-02, 1.227318532813230e-02, + 1.072475421518567e-02, 9.338693404676062e-03, 8.102139438575821e-03, 7.002773858835369e-03, 6.028852408470130e-03, + 5.169227166401885e-03, 4.413361969047579e-03, 3.751341522971312e-03, 3.173874653799314e-03, 2.672292167462025e-03, + 2.238539821235712e-03, 1.865166914682179e-03, 1.545311015180633e-03, 1.272679330109336e-03, 1.041527228687644e-03, + 8.466344018536364e-04, 6.832791291344422e-04, 5.472110980420254e-04, 4.346231948339177e-04, 3.421226562082296e-04, + 2.667019402979896e-04, 2.057096427837635e-04, 1.568217505967225e-04, 1.180134920282553e-04, 8.753200853960576e-05, + 6.387004057159679e-05, 4.574078753977487e-05, 3.205407126647298e-05, 2.189390259660641e-05, 1.449752303895666e-05, + 9.235966977587421e-06, 5.596164823995474e-06, 3.164580913106852e-06, 1.612338255148207e-06, 6.816185333295410e-07, + 1.708705677347936e-07, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00 +}; + +const LC3_FLOAT MDCT_HRA_WINDOW_960_7_5ms[1440] = { + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 4.814997152662380e-08, + 1.190718835543930e-07, 2.207853347953071e-07, 3.606855997228003e-07, 5.473208818980691e-07, 7.905197136719171e-07, + 1.101521714920831e-06, 1.493116418344220e-06, 1.979790786588690e-06, 2.577885657879143e-06, 3.305761290579034e-06, + 4.183972154098288e-06, 5.235451095160501e-06, 6.485702988281604e-06, 7.963007956558409e-06, 9.698634223646832e-06, + 1.172706063036777e-05, 1.408620881991443e-05, 1.681768506430009e-05, 1.996703167159834e-05, 2.358398787878628e-05, + 2.772276009869224e-05, 3.244230135176009e-05, 3.780659967415316e-05, 4.388497525322647e-05, 5.075238599968363e-05, + 5.848974122290910e-05, 6.718422303212972e-05, 7.692961504132544e-05, 8.782663791029826e-05, 9.998329120814524e-05, + 1.135152010387006e-04, 1.285459728204526e-04, 1.452075485661517e-04, 1.636405679599540e-04, 1.839947324826567e-04, + 2.064291717885308e-04, 2.311128114906271e-04, 2.582247414653769e-04, 2.879545837420285e-04, 3.205028589981173e-04, + 3.560813506389657e-04, 3.949134653973109e-04, 4.372345893487853e-04, 4.832924382002834e-04, 5.333474006714636e-04, + 5.876728737549225e-04, 6.465555886081460e-04, 7.102959258003701e-04, 7.792082186101814e-04, 8.536210430451991e-04, + 9.338774932337428e-04, 1.020335440820132e-03, 1.113367776980400e-03, 1.213362635663867e-03, 1.320723596658401e-03, + 1.435869867073428e-03, 1.559236439835012e-03, 1.691274227791697e-03, 1.832450172038491e-03, 1.983247323079433e-03, + 2.144164893466752e-03, 2.315718280576775e-03, 2.498439058209637e-03, 2.692874935731413e-03, 2.899589683513746e-03, + 3.119163023467312e-03, 3.352190483511667e-03, 3.599283214875066e-03, 3.861067771173851e-03, 4.138185848281871e-03, + 4.431293984066133e-03, 4.741063217135362e-03, 5.068178703823501e-03, 5.413339292709984e-03, 5.777257056063160e-03, + 6.160656777682084e-03, 6.564275396705108e-03, 6.988861407050997e-03, 7.435174212259442e-03, 7.903983435603223e-03, + 8.396068185452360e-03, 8.912216275983018e-03, 9.453223403438580e-03, 1.001989227826831e-02, 1.061303171358943e-02, + 1.123345567054105e-02, 1.188198226122286e-02, 1.255943271003813e-02, 1.326663027438758e-02, 1.400439912578959e-02, + 1.477356319263120e-02, 1.557494496588335e-02, 1.640936426924359e-02, 1.727763699529732e-02, 1.818057380941704e-02, + 1.911897882324480e-02, 2.009364823972783e-02, 2.110536897180007e-02, 2.215491723692114e-02, 2.324305712980262e-02, + 2.437053917576323e-02, 2.553809886726559e-02, 2.674645518629135e-02, 2.799630911531313e-02, 2.928834213971679e-02, + 3.062321474461790e-02, 3.200156490910068e-02, 3.342400660098604e-02, 3.489112827530663e-02, 3.640349137973180e-02, + 3.796162887024292e-02, 3.956604374040874e-02, 4.121720756765420e-02, 4.291555907994722e-02, 4.466150274635713e-02, + 4.645540739495172e-02, 4.829760486151040e-02, 5.018838867252923e-02, 5.212801276598264e-02, 5.411669025328793e-02, + 5.615459222588953e-02, 5.824184660984119e-02, 6.037853707171543e-02, 6.256470197911304e-02, 6.480033341897713e-02, + 6.708537627683842e-02, 6.941972738003349e-02, 7.180323470784016e-02, 7.423569667136878e-02, 7.671686146593476e-02, + 7.924642649851196e-02, 8.182403789273630e-02, 8.444929007378586e-02, 8.712172543531613e-02, 8.984083409047044e-02, + 9.260605370882179e-02, 9.541676944092861e-02, 9.827231393200973e-02, 1.011719674260564e-01, 1.041149579615082e-01, + 1.071004616594233e-01, 1.101276031048689e-01, 1.131954558220525e-01, 1.163031145055895e-01, 1.194495144788202e-01, + 1.226335917234308e-01, 1.258542330378917e-01, 1.291102796186627e-01, 1.324005282765081e-01, 1.357237327475410e-01, + 1.390786051045917e-01, 1.424638172681925e-01, 1.458780026156580e-01, 1.493197576864202e-01, 1.527876439815144e-01, + 1.562801898548664e-01, 1.597958924937929e-01, 1.633332199858745e-01, 1.668906134691307e-01, 1.704664893621876e-01, + 1.740592416709001e-01, 1.776672443676665e-01, 1.812888538394568e-01, 1.849224114003725e-01, 1.885662458643452e-01, + 1.922186761734047e-01, 1.958780140767561e-01, 1.995425668557404e-01, 2.032106400895931e-01, 2.068805404567710e-01, + 2.105505785664793e-01, 2.142190718149099e-01, 2.178843472605934e-01, 2.215447445131696e-01, 2.251986186298022e-01, + 2.288443430133839e-01, 2.324803123066372e-01, 2.361049452761597e-01, 2.397166876804412e-01, 2.433140151158676e-01, + 2.468954358347107e-01, 2.504594935291377e-01, 2.540047700752680e-01, 2.575298882313734e-01, 2.610335142843411e-01, + 2.645143606385947e-01, 2.679711883417369e-01, 2.714028095412598e-01, 2.748080898667649e-01, 2.781859507322435e-01, + 2.815353715530788e-01, 2.848553918725547e-01, 2.881451133928004e-01, 2.914037019052332e-01, 2.946303891157192e-01, + 2.978244743598311e-01, 3.009853262037530e-01, 3.041123839265586e-01, 3.072051588797733e-01, 3.102632357203233e-01, + 3.132862735131834e-01, 3.162740067002296e-01, 3.192262459320352e-01, 3.221428787595638e-01, 3.250238701829489e-01, + 3.278692630547906e-01, 3.306791783356554e-01, 3.334538151997121e-01, 3.361934509887193e-01, 3.388984410128472e-01, + 3.415692181971050e-01, 3.442062925724498e-01, 3.468102506109446e-01, 3.493817544046665e-01, 3.519215406883794e-01, + 3.544304197063321e-01, 3.569092739238819e-01, 3.593590565850064e-01, 3.617807901171322e-01, 3.641755643850764e-01, + 3.665445347962969e-01, 3.688889202600189e-01, 3.712100010032212e-01, 3.735091162468620e-01, 3.757876617461321e-01, + 3.780470871989401e-01, 3.802888935272475e-01, 3.825146300362834e-01, 3.847258914570857e-01, 3.869243148782224e-01, + 3.891115765729500e-01, 3.912893887284619e-01, 3.934594960842652e-01, 3.956236724870978e-01, 3.977837173701507e-01, + 3.999414521646988e-01, 4.020987166525755e-01, 4.042573652681952e-01, 4.064192633591230e-01, 4.085862834144205e-01, + 4.107603012702034e-01, 4.129431923020324e-01, 4.151368276138986e-01, 4.173430702336651e-01, 4.195637713248997e-01, + 4.218007664250568e-01, 4.240558717199467e-01, 4.263308803643829e-01, 4.286275588587793e-01, 4.309476434913423e-01, + 4.332928368553010e-01, 4.356648044503836e-01, 4.380651713774884e-01, 4.404955191351588e-01, 4.429573825261284e-01, + 4.454522466818012e-01, 4.479815442120949e-01, 4.505466524876126e-01, 4.531488910606020e-01, 4.557895192306389e-01, + 4.584697337604117e-01, 4.611906667464130e-01, 4.639533836487439e-01, 4.667588814836276e-01, 4.696080871816153e-01, + 4.725018561138271e-01, 4.754409707879499e-01, 4.784261397150824e-01, 4.814579964478883e-01, 4.845370987899071e-01, + 4.876639281752684e-01, 4.908388892174636e-01, 4.940623094252686e-01, 4.973344390833572e-01, 5.006554512946366e-01, + 5.040254421808312e-01, 5.074444312373949e-01, 5.109123618383964e-01, 5.144291018866259e-01, 5.179944446038284e-01, + 5.216081094556281e-01, 5.252697432054461e-01, 5.289789210914528e-01, 5.327351481204011e-01, 5.365378604720108e-01, + 5.403864270074484e-01, 5.442801508753474e-01, 5.482182712087564e-01, 5.521999649063806e-01, 5.562243484914785e-01, + 5.602904800418288e-01, 5.643973611842344e-01, 5.685439391471354e-01, 5.727291088650085e-01, 5.769517151283868e-01, + 5.812105547734755e-01, 5.855043789055335e-01, 5.898318951503732e-01, 5.941917699285435e-01, 5.985826307469763e-01, + 6.030030685030957e-01, 6.074516397966441e-01, 6.119268692446796e-01, 6.164272517954765e-01, 6.209512550372698e-01, + 6.254973214980470e-01, 6.300638709328106e-01, 6.346493025949689e-01, 6.392519974887557e-01, 6.438703205997779e-01, + 6.485026231010093e-01, 6.531472445317767e-01, 6.578025149474425e-01, 6.624667570377041e-01, 6.671382882115985e-01, + 6.718154226474637e-01, 6.764964733062689e-01, 6.811797539068755e-01, 6.858635808619125e-01, 6.905462751730997e-01, + 6.952261642849390e-01, 6.999015838958201e-01, 7.045708797256799e-01, 7.092324092394289e-01, 7.138845433254541e-01, + 7.185256679285629e-01, 7.231541856368034e-01, 7.277685172216439e-01, 7.323671031310492e-01, 7.369484049350288e-01, + 7.415109067232617e-01, 7.460531164544494e-01, 7.505735672570528e-01, 7.550708186811053e-01, 7.595434579008099e-01, + 7.639901008676322e-01, 7.684093934136257e-01, 7.728000123047261e-01, 7.771606662437623e-01, 7.814900968229372e-01, + 7.857870794255352e-01, 7.900504240766176e-01, 7.942789762424746e-01, 7.984716175785987e-01, 8.026272666259650e-01, + 8.067448794553850e-01, 8.108234502597368e-01, 8.148620118938579e-01, 8.188596363619152e-01, 8.228154352520715e-01, + 8.267285601182841e-01, 8.305982028090957e-01, 8.344235957432927e-01, 8.382040121323370e-01, 8.419387661495058e-01, + 8.456272130457134e-01, 8.492687492120119e-01, 8.528628121888369e-01, 8.564088806220885e-01, 8.599064741662098e-01, + 8.633551533344737e-01, 8.667545192967644e-01, 8.701042136252025e-01, 8.734039179880492e-01, 8.766533537923937e-01, + 8.798522817762424e-01, 8.830005015507004e-01, 8.860978510930465e-01, 8.891442061916122e-01, 8.921394798434883e-01, + 8.950836216061893e-01, 8.979766169045416e-01, 9.008184862941767e-01, 9.036092846831453e-01, 9.063491005132949e-01, + 9.090380549031886e-01, 9.116763007544754e-01, 9.142640218237603e-01, 9.168014317621422e-01, 9.192887731247262e-01, + 9.217263163525492e-01, 9.241143587294502e-01, 9.264532233165643e-01, 9.287432578672022e-01, 9.309848337249814e-01, + 9.331783447081556e-01, 9.353242059831766e-01, 9.374228529305666e-01, 9.394747400062335e-01, 9.414803396013999e-01, + 9.434401409043077e-01, 9.453546487668929e-01, 9.472243825795639e-01, 9.490498751572118e-01, 9.508316716394957e-01, + 9.525703284083868e-01, 9.542664120258422e-01, 9.559204981943715e-01, 9.575331707431241e-01, 9.591050206419620e-01, + 9.606366450458275e-01, 9.621286463715110e-01, 9.635816314087369e-01, 9.649962104672655e-01, 9.663729965614801e-01, + 9.677126046337026e-01, 9.690156508172226e-01, 9.702827517397986e-01, 9.715145238681151e-01, 9.727115828934468e-01, + 9.738745431585201e-01, 9.750040171253210e-01, 9.761006148833546e-01, 9.771649436976386e-01, 9.781976075954760e-01, + 9.791992069908698e-01, 9.801703383452239e-01, 9.811115938628175e-01, 9.820235612193683e-01, 9.829068233218750e-01, + 9.837619580977977e-01, 9.845895383115438e-01, 9.853901314061559e-01, 9.861642993680373e-01, 9.869125986125210e-01, + 9.876355798880896e-01, 9.883337881970466e-01, 9.890077627304957e-01, 9.896580368155167e-01, 9.902851378725152e-01, + 9.908895873808024e-01, 9.914719008505681e-01, 9.920325877995377e-01, 9.925721517327187e-01, 9.930910901238019e-01, + 9.935898943969245e-01, 9.940690499076552e-01, 9.945290359222332e-01, 9.949703255942541e-01, 9.953933859381526e-01, + 9.957986777990047e-01, 9.961866558183331e-01, 9.965577683957455e-01, 9.969124576463969e-01, 9.972511593543985e-01, + 9.975743029224325e-01, 9.978823113179629e-01, 9.981756010165178e-01, 9.984545819426528e-01, 9.987196574092618e-01, + 9.989712240559885e-01, 9.992096717875499e-01, 9.994353837128311e-01, 9.996487360856312e-01, 9.998500982479841e-01, + 1.000039832576952e+00, 1.000218294435816e+00, 1.000385832130536e+00, 1.000542786872366e+00, 1.000689492747415e+00, + 1.000826276693953e+00, 1.000953458488153e+00, 1.001071350738924e+00, 1.001180258892415e+00, 1.001280481246664e+00, + 1.001372308976828e+00, 1.001456026171296e+00, 1.001531909878933e+00, 1.001600230167594e+00, 1.001661250193955e+00, + 1.001715226284630e+00, 1.001762408028438e+00, 1.001803038379606e+00, 1.001837353771603e+00, 1.001865584241233e+00, + 1.001887953562516e+00, 1.001904679389828e+00, 1.001915973409726e+00, 1.001922041500763e+00, 1.001923083900631e+00, + 1.001919295379834e+00, 1.001910865421132e+00, 1.001897978403901e+00, 1.001880813792572e+00, 1.001859546328272e+00, + 1.001834346222781e+00, 1.001805379353926e+00, 1.001772807461511e+00, 1.001736788342922e+00, 1.001697476047539e+00, + 1.001655021069100e+00, 1.001609570535228e+00, 1.001561268393305e+00, 1.001510255591984e+00, 1.001456670257582e+00, + 1.001400647864737e+00, 1.001342321400680e+00, 1.001281821522569e+00, 1.001219276707368e+00, 1.001154813393807e+00, + 1.001088556116027e+00, 1.001020627628542e+00, 1.000951149022254e+00, 1.000880239831253e+00, 1.000808018130249e+00, + 1.000734600622500e+00, 1.000660102718162e+00, 1.000584638603047e+00, 1.000508321297830e+00, 1.000431262707766e+00, + 1.000353573663063e+00, 1.000275363950073e+00, 1.000196742333506e+00, 1.000117816569928e+00, 1.000038693412811e+00, + 9.999594786094657e-01, 9.998802768901784e-01, 9.998011919499361e-01, 9.997223264231200e-01, 9.996437818515729e-01, + 9.995656586464663e-01, 9.994880560443949e-01, 9.994110720581462e-01, 9.993348034225887e-01, 9.992593455361456e-01, + 9.991847923983630e-01, 9.991112365446738e-01, 9.990387692132843e-01, 9.989674755310745e-01, 9.988974493950561e-01, + 9.988287760995599e-01, 9.987615392519850e-01, 9.986958206712464e-01, 9.986317002885794e-01, 9.985692560508309e-01, + 9.985085638263473e-01, 9.984496973135677e-01, 9.983927279524338e-01, 9.983377248387103e-01, 9.982847546413267e-01, + 9.982338815228151e-01, 9.981851670629547e-01, 9.981386701856864e-01, 9.980944470893998e-01, 9.980525511806362e-01, + 9.980130330113137e-01, 9.979759402195160e-01, 9.979413174739102e-01, 9.979092064218532e-01, 9.978796456412409e-01, + 9.978526705961338e-01, 9.978283135962164e-01, 9.978066037601111e-01, 9.977875669825975e-01, 9.977712259057413e-01, + 9.977575998939762e-01, 9.977467050131418e-01, 9.977385540135004e-01, 9.977331563167335e-01, 9.977305180069234e-01, + 9.977306418255271e-01, 9.977335271703227e-01, 9.977391700983312e-01, 9.977475633326937e-01, 9.977586962734870e-01, + 9.977725550124530e-01, 9.977891223516203e-01, 9.978083778257809e-01, 9.978302977287913e-01, 9.978548551436590e-01, + 9.978820199763681e-01, 9.979117589934062e-01, 9.979440358629286e-01, 9.979788111995230e-01, 9.980160426125044e-01, + 9.980556847576850e-01, 9.980976893925572e-01, 9.981420054348167e-01, 9.981885790241626e-01, 9.982373535872919e-01, + 9.982882699060266e-01, 9.983412661884745e-01, 9.983962781431597e-01, 9.984532390560278e-01, 9.985120798702389e-01, + 9.985727292686638e-01, 9.986351137589832e-01, 9.986991577612992e-01, 9.987647836981626e-01, 9.988319120869124e-01, + 9.989004616342260e-01, 9.989703493327806e-01, 9.990414905599119e-01, 9.991137991781697e-01, 9.991871876376540e-01, + 9.992615670800187e-01, 9.993368474440421e-01, 9.994129375726286e-01, 9.994897453211379e-01, 9.995671776669227e-01, + 9.996451408199485e-01, 9.997235403343790e-01, 9.998022812210010e-01, 9.998812680603694e-01, 9.999604051165407e-01, + 1.000039596451276e+00, 1.000118746038578e+00, 1.000197757879446e+00, 1.000276536116704e+00, 1.000354985149791e+00, + 1.000433009749368e+00, 1.000510515171617e+00, 1.000587407272111e+00, 1.000663592619100e+00, 1.000738978606112e+00, + 1.000813473563716e+00, 1.000886986870324e+00, 1.000959429061901e+00, 1.001030711940457e+00, 1.001100748681180e+00, + 1.001169453938098e+00, 1.001236743948124e+00, 1.001302536633371e+00, 1.001366751701609e+00, 1.001429310744728e+00, + 1.001490137335098e+00, 1.001549157119701e+00, 1.001606297911910e+00, 1.001661489780803e+00, 1.001714665137891e+00, + 1.001765758821160e+00, 1.001814708176293e+00, 1.001861453134992e+00, 1.001905936290265e+00, 1.001948102968611e+00, + 1.001987901298963e+00, 1.002025282278336e+00, 1.002060199834045e+00, 1.002092610882449e+00, 1.002122475384096e+00, + 1.002149756395215e+00, 1.002174420115472e+00, 1.002196435931912e+00, 1.002215776459027e+00, 1.002232417574884e+00, + 1.002246338453259e+00, 1.002257521591717e+00, 1.002265952835595e+00, 1.002271621397855e+00, 1.002274519874744e+00, + 1.002274644257259e+00, 1.002271993938374e+00, 1.002266571716010e+00, 1.002258383791734e+00, 1.002247439765192e+00, + 1.002233752624241e+00, 1.002217338730821e+00, 1.002198217802551e+00, 1.002176412890066e+00, 1.002151950350129e+00, + 1.002124859814529e+00, 1.002095174154815e+00, 1.002062929442886e+00, 1.002028164907501e+00, 1.001990922886739e+00, + 1.001951248776490e+00, 1.001909190975020e+00, 1.001864800823684e+00, 1.001818132543870e+00, 1.001769243170239e+00, + 1.001718192480350e+00, 1.001665042920779e+00, 1.001609859529789e+00, 1.001552709856694e+00, 1.001493663877992e+00, + 1.001432793910387e+00, 1.001370174520822e+00, 1.001305882433629e+00, 1.001239996434927e+00, 1.001172597274394e+00, + 1.001103767564540e+00, 1.001033591677623e+00, 1.000962155640339e+00, 1.000889547026422e+00, 1.000815854847318e+00, + 1.000741169441052e+00, 1.000665582359457e+00, 1.000589186253905e+00, 1.000512074759701e+00, 1.000434342379282e+00, + 1.000356084364390e+00, 1.000277396597363e+00, 1.000198375471716e+00, 1.000119117772151e+00, 1.000039720554179e+00, + 9.999602810234808e-01, 9.998808964152024e-01, 9.998016638733073e-01, 9.997226803301702e-01, 9.996440423865509e-01, + 9.995658461921156e-01, 9.994881873266507e-01, 9.994111606821270e-01, 9.993348603457636e-01, 9.992593794842417e-01, + 9.991848102292076e-01, 9.991112435642227e-01, 9.990387692132843e-01, 9.989674755310747e-01, 9.988974493950561e-01, + 9.988287760995599e-01, 9.987615392519850e-01, 9.986958206712466e-01, 9.986317002885796e-01, 9.985692560508309e-01, + 9.985085638263473e-01, 9.984496973135679e-01, 9.983927279524338e-01, 9.983377248387103e-01, 9.982847546413269e-01, + 9.982338815228151e-01, 9.981851670629547e-01, 9.981386701856864e-01, 9.980944470893998e-01, 9.980525511806362e-01, + 9.980130330113137e-01, 9.979759402195162e-01, 9.979413174739102e-01, 9.979092064218532e-01, 9.978796456412409e-01, + 9.978526705961338e-01, 9.978283135962164e-01, 9.978066037601111e-01, 9.977875669825975e-01, 9.977712259057413e-01, + 9.977575998939762e-01, 9.977467050131418e-01, 9.977385540135004e-01, 9.977331563167335e-01, 9.977305180069234e-01, + 9.977306418255271e-01, 9.977335271703227e-01, 9.977391700983312e-01, 9.977475633326937e-01, 9.977586962734870e-01, + 9.977725550124529e-01, 9.977891223516203e-01, 9.978083778257809e-01, 9.978302977287912e-01, 9.978548551436589e-01, + 9.978820199763679e-01, 9.979117589934061e-01, 9.979440358629285e-01, 9.979788111995229e-01, 9.980160426125043e-01, + 9.980556847576849e-01, 9.980976893925571e-01, 9.981420054348165e-01, 9.981885790241625e-01, 9.982373535872917e-01, + 9.982882699060264e-01, 9.983412661884743e-01, 9.983962781431595e-01, 9.984532390560276e-01, 9.985120798702387e-01, + 9.985727292686636e-01, 9.986351137589830e-01, 9.986991577612990e-01, 9.987647836981624e-01, 9.988319120869121e-01, + 9.989004616342257e-01, 9.989703493327803e-01, 9.990414905599115e-01, 9.991137991781693e-01, 9.991871876376537e-01, + 9.992615670800183e-01, 9.993368474440417e-01, 9.994129375726283e-01, 9.994897453211377e-01, 9.995671776669224e-01, + 9.996451408199482e-01, 9.997235403343787e-01, 9.998022812210007e-01, 9.998812680603690e-01, 9.999604051165404e-01, + 1.000039596451276e+00, 1.000118746038578e+00, 1.000197757879445e+00, 1.000276536116703e+00, 1.000354985149791e+00, + 1.000433009749367e+00, 1.000510515171617e+00, 1.000587407272111e+00, 1.000663592619099e+00, 1.000738978606111e+00, + 1.000813473563715e+00, 1.000886986870324e+00, 1.000959429061901e+00, 1.001030711940456e+00, 1.001100748681180e+00, + 1.001169453938098e+00, 1.001236743948123e+00, 1.001302536633371e+00, 1.001366751701609e+00, 1.001429310744728e+00, + 1.001490137335098e+00, 1.001549157119701e+00, 1.001606297911910e+00, 1.001661489780802e+00, 1.001714665137891e+00, + 1.001765758821160e+00, 1.001814708176293e+00, 1.001861453134991e+00, 1.001905936290265e+00, 1.001948102968610e+00, + 1.001987901298963e+00, 1.002025282278336e+00, 1.002060199834045e+00, 1.002092610882449e+00, 1.002122475384096e+00, + 1.002149756395215e+00, 1.002174420115472e+00, 1.002196435931912e+00, 1.002215776459027e+00, 1.002232417574884e+00, + 1.002246338453259e+00, 1.002257521591717e+00, 1.002265952835595e+00, 1.002271621397855e+00, 1.002274519874744e+00, + 1.002274644257259e+00, 1.002271993938374e+00, 1.002266571716010e+00, 1.002258383791734e+00, 1.002247439765192e+00, + 1.002233752624241e+00, 1.002217338730821e+00, 1.002198217802551e+00, 1.002176412890066e+00, 1.002151950350129e+00, + 1.002124859814529e+00, 1.002095174154815e+00, 1.002062929442886e+00, 1.002028164907501e+00, 1.001990922886739e+00, + 1.001951248776490e+00, 1.001909190975020e+00, 1.001864800823684e+00, 1.001818132543870e+00, 1.001769243170239e+00, + 1.001718192480350e+00, 1.001665042920779e+00, 1.001609859529789e+00, 1.001552709856694e+00, 1.001493663877992e+00, + 1.001432793910387e+00, 1.001370174520822e+00, 1.001305882433629e+00, 1.001239996434927e+00, 1.001172597274394e+00, + 1.001103767564540e+00, 1.001033591677624e+00, 1.000962155640339e+00, 1.000889539994377e+00, 1.000815836987349e+00, + 1.000741135442554e+00, 1.000665525360320e+00, 1.000589097525086e+00, 1.000511943342175e+00, 1.000434154669159e+00, + 1.000355823641039e+00, 1.000277042489024e+00, 1.000197903352750e+00, 1.000118498085805e+00, 1.000038918054429e+00, + 9.999592539292592e-01, 9.998795954700279e-01, 9.998000313030908e-01, 9.997206486917303e-01, 9.996415332991556e-01, + 9.995627689441696e-01, 9.994844373494816e-01, 9.994066178826749e-01, 9.993293872898719e-01, 9.992528194221602e-01, + 9.991769849548788e-01, 9.991019510999088e-01, 9.990277813111228e-01, 9.989545349832153e-01, 9.988822671441485e-01, + 9.988110281415057e-01, 9.987408633230653e-01, 9.986718127119733e-01, 9.986039106768975e-01, 9.985371855976206e-01, + 9.984716595265433e-01, 9.984073478466060e-01, 9.983442589261942e-01, 9.982823937715852e-01, 9.982217456775688e-01, + 9.981622998768528e-01, 9.981040331889378e-01, 9.980469136691089e-01, 9.979909002582600e-01, 9.979359424342189e-01, + 9.978819798653003e-01, 9.978289420667763e-01, 9.977767480609429e-01, 9.977253060414770e-01, 9.976745130427335e-01, + 9.976242546146024e-01, 9.975744045035392e-01, 9.975248243403034e-01, 9.974753633349420e-01, 9.974258579794437e-01, + 9.973761317584910e-01, 9.973259948686257e-01, 9.972752439461025e-01, 9.972236618036201e-01, 9.971710171760355e-01, + 9.971170644751025e-01, 9.970615435531658e-01, 9.970041794756773e-01, 9.969446823022998e-01, 9.968827468762742e-01, + 9.968180526216487e-01, 9.967502633478675e-01, 9.966790270611490e-01, 9.966039757819899e-01, 9.965247253680732e-01, + 9.964408753417748e-01, 9.963520087214246e-01, 9.962576918554058e-01, 9.961574742581648e-01, 9.960508884471466e-01, + 9.959374497796830e-01, 9.958166562888472e-01, 9.956879885173003e-01, 9.955509093482032e-01, 9.954048638322855e-01, + 9.952492790102677e-01, 9.950835637298708e-01, 9.949071084567831e-01, 9.947192850790569e-01, 9.945194467045426e-01, + 9.943069274511299e-01, 9.940810422297355e-01, 9.938410865201561e-01, 9.935863361401250e-01, 9.933160470081145e-01, + 9.930294549006624e-01, 9.927257752052461e-01, 9.924042026699723e-01, 9.920639111516145e-01, 9.917040533637881e-01, + 9.913237606273204e-01, 9.909221426251413e-01, 9.904982871642726e-01, 9.900512599477517e-01, 9.895801043595820e-01, + 9.890838412660165e-01, 9.885614688367104e-01, 9.880119623894829e-01, 9.874342742625883e-01, 9.868273337185698e-01, + 9.861900468838825e-01, 9.855212967285775e-01, 9.848199430904010e-01, 9.840848227476926e-01, 9.833147495454723e-01, + 9.825085145790535e-01, 9.816648864394526e-01, 9.807826115247470e-01, 9.798604144213754e-01, 9.788969983591844e-01, + 9.778910457438047e-01, 9.768412187696544e-01, 9.757461601165864e-01, 9.746044937328510e-01, 9.734148257066850e-01, + 9.721757452284399e-01, 9.708858256447525e-01, 9.695436256058197e-01, 9.681476903063706e-01, 9.666965528204767e-01, + 9.651887355298391e-01, 9.636227516447159e-01, 9.619971068161570e-01, 9.603103008377231e-01, 9.585608294343847e-01, + 9.567471861358257e-01, 9.548678642309127e-01, 9.529213587996556e-01, 9.509061688185575e-01, 9.488207993348687e-01, + 9.466637637048801e-01, 9.444335858910574e-01, 9.421288028125191e-01, 9.397479667430725e-01, 9.372896477508165e-01, + 9.347524361730808e-01, 9.321349451203507e-01, 9.294358130026688e-01, 9.266537060719486e-01, 9.237873209735582e-01, + 9.208353873005455e-01, 9.177966701438771e-01, 9.146699726321402e-01, 9.114541384542267e-01, 9.081480543586499e-01, + 9.047506526232865e-01, 9.012609134895138e-01, 8.976778675548984e-01, 8.940005981188177e-01, 8.902282434756291e-01, + 8.863599991502473e-01, 8.823951200712559e-01, 8.783329226769567e-01, 8.741727869500308e-01, 8.699141583767795e-01, + 8.655565498272043e-01, 8.610995433524644e-01, 8.565427918965455e-01, 8.518860209192624e-01, 8.471290299279841e-01, + 8.422716939157602e-01, 8.373139647037767e-01, 8.322558721863335e-01, 8.270975254767841e-01, 8.218391139531005e-01, + 8.164809082019563e-01, 8.110232608604324e-01, 8.054666073546400e-01, 7.998114665347398e-01, 7.940584412060114e-01, + 7.882082185557775e-01, 7.822615704761332e-01, 7.762193537825687e-01, 7.700825103286711e-01, 7.638520670172276e-01, + 7.575291357081170e-01, 7.511149130234813e-01, 7.446106800507299e-01, 7.380178019439980e-01, 7.313377274247339e-01, + 7.245719881821328e-01, 7.177221981741801e-01, 7.107900528300912e-01, 7.037773281549656e-01, 6.966858797374927e-01, + 6.895176416615646e-01, 6.822746253226608e-01, 6.749589181498854e-01, 6.675726822345424e-01, 6.601181528661474e-01, + 6.525976369767750e-01, 6.450135114946609e-01, 6.373682216079785e-01, 6.296642789397278e-01, 6.219042596346939e-01, + 6.140908023594462e-01, 6.062266062163840e-01, 5.983144285728536e-01, 5.903570828064187e-01, 5.823574359673894e-01, + 5.743184063597853e-01, 5.662429610419641e-01, 5.581341132482169e-01, 5.499949197327134e-01, 5.418284780372742e-01, + 5.336379236845493e-01, 5.254264272982935e-01, 5.171971916525543e-01, 5.089534486517354e-01, 5.006984562436330e-01, + 4.924354952677195e-01, 4.841678662411154e-01, 4.758988860848792e-01, 4.676318847934465e-01, 4.593702020502552e-01, + 4.511171837928217e-01, 4.428761787307617e-01, 4.346505348204885e-01, 4.264435957005810e-01, 4.182586970920628e-01, + 4.100991631681045e-01, 4.019683028979270e-01, 3.938694063699639e-01, 3.858057410996029e-01, 3.777805483271167e-01, + 3.697970393116528e-01, 3.618583916274267e-01, 3.539677454685226e-01, 3.461281999689568e-01, 3.383428095449016e-01, + 3.306145802661934e-01, 3.229464662644602e-01, 3.153413661853912e-01, 3.078021196928487e-01, 3.003315040326600e-01, + 2.929322306640503e-01, 2.856069419667691e-01, 2.783582080320176e-01, 2.711885235453130e-01, 2.641003047694161e-01, + 2.570958866354019e-01, 2.501775199498664e-01, 2.433473687261406e-01, 2.366075076472159e-01, 2.299599196678819e-01, + 2.234064937633224e-01, 2.169490228311333e-01, 2.105892017533920e-01, 2.043286256250337e-01, 1.981687881543829e-01, + 1.921110802412354e-01, 1.861567887374030e-01, 1.803070953941089e-01, 1.745630760000725e-01, 1.689256997135387e-01, + 1.633958285908989e-01, 1.579742173139196e-01, 1.526615131169428e-01, 1.474582559147575e-01, 1.423648786311610e-01, + 1.373817077275422e-01, 1.325089639301291e-01, 1.277467631538520e-01, 1.230951176200877e-01, 1.185539371648735e-01, + 1.141230307335134e-01, 1.098021080568559e-01, 1.055907815038885e-01, 1.014885681047006e-01, 9.749489173728383e-02, + 9.360908547110176e-02, 8.983039405984916e-02, 8.615797657535108e-02, 8.259090917411954e-02, 7.912818798769637e-02, + 7.576873212756439e-02, 7.251138679510837e-02, 6.935492648685226e-02, 6.629805828499362e-02, 6.333942522309385e-02, + 6.047760971667378e-02, 5.771113704839873e-02, 5.503847889751997e-02, 5.245805690326935e-02, 4.996824625197753e-02, + 4.756737927780486e-02, 4.525374906713279e-02, 4.302561305686507e-02, 4.088119661712488e-02, 3.881869660910822e-02, + 3.683628490916042e-02, 3.493211189048053e-02, 3.310430985422298e-02, 3.135099640215624e-02, 2.967027774345144e-02, + 2.806025192860465e-02, 2.651901200394490e-02, 2.504464908064207e-02, 2.363525531259980e-02, 2.228892677809941e-02, + 2.100376626054477e-02, 1.977788592414561e-02, 1.860940988086348e-02, 1.749647664542867e-02, 1.643724147571549e-02, + 1.542987859623567e-02, 1.447258330297169e-02, 1.356357394822445e-02, 1.270109380458789e-02, 1.188341280758823e-02, + 1.110882917693435e-02, 1.037567091671765e-02, 9.682297195274189e-03, 9.027099605776615e-03, 8.408503308959755e-03, + 7.824968059698375e-03, 7.274989119451309e-03, 6.757098056859764e-03, 6.269863439040749e-03, 5.811891416348594e-03, + 5.381826203588412e-03, 4.978350460855568e-03, 4.600185577345007e-03, 4.246091861623697e-03, 3.914868641989499e-03, + 3.605354280650456e-03, 3.316426105550754e-03, 3.047000263743920e-03, 2.796031500270941e-03, 2.562512866541615e-03, + 2.345475362242355e-03, 2.143987514803593e-03, 1.957154900455791e-03, 1.784119610885449e-03, 1.624059669472490e-03, + 1.476188401048562e-03, 1.339753759063066e-03, 1.214037613980937e-03, 1.098355006663937e-03, 9.920533704065749e-04, + 8.945117252091245e-04, 8.051398477746440e-04, 7.233774206148687e-04, 6.486931635421752e-04, 5.805839507121312e-04, + 5.185739162640836e-04, 4.622135514864277e-04, 4.110787963092279e-04, 3.647701278002823e-04, 3.229116482121258e-04, + 2.851501749972799e-04, 2.511543350778764e-04, 2.206136655240024e-04, 1.932377226631928e-04, 1.687552015118974e-04, + 1.469130672888079e-04, 1.274757006400757e-04, 1.102240580780130e-04, 9.495484900818888e-05, 8.147973059522124e-05, + 6.962452159532738e-05, 5.922843616409273e-05, 5.014333853121625e-05, 4.223301932042882e-05, 3.537249418257647e-05, + 2.944732530322636e-05, 2.435296624327736e-05, 1.999413047212912e-05, 1.628418385815330e-05, 1.314456129070047e-05, + 1.050420752185282e-05, 8.299042234809909e-06, 6.471449269445341e-06, 4.969789864549787e-06, 3.747939711067031e-06, + 2.764849551822885e-06, 1.984129011158285e-06, 1.373653290393152e-06, 9.051923062411747e-07, 5.540616821452014e-07, + 2.987940262820261e-07, 1.208186781658135e-07, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00 +}; + +const LC3_FLOAT MDCT_WINDOW_80_7_5ms[120] = {0.00295060859318731, + 0.00717541131643851, + 0.0137695373537175, + 0.0230953556487727, + 0.0354036229832600, + 0.0508289303571015, + 0.0694696292595147, + 0.0913884277813343, + 0.116604574829623, + 0.145073545983920, + 0.176711174053461, + 0.211342952955480, + 0.248768614459915, + 0.288701101746986, + 0.330823871149994, + 0.374814544406725, + 0.420308013047231, + 0.466904917964874, + 0.514185341357833, + 0.561710040666941, + 0.609026346152434, + 0.655671016213410, + 0.701218384229819, + 0.745240678762236, + 0.787369206048433, + 0.827223833436804, + 0.864513675018828, + 0.898977414612621, + 0.930407517984552, + 0.958599937397485, + 0.983447719378423, + 1.00488283328902, + 1.02285380727854, + 1.03740494796704, + 1.04859791420260, + 1.05656184342744, + 1.06149370624356, + 1.06362578371698, + 1.06325972797388, + 1.06074504835117, + 1.05643589789450, + 1.05069500101126, + 1.04392434506884, + 1.03647724602858, + 1.02872867366600, + 1.02106485991803, + 1.01400658226217, + 1.00727455010293, + 1.00172249743714, + 0.997309591666583, + 0.993985158260167, + 0.991683334808959, + 0.990325325024913, + 0.989822612537615, + 0.990074733989367, + 0.990975314368959, + 0.992412851225652, + 0.994273149357862, + 0.996439157431590, + 0.998791615753409, + 1.00120984620569, + 1.00357356747961, + 1.00575983636472, + 1.00764515369282, + 1.00910687229055, + 1.01002476446464, + 1.01028203168272, + 1.00976918870054, + 1.00838641217324, + 1.00605123898466, + 1.00269766615693, + 0.998280464458421, + 0.992777986793980, + 0.986186892168957, + 0.977634164392255, + 0.967447269570116, + 0.955129725416117, + 0.940389877411592, + 0.922959279964298, + 0.902607349937268, + 0.879202688562948, + 0.852641749726566, + 0.822881271616311, + 0.789971715171577, + 0.754030327670636, + 0.715255741732847, + 0.673936911240907, + 0.630414716229245, + 0.585078857908467, + 0.538398518296620, + 0.490833753173281, + 0.442885823257372, + 0.395091024053755, + 0.348004343198510, + 0.302196710240947, + 0.258227430580528, + 0.216641416438901, + 0.177922121520115, + 0.142480547128767, + 0.110652194335372, + 0.0826995966952829, + 0.0588334516201313, + 0.0392030848454565, + 0.0238629107447942, + 0.0126976223424625, + 0.00535665361021599, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0}; + +const LC3_FLOAT MDCT_WINDOW_160_7_5ms[240] = {0.00220824874304665, + 0.00381014419509035, + 0.00591552473428981, + 0.00858361456803004, + 0.0118759722608345, + 0.0158335301409709, + 0.0204918651551601, + 0.0258883592892154, + 0.0320415894481754, + 0.0389616721239547, + 0.0466742169139349, + 0.0551849337276135, + 0.0645038384438376, + 0.0746411071480673, + 0.0856000161887899, + 0.0973846702504817, + 0.109993602538973, + 0.123419277472281, + 0.137655456547628, + 0.152690437463956, + 0.168513362640497, + 0.185093104613143, + 0.202410419487986, + 0.220450365133188, + 0.239167940620308, + 0.258526168288333, + 0.278498538773636, + 0.299038431599591, + 0.320104862365552, + 0.341658622243036, + 0.363660034025212, + 0.386062695189504, + 0.408815272459443, + 0.431871045845866, + 0.455176987704814, + 0.478676592635263, + 0.502324813138104, + 0.526060916224847, + 0.549831282885023, + 0.573576882777006, + 0.597241338441034, + 0.620770242419397, + 0.644099662433612, + 0.667176381676395, + 0.689958853765865, + 0.712379980093130, + 0.734396371869479, + 0.755966688050532, + 0.777036981101517, + 0.797558113689794, + 0.817490855531114, + 0.836796949640853, + 0.855447309567916, + 0.873400798399116, + 0.890635718969808, + 0.907128770123878, + 0.922848783570288, + 0.937763322534182, + 0.951860206252747, + 0.965130600153629, + 0.977556540546725, + 0.989126208677996, + 0.999846919168316, + 1.00970072970387, + 1.01868228690835, + 1.02681455085919, + 1.03408981275172, + 1.04051195662940, + 1.04610836852236, + 1.05088564953428, + 1.05486288757866, + 1.05807220584955, + 1.06053413867011, + 1.06227661751764, + 1.06333815026019, + 1.06375556676696, + 1.06356632061806, + 1.06282155753012, + 1.06155995891758, + 1.05981709158148, + 1.05765876038451, + 1.05512005736540, + 1.05223985071955, + 1.04908778571338, + 1.04569859514623, + 1.04210830682439, + 1.03838098558867, + 1.03455276253936, + 1.03067199718128, + 1.02679166694268, + 1.02295558402234, + 1.01920733213785, + 1.01587288719722, + 1.01221017459353, + 1.00884559103696, + 1.00577851248622, + 1.00300261849896, + 1.00051460180915, + 0.998309228756053, + 0.996378601374572, + 0.994718132279737, + 0.993316215711850, + 0.992166956964939, + 0.991258602708851, + 0.990581103872326, + 0.990123118186375, + 0.989873711994700, + 0.989818706664725, + 0.989946800178719, + 0.990243175367708, + 0.990695563551443, + 0.991288540103593, + 0.992009469063567, + 0.992842692750141, + 0.993775066630664, + 0.994790397982872, + 0.995875533622126, + 0.997014367015673, + 0.998192870684212, + 0.999394506476233, + 1.00060586036830, + 1.00181040094441, + 1.00299457368229, + 1.00414154805357, + 1.00523688409909, + 1.00626392589064, + 1.00720890358777, + 1.00805489381465, + 1.00878801634839, + 1.00939182206005, + 1.00985295821773, + 1.01015529301117, + 1.01028601830489, + 1.01022987870331, + 1.00997540773688, + 1.00950845528029, + 1.00881848315592, + 1.00789488400120, + 1.00672875785417, + 1.00530991398353, + 1.00363456081898, + 1.00169363479295, + 0.999485662869670, + 0.997006370229165, + 0.994254686877395, + 0.991231967393677, + 0.987937115334337, + 0.984375124686103, + 0.979890963312768, + 0.975269878842859, + 0.970180498004025, + 0.964580026820328, + 0.958425533515528, + 0.951684013845583, + 0.944320232231505, + 0.936290624169877, + 0.927580506944232, + 0.918153413723035, + 0.907976524013806, + 0.897050058479312, + 0.885351360384818, + 0.872857926504400, + 0.859579818650462, + 0.845502615038655, + 0.830619943301480, + 0.814946648157534, + 0.798489377529441, + 0.781262449660145, + 0.763291769255088, + 0.744590843420388, + 0.725199287080917, + 0.705153668360855, + 0.684490544603819, + 0.663245209931378, + 0.641477161661819, + 0.619235333635541, + 0.596559132542786, + 0.573519989364814, + 0.550173851023454, + 0.526568538230013, + 0.502781158663802, + 0.478860889056198, + 0.454877894349081, + 0.430898122898976, + 0.406993964205627, + 0.383234030582781, + 0.359680098334456, + 0.336408100091304, + 0.313496418152647, + 0.291010565493871, + 0.269019585108746, + 0.247584347561867, + 0.226788433385199, + 0.206677770653849, + 0.187310343238419, + 0.168739644125069, + 0.151012382058898, + 0.134171842279709, + 0.118254662325635, + 0.103290733977460, + 0.0893117360272552, + 0.0763429786604178, + 0.0644077291458590, + 0.0535243714739393, + 0.0437084452819923, + 0.0349667099153409, + 0.0272984629264830, + 0.0206895808034878, + 0.0151125125235276, + 0.0105228753811890, + 0.00685547314312078, + 0.00402351119094097, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0}; + +const LC3_FLOAT MDCT_WINDOW_240_7_5ms[360] = {0.00197084907651299, + 0.00295060859318731, + 0.00412447721346795, + 0.00552688663943736, + 0.00717541131643851, + 0.00908757730429167, + 0.0112819105170366, + 0.0137695373537175, + 0.0165600266160529, + 0.0196650894549232, + 0.0230953556487727, + 0.0268612893898298, + 0.0309632559743172, + 0.0354036229832600, + 0.0401915610110090, + 0.0453331403333732, + 0.0508289303571015, + 0.0566815447853484, + 0.0628935304464015, + 0.0694696292595147, + 0.0764106313680933, + 0.0837160015651998, + 0.0913884277813343, + 0.0994294007679240, + 0.107834724972307, + 0.116604574829623, + 0.125736502786435, + 0.135226811339595, + 0.145073545983920, + 0.155273818664872, + 0.165822194234144, + 0.176711174053461, + 0.187928775884881, + 0.199473179818881, + 0.211342952955480, + 0.223524554031808, + 0.236003099651800, + 0.248768614459915, + 0.261813810748989, + 0.275129160854431, + 0.288701101746986, + 0.302514033630995, + 0.316558805236645, + 0.330823871149994, + 0.345295566673095, + 0.359963991566213, + 0.374814544406725, + 0.389831816553239, + 0.405001009601585, + 0.420308013047231, + 0.435739515285996, + 0.451277817354750, + 0.466904917964874, + 0.482609040567348, + 0.498375466266412, + 0.514185341357833, + 0.530021478313683, + 0.545869351788699, + 0.561710040666941, + 0.577528151441720, + 0.593304696426258, + 0.609026346152434, + 0.624674188938691, + 0.640227554714632, + 0.655671016213410, + 0.670995934643907, + 0.686184558797250, + 0.701218384229819, + 0.716078448562218, + 0.730756084155059, + 0.745240678762236, + 0.759515121573879, + 0.773561955408612, + 0.787369206048433, + 0.800923137730798, + 0.814211386313193, + 0.827223833436804, + 0.839952374193807, + 0.852386102361013, + 0.864513675018828, + 0.876324078835538, + 0.887814288392476, + 0.898977414612621, + 0.909803318928109, + 0.920284311925309, + 0.930407517984552, + 0.940169652216635, + 0.949567794930265, + 0.958599937397485, + 0.967260260011783, + 0.975545165941725, + 0.983447719378423, + 0.990971957260661, + 0.998119268644039, + 1.00488283328902, + 1.01125773114014, + 1.01724436218938, + 1.02285380727854, + 1.02808733870912, + 1.03293706325880, + 1.03740494796704, + 1.04150164119898, + 1.04523235573095, + 1.04859791420260, + 1.05160339500287, + 1.05425505026848, + 1.05656184342744, + 1.05853400282251, + 1.06017413540787, + 1.06149370624356, + 1.06249943033024, + 1.06320577147234, + 1.06362578371698, + 1.06376486534444, + 1.06363777833448, + 1.06325972797388, + 1.06264695324506, + 1.06180496269951, + 1.06074504835117, + 1.05948491573959, + 1.05804533277758, + 1.05643589789450, + 1.05466217871738, + 1.05274047445925, + 1.05069500101126, + 1.04853893535431, + 1.04627898264892, + 1.04392434506884, + 1.04149539738413, + 1.03901002688052, + 1.03647724602858, + 1.03390792836167, + 1.03131989375422, + 1.02872867366600, + 1.02614831936266, + 1.02358988084027, + 1.02106485991803, + 1.01856261937655, + 1.01655770337597, + 1.01400658226217, + 1.01162952586308, + 1.00938590180064, + 1.00727455010293, + 1.00529616458224, + 1.00344525988730, + 1.00172249743714, + 1.00012792446354, + 0.998657533466906, + 0.997309591666583, + 0.996083571092922, + 0.994976568981429, + 0.993985158260167, + 0.993107530052222, + 0.992341305231054, + 0.991683334808959, + 0.991130069631426, + 0.990678325164172, + 0.990325325024913, + 0.990067562181601, + 0.989901281872290, + 0.989822612537615, + 0.989827845401607, + 0.989913241125937, + 0.990074733989367, + 0.990308255838731, + 0.990609851788114, + 0.990975314368959, + 0.991400330446183, + 0.991880966170107, + 0.992412851225652, + 0.992991779075812, + 0.993613381385812, + 0.994273149357862, + 0.994966957785808, + 0.995690370111366, + 0.996439157431590, + 0.997208572194836, + 0.997994274967679, + 0.998791615753409, + 0.999596061975986, + 1.00040410125588, + 1.00120984620569, + 1.00200975605034, + 1.00279924168624, + 1.00357356747961, + 1.00432828318722, + 1.00505850186763, + 1.00575983636472, + 1.00642766968907, + 1.00705768272393, + 1.00764515369282, + 1.00818549211731, + 1.00867426536962, + 1.00910687229055, + 1.00947915891906, + 1.00978659331994, + 1.01002476446464, + 1.01018953828983, + 1.01027669068480, + 1.01028203168272, + 1.01020174265116, + 1.01003208083751, + 1.00976918870054, + 1.00940938607321, + 1.00894931012624, + 1.00838641217324, + 1.00771780306692, + 1.00694030579691, + 1.00605123898466, + 1.00504879328336, + 1.00393182763047, + 1.00269766615693, + 1.00134427117215, + 0.999872091899038, + 0.998280464458421, + 0.996566569174198, + 0.994731737005642, + 0.992777986793980, + 0.990701374188107, + 0.988504165244528, + 0.986186892168957, + 0.983711988683984, + 0.980584643109501, + 0.977634164392255, + 0.974455033150736, + 0.971062915561309, + 0.967447269570116, + 0.963593926287407, + 0.959491398347322, + 0.955129725416117, + 0.950501325912076, + 0.945592810314402, + 0.940389877411592, + 0.934886760414132, + 0.929080558710635, + 0.922959279964298, + 0.916509579192867, + 0.909724456073370, + 0.902607349937268, + 0.895155083757719, + 0.887356154208250, + 0.879202688562948, + 0.870699697841629, + 0.861847424457935, + 0.852641749726566, + 0.843077833241503, + 0.833154904680532, + 0.822881271616311, + 0.812257596919709, + 0.801285439243471, + 0.789971715171577, + 0.778318177172464, + 0.766337710411639, + 0.754030327670636, + 0.741407990945757, + 0.728477500803539, + 0.715255741732847, + 0.701751739457159, + 0.687975631811811, + 0.673936911240907, + 0.659652573201310, + 0.645139489066839, + 0.630414716229245, + 0.615483621927165, + 0.600365851941398, + 0.585078857908467, + 0.569649536456405, + 0.554084809831234, + 0.538398518296620, + 0.522614737753751, + 0.506756804966295, + 0.490833753173273, + 0.474866032652527, + 0.458876565810813, + 0.442885823257372, + 0.426906539230033, + 0.410970973391487, + 0.395091024053754, + 0.379291327017083, + 0.363587416985863, + 0.348004343198509, + 0.332563200617546, + 0.317287484882341, + 0.302196710240947, + 0.287309402575471, + 0.272643991600386, + 0.258227430580528, + 0.244072856174013, + 0.230208977382347, + 0.216641416438901, + 0.203398480689705, + 0.190486161546394, + 0.177922121520115, + 0.165726674483589, + 0.153906396679985, + 0.142480547128767, + 0.131453980101158, + 0.120841778238095, + 0.110652194335372, + 0.100891734193622, + 0.0915718850864754, + 0.0826995966952829, + 0.0742815528886268, + 0.0663242381533172, + 0.0588334516201312, + 0.0518140676237795, + 0.0452698345565108, + 0.0392030848454564, + 0.0336144159421411, + 0.0285023308156286, + 0.0238629107447942, + 0.0196894226553178, + 0.0159720527024086, + 0.0126976223424625, + 0.00984937739446455, + 0.00740724463299836, + 0.00535665361021599, + 0.00383226551874691, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0}; + +const LC3_FLOAT MDCT_WINDOW_320_7_5ms[480] = {0.00184833037060189, + 0.00256481839443054, + 0.00336762117525576, + 0.00428736617294702, + 0.00533830142913148, + 0.00652679222980445, + 0.00786112587274496, + 0.00934628179329417, + 0.0109916867707302, + 0.0128011172432759, + 0.0147805910526259, + 0.0169307043075075, + 0.0192592307040902, + 0.0217696937210109, + 0.0244685982614465, + 0.0273556542738590, + 0.0304319230257638, + 0.0336980463900663, + 0.0371583577255157, + 0.0408148179520755, + 0.0446708068423474, + 0.0487262995262562, + 0.0529820632544155, + 0.0574382469666485, + 0.0620968579875224, + 0.0669609766608529, + 0.0720298363678982, + 0.0773039146477137, + 0.0827825574095362, + 0.0884682101593173, + 0.0943607566451845, + 0.100460272003600, + 0.106763823750452, + 0.113273679440610, + 0.119986420273010, + 0.126903520680586, + 0.134020853127777, + 0.141339556870128, + 0.148857211288972, + 0.156573685338126, + 0.164484622056357, + 0.172589076538143, + 0.180879089820471, + 0.189354319600685, + 0.198012243528402, + 0.206854140994642, + 0.215875318757054, + 0.225068672370813, + 0.234427407249969, + 0.243948313710515, + 0.253627992837806, + 0.263464060987933, + 0.273450494478137, + 0.283582188986510, + 0.293853469478657, + 0.304257373461563, + 0.314790914011331, + 0.325449123426950, + 0.336227409661803, + 0.347118760290707, + 0.358120176960450, + 0.369224663378337, + 0.380427792871280, + 0.391720022741618, + 0.403097022154837, + 0.414551955216869, + 0.426081718612424, + 0.437676318481682, + 0.449330195657235, + 0.461034855039307, + 0.472786043282829, + 0.484576777178737, + 0.496401706766520, + 0.508252457556495, + 0.520122078483965, + 0.532002077000542, + 0.543888089744156, + 0.555771601181136, + 0.567645738774683, + 0.579502786315012, + 0.591335034592786, + 0.603138367473440, + 0.614904171685981, + 0.626623941105601, + 0.638288834425202, + 0.649893374776772, + 0.661432360150173, + 0.672902513906348, + 0.684293749833449, + 0.695600459535883, + 0.706811783648976, + 0.717923424519233, + 0.728931385727289, + 0.739832772797360, + 0.750618982371933, + 0.761284053417755, + 0.771818918701624, + 0.782220991963992, + 0.792481330455120, + 0.802599447723046, + 0.812565229501908, + 0.822377128920089, + 0.832030518374920, + 0.841523207674513, + 0.850848312948314, + 0.860002411781952, + 0.868979880825105, + 0.877778346729487, + 0.886395903955835, + 0.894829420791081, + 0.903077625660289, + 0.911132652155618, + 0.918993585364937, + 0.926652936933657, + 0.934111420416517, + 0.941364344292899, + 0.948412967370989, + 0.955255629597394, + 0.961892013137868, + 0.968316362908677, + 0.974530156362119, + 0.980528338141726, + 0.986313927767294, + 0.991886048619893, + 0.997246344766401, + 1.00239189664458, + 1.00731946437583, + 1.01202707343585, + 1.01651654151239, + 1.02079430268870, + 1.02486081579449, + 1.02871470580975, + 1.03235170271917, + 1.03577375047282, + 1.03898431507401, + 1.04198785539891, + 1.04478564357336, + 1.04737818412200, + 1.04976743149521, + 1.05195404554314, + 1.05394289856216, + 1.05573463147380, + 1.05734176732398, + 1.05875726493872, + 1.05998674447371, + 1.06103671687069, + 1.06190651084450, + 1.06260369490638, + 1.06313289329257, + 1.06350237394105, + 1.06370980806189, + 1.06376322346189, + 1.06366764604617, + 1.06343011818702, + 1.06305656438567, + 1.06255421036890, + 1.06192234666436, + 1.06116701778323, + 1.06029468923457, + 1.05931468949374, + 1.05823464730377, + 1.05705890752753, + 1.05578948247366, + 1.05442978686656, + 1.05298792590271, + 1.05147505164534, + 1.04989930053323, + 1.04826212949578, + 1.04656690601558, + 1.04481699264239, + 1.04302124919620, + 1.04118768090749, + 1.03932339102548, + 1.03743168416508, + 1.03551757331127, + 1.03358510598971, + 1.03164370854303, + 1.02969954597728, + 1.02775943851786, + 1.02582718703711, + 1.02390791088663, + 1.02200805068553, + 1.02013910120702, + 1.01826310081338, + 1.01687901084998, + 1.01492194818759, + 1.01309662336946, + 1.01134205244082, + 1.00965912296053, + 1.00805036388672, + 1.00651754025099, + 1.00505799251731, + 1.00366956090429, + 1.00235327309256, + 1.00110980844711, + 0.999937523064020, + 0.998834523778354, + 0.997800605926859, + 0.996835755847371, + 0.995938881156864, + 0.995108458955550, + 0.994343411090332, + 0.993642921198198, + 0.993005832427090, + 0.992430983777039, + 0.991917492640328, + 0.991463898014730, + 0.991068213957297, + 0.990729218448801, + 0.990446224564421, + 0.990217818551850, + 0.990041963066712, + 0.989917085260000, + 0.989841974698949, + 0.989815048293785, + 0.989834329137160, + 0.989898210724722, + 0.990005403060575, + 0.990154189263867, + 0.990342426919530, + 0.990568458991084, + 0.990830952741348, + 0.991128037927190, + 0.991457565684290, + 0.991817880927468, + 0.992207558971979, + 0.992624757299280, + 0.993067358412365, + 0.993533398279548, + 0.994021410066004, + 0.994529685133772, + 0.995055963618118, + 0.995598350543474, + 0.996155580104219, + 0.996725626776922, + 0.997306092208332, + 0.997895213854288, + 0.998491440631921, + 0.999092889987779, + 0.999697062575683, + 1.00030302922321, + 1.00090793360789, + 1.00151083855774, + 1.00210922561456, + 1.00270118453373, + 1.00328512996467, + 1.00385925649825, + 1.00442110963133, + 1.00496860132761, + 1.00550040380694, + 1.00601454845283, + 1.00650869083178, + 1.00698103862634, + 1.00743004105679, + 1.00785364005500, + 1.00824961843285, + 1.00861603623935, + 1.00895137836214, + 1.00925389667459, + 1.00952134193584, + 1.00975175133162, + 1.00994371466878, + 1.01009549736651, + 1.01020487679019, + 1.01027007304515, + 1.01028975233683, + 1.01026226969627, + 1.01018561543197, + 1.01005819682879, + 1.00987881783672, + 1.00964593048934, + 1.00935753319733, + 1.00901228181564, + 1.00860959436079, + 1.00814836659263, + 1.00762674316571, + 1.00704343050616, + 1.00639774980144, + 1.00568876793126, + 1.00491558583432, + 1.00407767878127, + 1.00317428837606, + 1.00220424207009, + 1.00116683614142, + 1.00006248083959, + 0.998891421862267, + 0.997652251800105, + 0.996343855540476, + 0.994967462022130, + 0.993524663018428, + 0.992013926907702, + 0.990433283134003, + 0.988785147009912, + 0.987072680860489, + 0.985297442611976, + 0.983401161131380, + 0.980949417765551, + 0.978782729044635, + 0.976468238349044, + 0.974042850200711, + 0.971498848279787, + 0.968829967901758, + 0.966030973927894, + 0.963095103865114, + 0.960018197689881, + 0.956795738404679, + 0.953426266696235, + 0.949903482303963, + 0.946222115168414, + 0.942375819502639, + 0.938361701514345, + 0.934177797863119, + 0.929823123908876, + 0.925292319504672, + 0.920580120066111, + 0.915679792968200, + 0.910590604293827, + 0.905315030158709, + 0.899852756107195, + 0.894199497118493, + 0.888350152427933, + 0.882301631337498, + 0.876054874152525, + 0.869612384940706, + 0.862972799329697, + 0.856135197574920, + 0.849098178607312, + 0.841857024342112, + 0.834414055019111, + 0.826774616875239, + 0.818939244026861, + 0.810904891487294, + 0.802675318450619, + 0.794253750525830, + 0.785641661592052, + 0.776838608661742, + 0.767853193256071, + 0.758685180670574, + 0.749330657713362, + 0.739809171155050, + 0.730109944357775, + 0.720247780620101, + 0.710224160990164, + 0.700044325846151, + 0.689711889540493, + 0.679231154104663, + 0.668608178924739, + 0.657850996784250, + 0.646965718233652, + 0.635959616622744, + 0.624840335899161, + 0.613603502679100, + 0.602265090642188, + 0.590829083373282, + 0.579309407943056, + 0.567711124002091, + 0.556037415675143, + 0.544293664349262, + 0.532489768053648, + 0.520636084113626, + 0.508743272768040, + 0.496811166041365, + 0.484849880708936, + 0.472868107365031, + 0.460875918379489, + 0.448881080632702, + 0.436891038772751, + 0.424912022350783, + 0.412960603164169, + 0.401035896287704, + 0.389157866744938, + 0.377322198811674, + 0.365543766863001, + 0.353832356425067, + 0.342196115433984, + 0.330644820108683, + 0.319187558989871, + 0.307833309339190, + 0.296588181651645, + 0.285463716536022, + 0.274462408857763, + 0.263609584476890, + 0.252883101143323, + 0.242323488971182, + 0.231925746284170, + 0.221690837369583, + 0.211638057695031, + 0.201766920294530, + 0.192082235818342, + 0.182589160013263, + 0.173305996740759, + 0.164229200045030, + 0.155362654247925, + 0.146717078597741, + 0.138299391415146, + 0.130105078076731, + 0.122145309929155, + 0.114423458192169, + 0.106941075992303, + 0.0997025893446062, + 0.0927124283374869, + 0.0859737427062027, + 0.0794893311195214, + 0.0732616579460535, + 0.0672934102310889, + 0.0615874081007633, + 0.0561458002593222, + 0.0509700747035652, + 0.0460617047145777, + 0.0414220116926541, + 0.0370514188750623, + 0.0329494666227939, + 0.0291153326941312, + 0.0255476401323823, + 0.0222437711282860, + 0.0192000658979791, + 0.0164122204526698, + 0.0138747611120131, + 0.0115806352990988, + 0.00952213664221592, + 0.00769137379581469, + 0.00607207833119310, + 0.00462581216874268, + 0.00360685164162597, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0}; + +const LC3_FLOAT MDCT_WINDOW_480_7_5ms[720] = {0.00172152668161197, + 0.00220824874304665, + 0.00268901752259534, + 0.00322613341770658, + 0.00381014419509035, + 0.00445371931718418, + 0.00515369239968132, + 0.00591552473428981, + 0.00673869158441088, + 0.00762861840690755, + 0.00858361456803004, + 0.00960938437461376, + 0.0107060753216012, + 0.0118759722608345, + 0.0131190129731594, + 0.0144390107858867, + 0.0158335301409709, + 0.0173063081075865, + 0.0188584711217331, + 0.0204918651551601, + 0.0222061476414017, + 0.0240057166241995, + 0.0258883592892154, + 0.0278552325915007, + 0.0299059145401639, + 0.0320415894481754, + 0.0342610013298592, + 0.0365680972732117, + 0.0389616721239547, + 0.0414435823556703, + 0.0440140795515652, + 0.0466742169139349, + 0.0494214624989609, + 0.0522588488991433, + 0.0551849337276135, + 0.0582005142844991, + 0.0613059844876918, + 0.0645038384438376, + 0.0677913922780715, + 0.0711707832894713, + 0.0746411071480673, + 0.0782028053093391, + 0.0818549520793733, + 0.0856000161887899, + 0.0894357617466231, + 0.0933642589167916, + 0.0973846702504817, + 0.101496717842215, + 0.105698760137915, + 0.109993602538973, + 0.114378287000688, + 0.118853507644691, + 0.123419277472281, + 0.128075996686182, + 0.132820580592162, + 0.137655456547628, + 0.142578647864983, + 0.147590521689500, + 0.152690437463956, + 0.157878852729327, + 0.163152528516638, + 0.168513362640497, + 0.173957968965553, + 0.179484736541084, + 0.185093104613143, + 0.190784835080141, + 0.196556497277956, + 0.202410419487986, + 0.208345433427595, + 0.214359824832231, + 0.220450365133188, + 0.226617296379634, + 0.232856279279332, + 0.239167940620308, + 0.245550641734726, + 0.252003950801656, + 0.258526168288333, + 0.265118407626359, + 0.271775911320379, + 0.278498538773636, + 0.285284606228892, + 0.292132459126393, + 0.299038431599591, + 0.306004255968647, + 0.313026529044311, + 0.320104862365552, + 0.327237324371911, + 0.334423209544169, + 0.341658622243036, + 0.348944976164519, + 0.356279251911600, + 0.363660034025212, + 0.371085146360032, + 0.378554326716481, + 0.386062695189504, + 0.393610553614044, + 0.401195224753282, + 0.408815272459443, + 0.416468460349459, + 0.424155411395509, + 0.431871045845866, + 0.439614743914448, + 0.447384019490353, + 0.455176987704814, + 0.462990137501968, + 0.470824618788539, + 0.478676592635263, + 0.486545433113577, + 0.494428714400322, + 0.502324813138104, + 0.510229471464589, + 0.518142926555815, + 0.526060916224847, + 0.533982817654487, + 0.541906816785495, + 0.549831282885023, + 0.557751233747995, + 0.565667636233856, + 0.573576882777006, + 0.581476665547768, + 0.589364661090802, + 0.597241338441034, + 0.605102013194533, + 0.612946170296527, + 0.620770242419397, + 0.628572093800007, + 0.636348526182129, + 0.644099662433612, + 0.651820973301216, + 0.659513821705787, + 0.667176381676395, + 0.674806795170392, + 0.682400710845902, + 0.689958853765865, + 0.697475722348889, + 0.704950144755303, + 0.712379980093130, + 0.719765434054233, + 0.727103832924324, + 0.734396371869479, + 0.741638560666120, + 0.748829639427782, + 0.755966688050532, + 0.763049259441822, + 0.770072273456679, + 0.777036981101517, + 0.783941107955561, + 0.790781256570410, + 0.797558113689794, + 0.804271380965317, + 0.810914900592988, + 0.817490855531114, + 0.823997093771197, + 0.830432785018494, + 0.836796949640853, + 0.843089297972628, + 0.849305847142233, + 0.855447309567916, + 0.861511036513329, + 0.867496280683677, + 0.873400798399116, + 0.879227518344298, + 0.884972438304695, + 0.890635718969808, + 0.896217172709751, + 0.901716413868111, + 0.907128770123878, + 0.912456578161017, + 0.917697260839682, + 0.922848783570288, + 0.927909917257080, + 0.932882596476862, + 0.937763322534182, + 0.942553355949148, + 0.947252428176398, + 0.951860206252747, + 0.956376059930715, + 0.960800601653643, + 0.965130600153629, + 0.969366688856792, + 0.973508812191284, + 0.977556540546725, + 0.981507226076202, + 0.985364580290061, + 0.989126208677996, + 0.992794200680601, + 0.996367545084978, + 0.999846919168316, + 1.00322812484515, + 1.00651341182191, + 1.00970072970387, + 1.01279028960634, + 1.01578293436089, + 1.01868228690835, + 1.02148657041020, + 1.02419771842881, + 1.02681455085919, + 1.02933598109997, + 1.03176042993634, + 1.03408981275172, + 1.03632325851578, + 1.03846360765363, + 1.04051195662940, + 1.04246831469554, + 1.04433331015458, + 1.04610836852236, + 1.04779018315657, + 1.04938333555913, + 1.05088564953428, + 1.05229923461622, + 1.05362521849064, + 1.05486288757866, + 1.05601520650228, + 1.05708745929907, + 1.05807220584955, + 1.05897524171920, + 1.05979446723066, + 1.06053413867011, + 1.06119411863264, + 1.06177365556482, + 1.06227661751764, + 1.06270323725515, + 1.06305568550874, + 1.06333815026019, + 1.06354799718407, + 1.06368606790043, + 1.06375556676696, + 1.06375743495314, + 1.06369358352060, + 1.06356632061806, + 1.06337707389149, + 1.06312781969919, + 1.06282155753012, + 1.06245781539243, + 1.06203634281998, + 1.06155995891758, + 1.06102951018466, + 1.06044796508355, + 1.05981709158148, + 1.05914162811841, + 1.05842135887536, + 1.05765876038451, + 1.05685377407703, + 1.05600761436100, + 1.05512005736540, + 1.05419504543825, + 1.05323345555133, + 1.05223985071955, + 1.05121667551754, + 1.05016636928704, + 1.04908778571338, + 1.04798366418119, + 1.04685333764799, + 1.04569859514623, + 1.04452056473031, + 1.04332348168164, + 1.04210830682439, + 1.04087907347658, + 1.03963603298779, + 1.03838098558867, + 1.03711402960368, + 1.03583813453316, + 1.03455276253936, + 1.03326200062149, + 1.03196749756726, + 1.03067199718128, + 1.02937563931250, + 1.02808243736505, + 1.02679166694268, + 1.02550635249346, + 1.02422655030626, + 1.02295558402234, + 1.02169298956325, + 1.02044474846015, + 1.01920733213785, + 1.01799991915642, + 1.01716021719396, + 1.01587288719722, + 1.01461782929950, + 1.01339738080134, + 1.01221017459353, + 1.01105651618772, + 1.00993443649479, + 1.00884559103696, + 1.00778955760958, + 1.00676790147273, + 1.00577851248622, + 1.00482173369676, + 1.00389592016124, + 1.00300261849896, + 1.00214090725866, + 1.00131212703156, + 1.00051460180915, + 0.999748987566388, + 0.999013486065174, + 0.998309228756053, + 0.997634933573802, + 0.996991885118110, + 0.996378601374572, + 0.995795982324256, + 0.995242217431553, + 0.994718132279737, + 0.994222121603521, + 0.993755313270097, + 0.993316215711850, + 0.992905809264804, + 0.992522421568056, + 0.992166956964939, + 0.991837703847481, + 0.991535508409853, + 0.991258602708851, + 0.991007878425042, + 0.990781722666477, + 0.990581103872326, + 0.990404336010644, + 0.990252266515061, + 0.990123118186375, + 0.990017725942080, + 0.989934325251675, + 0.989873711994700, + 0.989834110063609, + 0.989816358516333, + 0.989818706664725, + 0.989841997633560, + 0.989884437608375, + 0.989946800178719, + 0.990027287179467, + 0.990126680433027, + 0.990243175367708, + 0.990377593567359, + 0.990528133732004, + 0.990695563551443, + 0.990878043253865, + 0.991076301696221, + 0.991288540103593, + 0.991515601979036, + 0.991755665863857, + 0.992009469063567, + 0.992275155432533, + 0.992553486464066, + 0.992842692750141, + 0.993143533338714, + 0.993454079661184, + 0.993775066630664, + 0.994104689071308, + 0.994443741563539, + 0.994790397982872, + 0.995145361143570, + 0.995506799575831, + 0.995875533622126, + 0.996249681496846, + 0.996629918576519, + 0.997014367015673, + 0.997403799406302, + 0.997796404470102, + 0.998192870684212, + 0.998591285561368, + 0.998992436297826, + 0.999394506476233, + 0.999798247074188, + 1.00020179363827, + 1.00060586036830, + 1.00100857991068, + 1.00141070171451, + 1.00181040094441, + 1.00220846208708, + 1.00260295839583, + 1.00299457368229, + 1.00338147727724, + 1.00376443633841, + 1.00414154805357, + 1.00451348039620, + 1.00487832134478, + 1.00523688409909, + 1.00558730293553, + 1.00593027172440, + 1.00626392589064, + 1.00658905174666, + 1.00690380235195, + 1.00720890358777, + 1.00750238011098, + 1.00778498234605, + 1.00805489381465, + 1.00831286819921, + 1.00855699900640, + 1.00878801634839, + 1.00900404770905, + 1.00920593286756, + 1.00939182206005, + 1.00956244042490, + 1.00971589673993, + 1.00985295821773, + 1.00997177407911, + 1.01007316964863, + 1.01015529301117, + 1.01021893264234, + 1.01026224628852, + 1.01028601830489, + 1.01028841501360, + 1.01027029664166, + 1.01022987870331, + 1.01016802275824, + 1.01008292457433, + 1.00997540773688, + 1.00984368712353, + 1.00968863285475, + 1.00950845528029, + 1.00930404459694, + 1.00907371350998, + 1.00881848315592, + 1.00853675084589, + 1.00822946750346, + 1.00789488400120, + 1.00753391386376, + 1.00714487786153, + 1.00672875785417, + 1.00628392789102, + 1.00581145628420, + 1.00530991398353, + 1.00478052727780, + 1.00422176605486, + 1.00363456081898, + 1.00301719093886, + 1.00237067322585, + 1.00169363479295, + 1.00098748810560, + 1.00025107545667, + 0.999485662869670, + 0.998689592389690, + 0.997863666433377, + 0.997006370229165, + 0.996119199129118, + 0.995201403855962, + 0.994254686877395, + 0.993277595101281, + 0.992270650602836, + 0.991231967393677, + 0.990163285718553, + 0.989064393522322, + 0.987937115334337, + 0.986779736108308, + 0.985592773084236, + 0.984375124686103, + 0.983129287890062, + 0.981348462911328, + 0.979890963312768, + 0.978400458984906, + 0.976860435411572, + 0.975269878842859, + 0.973627353241612, + 0.971931340983223, + 0.970180498004025, + 0.968372651965257, + 0.966506952259707, + 0.964580026820328, + 0.962592317588312, + 0.960540986343273, + 0.958425533515528, + 0.956244393275019, + 0.953998415902893, + 0.951684013845583, + 0.949301185363779, + 0.946846884329832, + 0.944320232231505, + 0.941718404323327, + 0.939042579646710, + 0.936290624169877, + 0.933464049736310, + 0.930560853876881, + 0.927580506944232, + 0.924519591719516, + 0.921378471441385, + 0.918153413723035, + 0.914844695613022, + 0.911451651601712, + 0.907976524013806, + 0.904417545083186, + 0.900776307727862, + 0.897050058479312, + 0.893238397854931, + 0.889338680564778, + 0.885351360384818, + 0.881274022956677, + 0.877109637913966, + 0.872857926504400, + 0.868519505092655, + 0.864092796449043, + 0.859579818650462, + 0.854976006559576, + 0.850285220126345, + 0.845502615038655, + 0.840630470320405, + 0.835667925492783, + 0.830619943301480, + 0.825482006990559, + 0.820258908705916, + 0.814946648157534, + 0.809546695921391, + 0.804059977858176, + 0.798489377529441, + 0.792831417318078, + 0.787090668112010, + 0.781262449660145, + 0.775353946896531, + 0.769363612973808, + 0.763291769255088, + 0.757139016438538, + 0.750901711179744, + 0.744590843420388, + 0.738205135983222, + 0.731738075019976, + 0.725199287080917, + 0.718588225289593, + 0.711905686689260, + 0.705153668360855, + 0.698332634155137, + 0.691444101223867, + 0.684490544603819, + 0.677470119276872, + 0.670388375375255, + 0.663245209931378, + 0.656045780075394, + 0.648788626910908, + 0.641477161661819, + 0.634114322697443, + 0.626702000288600, + 0.619235333635541, + 0.611720595766813, + 0.604161612008372, + 0.596559132542786, + 0.588914400742527, + 0.581234783414194, + 0.573519989364814, + 0.565770615838341, + 0.557988067156798, + 0.550173851023454, + 0.542330193938633, + 0.534460798055783, + 0.526568538230013, + 0.518656324106017, + 0.510728812610530, + 0.502781158663802, + 0.494819490990687, + 0.486845139248642, + 0.478860889056187, + 0.470869928237011, + 0.462875144056541, + 0.454877894349081, + 0.446882512027806, + 0.438889324991181, + 0.430898122898976, + 0.422918322377786, + 0.414950877976117, + 0.406993964205624, + 0.399052648395750, + 0.391134613511556, + 0.383234030582781, + 0.375354652658444, + 0.367502059648862, + 0.359680098334456, + 0.351887311977221, + 0.344130165828257, + 0.336408100091303, + 0.328728966167385, + 0.321090505163296, + 0.313496418152647, + 0.305951564939720, + 0.298454318724068, + 0.291010565493870, + 0.283621109377504, + 0.276285415057373, + 0.269019585108745, + 0.261812445205796, + 0.254659232371968, + 0.247584347561867, + 0.240578694191260, + 0.233647008666278, + 0.226788433385199, + 0.220001991767835, + 0.213301325170393, + 0.206677770653848, + 0.200140409104345, + 0.193683630277597, + 0.187310343238419, + 0.181027383883625, + 0.174839476062309, + 0.168739644125069, + 0.162737273481917, + 0.156825277050683, + 0.151012382058898, + 0.145298229536747, + 0.139687469382981, + 0.134171842279709, + 0.128762544136019, + 0.123455562073148, + 0.118254662325635, + 0.113159676766305, + 0.108171439273590, + 0.103290733977459, + 0.0985202977906343, + 0.0938600022604814, + 0.0893117360272552, + 0.0848752102882993, + 0.0805523737322188, + 0.0763429786604177, + 0.0722489245608881, + 0.0682699119548786, + 0.0644077291458590, + 0.0606620002841447, + 0.0570343711147243, + 0.0535243714739393, + 0.0501334689685108, + 0.0468610789607730, + 0.0437084452819923, + 0.0406748365259497, + 0.0377612269065632, + 0.0349667099153408, + 0.0322919274833124, + 0.0297357668703102, + 0.0272984629264830, + 0.0249787185611126, + 0.0227762541832071, + 0.0206895808034878, + 0.0187178169347065, + 0.0168593417528780, + 0.0151125125235276, + 0.0134757094495118, + 0.0119462709121848, + 0.0105228753811890, + 0.00920130941284003, + 0.00798124316373271, + 0.00685547314312078, + 0.00582657334385164, + 0.00487838525422656, + 0.00402351119094097, + 0.00315418662758696, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 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 /* #ifdef CR8_G_ADD_75MS */ + +const LC3_FLOAT MDCT_WINDOW_80_2_5ms[40] = { + 6.737914289329320e-03, 2.732289618100209e-02, 6.163560962361236e-02, 1.119125037883055e-01, 1.787053464784875e-01, + 2.607525136824537e-01, 3.549776504187033e-01, 4.567696724165073e-01, 5.605239559005871e-01, 6.603665285212146e-01, + 7.509434386216048e-01, 8.281382099997300e-01, 8.895849967038094e-01, 9.348747871791264e-01, 9.654056798094166e-01, + 9.839026370225886e-01, 9.937180643904148e-01, 9.980987183772584e-01, 9.996266599807562e-01, 9.999772999978698e-01, + 9.999772999978698e-01, 9.996266599807562e-01, 9.980987183772584e-01, 9.937180643904148e-01, 9.839026370225886e-01, + 9.654056798094166e-01, 9.348747871791264e-01, 8.895849967038094e-01, 8.281382099997300e-01, 7.509434386216048e-01, + 6.603665285212146e-01, 5.605239559005871e-01, 4.567696724165073e-01, 3.549776504187033e-01, 2.607525136824537e-01, + 1.787053464784875e-01, 1.119125037883055e-01, 6.163560962361236e-02, 2.732289618100209e-02, 6.737914289329320e-03}; + +const LC3_FLOAT MDCT_WINDOW_160_2_5ms[80] = { + 4.764416154578566e-03, 1.204636278996989e-02, 2.226396539371650e-02, 3.580223111285056e-02, 5.299054649961241e-02, + 7.408518398076024e-02, 9.925385917916330e-02, 1.285631180041137e-01, 1.619692437449073e-01, 1.993132407013812e-01, + 2.403202823615340e-01, 2.846038181323611e-01, 3.316743228466244e-01, 3.809524578920635e-01, 4.317862022264749e-01, + 4.834713159013930e-01, 5.352743274612082e-01, 5.864570980113353e-01, 6.363019156559162e-01, 6.841360194558924e-01, + 7.293544453028629e-01, 7.714401286766273e-01, 8.099802912368443e-01, 8.446782786131956e-01, 8.753602039735273e-01, + 9.019759839191052e-01, 9.245946272967390e-01, 9.433939492938426e-01, 9.586452246292587e-01, 9.706936498636800e-01, + 9.799358305935717e-01, 9.867958066797319e-01, 9.917013283691115e-01, 9.950621445106043e-01, 9.972519167765670e-01, + 9.985950139980033e-01, 9.993588946156141e-01, 9.997521272020117e-01, 9.999274399392850e-01, 9.999886501049429e-01, + 9.999886501049429e-01, 9.999274399392850e-01, 9.997521272020117e-01, 9.993588946156141e-01, 9.985950139980033e-01, + 9.972519167765670e-01, 9.950621445106043e-01, 9.917013283691115e-01, 9.867958066797319e-01, 9.799358305935717e-01, + 9.706936498636800e-01, 9.586452246292587e-01, 9.433939492938426e-01, 9.245946272967390e-01, 9.019759839191052e-01, + 8.753602039735273e-01, 8.446782786131956e-01, 8.099802912368443e-01, 7.714401286766273e-01, 7.293544453028629e-01, + 6.841360194558924e-01, 6.363019156559162e-01, 5.864570980113353e-01, 5.352743274612082e-01, 4.834713159013930e-01, + 4.317862022264749e-01, 3.809524578920635e-01, 3.316743228466244e-01, 2.846038181323611e-01, 2.403202823615340e-01, + 1.993132407013812e-01, 1.619692437449073e-01, 1.285631180041137e-01, 9.925385917916330e-02, 7.408518398076024e-02, + 5.299054649961241e-02, 3.580223111285056e-02, 2.226396539371650e-02, 1.204636278996989e-02, 4.764416154578566e-03}; + +const LC3_FLOAT MDCT_WINDOW_240_2_5ms[120] = { + 3.890134207235998e-03, 8.202595078385781e-03, 1.370235555340779e-02, 2.052968531182845e-02, 2.880307728389693e-02, + 3.862785141889536e-02, 5.009569719921809e-02, 6.328296540190831e-02, 7.824881086160715e-02, 9.503346510857243e-02, + 1.136567491769230e-01, 1.341168883357315e-01, 1.563896708020576e-01, 1.804279808512455e-01, 2.061617274373514e-01, + 2.334981807379911e-01, 2.623227204239969e-01, 2.924999908279060e-01, 3.238754496100354e-01, 3.562772881250116e-01, + 3.895186936283779e-01, 4.234004158919065e-01, 4.577135938730904e-01, 4.922427919542673e-01, 5.267691900603833e-01, + 5.610738677940736e-01, 5.949411196851041e-01, 6.281617368097510e-01, 6.605361894447956e-01, 6.918776461105686e-01, + 7.220147663396499e-01, 7.507942077785026e-01, 7.780827927721814e-01, 8.037692853722609e-01, 8.277657367145603e-01, + 8.500083649018569e-01, 8.704579448595252e-01, 8.890996940634835e-01, 9.059426515086708e-01, 9.210185597011833e-01, + 9.343802726761132e-01, 9.460997268469628e-01, 9.562655255553633e-01, 9.649802020504638e-01, 9.723572386690237e-01, + 9.785179314351103e-01, 9.835881982445411e-01, 9.876954342642392e-01, 9.909655192099981e-01, 9.935200769821082e-01, + 9.954740782709803e-01, 9.969338611957889e-01, 9.979956243841658e-01, 9.987444223234112e-01, 9.992536660401901e-01, + 9.995851053006831e-01, 9.997892438014110e-01, 9.999061183192590e-01, 9.999663581511030e-01, 9.999924333992981e-01, + 9.999924333992981e-01, 9.999663581511030e-01, 9.999061183192590e-01, 9.997892438014110e-01, 9.995851053006831e-01, + 9.992536660401901e-01, 9.987444223234112e-01, 9.979956243841658e-01, 9.969338611957889e-01, 9.954740782709803e-01, + 9.935200769821082e-01, 9.909655192099981e-01, 9.876954342642392e-01, 9.835881982445411e-01, 9.785179314351103e-01, + 9.723572386690237e-01, 9.649802020504638e-01, 9.562655255553633e-01, 9.460997268469628e-01, 9.343802726761132e-01, + 9.210185597011833e-01, 9.059426515086708e-01, 8.890996940634835e-01, 8.704579448595252e-01, 8.500083649018569e-01, + 8.277657367145603e-01, 8.037692853722609e-01, 7.780827927721814e-01, 7.507942077785026e-01, 7.220147663396499e-01, + 6.918776461105686e-01, 6.605361894447956e-01, 6.281617368097510e-01, 5.949411196851041e-01, 5.610738677940736e-01, + 5.267691900603833e-01, 4.922427919542673e-01, 4.577135938730904e-01, 4.234004158919065e-01, 3.895186936283779e-01, + 3.562772881250116e-01, 3.238754496100354e-01, 2.924999908279060e-01, 2.623227204239969e-01, 2.334981807379911e-01, + 2.061617274373514e-01, 1.804279808512455e-01, 1.563896708020576e-01, 1.341168883357315e-01, 1.136567491769230e-01, + 9.503346510857243e-02, 7.824881086160715e-02, 6.328296540190831e-02, 5.009569719921809e-02, 3.862785141889536e-02, + 2.880307728389693e-02, 2.052968531182845e-02, 1.370235555340779e-02, 8.202595078385781e-03, 3.890134207235998e-03}; + +const LC3_FLOAT MDCT_WINDOW_320_2_5ms[160] = { + 3.368958353152859e-03, 6.455557414799749e-03, 1.014308076237845e-02, 1.452126850237346e-02, 1.965076732239952e-02, + 2.558352795411825e-02, 3.236628529621430e-02, 4.004117865352276e-02, 4.864564178753818e-02, 5.821207082124419e-02, + 6.876742903793599e-02, 8.033284980531531e-02, 9.292326595333501e-02, 1.065470811378728e-01, 1.212058930254449e-01, + 1.368942751980506e-01, 1.535996228917228e-01, 1.713020663983868e-01, 1.899744548998832e-01, 2.095824125414741e-01, + 2.300844676343023e-01, 2.514322549787097e-01, 2.735707904154788e-01, 2.964388158404272e-01, 3.199692120640840e-01, + 3.440894760693133e-01, 3.687222584236977e-01, 3.937859558486231e-01, 4.191953532416662e-01, 4.448623088011174e-01, + 4.706964753188311e-01, 4.966060501969578e-01, 5.224985463116437e-01, 5.482815754977786e-01, 5.738636361677886e-01, + 5.991548964078475e-01, 6.240679638193776e-01, 6.485186333941402e-01, 6.724266048285701e-01, 6.957161608975563e-01, + 7.183167988192716e-01, 7.401638069500036e-01, 7.611987796499656e-01, 7.813700637561797e-01, 8.006331307849442e-01, + 8.189508697622124e-01, 8.362937964433754e-01, 8.526401756322647e-01, 8.679760543400818e-01, 8.822952046352904e-01, + 8.955989762210201e-01, 9.078960600314304e-01, 9.192021654545784e-01, 9.295396151552272e-01, 9.389368628711653e-01, + 9.474279409702298e-01, 9.550518459555614e-01, 9.618518714601797e-01, 9.678748995383242e-01, 9.731706621931426e-01, + 9.777909860257944e-01, 9.817890335940264e-01, 9.852185554726640e-01, 9.881331670617683e-01, 9.905856638463937e-01, + 9.926273880444285e-01, 9.943076583739057e-01, 9.956732730391862e-01, 9.967680940129237e-01, 9.976327183405286e-01, + 9.983042396036903e-01, 9.988160999578843e-01, 9.991980304284215e-01, 9.994760745391177e-01, 9.996726879821318e-01, + 9.998069050289865e-01, 9.998945608218308e-01, 9.999485576331654e-01, 9.999791626721350e-01, 9.999943250437048e-01, + 9.999943250437048e-01, 9.999791626721350e-01, 9.999485576331654e-01, 9.998945608218308e-01, 9.998069050289865e-01, + 9.996726879821318e-01, 9.994760745391177e-01, 9.991980304284215e-01, 9.988160999578843e-01, 9.983042396036903e-01, + 9.976327183405286e-01, 9.967680940129237e-01, 9.956732730391862e-01, 9.943076583739057e-01, 9.926273880444285e-01, + 9.905856638463937e-01, 9.881331670617683e-01, 9.852185554726640e-01, 9.817890335940264e-01, 9.777909860257944e-01, + 9.731706621931426e-01, 9.678748995383242e-01, 9.618518714601797e-01, 9.550518459555614e-01, 9.474279409702298e-01, + 9.389368628711653e-01, 9.295396151552272e-01, 9.192021654545784e-01, 9.078960600314304e-01, 8.955989762210201e-01, + 8.822952046352904e-01, 8.679760543400818e-01, 8.526401756322647e-01, 8.362937964433754e-01, 8.189508697622124e-01, + 8.006331307849442e-01, 7.813700637561797e-01, 7.611987796499656e-01, 7.401638069500036e-01, 7.183167988192716e-01, + 6.957161608975563e-01, 6.724266048285701e-01, 6.485186333941402e-01, 6.240679638193776e-01, 5.991548964078475e-01, + 5.738636361677886e-01, 5.482815754977786e-01, 5.224985463116437e-01, 4.966060501969578e-01, 4.706964753188311e-01, + 4.448623088011174e-01, 4.191953532416662e-01, 3.937859558486231e-01, 3.687222584236977e-01, 3.440894760693133e-01, + 3.199692120640840e-01, 2.964388158404272e-01, 2.735707904154788e-01, 2.514322549787097e-01, 2.300844676343023e-01, + 2.095824125414741e-01, 1.899744548998832e-01, 1.713020663983868e-01, 1.535996228917228e-01, 1.368942751980506e-01, + 1.212058930254449e-01, 1.065470811378728e-01, 9.292326595333501e-02, 8.033284980531531e-02, 6.876742903793599e-02, + 5.821207082124419e-02, 4.864564178753818e-02, 4.004117865352276e-02, 3.236628529621430e-02, 2.558352795411825e-02, + 1.965076732239952e-02, 1.452126850237346e-02, 1.014308076237845e-02, 6.455557414799749e-03, 3.368958353152859e-03}; + +const LC3_FLOAT MDCT_WINDOW_480_2_5ms[240] = { + 2.750746382614873e-03, 4.775245154322467e-03, 6.991265476184880e-03, 9.470118155887091e-03, 1.224415763156159e-02, + 1.533559472880042e-02, 1.876266772162453e-02, 2.254154337372088e-02, 2.668701415521377e-02, 3.121277069249126e-02, + 3.613150075407039e-02, 4.145491000214293e-02, 4.719370517091751e-02, 5.335755875796826e-02, 5.995506493224793e-02, + 6.699369195627566e-02, 7.447973421347953e-02, 8.241826576309315e-02, 9.081309669365416e-02, 9.966673316465058e-02, + 1.089803417907089e-01, 1.187537188695662e-01, 1.289852648491186e-01, 1.396719643506733e-01, 1.508093720039881e-01, + 1.623916042982366e-01, 1.744113376077630e-01, 1.868598125100347e-01, 1.997268444741311e-01, 2.130008409605561e-01, + 2.266688249366323e-01, 2.407164647759538e-01, 2.551281104752023e-01, 2.698868360870567e-01, 2.849744882339612e-01, + 3.003717405342550e-01, 3.160581537396951e-01, 3.320122413518523e-01, 3.482115404543554e-01, 3.646326874686314e-01, + 3.812514985127824e-01, 3.980430540166849e-01, 4.149817872214252e-01, 4.320415761679195e-01, 4.491958387581356e-01, + 4.664176304528364e-01, 4.836797441523142e-01, 5.009548117912680e-01, 5.182154071658814e-01, 5.354341495003542e-01, + 5.525838072516958e-01, 5.696374016455559e-01, 5.865683094322820e-01, 6.033503643513004e-01, 6.199579567933325e-01, + 6.363661311538971e-01, 6.525506803780192e-01, 6.684882372050696e-01, 6.841563616341746e-01, 6.995336241446708e-01, + 7.145996842225878e-01, 7.293353637631239e-01, 7.437227149404935e-01, 7.577450821603423e-01, 7.713871577361272e-01, + 7.846350309593857e-01, 7.974762302646725e-01, 8.098997582230498e-01, 8.218961191333729e-01, 8.334573390181531e-01, + 8.445769778704795e-01, 8.552501340402698e-01, 8.654734406919574e-01, 8.752450543115063e-01, 8.845646352883213e-01, + 8.934333206470277e-01, 9.018536890551258e-01, 9.098297182849719e-01, 9.173667353621834e-01, 9.244713596871228e-01, + 9.311514394712620e-01, 9.374159818855259e-01, 9.432750773727245e-01, 9.487398186303003e-01, 9.538222148222497e-01, + 9.585351016294561e-01, 9.628920477950361e-01, 9.669072588647543e-01, 9.705954788611818e-01, 9.739718906630962e-01, + 9.770520158876372e-01, 9.798516150909821e-01, 9.823865891128170e-01, 9.846728823898172e-01, 9.867263890529354e-01, + 9.885628626019504e-01, 9.901978299180545e-01, 9.916465103310770e-01, 9.929237404023775e-01, 9.940439050178721e-01, + 9.950208753087979e-01, 9.958679538316859e-01, 9.965978273449145e-01, 9.972225274187749e-01, 9.977533990110320e-01, + 9.982010770325636e-01, 9.985754708200026e-01, 9.988857563266385e-01, 9.991403757414241e-01, 9.993470441509588e-01, + 9.995127627727911e-01, 9.996438382121301e-01, 9.997459071295719e-01, 9.998239656559388e-01, 9.998824028526124e-01, + 9.999250374922579e-01, 9.999551574256286e-01, 9.999755608048836e-01, 9.999885984518604e-01, 9.999962166900126e-01, + 9.999962166900126e-01, 9.999885984518604e-01, 9.999755608048836e-01, 9.999551574256286e-01, 9.999250374922579e-01, + 9.998824028526124e-01, 9.998239656559388e-01, 9.997459071295719e-01, 9.996438382121301e-01, 9.995127627727911e-01, + 9.993470441509588e-01, 9.991403757414241e-01, 9.988857563266385e-01, 9.985754708200026e-01, 9.982010770325636e-01, + 9.977533990110320e-01, 9.972225274187749e-01, 9.965978273449145e-01, 9.958679538316859e-01, 9.950208753087979e-01, + 9.940439050178721e-01, 9.929237404023775e-01, 9.916465103310770e-01, 9.901978299180545e-01, 9.885628626019504e-01, + 9.867263890529354e-01, 9.846728823898172e-01, 9.823865891128170e-01, 9.798516150909821e-01, 9.770520158876372e-01, + 9.739718906630962e-01, 9.705954788611818e-01, 9.669072588647543e-01, 9.628920477950361e-01, 9.585351016294561e-01, + 9.538222148222497e-01, 9.487398186303003e-01, 9.432750773727245e-01, 9.374159818855259e-01, 9.311514394712620e-01, + 9.244713596871228e-01, 9.173667353621834e-01, 9.098297182849719e-01, 9.018536890551258e-01, 8.934333206470277e-01, + 8.845646352883213e-01, 8.752450543115063e-01, 8.654734406919574e-01, 8.552501340402698e-01, 8.445769778704795e-01, + 8.334573390181531e-01, 8.218961191333729e-01, 8.098997582230498e-01, 7.974762302646725e-01, 7.846350309593857e-01, + 7.713871577361272e-01, 7.577450821603423e-01, 7.437227149404935e-01, 7.293353637631239e-01, 7.145996842225878e-01, + 6.995336241446708e-01, 6.841563616341746e-01, 6.684882372050696e-01, 6.525506803780192e-01, 6.363661311538971e-01, + 6.199579567933325e-01, 6.033503643513004e-01, 5.865683094322820e-01, 5.696374016455559e-01, 5.525838072516958e-01, + 5.354341495003542e-01, 5.182154071658814e-01, 5.009548117912680e-01, 4.836797441523142e-01, 4.664176304528364e-01, + 4.491958387581356e-01, 4.320415761679195e-01, 4.149817872214252e-01, 3.980430540166849e-01, 3.812514985127824e-01, + 3.646326874686314e-01, 3.482115404543554e-01, 3.320122413518523e-01, 3.160581537396951e-01, 3.003717405342550e-01, + 2.849744882339612e-01, 2.698868360870567e-01, 2.551281104752023e-01, 2.407164647759538e-01, 2.266688249366323e-01, + 2.130008409605561e-01, 1.997268444741311e-01, 1.868598125100347e-01, 1.744113376077630e-01, 1.623916042982366e-01, + 1.508093720039881e-01, 1.396719643506733e-01, 1.289852648491186e-01, 1.187537188695662e-01, 1.089803417907089e-01, + 9.966673316465058e-02, 9.081309669365416e-02, 8.241826576309315e-02, 7.447973421347953e-02, 6.699369195627566e-02, + 5.995506493224793e-02, 5.335755875796826e-02, 4.719370517091751e-02, 4.145491000214293e-02, 3.613150075407039e-02, + 3.121277069249126e-02, 2.668701415521377e-02, 2.254154337372088e-02, 1.876266772162453e-02, 1.533559472880042e-02, + 1.224415763156159e-02, 9.470118155887091e-03, 6.991265476184880e-03, 4.775245154322467e-03, 2.750746382614873e-03}; + +const LC3_FLOAT MDCT_WINDOW_80[160] = { + -7.078546706512391e-04, -2.098197727900724e-03, -4.525198076002370e-03, -8.233976327300612e-03, + -1.337713096257934e-02, -1.999721557401502e-02, -2.800909464274782e-02, -3.721502082245055e-02, + -4.731768261606175e-02, -5.794654834034055e-02, -6.867606753531441e-02, -7.904647440788692e-02, + -8.859705468085925e-02, -9.688303623049199e-02, -1.034961241263523e-01, -1.080766457616878e-01, + -1.103242262600913e-01, -1.099809851424550e-01, -1.068172142230882e-01, -1.006190418791648e-01, + -9.116452506492527e-02, -7.820617483254730e-02, -6.146688124166948e-02, -4.063362855701623e-02, + -1.536329520788766e-02, 1.470155068746303e-02, 4.989736509080558e-02, 9.050369257152079e-02, + 1.366911019414417e-01, 1.884686389218322e-01, 2.456456803467095e-01, 3.077789078889820e-01, + 3.741642373060188e-01, 4.438114799213576e-01, 5.154735456539700e-01, 5.876661722564289e-01, + 6.587619767809000e-01, 7.270576699841359e-01, 7.908752989295335e-01, 8.486643364959733e-01, + 8.991320235484349e-01, 9.413348145272842e-01, 9.747634827941575e-01, 9.994114730415857e-01, + 1.015760373791603e+00, 1.024736164069697e+00, 1.027634294456205e+00, 1.025991493983836e+00, + 1.021427210603284e+00, 1.015439859549357e+00, 1.009366925499550e+00, 1.003508162416449e+00, + 9.988898206257559e-01, 9.953133902427869e-01, 9.925943919208190e-01, 9.905771957917731e-01, + 9.891371616557014e-01, 9.881790747212391e-01, 9.876249269174586e-01, 9.874056275509585e-01, + 9.874524849192456e-01, 9.876951134084213e-01, 9.880640617030884e-01, 9.884926873551375e-01, + 9.889230031022089e-01, 9.893074965384659e-01, 9.896146331889107e-01, 9.898319269347060e-01, + 9.899693102025342e-01, 9.900603352632121e-01, 9.901575015155720e-01, 9.903255289051605e-01, + 9.906303787150326e-01, 9.911298894709990e-01, 9.918665491182922e-01, 9.928619727154252e-01, + 9.941156069136238e-01, 9.956033775539884e-01, 9.972793109558521e-01, 9.990784840729244e-01, + 1.000922365901945e+00, 1.002728111386909e+00, 1.004416038098237e+00, 1.005919224127911e+00, + 1.007189345025525e+00, 1.008200146369426e+00, 1.008949493525753e+00, 1.009458241425143e+00, + 1.009768980817384e+00, 1.009940336228694e+00, 1.010039453539107e+00, 1.010132323996401e+00, + 1.010272524848519e+00, 1.010494354532353e+00, 1.010808068774316e+00, 1.011201071127927e+00, + 1.011641272406023e+00, 1.012080125934687e+00, 1.012458183122033e+00, 1.012706955800289e+00, + 1.012755013843985e+00, 1.012530134411619e+00, 1.011962331100864e+00, 1.010982135506986e+00, + 1.009512438049510e+00, 1.007460860286395e+00, 1.004708677491086e+00, 1.001111413242302e+00, + 9.965041017623596e-01, 9.907199995730845e-01, 9.823765865983288e-01, 9.708821747608998e-01, + 9.546732976073705e-01, 9.321553861564006e-01, 9.018003682081348e-01, 8.623984077953557e-01, + 8.132817365236141e-01, 7.544551974836834e-01, 6.866580716267418e-01, 6.113488038789190e-01, + 5.306181649316597e-01, 4.471309850999502e-01, 3.639114681156236e-01, 2.841647033392408e-01, + 2.110209448747969e-01, 1.472287968327703e-01, 9.482665349502291e-02, 5.482436608328477e-02, + 2.701461405056264e-02, 9.996743588367519e-03, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00}; + +const LC3_FLOAT MDCT_WINDOW_160[320] = { + -4.619898752628163e-04, -9.747166718929050e-04, -1.664473096973725e-03, -2.597106916737789e-03, + -3.806285163352241e-03, -5.324608721716763e-03, -7.175885277771099e-03, -9.382480860899108e-03, + -1.195270300743193e-02, -1.489528159506296e-02, -1.820666399965468e-02, -2.187570925786862e-02, + -2.588471937157619e-02, -3.020862738245264e-02, -3.481597793538342e-02, -3.967067992672979e-02, + -4.472698045914417e-02, -4.994225863256500e-02, -5.526334794593565e-02, -6.063717235243996e-02, + -6.600961519440657e-02, -7.131966266443390e-02, -7.651178225890490e-02, -8.152964005319532e-02, + -8.631137544905677e-02, -9.080411291245728e-02, -9.495377758870335e-02, -9.870736514214426e-02, + -1.020202684361974e-01, -1.048438825017798e-01, -1.071382314127799e-01, -1.088690135027248e-01, + -1.099969655786929e-01, -1.104898474883336e-01, -1.103225838568563e-01, -1.094621746650760e-01, + -1.078834293141886e-01, -1.055612509762041e-01, -1.024650162703341e-01, -9.857014566194629e-02, + -9.384684920715425e-02, -8.826309993000785e-02, -8.178792716809512e-02, -7.438785600211463e-02, + -6.602189797715241e-02, -5.665655641133161e-02, -4.624456893420224e-02, -3.474585776145929e-02, + -2.211581608120528e-02, -8.310425696208936e-03, 6.717697635290676e-03, 2.300642061077823e-02, + 4.060106462625085e-02, 5.953239090915557e-02, 7.983354189816511e-02, 1.015233140203748e-01, + 1.246171387327525e-01, 1.491152519299797e-01, 1.750067399059861e-01, 2.022699854906251e-01, + 2.308655379767671e-01, 2.607365124918583e-01, 2.918144694729168e-01, 3.240095704645023e-01, + 3.572175180786021e-01, 3.913146885756875e-01, 4.261571642320424e-01, 4.615925445090212e-01, + 4.974471592901086e-01, 5.335326819631583e-01, 5.696546730080154e-01, 6.056083823929643e-01, + 6.411830842823245e-01, 6.761653499550255e-01, 7.103400549562944e-01, 7.434943718765665e-01, + 7.754281892901473e-01, 8.059437233154637e-01, 8.348589373399948e-01, 8.620108336276733e-01, + 8.872599706865123e-01, 9.104863121445679e-01, 9.315962496426278e-01, 9.505220861927248e-01, + 9.672366712325431e-01, 9.817397501303696e-01, 9.940557180662704e-01, 1.004247514102417e+00, + 1.012407428282884e+00, 1.018650990561848e+00, 1.023118841384460e+00, 1.025972450969440e+00, + 1.027397523939210e+00, 1.027585830688143e+00, 1.026738673647482e+00, 1.025061777648234e+00, + 1.022756514615106e+00, 1.020009139549275e+00, 1.016996499560845e+00, 1.013915946100629e+00, + 1.011044869639164e+00, 1.007773858455400e+00, 1.004848753962734e+00, 1.002245009135684e+00, + 9.999393169239009e-01, 9.979055415627330e-01, 9.961203379971326e-01, 9.945597525471822e-01, + 9.932031606606762e-01, 9.920297273323891e-01, 9.910230654424902e-01, 9.901668953434221e-01, + 9.894488374513719e-01, 9.888556356037892e-01, 9.883778520531268e-01, 9.880051626345804e-01, + 9.877295459610343e-01, 9.875412739766566e-01, 9.874329809802893e-01, 9.873949921033299e-01, + 9.874197049003676e-01, 9.874973205882319e-01, 9.876201238703241e-01, 9.877781920433015e-01, + 9.879637979933339e-01, 9.881678007807095e-01, 9.883835200189653e-01, 9.886022219397892e-01, + 9.888182771263505e-01, 9.890247977602895e-01, 9.892178658748239e-01, 9.893923680007577e-01, + 9.895463342815009e-01, 9.896772011542693e-01, 9.897859195209235e-01, 9.898725363809847e-01, + 9.899410789223559e-01, 9.899945557067980e-01, 9.900394023736973e-01, 9.900814722948890e-01, + 9.901293790312005e-01, 9.901902265696609e-01, 9.902734448815004e-01, 9.903862280081246e-01, + 9.905379830873822e-01, 9.907348826312993e-01, 9.909842592301273e-01, 9.912905118607647e-01, + 9.916586940166509e-01, 9.920906151219310e-01, 9.925887208794144e-01, 9.931516528513824e-01, + 9.937790866568735e-01, 9.944668184371617e-01, 9.952116634297566e-01, 9.960068616185641e-01, + 9.968461329825753e-01, 9.977203369515556e-01, 9.986213520769593e-01, 9.995382582242990e-01, + 1.000461955079660e+00, 1.001380551217109e+00, 1.002284871786226e+00, 1.003163845364970e+00, + 1.004009147462043e+00, 1.004811375053364e+00, 1.005563968008037e+00, 1.006259855360867e+00, + 1.006895570408563e+00, 1.007466616298057e+00, 1.007972441990187e+00, 1.008411468616852e+00, + 1.008786009787269e+00, 1.009097763850333e+00, 1.009351762546296e+00, 1.009552401900961e+00, + 1.009707093778162e+00, 1.009822090220407e+00, 1.009906958448099e+00, 1.009969021400474e+00, + 1.010017890428877e+00, 1.010060809299530e+00, 1.010106564965965e+00, 1.010161131093372e+00, + 1.010231078494249e+00, 1.010319484524512e+00, 1.010430470494512e+00, 1.010564099281000e+00, + 1.010721360243234e+00, 1.010899655674578e+00, 1.011096993993037e+00, 1.011308167670753e+00, + 1.011529185153809e+00, 1.011753008569803e+00, 1.011973876511603e+00, 1.012182837094955e+00, + 1.012373028737774e+00, 1.012535058602453e+00, 1.012660975529858e+00, 1.012740575296603e+00, + 1.012765922449960e+00, 1.012726958954961e+00, 1.012615904116265e+00, 1.012422888521601e+00, + 1.012140460211194e+00, 1.011758810583150e+00, 1.011269960947744e+00, 1.010663676735228e+00, + 1.009930754807923e+00, 1.009058249873833e+00, 1.008034308295421e+00, 1.006843352506855e+00, + 1.005470005637052e+00, 1.003894772403371e+00, 1.002098854400575e+00, 1.000060686758758e+00, + 9.977600196406868e-01, 9.951746430061121e-01, 9.922861082472264e-01, 9.890757868707590e-01, + 9.847362453480265e-01, 9.798613526271561e-01, 9.741378617337759e-01, 9.673331975559332e-01, + 9.592539757044516e-01, 9.496984081652284e-01, 9.384634163826711e-01, 9.253567968750328e-01, + 9.101986790930605e-01, 8.928338316495705e-01, 8.731437835983047e-01, 8.510420440685049e-01, + 8.264839911291133e-01, 7.994681492797084e-01, 7.700431275216928e-01, 7.383028603058783e-01, + 7.043814340356083e-01, 6.684616478236647e-01, 6.307755329382612e-01, 5.915799587176216e-01, + 5.511703155400274e-01, 5.098915423728179e-01, 4.681017110047964e-01, 4.261772971493010e-01, + 3.845172335531009e-01, 3.435228672445613e-01, 3.036004651973099e-01, 2.651434678028531e-01, + 2.285283969438072e-01, 1.941021906320984e-01, 1.621735416384830e-01, 1.330015240938615e-01, + 1.067840430193724e-01, 8.365057236623041e-02, 6.365188111381356e-02, 4.676538412257621e-02, + 3.288072750732215e-02, 2.183057564646270e-02, 1.336381425803019e-02, 6.758124889697787e-03, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00}; + +const LC3_FLOAT MDCT_WINDOW_240[480] = { + -3.613496418928369e-04, -7.078546706512391e-04, -1.074443637110903e-03, -1.533478537964509e-03, + -2.098197727900724e-03, -2.778420871815740e-03, -3.584129920673041e-03, -4.525198076002370e-03, + -5.609327243712055e-03, -6.843234536105624e-03, -8.233976327300612e-03, -9.785314755557023e-03, + -1.149880303071551e-02, -1.337713096257934e-02, -1.542181679511618e-02, -1.762979910961727e-02, + -1.999721557401502e-02, -2.252080561390149e-02, -2.519406300389030e-02, -2.800909464274782e-02, + -3.095765092956728e-02, -3.402996266948349e-02, -3.721502082245055e-02, -4.050053247568393e-02, + -4.387219218706189e-02, -4.731768261606175e-02, -5.082325342672667e-02, -5.437166635159518e-02, + -5.794654834034055e-02, -6.153426201732499e-02, -6.511708163113709e-02, -6.867606753531441e-02, + -7.219447805250771e-02, -7.565695975592170e-02, -7.904647440788692e-02, -8.234442557322251e-02, + -8.553324579905185e-02, -8.859705468085925e-02, -9.152091100798199e-02, -9.428847446755965e-02, + -9.688303623049198e-02, -9.929123258537813e-02, -1.015008467688577e-01, -1.034961241263523e-01, + -1.052637003544443e-01, -1.067939984687745e-01, -1.080766457616878e-01, -1.090997300590506e-01, + -1.098524491515805e-01, -1.103242262600913e-01, -1.105084619148789e-01, -1.103977408741932e-01, + -1.099809851424550e-01, -1.092492774392824e-01, -1.081974227416502e-01, -1.068172142230882e-01, + -1.050995803285455e-01, -1.030360111111103e-01, -1.006190418791648e-01, -9.784120023411771e-02, + -9.469304216883027e-02, -9.116452506492527e-02, -8.724644532866996e-02, -8.293043914044632e-02, + -7.820617483254730e-02, -7.306142427456862e-02, -6.748468182105991e-02, -6.146688124166948e-02, + -5.499497258200362e-02, -4.805444424454820e-02, -4.063362855701623e-02, -3.272045590229335e-02, + -2.430122582451853e-02, -1.536329520788766e-02, -5.891434269890659e-03, 4.126595858583295e-03, + 1.470155068746303e-02, 2.584738191459814e-02, 3.757652772246801e-02, 4.989736509080558e-02, + 6.282034030592902e-02, 7.635397728566121e-02, 9.050369257152079e-02, 1.052747118478660e-01, + 1.206703467513333e-01, 1.366911019414417e-01, 1.533343890681390e-01, 1.705954709184399e-01, + 1.884686389218322e-01, 2.069449962574092e-01, 2.260093000067393e-01, 2.456456803467095e-01, + 2.658346019332584e-01, 2.865543814049772e-01, 3.077789078889820e-01, 3.294769437072290e-01, + 3.516171481750350e-01, 3.741642373060188e-01, 3.970739591211551e-01, 4.203043046885219e-01, + 4.438114799213576e-01, 4.675442291623012e-01, 4.914498631045615e-01, 5.154735456539700e-01, + 5.395557644293222e-01, 5.636399817032525e-01, 5.876661722564289e-01, 6.115695310143157e-01, + 6.352890592874099e-01, 6.587619767809000e-01, 6.819230974423550e-01, 7.047092819314779e-01, + 7.270576699841359e-01, 7.489068963384272e-01, 7.701990187606995e-01, 7.908752989295335e-01, + 8.108788692151807e-01, 8.301579139160681e-01, 8.486643364959733e-01, 8.663548164329093e-01, + 8.831896853053627e-01, 8.991320235484349e-01, 9.141540563656075e-01, 9.282282546151819e-01, + 9.413348145272842e-01, 9.534619388400459e-01, 9.646048250501910e-01, 9.747634827941575e-01, + 9.839435385219192e-01, 9.921529097154242e-01, 9.994114730415857e-01, 1.005746084650236e+00, + 1.011183971347815e+00, 1.015760373791603e+00, 1.019515072412387e+00, 1.022490937034641e+00, + 1.024736164069697e+00, 1.026304095700693e+00, 1.027250978292214e+00, 1.027634294456205e+00, + 1.027511063644843e+00, 1.026942795115598e+00, 1.025991493983836e+00, 1.024716149969084e+00, + 1.023175976163407e+00, 1.021427210603284e+00, 1.019521566634239e+00, 1.017510118327508e+00, + 1.015439859549357e+00, 1.013460916839174e+00, 1.011654901040475e+00, 1.009366925499550e+00, + 1.007263182132894e+00, 1.005313192386866e+00, 1.003508162416449e+00, 1.001840787319378e+00, + 1.000303927234380e+00, 9.988898206257559e-01, 9.975915283480670e-01, 9.964015284765968e-01, + 9.953133902427869e-01, 9.943201078053212e-01, 9.934158959186011e-01, 9.925943919208190e-01, + 9.918510277326026e-01, 9.911797988363887e-01, 9.905771957917731e-01, 9.900381047643838e-01, + 9.895594394179152e-01, 9.891371616557014e-01, 9.887684373604154e-01, 9.884497924570929e-01, + 9.881790747212391e-01, 9.879528358230726e-01, 9.877691368590689e-01, 9.876249269174586e-01, + 9.875179947346887e-01, 9.874458127312921e-01, 9.874056275509585e-01, 9.873951115886979e-01, + 9.874115368168944e-01, 9.874524849192456e-01, 9.875149888347144e-01, 9.875968894760857e-01, + 9.876951134084213e-01, 9.878075819424549e-01, 9.879311998177238e-01, 9.880640617030884e-01, + 9.882032571565917e-01, 9.883471084085503e-01, 9.884926873551375e-01, 9.886386592120545e-01, + 9.887825578295630e-01, 9.889230031022089e-01, 9.890581715933395e-01, 9.891867674284610e-01, + 9.893074965384659e-01, 9.894196399062921e-01, 9.895220757174378e-01, 9.896146331889107e-01, + 9.896970346678272e-01, 9.897692596535289e-01, 9.898319269347060e-01, 9.898852572653667e-01, + 9.899307640365727e-01, 9.899693102025343e-01, 9.900025692522435e-01, 9.900321562263099e-01, + 9.900603352632121e-01, 9.900889812894406e-01, 9.901206586012907e-01, 9.901575015155720e-01, + 9.902023946214220e-01, 9.902575406142213e-01, 9.903255289051605e-01, 9.904087914462694e-01, + 9.905096491583045e-01, 9.906303787150326e-01, 9.907727108894024e-01, 9.909387444078919e-01, + 9.911298894709990e-01, 9.913476318763218e-01, 9.915928560402563e-01, 9.918665491182922e-01, + 9.921691315380984e-01, 9.925010851461232e-01, 9.928619727154252e-01, 9.932519181564613e-01, + 9.936700207375173e-01, 9.941156069136238e-01, 9.945873147903244e-01, 9.950837402063278e-01, + 9.956033775539884e-01, 9.961439922621166e-01, 9.967034533921340e-01, 9.972793109558521e-01, + 9.978690858367024e-01, 9.984697087896268e-01, 9.990784840729244e-01, 9.996919011206490e-01, + 1.000308193833526e+00, 1.000922365901945e+00, 1.001532636590676e+00, 1.002135464655177e+00, + 1.002728111386909e+00, 1.003307449770187e+00, 1.003870934089686e+00, 1.004416038098237e+00, + 1.004940548815171e+00, 1.005442141810160e+00, 1.005919224127911e+00, 1.006370303149314e+00, + 1.006793927824538e+00, 1.007189345025525e+00, 1.007555573455895e+00, 1.007892674961336e+00, + 1.008200146369426e+00, 1.008478423284851e+00, 1.008727884997619e+00, 1.008949493525753e+00, + 1.009144112734761e+00, 1.009313224929575e+00, 1.009458241425143e+00, 1.009581280555682e+00, + 1.009684090687164e+00, 1.009768980817384e+00, 1.009838308708799e+00, 1.009894548257807e+00, + 1.009940336228694e+00, 1.009977916643680e+00, 1.010010230290263e+00, 1.010039453539107e+00, + 1.010068202038694e+00, 1.010098388689342e+00, 1.010132323996401e+00, 1.010171656775640e+00, + 1.010218096148412e+00, 1.010272524848519e+00, 1.010336490294771e+00, 1.010410221483215e+00, + 1.010494354532353e+00, 1.010588873699422e+00, 1.010693501186928e+00, 1.010808068774316e+00, + 1.010931436739342e+00, 1.011062876503041e+00, 1.011201071127927e+00, 1.011344700694417e+00, + 1.011491904228184e+00, 1.011641272406023e+00, 1.011790282474963e+00, 1.011937567254485e+00, + 1.012080125934687e+00, 1.012216235487353e+00, 1.012342907951334e+00, 1.012458183122033e+00, + 1.012558879696851e+00, 1.012642857380847e+00, 1.012706955800289e+00, 1.012748952907404e+00, + 1.012765799894453e+00, 1.012755013843985e+00, 1.012713798678211e+00, 1.012639775003457e+00, + 1.012530134411619e+00, 1.012382309473470e+00, 1.012194068117524e+00, 1.011962331100864e+00, + 1.011685173724601e+00, 1.011359143572147e+00, 1.010982135506986e+00, 1.010550715971368e+00, + 1.010062133151922e+00, 1.009512438049510e+00, 1.008898689394160e+00, 1.008215923600973e+00, + 1.007460860286395e+00, 1.006627741823389e+00, 1.005712337656749e+00, 1.004708677491086e+00, + 1.003611467285588e+00, 1.002414286392268e+00, 1.001111413242302e+00, 9.996961651093181e-01, + 9.981625949525345e-01, 9.965041017623596e-01, 9.947148884277037e-01, 9.927891912841345e-01, + 9.907199995730845e-01, 9.884793707533194e-01, 9.855347660016696e-01, 9.823765865983286e-01, + 9.789747333404933e-01, 9.751623811486372e-01, 9.708821747608998e-01, 9.660805524695870e-01, + 9.606976399184645e-01, 9.546732976073706e-01, 9.479479345282376e-01, 9.404609052933396e-01, + 9.321553861564006e-01, 9.229775478442888e-01, 9.128745354570823e-01, 9.018003682081348e-01, + 8.897163275605041e-01, 8.765908974996186e-01, 8.623984077953557e-01, 8.471200801854385e-01, + 8.307479727020245e-01, 8.132817365236141e-01, 7.947291447585267e-01, 7.751108841891807e-01, + 7.544551974836834e-01, 7.327963552921717e-01, 7.101790843209148e-01, 6.866580716267418e-01, + 6.622962432368731e-01, 6.371684119604742e-01, 6.113488038789190e-01, 5.849206604934815e-01, + 5.579747428663487e-01, 5.306181649316717e-01, 5.029523957059122e-01, 4.750868825511614e-01, + 4.471309850999535e-01, 4.192049917945288e-01, 3.914252910998820e-01, 3.639114681156252e-01, + 3.367837772954476e-01, 3.101627843160973e-01, 2.841647033392418e-01, 2.589033711808454e-01, + 2.344880603710975e-01, 2.110209448747974e-01, 1.885997642296488e-01, 1.673100807904834e-01, + 1.472287968327706e-01, 1.284223074167396e-01, 1.109422548710344e-01, 9.482665349502306e-02, + 8.009914366829558e-02, 6.676765847398403e-02, 5.482436608328485e-02, 4.424588851571281e-02, + 3.499361000717621e-02, 2.701461405056267e-02, 2.024370180670145e-02, 1.460796755137538e-02, + 9.996743588367531e-03, 5.305235098871444e-03, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00}; + +const LC3_FLOAT MDCT_WINDOW_320[640] = { + -3.021153494057143e-04, -5.867737487939294e-04, -8.366504004139796e-04, -1.126635355725494e-03, + -1.470492941694331e-03, -1.873473391018495e-03, -2.339292362082021e-03, -2.872008069419264e-03, + -3.476256385086407e-03, -4.155963816705528e-03, -4.914563787665504e-03, -5.755172503953251e-03, + -6.680623380533122e-03, -7.693816924650567e-03, -8.796760749750191e-03, -9.990503073705982e-03, + -1.127574117138621e-02, -1.265334152129685e-02, -1.412438986522702e-02, -1.568889620430290e-02, + -1.734512089366117e-02, -1.909097368362797e-02, -2.092546711168754e-02, -2.284684792818856e-02, + -2.485207716234951e-02, -2.693746704328349e-02, -2.909952486193999e-02, -3.133504629493832e-02, + -3.363960728361352e-02, -3.600820974457969e-02, -3.843601741746971e-02, -4.091746034850161e-02, + -4.344654894948344e-02, -4.601786724624048e-02, -4.862598509282497e-02, -5.126474204655663e-02, + -5.392644753556616e-02, -5.660384311081047e-02, -5.929116747072080e-02, -6.198268202511926e-02, + -6.467025548071184e-02, -6.734542216184526e-02, -7.000099017198280e-02, -7.263057011354321e-02, + -7.522784961377151e-02, -7.778525942347714e-02, -8.029480247839878e-02, -8.274924535373614e-02, + -8.514125464087215e-02, -8.746379123238275e-02, -8.971069341834263e-02, -9.187564084638347e-02, + -9.395176975347193e-02, -9.593137735886889e-02, -9.780843257659243e-02, -9.957851303827886e-02, + -1.012361165314596e-01, -1.027741036495644e-01, -1.041861222641119e-01, -1.054680247057000e-01, + -1.066160875985523e-01, -1.076255384835563e-01, -1.084912299471198e-01, -1.092087422379003e-01, + -1.097736146613313e-01, -1.101808861640070e-01, -1.104271876052675e-01, -1.105108362290460e-01, + -1.104281465492726e-01, -1.101739218186236e-01, -1.097437360338336e-01, -1.091353125572511e-01, + -1.083467335729228e-01, -1.073739938306107e-01, -1.062130155324388e-01, -1.048606145834788e-01, + -1.033132401525343e-01, -1.015673163469357e-01, -9.962005506126154e-02, -9.746803229469267e-02, + -9.510723623306666e-02, -9.253303383231506e-02, -8.974125216128212e-02, -8.672877689119252e-02, + -8.349213839083708e-02, -8.002639902061687e-02, -7.632679536516856e-02, -7.238806162166744e-02, + -6.820576796149519e-02, -6.377611429172260e-02, -5.909386001558149e-02, -5.415316322402774e-02, + -4.894812724598650e-02, -4.347347112195197e-02, -3.772461300253332e-02, -3.169587609244436e-02, + -2.538179830690266e-02, -1.877689096555516e-02, -1.187461378850388e-02, -4.669099247423082e-03, + 2.844096748870385e-03, 1.066976124794342e-02, 1.881355950582949e-02, 2.728156010437695e-02, + 3.607810469851272e-02, 4.520702759803914e-02, 5.467238802204326e-02, 6.447866054615346e-02, + 7.462862199422061e-02, 8.512490568723846e-02, 9.596983987496970e-02, 1.071650779014335e-01, + 1.187115850305241e-01, 1.306101067250375e-01, 1.428596447589721e-01, 1.554584725339102e-01, + 1.684041609371527e-01, 1.816947894623263e-01, 1.953273880886783e-01, 2.092963206850239e-01, + 2.235945635254679e-01, 2.382160219461597e-01, 2.531529721334063e-01, 2.683961570569586e-01, + 2.839361392493072e-01, 2.997624255177811e-01, 3.158619077906196e-01, 3.322210551086769e-01, + 3.488264676990591e-01, 3.656640377499646e-01, 3.827152968157059e-01, 3.999611859760947e-01, + 4.173843265025887e-01, 4.349669624916473e-01, 4.526876397402144e-01, 4.705242008503956e-01, + 4.884539254831315e-01, 5.064545550235134e-01, 5.245006748662190e-01, 5.425674372882107e-01, + 5.606312044701524e-01, 5.786672646386708e-01, 5.966477035050948e-01, 6.145458904162185e-01, + 6.323361944662236e-01, 6.499926319211774e-01, 6.674874032292857e-01, 6.847932667399612e-01, + 7.018835463513400e-01, 7.187322544823347e-01, 7.353128213893310e-01, 7.516001985652684e-01, + 7.675699252273948e-01, 7.831974571624924e-01, 7.984583859818390e-01, 8.133295347030278e-01, + 8.277892271515950e-01, 8.418178561101360e-01, 8.553961300139363e-01, 8.685068980898102e-01, + 8.811334436653052e-01, 8.932596784799233e-01, 9.048748835980528e-01, 9.159657608120536e-01, + 9.265215299450000e-01, 9.365339988633418e-01, 9.459977028429117e-01, 9.549088408436811e-01, + 9.632658122557368e-01, 9.710688896122810e-01, 9.783204156360773e-01, 9.850226760127131e-01, + 9.911792082081333e-01, 9.967989944502682e-01, 1.001894024615659e+00, 1.006474342231823e+00, + 1.010552057109195e+00, 1.014142538208007e+00, 1.017262593268930e+00, 1.019928842669923e+00, + 1.022159867011177e+00, 1.023976320927187e+00, 1.025400734608122e+00, 1.026455340400072e+00, + 1.027164510654160e+00, 1.027552729180790e+00, 1.027644462380432e+00, 1.027463246660797e+00, + 1.027035903410657e+00, 1.026389068000259e+00, 1.025548201799728e+00, 1.024537134749709e+00, + 1.023380803775376e+00, 1.022103695693341e+00, 1.020728359657958e+00, 1.019275334687329e+00, + 1.017765178792830e+00, 1.016217355867531e+00, 1.014665311686846e+00, 1.013249071090664e+00, + 1.011948006992127e+00, 1.010189090179223e+00, 1.008557961167850e+00, 1.007011287608451e+00, + 1.005548764575910e+00, 1.004168417268956e+00, 1.002867268893035e+00, 1.001641769115897e+00, + 1.000489068954641e+00, 9.994060799749374e-01, 9.983898865406841e-01, 9.974370849972721e-01, + 9.965444836911705e-01, 9.957098545943852e-01, 9.949302413030897e-01, 9.942024045863540e-01, + 9.935241604969254e-01, 9.928930430130044e-01, 9.923068103443909e-01, 9.917633778190438e-01, + 9.912597642374404e-01, 9.907954498484041e-01, 9.903677893656558e-01, 9.899751611066148e-01, + 9.896160337369861e-01, 9.892890160408989e-01, 9.889928511129679e-01, 9.887260333430423e-01, + 9.884868721088945e-01, 9.882751039537586e-01, 9.880892168751595e-01, 9.879277114724612e-01, + 9.877898261218510e-01, 9.876743442038471e-01, 9.875807496078497e-01, 9.875072021876561e-01, + 9.874529447589979e-01, 9.874169741527905e-01, 9.873984685207834e-01, 9.873958301311858e-01, + 9.874080027710336e-01, 9.874343401290739e-01, 9.874736235387018e-01, 9.875243137719285e-01, + 9.875856201221135e-01, 9.876563785063032e-01, 9.877358921155149e-01, 9.878225576787804e-01, + 9.879150968481590e-01, 9.880132731565830e-01, 9.881156946084619e-01, 9.882211314188272e-01, + 9.883289032519310e-01, 9.884378310018685e-01, 9.885476787868710e-01, 9.886568414746639e-01, + 9.887645868459630e-01, 9.888708540445242e-01, 9.889744320992592e-01, 9.890747269455915e-01, + 9.891710038703801e-01, 9.892631024032380e-01, 9.893507219573624e-01, 9.894330645494204e-01, + 9.895096919388534e-01, 9.895810813422480e-01, 9.896467469067676e-01, 9.897067365020641e-01, + 9.897606930400666e-01, 9.898094478563998e-01, 9.898530133261707e-01, 9.898914705684924e-01, + 9.899254194103574e-01, 9.899554202030650e-01, 9.899824494486951e-01, 9.900065116928948e-01, + 9.900284805353695e-01, 9.900497484789281e-01, 9.900709561632662e-01, 9.900928358611601e-01, + 9.901163920607219e-01, 9.901427479709606e-01, 9.901734275350572e-01, 9.902087332329851e-01, + 9.902498637985275e-01, 9.902983686695558e-01, 9.903548501470234e-01, 9.904205084933333e-01, + 9.904959297726740e-01, 9.905825150202904e-01, 9.906812569810133e-01, 9.907922087340426e-01, + 9.909165464981378e-01, 9.910550740962871e-01, 9.912084614290896e-01, 9.913768610980639e-01, + 9.915605826937839e-01, 9.917604214872976e-01, 9.919767175562684e-01, 9.922091101818779e-01, + 9.924579135466506e-01, 9.927231225056266e-01, 9.930049538427406e-01, 9.933027281437943e-01, + 9.936161084869942e-01, 9.939453714404443e-01, 9.942895145656371e-01, 9.946481676207727e-01, + 9.950203031067961e-01, 9.954058173659507e-01, 9.958038713694317e-01, 9.962130271017117e-01, + 9.966324689957675e-01, 9.970615306490058e-01, 9.974990583293081e-01, 9.979437430375855e-01, + 9.983940572002874e-01, 9.988493116887893e-01, 9.993083430214909e-01, 9.997689221333534e-01, + 1.000231131275969e+00, 1.000692135698996e+00, 1.001152013920163e+00, 1.001608526000461e+00, + 1.002060493867275e+00, 1.002507212061815e+00, 1.002947129400411e+00, 1.003378909587027e+00, + 1.003801368578070e+00, 1.004213810320699e+00, 1.004615386562846e+00, 1.005004618375781e+00, + 1.005380628601598e+00, 1.005743282364652e+00, 1.006091510392348e+00, 1.006424907424988e+00, + 1.006742427727669e+00, 1.007044321511378e+00, 1.007330218597112e+00, 1.007599401798709e+00, + 1.007852064386603e+00, 1.008088176165563e+00, 1.008308033204578e+00, 1.008511247273756e+00, + 1.008698144207627e+00, 1.008869515256392e+00, 1.009025659761512e+00, 1.009166718967367e+00, + 1.009293362609020e+00, 1.009406398832440e+00, 1.009507017171120e+00, 1.009595264293017e+00, + 1.009672145744679e+00, 1.009739084785160e+00, 1.009796675060142e+00, 1.009846137382005e+00, + 1.009888083631667e+00, 1.009924092276850e+00, 1.009955384765721e+00, 1.009982268770147e+00, + 1.010006298177305e+00, 1.010028618428735e+00, 1.010050254076988e+00, 1.010071952131355e+00, + 1.010094366238073e+00, 1.010118917317053e+00, 1.010146497096682e+00, 1.010177110711677e+00, + 1.010211755260102e+00, 1.010251003469427e+00, 1.010295468653759e+00, 1.010345234996637e+00, + 1.010400316698172e+00, 1.010461564316351e+00, 1.010528615445659e+00, 1.010601521285347e+00, + 1.010679788081867e+00, 1.010763905869062e+00, 1.010853429760676e+00, 1.010947547074519e+00, + 1.011045953108263e+00, 1.011148486293359e+00, 1.011254397791134e+00, 1.011363082075863e+00, + 1.011473302008831e+00, 1.011584996312149e+00, 1.011697416504599e+00, 1.011808919793469e+00, + 1.011919264025716e+00, 1.012027240794153e+00, 1.012132151631041e+00, 1.012232734564333e+00, + 1.012327560477901e+00, 1.012416383754384e+00, 1.012497890726292e+00, 1.012570434021054e+00, + 1.012633295255708e+00, 1.012685277016726e+00, 1.012725564992284e+00, 1.012752577651415e+00, + 1.012765062889864e+00, 1.012762356719162e+00, 1.012743376077777e+00, 1.012706484200181e+00, + 1.012650842226435e+00, 1.012575427778520e+00, 1.012479473490919e+00, 1.012361105121003e+00, + 1.012219809594718e+00, 1.012054359992419e+00, 1.011864000215460e+00, 1.011647223869087e+00, + 1.011402518267713e+00, 1.011129654652857e+00, 1.010826951260377e+00, 1.010492924436361e+00, + 1.010126353960416e+00, 1.009725892479312e+00, 1.009290060983833e+00, 1.008817301052548e+00, + 1.008305027555130e+00, 1.007752833675443e+00, 1.007157827358150e+00, 1.006518049344503e+00, + 1.005831403532018e+00, 1.005095592119373e+00, 1.004308630055050e+00, 1.003467498305776e+00, + 1.002569500413888e+00, 1.001612710105563e+00, 1.000594272975683e+00, 9.995111701168786e-01, + 9.983609218719522e-01, 9.971409288327860e-01, 9.958488863050556e-01, 9.944818543153893e-01, + 9.930375282832211e-01, 9.915146560759479e-01, 9.899136802423638e-01, 9.881930623810997e-01, + 9.859422591203311e-01, 9.835667898378924e-01, 9.811423034808365e-01, 9.785214441250228e-01, + 9.756636036109838e-01, 9.725453442532574e-01, 9.691456634185092e-01, 9.654406178310209e-01, + 9.614043615076308e-01, 9.570113065179300e-01, 9.522367669696690e-01, 9.470548839544214e-01, + 9.414403740008491e-01, 9.353691612846549e-01, 9.288190093977164e-01, 9.217662887169115e-01, + 9.141896283466009e-01, 9.060694681113471e-01, 8.973891675497357e-01, 8.881332000806269e-01, + 8.782893885841422e-01, 8.678469565343039e-01, 8.567970644671067e-01, 8.451334654019180e-01, + 8.328542805780399e-01, 8.199594783897041e-01, 8.064511006873497e-01, 7.923346478686025e-01, + 7.776204488292163e-01, 7.623206183595970e-01, 7.464486491227057e-01, 7.300205729992958e-01, + 7.130567383226717e-01, 6.955805444755916e-01, 6.776173229836567e-01, 6.591955305148172e-01, + 6.403486426892321e-01, 6.211072197441818e-01, 6.015049275244730e-01, 5.815787608870452e-01, + 5.613674511156324e-01, 5.409188627354076e-01, 5.202736834971303e-01, 4.994780733459294e-01, + 4.785774177949064e-01, 4.576172599874928e-01, 4.366490208265804e-01, 4.157221460415995e-01, + 3.948856590950757e-01, 3.741903189229770e-01, 3.536868899553974e-01, 3.334260017756462e-01, + 3.134586473252229e-01, 2.938337904395871e-01, 2.745992637590817e-01, 2.558030636168172e-01, + 2.374902188466697e-01, 2.197036032185785e-01, 2.024855415115456e-01, 1.858749915117319e-01, + 1.699067802117410e-01, 1.546132267478873e-01, 1.400238206749695e-01, 1.261637395672913e-01, + 1.130534434072719e-01, 1.007084973747940e-01, 8.914024389873081e-02, 7.835612100141792e-02, + 6.835821233920988e-02, 5.914211536028976e-02, 5.069893012340832e-02, 4.301717763585550e-02, + 3.608020726673359e-02, 2.986316337017630e-02, 2.433722657129812e-02, 1.947675241971700e-02, + 1.525710171255895e-02, 1.163787492636240e-02, 8.433087782643718e-03, 4.449668997344735e-03, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00}; + +const LC3_FLOAT MDCT_WINDOW_480[960] = { + -2.353032150516754e-04, -4.619898752628163e-04, -6.262931535610879e-04, -7.929180432976445e-04, + -9.747166718929050e-04, -1.180256894474562e-03, -1.409209039594871e-03, -1.664473096973725e-03, + -1.946591608170231e-03, -2.257081732588478e-03, -2.597106916737789e-03, -2.967607624839524e-03, + -3.370454877988472e-03, -3.806285163352241e-03, -4.276873767639064e-03, -4.782469904501813e-03, + -5.324608721716763e-03, -5.903403814095400e-03, -6.520419726599805e-03, -7.175885277771099e-03, + -7.871422820642307e-03, -8.606586039759667e-03, -9.382480860899108e-03, -1.019827182163307e-02, + -1.105520547739066e-02, -1.195270300743193e-02, -1.289205910303846e-02, -1.387263484323160e-02, + -1.489528159506296e-02, -1.595856621933800e-02, -1.706288556735433e-02, -1.820666399965468e-02, + -1.939065975232718e-02, -2.061355417582714e-02, -2.187570925786862e-02, -2.317526315266411e-02, + -2.451227449041489e-02, -2.588471937157619e-02, -2.729263737090799e-02, -2.873390902713615e-02, + -3.020862738245264e-02, -3.171440372994384e-02, -3.325098858986303e-02, -3.481597793538342e-02, + -3.640892406933019e-02, -3.802742318209150e-02, -3.967067992672979e-02, -4.133575417353826e-02, + -4.302203371734278e-02, -4.472698045914417e-02, -4.645022292934329e-02, -4.818891490266687e-02, + -4.994225863256500e-02, -5.170690802826666e-02, -5.348162036097223e-02, -5.526334794593565e-02, + -5.705123152423822e-02, -5.884271749745559e-02, -6.063717235243996e-02, -6.243104027829089e-02, + -6.422303545004304e-02, -6.600961519440657e-02, -6.778962269634495e-02, -6.955996868581379e-02, + -7.131966266443390e-02, -7.306581273272733e-02, -7.479758913001458e-02, -7.651178225890490e-02, + -7.820711420768856e-02, -7.988010693411644e-02, -8.152964005319532e-02, -8.315237353264004e-02, + -8.474728946770714e-02, -8.631137544905677e-02, -8.784374452959058e-02, -8.934164364321417e-02, + -9.080411291245728e-02, -9.222795761428432e-02, -9.361232867223340e-02, -9.495377758870335e-02, + -9.625155313139856e-02, -9.750284620437569e-02, -9.870736514214426e-02, -9.986271288271026e-02, + -1.009680221406219e-01, -1.020202684361974e-01, -1.030183804850491e-01, -1.039596356759290e-01, + -1.048438825017798e-01, -1.056686838192766e-01, -1.064342821660323e-01, -1.071382314127799e-01, + -1.077799961121537e-01, -1.083570625865931e-01, -1.088690135027248e-01, -1.093135588677235e-01, + -1.096903559498340e-01, -1.099969655786929e-01, -1.102332261219973e-01, -1.103972812085189e-01, + -1.104898474883336e-01, -1.105086416532167e-01, -1.104537426996073e-01, -1.103225838568563e-01, + -1.101145827722143e-01, -1.098276928170364e-01, -1.094621746650760e-01, -1.090163960055733e-01, + -1.084908852561722e-01, -1.078834293141886e-01, -1.071937180231978e-01, -1.064196358069465e-01, + -1.055612509762041e-01, -1.046162812518618e-01, -1.035849043557610e-01, -1.024650162703341e-01, + -1.012568997532046e-01, -9.995864571932928e-02, -9.857014566194627e-02, -9.708911135857967e-02, + -9.551545820689084e-02, -9.384684920715425e-02, -9.208300062891550e-02, -9.022171021406450e-02, + -8.826309993000785e-02, -8.620493821803937e-02, -8.404742152815330e-02, -8.178792716809512e-02, + -7.942625026703617e-02, -7.695980775819990e-02, -7.438785600211463e-02, -7.170797002873608e-02, + -6.891994783815969e-02, -6.602189797715241e-02, -6.301349420724424e-02, -5.989191912667712e-02, + -5.665655641133161e-02, -5.330406164482222e-02, -4.983427241976235e-02, -4.624456893420224e-02, + -4.253455686336916e-02, -3.870195772538443e-02, -3.474585776145929e-02, -3.066341518682682e-02, + -2.645425077642105e-02, -2.211581608120528e-02, -1.764740541599136e-02, -1.304581363895818e-02, + -8.310425696208936e-03, -3.438268661133170e-03, 1.570315476576933e-03, 6.717697635290676e-03, + 1.200477020244778e-02, 1.743398319747869e-02, 2.300642061077823e-02, 2.872481423270595e-02, + 3.458896350634671e-02, 4.060106462625085e-02, 4.676102915752826e-02, 5.307133911821893e-02, + 5.953239090915557e-02, 6.614647812869151e-02, 7.291293184312803e-02, 7.983354189816511e-02, + 8.690807412770696e-02, 9.413813765275064e-02, 1.015233140203748e-01, 1.090651518336202e-01, + 1.167626546016197e-01, 1.246171387327525e-01, 1.326272948938113e-01, 1.407938190608664e-01, + 1.491152519299797e-01, 1.575921408388593e-01, 1.662224799248571e-01, 1.750067399059861e-01, + 1.839431938620024e-01, 1.930318183054904e-01, 2.022699854906251e-01, 2.116567430906184e-01, + 2.211888523410642e-01, 2.308655379767671e-01, 2.406837992341654e-01, 2.506420640291662e-01, + 2.607365124918583e-01, 2.709659073501196e-01, 2.813259021832532e-01, 2.918144694729168e-01, + 3.024270279840051e-01, 3.131603499997996e-01, 3.240095704645023e-01, 3.349719592361666e-01, + 3.460422935204829e-01, 3.572175180786021e-01, 3.684915649120530e-01, 3.798595119591716e-01, + 3.913146885756875e-01, 4.028532873867052e-01, 4.144688328137527e-01, 4.261571642320424e-01, + 4.379113897565727e-01, 4.497256320417501e-01, 4.615925445090212e-01, 4.735067030065239e-01, + 4.854600184866710e-01, 4.974471592901086e-01, 5.094597228333853e-01, 5.214909841729947e-01, + 5.335326819631583e-01, 5.455789811615239e-01, 5.576217157959890e-01, 5.696546730080154e-01, + 5.816685576268035e-01, 5.936560624526468e-01, 6.056083823929643e-01, 6.175192060085208e-01, + 6.293796611336280e-01, 6.411830842823245e-01, 6.529203544876097e-01, 6.645840786371451e-01, + 6.761653499550255e-01, 6.876573952173626e-01, 6.990511539119996e-01, 7.103400549562944e-01, + 7.215149331458728e-01, 7.325691772738999e-01, 7.434943718765665e-01, 7.542846327442048e-01, + 7.649313654540612e-01, 7.754281892901473e-01, 7.857670170752049e-01, 7.959414651061612e-01, + 8.059437233154637e-01, 8.157687070715176e-01, 8.254086223972127e-01, 8.348589373399948e-01, + 8.441125827416620e-01, 8.531651194538425e-01, 8.620108336276733e-01, 8.706456337542150e-01, + 8.790631561061171e-01, 8.872599706865123e-01, 8.952313288619367e-01, 9.029751680353524e-01, + 9.104863121445679e-01, 9.177625550620636e-01, 9.247997426966093e-01, 9.315962496426278e-01, + 9.381494858921667e-01, 9.444588390359354e-01, 9.505220861927248e-01, 9.563402921286364e-01, + 9.619114522936701e-01, 9.672366712325431e-01, 9.723156637834687e-01, 9.771501187120180e-01, + 9.817397501303696e-01, 9.860865871353246e-01, 9.901906380163595e-01, 9.940557180662704e-01, + 9.976842395284637e-01, 1.001080961257010e+00, 1.004247514102417e+00, 1.007188578458507e+00, + 1.009906654565108e+00, 1.012407428282884e+00, 1.014694702432600e+00, 1.016774659209400e+00, + 1.018650990561848e+00, 1.020330464463111e+00, 1.021817328911793e+00, 1.023118841384460e+00, + 1.024240262467000e+00, 1.025189721888128e+00, 1.025972450969440e+00, 1.026596938589443e+00, + 1.027069179375841e+00, 1.027397523939210e+00, 1.027587902203109e+00, 1.027648951922701e+00, + 1.027585830688143e+00, 1.027408519661012e+00, 1.027122986826984e+00, 1.026738673647482e+00, + 1.026261663878092e+00, 1.025701002415063e+00, 1.025061777648234e+00, 1.024353980976701e+00, + 1.023582385618774e+00, 1.022756514615106e+00, 1.021880604350422e+00, 1.020963871317665e+00, + 1.020009139549275e+00, 1.019027285501251e+00, 1.018019442784231e+00, 1.016996499560845e+00, + 1.015957433206324e+00, 1.014923441259795e+00, 1.013915946100629e+00, 1.013047565149327e+00, + 1.012216130365610e+00, 1.011044869639164e+00, 1.009914592130044e+00, 1.008824888092573e+00, + 1.007773858455400e+00, 1.006761700412993e+00, 1.005786648810854e+00, 1.004848753962734e+00, + 1.003946083413733e+00, 1.003078846506546e+00, 1.002245009135684e+00, 1.001444733905817e+00, + 1.000676188436651e+00, 9.999393169239009e-01, 9.992320848298057e-01, 9.985548127155425e-01, + 9.979055415627330e-01, 9.972842679758880e-01, 9.966890948441745e-01, 9.961203379971326e-01, + 9.955761256313581e-01, 9.950565724564597e-01, 9.945597525471822e-01, 9.940860378486615e-01, + 9.936337788972491e-01, 9.932031606606759e-01, 9.927921871265732e-01, 9.924015177880798e-01, + 9.920297273323891e-01, 9.916767775088281e-01, 9.913408767719142e-01, 9.910230654424902e-01, + 9.907216425865902e-01, 9.904366799536263e-01, 9.901668953434221e-01, 9.899131011580791e-01, + 9.896735637374597e-01, 9.894488374513719e-01, 9.892374835404283e-01, 9.890401927796704e-01, + 9.888556356037892e-01, 9.886843467692753e-01, 9.885247606051014e-01, 9.883778520531268e-01, + 9.882423270582524e-01, 9.881185638915363e-01, 9.880051626345804e-01, 9.879032023766432e-01, + 9.878111744348976e-01, 9.877295459610343e-01, 9.876571983429736e-01, 9.875949843246187e-01, + 9.875412739766566e-01, 9.874969061399389e-01, 9.874606249127551e-01, 9.874329809802893e-01, + 9.874126414437681e-01, 9.874004750404033e-01, 9.873949921033299e-01, 9.873969162747074e-01, + 9.874049060317581e-01, 9.874197049003676e-01, 9.874399717110517e-01, 9.874663281231737e-01, + 9.874973205882319e-01, 9.875338926695315e-01, 9.875746535410983e-01, 9.876201238703241e-01, + 9.876689801932402e-01, 9.877221556193183e-01, 9.877781920433015e-01, 9.878376489591358e-01, + 9.878991990245439e-01, 9.879637979933339e-01, 9.880300303653743e-01, 9.880984675859855e-01, + 9.881678007807095e-01, 9.882390300097154e-01, 9.883107693992456e-01, 9.883835200189653e-01, + 9.884560159878955e-01, 9.885294200392185e-01, 9.886022219397892e-01, 9.886749404176028e-01, + 9.887466261142505e-01, 9.888182771263505e-01, 9.888882480852147e-01, 9.889574384705896e-01, + 9.890247977602895e-01, 9.890911247701029e-01, 9.891551701556196e-01, 9.892178658748239e-01, + 9.892779555818088e-01, 9.893365186903538e-01, 9.893923680007577e-01, 9.894462830852175e-01, + 9.894972124952000e-01, 9.895463342815009e-01, 9.895923617530382e-01, 9.896362652966239e-01, + 9.896772011542693e-01, 9.897162195263046e-01, 9.897520286480039e-01, 9.897859195209235e-01, + 9.898170267411330e-01, 9.898462068764986e-01, 9.898725363809847e-01, 9.898975138787787e-01, + 9.899200050208486e-01, 9.899410789223559e-01, 9.899600605054418e-01, 9.899782261038060e-01, + 9.899945557067980e-01, 9.900103500807507e-01, 9.900248320990181e-01, 9.900394023736973e-01, + 9.900532105829365e-01, 9.900674746047259e-01, 9.900814722948890e-01, 9.900966926051257e-01, + 9.901122448734595e-01, 9.901293790312005e-01, 9.901474648912307e-01, 9.901680598867444e-01, + 9.901902265696609e-01, 9.902151896501201e-01, 9.902424418296485e-01, 9.902734448815004e-01, + 9.903071270768942e-01, 9.903448913950654e-01, 9.903862280081246e-01, 9.904324484666853e-01, + 9.904825650601110e-01, 9.905379830873822e-01, 9.905980602136440e-01, 9.906640366554630e-01, + 9.907348826312993e-01, 9.908120376822228e-01, 9.908947858311721e-01, 9.909842592301273e-01, + 9.910795247770178e-01, 9.911819240108124e-01, 9.912905118607647e-01, 9.914064705361564e-01, + 9.915288011543961e-01, 9.916586940166509e-01, 9.917952720685562e-01, 9.919396217291009e-01, + 9.920906151219310e-01, 9.922495028313456e-01, 9.924152398352751e-01, 9.925887208794144e-01, + 9.927688708468421e-01, 9.929569112537944e-01, 9.931516528513824e-01, 9.933539244159140e-01, + 9.935626893131695e-01, 9.937790866568735e-01, 9.940016434044485e-01, 9.942312024833810e-01, + 9.944668184371617e-01, 9.947093441694513e-01, 9.949572854565533e-01, 9.952116634297566e-01, + 9.954712635321227e-01, 9.957367951478069e-01, 9.960068616185641e-01, 9.962823025614079e-01, + 9.965617986382630e-01, 9.968461329825753e-01, 9.971338271912752e-01, 9.974256691222113e-01, + 9.977203369515556e-01, 9.980185087055744e-01, 9.983185871761977e-01, 9.986213520769593e-01, + 9.989255426466267e-01, 9.992317314100975e-01, 9.995382582242990e-01, 9.998461160718275e-01, + 1.000153907612080e+00, 1.000461955079660e+00, 1.000768859280338e+00, 1.001075613053728e+00, + 1.001380551217109e+00, 1.001684244734497e+00, 1.001985425397567e+00, 1.002284871786226e+00, + 1.002580975161843e+00, 1.002874411368430e+00, 1.003163845364970e+00, 1.003450063374329e+00, + 1.003731570287893e+00, 1.004009147462043e+00, 1.004281457582935e+00, 1.004549339226336e+00, + 1.004811375053364e+00, 1.005068272394360e+00, 1.005318795748286e+00, 1.005563968008037e+00, + 1.005802269635282e+00, 1.006034554002353e+00, 1.006259855360867e+00, 1.006479018139540e+00, + 1.006690541428116e+00, 1.006895570408563e+00, 1.007093045696527e+00, 1.007283799246233e+00, + 1.007466616298057e+00, 1.007642728426847e+00, 1.007811036585595e+00, 1.007972441990187e+00, + 1.008125875904472e+00, 1.008272602383284e+00, 1.008411468616852e+00, 1.008543573152632e+00, + 1.008668018334797e+00, 1.008786009787269e+00, 1.008896526233555e+00, 1.009000766336071e+00, + 1.009097763850333e+00, 1.009188880897370e+00, 1.009273163797313e+00, 1.009351762546296e+00, + 1.009423944949143e+00, 1.009491175244507e+00, 1.009552401900961e+00, 1.009608886895764e+00, + 1.009659973830751e+00, 1.009707093778162e+00, 1.009749238562067e+00, 1.009787744284661e+00, + 1.009822090220407e+00, 1.009853706282597e+00, 1.009881498943010e+00, 1.009906958448099e+00, + 1.009929567021562e+00, 1.009950573483366e+00, 1.009969021400474e+00, 1.009986499185054e+00, + 1.010002363879044e+00, 1.010017890428877e+00, 1.010032170180360e+00, 1.010046722045583e+00, + 1.010060809299530e+00, 1.010075674445289e+00, 1.010090449982098e+00, 1.010106564965965e+00, + 1.010123226584120e+00, 1.010141762173145e+00, 1.010161131093372e+00, 1.010182635897876e+00, + 1.010205587931660e+00, 1.010231078494249e+00, 1.010257950227988e+00, 1.010287732968580e+00, + 1.010319484524512e+00, 1.010354079663767e+00, 1.010390635488037e+00, 1.010430470494512e+00, + 1.010472266495074e+00, 1.010517096381509e+00, 1.010564099281000e+00, 1.010614266894512e+00, + 1.010666285876455e+00, 1.010721360243234e+00, 1.010778416755264e+00, 1.010838252644461e+00, + 1.010899655674578e+00, 1.010963729626641e+00, 1.011029191301694e+00, 1.011096993993037e+00, + 1.011165861239173e+00, 1.011236610341260e+00, 1.011308167670753e+00, 1.011381453638912e+00, + 1.011454785713102e+00, 1.011529185153809e+00, 1.011603680910505e+00, 1.011678803938046e+00, + 1.011753008569803e+00, 1.011827484797985e+00, 1.011900936547881e+00, 1.011973876511603e+00, + 1.012044885003304e+00, 1.012114985644919e+00, 1.012182837094955e+00, 1.012249023976742e+00, + 1.012312095063070e+00, 1.012373028737774e+00, 1.012430463679316e+00, 1.012484972246822e+00, + 1.012535058602453e+00, 1.012581678169188e+00, 1.012623472898504e+00, 1.012660975529858e+00, + 1.012692758750213e+00, 1.012719789201144e+00, 1.012740575296603e+00, 1.012755753887085e+00, + 1.012763948841204e+00, 1.012765922449960e+00, 1.012760298661069e+00, 1.012747819936584e+00, + 1.012726958954961e+00, 1.012698607692183e+00, 1.012661400539405e+00, 1.012615904116265e+00, + 1.012560833005713e+00, 1.012497050269805e+00, 1.012422888521601e+00, 1.012339226241367e+00, + 1.012244921966297e+00, 1.012140460211194e+00, 1.012024302085441e+00, 1.011897560567707e+00, + 1.011758810583150e+00, 1.011608449127642e+00, 1.011445162723270e+00, 1.011269960947744e+00, + 1.011081255645969e+00, 1.010879608424312e+00, 1.010663676735228e+00, 1.010434184200640e+00, + 1.010189681124657e+00, 1.009930754807923e+00, 1.009655660215271e+00, 1.009365251564694e+00, + 1.009058249873833e+00, 1.008734758578989e+00, 1.008393079963091e+00, 1.008034308295421e+00, + 1.007656661215973e+00, 1.007260142622887e+00, 1.006843352506855e+00, 1.006407009542103e+00, + 1.005949145170711e+00, 1.005470005637052e+00, 1.004967986424467e+00, 1.004443531995945e+00, + 1.003894772403371e+00, 1.003321903663793e+00, 1.002723127308148e+00, 1.002098854400575e+00, + 1.001447278873483e+00, 1.000768505317086e+00, 1.000060686758758e+00, 9.993242684851855e-01, + 9.985573503390627e-01, 9.977600196406868e-01, 9.969306036935497e-01, 9.960694269553644e-01, + 9.951746430061121e-01, 9.942466438407230e-01, 9.932837131068657e-01, 9.922861082472264e-01, + 9.912523092989319e-01, 9.901827419790691e-01, 9.890757868707590e-01, 9.879313024174022e-01, + 9.863553220272523e-01, 9.847362453480265e-01, 9.831750948772566e-01, 9.815583336011345e-01, + 9.798613526271561e-01, 9.780617486993630e-01, 9.761574317374303e-01, 9.741378617337759e-01, + 9.719990112065752e-01, 9.697327413658168e-01, 9.673331975559332e-01, 9.647915124057732e-01, + 9.621011497566145e-01, 9.592539757044516e-01, 9.562427177295731e-01, 9.530600909726344e-01, + 9.496984081652284e-01, 9.461498120176854e-01, 9.424071613625743e-01, 9.384634163826711e-01, + 9.343112966094085e-01, 9.299449872197452e-01, 9.253567968750328e-01, 9.205404627076625e-01, + 9.154896280575360e-01, 9.101986790930605e-01, 9.046620597741508e-01, 8.988755194372424e-01, + 8.928338316495705e-01, 8.865337190368053e-01, 8.799712722567934e-01, 8.731437835983047e-01, + 8.660476534563131e-01, 8.586812520174252e-01, 8.510420440685049e-01, 8.431297226886574e-01, + 8.349435141989714e-01, 8.264839911291133e-01, 8.177505366573690e-01, 8.087449817124315e-01, + 7.994681492797084e-01, 7.899235162194718e-01, 7.801137731566502e-01, 7.700431275216928e-01, + 7.597145736971065e-01, 7.491330971820804e-01, 7.383028603058783e-01, 7.272298755824693e-01, + 7.159201919962611e-01, 7.043814340356083e-01, 6.926196927377140e-01, 6.806438831866077e-01, + 6.684616478236647e-01, 6.560830137986515e-01, 6.435179268559957e-01, 6.307755329382612e-01, + 6.178641647786525e-01, 6.047954625702541e-01, 5.915799587176216e-01, 5.782289366005894e-01, + 5.647535885752191e-01, 5.511703155400274e-01, 5.374905090437071e-01, 5.237263500445715e-01, + 5.098915423728255e-01, 4.960008074926423e-01, 4.820662943337458e-01, 4.681017110048007e-01, + 4.541216995958746e-01, 4.401421815729068e-01, 4.261772971493010e-01, 4.122417888542512e-01, + 3.983499612526493e-01, 3.845172335531009e-01, 3.707583717376236e-01, 3.570886786795506e-01, + 3.435228672445627e-01, 3.300763764703638e-01, 3.167640325043893e-01, 3.036004651973109e-01, + 2.905996158436682e-01, 2.777758503744847e-01, 2.651434678028531e-01, 2.527161881181577e-01, + 2.405069849650012e-01, 2.285283969438072e-01, 2.167933432162879e-01, 2.053139897833021e-01, + 1.941021906320988e-01, 1.831680872008943e-01, 1.725221947208913e-01, 1.621735416384834e-01, + 1.521320683467849e-01, 1.424052801149985e-01, 1.330015240938615e-01, 1.239260664828526e-01, + 1.151858295527293e-01, 1.067840430193724e-01, 9.872637505002878e-02, 9.101379000888035e-02, + 8.365057236623055e-02, 7.663508305536153e-02, 6.997033405748826e-02, 6.365188111381365e-02, + 5.768176015814392e-02, 5.205244216987966e-02, 4.676538412257621e-02, 4.180950541438362e-02, + 3.718640251368464e-02, 3.288072750732215e-02, 2.889548499582958e-02, 2.520980565928884e-02, + 2.183057564646272e-02, 1.872896194002638e-02, 1.592127815153420e-02, 1.336381425803020e-02, + 1.108558877807282e-02, 8.943474189364638e-03, 6.758124889697787e-03, 3.504438130619497e-03, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00}; + +const LC3_FLOAT MDCT_WINDOW_80_5ms[80] = { + 9.959086585790517e-04, 3.819056787237678e-03, 9.540832613229890e-03, 1.921659800166160e-02, 3.382719081038548e-02, + 5.424831667522354e-02, 8.120777668775610e-02, 1.152171887125930e-01, 1.564942331034909e-01, 2.049363422022628e-01, + 2.601166575816199e-01, 3.212814164616093e-01, 3.873472997948746e-01, 4.569497078592333e-01, 5.285192958868393e-01, + 6.003522489375573e-01, 6.706896380227332e-01, 7.378044458510402e-01, 8.000925313431716e-01, 8.561409184410547e-01, + 9.048272294524792e-01, 9.453685031730190e-01, 9.773507430600533e-01, 1.000800872826561e+00, 1.016171590112097e+00, + 1.024315247630982e+00, 1.026415431432931e+00, 1.023858366571912e+00, 1.018135705524407e+00, 1.010794822557756e+00, + 1.003406509762925e+00, 9.967831265986109e-01, 9.920995520917141e-01, 9.892206942816891e-01, 9.879658322200813e-01, + 9.881273531631907e-01, 9.894805541465801e-01, 9.917849916000535e-01, 9.947847580943504e-01, 9.982119669301160e-01, + 1.001791235858836e+00, 1.005242583245485e+00, 1.008283053756130e+00, 1.010631281038659e+00, 1.012015300253356e+00, + 1.012180753005270e+00, 1.010896765282633e+00, 1.007963362035220e+00, 1.003227255072391e+00, 9.966050551498514e-01, + 9.868284225039941e-01, 9.731250287581631e-01, 9.540636479502398e-01, 9.283864275822276e-01, 8.950916858157935e-01, + 8.534769362643825e-01, 8.032090930429980e-01, 7.444735201251689e-01, 6.780787033699449e-01, 6.053970453856138e-01, + 5.282077505750667e-01, 4.486552956056635e-01, 3.691875990296312e-01, 2.924566408966777e-01, 2.210718537110463e-01, + 1.573148583944309e-01, 1.030525757797768e-01, 5.982732244758054e-02, 2.871831923385133e-02, 9.683884928956490e-03, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00}; + +const LC3_FLOAT MDCT_WINDOW_160_5ms[160] = { + 6.143388180964179e-04, 1.489582832987000e-03, 2.884104959764029e-03, 4.934298832466617e-03, 7.779130464154915e-03, + 1.154910606525086e-02, 1.637155619860352e-02, 2.237116158648752e-02, 2.966159685753317e-02, 3.835663329277230e-02, + 4.855610986150206e-02, 6.035055738891727e-02, 7.382288203064732e-02, 8.903563687211119e-02, 1.060356225286319e-01, + 1.248534855777947e-01, 1.454931890869180e-01, 1.679435556337752e-01, 1.921728622634411e-01, 2.181238261985594e-01, + 2.457259744642953e-01, 2.748839432649996e-01, 3.054824712370942e-01, 3.373873799614014e-01, 3.704415932452488e-01, + 4.044749630814483e-01, 4.393004362003260e-01, 4.747225454237193e-01, 5.105341492548225e-01, 5.465201916422433e-01, + 5.824658100332457e-01, 6.181452662624718e-01, 6.533411462740817e-01, 6.878367295965062e-01, 7.214176027060971e-01, + 7.538887973483771e-01, 7.850546571907628e-01, 8.147397447696774e-01, 8.427819363777799e-01, 8.690376742017057e-01, + 8.933935477349644e-01, 9.157483563218768e-01, 9.360270196617569e-01, 9.541731142261065e-01, 9.701635474343885e-01, + 9.840036439809510e-01, 9.957199420334376e-01, 1.005374268639838e+00, 1.013046655758663e+00, 1.018843380560658e+00, + 1.022896948293643e+00, 1.025355286710874e+00, 1.026382881625701e+00, 1.026155530733488e+00, 1.024853974580724e+00, + 1.022664602721801e+00, 1.019779396547454e+00, 1.016391686789653e+00, 1.012697033320358e+00, 1.008885191761748e+00, + 1.005378742804807e+00, 1.001563778373068e+00, 9.982531564931281e-01, 9.954346644968789e-01, 9.930950268060122e-01, + 9.912170911359961e-01, 9.897805192546195e-01, 9.887624937408933e-01, 9.881383235740961e-01, 9.878819413827574e-01, + 9.879662130250981e-01, 9.883630508181326e-01, 9.890434070785485e-01, 9.899772316163624e-01, 9.911334564321237e-01, + 9.924800441092685e-01, 9.939841207305906e-01, 9.956121471675398e-01, 9.973300590248015e-01, 9.991033633647473e-01, + 1.000897441314013e+00, 1.002677088643863e+00, 1.004407190937699e+00, 1.006052289109999e+00, 1.007576934100958e+00, + 1.008945862447015e+00, 1.010124241309341e+00, 1.011077969726137e+00, 1.011773962181442e+00, 1.012180362866919e+00, + 1.012266707295288e+00, 1.012004064757857e+00, 1.011365223023975e+00, 1.010324996851905e+00, 1.008860731864438e+00, + 1.006952983357691e+00, 1.004586273379809e+00, 1.001749900308864e+00, 9.984386632116344e-01, 9.946500332901397e-01, + 9.895756853352172e-01, 9.838303127859196e-01, 9.769999155793757e-01, 9.689141159310996e-01, 9.594038121639412e-01, + 9.483086322505029e-01, 9.354860218216989e-01, 9.208101305030523e-01, 9.041732260327581e-01, 8.854882249661838e-01, + 8.646864947605046e-01, 8.417237467711145e-01, 8.165875713256009e-01, 7.892986353718001e-01, 7.599171886893816e-01, + 7.285474515411827e-01, 6.953282935906302e-01, 6.604334017809461e-01, 6.240661431421666e-01, 5.864461424698465e-01, + 5.478160663871147e-01, 5.084499758302218e-01, 4.686361426418982e-01, 4.286789889246253e-01, 3.889032719013045e-01, + 3.496431418636314e-01, 3.112360816586544e-01, 2.740128472224535e-01, 2.382847225401666e-01, 2.043379825955252e-01, + 1.724305860483632e-01, 1.427939789949265e-01, 1.156385879569741e-01, 9.115821766571995e-02, 6.952749039054593e-02, + 5.088975408628225e-02, 3.533430192568954e-02, 2.286680405144430e-02, 1.338005016725895e-02, 6.640506529168652e-03, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00}; + +const LC3_FLOAT MDCT_WINDOW_240_5ms[240] = { + 5.087227626168386e-04, 9.959086585790517e-04, 1.682208006328800e-03, 2.609697259047744e-03, 3.819056787237678e-03, + 5.349319592933909e-03, 7.243906383895192e-03, 9.540832613229890e-03, 1.227637642543709e-02, 1.548950238899404e-02, + 1.921659800166160e-02, 2.349369619441617e-02, 2.835199581667961e-02, 3.382719081038548e-02, 3.994939538719628e-02, + 4.674775238543380e-02, 5.424831667522354e-02, 6.247770776443612e-02, 7.145835917501348e-02, 8.120777668775610e-02, + 9.174400412319896e-02, 1.030764959637497e-01, 1.152171887125930e-01, 1.281665713944242e-01, 1.419264381068653e-01, + 1.564942331034909e-01, 1.718593189799504e-01, 1.880134254543744e-01, 2.049363422022628e-01, 2.226123055761096e-01, + 2.410151242797736e-01, 2.601166575816199e-01, 2.798871008989962e-01, 3.002880135563586e-01, 3.212814164616093e-01, + 3.428208463088390e-01, 3.648596557863134e-01, 3.873472997948746e-01, 4.102294951869188e-01, 4.334494534591082e-01, + 4.569497078592333e-01, 4.806696403251166e-01, 5.045473815014847e-01, 5.285192958868393e-01, 5.525196099932443e-01, + 5.764872452085427e-01, 6.003522489375573e-01, 6.240509872809882e-01, 6.475182586093196e-01, 6.706896380227332e-01, + 6.935029068990036e-01, 7.158927516396895e-01, 7.378044458510402e-01, 7.591787241845952e-01, 7.799586608897265e-01, + 8.000925313431716e-01, 8.195318652294690e-01, 8.382288957404715e-01, 8.561409184410547e-01, 8.732316951214179e-01, + 8.894702022170831e-01, 9.048272294524792e-01, 9.192736375782965e-01, 9.327940405054362e-01, 9.453685031730190e-01, + 9.569883933538136e-01, 9.676486424195593e-01, 9.773507430600533e-01, 9.861027831072527e-01, 9.939122412655677e-01, + 1.000800872826561e+00, 1.006787811971719e+00, 1.011901269172423e+00, 1.016171590112097e+00, 1.019636414864842e+00, + 1.022336613864005e+00, 1.024315247630982e+00, 1.025621299895396e+00, 1.026303439275662e+00, 1.026415431432931e+00, + 1.026007933174836e+00, 1.025137435167917e+00, 1.023858366571912e+00, 1.022226936424625e+00, 1.020300550334848e+00, + 1.018135705524407e+00, 1.015792146756340e+00, 1.013325966774524e+00, 1.010794822557756e+00, 1.008265131568879e+00, + 1.006046874304407e+00, 1.003406509762925e+00, 1.000977398831985e+00, 9.987704535700208e-01, 9.967831265986109e-01, + 9.950118905889862e-01, 9.934523971504882e-01, 9.920995520917141e-01, 9.909475998606236e-01, 9.899902426925508e-01, + 9.892206942816891e-01, 9.886318043013834e-01, 9.882160904669929e-01, 9.879658322200813e-01, 9.878730767519871e-01, + 9.879296932443894e-01, 9.881273531631907e-01, 9.884575535474619e-01, 9.889115869213529e-01, 9.894805541465801e-01, + 9.901553455166457e-01, 9.909266562913843e-01, 9.917849916000535e-01, 9.927206838643636e-01, 9.937239208721489e-01, + 9.947847580943504e-01, 9.958931493776203e-01, 9.970389567617592e-01, 9.982119669301160e-01, 9.994020338838508e-01, + 1.000598323893564e+00, 1.001791235858836e+00, 1.002969837054169e+00, 1.004123786397111e+00, 1.005242583245485e+00, + 1.006315717067918e+00, 1.007332693127034e+00, 1.008283053756130e+00, 1.009156423082384e+00, 1.009942535308151e+00, + 1.010631281038659e+00, 1.011212744622770e+00, 1.011677230257499e+00, 1.012015300253356e+00, 1.012217779097186e+00, + 1.012275790821109e+00, 1.012180753005270e+00, 1.011924425888915e+00, 1.011498917644724e+00, 1.010896765282633e+00, + 1.010110965619444e+00, 1.009135094671655e+00, 1.007963362035220e+00, 1.006590756505588e+00, 1.005013115379014e+00, + 1.003227255072391e+00, 1.001231060075500e+00, 9.990235555436858e-01, 9.966050551498514e-01, 9.939894706113089e-01, + 9.904539200261149e-01, 9.868284225039941e-01, 9.827716736909488e-01, 9.782206672373213e-01, 9.731250287581631e-01, + 9.674323528812744e-01, 9.610947043524248e-01, 9.540636479502398e-01, 9.462952991190324e-01, 9.377489107516087e-01, + 9.283864275822276e-01, 9.181762606422500e-01, 9.070861558801854e-01, 8.950916858157935e-01, 8.821696237804294e-01, + 8.683025287048570e-01, 8.534769362643825e-01, 8.376852006833730e-01, 8.209275259764013e-01, 8.032090930429980e-01, + 7.845450482523652e-01, 7.649554851899686e-01, 7.444735201251689e-01, 7.231348066419057e-01, 7.009860555207412e-01, + 6.780787033699450e-01, 6.544686506489734e-01, 6.302212149502727e-01, 6.053970453856138e-01, 5.800715766089168e-01, + 5.543129276657669e-01, 5.282077505750727e-01, 5.018369724442092e-01, 4.752902962082383e-01, 4.486552956056652e-01, + 4.220281118338883e-01, 3.955057965950340e-01, 3.691875990296320e-01, 3.431732847389720e-01, 3.175633015043183e-01, + 2.924566408966782e-01, 2.679463783886042e-01, 2.441231331518492e-01, 2.210718537110466e-01, 1.988719153219592e-01, + 1.775967625327044e-01, 1.573148583944310e-01, 1.380903364946733e-01, 1.199837497591550e-01, 1.030525757797769e-01, + 8.735085011789188e-02, 7.292811584897502e-02, 5.982732244758056e-02, 4.808178837444506e-02, 3.771135297837851e-02, + 2.871831923385135e-02, 2.108352028641225e-02, 1.476289412849005e-02, 9.683884928956495e-03, 5.642168789286858e-03, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00}; + +const LC3_FLOAT MDCT_WINDOW_320_5ms[320] = { + 4.595886345493055e-04, 7.919323614002698e-04, 1.227927169310031e-03, 1.783653266717233e-03, 2.479549413444207e-03, + 3.329799454594261e-03, 4.353535478916468e-03, 5.564965156664018e-03, 6.986108359341676e-03, 8.629882322202329e-03, + 1.051343406844975e-02, 1.265082642578719e-02, 1.506090447446532e-02, 1.775591229287213e-02, 2.075475983187825e-02, + 2.406813715401559e-02, 2.771207863541604e-02, 3.169933248543932e-02, 3.604609640533871e-02, 4.076128638095439e-02, + 4.586038120884381e-02, 5.135136676471998e-02, 5.724780220726930e-02, 6.355854744461048e-02, 7.029450733434550e-02, + 7.745987198268531e-02, 8.506635369887924e-02, 9.311641620512773e-02, 1.016162955027316e-01, 1.105690806271684e-01, + 1.199789286645804e-01, 1.298417294090302e-01, 1.401623800497866e-01, 1.509371564593891e-01, 1.621632295622287e-01, + 1.738354123649302e-01, 1.859520359191026e-01, 1.985008828937603e-01, 2.114778554475382e-01, 2.248732557074316e-01, + 2.386763947872762e-01, 2.528729453658238e-01, 2.674547009618951e-01, 2.824031465430401e-01, 2.977050145264297e-01, + 3.133419120661713e-01, 3.292976696294886e-01, 3.455490160824131e-01, 3.620795045342974e-01, 3.788648665671841e-01, + 3.958851576591690e-01, 4.131143794748322e-01, 4.305308301005456e-01, 4.481076715576617e-01, 4.658227790464821e-01, + 4.836466393241829e-01, 5.015564851667653e-01, 5.195228071176610e-01, 5.375197039843709e-01, 5.555183841040963e-01, + 5.734957812557457e-01, 5.914186654649489e-01, 6.092622887527459e-01, 6.269981160888640e-01, 6.446002007776794e-01, + 6.620384583071039e-01, 6.792906550106088e-01, 6.963256426589250e-01, 7.131194393772130e-01, 7.296469905863920e-01, + 7.458864594794676e-01, 7.618094719403713e-01, 7.773958448163656e-01, 7.926208751337592e-01, 8.074666387233143e-01, + 8.219101564897180e-01, 8.359343163788637e-01, 8.495180470826319e-01, 8.626485837105826e-01, 8.753083234662220e-01, + 8.874884715160425e-01, 8.991737724042251e-01, 9.103527429187326e-01, 9.210144133066616e-01, 9.311556192776946e-01, + 9.407644740241826e-01, 9.498382236872068e-01, 9.583732599601223e-01, 9.663690412284377e-01, 9.738235617865406e-01, + 9.807442506043361e-01, 9.871297972052695e-01, 9.929872268444632e-01, 9.983241398929388e-01, 1.003150760219063e+00, + 1.007473713377193e+00, 1.011309151636166e+00, 1.014666681083198e+00, 1.017563337333301e+00, 1.020014681326785e+00, + 1.022039872150903e+00, 1.023654257342442e+00, 1.024881624147540e+00, 1.025739288978437e+00, 1.026250709375593e+00, + 1.026436666375082e+00, 1.026320857404224e+00, 1.025922917798664e+00, 1.025269979527211e+00, 1.024382188798244e+00, + 1.023284940887058e+00, 1.022000829220643e+00, 1.020555973231408e+00, 1.018971390778550e+00, 1.017275179369116e+00, + 1.015489129111694e+00, 1.013639356938881e+00, 1.011747750709711e+00, 1.009840844244693e+00, 1.007939764480188e+00, + 1.006407400915498e+00, 1.004374825095777e+00, 1.002469814737132e+00, 1.000689073754539e+00, 9.990346001249977e-01, + 9.975024904153303e-01, 9.960941547576162e-01, 9.948051243621099e-01, 9.936362728142866e-01, 9.925826537087717e-01, + 9.916447007525191e-01, 9.908170758245324e-01, 9.900998445795673e-01, 9.894873685512386e-01, 9.889794323427195e-01, + 9.885701787626714e-01, 9.882591911282058e-01, 9.880404423341358e-01, 9.879133688360181e-01, 9.878718098237022e-01, + 9.879150762106034e-01, 9.880368938846610e-01, 9.882364564839506e-01, 9.885073687439192e-01, 9.888487088987707e-01, + 9.892539488627546e-01, 9.897220412447528e-01, 9.902463287269285e-01, 9.908256340476208e-01, 9.914531811725067e-01, + 9.921276814881759e-01, 9.928422499725458e-01, 9.935955098307742e-01, 9.943804814776256e-01, 9.951957244449919e-01, + 9.960341878404958e-01, 9.968943831870675e-01, 9.977692009836100e-01, 9.986571134591464e-01, 9.995509738170480e-01, + 1.000449227898040e+00, 1.001344692310058e+00, 1.002235786606954e+00, 1.003115291715261e+00, 1.003981602446902e+00, + 1.004827468041713e+00, 1.005651275972376e+00, 1.006445772052972e+00, 1.007209352772459e+00, 1.007934783656087e+00, + 1.008620496650569e+00, 1.009259314290145e+00, 1.009849742422788e+00, 1.010384692193296e+00, 1.010862783160582e+00, + 1.011277044709547e+00, 1.011626247430694e+00, 1.011903571699736e+00, 1.012107954864219e+00, 1.012232755709885e+00, + 1.012277089047072e+00, 1.012234505114778e+00, 1.012104319978655e+00, 1.011880293122688e+00, 1.011561972516341e+00, + 1.011143373963981e+00, 1.010624321020038e+00, 1.009999148545101e+00, 1.009268031808824e+00, 1.008425698479647e+00, + 1.007472774447058e+00, 1.006404483571931e+00, 1.005222003295591e+00, 1.003921160689206e+00, 1.002503762756151e+00, + 1.000966332772540e+00, 9.993114007411373e-01, 9.975362702189898e-01, 9.956442306333592e-01, 9.936333924912825e-01, + 9.908677480361242e-01, 9.882326326262749e-01, 9.853620567056602e-01, 9.822305093671991e-01, 9.788185853162172e-01, + 9.751026333215268e-01, 9.710631852370086e-01, 9.666759668947944e-01, 9.619242192293307e-01, 9.567841986369235e-01, + 9.512394303101863e-01, 9.452700238623795e-01, 9.388615698236068e-01, 9.319946435581106e-01, 9.246592033932568e-01, + 9.168383396399868e-01, 9.085218034087421e-01, 8.996967011299613e-01, 8.903562054918268e-01, 8.804877931535187e-01, + 8.700884209228057e-01, 8.591492134848259e-01, 8.476686394755906e-01, 8.356428970797861e-01, 8.230753889817990e-01, + 8.099649296155544e-01, 7.963204506324437e-01, 7.821460539775005e-01, 7.674541821769616e-01, 7.522563457568547e-01, + 7.365702052057368e-01, 7.204090552899627e-01, 7.037975107157410e-01, 6.867542812151157e-01, 6.693041888771051e-01, + 6.514710959179395e-01, 6.332854832820911e-01, 6.147685389896460e-01, 5.959553778639692e-01, 5.768737955463938e-01, + 5.575534287167304e-01, 5.380320138068979e-01, 5.183454027643563e-01, 4.985259415650634e-01, 4.786156067459849e-01, + 4.586473038370941e-01, 4.386643656872842e-01, 4.187046888325280e-01, 3.988123056192917e-01, 3.790262923635886e-01, + 3.593914828698096e-01, 3.399474132903109e-01, 3.207392420889753e-01, 3.018061113177048e-01, 2.831905952786929e-01, + 2.649288369241889e-01, 2.470608550624402e-01, 2.296201119084317e-01, 2.126433716126151e-01, 1.961601816145380e-01, + 1.802035203864437e-01, 1.647996883470626e-01, 1.499787548077656e-01, 1.357643522991611e-01, 1.221842534547464e-01, + 1.092601994264172e-01, 9.701788451015501e-02, 8.547680283183663e-02, 7.465976378295235e-02, 6.458254322751883e-02, + 5.526281189874138e-02, 4.670976978373095e-02, 3.893244425578719e-02, 3.192976013776996e-02, 2.569810636390756e-02, + 2.022259265088492e-02, 1.548317776486452e-02, 1.144924909653903e-02, 8.076482660383199e-03, 5.300044080947794e-03, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00}; + +const LC3_FLOAT MDCT_WINDOW_480_5ms[480] = { + 4.090106504820579e-04, 6.143388180964179e-04, 8.571759876954877e-04, 1.147015057857495e-03, 1.489582832987000e-03, + 1.889770382231583e-03, 2.353000800169909e-03, 2.884104959764029e-03, 3.488213786635855e-03, 4.170040431489613e-03, + 4.934298832466617e-03, 5.787076505403503e-03, 6.733811743137561e-03, 7.779130464154915e-03, 8.927044958757816e-03, + 1.018202888968871e-02, 1.154910606525086e-02, 1.303349217699797e-02, 1.463951288465963e-02, 1.637155619860352e-02, + 1.823455383898077e-02, 2.023309488998589e-02, 2.237116158648752e-02, 2.465237348403478e-02, 2.708101935270475e-02, + 2.966159685753317e-02, 3.239884850877327e-02, 3.529601774976465e-02, 3.835663329277230e-02, 4.158447932459513e-02, + 4.498322421745353e-02, 4.855610986150206e-02, 5.230596475016741e-02, 5.623624576084146e-02, 6.035055738891727e-02, + 6.465186317477950e-02, 6.914195749790462e-02, 7.382288203064732e-02, 7.869709331995660e-02, 8.376761638427657e-02, + 8.903563687211118e-02, 9.450199243028472e-02, 1.001680193006426e-01, 1.060356225286319e-01, 1.121060220821844e-01, + 1.183788547045326e-01, 1.248534855777947e-01, 1.315302847610869e-01, 1.384103079528939e-01, 1.454931890869180e-01, + 1.527772946853750e-01, 1.602608842337125e-01, 1.679435556337752e-01, 1.758245615079801e-01, 1.839020119821303e-01, + 1.921728622634411e-01, 2.006344295681524e-01, 2.092853879977170e-01, 2.181238261985594e-01, 2.271462264407930e-01, + 2.363479205237173e-01, 2.457259744642953e-01, 2.552771551741124e-01, 2.649981094228982e-01, 2.748839432649996e-01, + 2.849296444030153e-01, 2.951306505827265e-01, 3.054824712370942e-01, 3.159799638238941e-01, 3.266169794538543e-01, + 3.373873799614014e-01, 3.482855915638277e-01, 3.593057693987583e-01, 3.704415932452488e-01, 3.816862385160692e-01, + 3.930329782788047e-01, 4.044749630814483e-01, 4.160051103939122e-01, 4.276159595085598e-01, 4.393004362003260e-01, + 4.510516333434032e-01, 4.628616046119925e-01, 4.747225454237193e-01, 4.866266705542529e-01, 4.985664508456704e-01, + 5.105341492548225e-01, 5.225212793188740e-01, 5.345190505841265e-01, 5.465201916422433e-01, 5.585172769552711e-01, + 5.705021536899105e-01, 5.824658100332457e-01, 5.943991720381216e-01, 6.062948176207270e-01, 6.181452662624718e-01, + 6.299422016714543e-01, 6.416768736044914e-01, 6.533411462740817e-01, 6.649277540000037e-01, 6.764292700223311e-01, + 6.878367295965062e-01, 6.991421467689277e-01, 7.103379606632721e-01, 7.214176027060971e-01, 7.323746102405828e-01, + 7.432008025932804e-01, 7.538887973483771e-01, 7.644315495717613e-01, 7.748223151443820e-01, 7.850546571907628e-01, + 7.951223518167163e-01, 8.050193862201107e-01, 8.147397447696774e-01, 8.242774413707643e-01, 8.336267114335371e-01, + 8.427819363777799e-01, 8.517386186427548e-01, 8.604920874939698e-01, 8.690376742017057e-01, 8.773720451249032e-01, + 8.854927938913381e-01, 8.933935477349644e-01, 9.010727088526728e-01, 9.085249398881980e-01, 9.157483563218768e-01, + 9.227413839712016e-01, 9.295017469413066e-01, 9.360270196617569e-01, 9.423143052164881e-01, 9.483629792665091e-01, + 9.541731142261065e-01, 9.597438382130120e-01, 9.650738394220176e-01, 9.701635474343885e-01, 9.750143364412617e-01, + 9.796277191617885e-01, 9.840036439809510e-01, 9.881426772731259e-01, 9.920470446911211e-01, 9.957199420334376e-01, + 9.991640812275709e-01, 1.002381307710643e+00, 1.005374268639838e+00, 1.008146718214831e+00, 1.010703123647275e+00, + 1.013046655758663e+00, 1.015181271161417e+00, 1.017111643578857e+00, 1.018843380560658e+00, 1.020381713994816e+00, + 1.021731101971518e+00, 1.022896948293643e+00, 1.023885455671576e+00, 1.024702974608899e+00, 1.025355286710874e+00, + 1.025848243050604e+00, 1.026188366261215e+00, 1.026382881625701e+00, 1.026438102255574e+00, 1.026360125820994e+00, + 1.026155530733488e+00, 1.025831456886557e+00, 1.025395432284244e+00, 1.024853974580724e+00, 1.024213482124578e+00, + 1.023481184943025e+00, 1.022664602721801e+00, 1.021770903480975e+00, 1.020806917660529e+00, 1.019779396547454e+00, + 1.018695995335235e+00, 1.017564416918053e+00, 1.016391686789653e+00, 1.015184918030332e+00, 1.013950835315021e+00, + 1.012697033320358e+00, 1.011430749860716e+00, 1.010158346781076e+00, 1.008885191761748e+00, 1.007592718305943e+00, + 1.006805603478092e+00, 1.005378742804807e+00, 1.004049051787112e+00, 1.002778356298787e+00, 1.001563778373068e+00, + 1.000404915291105e+00, 9.993014844615166e-01, 9.982531564931281e-01, 9.972595460676951e-01, 9.963202131848272e-01, + 9.954346644968789e-01, 9.946023543844607e-01, 9.938226881029791e-01, 9.930950268060122e-01, 9.924186919309267e-01, + 9.917929657090736e-01, 9.912170911359961e-01, 9.906902760441473e-01, 9.902117003786811e-01, 9.897805192546193e-01, + 9.893958602389157e-01, 9.890568243690241e-01, 9.887624937408933e-01, 9.885119364350415e-01, 9.883042028597552e-01, + 9.881383235740961e-01, 9.880133161159576e-01, 9.879281898513085e-01, 9.878819413827574e-01, 9.878735508484809e-01, + 9.879019873841568e-01, 9.879662130250981e-01, 9.880651778500144e-01, 9.881978162133899e-01, 9.883630508181326e-01, + 9.885597957603544e-01, 9.887869526128024e-01, 9.890434070785485e-01, 9.893280319166613e-01, 9.896396899060125e-01, + 9.899772316163624e-01, 9.903394929409673e-01, 9.907252968668226e-01, 9.911334564321237e-01, 9.915627747807666e-01, + 9.920120436855326e-01, 9.924800441092685e-01, 9.929655482846576e-01, 9.934673212537685e-01, 9.939841207305906e-01, + 9.945146969322154e-01, 9.950577931942117e-01, 9.956121471675398e-01, 9.961764915534302e-01, 9.967495543671935e-01, + 9.973300590248015e-01, 9.979167245036720e-01, 9.985082643417953e-01, 9.991033633647473e-01, 9.997003478609010e-01, + 1.000299741957418e+00, 1.000897441314013e+00, 1.001493964257960e+00, 1.002087624593489e+00, 1.002677088643863e+00, + 1.003261045483858e+00, 1.003838183774652e+00, 1.004407190937699e+00, 1.004966753528881e+00, 1.005515557572658e+00, + 1.006052289109999e+00, 1.006575635258931e+00, 1.007084285781611e+00, 1.007576934100958e+00, 1.008052277555815e+00, + 1.008509017718116e+00, 1.008945862447015e+00, 1.009361528531177e+00, 1.009754742820913e+00, 1.010124241309341e+00, + 1.010468769795370e+00, 1.010787087537248e+00, 1.011077969726137e+00, 1.011340205650538e+00, 1.011572597114216e+00, + 1.011773962181442e+00, 1.011943138906979e+00, 1.012078982659783e+00, 1.012180362866919e+00, 1.012246166897464e+00, + 1.012275305013586e+00, 1.012266707295288e+00, 1.012219319453278e+00, 1.012132107622966e+00, 1.012004064757857e+00, + 1.011834207632025e+00, 1.011621572933544e+00, 1.011365223023975e+00, 1.011064253702468e+00, 1.010717792733157e+00, + 1.010324996851905e+00, 1.009885057526159e+00, 1.009397209381147e+00, 1.008860731864438e+00, 1.008274947065247e+00, + 1.007639223374887e+00, 1.006952983357691e+00, 1.006215708265639e+00, 1.005426938305289e+00, 1.004586273379809e+00, + 1.003693377657581e+00, 1.002747984657666e+00, 1.001749900308864e+00, 1.000699003803502e+00, 9.995952485989262e-01, + 9.984386632116344e-01, 9.972293415774932e-01, 9.959672769174924e-01, 9.946500332901397e-01, 9.932403996813470e-01, + 9.912511516117244e-01, 9.895756853352172e-01, 9.877713214760662e-01, 9.858577479051078e-01, 9.838303127859196e-01, + 9.816822625580078e-01, 9.794074486605805e-01, 9.769999155793757e-01, 9.744528356359687e-01, 9.717597500340699e-01, + 9.689141159310996e-01, 9.659101618500662e-01, 9.627421831412876e-01, 9.594038121639412e-01, 9.558889978382734e-01, + 9.521922434090249e-01, 9.483086322505029e-01, 9.442332539187503e-01, 9.399607238929982e-01, 9.354860218216989e-01, + 9.308052967663477e-01, 9.259146970284931e-01, 9.208101305030523e-01, 9.154873597416558e-01, 9.099426066529104e-01, + 9.041732260327581e-01, 8.981763729936715e-01, 8.919490241013392e-01, 8.854882249661838e-01, 8.787919436722827e-01, + 8.718585835568161e-01, 8.646864947605047e-01, 8.572738135700366e-01, 8.496195859658071e-01, 8.417237467711145e-01, + 8.335862715770727e-01, 8.252074428838668e-01, 8.165875713256009e-01, 8.077280370477699e-01, 7.986311592191131e-01, + 7.892986353718001e-01, 7.797330954210866e-01, 7.699379531983687e-01, 7.599171886893816e-01, 7.496758423734833e-01, + 7.392176841476761e-01, 7.285474515411827e-01, 7.176714478163359e-01, 7.065962311464494e-01, 6.953282935906302e-01, + 6.838739059112046e-01, 6.722395305539791e-01, 6.604334017809461e-01, 6.484643596235256e-01, 6.363395004626368e-01, + 6.240661431421666e-01, 6.116530334821534e-01, 5.991098644638286e-01, 5.864461424698465e-01, 5.736694851703749e-01, + 5.607881029948401e-01, 5.478160663871271e-01, 5.347619788897301e-01, 5.216365147692703e-01, 5.084499758302256e-01, + 4.952135086430446e-01, 4.819387562519412e-01, 4.686361426419003e-01, 4.553170769563941e-01, 4.419939954454178e-01, + 4.286789889246267e-01, 4.153837786572842e-01, 4.021211063103491e-01, 3.889032719013054e-01, 3.757425439137077e-01, + 3.626515183776310e-01, 3.496431418636322e-01, 3.367290822653354e-01, 3.239228075238623e-01, 3.112360816586549e-01, + 2.986807941537710e-01, 2.862694673284843e-01, 2.740128472224539e-01, 2.619228330079575e-01, 2.500098438708934e-01, + 2.382847225401669e-01, 2.267578490199104e-01, 2.154390996938547e-01, 2.043379825955254e-01, 1.934636765792024e-01, + 1.828250319214460e-01, 1.724305860483634e-01, 1.622886348529314e-01, 1.524071880359812e-01, 1.427939789949266e-01, + 1.334565845242183e-01, 1.244023922999665e-01, 1.156385879569742e-01, 1.071721547807196e-01, 9.900985872728905e-02, + 9.115821766572002e-02, 8.362344855837105e-02, 7.641140367416376e-02, 6.952749039054598e-02, 6.297656454790079e-02, + 5.676284244020858e-02, 5.088975408628229e-02, 4.535983304624439e-02, 4.017457306236873e-02, 3.533430192568957e-02, + 3.083806062123772e-02, 2.668355420358626e-02, 2.286680405144430e-02, 1.938236337675363e-02, 1.622312720409645e-02, + 1.338005016725895e-02, 1.084218595595746e-02, 8.596753980908744e-03, 6.640506529168652e-03, 5.172703110468352e-03, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00}; + + +const LC3_FLOAT MDCT_HRA_WINDOW_480_2_5ms[240] = { + 1.928875250471185e-07, 1.268623078914631e-06, 3.736943081685792e-06, 8.649386473419844e-06, 1.752499879209154e-05, + 3.251004192297566e-05, 5.654995150945631e-05, 9.358653414327445e-05, 1.487809853781833e-04, 2.287619057346095e-04, + 3.418963835622074e-04, 4.985810015573861e-04, 7.115482671394238e-04, 9.961824750040105e-04, 1.370837415765066e-03, + 1.857146703383843e-03, 2.480315886706181e-03, 3.269384042869696e-03, 4.257441351253188e-03, 5.481788360538607e-03, + 6.984022437256788e-03, 8.810037359146468e-03, 1.100992329671028e-02, 1.363775656493463e-02, 1.675127150559057e-02, + 2.041141057401967e-02, 2.468175295733717e-02, 2.962782656580052e-02, 3.531631267855188e-02, 4.181415652877682e-02, + 4.918760034374654e-02, 5.750115754515065e-02, 6.681654781077175e-02, 7.719161248813326e-02, 8.867922857347045e-02, + 1.013262374019720e-01, 1.151724017179353e-01, 1.302494023407827e-01, 1.465798836473051e-01, 1.641765559275968e-01, + 1.830413626142431e-01, 2.031647215674081e-01, 2.245248520040451e-01, 2.470872021104946e-01, 2.708039965464759e-01, + 2.956139274737775e-01, 3.214420168557505e-01, 3.481996809305596e-01, 3.757850292873181e-01, 4.040834302177654e-01, + 4.329683704138883e-01, 4.623026302356333e-01, 4.919397855296871e-01, 5.217260335074649e-01, 5.515023240298861e-01, + 5.811067597335228e-01, 6.103772100633116e-01, 6.391540670154212e-01, 6.672830559207561e-01, 6.946180045149623e-01, + 7.210234691482331e-01, 7.463771190956836e-01, 7.705717887049389e-01, 7.935171220325148e-01, 8.151407544921331e-01, + 8.353889991744725e-01, 8.542270299166949e-01, 8.716385768842180e-01, 8.876251715716619e-01, 9.022049953400274e-01, + 9.154113980197115e-01, 9.272911604251438e-01, 9.379025770646191e-01, 9.473134335138002e-01, 9.555989477431630e-01, + 9.628397371519567e-01, 9.691198641470655e-01, 9.745250036731624e-01, 9.791407668194774e-01, 9.830512059497915e-01, + 9.863375189657285e-01, 9.890769633791019e-01, 9.913419847656554e-01, 9.931995587544050e-01, 9.947107408108303e-01, + 9.959304135675596e-01, 9.969072172806543e-01, 9.976836451676292e-01, 9.982962820245519e-01, 9.987761617973335e-01, + 9.991492178976376e-01, 9.994367991905715e-01, 9.996562248627440e-01, 9.998213528339476e-01, 9.999431389208511e-01, + 1.000030167405588e+00, 1.000089137729581e+00, 1.000125296398298e+00, 1.000142807515464e+00, 1.000145059370791e+00, + 1.000134907956303e+00, 1.000114861040898e+00, 1.000087208438067e+00, 1.000054105383460e+00, 1.000017616583971e+00, + 9.999797286315710e-01, 9.999423382309206e-01, 9.999072232012880e-01, 9.998760025910959e-01, 9.998500915686289e-01, + 9.998306560737898e-01, 9.998185715517388e-01, 9.998143894342878e-01, 9.998183143680869e-01, 9.998301944838478e-01, + 9.998495262367371e-01, 9.998754745167079e-01, 9.999069078401956e-01, 9.999424475239904e-01, 9.999805288598742e-01, + 1.000019471519221e+00, 1.000057555786879e+00, 1.000093100812805e+00, 1.000124540917058e+00, 1.000150496102128e+00, + 1.000169833298924e+00, 1.000181715452526e+00, 1.000185636273393e+00, 1.000181439257840e+00, 1.000169320335504e+00, + 1.000149814156658e+00, 1.000123764529774e+00, 1.000092279821119e+00, 1.000056674215966e+00, 1.000018395617911e+00, + 9.999789406480724e-01, 9.999397567326687e-01, 9.999021306794866e-01, 9.998670624939285e-01, 9.998351225350340e-01, + 9.998062895304436e-01, 9.997797665333356e-01, 9.997537716957203e-01, 9.997253008334399e-01, 9.996898592447866e-01, + 9.996411611766667e-01, 9.995707967428177e-01, 9.994678679836200e-01, 9.993185980679096e-01, 9.991059202780914e-01, + 9.988090562524252e-01, 9.984030958127336e-01, 9.978585933978946e-01, 9.971411984750603e-01, 9.962113391583908e-01, + 9.950239795154223e-01, 9.935284716160412e-01, 9.916685232530794e-01, 9.893823014422549e-01, 9.866026903106617e-01, + 9.832577198181265e-01, 9.792711789106039e-01, 9.745634231307387e-01, 9.690523823244767e-01, 9.626547687789766e-01, + 9.552874798038419e-01, 9.468691813614447e-01, 9.373220508813107e-01, 9.265736480032657e-01, 9.145588719963409e-01, + 9.012219545005915e-01, 8.865184267401519e-01, 8.704169923325978e-01, 8.529012312555665e-01, 8.339710584198038e-01, + 8.136438625110305e-01, 7.919552579077074e-01, 7.689593947581650e-01, 7.447287893964823e-01, 7.193536583208960e-01, + 6.929407625549489e-01, 6.656117935585394e-01, 6.375013549431151e-01, 6.087546140984144e-01, 5.795247127727363e-01, + 5.499700344866872e-01, 5.202514288725478e-01, 4.905294887819369e-01, 4.609619660928919e-01, 4.317013978660552e-01, + 4.028929974356116e-01, 3.746728468420245e-01, 3.471664092737412e-01, 3.204873641715565e-01, 2.947367542923338e-01, + 2.700024238683050e-01, 2.463587202023185e-01, 2.238664274584689e-01, 2.025729006480214e-01, 1.825123693148748e-01, + 1.637063835467572e-01, 1.461643790086412e-01, 1.298843420747792e-01, 1.148535602600838e-01, 1.010494465619472e-01, + 8.844042869400506e-02, 7.698689534753124e-02, 6.664219153548699e-02, 5.735365389394342e-02, 4.906367480666277e-02, + 4.171078175510523e-02, 3.523071580898128e-02, 2.955749109487545e-02, 2.462441579169607e-02, 2.036505497804320e-02, + 1.671411663728698e-02, 1.360824429995981e-02, 1.098670301702559e-02, 8.791949345648940e-03, 6.970080454492374e-03, + 5.471161958930394e-03, 4.249438341364304e-03, 3.263433520599239e-03, 2.475952111493295e-03, 1.853994056678125e-03, + 1.368596596909542e-03, 9.946180283333026e-04, 7.104774789034889e-04, 4.978641589703932e-04, 3.414283510010364e-04, + 2.284649445606105e-04, 1.485987233730432e-04, 9.347897725317759e-05, 5.648942347847280e-05, 3.247793542861785e-05, + 1.750922386335714e-05, 8.642407336226362e-06, 3.734302301245202e-06, 1.267861256795911e-06, 1.927766981311251e-07}; + +const LC3_FLOAT MDCT_HRA_WINDOW_960_2_5ms[480] = { + 1.363353492760669e-07, 4.577676005269251e-07, 9.975675168391671e-07, 1.840776229085288e-06, 3.092248230077047e-06, + 4.880943708557620e-06, 7.363817805099883e-06, 1.073000750387602e-05, 1.520538607055496e-05, 2.105750528134522e-05, + 2.860093592119667e-05, 3.820301288710557e-05, 5.028998805188179e-05, 6.535359090391442e-05, 8.395799364585048e-05, + 1.067471738361778e-04, 1.344526637637966e-04, 1.679016715435404e-04, 2.080255544044134e-04, 2.558686198117505e-04, + 3.125972249248099e-04, 3.795091394541575e-04, 4.580431312676675e-04, 5.497887281277575e-04, 6.564961027629782e-04, + 7.800860221325537e-04, 9.226597952927381e-04, 1.086509147791288e-03, 1.274125944085974e-03, 1.488211673202887e-03, + 1.731686606830910e-03, 2.007698533412427e-03, 2.319630966669840e-03, 2.671110722544265e-03, 3.066014754864068e-03, + 3.508476137357141e-03, 4.002889078021606e-03, 4.553912851519276e-03, 5.166474536289647e-03, 5.845770445618693e-03, + 6.597266146035767e-03, 7.426694962226363e-03, 8.340054875180547e-03, 9.343603729551937e-03, 1.044385267714563e-02, + 1.164755779600632e-02, 1.296170983861615e-02, 1.439352207806304e-02, 1.595041623748902e-02, 1.764000650541313e-02, + 1.947008165734806e-02, 2.144858532216432e-02, 2.358359444954804e-02, 2.588329605228426e-02, 2.835596231360897e-02, + 3.100992416515645e-02, 3.385354345474830e-02, 3.689518383513415e-02, 4.014318051454780e-02, 4.360580901740066e-02, + 4.729125310846769e-02, 5.120757203648361e-02, 5.536266725318061e-02, 5.976424876157179e-02, 6.441980124289254e-02, + 6.933655010531084e-02, 7.452142758961615e-02, 7.998103905796611e-02, 8.572162958181787e-02, 9.174905093483054e-02, + 9.806872908624656e-02, 1.046856322804917e-01, 1.116042397799019e-01, 1.188285113399959e-01, 1.263618574809210e-01, + 1.342071106149135e-01, 1.423664970880752e-01, 1.508416101956496e-01, 1.596333842333865e-01, 1.687420696535257e-01, + 1.781672094023636e-01, 1.879076165271377e-01, 1.979613531528743e-01, 2.083257109445936e-01, 2.189971931864894e-01, + 2.299714986269890e-01, 2.412435072564368e-01, 2.528072682020181e-01, 2.646559899418406e-01, 2.767820330562002e-01, + 2.891769057483280e-01, 3.018312623786579e-01, 3.147349052652145e-01, 3.278767900074122e-01, 3.412450345907444e-01, + 3.548269325249284e-01, 3.686089702575019e-01, 3.825768490881926e-01, 3.967155117862224e-01, 4.110091740828488e-01, + 4.254413611747417e-01, 4.399949493303511e-01, 4.546522126414323e-01, 4.693948749058132e-01, 4.842041665659120e-01, + 4.990608865612834e-01, 5.139454688835927e-01, 5.288380535501122e-01, 5.437185616384643e-01, 5.585667739524391e-01, + 5.733624128178846e-01, 5.880852264406471e-01, 6.027150751969793e-01, 6.172320191724501e-01, 6.316164062197546e-01, + 6.458489597703579e-01, 6.599108656108541e-01, 6.737838568232726e-01, 6.874502960899853e-01, 7.008932545787268e-01, + 7.140965866515435e-01, 7.270449996828834e-01, 7.397241183258171e-01, 7.521205426304834e-01, 7.642218994939656e-01, + 7.760168870042503e-01, 7.874953113309442e-01, 7.986481159099932e-01, 8.094674027667472e-01, 8.199464459192338e-01, + 8.300796968994718e-01, 8.398627825231116e-01, 8.492924951249206e-01, 8.583667755581161e-01, 8.670846893280041e-01, + 8.754463962937875e-01, 8.834531144261093e-01, 8.911070781514043e-01, 8.984114918473676e-01, 9.053704790768982e-01, + 9.119890281611266e-01, 9.182729346961321e-01, 9.242287416134559e-01, 9.298636773723805e-01, 9.351855928531210e-01, + 9.402028974955879e-01, 9.449244951992589e-01, 9.493597204669394e-01, 9.535182752397909e-01, 9.574101668338553e-01, + 9.610456473502188e-01, 9.644351548926832e-01, 9.675892568889318e-01, 9.705185957742447e-01, 9.732338372611643e-01, + 9.757456213845153e-01, 9.780645164789403e-01, 9.802009762158145e-01, 9.821652997980082e-01, 9.839675953844861e-01, + 9.856177467920233e-01, 9.871253834983186e-01, 9.884998539492639e-01, 9.897502021530162e-01, 9.908851475245483e-01, + 9.919130679264989e-01, 9.928419858351684e-01, 9.936795575444219e-01, 9.944330653049196e-01, 9.951094122815642e-01, + 9.957151201982998e-01, 9.962563295265126e-01, 9.967388020613602e-01, 9.971679257195168e-01, 9.975487213822326e-01, + 9.978858515994010e-01, 9.981836309637017e-01, 9.984460379589807e-01, 9.986767280839717e-01, 9.988790480513948e-01, + 9.990560508634377e-01, 9.992105115676724e-01, 9.993449435025852e-01, 9.994616148490124e-01, 9.995625653127808e-01, + 9.996496227746003e-01, 9.997244197555017e-01, 9.997884095596641e-01, 9.998428819710351e-01, 9.998889783954170e-01, + 9.999277063554146e-01, 9.999599532614691e-01, 9.999864993978808e-01, 1.000008030077971e+00, 1.000025146937107e+00, + 1.000038378346013e+00, 1.000048188939381e+00, 1.000054988266291e+00, 1.000059138579006e+00, 1.000060961785582e+00, + 1.000060745599070e+00, 1.000058748922255e+00, 1.000055206511563e+00, 1.000050332967367e+00, 1.000044326100310e+00, + 1.000037369724671e+00, 1.000029635930232e+00, 1.000021286883873e+00, 1.000012476211096e+00, 1.000003350006250e+00, + 9.999940475182815e-01, 9.999847015566445e-01, 9.999754386595657e-01, 9.999663790642979e-01, 9.999576365163719e-01, + 9.999493179522237e-01, 9.999415230869807e-01, 9.999343439366570e-01, 9.999278643015735e-01, 9.999221592354568e-01, + 9.999172945224162e-01, 9.999133261818468e-01, 9.999103000191805e-01, 9.999082512384065e-01, 9.999072041302636e-01, + 9.999071718480597e-01, 9.999081562811047e-01, 9.999101480338050e-01, 9.999131265164656e-01, 9.999170601519115e-01, + 9.999219066999991e-01, 9.999276137001288e-01, 9.999341190298563e-01, 9.999413515757679e-01, 9.999492320108540e-01, + 9.999576736708096e-01, 9.999665835199758e-01, 9.999758631960602e-01, 9.999854101213793e-01, 9.999951186671812e-01, + 1.000004881356628e+00, 1.000014590091279e+00, 1.000024137385544e+00, 1.000033417593335e+00, 1.000042328111225e+00, + 1.000050770542848e+00, 1.000058651809861e+00, 1.000065885195634e+00, 1.000072391308898e+00, 1.000078098955774e+00, + 1.000082945909961e+00, 1.000086879572280e+00, 1.000089857512229e+00, 1.000091847885646e+00, 1.000092829723974e+00, + 1.000092793091916e+00, 1.000091739111420e+00, 1.000089679850895e+00, 1.000086638079347e+00, 1.000082646885623e+00, + 1.000077749163242e+00, 1.000071996961268e+00, 1.000065450701385e+00, 1.000058178260741e+00, 1.000050253919262e+00, + 1.000041757168942e+00, 1.000032771381191e+00, 1.000023382326608e+00, 1.000013676539597e+00, 1.000003739518099e+00, + 9.999936537463840e-01, 9.999834965263427e-01, 9.999733376002018e-01, 9.999632365449369e-01, 9.999532399160947e-01, + 9.999433781162252e-01, 9.999336619607787e-01, 9.999240789122246e-01, 9.999145889513631e-01, 9.999051200534473e-01, + 9.998955632358651e-01, 9.998857671439174e-01, 9.998755321416521e-01, 9.998646038760159e-01, 9.998526662846789e-01, + 9.998393340210341e-01, 9.998241442739438e-01, 9.998065479650342e-01, 9.997859003125656e-01, 9.997614507583039e-01, + 9.997323322622099e-01, 9.996975499792088e-01, 9.996559693426429e-01, 9.996063035901801e-01, 9.995471007797664e-01, + 9.994767303555520e-01, 9.993933693363640e-01, 9.992949882120472e-01, 9.991793366456373e-01, 9.990439290916592e-01, + 9.988860304525888e-01, 9.987026419065322e-01, 9.984904870492169e-01, 9.982459985022988e-01, 9.979653051476074e-01, + 9.976442201531890e-01, 9.972782299617136e-01, 9.968624844150069e-01, 9.963917881900651e-01, 9.958605937219481e-01, + 9.952629957874448e-01, 9.945927279204203e-01, 9.938431608253206e-01, 9.930073029495663e-01, 9.920778033684794e-01, + 9.910469571281373e-01, 9.899067131820748e-01, 9.886486850471784e-01, 9.872641642923781e-01, 9.857441369608847e-01, + 9.840793030126235e-01, 9.822600988582102e-01, 9.802767230390885e-01, 9.781191650903150e-01, 9.757772376026793e-01, + 9.732406114793927e-01, 9.704988543592059e-01, 9.675414721525257e-01, 9.643579536097365e-01, 9.609378178114939e-01, + 9.572706644392005e-01, 9.533462266503443e-01, 9.491544263479285e-01, 9.446854315961644e-01, 9.399297158962095e-01, + 9.348781189964488e-01, 9.295219088721776e-01, 9.238528444701966e-01, 9.178632387754598e-01, 9.115460217204322e-01, + 9.048948024240450e-01, 8.979039302171362e-01, 8.905685538859580e-01, 8.828846785458305e-01, 8.748492195442639e-01, + 8.664600527878369e-01, 8.577160608906681e-01, 8.486171745551603e-01, 8.391644086184020e-01, 8.293598922305367e-01, + 8.192068926746530e-01, 8.087098323911928e-01, 7.978742988330544e-01, 7.867070468498287e-01, 7.752159933798504e-01, + 7.634102043158196e-01, 7.512998735020282e-01, 7.388962939169839e-01, 7.262118211926384e-01, 7.132598297183557e-01, + 7.000546616722335e-01, 6.866115694122957e-01, 6.729466517435032e-01, 6.590767846515775e-01, 6.450195471597746e-01, + 6.307931430185830e-01, 6.164163189797930e-01, 6.019082804348481e-01, 5.872886052124403e-01, 5.725771563319307e-01, + 5.577939944978301e-01, 5.429592910967905e-01, 5.280932424234555e-01, 5.132159858162120e-01, 4.983475183298941e-01, + 4.835076185113182e-01, 4.687157717768828e-01, 4.539910998210603e-01, 4.393522944120604e-01, 4.248175558579833e-01, + 4.104045363548025e-01, 3.961302883579846e-01, 3.820112180536255e-01, 3.680630439436816e-01, 3.543007605040334e-01, + 3.407386068243548e-01, 3.273900400954695e-01, 3.142677137733552e-01, 3.013834602191723e-01, 2.887482775916394e-01, + 2.763723207514489e-01, 2.642648959268686e-01, 2.524344588847748e-01, 2.408886163515173e-01, 2.296341304326797e-01, + 2.186769257893048e-01, 2.080220993398264e-01, 1.976739322711464e-01, 1.876359041583237e-01, 1.779107090095517e-01, + 1.685002730708834e-01, 1.594057742429125e-01, 1.506276629788181e-01, 1.421656845493104e-01, 1.340189025746913e-01, + 1.261857237370651e-01, 1.186639235964411e-01, 1.114506734428340e-01, 1.045425681223503e-01, 9.793565477860058e-02, + 9.162546245161339e-02, 8.560703247484407e-02, 7.987494960705163e-02, 7.442337382999228e-02, 6.924607273536325e-02, + 6.433645441557491e-02, 5.968760076313909e-02, 5.529230107316437e-02, 5.114308583308901e-02, 4.723226057381158e-02, + 4.355193964722984e-02, 4.009407978727676e-02, 3.685051330522059e-02, 3.381298076557955e-02, 3.097316298675063e-02, + 2.832271221053797e-02, 2.585328228730008e-02, 2.355655772843824e-02, 2.142428148537503e-02, 1.944828132389286e-02, + 1.762049467453352e-02, 1.593299185344667e-02, 1.437799756332653e-02, 1.294791060055676e-02, 1.163532171204003e-02, + 1.043302956305446e-02, 9.334054795489547e-03, 8.331652173617308e-03, 7.419320831822072e-03, 6.590812655146027e-03, + 5.840138838848342e-03, 5.161574687206487e-03, 4.549662724337389e-03, 3.999214200759286e-03, 3.505309088672846e-03, + 3.063294666478038e-03, 2.668782798866110e-03, 2.317646022975776e-03, 2.006012553652158e-03, 1.730260321894845e-03, + 1.487010160247016e-03, 1.273118247295162e-03, 1.085667920762688e-03, 9.219609650399310e-04, 7.795084745479000e-04, + 6.560213892304477e-04, 5.494007928508220e-04, 4.577280587661532e-04, 3.792549215895880e-04, 3.123935467349105e-04, + 2.557066633705375e-04, 2.078978198736850e-04, 1.678018145436083e-04, 1.343753481649133e-04, 1.066879390562912e-04, + 8.391313553401788e-05, 6.532005529093359e-05, 5.026527605947520e-05, 3.818509710338716e-05, 2.858818657228189e-05, + 2.104862555598476e-05, 1.519935578579325e-05, 1.072603433419925e-05, 7.361295334616452e-06, 4.879415604699819e-06, + 3.091377877253446e-06, 1.840321200267112e-06, 9.973582966273186e-07, 4.576899867970956e-07, 1.363156993327630e-07}; + +const LC3_FLOAT MDCT_HRA_WINDOW_480_5ms[480] = { + 9.752475122178133e-08, 6.413568706385488e-07, 1.888722582859778e-06, 4.370037451432268e-06, 8.850535239285388e-06, + 1.640976145163547e-05, 2.852654713353143e-05, 4.717577700625728e-05, 7.493695610161539e-05, 1.151138634046934e-04, + 1.718640547726665e-04, 2.503364524287818e-04, 3.568147253529307e-04, 4.988636346654247e-04, 6.854750052598100e-04, + 9.272095051506971e-04, 1.236329983123574e-03, 1.626921748932395e-03, 2.114994893578391e-03, 2.718563554424897e-03, + 3.457696944351759e-03, 4.354536997897421e-03, 5.433277651003014e-03, 6.720101073517573e-03, 8.243066622086374e-03, + 1.003194888027514e-02, 1.211802190514137e-02, 1.453378770448280e-02, 1.731264802301458e-02, 2.048851971150478e-02, + 2.409539527917081e-02, 2.816685167069475e-02, 3.273551184443837e-02, 3.783246533188810e-02, 4.348665559839211e-02, + 4.972424366422929e-02, 5.656795903921283e-02, 6.403645052356303e-02, 7.214365077720192e-02, 8.089816969852329e-02, + 9.030273251800713e-02, 1.003536790358444e-01, 1.110405405506510e-01, 1.223457106767086e-01, 1.342442253757111e-01, + 1.467036660932157e-01, 1.596841978637899e-01, 1.731387516273307e-01, 1.870133568030685e-01, 2.012476264477750e-01, + 2.157753931632489e-01, 2.305254894308376e-01, 2.454226613848142e-01, 2.603886003668338e-01, 2.753430721265570e-01, + 2.902051194568206e-01, 3.048943105839568e-01, 3.193320029709852e-01, 3.334425905036104e-01, 3.471547014476447e-01, + 3.604024000326147e-01, 3.731263195417857e-01, 3.852742256277580e-01, 3.968020335005454e-01, 4.076742901287472e-01, + 4.178645650568324e-01, 4.273556452755667e-01, 4.361395400809099e-01, 4.442173028452789e-01, 4.515986821559811e-01, + 4.583016198658067e-01, 4.643516178635941e-01, 4.697809986240601e-01, 4.746280867221525e-01, 4.789363394414859e-01, + 4.827534543679447e-01, 4.861304804889396e-01, 4.891209569144257e-01, 4.917801000389275e-01, 4.941640559535466e-01, + 4.963292304037445e-01, 4.983317038070890e-01, 5.002267340435251e-01, 5.020683451596181e-01, 5.039089960260009e-01, + 5.057993195650324e-01, 5.077879205925190e-01, 5.099212187075181e-01, 5.122433220684072e-01, 5.147959182947806e-01, + 5.176181700509677e-01, 5.207466049576202e-01, 5.242149921562288e-01, 5.280542009005510e-01, 5.322920397381714e-01, + 5.369530779485470e-01, 5.420584537149585e-01, 5.476256758552612e-01, 5.536684276931489e-01, 5.601963827419005e-01, + 5.672150422730262e-01, 5.747256045798048e-01, 5.827248748908062e-01, 5.912052235447917e-01, 6.001545983308831e-01, + 6.095565949599409e-01, 6.193905875944715e-01, 6.296319193412947e-01, 6.402521506992933e-01, 6.512193622254838e-01, + 6.624985061836945e-01, 6.740518006968909e-01, 6.858391589448801e-01, 6.978186452298805e-01, 7.099469492625143e-01, + 7.221798697869513e-01, 7.344727986533678e-01, 7.467811966479000e-01, 7.590610527959840e-01, 7.712693194564819e-01, + 7.833643163120154e-01, 7.953060973228134e-01, 8.070567758283893e-01, 8.185808042273020e-01, 8.298452060049231e-01, + 8.408197592685507e-01, 8.514771323358515e-01, 8.617929732481214e-01, 8.717459562819760e-01, 8.813177895502246e-01, + 8.904931885580764e-01, 8.992598210679454e-01, 9.076082287937692e-01, 9.155317312832600e-01, 9.230263168675006e-01, + 9.300905248019673e-01, 9.367253217576155e-01, 9.429339747337118e-01, 9.487219213595656e-01, 9.540966375393273e-01, + 9.590675015747306e-01, 9.636456533576906e-01, 9.678438470101040e-01, 9.716762954761368e-01, 9.751585060165801e-01, + 9.783071062524560e-01, 9.811396612648455e-01, 9.836744831733611e-01, 9.859304354792453e-01, 9.879267351759304e-01, + 9.896827561287711e-01, 9.912178374656364e-01, 9.925511006920656e-01, 9.937012789694025e-01, 9.946865615154821e-01, + 9.955244554643670e-01, 9.962316668199601e-01, 9.968240014222112e-01, 9.973162861697706e-01, 9.977223101520583e-01, + 9.980547848638137e-01, 9.983253223174189e-01, 9.985444296291865e-01, 9.987215185204544e-01, 9.988649281201196e-01, + 9.989819594562657e-01, 9.990789200557365e-01, 9.991611771110095e-01, 9.992332177094652e-01, 9.992987146446982e-01, + 9.993605963440879e-01, 9.994211194587087e-01, 9.994819426820254e-01, 9.995442004050701e-01, 9.996085748889234e-01, + 9.996753657478641e-01, 9.997445556919270e-01, 9.998158716802928e-01, 9.998888409489480e-01, 9.999628437059447e-01, + 1.000037122530308e+00, 1.000110932111342e+00, 1.000183434550577e+00, 1.000253775458271e+00, 1.000321131235573e+00, + 1.000384720523657e+00, 1.000443814718821e+00, 1.000497747347372e+00, 1.000545922137548e+00, 1.000587819673348e+00, + 1.000623002564305e+00, 1.000651119113520e+00, 1.000671905511154e+00, 1.000685186620367e+00, 1.000690875455855e+00, + 1.000688971480779e+00, 1.000679557865722e+00, 1.000662797863287e+00, 1.000638930454792e+00, 1.000608265421794e+00, + 1.000571177986086e+00, 1.000528103148456e+00, 1.000479529839953e+00, 1.000425994980975e+00, 1.000368077524065e+00, + 1.000306392536921e+00, 1.000241585363485e+00, 1.000174325883803e+00, 1.000105302878071e+00, 1.000035218487335e+00, + 9.999647827529677e-01, 9.998947082094627e-01, 9.998257045004189e-01, 9.997584729859116e-01, 9.996937013107159e-01, + 9.996320579071534e-01, 9.995741864134795e-01, 9.995206999987033e-01, 9.994721755972762e-01, 9.994291480719714e-01, + 9.993921043401182e-01, 9.993614775166697e-01, 9.993376411467469e-01, 9.993209036195655e-01, 9.993115028741053e-01, + 9.993096015235072e-01, 9.993152825388751e-01, 9.993285456427281e-01, 9.993493045667127e-01, 9.993773853262324e-01, + 9.994125256556279e-01, 9.994543757308175e-01, 9.995025002817920e-01, 9.995563821653024e-01, 9.996154274293025e-01, + 9.996789718565903e-01, 9.997462889273712e-01, 9.998165990914856e-01, 9.998890801932255e-01, 9.999628788477228e-01, + 1.000037122530308e+00, 1.000110932111343e+00, 1.000183434550578e+00, 1.000253775458273e+00, 1.000321131235574e+00, + 1.000384720523658e+00, 1.000443814718822e+00, 1.000497747347373e+00, 1.000545922137550e+00, 1.000587819673349e+00, + 1.000623002564306e+00, 1.000651119113521e+00, 1.000671905511155e+00, 1.000685186620368e+00, 1.000690875455855e+00, + 1.000688971480779e+00, 1.000679557865721e+00, 1.000662797863286e+00, 1.000638930454791e+00, 1.000608265421792e+00, + 1.000571177986083e+00, 1.000528103148453e+00, 1.000479529839950e+00, 1.000425994980971e+00, 1.000368077524061e+00, + 1.000306392536917e+00, 1.000241585363480e+00, 1.000174325883798e+00, 1.000105302878066e+00, 1.000035218487330e+00, + 9.999647827529627e-01, 9.998947082094576e-01, 9.998257045004140e-01, 9.997584729859067e-01, 9.996937013107114e-01, + 9.996320579071492e-01, 9.995741864134757e-01, 9.995206999987001e-01, 9.994721755972732e-01, 9.994291480719688e-01, + 9.993921043401160e-01, 9.993614775166682e-01, 9.993376411467459e-01, 9.993209036195649e-01, 9.993115028741050e-01, + 9.993096015235075e-01, 9.993152825388757e-01, 9.993285456427290e-01, 9.993493045667138e-01, 9.993773853262338e-01, + 9.994125256556294e-01, 9.994543757308189e-01, 9.995025002817937e-01, 9.995563821653038e-01, 9.996154274293039e-01, + 9.996789718565914e-01, 9.997462889273723e-01, 9.998165990914865e-01, 9.998890801932260e-01, 9.999628788477231e-01, + 1.000037087385911e+00, 1.000110692813570e+00, 1.000182706868929e+00, 1.000252041323928e+00, 1.000317522732163e+00, + 1.000377862440740e+00, 1.000431621330905e+00, 1.000477167056245e+00, 1.000512623941274e+00, 1.000535816073234e+00, + 1.000544204364164e+00, 1.000534818530052e+00, 1.000504185023504e+00, 1.000448251960702e+00, 1.000362312003691e+00, + 1.000240924003935e+00, 1.000077833997232e+00, 9.998658958833085e-01, 9.995969918486358e-01, 9.992619523233789e-01, + 9.988504750288640e-01, 9.983510424973004e-01, 9.977508373579080e-01, 9.970356547108338e-01, 9.961898110802319e-01, + 9.951960497774461e-01, 9.940354430376489e-01, 9.926872920341389e-01, 9.911290268265915e-01, 9.893361094467528e-01, + 9.872819446267991e-01, 9.849378040627681e-01, 9.822727714796871e-01, 9.792537170020328e-01, 9.758453102910697e-01, + 9.720100824436398e-01, 9.677085466217928e-01, 9.628993866974633e-01, 9.575397217975740e-01, 9.515854525300023e-01, + 9.449916919338839e-01, 9.377132809663818e-01, 9.297053848015243e-01, 9.209241625967119e-01, 9.113274999097554e-01, + 9.008757898394824e-01, 8.895327463959180e-01, 8.772662317107712e-01, 8.640490775465693e-01, 8.498598811668777e-01, + 8.346837559540076e-01, 8.185130181287622e-01, 8.013477924378186e-01, 7.831965216140859e-01, 7.640763666675557e-01, + 7.440134875182273e-01, 7.230431960387166e-01, 7.012099761451619e-01, 6.785673680876833e-01, 6.551777164863924e-01, + 6.311117838899523e-01, 6.064482336696789e-01, 5.812729878873076e-01, 5.556784673902739e-01, 5.297627228142773e-01, + 5.036284664469868e-01, 4.773820160836825e-01, 4.511321631520609e-01, 4.249889785709717e-01, 3.990625711023555e-01, + 3.734618144045748e-01, 3.482930606136814e-01, 3.236588600361913e-01, 2.996567083459001e-01, 2.763778443910257e-01, + 2.539061231327225e-01, 2.323169891052670e-01, 2.116765758470110e-01, 1.920409557494601e-01, 1.734555625129627e-01, + 1.559548047768156e-01, 1.395618845278644e-01, 1.242888277448971e-01, 1.101367277067382e-01, 9.709619389909366e-02, + 8.514799199591219e-02, 7.426385348588532e-02, 6.440742764829473e-02, 5.553534414838273e-02, 4.759835178173250e-02, + 4.054249795560948e-02, 3.431031430250281e-02, 2.884197618951215e-02, 2.407640752522409e-02, 1.995230681955070e-02, + 1.640907554818694e-02, 1.338763515624311e-02, 1.083112419588716e-02, 8.685471885106049e-03, 6.899848624541457e-03, + 5.426997611391803e-03, 4.223454598964128e-03, 3.249665071710221e-03, 2.470009678121166e-03, 1.852749750240329e-03, + 1.369905213535462e-03, 9.970772330834560e-04, 7.132276282050243e-04, 5.004264891539459e-04, 3.435786103798425e-04, + 2.301383718361825e-04, 1.498216022111699e-04, 9.432178886435202e-05, 5.703679621983551e-05, 3.281105011319028e-05, + 1.769696765784037e-05, 8.738278469978569e-06, 3.776770390150926e-06, 1.282520060393973e-06, 1.950213832061108e-07, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00}; + +const LC3_FLOAT MDCT_HRA_WINDOW_960_5ms[960] = { + 6.895487963711672e-08, 2.315162529310440e-07, 5.044776791712418e-07, 9.307951082662299e-07, 1.563406927329763e-06, + 2.467387587537570e-06, 3.721891688909285e-06, 5.422241751611354e-06, 7.682193559629735e-06, 1.063638764371401e-05, + 1.444299034054517e-05, 1.928652559405143e-05, 2.538089690430043e-05, 3.297259712577839e-05, 4.234410206521111e-05, + 5.381744200626993e-05, 6.775794339454556e-05, 8.457813095885401e-05, 1.047417785352287e-04, 1.287680948104183e-04, + 1.572360281259058e-04, 1.907886723956216e-04, 2.301377541053808e-04, 2.760681782947526e-04, 3.294426093879363e-04, + 3.912060607548454e-04, 4.623904649625926e-04, 5.441191948366056e-04, 6.376115037051945e-04, 7.441868515669874e-04, + 8.652690824124538e-04, 1.002390416563642e-03, 1.157195220684898e-03, 1.331443517075892e-03, 1.527014193000520e-03, + 1.745907870144461e-03, 1.990249393843025e-03, 2.262289901491620e-03, 2.564408429555132e-03, 2.899113018840483e-03, + 3.269041278198808e-03, 3.676960367589013e-03, 4.125766362471570e-03, 4.618482962817473e-03, 5.158259511618939e-03, + 5.748368289680850e-03, 6.392201055659471e-03, 7.093264802800713e-03, 7.855176706615627e-03, 8.681658240816716e-03, + 9.576528442223354e-03, 1.054369630902618e-02, 1.158715232077375e-02, 1.271095907270489e-02, 1.391924102158781e-02, + 1.521617334503430e-02, 1.660596992132020e-02, 1.809287044204954e-02, 1.968112667553175e-02, 2.137498790448110e-02, + 2.317868556757386e-02, 2.509641714048705e-02, 2.713232929826755e-02, 2.929050040721149e-02, 3.157492240084053e-02, + 3.398948210100576e-02, 3.653794205159846e-02, 3.922392093875195e-02, 4.205087367774323e-02, 4.502207125299418e-02, + 4.814058040358271e-02, 5.140924325245049e-02, 5.483065698298122e-02, 5.840715367176064e-02, 6.214078039106200e-02, + 6.603327969885861e-02, 7.008607063789310e-02, 7.430023036845897e-02, 7.867647656201358e-02, 8.321515068447660e-02, + 8.791620229900704e-02, 9.277917451814051e-02, 9.780319073433394e-02, 1.029869427561657e-01, 1.083286804746118e-01, + 1.138262031799212e-01, 1.194768526446087e-01, 1.252775080819347e-01, 1.312245830819321e-01, 1.373140246185531e-01, + 1.435413142118472e-01, 1.499014713182564e-01, 1.563890590101503e-01, 1.629981919926660e-01, 1.697225469918130e-01, + 1.765553755327395e-01, 1.834895191111025e-01, 1.905174267437600e-01, 1.976311748676255e-01, 2.048224895376239e-01, + 2.120827708564311e-01, 2.194031195502149e-01, 2.267743655861134e-01, 2.341870987088808e-01, 2.416317007561807e-01, + 2.490983795946414e-01, 2.565772045021951e-01, 2.640581428066213e-01, 2.715310975758094e-01, 2.789859461422405e-01, + 2.864125792327671e-01, 2.938009404650995e-01, 3.011410659646723e-01, 3.084231238498945e-01, 3.156374533302977e-01, + 3.227746031609007e-01, 3.298253691972654e-01, 3.367808307992519e-01, 3.436323858374391e-01, 3.503717840645000e-01, + 3.569912187918766e-01, 3.634832564154323e-01, 3.698408960767766e-01, 3.760576237679591e-01, 3.821274200069671e-01, + 3.880447807855012e-01, 3.938047354128900e-01, 3.994028614671444e-01, 4.048352968090768e-01, 4.100987486186185e-01, + 4.151904994338012e-01, 4.201084101968628e-01, 4.248509203362432e-01, 4.294170449371775e-01, 4.338063690767977e-01, + 4.380190394218450e-01, 4.420557532080190e-01, 4.459177447394188e-01, 4.496067695642793e-01, 4.531250864990879e-01, + 4.564754376870322e-01, 4.596610268884718e-01, 4.626854962106256e-01, 4.655529014908880e-01, 4.682676865530477e-01, + 4.708346565582213e-01, 4.732589506724937e-01, 4.755460142711474e-01, 4.777015708950234e-01, 4.797315941680489e-01, + 4.816422798764418e-01, 4.834400183996339e-01, 4.851313676707616e-01, 4.867230268307342e-01, 4.882218107246894e-01, + 4.896346253731921e-01, 4.909684445331096e-01, 4.922302874448856e-01, 4.934271978441982e-01, 4.945662242969564e-01, + 4.956544018975119e-01, 4.966987353511036e-01, 4.977061834431282e-01, 4.986836448801200e-01, 4.996379454705324e-01, + 5.005758265977741e-01, 5.015039349236500e-01, 5.024288132476197e-01, 5.033568924361829e-01, 5.042944843274677e-01, + 5.052477755087517e-01, 5.062228218592734e-01, 5.072255437473754e-01, 5.082617217696771e-01, 5.093369929206453e-01, + 5.104568470835084e-01, 5.116266237378464e-01, 5.128515087852868e-01, 5.141365314023457e-01, 5.154865608384481e-01, + 5.169063030872989e-01, 5.184002973708743e-01, 5.199729123871391e-01, 5.216283422849100e-01, 5.233706023418981e-01, + 5.252035243345977e-01, 5.271307516011422e-01, 5.291557338103311e-01, 5.312817214614957e-01, 5.335117601505942e-01, + 5.358486846476969e-01, 5.382951128397399e-01, 5.408534395999681e-01, 5.435258306517384e-01, 5.463142164993156e-01, + 5.492202865018518e-01, 5.522454831689516e-01, 5.553909967570894e-01, 5.586577602456578e-01, 5.620464447697334e-01, + 5.655574555837481e-01, 5.691909286262941e-01, 5.729467277513715e-01, 5.768244426856284e-01, 5.808233877646608e-01, + 5.849426014943921e-01, 5.891808469760642e-01, 5.935366132255452e-01, 5.980081174096790e-01, 6.025933080143371e-01, + 6.072898689508155e-01, 6.120952245993402e-01, 6.170065457808297e-01, 6.220207566407007e-01, 6.271345424215810e-01, + 6.323443580952387e-01, 6.376464378179791e-01, 6.430368051681870e-01, 6.485112841196261e-01, 6.540655106995645e-01, + 6.596949452767820e-01, 6.653948854210106e-01, 6.711604792723804e-01, 6.769867393569574e-01, 6.828685567824609e-01, + 6.888007157467320e-01, 6.947779082904570e-01, 7.007947492250285e-01, 7.068457911662456e-01, 7.129255396047764e-01, + 7.190284679449507e-01, 7.251490324444848e-01, 7.312816869891655e-01, 7.374208976383266e-01, 7.435611568791312e-01, + 7.496969975302182e-01, 7.558230062381704e-01, 7.619338365135002e-01, 7.680242212564293e-01, 7.740889847266266e-01, + 7.801230539152502e-01, 7.861214692821104e-01, 7.920793948254449e-01, 7.979921274567765e-01, 8.038551056583576e-01, + 8.096639174059964e-01, 8.154143073453887e-01, 8.211021832154612e-01, 8.267236215176270e-01, 8.322748724351863e-01, + 8.377523640123131e-01, 8.431527056071227e-01, 8.484726906381246e-01, 8.537092986478724e-01, 8.588596967118024e-01, + 8.639212402239919e-01, 8.688914730948750e-01, 8.737681273987250e-01, 8.785491225109360e-01, 8.832325637767802e-01, + 8.878167407543193e-01, 8.923001250745454e-01, 8.966813679615423e-01, 9.009592974545819e-01, 9.051329153725320e-01, + 9.092013940588521e-01, 9.131640729428008e-01, 9.170204549493250e-01, 9.207702027865553e-01, 9.244131351359152e-01, + 9.279492227657136e-01, 9.313785845847777e-01, 9.347014836483568e-01, 9.379183231242151e-01, 9.410296422227417e-01, + 9.440361120910473e-01, 9.469385316675432e-01, 9.497378234904927e-01, 9.524350294515523e-01, 9.550313064834267e-01, + 9.575279221695473e-01, 9.599262502631155e-01, 9.622277661029504e-01, 9.644340419143761e-01, 9.665467419847689e-01, + 9.685676177053684e-01, 9.704985024734301e-01, 9.723413064517235e-01, 9.740980111855780e-01, 9.757706640811671e-01, + 9.773613727522825e-01, 9.788722992464219e-01, 9.803056541645230e-01, 9.816636906919504e-01, 9.829486985613498e-01, + 9.841629979706453e-01, 9.853089334816367e-01, 9.863888679264271e-01, 9.874051763501168e-01, 9.883602400189044e-01, + 9.892564405229114e-01, 9.900961540026917e-01, 9.908817455275554e-01, 9.916155636525488e-01, 9.922999351792323e-01, + 9.929371601433686e-01, 9.935295070502858e-01, 9.940792083761523e-01, 9.945884563506685e-01, 9.950593990338927e-01, + 9.954941366970841e-01, 9.958947185146307e-01, 9.962631395714290e-01, 9.966013381874510e-01, 9.969111935588407e-01, + 9.971945237126117e-01, 9.974530837700109e-01, 9.976885645118487e-01, 9.979025912375212e-01, 9.980967229081705e-01, + 9.982724515633580e-01, 9.984312019997783e-01, 9.985743316998982e-01, 9.987031309979628e-01, 9.988188234704969e-01, + 9.989225665382725e-01, 9.990154522666818e-01, 9.990985083514453e-01, 9.991726992767055e-01, 9.992389276326772e-01, + 9.992980355801597e-01, 9.993508064493677e-01, 9.993979664606926e-01, 9.994401865550964e-01, 9.994780843219823e-01, + 9.995122260124369e-01, 9.995431286258258e-01, 9.995712620577665e-01, 9.995970512975859e-01, 9.996208786634017e-01, + 9.996430860630976e-01, 9.996639772695648e-01, 9.996838201987696e-01, 9.997028491794524e-01, 9.997212672035590e-01, + 9.997392481469061e-01, 9.997569389500512e-01, 9.997744617498990e-01, 9.997919159532207e-01, 9.998093802440068e-01, + 9.998269145173621e-01, 9.998445617335565e-01, 9.998623496867628e-01, 9.998802926840086e-01, 9.998983931308962e-01, + 9.999166430217568e-01, 9.999350253331990e-01, 9.999535153223720e-01, 9.999720817407219e-01, 9.999906880869937e-01, + 1.000009287384094e+00, 1.000027834887701e+00, 1.000046300263356e+00, 1.000064628855653e+00, 1.000082766500416e+00, + 1.000100659718907e+00, 1.000118255908114e+00, 1.000135503526064e+00, 1.000152352271145e+00, 1.000168753254485e+00, + 1.000184659164501e+00, 1.000200024422812e+00, 1.000214805330795e+00, 1.000228960206152e+00, 1.000242449508936e+00, + 1.000255235956603e+00, 1.000267284627736e+00, 1.000278563054190e+00, 1.000289041301502e+00, 1.000298692037510e+00, + 1.000307490589210e+00, 1.000315414987954e+00, 1.000322446003211e+00, 1.000328567165139e+00, 1.000333764776314e+00, + 1.000338027913029e+00, 1.000341348416600e+00, 1.000343720875191e+00, 1.000345142596687e+00, 1.000345613573201e+00, + 1.000345136437780e+00, 1.000343716413940e+00, 1.000341361258634e+00, 1.000338081199265e+00, 1.000333888865364e+00, + 1.000328799215526e+00, 1.000322829460192e+00, 1.000315998980821e+00, 1.000308329246033e+00, 1.000299843725172e+00, + 1.000290567799819e+00, 1.000280528673668e+00, 1.000269755281177e+00, 1.000258278195373e+00, 1.000246129535135e+00, + 1.000233342872247e+00, 1.000219953138478e+00, 1.000205996532915e+00, 1.000191510429709e+00, 1.000176533286394e+00, + 1.000161104552890e+00, 1.000145264581248e+00, 1.000129054536203e+00, 1.000112516306544e+00, 1.000095692417284e+00, + 1.000078625942615e+00, 1.000061360419570e+00, 1.000043939762341e+00, 1.000026408177143e+00, 1.000008810077537e+00, + 9.999911900000854e-01, 9.999735925202352e-01, 9.999560621682817e-01, 9.999386433453050e-01, 9.999213802389432e-01, + 9.999043167388835e-01, 9.998874963519558e-01, 9.998709621167259e-01, 9.998547565174905e-01, 9.998389213976104e-01, + 9.998234978721111e-01, 9.998085262395175e-01, 9.997940458929213e-01, 9.997800952302701e-01, 9.997667115639504e-01, + 9.997539310297094e-01, 9.997417884950316e-01, 9.997303174671138e-01, 9.997195500006013e-01, 9.997095166053042e-01, + 9.997002461541395e-01, 9.996917657915899e-01, 9.996841008429919e-01, 9.996772747250358e-01, 9.996713088578647e-01, + 9.996662225792015e-01, 9.996620330610038e-01, 9.996587552291110e-01, 9.996564016864400e-01, 9.996549826402822e-01, + 9.996545058342721e-01, 9.996549764856241e-01, 9.996563972282545e-01, 9.996587680623811e-01, 9.996620863112294e-01, + 9.996663465854424e-01, 9.996715407557830e-01, 9.996776579346981e-01, 9.996846844672899e-01, 9.996926039321870e-01, + 9.997013971527812e-01, 9.997110422192300e-01, 9.997215145215743e-01, 9.997327867942448e-01, 9.997448291721661e-01, + 9.997576092585791e-01, 9.997710922046226e-01, 9.997852408006243e-01, 9.998000155789548e-01, 9.998153749282088e-01, + 9.998312752183693e-01, 9.998476709365326e-01, 9.998645148326526e-01, 9.998817580746910e-01, 9.998993504124509e-01, + 9.999172403493095e-01, 9.999353753209654e-01, 9.999537018802583e-01, 9.999721658870582e-01, 9.999907127021609e-01, + 1.000009287384094e+00, 1.000027834887701e+00, 1.000046300263357e+00, 1.000064628855654e+00, 1.000082766500417e+00, + 1.000100659718908e+00, 1.000118255908115e+00, 1.000135503526065e+00, 1.000152352271146e+00, 1.000168753254487e+00, + 1.000184659164503e+00, 1.000200024422814e+00, 1.000214805330797e+00, 1.000228960206154e+00, 1.000242449508937e+00, + 1.000255235956604e+00, 1.000267284627737e+00, 1.000278563054191e+00, 1.000289041301503e+00, 1.000298692037512e+00, + 1.000307490589211e+00, 1.000315414987955e+00, 1.000322446003212e+00, 1.000328567165140e+00, 1.000333764776315e+00, + 1.000338027913030e+00, 1.000341348416601e+00, 1.000343720875191e+00, 1.000345142596688e+00, 1.000345613573201e+00, + 1.000345136437780e+00, 1.000343716413940e+00, 1.000341361258634e+00, 1.000338081199264e+00, 1.000333888865363e+00, + 1.000328799215525e+00, 1.000322829460191e+00, 1.000315998980820e+00, 1.000308329246031e+00, 1.000299843725170e+00, + 1.000290567799817e+00, 1.000280528673665e+00, 1.000269755281174e+00, 1.000258278195370e+00, 1.000246129535132e+00, + 1.000233342872243e+00, 1.000219953138474e+00, 1.000205996532911e+00, 1.000191510429705e+00, 1.000176533286390e+00, + 1.000161104552886e+00, 1.000145264581243e+00, 1.000129054536198e+00, 1.000112516306539e+00, 1.000095692417279e+00, + 1.000078625942610e+00, 1.000061360419565e+00, 1.000043939762336e+00, 1.000026408177138e+00, 1.000008810077532e+00, + 9.999911900000801e-01, 9.999735925202301e-01, 9.999560621682765e-01, 9.999386433453000e-01, 9.999213802389382e-01, + 9.999043167388785e-01, 9.998874963519510e-01, 9.998709621167211e-01, 9.998547565174859e-01, 9.998389213976059e-01, + 9.998234978721068e-01, 9.998085262395136e-01, 9.997940458929174e-01, 9.997800952302665e-01, 9.997667115639468e-01, + 9.997539310297062e-01, 9.997417884950285e-01, 9.997303174671109e-01, 9.997195500005988e-01, 9.997095166053018e-01, + 9.997002461541374e-01, 9.996917657915880e-01, 9.996841008429901e-01, 9.996772747250343e-01, 9.996713088578635e-01, + 9.996662225792006e-01, 9.996620330610030e-01, 9.996587552291103e-01, 9.996564016864398e-01, 9.996549826402821e-01, + 9.996545058342721e-01, 9.996549764856244e-01, 9.996563972282549e-01, 9.996587680623816e-01, 9.996620863112300e-01, + 9.996663465854433e-01, 9.996715407557840e-01, 9.996776579346992e-01, 9.996846844672912e-01, 9.996926039321883e-01, + 9.997013971527825e-01, 9.997110422192316e-01, 9.997215145215756e-01, 9.997327867942462e-01, 9.997448291721677e-01, + 9.997576092585806e-01, 9.997710922046239e-01, 9.997852408006256e-01, 9.998000155789563e-01, 9.998153749282102e-01, + 9.998312752183705e-01, 9.998476709365336e-01, 9.998645148326535e-01, 9.998817580746918e-01, 9.998993504124516e-01, + 9.999172403493102e-01, 9.999353753209660e-01, 9.999537018802587e-01, 9.999721658870584e-01, 9.999907127021610e-01, + 1.000009262768464e+00, 1.000027750736626e+00, 1.000046113687940e+00, 1.000064278821780e+00, 1.000082169071538e+00, + 1.000099702238537e+00, 1.000116790156982e+00, 1.000133337763978e+00, 1.000149242061725e+00, 1.000164390968527e+00, + 1.000178662057694e+00, 1.000191921184823e+00, 1.000204021005123e+00, 1.000214799383556e+00, 1.000224077701589e+00, + 1.000231659065357e+00, 1.000237326420850e+00, 1.000240840582544e+00, 1.000241938182520e+00, 1.000240329547572e+00, + 1.000235696512191e+00, 1.000227690175467e+00, 1.000215928609961e+00, 1.000199994530463e+00, 1.000179432930259e+00, + 1.000153748692032e+00, 1.000122404179984e+00, 1.000084816818973e+00, 1.000040356665695e+00, 9.999883439759534e-01, + 9.999280467710976e-01, 9.998586784056549e-01, 9.997793951371076e-01, 9.996892936976876e-01, 9.995874088670188e-01, + 9.994727110434261e-01, 9.993441038107910e-01, 9.992004214970033e-01, 9.990404267193601e-01, 9.988628079116455e-01, + 9.986661768272946e-01, 9.984490660128014e-01, 9.982099262455740e-01, 9.979471239307242e-01, 9.976589384518300e-01, + 9.973435594715599e-01, 9.969990841792483e-01, 9.966235144840385e-01, 9.962147541541155e-01, 9.957706059048574e-01, + 9.952887684414411e-01, 9.947668334645193e-01, 9.942022826511501e-01, 9.935924846270409e-01, 9.929346919504907e-01, + 9.922260381330554e-01, 9.914635347268980e-01, 9.906440685140006e-01, 9.897643988377397e-01, 9.888211551228012e-01, + 9.878108346347950e-01, 9.867298005362246e-01, 9.855742803004703e-01, 9.843403645500459e-01, 9.830240063894612e-01, + 9.816210213063771e-01, 9.801270877173017e-01, 9.785377482356147e-01, 9.768484117402024e-01, 9.750543563222487e-01, + 9.731507331856758e-01, 9.711325715733536e-01, 9.689947847863860e-01, 9.667321773575633e-01, 9.643394534324848e-01, + 9.618112264029069e-01, 9.591420298267040e-01, 9.563263296575538e-01, 9.533585377951747e-01, 9.502330269539270e-01, + 9.469441468339291e-01, 9.434862415648529e-01, 9.398536683783788e-01, 9.360408174512334e-01, 9.320421328469384e-01, + 9.278521344711611e-01, 9.234654409430395e-01, 9.188767932732427e-01, 9.140810792290244e-01, 9.090733582572249e-01, + 9.038488868282046e-01, 8.984031440571518e-01, 8.927318574541139e-01, 8.868310286504967e-01, 8.806969589476717e-01, + 8.743262745326578e-01, 8.677159512065934e-01, 8.608633384737868e-01, 8.537661828424618e-01, 8.464226501927783e-01, + 8.388313470732423e-01, 8.309913407930509e-01, 8.229021781851953e-01, 8.145639029231079e-01, 8.059770712821837e-01, + 7.971427662465509e-01, 7.880626098708469e-01, 7.787387738164395e-01, 7.691739879913762e-01, 7.593715472332762e-01, + 7.493353159843403e-01, 7.390697309175267e-01, 7.285798014827035e-01, 7.178711083511555e-01, 7.069497997461519e-01, + 6.958225856563154e-01, 6.844967299372567e-01, 6.729800403152869e-01, 6.612808563149986e-01, 6.494080351400781e-01, + 6.373709355438772e-01, 6.251793997330287e-01, 6.128437333537300e-01, 6.003746836162993e-01, 5.877834156192006e-01, + 5.750814869390165e-01, 5.622808205578382e-01, 5.493936762043069e-01, 5.364326201891255e-01, 5.234104938203454e-01, + 5.103403804881693e-01, 4.972355715134865e-01, 4.841095308589323e-01, 4.709758588060189e-01, 4.578482547068641e-01, + 4.447404789243264e-01, 4.316663140799624e-01, 4.186395257351866e-01, 4.056738226373441e-01, 3.927828166690819e-01, + 3.799799826463771e-01, 3.672786181177968e-01, 3.546918033248968e-01, 3.422323614910038e-01, 3.299128196128071e-01, + 3.177453699359932e-01, 3.057418323024091e-01, 2.939136175616680e-01, 2.822716922444745e-01, 2.708265446979701e-01, + 2.595881528848133e-01, 2.485659540472639e-01, 2.377688164349652e-01, 2.272050132902212e-01, 2.168821992771410e-01, + 2.068073895309444e-01, 1.969869414909128e-01, 1.874265396648929e-01, 1.781311834549869e-01, 1.691051781531976e-01, + 1.603521291925451e-01, 1.518749397137918e-01, 1.436758114807520e-01, 1.357562491485994e-01, 1.281170678600890e-01, + 1.207584041146470e-01, 1.136797298253828e-01, 1.068798694497608e-01, 1.003570200514591e-01, 9.410877412434678e-02, + 8.813214498499827e-02, 8.242359451816077e-02, 7.697906304046008e-02, 7.179400103167609e-02, 6.686340247035585e-02, + 6.218183950151154e-02, 5.774349815872721e-02, 5.354221486116098e-02, 4.957151340757950e-02, 4.582464219454362e-02, + 4.229461139394613e-02, 3.897422983601720e-02, 3.585614135733534e-02, 3.293286038897012e-02, 3.019680657726779e-02, + 2.764033824859545e-02, 2.525578454921406e-02, 2.303547611198478e-02, 2.097177412248857e-02, 1.905709767802756e-02, + 1.728394935359176e-02, 1.564493890895436e-02, 1.413280509038132e-02, 1.274043549881785e-02, 1.146088451369467e-02, + 1.028738927756386e-02, 9.213383761543762e-03, 8.232510944970423e-03, 7.338633154694566e-03, 6.525840620123105e-03, + 5.788458309403464e-03, 5.121051120120478e-03, 4.518427504569718e-03, 3.975641615147556e-03, 3.487994059724770e-03, + 3.051031360120983e-03, 2.660544209048234e-03, 2.312564622222088e-03, 2.003362082825875e-03, 1.729438775235064e-03, + 1.487524003938835e-03, 1.274567892006584e-03, 1.087734451306357e-03, 9.243941140548951e-04, 7.821158122256320e-04, + 6.586586879186365e-04, 5.519635140582476e-04, 4.601439007796695e-04, 3.814773586413279e-04, 3.143962853984603e-04, + 2.574789385355991e-04, 2.094404511189233e-04, 1.691239438292752e-04, 1.354917813061114e-04, 1.076170162029800e-04, + 8.467505965565773e-05, 6.593561222250244e-05, 5.075488479887568e-05, 3.856813455801580e-05, 2.888253665201353e-05, + 2.127040823889544e-05, 1.536279740228267e-05, 1.084344570939908e-05, 7.443129506680882e-06, 4.934381529209004e-06, + 3.126590786650604e-06, 1.861474073153740e-06, 1.008902130957542e-06, 4.630128105556161e-07, 1.379047824504878e-07, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00}; + +const LC3_FLOAT MDCT_HRA_WINDOW_480_10ms[960] = { + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 9.423411645757145e-08, 6.198383813913816e-07, 1.826038044753334e-06, 4.227415544684874e-06, 8.568221371240009e-06, + 1.590138306691229e-05, 2.767384916372097e-05, 4.582461489197476e-05, 7.289566442148343e-05, 1.121553337189409e-04, + 1.677330226576781e-04, 2.447635817250988e-04, 3.495390594774230e-04, 4.896648355656373e-04, 6.742165007916612e-04, + 9.138932038423809e-04, 1.221162590096684e-03, 1.610391938745493e-03, 2.097959688543948e-03, 2.702341257534836e-03, + 3.444162934209273e-03, 4.346217670272292e-03, 5.433436858058855e-03, 6.732812643305091e-03, 8.273266014983896e-03, + 1.008545682987358e-02, 1.220153306437313e-02, 1.465481792555360e-02, 1.747943497487382e-02, 2.070987309036685e-02, + 2.438049487743156e-02, 2.852499398840518e-02, 3.317580867440409e-02, 3.836350071222914e-02, 4.411611056397528e-02, + 5.045850117560903e-02, 5.741170414223051e-02, 6.499228300404947e-02, 7.321172913556540e-02, 8.207590600577601e-02, + 9.158455748369454e-02, 1.017308953166495e-01, 1.125012799073065e-01, 1.238750070616895e-01, 1.358242114920720e-01, + 1.483138955678087e-01, 1.613020891609740e-01, 1.747401434927874e-01, 1.885731587242474e-01, 2.027405417335493e-01, + 2.171766871750067e-01, 2.318117716158385e-01, 2.465726473968904e-01, 2.613838199586506e-01, 2.761684898079396e-01, + 2.908496381590925e-01, 3.053511336415384e-01, 3.195988363856895e-01, 3.335216753280081e-01, 3.470526747443392e-01, + 3.601299968134419e-01, 3.726979341699064e-01, 3.847073300820699e-01, 3.961165192918680e-01, 4.068917464693262e-01, + 4.170075357150957e-01, 4.264469007050540e-01, 4.352013996719531e-01, 4.432710380854631e-01, 4.506640257151909e-01, + 4.573963985795680e-01, 4.634915197715306e-01, 4.689794761564862e-01, 4.738963903364035e-01, 4.782836689638748e-01, + 4.821872093925473e-01, 4.856565867140006e-01, 4.887442424370954e-01, 4.915046944332492e-01, 4.939937853618382e-01, + 4.962679837116828e-01, 4.983837480011794e-01, 5.003969607669508e-01, 5.023624349677376e-01, 5.043334915837460e-01, + 5.063616037481589e-01, 5.084960999306821e-01, 5.107839166820760e-01, 5.132693903594975e-01, 5.159940771247666e-01, + 5.189965912996581e-01, 5.223124537547313e-01, 5.259739442166247e-01, 5.300099539725758e-01, 5.344458381774531e-01, + 5.393032695777062e-01, 5.446000977350559e-01, 5.503502195833738e-01, 5.565634682679432e-01, 5.632455276465002e-01, + 5.703978795909497e-01, 5.780177903898996e-01, 5.860983412324646e-01, 5.946285060985402e-01, 6.035932785464501e-01, + 6.129738470263359e-01, 6.227478165890419e-01, 6.328894733093686e-01, 6.433700864704220e-01, 6.541582425999274e-01, + 6.652202048172945e-01, 6.765202906248624e-01, 6.880212612236103e-01, 6.996847156078869e-01, 7.114714830467992e-01, + 7.233420080447298e-01, 7.352567224482216e-01, 7.471763999968595e-01, 7.590624892758133e-01, 7.708774216994878e-01, + 7.825848918282421e-01, 7.941501079877761e-01, 8.055400118211323e-01, 8.167234660553659e-01, 8.276714104070468e-01, + 8.383569861788307e-01, 8.487556307051457e-01, 8.588451433758131e-01, 8.686057254837016e-01, 8.780199965830640e-01, + 8.870729903819699e-01, 8.957521333967015e-01, 9.040472096414102e-01, 9.119503144919421e-01, 9.194558005383104e-01, + 9.265602177306744e-01, 9.332622494524668e-01, 9.395626453655078e-01, 9.454641510291475e-01, 9.509714334776073e-01, + 9.560910012334918e-01, 9.608311167251793e-01, 9.652016988316350e-01, 9.692142133449947e-01, 9.728815495300325e-01, + 9.762178816434048e-01, 9.792385151909874e-01, 9.819597187561544e-01, 9.843985433157453e-01, 9.865726319613708e-01, + 9.885000237614154e-01, 9.901989560579394e-01, 9.916876697497727e-01, 9.929842220610799e-01, 9.941063109595989e-01, + 9.950711148231832e-01, 9.958951502269355e-01, 9.965941499123417e-01, 9.971829621771531e-01, 9.976754721515079e-01, + 9.980845447462318e-01, 9.984219884986877e-01, 9.986985391068631e-01, 9.989238611254968e-01, 9.991065660804971e-01, + 9.992542451163898e-01, 9.993735142030505e-01, 9.994700698738658e-01, 9.995487534360048e-01, 9.996136215806155e-01, + 9.996680213292980e-01, 9.997146672907700e-01, 9.997557192777461e-01, 9.997928584573587e-01, 9.998273603841155e-01, + 9.998601634925650e-01, 9.998919319028886e-01, 9.999231117133845e-01, 9.999539803782231e-01, 9.999846913144619e-01, + 1.000015271687402e+00, 1.000045768313827e+00, 1.000076123719886e+00, 1.000106243781657e+00, 1.000136035347070e+00, + 1.000165406619359e+00, 1.000194267530612e+00, 1.000222530102796e+00, 1.000250108793741e+00, 1.000276920825814e+00, + 1.000302886495191e+00, 1.000327929459891e+00, 1.000351977005012e+00, 1.000374960283849e+00, 1.000396814533868e+00, + 1.000417479266803e+00, 1.000436898432418e+00, 1.000455020555724e+00, 1.000471798847772e+00, 1.000487191290310e+00, + 1.000501160694917e+00, 1.000513674737357e+00, 1.000524705968167e+00, 1.000534231800605e+00, 1.000542234477265e+00, + 1.000548701016775e+00, 1.000553623142091e+00, 1.000556997191966e+00, 1.000558824017243e+00, 1.000559108863603e+00, + 1.000557861242456e+00, 1.000555094791586e+00, 1.000550827127188e+00, 1.000545079688822e+00, 1.000537877578802e+00, + 1.000529249397403e+00, 1.000519227075235e+00, 1.000507845704000e+00, 1.000495143366764e+00, 1.000481160968755e+00, + 1.000465942069620e+00, 1.000449532717920e+00, 1.000431981288574e+00, 1.000413338323831e+00, 1.000393656378250e+00, + 1.000372989868060e+00, 1.000351394925194e+00, 1.000328929256167e+00, 1.000305652005906e+00, 1.000281623626542e+00, + 1.000256905751110e+00, 1.000231561072014e+00, 1.000205653224064e+00, 1.000179246671831e+00, 1.000152406601017e+00, + 1.000125198813461e+00, 1.000097689625410e+00, 1.000069945768613e+00, 1.000042034293768e+00, 1.000014022475844e+00, + 9.999859777207831e-01, 9.999579674730398e-01, 9.999300591234549e-01, 9.999023199169207e-01, 9.998748168593201e-01, + 9.998476166232155e-01, 9.998207854517803e-01, 9.997943890604891e-01, 9.997684925361024e-01, 9.997431602325028e-01, + 9.997184556629950e-01, 9.996944413886967e-01, 9.996711789027117e-01, 9.996487285098250e-01, 9.996271492015102e-01, + 9.996064985261154e-01, 9.995868324541498e-01, 9.995682052386838e-01, 9.995506692709443e-01, 9.995342749312822e-01, + 9.995190704357798e-01, 9.995051016788571e-01, 9.994924120723486e-01, 9.994810423816121e-01, 9.994710305593550e-01, + 9.994624115779566e-01, 9.994552172611834e-01, 9.994494761163015e-01, 9.994452131676952e-01, 9.994424497931953e-01, + 9.994412035644367e-01, 9.994414880926250e-01, 9.994433128811957e-01, 9.994466831869019e-01, 9.994515998909221e-01, + 9.994580593816230e-01, 9.994660534506217e-01, 9.994755692038015e-01, 9.994865889889091e-01, 9.994990903413156e-01, + 9.995130459494618e-01, 9.995284236414108e-01, 9.995451863938154e-01, 9.995632923644638e-01, 9.995826949494031e-01, + 9.996033428654485e-01, 9.996251802586674e-01, 9.996481468392096e-01, 9.996721780425870e-01, 9.996972052172600e-01, + 9.997231558380996e-01, 9.997499537450264e-01, 9.997775194058337e-01, 9.998057702019313e-01, 9.998346207354666e-01, + 9.998639831560286e-01, 9.998937675048852e-01, 9.999238820744936e-01, 9.999542337808154e-01, 9.999847285458191e-01, + 1.000015271687393e+00, 1.000045768313818e+00, 1.000076123719878e+00, 1.000106243781648e+00, 1.000136035347061e+00, + 1.000165406619350e+00, 1.000194267530604e+00, 1.000222530102788e+00, 1.000250108793733e+00, 1.000276920825807e+00, + 1.000302886495184e+00, 1.000327929459883e+00, 1.000351977005006e+00, 1.000374960283843e+00, 1.000396814533862e+00, + 1.000417479266798e+00, 1.000436898432413e+00, 1.000455020555719e+00, 1.000471798847767e+00, 1.000487191290306e+00, + 1.000501160694914e+00, 1.000513674737354e+00, 1.000524705968165e+00, 1.000534231800603e+00, 1.000542234477263e+00, + 1.000548701016774e+00, 1.000553623142090e+00, 1.000556997191965e+00, 1.000558824017242e+00, 1.000559108863603e+00, + 1.000557861242456e+00, 1.000555094791587e+00, 1.000550827127188e+00, 1.000545079688823e+00, 1.000537877578803e+00, + 1.000529249397404e+00, 1.000519227075236e+00, 1.000507845704002e+00, 1.000495143366766e+00, 1.000481160968757e+00, + 1.000465942069622e+00, 1.000449532717922e+00, 1.000431981288576e+00, 1.000413338323833e+00, 1.000393656378252e+00, + 1.000372989868062e+00, 1.000351394925196e+00, 1.000328929256169e+00, 1.000305652005908e+00, 1.000281623626544e+00, + 1.000256905751112e+00, 1.000231561072016e+00, 1.000205653224065e+00, 1.000179246671832e+00, 1.000152406601018e+00, + 1.000125198813462e+00, 1.000097689625411e+00, 1.000069945768614e+00, 1.000042034293768e+00, 1.000014022475844e+00, + 9.999859777207829e-01, 9.999579674730393e-01, 9.999300591234543e-01, 9.999023199169199e-01, 9.998748168593190e-01, + 9.998476166232144e-01, 9.998207854517789e-01, 9.997943890604876e-01, 9.997684925361007e-01, 9.997431602325010e-01, + 9.997184556629931e-01, 9.996944413886946e-01, 9.996711789027095e-01, 9.996487285098227e-01, 9.996271492015080e-01, + 9.996064985261129e-01, 9.995868324541474e-01, 9.995682052386815e-01, 9.995506692709419e-01, 9.995342749312801e-01, + 9.995190704357777e-01, 9.995051016788550e-01, 9.994924120723468e-01, 9.994810423816103e-01, 9.994710305593536e-01, + 9.994624115779553e-01, 9.994552172611824e-01, 9.994494761163009e-01, 9.994452131676944e-01, 9.994424497931950e-01, + 9.994412035644368e-01, 9.994414880926255e-01, 9.994433128811966e-01, 9.994466831869030e-01, 9.994515998909239e-01, + 9.994580593816250e-01, 9.994660534506239e-01, 9.994755692038041e-01, 9.994865889889122e-01, 9.994990903413189e-01, + 9.995130459494656e-01, 9.995284236414153e-01, 9.995451863938203e-01, 9.995632923644688e-01, 9.995826949494085e-01, + 9.996033428654543e-01, 9.996251802586735e-01, 9.996481468392161e-01, 9.996721780425940e-01, 9.996972052172670e-01, + 9.997231558381070e-01, 9.997499537450341e-01, 9.997775194058416e-01, 9.998057702019393e-01, 9.998346207354748e-01, + 9.998639831560371e-01, 9.998937675048939e-01, 9.999238820745020e-01, 9.999542337808240e-01, 9.999847285458278e-01, + 1.000015271687402e+00, 1.000045768313827e+00, 1.000076123719886e+00, 1.000106243781657e+00, 1.000136035347070e+00, + 1.000165406619359e+00, 1.000194267530612e+00, 1.000222530102796e+00, 1.000250108793741e+00, 1.000276920825814e+00, + 1.000302886495191e+00, 1.000327929459890e+00, 1.000351977005012e+00, 1.000374960283849e+00, 1.000396814533868e+00, + 1.000417479266803e+00, 1.000436898432418e+00, 1.000455020555724e+00, 1.000471798847772e+00, 1.000487191290310e+00, + 1.000501160694917e+00, 1.000513674737357e+00, 1.000524705968167e+00, 1.000534231800605e+00, 1.000542234477265e+00, + 1.000548701016775e+00, 1.000553623142091e+00, 1.000556997191966e+00, 1.000558824017243e+00, 1.000559108863603e+00, + 1.000557861242456e+00, 1.000555094791586e+00, 1.000550827127188e+00, 1.000545079688822e+00, 1.000537877578802e+00, + 1.000529249397403e+00, 1.000519227075234e+00, 1.000507845704000e+00, 1.000495143366764e+00, 1.000481160968755e+00, + 1.000465942069620e+00, 1.000449532717920e+00, 1.000431981288574e+00, 1.000413338323831e+00, 1.000393656378250e+00, + 1.000372989868060e+00, 1.000351394925194e+00, 1.000328929256167e+00, 1.000305652005906e+00, 1.000281623626542e+00, + 1.000256905751111e+00, 1.000231561072014e+00, 1.000205653224064e+00, 1.000179246671831e+00, 1.000152406601017e+00, + 1.000125198813461e+00, 1.000097689625410e+00, 1.000069945768614e+00, 1.000042034293768e+00, 1.000014022475844e+00, + 9.999859777207832e-01, 9.999579674730399e-01, 9.999300591234550e-01, 9.999023199169208e-01, 9.998748168593202e-01, + 9.998476166232156e-01, 9.998207854517805e-01, 9.997943890604892e-01, 9.997684925361026e-01, 9.997431602325029e-01, + 9.997184556629951e-01, 9.996944413886968e-01, 9.996711789027117e-01, 9.996487285098250e-01, 9.996271492015103e-01, + 9.996064985261155e-01, 9.995868324541498e-01, 9.995682052386839e-01, 9.995506692709443e-01, 9.995342749312823e-01, + 9.995190704357798e-01, 9.995051016788571e-01, 9.994924120723486e-01, 9.994810423816120e-01, 9.994710305593552e-01, + 9.994624115779566e-01, 9.994552172611834e-01, 9.994494761163015e-01, 9.994452131676951e-01, 9.994424497931953e-01, + 9.994412035644367e-01, 9.994414880926250e-01, 9.994433128811958e-01, 9.994466831869019e-01, 9.994515998909221e-01, + 9.994580593816230e-01, 9.994660534506217e-01, 9.994755692038015e-01, 9.994865889889089e-01, 9.994990903413155e-01, + 9.995130459494618e-01, 9.995284236414110e-01, 9.995451863938154e-01, 9.995632923644640e-01, 9.995826949494031e-01, + 9.996033428654485e-01, 9.996251802586674e-01, 9.996481468392096e-01, 9.996721780425870e-01, 9.996972052172600e-01, + 9.997231558380997e-01, 9.997499537450264e-01, 9.997775194058337e-01, 9.998057702019313e-01, 9.998346207354665e-01, + 9.998639831560286e-01, 9.998937675048852e-01, 9.999238820744936e-01, 9.999542337808154e-01, 9.999847285458191e-01, + 1.000015234454879e+00, 1.000045514887559e+00, 1.000075353237462e+00, 1.000104407768116e+00, 1.000132214556229e+00, + 1.000158143563050e+00, 1.000181349852841e+00, 1.000200717764093e+00, 1.000214798354899e+00, 1.000221740822748e+00, + 1.000219218852980e+00, 1.000204353032496e+00, 1.000173630567007e+00, 1.000122823551604e+00, 1.000046906963284e+00, + 9.999399773758973e-01, 9.997951731574873e-01, 9.996045966188434e-01, 9.993592382687311e-01, 9.990489030278769e-01, + 9.986621379953039e-01, 9.981861611823875e-01, 9.976067905662288e-01, 9.969083728962124e-01, 9.960737119427251e-01, + 9.950839963248127e-01, 9.939187277034516e-01, 9.925556509742455e-01, 9.909706891139552e-01, 9.891378864826104e-01, + 9.870293655848442e-01, 9.846153034530920e-01, 9.818639348132027e-01, 9.787415898998961e-01, 9.752127750773143e-01, + 9.712403041791187e-01, 9.667854876397981e-01, 9.618083850218845e-01, 9.562681244917907e-01, 9.501232902622440e-01, + 9.433323761603356e-01, 9.358543004959359e-01, 9.276489745130293e-01, 9.186779141170132e-01, 9.089048824643602e-01, + 8.982965495078461e-01, 8.868231537804969e-01, 8.744591515805539e-01, 8.611838392360764e-01, 8.469819351830896e-01, + 8.318441100567543e-01, 8.157674547284579e-01, 7.987558780821055e-01, 7.808204281831013e-01, 7.619795322485697e-01, + 7.422591523986999e-01, 7.216928555056540e-01, 7.003217965330363e-01, 6.781946155731466e-01, 6.553672493579565e-01, + 6.319026583753357e-01, 6.078704709095413e-01, 5.833465453994711e-01, 5.584124525334641e-01, 5.331548785464441e-01, + 5.076649513306994e-01, 4.820374912962984e-01, 4.563701895024020e-01, 4.307627165039317e-01, 4.053157666856800e-01, + 3.801300446346412e-01, 3.553052023472212e-01, 3.309387387548210e-01, 3.071248760994941e-01, 2.839534309593199e-01, + 2.615087010038701e-01, 2.398683915856861e-01, 2.191026087292818e-01, 1.992729466284019e-01, 1.804316980820018e-01, + 1.626212151220100e-01, 1.458734442426148e-01, 1.302096560997370e-01, 1.156403834405376e-01, 1.021655736434582e-01, + 8.977495404596501e-02, 7.844859976518601e-02, 6.815768558157265e-02, 5.886539624579484e-02, 5.052796378898961e-02, + 4.309579643342800e-02, 3.651466171052548e-02, 3.072688641085486e-02, 2.567253786455677e-02, 2.129055449466347e-02, + 1.751979822585132e-02, 1.430000675209340e-02, 1.157262945800897e-02, 9.281536579910191e-03, 7.373596677207363e-03, + 5.799122432483531e-03, 4.512189056010577e-03, 3.470833055336534e-03, 2.637141819806632e-03, 1.977246386436426e-03, + 1.461230953040205e-03, 1.062973263413438e-03, 7.599299954798238e-04, 5.328808285940163e-04, 3.656440417062249e-04, + 2.447753867250028e-04, 1.592606718286519e-04, 1.002110509628055e-04, 6.056851356108083e-05, 3.482755929907460e-05, + 1.877757338165862e-05, 9.269020516017977e-06, 4.005234147116555e-06, 1.359891615054068e-06, 2.067694412143206e-07, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00}; + +const LC3_FLOAT MDCT_HRA_WINDOW_960_10ms[1920] = { + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 6.663107991278473e-08, 2.237239208214098e-07, 4.875418283123564e-07, 8.996727135884617e-07, 1.511418282137696e-06, + 2.385908181307981e-06, 3.600021534325060e-06, 5.246458929559746e-06, 7.435999429480928e-06, 1.029995277226023e-05, + 1.399281202683861e-05, 1.869510977726803e-05, 2.461647918005920e-05, 3.199891951615131e-05, 4.112026404149671e-05, + 5.229784600131515e-05, 6.589235661010597e-05, 8.231188661821365e-05, 1.020161407958678e-04, 1.255208122795613e-04, + 1.534021012578998e-04, 1.863013599410517e-04, 2.249298431778123e-04, 2.700735414768832e-04, 3.225980705756125e-04, + 3.834535891028970e-04, 4.536797133272969e-04, 5.344103954917697e-04, 6.268787298389575e-04, 7.324216481524320e-04, + 8.524844645071808e-04, 9.886252269645022e-04, 1.142518832190136e-03, 1.315960857447457e-03, 1.510871063146860e-03, + 1.729296518144556e-03, 1.973414299303950e-03, 2.245533716484770e-03, 2.548098014131402e-03, 2.883685501012940e-03, + 3.255010060441685e-03, 3.664920994479873e-03, 4.116402157249738e-03, 4.612570334499312e-03, 5.156672829053223e-03, + 5.752084214696966e-03, 6.402302224405338e-03, 7.110942742626702e-03, 7.881733875566514e-03, 8.718509078064964e-03, + 9.625199320718177e-03, 1.060582428632988e-02, 1.166448259057781e-02, 1.280534102790626e-02, 1.403262285008227e-02, + 1.535059509154052e-02, 1.676355496255211e-02, 1.827581533833950e-02, 1.989168937947954e-02, 2.161547432623578e-02, + 2.345143451678970e-02, 2.540378368664082e-02, 2.747666661366220e-02, 2.967414018037076e-02, 3.200015393184128e-02, + 3.445853021429810e-02, 3.705294398569962e-02, 3.978690239552551e-02, 4.266372423642605e-02, 4.568651937534197e-02, + 4.885816827608890e-02, 5.218130172917755e-02, 5.565828090775238e-02, 5.929117787093344e-02, 6.308175663749782e-02, + 6.703145495369379e-02, 7.114136687902073e-02, 7.541222631299167e-02, 7.984439158421140e-02, 8.443783122053150e-02, + 8.919211101557852e-02, 9.410638250258946e-02, 9.917937294123873e-02, 1.044093769170137e-01, 1.097942496457128e-01, + 1.153314020678296e-01, 1.210177978089837e-01, 1.268499520732061e-01, 1.328239325258333e-01, 1.389353622120686e-01, + 1.451794245459895e-01, 1.515508703929904e-01, 1.580440272564225e-01, 1.646528105666080e-01, 1.713707370575420e-01, + 1.781909402035578e-01, 1.851061876750831e-01, 1.921089007594860e-01, 1.991911756799545e-01, 2.063448067325118e-01, + 2.135613111487021e-01, 2.208319555793100e-01, 2.281477840827779e-01, 2.354996474908733e-01, 2.428782340136974e-01, + 2.502741009364257e-01, 2.576777072513037e-01, 2.650794470604564e-01, 2.724696835780986e-01, 2.798387835547953e-01, + 2.871771519416024e-01, 2.944752666082350e-01, 3.017237129269402e-01, 3.089132180325088e-01, 3.160346845688595e-01, + 3.230792237339257e-01, 3.300381874371329e-01, 3.369031993875939e-01, 3.436661849362722e-01, 3.503193995017128e-01, + 3.568555192112148e-01, 3.632675601002685e-01, 3.695489358061075e-01, 3.756935099828519e-01, 3.816956001322418e-01, + 3.875499962002574e-01, 3.932519766094684e-01, 3.987973219750102e-01, 4.041823264714043e-01, 4.094038068104935e-01, + 4.144591088030795e-01, 4.193461114921915e-01, 4.240632288619702e-01, 4.286094091423471e-01, 4.329841317457969e-01, + 4.371874018882834e-01, 4.412197429619175e-01, 4.450821867417134e-01, 4.487762615229755e-01, 4.523039782991779e-01, + 4.556678151025579e-01, 4.588706996409412e-01, 4.619159903744011e-01, 4.648074561841559e-01, 4.675492547935124e-01, + 4.701459101065887e-01, 4.726022886349306e-01, 4.749235751849055e-01, 4.771152479798792e-01, 4.791830533906173e-01, + 4.811329804451050e-01, 4.829712352850382e-01, 4.847042157306455e-01, 4.863384861083030e-01, 4.878807524866530e-01, + 4.893378384567565e-01, 4.907166615802867e-01, 4.920242106170628e-01, 4.932675236294833e-01, 4.944536670468351e-01, + 4.955897157572258e-01, 4.966827342792363e-01, 4.977397590495528e-01, 4.987677818470457e-01, 4.997737343582849e-01, + 5.007644738745453e-01, 5.017467700962179e-01, 5.027272930074345e-01, 5.037126017718407e-01, 5.047091345900308e-01, + 5.057231994503223e-01, 5.067609656974670e-01, 5.078284563386384e-01, 5.089315410026908e-01, 5.100759294672467e-01, + 5.112671656686335e-01, 5.125106221119896e-01, 5.138114946028988e-01, 5.151747972275419e-01, 5.166053575154047e-01, + 5.181078117268841e-01, 5.196866002174090e-01, 5.213459628397580e-01, 5.230899343568223e-01, 5.249223398478975e-01, + 5.268467901024086e-01, 5.288666770055838e-01, 5.309851689306879e-01, 5.332052061618728e-01, 5.355294963802417e-01, + 5.379605102532377e-01, 5.405004771737987e-01, 5.431513812007881e-01, 5.459149572559273e-01, 5.487926876348163e-01, + 5.517857988905945e-01, 5.548952591484511e-01, 5.581217759075547e-01, 5.614657943841375e-01, 5.649274964455743e-01, + 5.685068001804389e-01, 5.722033601438381e-01, 5.760165683110121e-01, 5.799455557653441e-01, 5.839891951397580e-01, + 5.881461038230944e-01, 5.924146479356704e-01, 5.967929470708762e-01, 6.012788797925822e-01, 6.058700898713546e-01, + 6.105639932361040e-01, 6.153577856119751e-01, 6.202484508099709e-01, 6.252327696291247e-01, 6.303073293279928e-01, + 6.354685336188206e-01, 6.407126131349797e-01, 6.460356363201389e-01, 6.514335206861067e-01, 6.569020443853303e-01, + 6.624368580436263e-01, 6.680334967987880e-01, 6.736873924912369e-01, 6.793938859538112e-01, 6.851482393490396e-01, + 6.909456485038137e-01, 6.967812551932001e-01, 7.026501593271524e-01, 7.085474309960862e-01, 7.144681223336159e-01, + 7.204072791571976e-01, 7.263599523499238e-01, 7.323212089493037e-01, 7.382861429114533e-01, 7.442498855217515e-01, + 7.502076154256456e-01, 7.561545682559222e-01, 7.620860458353852e-01, 7.679974249364871e-01, 7.738841655820752e-01, + 7.797418188739772e-01, 7.855660343387494e-01, 7.913525667824293e-01, 7.970972826487233e-01, 8.027961658775241e-01, + 8.084453232632074e-01, 8.140409893145931e-01, 8.195795306209357e-01, 8.250574497306905e-01, 8.304713885521608e-01, + 8.358181312874381e-01, 8.410946069132281e-01, 8.462978912242891e-01, 8.514252084571686e-01, 8.564739325137894e-01, + 8.614415878060635e-01, 8.663258497442113e-01, 8.711245448926651e-01, 8.758356508184248e-01, 8.804572956574126e-01, + 8.849877574247438e-01, 8.894254630948657e-01, 8.937689874771898e-01, 8.980170519121489e-01, 9.021685228115252e-01, + 9.062224100654551e-01, 9.101778653366538e-01, 9.140341802602550e-01, 9.177907845650995e-01, 9.214472441295430e-01, + 9.250032589817625e-01, 9.284586612513364e-01, 9.318134130755062e-01, 9.350676044601444e-01, 9.382214510920930e-01, + 9.412752920963378e-01, 9.442295877284584e-01, 9.470849169901138e-01, 9.498419751530142e-01, 9.525015711749794e-01, + 9.550646249903935e-01, 9.575321646566392e-01, 9.599053233380030e-01, 9.621853361091064e-01, 9.643735365611265e-01, + 9.664713531959190e-01, 9.684803055955929e-01, 9.704020003580881e-01, 9.722381267927611e-01, 9.739904523738324e-01, + 9.756608179536774e-01, 9.772511327422573e-01, 9.787633690633392e-01, 9.801995569024828e-01, 9.815617782659093e-01, + 9.828521613732500e-01, 9.840728747106564e-01, 9.852261209738314e-01, 9.863141309330354e-01, 9.873391572540936e-01, + 9.883034683107520e-01, 9.892093420244598e-01, 9.900590597677280e-01, 9.908549003667192e-01, 9.915991342376211e-01, + 9.922940176897662e-01, 9.929417874263897e-01, 9.935446552714569e-01, 9.941048031482164e-01, 9.946243783321176e-01, + 9.951054889975415e-01, 9.955502000745265e-01, 9.959605294283782e-01, 9.963384443718103e-01, 9.966858585161255e-01, + 9.970046289649677e-01, 9.972965538513794e-01, 9.975633702163375e-01, 9.978067522246161e-01, 9.980283097117545e-01, + 9.982295870540839e-01, 9.984120623522111e-01, 9.985771469170162e-01, 9.987261850461071e-01, 9.988604540777616e-01, + 9.989811647086401e-01, 9.990894615609515e-01, 9.991864239842999e-01, 9.992730670770456e-01, 9.993503429117423e-01, + 9.994191419489804e-01, 9.994802946237851e-01, 9.995345730885834e-01, 9.995826930966561e-01, 9.996253160099111e-01, + 9.996630509147824e-01, 9.996964568300586e-01, 9.997260449905023e-01, 9.997522811902100e-01, 9.997755881698448e-01, + 9.997963480321130e-01, 9.998149046701891e-01, 9.998315661942099e-01, 9.998466073415005e-01, 9.998602718567984e-01, + 9.998727748295070e-01, 9.998843049758280e-01, 9.998950268545727e-01, 9.999050830064863e-01, 9.999145960080379e-01, + 9.999236704318017e-01, 9.999323947068164e-01, 9.999408428735685e-01, 9.999490762295546e-01, 9.999571448627051e-01, + 9.999650890712967e-01, 9.999729406705412e-01, 9.999807241886484e-01, 9.999884579652744e-01, 9.999961552850937e-01, + 1.000003818641721e+00, 1.000011453001950e+00, 1.000019078522643e+00, 1.000026689281996e+00, 1.000034279373492e+00, + 1.000041842912049e+00, 1.000049374040126e+00, 1.000056866933785e+00, 1.000064315808680e+00, 1.000071714925990e+00, + 1.000079058598250e+00, 1.000086341195099e+00, 1.000093557148926e+00, 1.000100700960395e+00, 1.000107767203853e+00, + 1.000114750532603e+00, 1.000121645684037e+00, 1.000128447484626e+00, 1.000135150854742e+00, 1.000141750813332e+00, + 1.000148242482408e+00, 1.000154621091371e+00, 1.000160881981147e+00, 1.000167020608141e+00, 1.000173032547996e+00, + 1.000178913499161e+00, 1.000184659286256e+00, 1.000190265863238e+00, 1.000195729316362e+00, 1.000201045866939e+00, + 1.000206211873884e+00, 1.000211223836059e+00, 1.000216078394407e+00, 1.000220772333881e+00, 1.000225302585160e+00, + 1.000229666226172e+00, 1.000233860483401e+00, 1.000237882733002e+00, 1.000241730501714e+00, 1.000245401467578e+00, + 1.000248893460465e+00, 1.000252204462412e+00, 1.000255332607784e+00, 1.000258276183243e+00, 1.000261033627556e+00, + 1.000263603531226e+00, 1.000265984635963e+00, 1.000268175833992e+00, 1.000270176167217e+00, 1.000271984826231e+00, + 1.000273601149186e+00, 1.000275024620537e+00, 1.000276254869646e+00, 1.000277291669272e+00, 1.000278134933949e+00, + 1.000278784718248e+00, 1.000279241214938e+00, 1.000279504753058e+00, 1.000279575795894e+00, 1.000279454938873e+00, + 1.000279142907386e+00, 1.000278640554535e+00, 1.000277948858822e+00, 1.000277068921773e+00, 1.000276001965517e+00, + 1.000274749330316e+00, 1.000273312472054e+00, 1.000271692959694e+00, 1.000269892472703e+00, 1.000267912798451e+00, + 1.000265755829598e+00, 1.000263423561457e+00, 1.000260918089352e+00, 1.000258241605975e+00, 1.000255396398729e+00, + 1.000252384847089e+00, 1.000249209419954e+00, 1.000245872673023e+00, 1.000242377246174e+00, 1.000238725860863e+00, + 1.000234921317548e+00, 1.000230966493118e+00, 1.000226864338370e+00, 1.000222617875491e+00, 1.000218230195586e+00, + 1.000213704456221e+00, 1.000209043879012e+00, 1.000204251747240e+00, 1.000199331403501e+00, 1.000194286247397e+00, + 1.000189119733258e+00, 1.000183835367906e+00, 1.000178436708454e+00, 1.000172927360150e+00, 1.000167310974248e+00, + 1.000161591245930e+00, 1.000155771912258e+00, 1.000149856750174e+00, 1.000143849574523e+00, 1.000137754236130e+00, + 1.000131574619904e+00, 1.000125314642979e+00, 1.000118978252895e+00, 1.000112569425805e+00, 1.000106092164726e+00, + 1.000099550497809e+00, 1.000092948476653e+00, 1.000086290174636e+00, 1.000079579685283e+00, 1.000072821120651e+00, + 1.000066018609750e+00, 1.000059176296973e+00, 1.000052298340563e+00, 1.000045388911081e+00, 1.000038452189909e+00, + 1.000031492367753e+00, 1.000024513643172e+00, 1.000017520221111e+00, 1.000010516311443e+00, 1.000003506127529e+00, + 9.999964938847642e-01, 9.999894837991481e-01, 9.999824800858419e-01, 9.999754869577321e-01, 9.999685086239848e-01, + 9.999615492886049e-01, 9.999546131489783e-01, 9.999477043944101e-01, 9.999408272046536e-01, 9.999339857484195e-01, + 9.999271841818784e-01, 9.999204266471391e-01, 9.999137172707154e-01, 9.999070601619628e-01, 9.999004594115060e-01, + 9.998939190896278e-01, 9.998874432446441e-01, 9.998810359012452e-01, 9.998747010588128e-01, 9.998684426896991e-01, + 9.998622647374855e-01, 9.998561711152009e-01, 9.998501657035072e-01, 9.998442523488513e-01, 9.998384348615825e-01, + 9.998327170140316e-01, 9.998271025385516e-01, 9.998215951255243e-01, 9.998161984213253e-01, 9.998109160262525e-01, + 9.998057514924167e-01, 9.998007083215891e-01, 9.997957899630165e-01, 9.997909998111978e-01, 9.997863412036158e-01, + 9.997818174184411e-01, 9.997774316721972e-01, 9.997731871173844e-01, 9.997690868400847e-01, 9.997651338575159e-01, + 9.997613311155714e-01, 9.997576814863203e-01, 9.997541877654884e-01, 9.997508526699078e-01, 9.997476788349500e-01, + 9.997446688119369e-01, 9.997418250655351e-01, 9.997391499711387e-01, 9.997366458122413e-01, 9.997343147777986e-01, + 9.997321589595916e-01, 9.997301803495896e-01, 9.997283808373202e-01, 9.997267622072430e-01, 9.997253261361446e-01, + 9.997240741905490e-01, 9.997230078241506e-01, 9.997221283752786e-01, 9.997214370643954e-01, 9.997209349916318e-01, + 9.997206231343719e-01, 9.997205023448855e-01, 9.997205733480192e-01, 9.997208367389500e-01, 9.997212929810099e-01, + 9.997219424035818e-01, 9.997227852000825e-01, 9.997238214260301e-01, 9.997250509972079e-01, 9.997264736879267e-01, + 9.997280891294001e-01, 9.997298968082279e-01, 9.997318960650045e-01, 9.997340860930513e-01, 9.997364659372833e-01, + 9.997390344932165e-01, 9.997417905061193e-01, 9.997447325703145e-01, 9.997478591286405e-01, 9.997511684720751e-01, + 9.997546587395272e-01, 9.997583279177997e-01, 9.997621738417346e-01, 9.997661941945379e-01, 9.997703865082921e-01, + 9.997747481646607e-01, 9.997792763957842e-01, 9.997839682853786e-01, 9.997888207700281e-01, 9.997938306406862e-01, + 9.997989945443773e-01, 9.998043089861064e-01, 9.998097703309746e-01, 9.998153748065003e-01, 9.998211185051531e-01, + 9.998269973870870e-01, 9.998330072830846e-01, 9.998391438977015e-01, 9.998454028126147e-01, 9.998517794901678e-01, + 9.998582692771129e-01, 9.998648674085433e-01, 9.998715690120116e-01, 9.998783691118356e-01, 9.998852626335712e-01, + 9.998922444086656e-01, 9.998993091792668e-01, 9.999064516031954e-01, 9.999136662590592e-01, 9.999209476515181e-01, + 9.999282902166716e-01, 9.999356883275767e-01, 9.999431362998797e-01, 9.999506283975492e-01, 9.999581588387069e-01, + 9.999657218015428e-01, 9.999733114303027e-01, 9.999809218413399e-01, 9.999885471292198e-01, 9.999961813728609e-01, + 1.000003818641712e+00, 1.000011453001941e+00, 1.000019078522634e+00, 1.000026689281987e+00, 1.000034279373484e+00, + 1.000041842912040e+00, 1.000049374040118e+00, 1.000056866933776e+00, 1.000064315808672e+00, 1.000071714925982e+00, + 1.000079058598242e+00, 1.000086341195091e+00, 1.000093557148918e+00, 1.000100700960387e+00, 1.000107767203845e+00, + 1.000114750532595e+00, 1.000121645684029e+00, 1.000128447484618e+00, 1.000135150854734e+00, 1.000141750813325e+00, + 1.000148242482401e+00, 1.000154621091364e+00, 1.000160881981140e+00, 1.000167020608134e+00, 1.000173032547989e+00, + 1.000178913499155e+00, 1.000184659286250e+00, 1.000190265863232e+00, 1.000195729316356e+00, 1.000201045866933e+00, + 1.000206211873878e+00, 1.000211223836054e+00, 1.000216078394402e+00, 1.000220772333876e+00, 1.000225302585155e+00, + 1.000229666226167e+00, 1.000233860483396e+00, 1.000237882732998e+00, 1.000241730501710e+00, 1.000245401467574e+00, + 1.000248893460461e+00, 1.000252204462409e+00, 1.000255332607781e+00, 1.000258276183240e+00, 1.000261033627553e+00, + 1.000263603531224e+00, 1.000265984635960e+00, 1.000268175833990e+00, 1.000270176167215e+00, 1.000271984826229e+00, + 1.000273601149185e+00, 1.000275024620536e+00, 1.000276254869644e+00, 1.000277291669271e+00, 1.000278134933948e+00, + 1.000278784718247e+00, 1.000279241214938e+00, 1.000279504753058e+00, 1.000279575795894e+00, 1.000279454938873e+00, + 1.000279142907386e+00, 1.000278640554536e+00, 1.000277948858822e+00, 1.000277068921773e+00, 1.000276001965517e+00, + 1.000274749330316e+00, 1.000273312472055e+00, 1.000271692959695e+00, 1.000269892472704e+00, 1.000267912798453e+00, + 1.000265755829599e+00, 1.000263423561458e+00, 1.000260918089354e+00, 1.000258241605976e+00, 1.000255396398731e+00, + 1.000252384847091e+00, 1.000249209419956e+00, 1.000245872673025e+00, 1.000242377246176e+00, 1.000238725860866e+00, + 1.000234921317550e+00, 1.000230966493120e+00, 1.000226864338372e+00, 1.000222617875493e+00, 1.000218230195589e+00, + 1.000213704456224e+00, 1.000209043879015e+00, 1.000204251747242e+00, 1.000199331403503e+00, 1.000194286247399e+00, + 1.000189119733260e+00, 1.000183835367908e+00, 1.000178436708457e+00, 1.000172927360152e+00, 1.000167310974250e+00, + 1.000161591245932e+00, 1.000155771912260e+00, 1.000149856750176e+00, 1.000143849574525e+00, 1.000137754236132e+00, + 1.000131574619906e+00, 1.000125314642981e+00, 1.000118978252897e+00, 1.000112569425807e+00, 1.000106092164727e+00, + 1.000099550497811e+00, 1.000092948476655e+00, 1.000086290174638e+00, 1.000079579685284e+00, 1.000072821120652e+00, + 1.000066018609751e+00, 1.000059176296974e+00, 1.000052298340564e+00, 1.000045388911082e+00, 1.000038452189910e+00, + 1.000031492367754e+00, 1.000024513643172e+00, 1.000017520221111e+00, 1.000010516311444e+00, 1.000003506127529e+00, + 9.999964938847641e-01, 9.999894837991480e-01, 9.999824800858417e-01, 9.999754869577318e-01, 9.999685086239841e-01, + 9.999615492886044e-01, 9.999546131489776e-01, 9.999477043944092e-01, 9.999408272046527e-01, 9.999339857484185e-01, + 9.999271841818773e-01, 9.999204266471379e-01, 9.999137172707140e-01, 9.999070601619615e-01, 9.999004594115044e-01, + 9.998939190896263e-01, 9.998874432446425e-01, 9.998810359012436e-01, 9.998747010588109e-01, 9.998684426896972e-01, + 9.998622647374836e-01, 9.998561711151988e-01, 9.998501657035050e-01, 9.998442523488493e-01, 9.998384348615804e-01, + 9.998327170140294e-01, 9.998271025385493e-01, 9.998215951255222e-01, 9.998161984213230e-01, 9.998109160262503e-01, + 9.998057514924145e-01, 9.998007083215869e-01, 9.997957899630143e-01, 9.997909998111957e-01, 9.997863412036135e-01, + 9.997818174184390e-01, 9.997774316721950e-01, 9.997731871173822e-01, 9.997690868400825e-01, 9.997651338575136e-01, + 9.997613311155693e-01, 9.997576814863183e-01, 9.997541877654863e-01, 9.997508526699059e-01, 9.997476788349481e-01, + 9.997446688119350e-01, 9.997418250655334e-01, 9.997391499711371e-01, 9.997366458122399e-01, 9.997343147777973e-01, + 9.997321589595902e-01, 9.997301803495884e-01, 9.997283808373191e-01, 9.997267622072419e-01, 9.997253261361438e-01, + 9.997240741905483e-01, 9.997230078241500e-01, 9.997221283752783e-01, 9.997214370643952e-01, 9.997209349916318e-01, + 9.997206231343722e-01, 9.997205023448859e-01, 9.997205733480196e-01, 9.997208367389504e-01, 9.997212929810105e-01, + 9.997219424035826e-01, 9.997227852000836e-01, 9.997238214260314e-01, 9.997250509972092e-01, 9.997264736879284e-01, + 9.997280891294021e-01, 9.997298968082300e-01, 9.997318960650067e-01, 9.997340860930538e-01, 9.997364659372859e-01, + 9.997390344932195e-01, 9.997417905061224e-01, 9.997447325703176e-01, 9.997478591286439e-01, 9.997511684720787e-01, + 9.997546587395311e-01, 9.997583279178037e-01, 9.997621738417388e-01, 9.997661941945423e-01, 9.997703865082966e-01, + 9.997747481646656e-01, 9.997792763957892e-01, 9.997839682853837e-01, 9.997888207700335e-01, 9.997938306406916e-01, + 9.997989945443829e-01, 9.998043089861125e-01, 9.998097703309806e-01, 9.998153748065066e-01, 9.998211185051595e-01, + 9.998269973870937e-01, 9.998330072830913e-01, 9.998391438977084e-01, 9.998454028126217e-01, 9.998517794901752e-01, + 9.998582692771203e-01, 9.998648674085506e-01, 9.998715690120191e-01, 9.998783691118432e-01, 9.998852626335790e-01, + 9.998922444086736e-01, 9.998993091792749e-01, 9.999064516032034e-01, 9.999136662590675e-01, 9.999209476515264e-01, + 9.999282902166798e-01, 9.999356883275852e-01, 9.999431362998885e-01, 9.999506283975580e-01, 9.999581588387155e-01, + 9.999657218015514e-01, 9.999733114303114e-01, 9.999809218413486e-01, 9.999885471292286e-01, 9.999961813728698e-01, + 1.000003818641721e+00, 1.000011453001950e+00, 1.000019078522643e+00, 1.000026689281996e+00, 1.000034279373492e+00, + 1.000041842912049e+00, 1.000049374040126e+00, 1.000056866933785e+00, 1.000064315808680e+00, 1.000071714925990e+00, + 1.000079058598250e+00, 1.000086341195099e+00, 1.000093557148926e+00, 1.000100700960395e+00, 1.000107767203853e+00, + 1.000114750532602e+00, 1.000121645684037e+00, 1.000128447484626e+00, 1.000135150854742e+00, 1.000141750813332e+00, + 1.000148242482408e+00, 1.000154621091371e+00, 1.000160881981147e+00, 1.000167020608141e+00, 1.000173032547996e+00, + 1.000178913499161e+00, 1.000184659286256e+00, 1.000190265863238e+00, 1.000195729316362e+00, 1.000201045866939e+00, + 1.000206211873884e+00, 1.000211223836059e+00, 1.000216078394407e+00, 1.000220772333881e+00, 1.000225302585160e+00, + 1.000229666226172e+00, 1.000233860483401e+00, 1.000237882733002e+00, 1.000241730501714e+00, 1.000245401467578e+00, + 1.000248893460465e+00, 1.000252204462412e+00, 1.000255332607784e+00, 1.000258276183243e+00, 1.000261033627556e+00, + 1.000263603531226e+00, 1.000265984635963e+00, 1.000268175833992e+00, 1.000270176167217e+00, 1.000271984826231e+00, + 1.000273601149187e+00, 1.000275024620537e+00, 1.000276254869646e+00, 1.000277291669272e+00, 1.000278134933949e+00, + 1.000278784718248e+00, 1.000279241214938e+00, 1.000279504753058e+00, 1.000279575795894e+00, 1.000279454938873e+00, + 1.000279142907386e+00, 1.000278640554535e+00, 1.000277948858822e+00, 1.000277068921773e+00, 1.000276001965517e+00, + 1.000274749330316e+00, 1.000273312472054e+00, 1.000271692959694e+00, 1.000269892472703e+00, 1.000267912798451e+00, + 1.000265755829598e+00, 1.000263423561457e+00, 1.000260918089352e+00, 1.000258241605975e+00, 1.000255396398729e+00, + 1.000252384847089e+00, 1.000249209419954e+00, 1.000245872673023e+00, 1.000242377246174e+00, 1.000238725860863e+00, + 1.000234921317548e+00, 1.000230966493118e+00, 1.000226864338370e+00, 1.000222617875491e+00, 1.000218230195586e+00, + 1.000213704456221e+00, 1.000209043879013e+00, 1.000204251747240e+00, 1.000199331403501e+00, 1.000194286247397e+00, + 1.000189119733258e+00, 1.000183835367906e+00, 1.000178436708454e+00, 1.000172927360150e+00, 1.000167310974248e+00, + 1.000161591245930e+00, 1.000155771912258e+00, 1.000149856750174e+00, 1.000143849574523e+00, 1.000137754236130e+00, + 1.000131574619904e+00, 1.000125314642979e+00, 1.000118978252895e+00, 1.000112569425805e+00, 1.000106092164726e+00, + 1.000099550497809e+00, 1.000092948476653e+00, 1.000086290174636e+00, 1.000079579685283e+00, 1.000072821120651e+00, + 1.000066018609750e+00, 1.000059176296973e+00, 1.000052298340563e+00, 1.000045388911081e+00, 1.000038452189909e+00, + 1.000031492367753e+00, 1.000024513643172e+00, 1.000017520221111e+00, 1.000010516311443e+00, 1.000003506127529e+00, + 9.999964938847643e-01, 9.999894837991482e-01, 9.999824800858421e-01, 9.999754869577322e-01, 9.999685086239848e-01, + 9.999615492886050e-01, 9.999546131489783e-01, 9.999477043944101e-01, 9.999408272046536e-01, 9.999339857484195e-01, + 9.999271841818784e-01, 9.999204266471392e-01, 9.999137172707154e-01, 9.999070601619630e-01, 9.999004594115060e-01, + 9.998939190896279e-01, 9.998874432446442e-01, 9.998810359012452e-01, 9.998747010588128e-01, 9.998684426896991e-01, + 9.998622647374856e-01, 9.998561711152009e-01, 9.998501657035073e-01, 9.998442523488514e-01, 9.998384348615826e-01, + 9.998327170140316e-01, 9.998271025385517e-01, 9.998215951255245e-01, 9.998161984213253e-01, 9.998109160262525e-01, + 9.998057514924167e-01, 9.998007083215890e-01, 9.997957899630168e-01, 9.997909998111979e-01, 9.997863412036158e-01, + 9.997818174184412e-01, 9.997774316721972e-01, 9.997731871173845e-01, 9.997690868400848e-01, 9.997651338575160e-01, + 9.997613311155714e-01, 9.997576814863203e-01, 9.997541877654884e-01, 9.997508526699078e-01, 9.997476788349500e-01, + 9.997446688119369e-01, 9.997418250655351e-01, 9.997391499711387e-01, 9.997366458122413e-01, 9.997343147777986e-01, + 9.997321589595916e-01, 9.997301803495896e-01, 9.997283808373202e-01, 9.997267622072429e-01, 9.997253261361446e-01, + 9.997240741905490e-01, 9.997230078241506e-01, 9.997221283752786e-01, 9.997214370643954e-01, 9.997209349916318e-01, + 9.997206231343720e-01, 9.997205023448855e-01, 9.997205733480192e-01, 9.997208367389500e-01, 9.997212929810099e-01, + 9.997219424035817e-01, 9.997227852000825e-01, 9.997238214260302e-01, 9.997250509972079e-01, 9.997264736879269e-01, + 9.997280891294001e-01, 9.997298968082279e-01, 9.997318960650045e-01, 9.997340860930511e-01, 9.997364659372833e-01, + 9.997390344932165e-01, 9.997417905061193e-01, 9.997447325703143e-01, 9.997478591286405e-01, 9.997511684720751e-01, + 9.997546587395272e-01, 9.997583279177997e-01, 9.997621738417345e-01, 9.997661941945379e-01, 9.997703865082921e-01, + 9.997747481646605e-01, 9.997792763957843e-01, 9.997839682853786e-01, 9.997888207700281e-01, 9.997938306406862e-01, + 9.997989945443773e-01, 9.998043089861064e-01, 9.998097703309746e-01, 9.998153748065003e-01, 9.998211185051530e-01, + 9.998269973870870e-01, 9.998330072830846e-01, 9.998391438977015e-01, 9.998454028126147e-01, 9.998517794901678e-01, + 9.998582692771129e-01, 9.998648674085431e-01, 9.998715690120116e-01, 9.998783691118356e-01, 9.998852626335712e-01, + 9.998922444086656e-01, 9.998993091792668e-01, 9.999064516031954e-01, 9.999136662590593e-01, 9.999209476515181e-01, + 9.999282902166716e-01, 9.999356883275767e-01, 9.999431362998797e-01, 9.999506283975492e-01, 9.999581588387069e-01, + 9.999657218015426e-01, 9.999733114303028e-01, 9.999809218413399e-01, 9.999885471292198e-01, 9.999961813728609e-01, + 1.000003792553732e+00, 1.000011363835885e+00, 1.000018880862106e+00, 1.000026318501453e+00, 1.000033646597102e+00, + 1.000040828844329e+00, 1.000047821703262e+00, 1.000054573213544e+00, 1.000061021697840e+00, 1.000067094351168e+00, + 1.000072705715621e+00, 1.000077756041457e+00, 1.000082129536869e+00, 1.000085692509860e+00, 1.000088291406840e+00, + 1.000089750753633e+00, 1.000089871005573e+00, 1.000088426314299e+00, 1.000085162219593e+00, 1.000079793275302e+00, + 1.000072000618805e+00, 1.000061429493851e+00, 1.000047686736686e+00, 1.000030338235356e+00, 1.000008906371822e+00, + 9.999828674561138e-01, 9.999516491611377e-01, 9.999146279660260e-01, 9.998711266149775e-01, 9.998204115975446e-01, + 9.997616906551822e-01, 9.996941103176716e-01, 9.996167534717882e-01, 9.995286369633262e-01, 9.994287092323502e-01, + 9.993158479803570e-01, 9.991888578669340e-01, 9.990464682325365e-01, 9.988873308431691e-01, 9.987100176521666e-01, + 9.985130185738464e-01, 9.982947392636853e-01, 9.980534988998219e-01, 9.977875279611558e-01, 9.974949659981255e-01, + 9.971738593934303e-01, 9.968221591115168e-01, 9.964377184376065e-01, 9.960182907094022e-01, 9.955615270473709e-01, + 9.950649740926601e-01, 9.945260717652322e-01, 9.939421510586981e-01, 9.933104318925129e-01, 9.926280210466711e-01, + 9.918919102086680e-01, 9.910989741672799e-01, 9.902459691925082e-01, 9.893295316457497e-01, 9.883461768687914e-01, + 9.872922984044433e-01, 9.861641676054160e-01, 9.849579336912377e-01, 9.836696243155244e-01, 9.822951467075759e-01, + 9.808302894530008e-01, 9.792707249777252e-01, 9.776120127982821e-01, 9.758496035985741e-01, 9.739788441893990e-01, + 9.719949834018297e-01, 9.698931789591444e-01, 9.676685053644012e-01, 9.653159628320954e-01, 9.628304872826687e-01, + 9.602069614081798e-01, 9.574402268063275e-01, 9.545250971684157e-01, 9.514563724950412e-01, 9.482288543014010e-01, + 9.448373617624480e-01, 9.412767487368542e-01, 9.375419215980740e-01, 9.336278577909594e-01, 9.295296250234834e-01, + 9.252424009953755e-01, 9.207614935589523e-01, 9.160823612022024e-01, 9.112006337403594e-01, 9.061121330997502e-01, + 9.008128940766279e-01, 8.952991849539681e-01, 8.895675278607562e-01, 8.836147187609806e-01, 8.774378469633509e-01, + 8.710343140474714e-01, 8.644018521077256e-01, 8.575385412223282e-01, 8.504428260617042e-01, 8.431135315574496e-01, + 8.355498775604459e-01, 8.277514924241404e-01, 8.197184254564199e-01, 8.114511581907922e-01, 8.029506144346715e-01, + 7.942181690593274e-01, 7.852556555024425e-01, 7.760653719601955e-01, 7.666500862512726e-01, 7.570130393401874e-01, + 7.471579475117688e-01, 7.370890031926083e-01, 7.268108744186758e-01, 7.163287029512231e-01, 7.056481010455187e-01, + 6.947751468789124e-01, 6.837163786462801e-01, 6.724787873320510e-01, 6.610698081688499e-01, 6.494973107933384e-01, + 6.377695881101478e-01, 6.258953438749761e-01, 6.138836790079482e-01, 6.017440766483936e-01, 5.894863859622419e-01, + 5.771208047134243e-01, 5.646578606110257e-01, 5.521083914445795e-01, 5.394835240208723e-01, 5.267946519170417e-01, + 5.140534120666679e-01, 5.012716601980810e-01, 4.884614451472596e-01, 4.756349820716255e-01, 4.628046245957236e-01, + 4.499828359253513e-01, 4.371821589731387e-01, 4.244151855459629e-01, 4.116945246528834e-01, 3.990327700015137e-01, + 3.864424667608565e-01, 3.739360776795802e-01, 3.615259486603844e-01, 3.492242739034092e-01, 3.370430607443994e-01, + 3.249940943263768e-01, 3.130889022566745e-01, 3.013387194140940e-01, 2.897544530833894e-01, 2.783466486059465e-01, + 2.671254557460968e-01, 2.561005959816459e-01, 2.452813309345670e-01, 2.346764321630724e-01, 2.242941525391207e-01, + 2.141421994355449e-01, 2.042277099441413e-01, 1.945572283400477e-01, 1.851366859983997e-01, 1.759713839565222e-01, + 1.670659782987828e-01, 1.584244685217862e-01, 1.500501890149949e-01, 1.419458037663698e-01, 1.341133043745716e-01, + 1.265540114190599e-01, 1.192685792075560e-01, 1.122570038873269e-01, 1.055186348731866e-01, 9.905218951159138e-02, + 9.285577086735504e-02, 8.692688848791834e-02, 8.126248197036480e-02, 7.585894712900819e-02, 7.071216453687493e-02, + 6.581753019316379e-02, 6.116998805112477e-02, 5.676406412698673e-02, 5.259390190074066e-02, 4.865329871379729e-02, + 4.493574286675733e-02, 4.143445112264064e-02, 3.814240632671975e-02, 3.505239486333388e-02, 3.215704368240290e-02, + 2.944885664345253e-02, 2.692024994241165e-02, 2.456358640583462e-02, 2.237120845811709e-02, 2.033546958929542e-02, + 1.844876417374586e-02, 1.670355551314538e-02, 1.509240200007160e-02, 1.360798132128038e-02, 1.224311264172586e-02, + 1.099077673153155e-02, 9.844134018179273e-03, 8.796540564986736e-03, 7.841561994366898e-03, 6.972985390308479e-03, + 6.184829228925801e-03, 5.471351398766137e-03, 4.827055383826915e-03, 4.246694691940794e-03, 3.725275619368065e-03, + 3.258058449144477e-03, 2.840557186031939e-03, 2.468537934882437e-03, 2.138016031933214e-03, 1.845252040089026e-03, + 1.586746719704406e-03, 1.359235085846040e-03, 1.159679661583578e-03, 9.852630346169412e-04, 8.333798215882749e-04, + 7.016281408336979e-04, 5.878006901877478e-04, 4.898755218427234e-04, 4.060066012630820e-04, 3.345142318353532e-04, + 2.738754213664553e-04, 2.227142607936653e-04, 1.797923795997266e-04, 1.439995364945199e-04, 1.143443979841680e-04, + 8.994555154915584e-05, 7.002279434068894e-05, 5.388873262066439e-05, 4.094072165278127e-05, 3.065317043363458e-05, + 2.257023056170620e-05, 1.629888370183569e-05, 1.150243752713366e-05, 7.894435705240934e-06, 5.232983386684600e-06, + 3.315485520548709e-06, 1.973790197100917e-06, 1.069718110365652e-06, 4.909053882102472e-07, 1.462097501755241e-07, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00}; + + + +const LC3_FLOAT* MDCT_WINS_10ms[2][6] = { + {MDCT_WINDOW_80, MDCT_WINDOW_160, MDCT_WINDOW_240, MDCT_WINDOW_320, MDCT_WINDOW_480, NULL}, + {NULL, NULL, NULL, NULL, MDCT_HRA_WINDOW_480_10ms, MDCT_HRA_WINDOW_960_10ms}}; +const LC3_INT MDCT_la_zeroes[6] = {30, 60, 90, 120, 180, 360}; + +#ifdef CR8_G_ADD_75MS +const LC3_FLOAT* MDCT_WINS_7_5ms[2][6] = { + {MDCT_WINDOW_80_7_5ms, MDCT_WINDOW_160_7_5ms, MDCT_WINDOW_240_7_5ms, MDCT_WINDOW_320_7_5ms, MDCT_WINDOW_480_7_5ms, NULL}, + {NULL , NULL , NULL , NULL , MDCT_HRA_WINDOW_480_7_5ms, MDCT_HRA_WINDOW_960_7_5ms}}; +const LC3_INT32 MDCT_la_zeroes_7_5ms[6] = {14, 28, 42, 56, 84, 168}; +#endif + +const LC3_FLOAT* MDCT_WINS_2_5ms[2][6] = { + {MDCT_WINDOW_80_2_5ms, MDCT_WINDOW_160_2_5ms, MDCT_WINDOW_240_2_5ms, MDCT_WINDOW_320_2_5ms, MDCT_WINDOW_480_2_5ms, + NULL}, + {NULL, NULL, NULL, NULL, MDCT_HRA_WINDOW_480_2_5ms, MDCT_HRA_WINDOW_960_2_5ms}}; +const LC3_INT MDCT_la_zeroes_2_5ms[6] = {0, 0, 0, 0, 0, 0}; + +const LC3_FLOAT* MDCT_WINS_5ms[2][6] = { + {MDCT_WINDOW_80_5ms, MDCT_WINDOW_160_5ms, MDCT_WINDOW_240_5ms, MDCT_WINDOW_320_5ms, MDCT_WINDOW_480_5ms, NULL}, + {NULL, NULL, NULL, NULL, MDCT_HRA_WINDOW_480_5ms, MDCT_HRA_WINDOW_960_5ms}}; +const LC3_INT MDCT_la_zeroes_5ms[6] = {10, 20, 30, 40, 60, 120}; + +const LC3_INT MDCT_WINDOWS_LENGTHS_10ms[6] = {160, 320, 480, 640, 960, 1920}; /* Last 960 dummy */ + +const LC3_INT MDCT_WINDOWS_LENGTHS_7_5ms[6] = {120, 240, 360, 480, 720, 1440}; /* Last 960 dummy */ + +const LC3_INT MDCT_WINDOWS_LENGTHS_5ms[6] = {80, 160, 240, 320, 480, 960}; + +const LC3_INT MDCT_WINDOWS_LENGTHS_2_5ms[6] = {40, 80, 120, 160, 240, 480}; + +/* Per band energy */ +const LC3_INT ACC_COEFF_PER_BAND_8[65] = {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, 51, + 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 80}; + +const LC3_INT ACC_COEFF_PER_BAND_16[65] = {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, 30, 32, 34, 36, 38, + 40, 42, 44, 46, 48, 50, 52, 55, 58, 61, 64, 67, 70, 73, 76, 80, 84, + 88, 92, 96, 101, 106, 111, 116, 121, 127, 133, 139, 146, 153, 160}; + +const LC3_INT ACC_COEFF_PER_BAND_24[65] = { + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, + 22, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 46, 49, 52, 55, 58, 61, 64, 68, 72, 76, + 80, 85, 90, 95, 100, 106, 112, 118, 125, 132, 139, 147, 155, 164, 173, 183, 193, 204, 215, 227, 240}; + +const LC3_INT ACC_COEFF_PER_BAND_32[65] = { + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 22, + 24, 26, 28, 30, 32, 34, 36, 38, 41, 44, 47, 50, 53, 56, 60, 64, 68, 72, 76, 81, 86, 91, + 97, 103, 109, 116, 123, 131, 139, 148, 157, 166, 176, 187, 199, 211, 224, 238, 252, 268, 284, 302, 320}; + +const LC3_INT ACC_COEFF_PER_BAND_48[65] = { + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 20, 22, 24, + 26, 28, 30, 32, 34, 36, 39, 42, 45, 48, 51, 55, 59, 63, 67, 71, 76, 81, 86, 92, 98, 105, + 112, 119, 127, 135, 144, 154, 164, 175, 186, 198, 211, 225, 240, 256, 273, 291, 310, 330, 352, 375, 400}; + +const LC3_INT ACC_COEFF_PER_BAND_8_2_5ms[21] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + 11, 12, 13, 14, 15, 16, 17, 18, 19, 20}; + +const LC3_INT ACC_COEFF_PER_BAND_16_2_5ms[36] = {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, 32, 34, 36, 38, 40}; + +const LC3_INT ACC_COEFF_PER_BAND_24_2_5ms[41] = {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, 28, + 30, 32, 34, 36, 38, 40, 42, 44, 47, 50, 53, 56, 60}; + +const LC3_INT ACC_COEFF_PER_BAND_32_2_5ms[44] = {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, 26, 28, 30, 32, 34, + 36, 38, 40, 43, 46, 49, 52, 55, 59, 63, 67, 71, 75, 80}; + +const LC3_INT ACC_COEFF_PER_BAND_48_2_5ms[45] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 23, 25, 27, 29, 31, 33, 35, 37, + 40, 43, 46, 49, 52, 56, 60, 64, 68, 72, 77, 82, 87, 93, 100}; + +const LC3_INT ACC_COEFF_PER_BAND_48_2_5ms_HR[46] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 40, 43, 46, + 49, 53, 57, 61, 65, 69, 74, 79, 85, 91, 97, 104, 112, 120}; +const LC3_INT ACC_COEFF_PER_BAND_96_2_5ms_HR[50] = { + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 18, 20, 22, 24, 26, 28, 30, 32, + 35, 38, 41, 45, 49, 53, 57, 62, 67, 73, 79, 85, 92, 100, 108, 117, 127, 137, 149, 161, 174, 189, 204, 221, 240}; + + +const LC3_INT ACC_COEFF_PER_BAND_8_5ms[40] = {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, 40}; + +const LC3_INT ACC_COEFF_PER_BAND_16_5ms[51] = {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, 32, 34, 36, + 38, 40, 42, 44, 46, 48, 50, 52, 54, 57, 60, 63, 66, 69, 72, 76, 80}; + +const LC3_INT ACC_COEFF_PER_BAND_24_5ms[53] = { + 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, 26, 28, + 30, 32, 34, 36, 38, 40, 42, 44, 47, 50, 53, 56, 59, 62, 65, 69, 73, 77, 81, 86, 91, 96, 101, 107, 113, 120}; + +const LC3_INT ACC_COEFF_PER_BAND_32_5ms[55] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, + 14, 15, 16, 17, 18, 19, 20, 21, 22, 24, 26, 28, 30, 32, + 34, 36, 38, 40, 42, 45, 48, 51, 54, 57, 61, 65, 69, 73, + 78, 83, 88, 93, 99, 105, 112, 119, 126, 134, 142, 151, 160}; +const LC3_INT ACC_COEFF_PER_BAND_48_5ms_HR[56] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, + 14, 15, 16, 17, 18, 19, 21, 23, 25, 27, 29, 31, 33, 35, + 38, 41, 44, 47, 50, 54, 58, 62, 66, 71, 76, 81, 87, 93, + 100, 107, 114, 122, 131, 140, 149, 160, 171, 183, 196, 209, 224, 240}; +const LC3_INT ACC_COEFF_PER_BAND_48_5ms[56] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, + 14, 15, 16, 17, 18, 19, 20, 21, 23, 25, 27, 29, 31, 33, + 35, 37, 40, 43, 46, 49, 52, 55, 59, 63, 67, 72, 77, 82, + 87, 93, 99, 105, 112, 120, 128, 136, 145, 155, 165, 176, 187, 200}; +const LC3_INT ACC_COEFF_PER_BAND_96_5ms_HR[59] = { + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 19, 21, + 23, 25, 27, 29, 31, 34, 37, 40, 44, 48, 52, 56, 61, 66, 71, 77, 83, 90, 98, 106, + 115, 124, 135, 146, 158, 171, 185, 200, 217, 235, 254, 275, 298, 323, 349, 378, 409, 443, 480}; + + +const LC3_INT ACC_COEFF_PER_BAND_48_HR[65] = { + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 19, 21, 23, 25, + 27, 29, 31, 33, 36, 39, 42, 45, 48, 51, 55, 59, 63, 67, 72, 77, 83, 89, 95, 101, 108, 116, + 124, 133, 142, 152, 163, 174, 187, 200, 214, 229, 244, 262, 280, 299, 320, 343, 367, 392, 419, 449, 480}; + +const LC3_INT ACC_COEFF_PER_BAND_96_HR[65] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 33, 36, 39, 42, 46, 50, 54, 59, 64, 69, 75, 82, 89, 96, 104, 113, 122, 132, 143, 155, 168, 181, 196, 213, 230, 249, 270, 292, 316, 342, 371, 401, 434, 470, 509, 551, 596, 646, 699, 757, 819, 887, 960}; + +const LC3_INT* ACC_COEFF_PER_BAND_HR[6] = {NULL, NULL, NULL, NULL, ACC_COEFF_PER_BAND_48_HR, ACC_COEFF_PER_BAND_96_HR}; + +const LC3_INT* ACC_COEFF_PER_BAND[6] = {ACC_COEFF_PER_BAND_8, ACC_COEFF_PER_BAND_16, ACC_COEFF_PER_BAND_24, + ACC_COEFF_PER_BAND_32, ACC_COEFF_PER_BAND_48, NULL}; + +const LC3_INT* ACC_COEFF_PER_BAND_2_5ms_HR[6] = { + NULL, NULL, NULL, NULL, ACC_COEFF_PER_BAND_48_2_5ms_HR, ACC_COEFF_PER_BAND_96_2_5ms_HR}; + +const LC3_INT* ACC_COEFF_PER_BAND_2_5ms[5] = {ACC_COEFF_PER_BAND_8_2_5ms, ACC_COEFF_PER_BAND_16_2_5ms, + ACC_COEFF_PER_BAND_24_2_5ms, ACC_COEFF_PER_BAND_32_2_5ms, + ACC_COEFF_PER_BAND_48_2_5ms}; + + +const LC3_INT* ACC_COEFF_PER_BAND_5ms_HR[6] = { + NULL, NULL, NULL, NULL, ACC_COEFF_PER_BAND_48_5ms_HR, ACC_COEFF_PER_BAND_96_5ms_HR}; + +const LC3_INT* ACC_COEFF_PER_BAND_5ms[5] = {ACC_COEFF_PER_BAND_8_5ms, ACC_COEFF_PER_BAND_16_5ms, + ACC_COEFF_PER_BAND_24_5ms, ACC_COEFF_PER_BAND_32_5ms, + ACC_COEFF_PER_BAND_48_5ms}; + +#ifdef CR8_G_ADD_75MS +const LC3_INT ACC_COEFF_PER_BAND_8_7_5ms[61] = {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}; + +const LC3_INT ACC_COEFF_PER_BAND_16_7_5ms[65] = {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, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 65, 68, + 71, 74, 77, 80, 83, 86, 90, 94, 98, 102, 106, 110, 115, 120}; + +const LC3_INT ACC_COEFF_PER_BAND_24_7_5ms[65] = { + 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, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 52, 55, 58, 61, 64, + 67, 70, 74, 78, 82, 86, 90, 95, 100, 105, 110, 115, 121, 127, 134, 141, 148, 155, 163, 171, 180}; + +const LC3_INT ACC_COEFF_PER_BAND_32_7_5ms[65] = { + 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, 26, 28, 30, 32, 34, 36, 38, 40, 42, 45, 48, 51, 54, 57, 60, 63, 67, 71, 75, + 79, 84, 89, 94, 99, 105, 111, 117, 124, 131, 138, 146, 154, 163, 172, 182, 192, 203, 215, 227, 240}; + +const LC3_INT ACC_COEFF_PER_BAND_48_7_5ms[65] = { + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, + 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 43, 46, 49, 52, 55, 59, 63, 67, 71, 75, 80, 85, + 90, 96, 102, 108, 115, 122, 129, 137, 146, 155, 165, 175, 186, 197, 209, 222, 236, 251, 266, 283, 300}; + +const LC3_INT ACC_COEFF_PER_BAND_48_7_5ms_HR[65] = { + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 22, + 24, 26, 28, 30, 32, 34, 36, 38, 41, 44, 47, 50, 53, 56, 60, 64, 68, 73, 78, 83, 89, 95, + 101, 108, 115, 122, 130, 139, 148, 158, 168, 179, 191, 203, 217, 231, 246, 262, 279, 298, 317, 338, 360}; + +const LC3_INT ACC_COEFF_PER_BAND_96_7_5ms_HR[65] = { + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 18, 20, 22, + 24, 26, 28, 30, 32, 35, 38, 41, 44, 48, 52, 56, 61, 66, 71, 77, 83, 90, 97, 105, + 114, 123, 132, 143, 155, 167, 180, 195, 210, 227, 245, 265, 286, 309, 334, 360, 389, 420, 454, 490, + 529, 572, 617, 667, 720}; + +const LC3_INT* ACC_COEFF_PER_BAND_7_5ms_HR[6] = {NULL, NULL, + NULL, NULL, + ACC_COEFF_PER_BAND_48_7_5ms_HR, ACC_COEFF_PER_BAND_96_7_5ms_HR}; + +const LC3_INT* ACC_COEFF_PER_BAND_7_5ms[5] = {ACC_COEFF_PER_BAND_8_7_5ms , ACC_COEFF_PER_BAND_16_7_5ms, + ACC_COEFF_PER_BAND_24_7_5ms, ACC_COEFF_PER_BAND_32_7_5ms, + ACC_COEFF_PER_BAND_48_7_5ms}; + +const LC3_INT ACC_COEFF_PER_BAND_PLC_8_7_5ms[61] = {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}; + +const LC3_INT ACC_COEFF_PER_BAND_PLC_16_7_5ms[61] = { + 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, + 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, + 84, 86, 88, 90, 92, 94, 96, 98, 100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120}; + +const LC3_INT ACC_COEFF_PER_BAND_PLC_24_7_5ms[61] = { + 0, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, + 63, 66, 69, 72, 75, 78, 81, 84, 87, 90, 93, 96, 99, 102, 105, 108, 111, 114, 117, 120, 123, + 126, 129, 132, 135, 138, 141, 144, 147, 150, 153, 156, 159, 162, 165, 168, 171, 174, 177, 180}; + +const LC3_INT ACC_COEFF_PER_BAND_PLC_32_7_5ms[81] = { + 0, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, + 63, 66, 69, 72, 75, 78, 81, 84, 87, 90, 93, 96, 99, 102, 105, 108, 111, 114, 117, 120, 123, + 126, 129, 132, 135, 138, 141, 144, 147, 150, 153, 156, 159, 162, 165, 168, 171, 174, 177, 180, 183, 186, + 189, 192, 195, 198, 201, 204, 207, 210, 213, 216, 219, 222, 225, 228, 231, 234, 237, 240}; + +const LC3_INT ACC_COEFF_PER_BAND_PLC_48_7_5ms[61] = { + 0, 6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90, 96, 102, 108, 114, 120, + 126, 132, 138, 144, 150, 156, 162, 168, 174, 180, 186, 192, 198, 204, 210, 216, 222, 228, 234, 240, 246, + 252, 258, 264, 270, 276, 282, 288, 294, 300, 306, 312, 318, 324, 330, 336, 342, 348, 354, 360}; + +const LC3_INT ACC_COEFF_PER_BAND_PLC_96_7_5ms[81] = { + 0, 9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99, 108, 117, 126, 135, 144, 153, 162, 171, 180, + 189, 198, 207, 216, 225, 234, 243, 252, 261, 270, 279, 288, 297, 306, 315, 324, 333, 342, 351, 360, 369, + 378, 387, 396, 405, 414, 423, 432, 441, 450, 459, 468, 477, 486, 495, 504, 513, 522, 531, 540, 549, 558, + 567, 576, 585, 594, 603, 612, 621, 630, 639, 648, 657, 666, 675, 684, 693, 702, 711, 720}; + +const LC3_INT* ACC_COEFF_PER_BAND_PLC_7_5ms[] = { + ACC_COEFF_PER_BAND_PLC_8_7_5ms, ACC_COEFF_PER_BAND_PLC_16_7_5ms, ACC_COEFF_PER_BAND_PLC_24_7_5ms, + ACC_COEFF_PER_BAND_PLC_32_7_5ms, ACC_COEFF_PER_BAND_PLC_48_7_5ms, ACC_COEFF_PER_BAND_PLC_96_7_5ms}; +#endif + +/* Near Nyquist detector */ +const LC3_INT NN_thresh = 30; +/* Tone detector */ +#ifdef CR8_E_TONE_DETECTOR +const LC3_INT32 TD_HR_thresh_10ms = 83402; +const LC3_INT32 TD_HR_thresh_7_5ms = 743496; +const LC3_INT32 TD_HR_thresh_5ms = 382564; +const LC3_INT32 TD_HR_thresh_2_5ms = 301695; +#endif // CR8_E_TONE_DETECTOR + + +const LC3_INT32 xavg_N_grp[5] = { 4, 5, 6, 7, 8 }; + + +const LC3_INT32 gwlpr[MAX_LGW+1] = { 1, 3*QUOT_LPR_LTR, 5*QUOT_LPR_LTR, 9*QUOT_LPR_LTR, 17*QUOT_LPR_LTR, 33*QUOT_LPR_LTR, 49*QUOT_LPR_LTR, 65*QUOT_LPR_LTR, 81*QUOT_LPR_LTR, 97*QUOT_LPR_LTR}; + + +#ifdef CR8_A_PLC_FADEOUT_TUNING +/* PLC_FADEOUT_TUNING, extended table ranging from 30 ms to 140 ms */ +const LC3_INT16 fade_scheme_tab[24 / 2][3] = { + /* tabled {att_per_frame_idx_p3dB , burst_att_thresh, beta_mute_thr } */ + { 1, 2, 0 + 2 + 2 }, /* 30 ms, 0.3 dB delta att in slow mutephase nominal_fadeout=0 */ + { 1, 3, 0 + 3 + 2 }, /* 40 ms, 0.3 dB delta att in slow mutephase */ + { 3, 3, 1 + 3 + 1 }, /* 50 ms, 0.3 dB delta att in slow mutephase */ + { 3, 4, 1 + 4 + 1}, /* 60 ms, 0.3 dB delta att in slow mutephase */ + { 5, 4, 3 + 4 + 1 }, /* 70 ms, 0.3 dB delta att in slow mutephase */ + { 5, 5, 3 + 5 + 1 }, /* 80 ms, 0.3 dB delta att in slow mutephase */ + { 7, 5, 7 + 5 }, /* 90 ms, 0.3 dB delta att in slow mutephase */ + { 7, 5, 7 + 5 + 1}, /* 100 ms, 0.3 dB delta att in slow mutephase */ + { 9, 5, 9 + 5 }, /* 110 ms, 0.3 dB delta att in slow mutephase */ + { 9, 5, 9 + 5 + 1}, /* 120 ms, 0.3 dB delta att in slow mutephase nominal_fadeout=1 */ + { 11, 5, 15 + 5 },/* 130 ms, 0.3 dB delta att in slow mutephase */ + { 11, 6, 15 + 6 },/* 140 ms, 0.3 dB delta att in slow mutephase nominal 3GPP */ + +}; + + + +/*compressed ATH Abolute hearing THreshold function weights at band borders */ +const LC3_FLOAT scATHFx[MAX_LGW - 2] = { .455444335937500 , 0.930755615234375 , 0.973083496093750 , 0.999969482421875 , 0.908508300781250 , 0.775665283203125 , 0.5 }; +#endif + +const LC3_FLOAT PhECU_whr16ms_NB[128]={ +8.000000000000002e-02, 8.393536376804722e-02, 9.567411990702857e-02, 1.150154150448081e-01, 1.416283142591582e-01, +1.750574634660318e-01, 2.147308806541882e-01, 2.599697426559885e-01, 3.099999999999999e-01, 3.639656211120587e-01, +4.209432392528405e-01, 4.799579515787762e-01, 5.400000000000000e-01, 6.000420484212237e-01, 6.590567607471596e-01, +7.160343788879413e-01, 7.699999999999999e-01, 8.200302573440115e-01, 8.652691193458119e-01, 9.049425365339682e-01, +9.383716857408418e-01, 9.649845849551919e-01, 9.843258800929715e-01, 9.960646362319528e-01, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +9.960646362319528e-01, 9.843258800929715e-01, 9.649845849551919e-01, 9.383716857408418e-01, 9.049425365339682e-01, +8.652691193458119e-01, 8.200302573440115e-01, 7.699999999999999e-01, 7.160343788879413e-01, 6.590567607471596e-01, +6.000420484212237e-01, 5.400000000000000e-01, 4.799579515787762e-01, 4.209432392528405e-01, 3.639656211120587e-01, +3.099999999999999e-01, 2.599697426559885e-01, 2.147308806541882e-01, 1.750574634660318e-01, 1.416283142591582e-01, +1.150154150448081e-01, 9.567411990702857e-02, 8.393536376804722e-02 +}; +const LC3_FLOAT PhECU_whr16ms_WB[256]={ +8.000000000000002e-02, 8.098489531024239e-02, 8.393536376804722e-02, 8.883877101451404e-02, 9.567411990702857e-02, +1.044121404322514e-01, 1.150154150448081e-01, 1.274385388949634e-01, 1.416283142591582e-01, 1.575239783408292e-01, +1.750574634660318e-01, 1.941536885596704e-01, 2.147308806541882e-01, 2.367009250539683e-01, 2.599697426559885e-01, +2.844376928109830e-01, 3.099999999999999e-01, 3.365472024992595e-01, 3.639656211120587e-01, 3.921378459605457e-01, +4.209432392528405e-01, 4.502584518725810e-01, 4.799579515787762e-01, 5.099145605541342e-01, 5.400000000000000e-01, +5.700854394458659e-01, 6.000420484212237e-01, 6.297415481274190e-01, 6.590567607471596e-01, 6.878621540394543e-01, +7.160343788879413e-01, 7.434527975007406e-01, 7.699999999999999e-01, 7.955623071890170e-01, 8.200302573440115e-01, +8.432990749460317e-01, 8.652691193458119e-01, 8.858463114403297e-01, 9.049425365339682e-01, 9.224760216591710e-01, +9.383716857408418e-01, 9.525614611050366e-01, 9.649845849551919e-01, 9.755878595677486e-01, 9.843258800929715e-01, +9.911612289854861e-01, 9.960646362319528e-01, 9.990151046897577e-01, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 9.990151046897577e-01, +9.960646362319528e-01, 9.911612289854861e-01, 9.843258800929715e-01, 9.755878595677486e-01, 9.649845849551919e-01, +9.525614611050366e-01, 9.383716857408418e-01, 9.224760216591710e-01, 9.049425365339682e-01, 8.858463114403297e-01, +8.652691193458119e-01, 8.432990749460317e-01, 8.200302573440115e-01, 7.955623071890170e-01, 7.699999999999999e-01, +7.434527975007406e-01, 7.160343788879413e-01, 6.878621540394543e-01, 6.590567607471596e-01, 6.297415481274190e-01, +6.000420484212237e-01, 5.700854394458659e-01, 5.400000000000000e-01, 5.099145605541342e-01, 4.799579515787762e-01, +4.502584518725810e-01, 4.209432392528405e-01, 3.921378459605457e-01, 3.639656211120587e-01, 3.365472024992595e-01, +3.099999999999999e-01, 2.844376928109830e-01, 2.599697426559885e-01, 2.367009250539683e-01, 2.147308806541882e-01, +1.941536885596704e-01, 1.750574634660318e-01, 1.575239783408292e-01, 1.416283142591582e-01, 1.274385388949634e-01, +1.150154150448081e-01, 1.044121404322514e-01, 9.567411990702857e-02, 8.883877101451404e-02, 8.393536376804722e-02, +8.098489531024239e-02 +}; +const LC3_FLOAT PhECU_whr16ms_SSWB[384]={ +8.000000000000002e-02, 8.043781807234540e-02, 8.175043887779704e-02, 8.393536376804722e-02, 8.698843361438435e-02, +9.090383672483066e-02, 9.567411990702857e-02, 1.012902026558156e-01, 1.077413944384821e-01, 1.150154150448081e-01, +1.230984179631410e-01, 1.319750167380180e-01, 1.416283142591582e-01, 1.520399349260726e-01, 1.631900596270638e-01, +1.750574634660318e-01, 1.876195561652702e-01, 2.008524250673430e-01, 2.147308806541882e-01, 2.292285044967963e-01, +2.443176995441919e-01, 2.599697426559885e-01, 2.761548392785189e-01, 2.928421801604610e-01, 3.099999999999999e-01, +3.275956379118843e-01, 3.455955995992783e-01, 3.639656211120587e-01, 3.826707340701924e-01, 4.016753322280344e-01, +4.209432392528405e-01, 4.404377775884727e-01, 4.601218382732121e-01, 4.799579515787762e-01, 4.999083583360772e-01, +5.199350818119455e-01, 5.400000000000000e-01, 5.600649181880546e-01, 5.800916416639228e-01, 6.000420484212237e-01, +6.198781617267880e-01, 6.395622224115274e-01, 6.590567607471596e-01, 6.783246677719657e-01, 6.973292659298076e-01, +7.160343788879413e-01, 7.344044004007217e-01, 7.524043620881156e-01, 7.699999999999999e-01, 7.871578198395390e-01, +8.038451607214812e-01, 8.200302573440115e-01, 8.356823004558082e-01, 8.507714955032037e-01, 8.652691193458119e-01, +8.791475749326572e-01, 8.923804438347298e-01, 9.049425365339682e-01, 9.168099403729364e-01, 9.279600650739274e-01, +9.383716857408418e-01, 9.480249832619820e-01, 9.569015820368590e-01, 9.649845849551919e-01, 9.722586055615179e-01, +9.787097973441844e-01, 9.843258800929715e-01, 9.890961632751694e-01, 9.930115663856157e-01, 9.960646362319528e-01, +9.982495611222031e-01, 9.995621819276547e-01, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 9.995621819276547e-01, 9.982495611222031e-01, +9.960646362319528e-01, 9.930115663856157e-01, 9.890961632751694e-01, 9.843258800929715e-01, 9.787097973441844e-01, +9.722586055615179e-01, 9.649845849551919e-01, 9.569015820368590e-01, 9.480249832619820e-01, 9.383716857408418e-01, +9.279600650739274e-01, 9.168099403729364e-01, 9.049425365339682e-01, 8.923804438347298e-01, 8.791475749326572e-01, +8.652691193458119e-01, 8.507714955032037e-01, 8.356823004558082e-01, 8.200302573440115e-01, 8.038451607214812e-01, +7.871578198395390e-01, 7.699999999999999e-01, 7.524043620881156e-01, 7.344044004007217e-01, 7.160343788879413e-01, +6.973292659298076e-01, 6.783246677719657e-01, 6.590567607471596e-01, 6.395622224115274e-01, 6.198781617267880e-01, +6.000420484212237e-01, 5.800916416639228e-01, 5.600649181880546e-01, 5.400000000000000e-01, 5.199350818119455e-01, +4.999083583360772e-01, 4.799579515787762e-01, 4.601218382732121e-01, 4.404377775884727e-01, 4.209432392528405e-01, +4.016753322280344e-01, 3.826707340701924e-01, 3.639656211120587e-01, 3.455955995992783e-01, 3.275956379118843e-01, +3.099999999999999e-01, 2.928421801604610e-01, 2.761548392785189e-01, 2.599697426559885e-01, 2.443176995441919e-01, +2.292285044967963e-01, 2.147308806541882e-01, 2.008524250673430e-01, 1.876195561652702e-01, 1.750574634660318e-01, +1.631900596270638e-01, 1.520399349260726e-01, 1.416283142591582e-01, 1.319750167380180e-01, 1.230984179631410e-01, +1.150154150448081e-01, 1.077413944384821e-01, 1.012902026558156e-01, 9.567411990702857e-02, 9.090383672483066e-02, +8.698843361438435e-02, 8.393536376804722e-02, 8.175043887779704e-02, 8.043781807234540e-02 +}; +const LC3_FLOAT PhECU_whr16ms_SWB[512]={ +8.000000000000002e-02, 8.024628976087178e-02, 8.098489531024239e-02, 8.221502573078943e-02, 8.393536376804722e-02, +8.614406724095569e-02, 8.883877101451404e-02, 9.201658953242653e-02, 9.567411990702857e-02, 9.980744556318394e-02, +1.044121404322514e-01, 1.094832736916302e-01, 1.150154150448081e-01, 1.210026405362591e-01, 1.274385388949634e-01, +1.343162183997567e-01, 1.416283142591582e-01, 1.493669964977737e-01, 1.575239783408292e-01, 1.660905250878570e-01, +1.750574634660318e-01, 1.844151914531410e-01, 1.941536885596704e-01, 2.042625265589956e-01, 2.147308806541882e-01, +2.255475410694793e-01, 2.367009250539683e-01, 2.481790892847231e-01, 2.599697426559885e-01, 2.720602594408110e-01, +2.844376928109830e-01, 2.970887887008307e-01, 3.099999999999999e-01, 3.231575010600410e-01, 3.365472024992595e-01, +3.501547662899784e-01, 3.639656211120587e-01, 3.779649779562326e-01, 3.921378459605457e-01, 4.064690484629473e-01, +4.209432392528405e-01, 4.355449190041883e-01, 4.502584518725810e-01, 4.650680822384892e-01, 4.799579515787762e-01, +4.949121154484021e-01, 5.099145605541342e-01, 5.249492219019830e-01, 5.400000000000000e-01, 5.550507780980171e-01, +5.700854394458659e-01, 5.850878845515979e-01, 6.000420484212237e-01, 6.149319177615109e-01, 6.297415481274190e-01, +6.444550809958116e-01, 6.590567607471596e-01, 6.735309515370527e-01, 6.878621540394543e-01, 7.020350220437674e-01, +7.160343788879413e-01, 7.298452337100215e-01, 7.434527975007406e-01, 7.568424989399589e-01, 7.699999999999999e-01, +7.829112112991693e-01, 7.955623071890170e-01, 8.079397405591890e-01, 8.200302573440115e-01, 8.318209107152770e-01, +8.432990749460317e-01, 8.544524589305209e-01, 8.652691193458119e-01, 8.757374734410044e-01, 8.858463114403297e-01, +8.955848085468591e-01, 9.049425365339682e-01, 9.139094749121430e-01, 9.224760216591710e-01, 9.306330035022263e-01, +9.383716857408418e-01, 9.456837816002432e-01, 9.525614611050366e-01, 9.589973594637410e-01, 9.649845849551919e-01, +9.705167263083698e-01, 9.755878595677486e-01, 9.801925544368162e-01, 9.843258800929715e-01, 9.879834104675735e-01, +9.911612289854861e-01, 9.938559327590444e-01, 9.960646362319528e-01, 9.977849742692106e-01, 9.990151046897577e-01, +9.997537102391283e-01, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 9.997537102391283e-01, 9.990151046897577e-01, 9.977849742692106e-01, +9.960646362319528e-01, 9.938559327590444e-01, 9.911612289854861e-01, 9.879834104675735e-01, 9.843258800929715e-01, +9.801925544368162e-01, 9.755878595677486e-01, 9.705167263083698e-01, 9.649845849551919e-01, 9.589973594637410e-01, +9.525614611050366e-01, 9.456837816002432e-01, 9.383716857408418e-01, 9.306330035022263e-01, 9.224760216591710e-01, +9.139094749121430e-01, 9.049425365339682e-01, 8.955848085468591e-01, 8.858463114403297e-01, 8.757374734410044e-01, +8.652691193458119e-01, 8.544524589305209e-01, 8.432990749460317e-01, 8.318209107152770e-01, 8.200302573440115e-01, +8.079397405591890e-01, 7.955623071890170e-01, 7.829112112991693e-01, 7.699999999999999e-01, 7.568424989399589e-01, +7.434527975007406e-01, 7.298452337100215e-01, 7.160343788879413e-01, 7.020350220437674e-01, 6.878621540394543e-01, +6.735309515370527e-01, 6.590567607471596e-01, 6.444550809958116e-01, 6.297415481274190e-01, 6.149319177615109e-01, +6.000420484212237e-01, 5.850878845515979e-01, 5.700854394458659e-01, 5.550507780980171e-01, 5.400000000000000e-01, +5.249492219019830e-01, 5.099145605541342e-01, 4.949121154484021e-01, 4.799579515787762e-01, 4.650680822384892e-01, +4.502584518725810e-01, 4.355449190041883e-01, 4.209432392528405e-01, 4.064690484629473e-01, 3.921378459605457e-01, +3.779649779562326e-01, 3.639656211120587e-01, 3.501547662899784e-01, 3.365472024992595e-01, 3.231575010600410e-01, +3.099999999999999e-01, 2.970887887008307e-01, 2.844376928109830e-01, 2.720602594408110e-01, 2.599697426559885e-01, +2.481790892847231e-01, 2.367009250539683e-01, 2.255475410694793e-01, 2.147308806541882e-01, 2.042625265589956e-01, +1.941536885596704e-01, 1.844151914531410e-01, 1.750574634660318e-01, 1.660905250878570e-01, 1.575239783408292e-01, +1.493669964977737e-01, 1.416283142591582e-01, 1.343162183997567e-01, 1.274385388949634e-01, 1.210026405362591e-01, +1.150154150448081e-01, 1.094832736916302e-01, 1.044121404322514e-01, 9.980744556318394e-02, 9.567411990702857e-02, +9.201658953242653e-02, 8.883877101451404e-02, 8.614406724095569e-02, 8.393536376804722e-02, 8.221502573078943e-02, +8.098489531024239e-02, 8.024628976087178e-02 +}; +const LC3_FLOAT PhECU_whr16ms_FB[768]={ +8.000000000000002e-02, 8.010946754324183e-02, 8.043781807234540e-02, 8.098489531024239e-02, 8.175043887779704e-02, +8.273408441773300e-02, 8.393536376804722e-02, 8.535370518483010e-02, 8.698843361438435e-02, 8.883877101451404e-02, +9.090383672483066e-02, 9.318264788589975e-02, 9.567411990702857e-02, 9.837706698247278e-02, 1.012902026558156e-01, +1.044121404322514e-01, 1.077413944384821e-01, 1.112763801299127e-01, 1.150154150448081e-01, 1.189567196050543e-01, +1.230984179631410e-01, 1.274385388949634e-01, 1.319750167380180e-01, 1.367056923745465e-01, 1.416283142591582e-01, +1.467405394904446e-01, 1.520399349260726e-01, 1.575239783408292e-01, 1.631900596270638e-01, 1.690354820369581e-01, +1.750574634660318e-01, 1.812531377772744e-01, 1.876195561652702e-01, 1.941536885596704e-01, 2.008524250673430e-01, +2.077125774525124e-01, 2.147308806541882e-01, 2.219039943401561e-01, 2.292285044967963e-01, 2.367009250539683e-01, +2.443176995441919e-01, 2.520752027953329e-01, 2.599697426559885e-01, 2.679975617527521e-01, 2.761548392785189e-01, +2.844376928109830e-01, 2.928421801604610e-01, 3.013643012461601e-01, 3.099999999999999e-01, 3.187451662970817e-01, +3.275956379118843e-01, 3.365472024992595e-01, 3.455955995992783e-01, 3.547365226649809e-01, 3.639656211120587e-01, +3.732785023894972e-01, 3.826707340701924e-01, 3.921378459605457e-01, 4.016753322280344e-01, 4.112786535457436e-01, +4.209432392528405e-01, 4.306644895299604e-01, 4.404377775884727e-01, 4.502584518725810e-01, 4.601218382732121e-01, +4.700232423526383e-01, 4.799579515787762e-01, 4.899212375680964e-01, 4.999083583360772e-01, 5.099145605541342e-01, +5.199350818119455e-01, 5.299651528841020e-01, 5.400000000000000e-01, 5.500348471158981e-01, 5.600649181880546e-01, +5.700854394458659e-01, 5.800916416639228e-01, 5.900787624319037e-01, 6.000420484212237e-01, 6.099767576473617e-01, +6.198781617267880e-01, 6.297415481274190e-01, 6.395622224115274e-01, 6.493355104700396e-01, 6.590567607471596e-01, +6.687213464542564e-01, 6.783246677719657e-01, 6.878621540394543e-01, 6.973292659298076e-01, 7.067214976105027e-01, +7.160343788879413e-01, 7.252634773350191e-01, 7.344044004007217e-01, 7.434527975007406e-01, 7.524043620881156e-01, +7.612548337029182e-01, 7.699999999999999e-01, 7.786356987538400e-01, 7.871578198395390e-01, 7.955623071890170e-01, +8.038451607214812e-01, 8.120024382472478e-01, 8.200302573440115e-01, 8.279247972046673e-01, 8.356823004558082e-01, +8.432990749460317e-01, 8.507714955032037e-01, 8.580960056598439e-01, 8.652691193458119e-01, 8.722874225474876e-01, +8.791475749326572e-01, 8.858463114403297e-01, 8.923804438347298e-01, 8.987468622227257e-01, 9.049425365339682e-01, +9.109645179630421e-01, 9.168099403729364e-01, 9.224760216591710e-01, 9.279600650739274e-01, 9.332594605095554e-01, +9.383716857408418e-01, 9.432943076254536e-01, 9.480249832619820e-01, 9.525614611050366e-01, 9.569015820368590e-01, +9.610432803949458e-01, 9.649845849551919e-01, 9.687236198700873e-01, 9.722586055615179e-01, 9.755878595677486e-01, +9.787097973441844e-01, 9.816229330175272e-01, 9.843258800929715e-01, 9.868173521141004e-01, 9.890961632751694e-01, +9.911612289854861e-01, 9.930115663856157e-01, 9.946462948151700e-01, 9.960646362319528e-01, 9.972659155822671e-01, +9.982495611222031e-01, 9.990151046897577e-01, 9.995621819276547e-01, 9.998905324567582e-01, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +9.998905324567582e-01, 9.995621819276547e-01, 9.990151046897577e-01, 9.982495611222031e-01, 9.972659155822671e-01, +9.960646362319528e-01, 9.946462948151700e-01, 9.930115663856157e-01, 9.911612289854861e-01, 9.890961632751694e-01, +9.868173521141004e-01, 9.843258800929715e-01, 9.816229330175272e-01, 9.787097973441844e-01, 9.755878595677486e-01, +9.722586055615179e-01, 9.687236198700873e-01, 9.649845849551919e-01, 9.610432803949458e-01, 9.569015820368590e-01, +9.525614611050366e-01, 9.480249832619820e-01, 9.432943076254536e-01, 9.383716857408418e-01, 9.332594605095554e-01, +9.279600650739274e-01, 9.224760216591710e-01, 9.168099403729364e-01, 9.109645179630421e-01, 9.049425365339682e-01, +8.987468622227257e-01, 8.923804438347298e-01, 8.858463114403297e-01, 8.791475749326572e-01, 8.722874225474876e-01, +8.652691193458119e-01, 8.580960056598439e-01, 8.507714955032037e-01, 8.432990749460317e-01, 8.356823004558082e-01, +8.279247972046673e-01, 8.200302573440115e-01, 8.120024382472478e-01, 8.038451607214812e-01, 7.955623071890170e-01, +7.871578198395390e-01, 7.786356987538400e-01, 7.699999999999999e-01, 7.612548337029182e-01, 7.524043620881156e-01, +7.434527975007406e-01, 7.344044004007217e-01, 7.252634773350191e-01, 7.160343788879413e-01, 7.067214976105027e-01, +6.973292659298076e-01, 6.878621540394543e-01, 6.783246677719657e-01, 6.687213464542564e-01, 6.590567607471596e-01, +6.493355104700396e-01, 6.395622224115274e-01, 6.297415481274190e-01, 6.198781617267880e-01, 6.099767576473617e-01, +6.000420484212237e-01, 5.900787624319037e-01, 5.800916416639228e-01, 5.700854394458659e-01, 5.600649181880546e-01, +5.500348471158981e-01, 5.400000000000000e-01, 5.299651528841020e-01, 5.199350818119455e-01, 5.099145605541342e-01, +4.999083583360772e-01, 4.899212375680964e-01, 4.799579515787762e-01, 4.700232423526383e-01, 4.601218382732121e-01, +4.502584518725810e-01, 4.404377775884727e-01, 4.306644895299604e-01, 4.209432392528405e-01, 4.112786535457436e-01, +4.016753322280344e-01, 3.921378459605457e-01, 3.826707340701924e-01, 3.732785023894972e-01, 3.639656211120587e-01, +3.547365226649809e-01, 3.455955995992783e-01, 3.365472024992595e-01, 3.275956379118843e-01, 3.187451662970817e-01, +3.099999999999999e-01, 3.013643012461601e-01, 2.928421801604610e-01, 2.844376928109830e-01, 2.761548392785189e-01, +2.679975617527521e-01, 2.599697426559885e-01, 2.520752027953329e-01, 2.443176995441919e-01, 2.367009250539683e-01, +2.292285044967963e-01, 2.219039943401561e-01, 2.147308806541882e-01, 2.077125774525124e-01, 2.008524250673430e-01, +1.941536885596704e-01, 1.876195561652702e-01, 1.812531377772744e-01, 1.750574634660318e-01, 1.690354820369581e-01, +1.631900596270638e-01, 1.575239783408292e-01, 1.520399349260726e-01, 1.467405394904446e-01, 1.416283142591582e-01, +1.367056923745465e-01, 1.319750167380180e-01, 1.274385388949634e-01, 1.230984179631410e-01, 1.189567196050543e-01, +1.150154150448081e-01, 1.112763801299127e-01, 1.077413944384821e-01, 1.044121404322514e-01, 1.012902026558156e-01, +9.837706698247278e-02, 9.567411990702857e-02, 9.318264788589975e-02, 9.090383672483066e-02, 8.883877101451404e-02, +8.698843361438435e-02, 8.535370518483010e-02, 8.393536376804722e-02, 8.273408441773300e-02, 8.175043887779704e-02, +8.098489531024239e-02, 8.043781807234540e-02, 8.010946754324183e-02 +}; + +const LC3_FLOAT* PhECU_whr16ms_wins[5] = { + PhECU_whr16ms_NB,PhECU_whr16ms_WB,PhECU_whr16ms_SSWB,PhECU_whr16ms_SWB, PhECU_whr16ms_FB +}; + + +const LC3_FLOAT hannOla_8k[28 / 2 + 1] = { + 0.0000000000, 0.0125360439, 0.0495155660, 0.1090842588, 0.1882550991, 0.2830581304, 0.3887395330, 0.5000000000, 0.6112604670, 0.7169418696, 0.8117449009, 0.8909157412, 0.9504844340, + 0.9874639561, 1.0000000000 }; + +const LC3_FLOAT hannOla_16k[56 / 2 + 1] = { + 0.0000000000, 0.0031438951, 0.0125360439, 0.0280583348, 0.0495155660, 0.0766379004, 0.1090842588, 0.1464466094, 0.1882550991, 0.2339839617, 0.2830581304, 0.3348604690, 0.3887395330, + 0.4440177619, 0.5000000000, 0.5559822381, 0.6112604670, 0.6651395310, 0.7169418696, 0.7660160383, 0.8117449009, 0.8535533906, 0.8909157412, 0.9233620996, 0.9504844340, 0.9719416652, + 0.9874639561, 0.9968561049, 1.0000000000 }; + +const LC3_FLOAT hannOla_24k[84 / 2 + 1] = { + 0.0000000000, 0.0013981014, 0.0055845869, 0.0125360439, 0.0222135971, 0.0345631257, 0.0495155660, 0.0669872981, 0.0868806128, 0.1090842588, 0.1334740641, 0.1599136311, 0.1882550991, + 0.2183399710, 0.2500000000, 0.2830581304, 0.3173294878, 0.3526224128, 0.3887395330, 0.4254788669, 0.4626349532, 0.5000000000, 0.5373650468, 0.5745211331, 0.6112604670, 0.6473775872, + 0.6826705122, 0.7169418696, 0.7500000000, 0.7816600290, 0.8117449009, 0.8400863689, 0.8665259359, 0.8909157412, 0.9131193872, 0.9330127019, 0.9504844340, 0.9654368743, 0.9777864029, + 0.9874639561, 0.9944154131, 0.9986018986, 1.0000000000 }; + +const LC3_FLOAT hannOla_32k[112 / 2 + 1] = { + 0.0000000000, 0.0007865925, 0.0031438951, 0.0070644907, 0.0125360439, 0.0195413390, 0.0280583348, 0.0380602337, 0.0495155660, 0.0623882890, 0.0766379004, 0.0922195655, 0.1090842588, + 0.1271789176, 0.1464466094, 0.1668267110, 0.1882550991, 0.2106643519, 0.2339839617, 0.2581405564, 0.2830581304, 0.3086582838, 0.3348604690, 0.3615822443, 0.3887395330, 0.4162468883, + 0.4440177619, 0.4719647764, 0.5000000000, 0.5280352236, 0.5559822381, 0.5837531117, 0.6112604670, 0.6384177557, 0.6651395310, 0.6913417162, 0.7169418696, 0.7418594436, 0.7660160383, + 0.7893356481, 0.8117449009, 0.8331732890, 0.8535533906, 0.8728210824, 0.8909157412, 0.9077804345, 0.9233620996, 0.9376117110, 0.9504844340, 0.9619397663, 0.9719416652, 0.9804586610, + 0.9874639561, 0.9929355093, 0.9968561049, 0.9992134075, 1.0000000000 }; + +const LC3_FLOAT hannOla_48k[168 / 2 + 1] = { + 0.0000000000, 0.0003496476, 0.0013981014, 0.0031438951, 0.0055845869, 0.0087167634, 0.0125360439, 0.0170370869, 0.0222135971, 0.0280583348, 0.0345631257, 0.0417188721, 0.0495155660, + 0.0579423032, 0.0669872981, 0.0766379004, 0.0868806128, 0.0977011101, 0.1090842588, 0.1210141384, 0.1334740641, 0.1464466094, 0.1599136311, 0.1738562944, 0.1882550991, 0.2030899072, + 0.2183399710, 0.2339839617, 0.2500000000, 0.2663656859, 0.2830581304, 0.3000539878, 0.3173294878, 0.3348604690, 0.3526224128, 0.3705904774, 0.3887395330, 0.4070441964, 0.4254788669, + 0.4440177619, 0.4626349532, 0.4813044029, 0.5000000000, 0.5186955971, 0.5373650468, 0.5559822381, 0.5745211331, 0.5929558036, 0.6112604670, 0.6294095226, 0.6473775872, 0.6651395310, + 0.6826705122, 0.6999460122, 0.7169418696, 0.7336343141, 0.7500000000, 0.7660160383, 0.7816600290, 0.7969100928, 0.8117449009, 0.8261437056, 0.8400863689, 0.8535533906, 0.8665259359, + 0.8789858616, 0.8909157412, 0.9022988899, 0.9131193872, 0.9233620996, 0.9330127019, 0.9420576968, 0.9504844340, 0.9582811279, 0.9654368743, 0.9719416652, 0.9777864029, 0.9829629131, + 0.9874639561, 0.9912832366, 0.9944154131, 0.9968561049, 0.9986018986, 0.9996503524, 1.0000000000 }; + +const LC3_FLOAT *hannOla_wins[5] = { hannOla_8k, hannOla_16k, hannOla_24k, hannOla_32k, hannOla_48k }; + +const LC3_FLOAT plc_tdc_lpc_8[17] = {1, 0.998890285693703, 0.995568526105076, 0.990056789412169, 0.982391584470799, 0.972623458066693, 0.960816439805232, 0.947047343167065, 0.931404933402306, 0.913988974871173, 0.894909172128633, 0.874284020464791, 0.852239582727672, 0.828908210053904, 0.804427224606163, 0.778937582561901, 0.752582535420797}; + +const LC3_FLOAT plc_tdc_lpc_16[17] = {1, 0.999722455898711, 0.998890285693703, 0.997504874399492, 0.995568526105076, 0.993084457588532, 0.990056789412169, 0.986490534532745, 0.982391584470799, 0.977766693092529, 0.972623458066693, 0.966970300067793, 0.960816439805232, 0.954171872966123, 0.947047343167065, 0.939454313017299, 0.931404933402306}; + +const LC3_FLOAT plc_tdc_lpc_24[17] = {1, 0.999876637554759, 0.999506641521283, 0.998890285693703, 0.998028026020383, 0.996920500041823, 0.995568526105076, 0.993973102356048, 0.992135405511397, 0.990056789412169, 0.987738783361644, 0.985183090250255, 0.982391584470799, 0.979366309627507, 0.976109476042902, 0.972623458066693, 0.968910791191297}; + +const LC3_FLOAT plc_tdc_lpc_32[17] = {1, 0.999930606751878, 0.999722455898711, 0.999375634094057, 0.998890285693703, 0.998266612655538, 0.997504874399492, 0.996605387627705, 0.995568526105076, 0.994394720400431, 0.993084457588532, 0.991638280913245, 0.990056789412169, 0.988340637503103, 0.986490534532745, 0.984507244288062, 0.982391584470799}; + +const LC3_FLOAT plc_tdc_lpc_48[17] = {1, 0.999969157961872, 0.999876637554759, 0.999722455898711, 0.999506641521283, 0.999229234348730, 0.998890285693703, 0.998489858239427, 0.998028026020383, 0.997504874399492, 0.996920500041823, 0.996275010884819, 0.995568526105076, 0.994801176081669, 0.993973102356048, 0.993084457588532, 0.992135405511397}; + +const LC3_FLOAT plc_tdc_lpc_96[17] = {1, 0.999992289401289, 0.999969157961872, 0.999930606751878, 0.999876637554759, 0.999807252867157, 0.999722455898711, 0.999622250571809, 0.999506641521283, 0.999375634094057, 0.999229234348730, 0.999067449055113, 0.998890285693703, 0.998697752455111, 0.998489858239427, 0.998266612655538, 0.998028026020383}; + +const LC3_FLOAT *plc_tdc_lpc_all[6] = {plc_tdc_lpc_8, plc_tdc_lpc_16, plc_tdc_lpc_24, plc_tdc_lpc_32, plc_tdc_lpc_48, plc_tdc_lpc_96}; + +const LC3_FLOAT plc_tdc_lpc_8_25ms[9] = {1, 0.998890285693703, 0.995568526105076, 0.990056789412169, 0.982391584470799, 0.972623458066693, 0.960816439805232, 0.947047343167065, 0.931404933402306}; + +const LC3_FLOAT plc_preemph_fac[] = {0.62, 0.72, 0.82, 0.92, 0.92, 0.92}; + +const LC3_INT ACC_COEFF_PER_BAND_PLC_8_10ms[81] = { + 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}; +const LC3_INT ACC_COEFF_PER_BAND_PLC_16_10ms[81] = { + 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, + 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, + 84, 86, 88, 90, 92, 94, 96, 98, 100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, 124, + 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 146, 148, 150, 152, 154, 156, 158, 160}; +const LC3_INT ACC_COEFF_PER_BAND_PLC_24_10ms[81] = { + 0, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, + 63, 66, 69, 72, 75, 78, 81, 84, 87, 90, 93, 96, 99, 102, 105, 108, 111, 114, 117, 120, 123, + 126, 129, 132, 135, 138, 141, 144, 147, 150, 153, 156, 159, 162, 165, 168, 171, 174, 177, 180, 183, 186, + 189, 192, 195, 198, 201, 204, 207, 210, 213, 216, 219, 222, 225, 228, 231, 234, 237, 240}; +const LC3_INT ACC_COEFF_PER_BAND_PLC_32_10ms[81] = { + 0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 68, 72, 76, 80, + 84, 88, 92, 96, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 144, 148, 152, 156, 160, 164, + 168, 172, 176, 180, 184, 188, 192, 196, 200, 204, 208, 212, 216, 220, 224, 228, 232, 236, 240, 244, 248, + 252, 256, 260, 264, 268, 272, 276, 280, 284, 288, 292, 296, 300, 304, 308, 312, 316, 320}; +const LC3_INT ACC_COEFF_PER_BAND_PLC_48_10ms[81] = { + 0, 6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90, 96, 102, 108, 114, 120, + 126, 132, 138, 144, 150, 156, 162, 168, 174, 180, 186, 192, 198, 204, 210, 216, 222, 228, 234, 240, 246, + 252, 258, 264, 270, 276, 282, 288, 294, 300, 306, 312, 318, 324, 330, 336, 342, 348, 354, 360, 366, 372, + 378, 384, 390, 396 , 402, 408, 414, 420, 426, 432, 438, 444, 450, 456, 462, 468, 474, 480}; +const LC3_INT ACC_COEFF_PER_BAND_PLC_96_10ms[81] = { + 0, 12, 24, 36, 48, 60, 72, 84, 96, 108, 120, 132, 144, 156, 168, 180, 192, 204, 216, 228, 240, + 252, 264, 276, 288, 300, 312, 324, 336, 348, 360, 372, 384, 396, 408, 420, 432, 444, 456, 468, 480, 492, + 504, 516, 528, 540, 552, 564, 576, 588, 600, 612, 624, 636, 648, 660, 672, 684, 696, 708, 720, 732, 744, + 756, 768, 780, 792, 804, 816, 828, 840, 852, 864, 876, 888, 900, 912, 924, 936, 948, 960}; + +const LC3_INT* ACC_COEFF_PER_BAND_PLC[] = { + ACC_COEFF_PER_BAND_PLC_8_10ms, ACC_COEFF_PER_BAND_PLC_16_10ms, ACC_COEFF_PER_BAND_PLC_24_10ms, + ACC_COEFF_PER_BAND_PLC_32_10ms, ACC_COEFF_PER_BAND_PLC_48_10ms, ACC_COEFF_PER_BAND_PLC_96_10ms}; + +const LC3_INT ACC_COEFF_PER_BAND_PLC_8_2_5ms[21] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + 11, 12, 13, 14, 15, 16, 17, 18, 19, 20}; + +const LC3_INT ACC_COEFF_PER_BAND_PLC_16_2_5ms[41] = {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}; + +const LC3_INT ACC_COEFF_PER_BAND_PLC_24_2_5ms[61] = {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}; + +const LC3_INT ACC_COEFF_PER_BAND_PLC_32_2_5ms[81] = { + 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}; + +const LC3_INT ACC_COEFF_PER_BAND_PLC_48_2_5ms[61] = { + 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, + 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, + 84, 86, 88, 90, 92, 94, 96, 98, 100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120}; + +const LC3_INT ACC_COEFF_PER_BAND_PLC_96_2_5ms[81] = { + 0, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, + 63, 66, 69, 72, 75, 78, 81, 84, 87, 90, 93, 96, 99, 102, 105, 108, 111, 114, 117, 120, 123, + 126, 129, 132, 135, 138, 141, 144, 147, 150, 153, 156, 159, 162, 165, 168, 171, 174, 177, 180, 183, 186, + 189, 192, 195, 198, 201, 204, 207, 210, 213, 216, 219, 222, 225, 228, 231, 234, 237, 240}; + +const LC3_INT* ACC_COEFF_PER_BAND_PLC_2_5ms[] = { + ACC_COEFF_PER_BAND_PLC_8_2_5ms, ACC_COEFF_PER_BAND_PLC_16_2_5ms, ACC_COEFF_PER_BAND_PLC_24_2_5ms, + ACC_COEFF_PER_BAND_PLC_32_2_5ms, ACC_COEFF_PER_BAND_PLC_48_2_5ms, ACC_COEFF_PER_BAND_PLC_96_2_5ms}; + +const LC3_INT ACC_COEFF_PER_BAND_PLC_8_5ms[41] = {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}; + +const LC3_INT ACC_COEFF_PER_BAND_PLC_16_5ms[81] = { + 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}; + +const LC3_INT ACC_COEFF_PER_BAND_PLC_24_5ms[41] = {0, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, + 42, 45, 48, 51, 54, 57, 60, 63, 66, 69, 72, 75, 78, 81, + 84, 87, 90, 93, 96, 99, 102, 105, 108, 111, 114, 117, 120}; + +const LC3_INT ACC_COEFF_PER_BAND_PLC_32_5ms[81] = { + 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, + 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, + 84, 86, 88, 90, 92, 94, 96, 98, 100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, 124, + 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 146, 148, 150, 152, 154, 156, 158, 160}; + +const LC3_INT ACC_COEFF_PER_BAND_PLC_48_5ms[81] = { + 0, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, + 63, 66, 69, 72, 75, 78, 81, 84, 87, 90, 93, 96, 99, 102, 105, 108, 111, 114, 117, 120, 123, + 126, 129, 132, 135, 138, 141, 144, 147, 150, 153, 156, 159, 162, 165, 168, 171, 174, 177, 180, 183, 186, + 189, 192, 195, 198, 201, 204, 207, 210, 213, 216, 219, 222, 225, 228, 231, 234, 237, 240}; + +const LC3_INT ACC_COEFF_PER_BAND_PLC_96_5ms[81] = { + 0, 6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90, 96, 102, 108, 114, 120, + 126, 132, 138, 144, 150, 156, 162, 168, 174, 180, 186, 192, 198, 204, 210, 216, 222, 228, 234, 240, 246, + 252, 258, 264, 270, 276, 282, 288, 294, 300, 306, 312, 318, 324, 330, 336, 342, 348, 354, 360, 366, 372, + 378, 384, 390, 396, 402, 408, 414, 420, 426, 432, 438, 444, 450, 456, 462, 468, 474, 480}; + +const LC3_INT* ACC_COEFF_PER_BAND_PLC_5ms[] = { + ACC_COEFF_PER_BAND_PLC_8_5ms, ACC_COEFF_PER_BAND_PLC_16_5ms, ACC_COEFF_PER_BAND_PLC_24_5ms, + ACC_COEFF_PER_BAND_PLC_32_5ms, ACC_COEFF_PER_BAND_PLC_48_5ms, ACC_COEFF_PER_BAND_PLC_96_5ms}; + +const LC3_INT32 mdct_grp_bins[10] = { 4, 14, 24, 44, 84, 164, 244, 324, 404, 484 }; + +#if defined(CR8_A_PLC_FADEOUT_TUNING) +const LC3_INT16 plc_fadeout_param_maxlen[4] = {800, 400, 266, 200}; +const LC3_INT16 plc_fadeout_param_maxbytes[4] = {27, 14, 9, 7}; +#endif diff --git a/lib_lc3plus/constants.h b/lib_lc3plus/constants.h new file mode 100644 index 0000000000000000000000000000000000000000..ace0f938306f301bb3729eb5e645995b29c23fd7 --- /dev/null +++ b/lib_lc3plus/constants.h @@ -0,0 +1,238 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.3 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + + +#ifndef CONSTANTS_H +#define CONSTANTS_H + +#include "options.h" +#include "wmc_auto.h" +#include "defines.h" +#include "structs.h" + +/* DCT */ +extern const Complex dct2_16[16]; + +/* Ari coder */ +extern const LC3_INT16 ari_tns_order_cf[2][9]; +extern const LC3_INT16 ari_tns_freq_cf[8][18]; +extern const LC3_INT ari_spec_lookup_fl[4096]; +extern const LC3_INT16 ari_spec_cumfreq_fl[64][18]; +extern const LC3_INT ari_spec_bits_fl[64][17]; + +/* SNS */ +extern const LC3_FLOAT sns_W[6]; +extern const LC3_FLOAT *sns_preemph_all[6]; +extern const LC3_FLOAT sns_LFCB[8][32]; +extern const LC3_FLOAT sns_HFCB[8][32]; +extern const LC3_INT pvq_enc_A[16][11]; +extern const LC3_FLOAT idct_lookup[M][M]; + +/* 12.8 kHz resampler */ +extern const LC3_FLOAT lp_scale_factors[6]; + +extern const LC3_INT32 resamp_params[][4]; +extern const LC3_FLOAT *lp_filter[6]; +extern const LC3_FLOAT highpass50_filt_b[3]; +extern const LC3_FLOAT highpass50_filt_a[3]; +extern const LC3_INT up_fac[6]; + +/* TNS */ +extern const LC3_FLOAT quants_pts_tns[17]; +extern const LC3_INT huff_bits_tns[8][17]; +extern const LC3_INT order1_tns[8]; +extern const LC3_INT order2_tns[8]; +extern const LC3_FLOAT lagw_tns[9]; +extern const LC3_FLOAT quants_pts_tns[17]; +extern const LC3_FLOAT quants_thr_tns[18]; + +/* SNS */ +extern const LC3_FLOAT sns_vq_far_adj_gains_fl[8]; +extern const LC3_FLOAT sns_vq_near_adj_gains_fl[4]; +extern const LC3_FLOAT sns_vq_reg_lf_adj_gains_fl[4]; +extern const LC3_FLOAT q_g_sns[6]; +extern const LC3_FLOAT sns_vq_reg_adj_gains_fl[2]; +extern const LC3_FLOAT sns_dec_gains[4][8]; + +/* Global Gain */ +extern const LC3_INT gg_p1[6]; +extern const LC3_INT gg_p2[6]; +extern const LC3_INT gg_p3[6]; +extern const LC3_FLOAT gg_c[6]; +extern const LC3_FLOAT gg_d[6]; + +/* Olpa */ +extern const LC3_FLOAT olpa_down2[5]; +extern const LC3_FLOAT olpa_acw[98]; + +/* LTPF */ +extern const LC3_FLOAT conf_inter_filter_48[4][12]; +extern const LC3_FLOAT conf_inter_filter_32[4][8]; +extern const LC3_FLOAT conf_inter_filter_24[4][6]; +extern const LC3_FLOAT conf_inter_filter_16[4][4]; +extern const LC3_FLOAT conf_tilt_filter_48[4][11]; +extern const LC3_FLOAT conf_tilt_filter_32[4][7]; +extern const LC3_FLOAT conf_tilt_filter_24[4][5]; +extern const LC3_FLOAT conf_tilt_filter_16[4][3]; +extern const LC3_FLOAT inter4_1[33]; +extern const LC3_FLOAT enc_inter_filter[4][4]; + +/* Bandwidth Detector */ +extern const LC3_INT threshold_quiet[4]; +extern const LC3_INT threshold_brickwall[4]; +extern const LC3_INT brickwall_dist[4]; +extern const LC3_INT BW_warp_idx_start_16k[4]; +extern const LC3_INT BW_warp_idx_stop_16k[4]; +extern const LC3_INT BW_warp_idx_start_24k[4]; +extern const LC3_INT BW_warp_idx_stop_24k[4]; +extern const LC3_INT BW_warp_idx_start_32k[4]; +extern const LC3_INT BW_warp_idx_stop_32k[4]; +extern const LC3_INT BW_warp_idx_start_48k[4]; +extern const LC3_INT BW_warp_idx_stop_48k[4]; +extern const LC3_INT* BW_warp_idx_start_all[4]; +extern const LC3_INT* BW_warp_idx_stop_all[4]; + +extern const LC3_INT BW_warp_idx_start_16k_2_5ms[4]; +extern const LC3_INT BW_warp_idx_stop_16k_2_5ms[4]; +extern const LC3_INT BW_warp_idx_start_24k_2_5ms[4]; +extern const LC3_INT BW_warp_idx_stop_24k_2_5ms[4]; +extern const LC3_INT BW_warp_idx_start_32k_2_5ms[4]; +extern const LC3_INT BW_warp_idx_stop_32k_2_5ms[4]; +extern const LC3_INT BW_warp_idx_start_48k_2_5ms[4]; +extern const LC3_INT BW_warp_idx_stop_48k_2_5ms[4]; +extern const LC3_INT* BW_warp_idx_start_all_2_5ms[4]; +extern const LC3_INT* BW_warp_idx_stop_all_2_5ms[4]; +extern const LC3_INT BW_cutoff_bin_all_2_5ms_HR[MAX_BW_BANDS_NUMBER]; +extern const LC3_INT bands_number_2_5ms_HR[6]; + +extern const LC3_INT BW_cutoff_bin_all_2_5ms[MAX_BW_BANDS_NUMBER]; +extern const LC3_INT bands_number_2_5ms[5]; + + +extern const LC3_INT BW_warp_idx_start_16k_5ms[4]; +extern const LC3_INT BW_warp_idx_stop_16k_5ms[4]; +extern const LC3_INT BW_warp_idx_start_24k_5ms[4]; +extern const LC3_INT BW_warp_idx_stop_24k_5ms[4]; +extern const LC3_INT BW_warp_idx_start_32k_5ms[4]; +extern const LC3_INT BW_warp_idx_stop_32k_5ms[4]; +extern const LC3_INT BW_warp_idx_start_48k_5ms[4]; +extern const LC3_INT BW_warp_idx_stop_48k_5ms[4]; +extern const LC3_INT* BW_warp_idx_start_all_5ms[4]; +extern const LC3_INT* BW_warp_idx_stop_all_5ms[4]; +extern const LC3_INT BW_cutoff_bin_all_5ms[MAX_BW_BANDS_NUMBER]; +extern const LC3_INT bands_number_5ms[6]; +extern const LC3_INT BW_cutoff_bin_all_HR[MAX_BW_BANDS_NUMBER]; +extern const LC3_INT BW_cutoff_bin_all_5ms_HR[MAX_BW_BANDS_NUMBER]; +extern const LC3_INT BW_cutoff_bin_all[MAX_BW_BANDS_NUMBER]; +extern const LC3_INT BW_cutoff_bits_all[MAX_BW_BANDS_NUMBER]; + +#ifdef CR8_G_ADD_75MS +extern const LC3_INT BW_cutoff_bin_all_7_5ms[MAX_BW_BANDS_NUMBER]; +extern const LC3_INT bands_number_7_5ms[6]; +extern const LC3_INT bands_number_7_5ms_HR[6]; +extern const LC3_INT* BW_warp_idx_start_all_7_5ms[4]; +extern const LC3_INT* BW_warp_idx_stop_all_7_5ms[4]; +extern const LC3_INT brickwall_dist_7_5ms[4]; +extern const LC3_INT* ACC_COEFF_PER_BAND_PLC_7_5ms[]; +#endif + +/* Arithmetic coding */ +extern const LC3_INT tns_cf[8][18]; +extern const LC3_INT tns_freq_cf[2][9]; + +/* MDCT Windows */ +extern const LC3_FLOAT MDCT_WINDOW_80[160]; +extern const LC3_FLOAT MDCT_WINDOW_160[320]; +extern const LC3_FLOAT MDCT_WINDOW_240[480]; +extern const LC3_FLOAT MDCT_WINDOW_320[640]; +extern const LC3_FLOAT MDCT_WINDOW_480[960]; +extern const LC3_FLOAT MDCT_WINDOW_960[1920]; +extern const LC3_FLOAT* MDCT_WINS_10ms[2][6]; +extern const LC3_INT MDCT_la_zeroes[6]; + +extern const LC3_FLOAT MDCT_WINDOW_80_2_5ms[40]; +extern const LC3_FLOAT MDCT_WINDOW_160_2_5ms[80]; +extern const LC3_FLOAT MDCT_WINDOW_240_2_5ms[120]; +extern const LC3_FLOAT MDCT_WINDOW_320_2_5ms[160]; +extern const LC3_FLOAT MDCT_WINDOW_480_2_5ms[240]; +extern const LC3_FLOAT* MDCT_WINS_2_5ms[2][6]; +extern const LC3_INT MDCT_la_zeroes_2_5ms[6]; + +extern const LC3_FLOAT MDCT_WINDOW_80_5ms[80]; +extern const LC3_FLOAT MDCT_WINDOW_160_5ms[160]; +extern const LC3_FLOAT MDCT_WINDOW_240_5ms[240]; +extern const LC3_FLOAT MDCT_WINDOW_320_5ms[320]; +extern const LC3_FLOAT MDCT_WINDOW_480_5ms[480]; +extern const LC3_FLOAT* MDCT_WINS_5ms[2][6]; +extern const LC3_INT MDCT_la_zeroes_5ms[6]; + +#ifdef CR8_G_ADD_75MS +extern const LC3_FLOAT* MDCT_WINS_7_5ms[2][6]; +extern const LC3_INT32 MDCT_la_zeroes_7_5ms[6]; +#endif + +extern const LC3_INT MDCT_WINDOWS_LENGTHS_10ms[6]; +extern const LC3_INT MDCT_WINDOWS_LENGTHS_7_5ms[6]; +extern const LC3_INT MDCT_WINDOWS_LENGTHS_5ms[6]; +extern const LC3_INT MDCT_WINDOWS_LENGTHS_2_5ms[6]; + +/* Per band energy */ +extern const LC3_INT* ACC_COEFF_PER_BAND[6]; +extern const LC3_INT* ACC_COEFF_PER_BAND_HR[6]; + +extern const LC3_INT* ACC_COEFF_PER_BAND_2_5ms_HR[6]; +extern const LC3_INT* ACC_COEFF_PER_BAND_2_5ms[5]; + +#ifdef CR8_G_ADD_75MS +extern const LC3_INT* ACC_COEFF_PER_BAND_7_5ms_HR[6]; +extern const LC3_INT* ACC_COEFF_PER_BAND_7_5ms[5]; +#endif + +extern const LC3_INT* ACC_COEFF_PER_BAND_5ms_HR[6]; +extern const LC3_INT* ACC_COEFF_PER_BAND_5ms[5]; + +/* Near Nyquist detector */ +extern const LC3_INT NN_thresh; +/* Tone detector */ +#ifdef CR8_E_TONE_DETECTOR +extern const LC3_INT32 TD_HR_thresh_10ms; +extern const LC3_INT32 TD_HR_thresh_7_5ms; +extern const LC3_INT32 TD_HR_thresh_5ms; +extern const LC3_INT32 TD_HR_thresh_2_5ms; +#endif // CR8_E_TONE_DETECTOR + +extern const LC3_INT32 xavg_N_grp[5]; +extern const LC3_FLOAT *hannOla_wins[5]; +extern const LC3_INT32 gwlpr[MAX_LGW+1]; +#ifdef CR8_A_PLC_FADEOUT_TUNING +extern const LC3_INT16 fade_scheme_tab[24 / 2][3]; +extern const LC3_FLOAT scATHFx[MAX_LGW - 2]; +#endif +extern const LC3_INT32 mdct_grp_bins[10]; +extern const LC3_FLOAT* PhECU_whr16ms_wins[5]; + +extern const LC3_FLOAT plc_preemph_fac[]; +extern const LC3_INT* ACC_COEFF_PER_BAND_PLC[]; +extern const LC3_INT* ACC_COEFF_PER_BAND_PLC_2_5ms[]; +extern const LC3_INT* ACC_COEFF_PER_BAND_PLC_5ms[]; +extern const LC3_FLOAT *plc_tdc_lpc_all[6]; +extern const LC3_FLOAT plc_tdc_lpc_8[17]; +extern const LC3_FLOAT plc_tdc_lpc_16[17]; +extern const LC3_FLOAT plc_tdc_lpc_24[17]; +extern const LC3_FLOAT plc_tdc_lpc_32[17]; +extern const LC3_FLOAT plc_tdc_lpc_48[17]; +extern const LC3_FLOAT plc_tdc_lpc_96[17]; +extern const LC3_FLOAT plc_tdc_lpc_8_25ms[9]; + +#if defined(CR8_A_PLC_FADEOUT_TUNING) +extern const LC3_INT16 plc_fadeout_param_maxlen[4]; +extern const LC3_INT16 plc_fadeout_param_maxbytes[4]; +#endif + +#endif /* CONSTANTS_H */ diff --git a/lib_lc3plus/cutoff_bandwidth.c b/lib_lc3plus/cutoff_bandwidth.c new file mode 100644 index 0000000000000000000000000000000000000000..c0ee62c62c522ce6b70158a4614696aa045cd5a3 --- /dev/null +++ b/lib_lc3plus/cutoff_bandwidth.c @@ -0,0 +1,28 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.3 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + + +#include "options.h" +#include "wmc_auto.h" +#include "functions.h" + +void process_cutoff_bandwidth(LC3_FLOAT *d_fl, LC3_INT len, LC3_INT bw_bin) +{ + LC3_INT i; + + if (len > bw_bin){ + for (i = -1; i < 3; i++) { + d_fl[bw_bin + i] = d_fl[bw_bin + i] * LC3_POW(2, -(i + 2)); + } + + for (i = bw_bin + 3; i < len; i++) { + d_fl[i] = 0; + } + } +} diff --git a/lib_lc3plus/dct4.c b/lib_lc3plus/dct4.c new file mode 100644 index 0000000000000000000000000000000000000000..055db02cbd8be826bdea341bda37fa126dfe8168 --- /dev/null +++ b/lib_lc3plus/dct4.c @@ -0,0 +1,95 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.3 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + + +#include "options.h" +#include "wmc_auto.h" +#include "functions.h" + +void dct2_init(Dct2* dct, int length) +{ + assert(length <= MAX_LEN); + dct->length = length; + fft_init(&dct->fft, length); +} + +void dct2_free(Dct2* dct) +{ + if (dct) { + fft_free(&dct->fft); + memset(dct, 0, sizeof(*dct)); + } +} + +void dct2_apply(Dct2* dct, const LC3_FLOAT* input, LC3_FLOAT* output) +{ + Complex tmp1[MAX_LEN]; + Complex tmp2[MAX_LEN]; + int i; + assert(input != output); + + for (i = 0; i < 8; i++) { + tmp1[i] = cmplx(input[i * 2], 0); + tmp1[16 - i - 1] = cmplx(input[i * 2 + 1], 0); + } + + fft_apply(&dct->fft, tmp1, tmp2); + + for (i = 0; i < 16; i++) { + output[i] = cmul(tmp2[i], dct2_16[i]).r; + } + output[0] /= (LC3_FLOAT)1.414213562373095; /* SQRT(2) */ +} + + +void dct4_init(Dct4* dct, int length) +{ + int i; + assert(length <= MAX_LEN); + dct->length = length; + dct->twid1 = calloc(sizeof(*dct->twid1), length / 2); + dct->twid2 = calloc(sizeof(*dct->twid2), length / 2); + for (i = 0; i < length / 2; i++) { + dct->twid1[i] = cexpi(-(LC3_FLOAT)M_PI * (i + (LC3_FLOAT)0.25) / length); + dct->twid2[i] = cexpi(-(LC3_FLOAT)M_PI * i / length); + } + fft_init(&dct->fft, length / 2); +} + +void dct4_free(Dct4* dct) +{ + if (dct) { + free(dct->twid1); + free(dct->twid2); + fft_free(&dct->fft); + memset(dct, 0, sizeof(*dct)); + } +} + +void dct4_apply(Dct4* dct, const LC3_FLOAT* input, LC3_FLOAT* output) +{ + Complex tmp2[MAX_LEN / 2]; + int i = 0; + Complex* tmp1 = (Complex*)output; + const int len = dct->length; + const LC3_FLOAT norm = (LC3_FLOAT)1.0 / LC3_SQRT((LC3_FLOAT)(len >> 1)); + assert(input != output); + + for (i = 0; i < len >> 1; i++) { + tmp1[i] = cmul(cmplx(input[i * 2], input[len - i * 2 - 1]), dct->twid1[i]); + } + + fft_apply(&dct->fft, tmp1, tmp2); + + for (i = 0; i < len >> 1; i++) { + Complex t = cmul(tmp2[i], dct->twid2[i]); + output[i * 2] = t.r * norm; + output[len - i * 2 - 1] = -t.i * norm; + } +} diff --git a/lib_lc3plus/dec_entropy.c b/lib_lc3plus/dec_entropy.c new file mode 100644 index 0000000000000000000000000000000000000000..4e1f830a244dec07a3f21b0da4a382270f491512 --- /dev/null +++ b/lib_lc3plus/dec_entropy.c @@ -0,0 +1,278 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.3 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + + +#include "options.h" +#include "wmc_auto.h" +#include "functions.h" + +static void read_bit_fl(LC3_UINT8* ptr, LC3_INT* mask_side, LC3_INT* bp_side, LC3_INT* bit); +static void read_uint_fl(LC3_INT nbits, LC3_UINT8* ptr, LC3_INT* mask_side, LC3_INT* bp_side, LC3_INT* val); + +void read_bit_fl(LC3_UINT8* ptr, LC3_INT* mask_side, LC3_INT* bp_side, LC3_INT* bit) +{ + if (ptr[*bp_side] & *mask_side) { + *bit = 1; + } else { + *bit = 0; + } + + if (*mask_side == 128) { + *mask_side = 1; + *bp_side = *bp_side - 1; + } else { + *mask_side = *mask_side * 2; + } +} + +void read_uint_fl(LC3_INT nbits, LC3_UINT8* ptr, LC3_INT* mask_side, LC3_INT* bp_side, LC3_INT* val) +{ + LC3_INT bit, i; + + read_bit_fl(ptr, mask_side, bp_side, val); + + for (i = 1; i < nbits; i++) { + read_bit_fl(ptr, mask_side, bp_side, &bit); + *val = *val + (bit << i); + } +} + +#ifdef ENABLE_PADDING +LC3_INT paddingDec_fl(LC3_UINT8* bytes, LC3_INT nbbits, LC3_INT L_spec, LC3_INT bw_cutoff_bits, LC3_INT ep_enabled, LC3_INT* total_padding, LC3_INT *np_zero) +{ + LC3_INT lastnz_threshold; + LC3_INT val, padding_len_bits, padding_len; + LC3_INT bp_side; + LC3_INT mask_side; + LC3_UINT8* ptr = bytes; + + LC3_INT nbbytes = nbbits >> 3; + LC3_INT lastnz; + LC3_INT bw_cutoff_idx; + LC3_INT nbits = ceil(LC3_LOGTWO(L_spec / 2)); + + if (nbits > nbbits) + { + return 1; + } + + *np_zero = 0; + + *total_padding = 0; + + bp_side = (nbbits - 1) >> 3; + mask_side = 1 << (8 - (nbbits - (bp_side << 3))); + + if (bp_side < 19 || bp_side >= LC3PLUS_MAX_BYTES) { + return 1; + } + + ptr = bytes; + + if (bw_cutoff_bits > 0) { + read_uint_fl(bw_cutoff_bits, ptr, &mask_side, &bp_side, &bw_cutoff_idx); + } + + read_uint_fl(nbits, ptr, &mask_side, &bp_side, &lastnz); + + lastnz_threshold = (1 << nbits) - 1 - 1; + + while (lastnz == lastnz_threshold) { + padding_len_bits = 16 - nbits - bw_cutoff_bits - 4; + + /*Read padding length*/ + read_uint_fl(padding_len_bits, ptr, &mask_side, &bp_side, &padding_len); + + /* Read 4 reserved bits */ + read_uint_fl(4, ptr, &mask_side, &bp_side, &val); + + if (ep_enabled == 0) + { + /* Discard padding length bytes */ + bp_side = bp_side - padding_len; + *total_padding = *total_padding + padding_len + 2; + } + else + { + *total_padding = *total_padding + 2; + *np_zero = *np_zero + padding_len; + } + + /* check if minimum payload size is reached */ + if ((nbbytes - (*total_padding + *np_zero)) < 20) { + return 1; + } + + /* Read bandwidth bits */ + if (bw_cutoff_bits > 0) { + read_uint_fl(bw_cutoff_bits, ptr, &mask_side, &bp_side, &bw_cutoff_idx); + } + + read_uint_fl(nbits, ptr, &mask_side, &bp_side, &lastnz); + } + + if (ep_enabled != 0) + { + *total_padding = *total_padding + *np_zero; + } + + return 0; +} +#endif + +void processDecoderEntropy_fl(LC3_UINT8* bytes, LC3_INT numbytes, LC3_INT* mask_side, LC3_INT* bp_side, LC3_INT N, LC3_INT fs_idx, + LC3_INT bw_cutoff_bits, LC3_INT* bfi, LC3_INT* gg_idx, LC3_INT* scf_idx, LC3_INT* fac_ns_idx, + LC3_INT* tns_numfilters, LC3_INT* tns_order, LC3_INT* ltpf_idx, LC3_INT* bw_cutoff_idx, LC3_INT* lastnz, + LC3_INT* lsbMode, LC3_INT frame_dms) +{ + + LC3_INT plc_trigger_bw, plc_trigger_last_nz, plc_trigger_SNS1, plc_trigger_SNS2, tmp, bit, + submodeMSB, i, ltpf_tmp[3], ind, submodeLSB, bp_side_local, mask_side_local; + LC3_UINT8* ptr; + LC3_INT gainMSBbits[4] = {1, 1, 2, 2}; + + *bp_side = -1; + bp_side_local = numbytes - 1; /* Matlab offset by 1 */ + mask_side_local = 1; + *mask_side = -1; + ptr = bytes; + *lsbMode = -1; + *lastnz = -1; + + plc_trigger_bw = 1; /* Bandwidth */ + plc_trigger_last_nz = 1; /* Last non-zero tuple */ + plc_trigger_SNS1 = 1; /* SNS-VQ 2nd stage MPVQ data (24-25 bits) */ + plc_trigger_SNS2 = 1; /* SNS-VQ 2nd stage MPVQ data (24-25 bits) */ + + + + /* Bandwidth */ + if (bw_cutoff_bits > 0) { + read_uint_fl(bw_cutoff_bits, ptr, &mask_side_local, &bp_side_local, bw_cutoff_idx); + + if (fs_idx < *bw_cutoff_idx) { + *bfi = plc_trigger_bw; + + if (*bfi) { + return; + } + } + } else { + *bw_cutoff_idx = fs_idx; + } + + /* Number of TNS filters */ + if (*bw_cutoff_idx < 3 || frame_dms == 25) { + *tns_numfilters = 1; + } else { + *tns_numfilters = 2; + } + + /* Last non-zero tuple */ + read_uint_fl(ceil(LC3_LOGTWO(N >> 1)), ptr, &mask_side_local, &bp_side_local, lastnz); + *lastnz = (*lastnz + 1) * 2; + + if (*lastnz > N) { + *bfi = plc_trigger_last_nz; + if (*bfi) { + return; + } + } + + /* LSB mode bit */ + read_bit_fl(ptr, &mask_side_local, &bp_side_local, lsbMode); + + /* Global gain */ + read_uint_fl(8, ptr, &mask_side_local, &bp_side_local, gg_idx); + + /* TNS activation flag */ + for (i = 0; i < *tns_numfilters; i++) { + read_bit_fl(ptr, &mask_side_local, &bp_side_local, &bit); + tns_order[i] = bit; + } + + /* LTPF activation flag */ + read_bit_fl(ptr, &mask_side_local, &bp_side_local, <pf_tmp[0]); + + /* SNS-VQ 1st stage */ + read_uint_fl(5, ptr, &mask_side_local, &bp_side_local, &scf_idx[0]); + read_uint_fl(5, ptr, &mask_side_local, &bp_side_local, &scf_idx[1]); + + /* SNS-VQ 2nd stage side-info (3-4 bits) */ + read_bit_fl(ptr, &mask_side_local, &bp_side_local, &submodeMSB); + scf_idx[2] = submodeMSB * 2; + + read_uint_fl(gainMSBbits[scf_idx[2]], ptr, &mask_side_local, &bp_side_local, &scf_idx[3]); + read_bit_fl(ptr, &mask_side_local, &bp_side_local, &scf_idx[4]); + + /* SNS-VQ 2nd stage MPVQ data (24-25 bits) */ + if (submodeMSB == 0) { + read_uint_fl(25, ptr, &mask_side_local, &bp_side_local, &tmp); + if (tmp >= 33460056) { + *bfi = plc_trigger_SNS1; + if (*bfi) { + return; + } + } + + ind = floor(tmp / 2390004); + scf_idx[5] = tmp - ind * 2390004; + + if (ind < 2) { + submodeLSB = 1; + scf_idx[3] = scf_idx[3] * 2 + ind; + scf_idx[6] = -2; + } else { + submodeLSB = 0; + scf_idx[6] = ind - 2; + } + + } else { + read_uint_fl(24, ptr, &mask_side_local, &bp_side_local, &tmp); + + if (tmp >= 16708096) { + *bfi = plc_trigger_SNS2; + if (*bfi) { + return; + } + } + + if (tmp >= 15158272) { + submodeLSB = 1; + scf_idx[3] = scf_idx[3] * 2 + ((tmp - 15158272) & 1); + scf_idx[5] = floor((tmp - 15158272) / 2); + scf_idx[6] = -2; + } else { + submodeLSB = 0; + scf_idx[5] = tmp; + scf_idx[6] = -1; + } + } + + scf_idx[2] = scf_idx[2] + submodeLSB; + + /* LTPF data */ + if (ltpf_tmp[0] == 1) { + read_bit_fl(ptr, &mask_side_local, &bp_side_local, <pf_tmp[1]); + read_uint_fl(9, ptr, &mask_side_local, &bp_side_local, <pf_tmp[2]); + } else { + ltpf_tmp[1] = 0; + ltpf_tmp[2] = 0; + } + + for (i = 0; i < 3; i++) { + ltpf_idx[i] = ltpf_tmp[i]; + } + + /* Noise factor */ + read_uint_fl(3, ptr, &mask_side_local, &bp_side_local, fac_ns_idx); + + *bp_side = bp_side_local; + *mask_side = mask_side_local; +} diff --git a/lib_lc3plus/dec_lc3_fl.c b/lib_lc3plus/dec_lc3_fl.c new file mode 100644 index 0000000000000000000000000000000000000000..6483265677ddc4c49eb1949719c5955ee2d2a850 --- /dev/null +++ b/lib_lc3plus/dec_lc3_fl.c @@ -0,0 +1,373 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.3 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + + +#include "options.h" +#include "wmc_auto.h" +#include "functions.h" + + +static int Dec_LC3PLUS_Channel_fl(LC3PLUS_Dec* decoder, int channel, uint8_t* bs_in, void* s_out, int bps, int bfi_ext) +{ + DecSetup* h_DecSetup; + LC3_INT mask_side = 0, bp_side = 0, bfi = 0, gg_idx = 0, fac_ns_idx = 0, tns_numfilters = 0, bw_cutoff_idx = 0, + lastnz = 0, lsbMode = 0, nf_seed = 0, zero_frame = 0, residualPresent = 0, nbits_residual = 0, bitsRead = 0, + i = 0, tns_order[2] = {0}, sqQdec[MAX_LEN] = {0}; + LC3_INT b_left; + LC3_FLOAT stab_fac = 0; + + h_DecSetup = decoder->channel_setup[channel]; + + memset(h_DecSetup->tns_idx, 0, sizeof(*h_DecSetup->tns_idx) * TNS_NUMFILTERS_MAX * MAXLAG); + + bfi = bfi_ext; + + decoder->rframe = 0; + if (bfi == 3) + { + bfi = 2; + decoder->rframe = 1; + } + + /* Entropy decoding */ + if (bfi != 1) { + processDecoderEntropy_fl(bs_in, h_DecSetup->targetBytes, &mask_side, &bp_side, decoder->yLen, decoder->fs_idx, + decoder->BW_cutoff_bits, &bfi, &gg_idx, h_DecSetup->scf_idx, &fac_ns_idx, + &tns_numfilters, tns_order, h_DecSetup->ltpf_param, &bw_cutoff_idx, &lastnz, &lsbMode, decoder->frame_dms + ); + h_DecSetup->BW_cutoff_idx_nf = bw_cutoff_idx; + } + + /* Arithmetic decoding */ + if (bfi != 1) { + processAriDecoder_fl(bs_in, bp_side, mask_side, decoder->yLen, decoder->fs_idx, + h_DecSetup->enable_lpc_weighting, tns_numfilters, lsbMode, lastnz, &bfi, tns_order, fac_ns_idx, gg_idx, h_DecSetup->resBits, + sqQdec, &nf_seed, h_DecSetup->tns_idx, &zero_frame, h_DecSetup->targetBytes, &nbits_residual, &residualPresent, decoder->frame_dms, + decoder->n_pc, decoder->be_bp_left, decoder->be_bp_right, 0, &b_left, &h_DecSetup->spec_inv_idx, + decoder->hrmode + ); + + if (decoder->rframe == 1 && zero_frame == 0 && bfi != 1) + { + LC3_INT32 max_bw_stopband = BW_cutoff_bin_all[bw_cutoff_idx]; + bfi = 2; + switch (decoder->frame_dms) + { + case 25: + max_bw_stopband = max_bw_stopband >> 2; + break; + case 50: + max_bw_stopband = max_bw_stopband >> 1; + break; +#ifdef CR8_G_ADD_75MS + case 75: + max_bw_stopband = 3 * (max_bw_stopband >> 2); + break; +#endif + case 100: + break; + } + + h_DecSetup->spec_inv_idx = MAX(lastnz, max_bw_stopband); + } + + /* Cast from int to float */ + for (i = 0; i < decoder->yLen; i++) { + h_DecSetup->sqQdec_fl[i] = (LC3_FLOAT)sqQdec[i]; + } + } + + if (bfi != 1) + { + /* SNS Quantize Decoder */ + process_snsQuantizesScf_Dec(h_DecSetup->scf_idx, h_DecSetup->scf_q); + } + if (h_DecSetup->PlcAdvSetup) + { + processPlcComputeStabFacMain_fl(h_DecSetup->scf_q, h_DecSetup->PlcAdvSetup->scf_q_old, h_DecSetup->PlcAdvSetup->scf_q_old_old, bfi, h_DecSetup->PlcSetup.prevBfi, + h_DecSetup->PlcSetup.prevprevBfi, &h_DecSetup->PlcAdvSetup->stabFac); + } + + if ( bfi != 1 ) + { + stab_fac = 1; + if (h_DecSetup->PlcAdvSetup) + { + stab_fac = h_DecSetup->PlcAdvSetup->stabFac; + } + + /* Partial Concealment */ + processPcMain_fl(&bfi, decoder, h_DecSetup->sqQdec_fl, h_DecSetup, h_DecSetup->ltpf_param[0], stab_fac, gg_idx, h_DecSetup->quantizedGainOff, + fac_ns_idx, &h_DecSetup->statePC, h_DecSetup->spec_inv_idx, decoder->yLen); + } + + /* Decoding only if no bit error detected */ + if (bfi != 1) { + /* Residual decoding */ + if (residualPresent) { + processResidualDecoding_fl(&bitsRead, h_DecSetup->sqQdec_fl, decoder->yLen, h_DecSetup->resBits, + nbits_residual + , decoder->hrmode + ); + } + + + /* Noise filling */ + if (zero_frame == 0) { + processNoiseFilling_fl(h_DecSetup->sqQdec_fl, nf_seed, fac_ns_idx, decoder->cutoffBins[h_DecSetup->BW_cutoff_idx_nf], decoder->frame_dms, h_DecSetup->prev_fac_ns, h_DecSetup->spec_inv_idx); + } + + /* Application of global gain */ + processApplyGlobalGain_fl(h_DecSetup->sqQdec_fl, decoder->yLen, gg_idx, h_DecSetup->quantizedGainOff); + + /* TNS decoder */ + processTnsDecoder_fl(h_DecSetup->sqQdec_fl, h_DecSetup->tns_idx, tns_order, tns_numfilters, + decoder->cutoffBins[bw_cutoff_idx], h_DecSetup->N_red_tns, h_DecSetup->fs_red_tns); + + /* SNS interpolation */ + processSnsInterpolateScf_fl(h_DecSetup->scf_q, 0, decoder->bands_number, h_DecSetup->int_scf); + + /* MDCT shaping */ + processMdctShaping_fl(h_DecSetup->sqQdec_fl, h_DecSetup->int_scf, decoder->bands_offset, decoder->bands_number); + } + + /* PLC */ + processPlcMain_fl(h_DecSetup->sqQdec_fl, h_DecSetup->x_fl, decoder, h_DecSetup, bfi, h_DecSetup->PlcAdvSetup, &h_DecSetup->PlcSetup, + decoder->plcMeth, h_DecSetup->ltpf_mem_pitch, h_DecSetup->ltpf_mem_pitch_fr, decoder->tilt, decoder->bands_offset, + decoder->bands_number, decoder->bands_offsetPLC, decoder->n_bandsPLC, decoder->hrmode, &h_DecSetup->statePC); + + processPlcDampingScramblingMain_fl(&h_DecSetup->PlcNsSetup.seed, + &h_DecSetup->statePC.seed, h_DecSetup->statePC.ns_nbLostCmpt_pc, + h_DecSetup->PlcSetup.nbLostCmpt, &h_DecSetup->PlcAdvSetup->stabFac, + &h_DecSetup->PlcAdvSetup->cum_fading_slow, &h_DecSetup->PlcAdvSetup->cum_fading_fast, + h_DecSetup->PlcSetup.q_d_prev, h_DecSetup->sqQdec_fl, h_DecSetup->spec_inv_idx, decoder->yLen, bfi, + decoder->frame_dms, h_DecSetup->concealMethod, h_DecSetup->ltpf_mem_pitch, h_DecSetup->ltpf_param[0], + &h_DecSetup->PlcAdvSetup->cum_fflcAtten +#ifdef CR8_A_PLC_FADEOUT_TUNING + , h_DecSetup->PlcAdvSetup->plc_fadeout_type +#endif + ); + + /* IMDCT */ + if (h_DecSetup->concealMethod == 4 || bfi != 1 ) + { + ProcessingIMDCT_fl(h_DecSetup->sqQdec_fl, decoder->frame_length, decoder->imdct_win, decoder->imdct_winLen, decoder->imdct_laZeros, + h_DecSetup->imdct_mem, h_DecSetup->x_fl, &h_DecSetup->dct4structImdct); + } + + processPlcUpdate_fl(h_DecSetup->PlcAdvSetup + , decoder->frame_length, h_DecSetup->x_fl, h_DecSetup->scf_q, + &h_DecSetup->PlcSetup.nbLostCmpt, &h_DecSetup->PlcNsSetup.cum_alpha, bfi, &h_DecSetup->PlcSetup.prevBfi, &h_DecSetup->PlcSetup.prevprevBfi); + + /* LTPF decoder */ + process_ltpf_decoder_fl(h_DecSetup->x_fl, decoder->frame_length, h_DecSetup->x_fl, decoder->fs, + h_DecSetup->ltpf_mem_x, h_DecSetup->ltpf_mem_y, &h_DecSetup->ltpf_mem_pitch, + &h_DecSetup->ltpf_mem_pitch_fr, &h_DecSetup->ltpf_mem_gain, &h_DecSetup->ltpf_mem_beta_idx, + bfi, h_DecSetup->ltpf_param, h_DecSetup->ltpf_param_mem, h_DecSetup->ltpf_conf_beta_idx, + h_DecSetup->ltpf_conf_beta, h_DecSetup->concealMethod, h_DecSetup->alpha + , &h_DecSetup->ltpf_mem_active +#ifdef CR9_N_SHORT_FADE_FOR_UNSTABLE_PITCH + , &h_DecSetup->rel_pitch_change, decoder->hrmode, decoder->frame_dms +#endif + ); + + { + /* Round, scale and copy output to output buffer */ + if (bps == 16) { + for (i = 0; i < decoder->frame_length; i++) { + LC3_FLOAT tmp = round(h_DecSetup->x_fl[i]); + ((int16_t*)s_out)[i] = (int16_t)fmaxf(fminf(tmp, 32767), -32768); + } + } else { + for (i = 0; i < decoder->frame_length; i++) { + LC3_FLOAT tmp = round(LC3_CONST_POW_2_23 * LC3_CONST_POW_2_M15 * h_DecSetup->x_fl[i]); + ((int32_t*)s_out)[i] = (int32_t)fmaxf(fminf(tmp, LC3_CONST_POW_2_23_RED), LC3_CONST_POW_2_23_NEG); + } + } + } + return bfi; +} + +LC3PLUS_Error Dec_LC3PLUS_fl(LC3PLUS_Dec* decoder, uint8_t* input, LC3_INT32 num_bytes, void** output, LC3_INT32 bps, LC3_INT32 bfi_ext) +{ + LC3_INT32 ch, bfi, lc3_num_bytes; + LC3PLUS_Error err; + LC3_INT32 fec_num_bytes; + LC3_INT32 lc3_channel_num_bytes; + LC3_INT32 channel_bfi, out_bfi; + LC3PLUS_EpModeRequest channel_epmr; + + bfi = bfi_ext; + lc3_num_bytes = 0; + err = LC3PLUS_OK; + + if (bfi == 0) + { + bfi = !num_bytes; + } + + if (decoder->ep_enabled) + { + decoder->combined_channel_coding = decoder->channels > 1 && num_bytes <= 160; + + if (decoder->combined_channel_coding) + { + fec_num_bytes = num_bytes; + + decoder->error_report = + fec_decoder(input, fec_num_bytes, &lc3_num_bytes, (LC3PLUS_EpModeRequest*)&decoder->epmr, decoder->combined_channel_coding, + &decoder->n_pccw, &bfi, &decoder->be_bp_left, &decoder->be_bp_right, &decoder->n_pc, &decoder->m_fec); + + for (ch = 0; ch < decoder->channels; ch++) + { + lc3_channel_num_bytes = lc3_num_bytes / decoder->channels + (ch < (lc3_num_bytes % decoder->channels)); + + + if (bfi != 1 && lc3_channel_num_bytes != decoder->channel_setup[ch]->last_size) + { + err = update_dec_bitrate(decoder, ch, lc3_channel_num_bytes); + if (err) + { + bfi = 1; + decoder->last_error = err; + } + else + { + decoder->channel_setup[ch]->last_size = lc3_channel_num_bytes; + } + } + + bfi = Dec_LC3PLUS_Channel_fl(decoder, ch, input, output[ch], bps, bfi); + input += decoder->channel_setup[ch]->targetBytes; + } + } + else + { + decoder->epmr = LC3PLUS_EPMR_HIGH_NC; + out_bfi = 0; + + for (ch = 0; ch < decoder->channels; ch++) + { + fec_num_bytes = num_bytes / decoder->channels + (ch < (num_bytes % decoder->channels)); + + channel_bfi = bfi; + + decoder->error_report = fec_decoder(input, fec_num_bytes, &lc3_num_bytes, &channel_epmr, + decoder->combined_channel_coding, &decoder->n_pccw, &channel_bfi, + &decoder->be_bp_left, &decoder->be_bp_right, &decoder->n_pc, &decoder->m_fec); + + decoder->epmr = MIN((LC3PLUS_EpModeRequest) decoder->epmr, channel_epmr); + + +#ifdef ENABLE_PADDING + if (channel_bfi != 1) + { + LC3_INT32 padding_len = 0, np_zero = 0; + + if (paddingDec_fl(input, (lc3_num_bytes << 3), decoder->yLen, decoder->BW_cutoff_bits, decoder->ep_enabled, &padding_len, &np_zero)) + { + channel_bfi = 1; + } + + input = input + np_zero; + decoder->n_pc = MAX(decoder->n_pc - (2 * np_zero), 0); + + if (channel_bfi == 2) + { + if (decoder->be_bp_right < (8 * np_zero)) + { + channel_bfi = 0; + decoder->be_bp_left = -1; + decoder->be_bp_right = -1; + } + else + { + decoder->be_bp_right = decoder->be_bp_right - (8 * np_zero); + decoder->be_bp_left = MAX(decoder->be_bp_left - (8 * np_zero), 0); + } + } + lc3_num_bytes = lc3_num_bytes - padding_len; + } +#endif + + if (channel_bfi != 1 && lc3_num_bytes != decoder->channel_setup[ch]->last_size) + { + err = update_dec_bitrate(decoder, ch, lc3_num_bytes); + if (err) + { + channel_bfi = 1; + decoder->last_error = err; + } + else + { + decoder->channel_setup[ch]->last_size = lc3_num_bytes; + } + } + + channel_bfi = Dec_LC3PLUS_Channel_fl(decoder, ch, input, output[ch], bps, channel_bfi); + + out_bfi |= channel_bfi; + input += fec_num_bytes; + } + + bfi = out_bfi & 1; + } + } + else + { + for (ch = 0; ch < decoder->channels; ch++) + { + lc3_num_bytes = num_bytes / decoder->channels + (ch < (num_bytes % decoder->channels)); + +#ifdef ENABLE_PADDING + if (bfi != 1) + { + LC3_INT32 padding_len = 0, np_zero = 0; + + if (paddingDec_fl(input, (lc3_num_bytes << 3), decoder->yLen, decoder->BW_cutoff_bits, decoder->ep_enabled, &padding_len, &np_zero)) + { + bfi = 1; + decoder->last_error = LC3PLUS_PADDING_ERROR; + } + + lc3_num_bytes = lc3_num_bytes - padding_len; + if (lc3_num_bytes < 20 || lc3_num_bytes > LC3PLUS_MAX_BYTES) + { + bfi = 1; /* mark frame as broken if frame size is below the minimum of 20 bytes or above the maximum of LC3PLUS_MAX_BYTES */ + decoder->last_error = FRAMESIZE_ERROR; + } + } +#endif + + if (bfi != 1 && lc3_num_bytes != decoder->channel_setup[ch]->last_size) + { + err = update_dec_bitrate(decoder, ch, lc3_num_bytes); + if (err) + { + bfi = 1; + decoder->last_error = err; + } + else + { + decoder->channel_setup[ch]->last_size = lc3_num_bytes; + } + } + + bfi = Dec_LC3PLUS_Channel_fl(decoder, ch, input, output[ch], bps, bfi); + input += decoder->channel_setup[ch]->targetBytes; + } + } + + if ((decoder->last_error == LC3PLUS_OK) && bfi) + { + decoder->last_error = LC3PLUS_DECODE_ERROR; + } + + return bfi == 1 ? LC3PLUS_DECODE_ERROR : LC3PLUS_OK; +} diff --git a/lib_lc3plus/defines.h b/lib_lc3plus/defines.h new file mode 100644 index 0000000000000000000000000000000000000000..2ee688e6c9c3b0ccf4c7bc325e5fe885a73d2f1a --- /dev/null +++ b/lib_lc3plus/defines.h @@ -0,0 +1,356 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.3 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + + +#ifndef DEFINES_H +#define DEFINES_H + +#include "options.h" +#include "wmc_auto.h" +#include "stdint.h" + + +typedef float LC3_FLOAT; +typedef int32_t LC3_INT; +typedef int16_t LC3_INT16; +typedef uint16_t LC3_UINT16; +typedef short LC3_SHORT; +typedef uint8_t LC3_UINT8; +typedef int8_t LC3_INT8; +typedef uint32_t LC3_UINT32; + +/* Release defines */ +#define ENABLE_2_5MS_MODE +#define ENABLE_5MS_MODE +#define ENABLE_075_DMS_MODE +#define ENABLE_10_MS_MODE +#define ENABLE_ADVANCED_PLC_FL +#define ENABLE_ADVANCED_PLC_FL_DEFAULT +#define ENABLE_BW_CONTROLLER +#define ENABLE_HR_MODE_FL +#define ENABLE_PADDING +#define ENABLE_RFRAME_FL +#define ENABLE_PLC +/* flags */ +#define ENABLE_PLC_MODE_FLAG +#define ENABLE_BANDWIDTH_FLAG +#define ENABLE_EP_MODE_FLAG +#define ENABLE_FRAME_MS_FLAG +#define ENABLE_HR_MODE_FL_FLAG + +#define CR8_G_ADD_75MS + +#ifndef NO_POST_REL_CHANGES +/* Post-release non-bitexact changes */ +#define CR8_A_PLC_FADEOUT_TUNING /* Adapt PLC fadeout to avoid gaps in signal */ +#define CR9_D_FLOATING_POINT_CODE_SIMPLIFICATIONS +#define CR9_F_PITCH_WIN_LEN_FIX /* Increase window length for pitch calculation */ +#define CR9_G_IMPROVE_TDC /* summarize G,H,J,L,N */ +#ifdef CR9_G_IMPROVE_TDC +#define CR9_G_PLC_NS_TDC_FIX /* Always use TDC if pitch > 0 */ +#define CR9_H_REMOVE_SWITCH_TO_PLC_NS +#define CR9_J_SLOW_TDC_FADEOUT +#define CR9_L_RETRAIN_FADEOUT_TYPE_CLASSIFIER +#ifdef ENABLE_HR_MODE_FL +#ifdef PLC_TUNING_SHORT_FADEOUT +#define CR9_N_SHORT_FADE_FOR_UNSTABLE_PITCH +#endif +#endif +#endif /* CR9_G_IMPROVE_TDC */ +#define CR9_I_INC_TDC_FADEOUT_LEN +#define CR9_K_REDUCE_NORM_CORR_TH + +#endif /* NO_POST_REL_CHANGES */ + +#ifdef CR9_D_FLOATING_POINT_CODE_SIMPLIFICATIONS +#define CR9_SIMPLIFY_LOOP +#define CR9_LTPF_REWRITE +#define CR9_QUANT_SPEC_REWRITE +#define CR9_SIMPLIFY_ARI_DECODER +#endif + +#ifdef CR8_A_PLC_FADEOUT_TUNING +#define MAX_UINT8 255 +#ifdef CR9_L_RETRAIN_FADEOUT_TYPE_CLASSIFIER +#ifdef CR9_K_REDUCE_NORM_CORR_TH +#define THRESH_100_DMS_TDC_CNT 9 +#define THRESH_100_DMS_NS_CNT 7 +#define THRESH_100_DMS_TDC_NS_CNT 73 +#define THRESH_075_DMS_TDC_CNT 7 +#define THRESH_075_DMS_NS_CNT 7 +#define THRESH_075_DMS_TDC_NS_CNT 87 +#define THRESH_050_DMS_TDC_CNT 22 +#define THRESH_050_DMS_NS_CNT 15 +#define THRESH_050_DMS_TDC_NS_CNT 141 +#define THRESH_025_DMS_TDC_CNT 20 +#define THRESH_025_DMS_NS_CNT 21 +#define THRESH_025_DMS_TDC_NS_CNT 278 +#else +#define THRESH_100_DMS_TDC_CNT 3 +#define THRESH_100_DMS_NS_CNT 35 +#define THRESH_100_DMS_TDC_NS_CNT 114 +#define THRESH_075_DMS_TDC_CNT 6 +#define THRESH_075_DMS_NS_CNT 37 +#define THRESH_075_DMS_TDC_NS_CNT 130 +#define THRESH_050_DMS_TDC_CNT 12 +#define THRESH_050_DMS_NS_CNT 55 +#define THRESH_050_DMS_TDC_NS_CNT 227 +#define THRESH_025_DMS_TDC_CNT 10 +#define THRESH_025_DMS_NS_CNT 138 +#define THRESH_025_DMS_TDC_NS_CNT 431 +#endif +#else +#define FAC1_FADEOUT 0.2 +#define FAC2_FADEOUT 1.5 +#define FAC3_FADEOUT 1.75 +#endif +#define REL_PITCH_THRESH 0.36 +#define PLC_LONGTERM_ANALYSIS_MS 200 /* Analysis window 2000 ms / 10 ms */ + +#define PLC_LONGTERM_ANALYSIS_STARTUP_FILL 0.5f /* required buffer fill amount, set to 0.0 to not require any fill at all */ + + +#endif + +/* Precision Defines */ +#define LC3_FABS(x) (fabsf(x)) +#define LC3_POW(x, y) (powf(x, y)) +#define LC3_LOGTEN(x) (log10f(x)) +#define LC3_LOGTWO(x) (log2f(x)) +#define LC3_COS(x) (cos(x)) +#define LC3_SIN(x) (sin(x)) +#define LC3_SQRT(x) (sqrtf(x)) +#define LC3_EXP(x) (expf(x)) + +#define MAX_BR 320000 /* 400 * 800 */ +#define MIN_BR_100DMS 16000 /* 20 * 800 * 100/100 */ +#define MIN_BR_025DMS 64000 /* 20 * 800 * 100/ 25 */ +#define MIN_BR_050DMS 32000 /* 20 * 800 * 100/ 50 */ +#define MAX_BR_050DMS_NB 260800 /* 163 * 800 * 100/ 50 */ +#define MAX_BR_100DMS_NB 114400 /* for 100ms at 8kHz */ +#define MAX_BR_100DMS_WB 221600 /* for 100ms at 16kHz */ +#define MAX_BR_100DMS_SSWB 314400 /* for 100ms at 24kHz */ + +#ifdef CR8_G_ADD_75MS +#define MIN_BR_075DMS_48KHZ_HR ((int)124800/ 800/2)* 800 +#define MIN_BR_075DMS_96KHZ_HR ((int)149600/ 800/2)* 800 +#define MIN_BR_075DMS 21334 /* ceil( 20 * 800 * 100/ 75) */ +#define MAX_BR_075DMS 426667 /* ceil(400 * 800 * 100/ 75) */ +#define MAX_BR_075DMS_NB 152534 /* ceil(143 * 800 * 100/ 75) */ +#define MAX_BR_075DMS_WB 295467 /* ceil(277 * 800 * 100/ 75) */ +#define MAX_BR_075DMS_SSWB 419200 /* ceil(393 * 800 * 100/ 75) */ +#endif +#define CR8_E_TONE_DETECTOR /* Tone detector for hrmode to deactivate TNS - improves SNR and THD+N */ + +typedef int32_t LC3_INT32; + +#if defined(__xtensa__) +#define ALIGNMENT_BALLOC 4 +#define ALIGNMENT_BALLOC_RED 3 +#else +#define ALIGNMENT_BALLOC 8 +#define ALIGNMENT_BALLOC_RED 7 +#endif + +#ifndef CR8_A_PLC_FADEOUT_TUNING +#define PLC2_FADEOUT_IN_MS 30 +#endif + +#ifdef CR8_A_PLC_FADEOUT_TUNING +/* PLC2/PhEcu fading settings */ +/* PLC2/PHEcu muting Table setup settings */ +#define PLC2_FADEOUT_IN_MS_MIN 30 /* Table min */ +#define PLC2_FADEOUT_IN_MS_MAX 140 /* Table max */ +#define PLC2_FADEOUT_RES 10 /* 10 ms steps used in fadeout constant tables */ + +/* current active settings */ +#define PLC2_FADEOUT_IN_MS 30 /* 30 P800 fadeout optimized */ +#define PLC2_FADEOUT_LONG_IN_MS 120 /* 120 MUSHRA, && stable tonal fadeout optimized */ + +#endif + +#define PHECU_FRES 62.5 +#define PHECU_C_JACOB 1.1429 +#define MAX_LGW 9 /* LGW48K + 1 !! */ +#define QUOT_LPR_LTR 4 +#define MAX_PLC_LPROT ((512 * 48) / 32) +#define MAX_PLC_NPLOCS ((MAX_PLC_LPROT / 4) + 1) +#define MAX_PLC_LMSPEC ((MAX_PLC_LPROT / 2) + 1) +#define MAX_PLC_LMEM (400) /* "only" up to 20kHz (400 MDCT bins at 10 ms) at 48 kHz supported by PhEcu */ + +#define POS_ONE_Q15 (32767.0 / 32768.0) +#define PHECU_LTOT_MIN_MAN 1 /* lowest possible mantissa energy value */ +#define PHECU_LTOT_MIN_EXP -61 /* L_tot = PHECU_LTOT_MIN_MAN*2^(PHECU_LTOT_MIN_EXP-31) */ +#define PHECU_LTOT_MIN +#define PHECU_GRP_SHAPE_INIT 0 /* BASOP Q15 */ +#define PHECU_ENV_STAB_LOCAL POS_ONE_Q15 +#define PHECU_DELTA_CORR 5 +#define PHECU_PFIND_SENS 0.93 +#define PHECU_LA 0 + +#define LC3_ROUND(x) (roundf(x)) +#define LC3_FLOOR(x) (floorf(x)) + +#define LC3_CONST_POW_2_16 65536 +#define LC3_CONST_POW_2_M16 1.525878906250000e-05 +#define LC3_CONST_POW_2_100 1.267650600228229e+30 + +#define MAX_LEN_PCM_PLC (MAX_PITCH + MAX_LEN) +#define MAX_PITCH CEILING((MAX_PITCH_12K8 * MAX_LEN * 100), 12800) +#define TDC_L_FIR_HP 11 +#define PLC3_HPBLENDTHROTTLE 30 /* higher numbers increase throttled blending from hp filtered to unfiltered uv excitation (0 is no throttle) */ + +#ifdef CR9_I_INC_TDC_FADEOUT_LEN +#define PLC_FADEOUT_TYPE_1_IN_MS 200 +#endif +#define PLC_FADEOUT_IN_MS 60 /* fade-out to zero in ms for TD-PLC and NS, minimum value is 20 */ +#define PLC4_TRANSIT_START_IN_MS 20 /* begin of transition time for noise substitution for voiced signals */ +#define PLC4_TRANSIT_END_IN_MS PLC_FADEOUT_IN_MS /* end of transition time for noise substitution */ +#define PLC34_ATTEN_FAC_100 0.5000 /* attenuation factor for NS and TDC @ 10 ms*/ +#ifdef CR8_G_ADD_75MS +#define PLC34_ATTEN_FAC_075 0.5946 /* attenuation factor for NS and TDC @ 7.5 ms */ +#endif +#define PLC34_ATTEN_FAC_050 0.7071 /* attenuation factor for NS and TDC @ 5.0 ms*/ +#define PLC34_ATTEN_FAC_025 0.8409 /* attenuation factor for NS and TDC @ 2.5 ms*/ + +#define FEC_SLOT_BYTES_MIN 40 +#define FEC_SLOT_BYTES_MAX 400 + +#define LC3_CONST_POW_2_M15 3.051757812500000e-05 +#define LC3_CONST_POW_2_23 8388608 +#define LC3_CONST_POW_2_23_NEG -8388608 +#define LC3_CONST_POW_2_23_RED 8388607 + +#define LC3_CONST_POW_2_100 1.267650600228229e+30 + +/* G192 bitstream writing/reading */ +#define G192_REDUNDANCY_FRAME 0x6B22 +#define G192_GOOD_FRAME 0x6B21 +#define G192_BAD_FRAME 0x6B20 +#define G192_ZERO 0x007F +#define G192_ONE 0x0081 +#define READ_G192FER /* Allow C executable to also read G192 formatted FER files */ + +#ifdef DEBUG +#ifdef READ_G192FER +#define READ_G192_FER_BYTE /* Allow C executable to also read G192 byte formatted FER files 0x20=BAD , 0x21=Good */ +#endif +#endif + + +#define LC3_EPS (1.1e-7f) + +#define M_PI 3.14159265358979323846 + +/* FUNCTION MACROS */ +#define CEILING(x, y) (((x) + (y)-1) / (y)) + + +#ifdef CR8_A_PLC_FADEOUT_TUNING +#define FRAME2FS_IDX_10MS(x) (x<500 ? (x/100) : 5) /* 80 -> 0, 160 -> 1, 240 -> 2, 320 -> 3, 480 -> 4 , 960 -> 5*/ +#define FS2FS_IDX(x) ((x) == 96000 ? 5 : (x) / 10000) /* 8000 -> 0, 16000 -> 1, 24000 -> 2, 32000 -> 3, 48000 -> 4, 96000 -> 5 */ +#else +#define FRAME2FS_IDX(x) (x / 100) /* 80 -> 0, 160 -> 1, 240 -> 2, 320 -> 3, 480 -> 4*/ +#define FS2FS_IDX(x) \ + (x / 10000) /* 8000 -> 0, 16000 -> 1, 24000 -> 2, 32000 -> 3, 48000 -> 4 \ + */ +#endif +#define UNUSED(x) (void)(x) /* silence unused parameter warning */ +#define MAX(a, b) ((a) > (b) ? (a) : (b)) +#define MIN(a, b) ((a) < (b) ? (a) : (b)) +#define STATIC_ASSERTS(cond, s) typedef char assert_##s[(cond) ? 1 : -1] +#define STATIC_ASSERTI(cond, i) STATIC_ASSERTS(cond, i) +#define STATIC_ASSERT(cond) STATIC_ASSERTI(cond, __LINE__) + +/* For dynamic memory calculations */ +#define CODEC_FS(fs) ((fs) == 44100 ? 48000 : (fs)) +#define DYN_MAX_LEN(fs) MAX(CODEC_FS(fs) / 100, 160) +#define DYN_MAX_LEN_EXT(fs) MAX(CODEC_FS(fs) / 100, 160) /* extension to length 160 for NB(fs=8000) */ +#define DYN_MAX_MDCT_LEN(fs) (DYN_MAX_LEN(fs) - (180 * DYN_MAX_LEN(fs) / 480)) + +/* OPTIONS */ + +#define MAX_LEN_NR 480 +#define MAX_SR 96000 +#define EXT_RES_ITER_MAX 20 +#define MAX_BW_BANDS_NUMBER 6 +#define MAX_LEN MAX_SR/100 /* = 10ms at 96kHz */ +#define MAX_RESBITS 5000 +#define MAX_RESBITS_LEN ((MAX_RESBITS + 7)/8) + +#define MAX_CHANNELS 2 +#define MIN_NBYTES 20 /* 100dms: 16 kbps at !=44.1kHz, 14.7kbps at 44.1kHz + 50dms: 32 kbps at !=44.1kHz, 29.4kbps at 44.1kHz + 25dms: 64 kbps at !=44.1kHz, 58.8kbps at 44.1kHz */ +#define MAX_NBYTES_025 100 /* any dms: 320 kbps at !=44.1kHz, 294 kbps at 44.1kHz */ +#define MAX_NBYTES_050 200 /* any dms: 320 kbps at !=44.1kHz, 294 kbps at 44.1kHz */ +#define MAX_NBYTES_100 400 /* any dms: 320 kbps at !=44.1kHz, 294 kbps at 44.1kHz */ + +#ifdef ENABLE_HR_MODE_FL +#define MIN_BR_25MS_48KHZ_HR ((int)172800/3200/2)*3200 +#define MIN_BR_25MS_96KHZ_HR ((int)198400/3200/2)*3200 +#define MIN_BR_50MS_48KHZ_HR ((int)148800/1600/2)*1600 +#define MIN_BR_50MS_96KHZ_HR ((int)174400/1600/2)*1600 +#define MIN_BR_100MS_48KHZ_HR ((int)124800/800/2)*800 +#define MIN_BR_100MS_96KHZ_HR ((int)149600/800/2)*800 +#endif /* ENABLE_HR_MODE */ +#define MAX_NBYTES2 625 +#define BYTESBUFSIZE (MAX_NBYTES2 * MAX_CHANNELS) +#define MAX_BW_BIN 400 +#if MAX_BW_BIN > MAX_LEN +#define MAX_BW MAX_LEN +#else +#define MAX_BW MAX_BW_BIN +#endif + +#ifdef ENABLE_HR_MODE_FL +#define MAX_BW_HR 960 +#endif + +/* SCF */ +#define M 16 +#define MAX_BANDS_NUMBER 64 +#define MAX_BANDS_NUMBER_PLC 80 +#define PVQ_MAX_VEC_SIZE M + +/* PVQ VQ setup */ +#define SCF_MAX_PARAM \ + 7 /* (L+H) + submode_MSB +gain+(Ia_leads+Ia_mpvq)+(Ib_joint_mpvq), \ + submode-LSB */ + +/* RESIDUAL CODING */ +#define NPRM_RESQ 5 * MAX_LEN + +/* MDCT */ +#define MDCT_MEM_LEN_MAX (MAX_LEN - ((180 * MAX_LEN) / 480)) + +/* TNS */ +#define TNS_NUMFILTERS_MAX 2 +#define MAXLAG 8 + +/* OLPA/LTPF */ +#define LEN_12K8 128 +#define LEN_6K4 64 +#define MIN_PITCH_6K4 17 +#define MAX_PITCH_6K4 114 +#define RANGE_PITCH_6K4 98 +#define MIN_PITCH_12K8 32 +#define MAX_PITCH_12K8 228 +#define RES2_PITCH_12K8 157 +#define RES4_PITCH_12K8 127 +#define LTPF_MEMIN_LEN (MAX_PITCH_12K8 + 4) + +/* Advanced PLC */ + + + +/* some configurations leave empty translation units. */ +extern int fix_empty_translation_unit_warning; + +#endif diff --git a/lib_lc3plus/detect_cutoff_warped.c b/lib_lc3plus/detect_cutoff_warped.c new file mode 100644 index 0000000000000000000000000000000000000000..21b73e8063c0fd07450046362a1a02008b279477 --- /dev/null +++ b/lib_lc3plus/detect_cutoff_warped.c @@ -0,0 +1,92 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.3 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + + +#include "options.h" +#include "wmc_auto.h" +#include "functions.h" + +void processDetectCutoffWarped_fl(LC3_FLOAT* d2, LC3_INT fs_idx, LC3_INT frame_dms, LC3_INT* bw_idx) +{ + const LC3_INT *warp_idx_start, *warp_idx_stop; + LC3_INT counter, brickwall = 0, i, stop, dist; + LC3_FLOAT d2_mean, d2_sum, e_diff, thr; + const LC3_INT *bw_dist; + + warp_idx_start = BW_warp_idx_start_all[fs_idx - 1]; + warp_idx_stop = BW_warp_idx_stop_all[fs_idx - 1]; + + switch (frame_dms) + { + case 25: + warp_idx_start = BW_warp_idx_start_all_2_5ms[fs_idx - 1]; + warp_idx_stop = BW_warp_idx_stop_all_2_5ms[fs_idx - 1]; + bw_dist = brickwall_dist; + break; + case 50: + warp_idx_start = BW_warp_idx_start_all_5ms[fs_idx - 1]; + warp_idx_stop = BW_warp_idx_stop_all_5ms[fs_idx - 1]; + bw_dist = brickwall_dist; + break; +#ifdef CR8_G_ADD_75MS + case 75: + warp_idx_start = BW_warp_idx_start_all_7_5ms[fs_idx - 1]; + warp_idx_stop = BW_warp_idx_stop_all_7_5ms[fs_idx - 1]; + bw_dist = brickwall_dist_7_5ms; + break; +#endif + case 100: + warp_idx_start = BW_warp_idx_start_all[fs_idx - 1]; + warp_idx_stop = BW_warp_idx_stop_all[fs_idx - 1]; + bw_dist = brickwall_dist; + break; + } + + counter = fs_idx; + + d2_sum = sum_vec(&d2[warp_idx_start[counter - 1]], warp_idx_stop[counter - 1] - warp_idx_start[counter - 1] + 1); + + d2_mean = d2_sum / (warp_idx_stop[counter - 1] - warp_idx_start[counter - 1] + 1); + + while (d2_mean < threshold_quiet[counter - 1]) { + d2_sum = 0; + counter--; + if (counter == 0) { + break; + } + + /* calculate mean energy per band */ + d2_sum = + sum_vec(&d2[warp_idx_start[counter - 1]], warp_idx_stop[counter - 1] - warp_idx_start[counter - 1] + 1); + + d2_mean = d2_sum / (warp_idx_stop[counter - 1] - warp_idx_start[counter - 1] + 1); + } + + *bw_idx = counter; + + /* check if energy difference between bands is present */ + if (*bw_idx < fs_idx) { + thr = (LC3_FLOAT)threshold_brickwall[counter]; + stop = warp_idx_start[counter]; + dist = bw_dist[counter]; + + for (i = stop; i >= stop - dist; i--) { + e_diff = 10.0 * LC3_LOGTEN(d2[i - dist + 1] + FLT_EPSILON) - 10.0 * LC3_LOGTEN(d2[i + 1] + FLT_EPSILON); + + if (e_diff > thr) { + brickwall = 1; + break; + } + } + + if (brickwall == 0) { + *bw_idx = fs_idx; + } + } +} diff --git a/lib_lc3plus/enc_entropy.c b/lib_lc3plus/enc_entropy.c new file mode 100644 index 0000000000000000000000000000000000000000..dc285088a40a509c87bf251872fb6a1308f86da1 --- /dev/null +++ b/lib_lc3plus/enc_entropy.c @@ -0,0 +1,128 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.3 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + + +#include "options.h" +#include "wmc_auto.h" +#include "functions.h" + +static const LC3_INT gainMSBbits[4] = {1, 1, 2, 2}; +static const LC3_INT gainLSBbits[4] = {0, 1, 0, 1}; + +void processEncoderEntropy_fl(LC3_UINT8* bytes, LC3_INT* bp_side, LC3_INT* mask_side, LC3_INT numbytes, LC3_INT bw_cutoff_bits, + LC3_INT bw_cutoff_idx, LC3_INT lastnz, LC3_INT N, LC3_INT lsbMode, LC3_INT gg_idx, LC3_INT num_tns_filters, + LC3_INT* tns_order, LC3_INT* ltpf_idx, LC3_INT* scf_idx, LC3_INT fac_ns_idx + , LC3_INT bfi_ext, LC3_INT fs_idx + ) +{ + LC3_UINT8* ptr; + LC3_INT i, submodeMSB, submodeLSB, tmp, gainMSB, gainLSB; + + + LC3_INT16 lastnzTrigger[5] = {63, 127, 127, 255, 255}; + + *bp_side = numbytes - 1; + *mask_side = 1; + ptr = bytes; + + /* Bandwidth */ + if (bw_cutoff_bits > 0) { + write_uint_backward_fl(ptr, bp_side, mask_side, bw_cutoff_idx, bw_cutoff_bits); + } + + /* Last non zero touple */ + if (bfi_ext == 1) { + write_uint_backward_fl(ptr, bp_side, mask_side, lastnzTrigger[fs_idx], ceil(LC3_LOGTWO(N >> 1))); + } + else + { + write_uint_backward_fl(ptr, bp_side, mask_side, lastnz / 2 - 1, ceil(LC3_LOGTWO(N >> 1))); + } + + /* LSB mode bit */ + write_bit_backward_fl(ptr, bp_side, mask_side, lsbMode); + + /* Global gain */ + write_uint_backward_fl(ptr, bp_side, mask_side, gg_idx, 8); + + /* TNS activation flag */ + for (i = 0; i < num_tns_filters; i++) { + write_bit_backward_fl(ptr, bp_side, mask_side, MIN(1, tns_order[i])); + } + + /* LTPF activation flag */ + write_bit_backward_fl(ptr, bp_side, mask_side, ltpf_idx[0]); + + /* SNS-VQ 1st stage */ + write_uint_backward_fl(ptr, bp_side, mask_side, scf_idx[0], 5); + write_uint_backward_fl(ptr, bp_side, mask_side, scf_idx[1], 5); + + /* SNS-VQ 2nd stage side-info (3-4 bits) */ + submodeMSB = scf_idx[2] / 2; + submodeLSB = scf_idx[2] & 1; + write_bit_backward_fl(ptr, bp_side, mask_side, submodeMSB); + gainMSB = scf_idx[3] >> (gainLSBbits[scf_idx[2]]); + gainLSB = scf_idx[3] & 1; + write_uint_backward_fl(ptr, bp_side, mask_side, gainMSB, gainMSBbits[scf_idx[2]]); + write_bit_backward_fl(ptr, bp_side, mask_side, scf_idx[4]); + + /* SNS-VQ 2nd stage MPVQ data (24-25 bits) */ + if (submodeMSB == 0) { + if (submodeLSB == 0) { + tmp = scf_idx[6] + 2; + } else { + tmp = gainLSB; + } + + tmp = tmp * 2390004 + scf_idx[5]; + write_uint_backward_fl(ptr, bp_side, mask_side, tmp, 25); + } else { + tmp = scf_idx[5]; + + if (submodeLSB != 0) { + tmp = 2 * tmp + gainLSB + 15158272; + } + + write_uint_backward_fl(ptr, bp_side, mask_side, tmp, 24); + } + + /* LTPF data */ + if (ltpf_idx[0] == 1) { + write_uint_backward_fl(ptr, bp_side, mask_side, ltpf_idx[1], 1); + write_uint_backward_fl(ptr, bp_side, mask_side, ltpf_idx[2], 9); + } + + /* Noise factor */ + write_uint_backward_fl(ptr, bp_side, mask_side, fac_ns_idx, 3); +} + +void write_uint_backward_fl(LC3_UINT8* ptr, LC3_INT* bp_side, LC3_INT* mask_side, LC3_INT val, LC3_INT numbits) +{ + LC3_INT k, bit; + + for (k = 0; k < numbits; k++) { + bit = val & 1; + write_bit_backward_fl(ptr, bp_side, mask_side, bit); + val = val >> 1; + } +} + +void write_bit_backward_fl(LC3_UINT8* ptr, LC3_INT* bp_side, LC3_INT* mask_side, LC3_INT bit) +{ + if (bit != 0) { + ptr[*bp_side] = ptr[*bp_side] | *mask_side; + } + + if (*mask_side == 128) { + *mask_side = 1; + *bp_side = *bp_side - 1; + } else { + *mask_side = *mask_side << 1; + } +} diff --git a/lib_lc3plus/enc_lc3_fl.c b/lib_lc3plus/enc_lc3_fl.c new file mode 100644 index 0000000000000000000000000000000000000000..56771ce5b84ab65e5d4e01edb9647a91604eba7c --- /dev/null +++ b/lib_lc3plus/enc_lc3_fl.c @@ -0,0 +1,283 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.3 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + + +#include "options.h" +#include "wmc_auto.h" +#include "functions.h" + +static void Enc_LC3PLUS_Channel_fl(LC3PLUS_Enc* encoder, int channel, int32_t* s_in, uint8_t* bytes, int bps +, LC3_INT32 bfi_ext +) +{ + EncSetup* h_EncSetup; + + LC3_INT s_12k8_len = 0, T0_out = 0, ltpfBits = 0, BW_cutoff_idx = 0, tns_numfilters = 0, quantizedGain = 0, + quantizedGainMin = 0, nbits = 0, nbits2 = 0, lastnz = 0, lsbMode = 0, gainChange = 0, bp_side = 0, + mask_side = 0, fac_ns_idx = 0, numResBits = 0, tns_order[2] = {0}, i = 0; + LC3_FLOAT normcorr = 0, gain = 0; + + + LC3_FLOAT d_fl[MAX_LEN] = {0}; + LC3_INT q_d[MAX_LEN] = {0}; + LC3_INT indexes[TNS_NUMFILTERS_MAX * MAXLAG] = {0}; + + h_EncSetup = encoder->channel_setup[channel]; + memset(bytes, 0, sizeof(uint8_t) * h_EncSetup->targetBytes); + + if (bps == 24) { + for (i = 0; i < encoder->frame_length; i++) { + int32_t tmp = ((int32_t*)s_in)[i]; + + if (tmp >= 0) + { + tmp = tmp & 0x007fffff; + } + else + { + tmp = tmp | (int32_t)0xff800000; + } + + h_EncSetup->s_in_scaled[i] = ((LC3_FLOAT) tmp / (float) LC3_POW(2, 8)); + } + } else if (bps == 16) { + for (i = 0; i < encoder->frame_length; i++) { + h_EncSetup->s_in_scaled[i] = (LC3_FLOAT)((int16_t*)s_in)[i]; + } + } + + /* MDCT */ + processMdct_fl(h_EncSetup->s_in_scaled, d_fl, &h_EncSetup->mdctStruct); + + /* 12.8 kHz resampler */ + process_resamp12k8_fl(h_EncSetup->s_in_scaled, encoder->frame_length, h_EncSetup->r12k8_mem_in, + encoder->r12k8_mem_in_len, h_EncSetup->r12k8_mem_50, h_EncSetup->r12k8_mem_out, + encoder->r12k8_mem_out_len, h_EncSetup->s_12k8, &s_12k8_len, encoder->fs_idx, + encoder->frame_dms, encoder->fs); + + /* Pitch estimation */ + processOlpa_fl(h_EncSetup->s_12k8, h_EncSetup->olpa_mem_s12k8, h_EncSetup->olpa_mem_s6k4, + &h_EncSetup->olpa_mem_pitch, +#ifdef CR9_F_PITCH_WIN_LEN_FIX + &h_EncSetup->pitch_flag, +#endif + &T0_out, &normcorr, s_12k8_len, encoder->frame_dms); + + /* LTPF encoder */ + process_ltpf_coder_fl(h_EncSetup->s_12k8, s_12k8_len + 1, h_EncSetup->ltpf_enable, T0_out, normcorr, + encoder->frame_dms, h_EncSetup->ltpf_mem_in, encoder->ltpf_mem_in_len, + &h_EncSetup->ltpf_mem_normcorr, &h_EncSetup->ltpf_mem_ltpf_on, + &h_EncSetup->ltpf_mem_pitch, h_EncSetup->ltpf_param, &h_EncSetup->ltpf_mem_mem_normcorr, + <pfBits +#ifdef CR9_K_REDUCE_NORM_CORR_TH + ,encoder->hrmode +#endif +); + + /* Attack detector */ + attack_detector_fl(h_EncSetup->s_in_scaled, encoder->frame_length, encoder->fs, &h_EncSetup->attdec_position, + &h_EncSetup->attdec_acc_energy, &h_EncSetup->attdec_detected, h_EncSetup->attdec_filter_mem, + h_EncSetup->attack_handling, encoder->attdec_nblocks, encoder->attdec_hangover_thresh); + + /* Per-band energy */ + processPerBandEnergy_fl(encoder->bands_number, encoder->bands_offset, encoder->hrmode, encoder->frame_dms, h_EncSetup->ener, d_fl); + /* Near Nyquist detector */ + processNearNyquistdetector_fl(&encoder->near_nyquist_flag, encoder->fs_idx, encoder->near_nyquist_index, encoder->bands_number, h_EncSetup->ener +#ifdef CR8_E_TONE_DETECTOR + , encoder->frame_dms, encoder->hrmode ); +#else + ); +#endif + /* Disable LTPF if nyquist detector triggers or -lfe mode is active*/ + if (encoder->near_nyquist_flag != 0 || h_EncSetup->lfe == 1) + { + h_EncSetup->ltpf_mem_ltpf_on = 0; + h_EncSetup->ltpf_param[1] = 0; + } + + /* Bandwidth cut-off detection */ + if (h_EncSetup->lfe == 0) { + /* No BW Cutoff for 8 kHz and 96 kHz. No detection if bandwidth controller is active */ + if (encoder->fs_idx > 0 && encoder->hrmode == 0 && encoder->bw_ctrl_active == 0) { + processDetectCutoffWarped_fl(h_EncSetup->ener, encoder->fs_idx, encoder->frame_dms, &BW_cutoff_idx); + } else { + BW_cutoff_idx = encoder->fs_idx; + } + } else { + BW_cutoff_idx = 0; + } + + processSnsComputeScf_fl(h_EncSetup->ener, encoder->bands_number, h_EncSetup->scf, + h_EncSetup->attdec_detected, encoder->sns_damping, encoder->attdec_damping, encoder->fs_idx); + + /* SNS Quantizer */ + process_snsQuantizesScf_Enc(h_EncSetup->scf, h_EncSetup->L_scf_idx, h_EncSetup->scf_q, h_EncSetup->dct2StructSNS); + + /* SNS Interpolation */ + processSnsInterpolateScf_fl(h_EncSetup->scf_q, 1, encoder->bands_number, h_EncSetup->int_scf); + + /* MDCT shaping */ + processMdctShaping_fl(d_fl, h_EncSetup->int_scf, encoder->bands_offset, encoder->bands_number); + + /* Bandwidth controller */ + if (encoder->bandwidth < encoder->fs / 2) { + process_cutoff_bandwidth(d_fl, encoder->yLen, encoder->bw_ctrl_cutoff_bin); + BW_cutoff_idx = MIN(BW_cutoff_idx, encoder->bw_index); + } + + /* TNS encoder */ + if (h_EncSetup->lfe == 0) + { + processTnsCoder_fl(d_fl, BW_cutoff_idx, encoder->cutoffBins[BW_cutoff_idx], encoder->fs, encoder->frame_length, + encoder->frame_dms, h_EncSetup->total_bits, tns_order, indexes, &tns_numfilters, + &(h_EncSetup->tns_bits) + , encoder->near_nyquist_flag + ); + } + else + { + tns_numfilters = 1; + tns_order[0] = 0; + h_EncSetup->tns_bits = tns_numfilters; + } + /* Global Gain Estimation */ + h_EncSetup->targetBitsQuant = h_EncSetup->targetBitsInit - (h_EncSetup->tns_bits + ltpfBits); + + if (h_EncSetup->targetBitsQuant < 0 && ltpfBits > 1) + { + /* Disable LTPF */ + h_EncSetup->ltpf_mem_ltpf_on = 0; + h_EncSetup->ltpf_param[1] = 0; + ltpfBits = 1; + h_EncSetup->targetBitsQuant = h_EncSetup->targetBitsInit - (h_EncSetup->tns_bits + ltpfBits); + } + + processEstimateGlobalGain_fl(d_fl, encoder->yLen, h_EncSetup->targetBitsQuant, &gain, &quantizedGain, + &quantizedGainMin, h_EncSetup->quantizedGainOff, &h_EncSetup->targetBitsOff, + &h_EncSetup->mem_targetBits, h_EncSetup->mem_specBits + , encoder->hrmode, h_EncSetup->regBits, encoder->frame_ms + + ); + + /* 1. Quantization */ + processQuantizeSpec_fl(d_fl, gain, q_d, encoder->yLen, h_EncSetup->total_bits, &nbits, &nbits2, encoder->fs, + &lastnz, h_EncSetup->codingdata, &lsbMode, -1, h_EncSetup->targetBitsQuant, encoder->hrmode + ); + + h_EncSetup->mem_specBits = nbits; + + /* Global Gain Adjustment */ + processAdjustGlobalGain_fl(&quantizedGain, quantizedGainMin, h_EncSetup->quantizedGainOff, &gain, + h_EncSetup->targetBitsQuant, h_EncSetup->mem_specBits, &gainChange, encoder->fs_idx + , encoder->hrmode, encoder->frame_dms + ); + + /* 2. Quantization */ + if (gainChange) { + processQuantizeSpec_fl(d_fl, gain, q_d, encoder->yLen, h_EncSetup->total_bits, &nbits, &nbits2, encoder->fs, + &lastnz, + h_EncSetup->codingdata, + &lsbMode, 0, h_EncSetup->targetBitsQuant + , encoder->hrmode + ); + } + + /* Noise factor */ + if (h_EncSetup->lfe == 0) + { + processNoiseFactor_fl(&fac_ns_idx, d_fl, q_d, gain, encoder->cutoffBins[BW_cutoff_idx], encoder->frame_dms, + h_EncSetup->targetBytes + ); + } + else + { + fac_ns_idx = 7; + } + /* Residual Coding */ + if (lsbMode == 0) { + processResidualCoding_fl(d_fl, q_d, gain, encoder->yLen, h_EncSetup->targetBitsQuant, nbits2, + h_EncSetup->resBits, &numResBits + , encoder->hrmode + ); + } else { + numResBits = 0; + } + + /* Entropy encoding */ + processEncoderEntropy_fl(bytes, &bp_side, &mask_side, h_EncSetup->targetBytes, encoder->BW_cutoff_bits, + BW_cutoff_idx, lastnz, encoder->yLen, lsbMode, quantizedGain, tns_numfilters, tns_order, + h_EncSetup->ltpf_param, h_EncSetup->L_scf_idx, fac_ns_idx + , bfi_ext, encoder->fs_idx + ); + + /* Artithmetic encoding */ + processAriEncoder_fl(bytes, bp_side, mask_side, q_d, tns_order, tns_numfilters, indexes, lastnz, + h_EncSetup->codingdata, + h_EncSetup->resBits, numResBits, lsbMode, h_EncSetup->targetBitsAri, + h_EncSetup->enable_lpc_weighting); + + if (encoder->combined_channel_coding == 0 && h_EncSetup->n_pc > 0) + { + LC3_INT32 xbuf[MAX_LEN] = {0}, nf_seed, tns_idx[M], zero_frame, nbits_residual, residualPresent, b_left, spec_inv_idx; + + memset(h_EncSetup->resBits, 0, sizeof(*(h_EncSetup->resBits)) * MAX_RESBITS_LEN); + + processAriDecoder_fl(bytes, bp_side, mask_side, encoder->yLen, encoder->fs_idx, h_EncSetup->enable_lpc_weighting, + tns_numfilters, lsbMode, lastnz, &bfi_ext, tns_order, fac_ns_idx, quantizedGain, + h_EncSetup->resBits, xbuf, &nf_seed, tns_idx, &zero_frame, h_EncSetup->targetBytes, &nbits_residual, + &residualPresent, encoder->frame_dms, h_EncSetup->n_pc, 0, h_EncSetup->total_bits >> 3, 1, &b_left, + &spec_inv_idx, encoder->hrmode); + + processReorderBitstream_fl(bytes, h_EncSetup->n_pccw, h_EncSetup->n_pc, b_left, h_EncSetup->targetBytes); + } + +} + +int Enc_LC3PLUS_fl(LC3PLUS_Enc* encoder, void** input, uint8_t* output, int bps +, LC3_INT32 bfi_ext +) +{ + int ch = 0, output_size = 0; + uint8_t* lc3buf = output; + + LC3_INT32 totalBytes; + LC3_INT32 output_size2, input_size; + + totalBytes = encoder->bitrate * encoder->frame_length / (8 * encoder->fs_in); + + for (ch = 0; ch < encoder->channels; ch++) + { + Enc_LC3PLUS_Channel_fl(encoder, ch, input[ch], lc3buf, bps, bfi_ext); + if (encoder->epmode && encoder->combined_channel_coding == 0) + { + output_size2 = totalBytes / encoder->channels + (ch < (totalBytes % encoder->channels)); + + fec_encoder(encoder->epmode, encoder->epmr, lc3buf, encoder->channel_setup[ch]->targetBytes, output_size2, + encoder->channel_setup[ch]->n_pccw); + + lc3buf += output_size2; + output_size += output_size2; + } + else + { + lc3buf += encoder->channel_setup[ch]->targetBytes; + output_size += encoder->channel_setup[ch]->targetBytes; + } + } + + if (encoder->epmode > 0 && encoder->combined_channel_coding) + { + input_size = output_size; + output_size = encoder->bitrate * encoder->frame_length / (8 * encoder->fs_in); + + fec_encoder(encoder->epmode, encoder->epmr, output, input_size, output_size, encoder->channel_setup[0]->n_pccw); + } + + return output_size; +} diff --git a/lib_lc3plus/estimate_global_gain.c b/lib_lc3plus/estimate_global_gain.c new file mode 100644 index 0000000000000000000000000000000000000000..2e69d239b2e0d7af87706afe197aa3c38458ffdf --- /dev/null +++ b/lib_lc3plus/estimate_global_gain.c @@ -0,0 +1,130 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.3 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + + +#include "options.h" +#include "wmc_auto.h" +#include "functions.h" + + +void processEstimateGlobalGain_fl(LC3_FLOAT x[], LC3_INT lg, LC3_INT nbitsSQ, LC3_FLOAT* gain, LC3_INT* quantizedGain, + LC3_INT* quantizedGainMin, LC3_INT quantizedGainOff, LC3_FLOAT* targetBitsOff, + LC3_INT* old_targetBits, LC3_INT old_specBits + , LC3_INT hrmode , LC3_INT regBits, LC3_FLOAT frame_ms +) +{ + + LC3_INT i, N, offset, j, iszero, fac; + LC3_FLOAT g_min, x_max, tmp, ind, ind_min, target, ener; + LC3_FLOAT en[MAX_LEN / 4]; + LC3_FLOAT reg_val = 4.656612873077393e-10; + + if (*old_targetBits < 0) { + *targetBitsOff = 0; + } else { + tmp = MIN(40, MAX(-40, *targetBitsOff + *old_targetBits - old_specBits)); + *targetBitsOff = 0.8 * *targetBitsOff + 0.2 * tmp; + } + + *old_targetBits = nbitsSQ; + nbitsSQ = nbitsSQ + round(*targetBitsOff); + + x_max = array_max_abs(x, lg); + + if (hrmode && regBits > 0) + { + LC3_FLOAT M0 = 1e-5, M1 = 1e-5, rB_offset; + LC3_FLOAT thresh = 2*frame_ms; + for (i = 0; i < lg; i++) + { + M0 += fabs(x[i]); + M1 += i*fabs(x[i]); + } + + rB_offset = 8 * (1 - MIN(M1/M0, thresh) / thresh); + reg_val = x_max * LC3_POW(2,-regBits - rB_offset); + } + + if (x_max < LC3_EPS) + { + ind_min = quantizedGainOff; + ind = 0; + *old_targetBits = -1; + } else { + if (hrmode == 1) { + g_min = x_max / (32768 * 256 - 2); + } else { + g_min = x_max / (32767 - 0.375); + } + /* Prevent positive rounding errors from LC3_LOG10 function */ + ind_min = 28.0 * LC3_LOGTEN(g_min); + + ind_min = ceil(ind_min + LC3_FABS(ind_min) * LC3_EPS); + + assert(LC3_POW(10, ind_min / 28.0) >= g_min); + assert(ind_min <= (255 + quantizedGainOff)); + + N = lg; + + j = 0; + for (i = 0; i < N; i = i + 4) { + tmp = x[i] * x[i]; + tmp += x[i + 1] * x[i + 1]; + tmp += x[i + 2] * x[i + 2]; + tmp += x[i + 3] * x[i + 3]; + en[j] = (28.0 / 20.0) * (7 + 10.0 * LC3_LOGTEN(tmp + reg_val)); + j++; + } + + target = (28.0 / 20.0) * (1.4) * nbitsSQ; + fac = 256; + offset = 255 + quantizedGainOff; + + for (i = 0; i < 8; i++) + { + fac = fac >> 1; + offset = offset - fac; + ener = 0; + iszero = 1; + + for (j = N / 4 - 1; j >= 0; j--) { + tmp = en[j] - offset; + + if (tmp < (7.0) * (28.0 / 20.0)) { + if (iszero == 0) { + ener = ener + (2.7) * (28.0 / 20.0); + } + } else { + if (tmp > (50.0) * (28.0 / 20.0)) { + ener = ener + 2.0 * tmp - (50.0) * (28.0 / 20.0); + } else { + ener = ener + tmp; + } + + iszero = 0; + } + } + + if (ener > target && iszero == 0) { + offset = offset + fac; + } + } + + if (offset < ind_min) { + *old_targetBits = -1; + } + + ind = MAX(ind_min, offset) - quantizedGainOff; + } + + *quantizedGainMin = ind_min; + *quantizedGain = ind; + + *gain = LC3_POW(10.0, ((ind + quantizedGainOff) / 28.0)); +} diff --git a/lib_lc3plus/fft/cfft.c b/lib_lc3plus/fft/cfft.c new file mode 100644 index 0000000000000000000000000000000000000000..d965163916db7e614bf9fa2f3881edb34323af08 --- /dev/null +++ b/lib_lc3plus/fft/cfft.c @@ -0,0 +1,427 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.3 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + + + +#include "options.h" +#include "wmc_auto.h" +#include "cfft.h" +#include "iisfft.h" /* for M_PIl */ +#include /* for abs() */ +#include + +#define MAX_FFT_SIZE 1024 +#define MAX_TRIGDATA_SIZE (MAX_FFT_SIZE / 2) + +/** + * \brief table aTrigData + + Generate table: aTrigData[i] = sin( pi * i / (2*MAX_TRIGDATA_SIZE) ); i = 0, ... MAX_TRIGDATA_SIZE + */ +static const LC3_FLOAT static_table[MAX_TRIGDATA_SIZE + 1] = { + 0.0000000000e+000, 3.0679567717e-003, 6.1358846724e-003, 9.2037543654e-003, 1.2271538377e-002, 1.5339205973e-002, + 1.8406730145e-002, 2.1474080160e-002, 2.4541229010e-002, 2.7608145028e-002, 3.0674804002e-002, 3.3741172403e-002, + 3.6807224154e-002, 3.9872925729e-002, 4.2938258499e-002, 4.6003181487e-002, 4.9067676067e-002, 5.2131704986e-002, + 5.5195245892e-002, 5.8258265257e-002, 6.1320737004e-002, 6.4382627606e-002, 6.7443922162e-002, 7.0504575968e-002, + 7.3564566672e-002, 7.6623864472e-002, 7.9682439566e-002, 8.2740262151e-002, 8.5797309875e-002, 8.8853552938e-002, + 9.1908954084e-002, 9.4963498414e-002, 9.8017141223e-002, 1.0106986016e-001, 1.0412163287e-001, 1.0717242211e-001, + 1.1022220552e-001, 1.1327095330e-001, 1.1631862819e-001, 1.1936521530e-001, 1.2241067737e-001, 1.2545497715e-001, + 1.2849810719e-001, 1.3154003024e-001, 1.3458070159e-001, 1.3762012124e-001, 1.4065824449e-001, 1.4369502664e-001, + 1.4673046768e-001, 1.4976453781e-001, 1.5279719234e-001, 1.5582840145e-001, 1.5885815024e-001, 1.6188639402e-001, + 1.6491311789e-001, 1.6793829203e-001, 1.7096188664e-001, 1.7398387194e-001, 1.7700421810e-001, 1.8002289534e-001, + 1.8303988874e-001, 1.8605515361e-001, 1.8906866014e-001, 1.9208039343e-001, 1.9509032369e-001, 1.9809840620e-001, + 2.0110464096e-001, 2.0410896838e-001, 2.0711137354e-001, 2.1011184156e-001, 2.1311031282e-001, 2.1610680223e-001, + 2.1910123527e-001, 2.2209362686e-001, 2.2508391738e-001, 2.2807207704e-001, 2.3105810583e-001, 2.3404195905e-001, + 2.3702360690e-001, 2.4000301957e-001, 2.4298018217e-001, 2.4595504999e-001, 2.4892760813e-001, 2.5189781189e-001, + 2.5486564636e-001, 2.5783109665e-001, 2.6079410315e-001, 2.6375466585e-001, 2.6671275496e-001, 2.6966831088e-001, + 2.7262136340e-001, 2.7557182312e-001, 2.7851969004e-001, 2.8146493435e-001, 2.8440752625e-001, 2.8734746575e-001, + 2.9028466344e-001, 2.9321914911e-001, 2.9615089297e-001, 2.9907983541e-001, 3.0200594664e-001, 3.0492922664e-001, + 3.0784964561e-001, 3.1076714396e-001, 3.1368175149e-001, 3.1659337878e-001, 3.1950202584e-001, 3.2240769267e-001, + 3.2531028986e-001, 3.2820984721e-001, 3.3110630512e-001, 3.3399966359e-001, 3.3688986301e-001, 3.3977687359e-001, + 3.4266072512e-001, 3.4554132819e-001, 3.4841868281e-001, 3.5129275918e-001, 3.5416352749e-001, 3.5703095794e-001, + 3.5989505053e-001, 3.6275571585e-001, 3.6561298370e-001, 3.6846682429e-001, 3.7131720781e-001, 3.7416407466e-001, + 3.7700742483e-001, 3.7984719872e-001, 3.8268342614e-001, 3.8551604748e-001, 3.8834503293e-001, 3.9117038250e-001, + 3.9399203658e-001, 3.9680999517e-001, 3.9962419868e-001, 4.0243464708e-001, 4.0524131060e-001, 4.0804415941e-001, + 4.1084316373e-001, 4.1363832355e-001, 4.1642954946e-001, 4.1921690106e-001, 4.2200025916e-001, 4.2477968335e-001, + 4.2755508423e-001, 4.3032649159e-001, 4.3309381604e-001, 4.3585708737e-001, 4.3861624599e-001, 4.4137126207e-001, + 4.4412213564e-001, 4.4686883688e-001, 4.4961133599e-001, 4.5234957337e-001, 4.5508357882e-001, 4.5781329274e-001, + 4.6053871512e-001, 4.6325978637e-001, 4.6597650647e-001, 4.6868881583e-001, 4.7139674425e-001, 4.7410020232e-001, + 4.7679921985e-001, 4.7949376702e-001, 4.8218378425e-001, 4.8486924171e-001, 4.8755016923e-001, 4.9022647738e-001, + 4.9289819598e-001, 4.9556526542e-001, 4.9822765589e-001, 5.0088536739e-001, 5.0353837013e-001, 5.0618666410e-001, + 5.0883013010e-001, 5.1146882772e-001, 5.1410275698e-001, 5.1673179865e-001, 5.1935601234e-001, 5.2197527885e-001, + 5.2458965778e-001, 5.2719914913e-001, 5.2980363369e-001, 5.3240311146e-001, 5.3499764204e-001, 5.3758704662e-001, + 5.4017144442e-001, 5.4275077581e-001, 5.4532498121e-001, 5.4789406061e-001, 5.5045795441e-001, 5.5301672220e-001, + 5.5557024479e-001, 5.5811852217e-001, 5.6066155434e-001, 5.6319934130e-001, 5.6573182344e-001, 5.6825894117e-001, + 5.7078075409e-001, 5.7329714298e-001, 5.7580816746e-001, 5.7831376791e-001, 5.8081394434e-001, 5.8330863714e-001, + 5.8579784632e-001, 5.8828157187e-001, 5.9075969458e-001, 5.9323227406e-001, 5.9569931030e-001, 5.9816068411e-001, + 6.0061645508e-001, 6.0306662321e-001, 6.0551106930e-001, 6.0794979334e-001, 6.1038279533e-001, 6.1281007528e-001, + 6.1523157358e-001, 6.1764729023e-001, 6.2005722523e-001, 6.2246125937e-001, 6.2485951185e-001, 6.2725180387e-001, + 6.2963825464e-001, 6.3201874495e-001, 6.3439327478e-001, 6.3676184416e-001, 6.3912445307e-001, 6.4148104191e-001, + 6.4383155107e-001, 6.4617604017e-001, 6.4851438999e-001, 6.5084666014e-001, 6.5317285061e-001, 6.5549284220e-001, + 6.5780669451e-001, 6.6011434793e-001, 6.6241580248e-001, 6.6471099854e-001, 6.6699993610e-001, 6.6928261518e-001, + 6.7155897617e-001, 6.7382901907e-001, 6.7609268427e-001, 6.7835003138e-001, 6.8060100079e-001, 6.8284553289e-001, + 6.8508368731e-001, 6.8731534481e-001, 6.8954056501e-001, 6.9175922871e-001, 6.9397145510e-001, 6.9617712498e-001, + 6.9837623835e-001, 7.0056879520e-001, 7.0275473595e-001, 7.0493406057e-001, 7.0710676908e-001, 7.0927280188e-001, + 7.1143221855e-001, 7.1358484030e-001, 7.1573084593e-001, 7.1787005663e-001, 7.2000253201e-001, 7.2212821245e-001, + 7.2424709797e-001, 7.2635912895e-001, 7.2846436501e-001, 7.3056274652e-001, 7.3265427351e-001, 7.3473888636e-001, + 7.3681658506e-001, 7.3888731003e-001, 7.4095112085e-001, 7.4300795794e-001, 7.4505776167e-001, 7.4710059166e-001, + 7.4913638830e-001, 7.5116515160e-001, 7.5318682194e-001, 7.5520139933e-001, 7.5720882416e-001, 7.5920921564e-001, + 7.6120239496e-001, 7.6318842173e-001, 7.6516723633e-001, 7.6713889837e-001, 7.6910334826e-001, 7.7106052637e-001, + 7.7301043272e-001, 7.7495312691e-001, 7.7688848972e-001, 7.7881652117e-001, 7.8073722124e-001, 7.8265058994e-001, + 7.8455656767e-001, 7.8645521402e-001, 7.8834640980e-001, 7.9023021460e-001, 7.9210656881e-001, 7.9397547245e-001, + 7.9583692551e-001, 7.9769086838e-001, 7.9953724146e-001, 8.0137616396e-001, 8.0320751667e-001, 8.0503135920e-001, + 8.0684757233e-001, 8.0865615606e-001, 8.1045717001e-001, 8.1225061417e-001, 8.1403630972e-001, 8.1581443548e-001, + 8.1758481264e-001, 8.1934750080e-001, 8.2110249996e-001, 8.2284981012e-001, 8.2458931208e-001, 8.2632106543e-001, + 8.2804507017e-001, 8.2976120710e-001, 8.3146959543e-001, 8.3317017555e-001, 8.3486288786e-001, 8.3654773235e-001, + 8.3822470903e-001, 8.3989381790e-001, 8.4155499935e-001, 8.4320825338e-001, 8.4485358000e-001, 8.4649091959e-001, + 8.4812033176e-001, 8.4974175692e-001, 8.5135519505e-001, 8.5296058655e-001, 8.5455799103e-001, 8.5614734888e-001, + 8.5772860050e-001, 8.5930180550e-001, 8.6086696386e-001, 8.6242395639e-001, 8.6397284269e-001, 8.6551362276e-001, + 8.6704623699e-001, 8.6857068539e-001, 8.7008696795e-001, 8.7159508467e-001, 8.7309497595e-001, 8.7458664179e-001, + 8.7607008219e-001, 8.7754529715e-001, 8.7901222706e-001, 8.8047087193e-001, 8.8192129135e-001, 8.8336336613e-001, + 8.8479709625e-001, 8.8622254133e-001, 8.8763964176e-001, 8.8904833794e-001, 8.9044874907e-001, 8.9184069633e-001, + 8.9322429895e-001, 8.9459949732e-001, 8.9596623182e-001, 8.9732456207e-001, 8.9867448807e-001, 9.0001589060e-001, + 9.0134882927e-001, 9.0267330408e-001, 9.0398931503e-001, 9.0529674292e-001, 9.0659570694e-001, 9.0788608789e-001, + 9.0916800499e-001, 9.1044127941e-001, 9.1170603037e-001, 9.1296219826e-001, 9.1420978308e-001, 9.1544872522e-001, + 9.1667908430e-001, 9.1790080070e-001, 9.1911387444e-001, 9.2031830549e-001, 9.2151403427e-001, 9.2270112038e-001, + 9.2387950420e-001, 9.2504924536e-001, 9.2621022463e-001, 9.2736250162e-001, 9.2850607634e-001, 9.2964088917e-001, + 9.3076694012e-001, 9.3188428879e-001, 9.3299281597e-001, 9.3409252167e-001, 9.3518352509e-001, 9.3626564741e-001, + 9.3733900785e-001, 9.3840354681e-001, 9.3945920467e-001, 9.4050604105e-001, 9.4154405594e-001, 9.4257318974e-001, + 9.4359344244e-001, 9.4460481405e-001, 9.4560730457e-001, 9.4660091400e-001, 9.4758558273e-001, 9.4856137037e-001, + 9.4952815771e-001, 9.5048606396e-001, 9.5143502951e-001, 9.5237499475e-001, 9.5330601931e-001, 9.5422810316e-001, + 9.5514118671e-001, 9.5604526997e-001, 9.5694035292e-001, 9.5782643557e-001, 9.5870345831e-001, 9.5957154036e-001, + 9.6043050289e-001, 9.6128046513e-001, 9.6212142706e-001, 9.6295326948e-001, 9.6377605200e-001, 9.6458977461e-001, + 9.6539443731e-001, 9.6618998051e-001, 9.6697646379e-001, 9.6775382757e-001, 9.6852207184e-001, 9.6928125620e-001, + 9.7003126144e-001, 9.7077214718e-001, 9.7150391340e-001, 9.7222650051e-001, 9.7293996811e-001, 9.7364425659e-001, + 9.7433936596e-001, 9.7502535582e-001, 9.7570210695e-001, 9.7636973858e-001, 9.7702813148e-001, 9.7767734528e-001, + 9.7831737995e-001, 9.7894817591e-001, 9.7956979275e-001, 9.8018211126e-001, 9.8078525066e-001, 9.8137921095e-001, + 9.8196387291e-001, 9.8253929615e-001, 9.8310548067e-001, 9.8366242647e-001, 9.8421007395e-001, 9.8474848270e-001, + 9.8527765274e-001, 9.8579752445e-001, 9.8630809784e-001, 9.8680937290e-001, 9.8730140924e-001, 9.8778414726e-001, + 9.8825758696e-001, 9.8872166872e-001, 9.8917651176e-001, 9.8962199688e-001, 9.9005818367e-001, 9.9048507214e-001, + 9.9090266228e-001, 9.9131083488e-001, 9.9170976877e-001, 9.9209928513e-001, 9.9247956276e-001, 9.9285042286e-001, + 9.9321192503e-001, 9.9356412888e-001, 9.9390697479e-001, 9.9424046278e-001, 9.9456459284e-001, 9.9487930536e-001, + 9.9518471956e-001, 9.9548077583e-001, 9.9576741457e-001, 9.9604469538e-001, 9.9631261826e-001, 9.9657112360e-001, + 9.9682027102e-001, 9.9706006050e-001, 9.9729043245e-001, 9.9751144648e-001, 9.9772304296e-001, 9.9792528152e-001, + 9.9811810255e-001, 9.9830156565e-001, 9.9847555161e-001, 9.9864023924e-001, 9.9879544973e-001, 9.9894130230e-001, + 9.9907773733e-001, 9.9920475483e-001, 9.9932235479e-001, 9.9943059683e-001, 9.9952942133e-001, 9.9961882830e-001, + 9.9969881773e-001, 9.9976938963e-001, 9.9983060360e-001, 9.9988234043e-001, 9.9992471933e-001, 9.9995762110e-001, + 9.9998116493e-001, 9.9999529123e-001, 1.0000000000e+000}; + +/** + * \brief scramble + The function sorts the complex vector re/im of length n from 'in-order' to 'bitreversed order'. + + * \param[i/o] re: real input + * \param[i/o] im: imag input + * \param[i ] n: size of fft + * \param[i ] s: stride of real and imag input + + * \return none + */ +static void scramble(LC3_FLOAT* re, LC3_FLOAT* im, LC3_INT n, LC3_INT s) +{ + LC3_FLOAT tmp; + LC3_INT m, k, j; + + for (m = 1, j = 0; m < (n - 1); m++) { + { + for (k = n >> 1; (!((j ^= k) & k)); k >>= 1) + ; + } + + if (j > m) { + tmp = re[s * m]; + re[s * m] = re[s * j]; + re[s * j] = tmp; + + tmp = im[s * m]; + im[s * m] = im[s * j]; + im[s * j] = tmp; + } + } +} + +/** + * \brief fft + The function performs a radix-2, decimation in time complex fft. The calculation takes place inplace. + The real and imaginary part can reside in separate buffers as well as interleaved in one buffer. The + stride length has to be set accordingly. + + * \param[i/o] re: real input / real output + * \param[i/o] im: imag input / imag output + * \param[i ] sizeOfFft: size of fft + * \param[i ] s: stride of real and imag input / output + + * \return none + */ +static void fft(const LC3_FLOAT* aTrigData, LC3_INT trigdata_size, LC3_FLOAT* re, LC3_FLOAT* im, LC3_INT sizeOfFft, + LC3_INT s) +{ + LC3_INT trigstep, i, ldm, n; + LC3_INT trigDataSize; + LC3_INT ldn = 0; + + trigDataSize = sizeOfFft / 2; + + while (sizeOfFft >>= 1) { + ldn++; + } + + n = 1 << ldn; + + scramble(re, im, n, s); + + /* 1+2 stage implemented as radix 4 */ + for (i = 0; i < n; i += 4) { + LC3_FLOAT a00, a01, a10, a11; + LC3_FLOAT a20, a21, a30, a31; + + a00 = re[s * (i + 0)] + re[s * (i + 1)]; + a10 = re[s * (i + 2)] + re[s * (i + 3)]; + a20 = im[s * (i + 0)] + im[s * (i + 1)]; + a30 = im[s * (i + 2)] + im[s * (i + 3)]; + + a01 = re[s * (i + 0)] - re[s * (i + 1)]; + a21 = re[s * (i + 2)] - re[s * (i + 3)]; + a31 = im[s * (i + 0)] - im[s * (i + 1)]; + a11 = im[s * (i + 2)] - im[s * (i + 3)]; + + re[s * (i + 0)] = a00 + a10; + re[s * (i + 2)] = a00 - a10; + im[s * (i + 0)] = a20 + a30; + im[s * (i + 2)] = a20 - a30; + re[s * (i + 1)] = a11 + a01; + re[s * (i + 3)] = a01 - a11; + im[s * (i + 1)] = a31 - a21; + im[s * (i + 3)] = a21 + a31; + } + + /* next stages implemented as radix 2 */ + for (ldm = 3; ldm <= ldn; ++ldm) { + const LC3_INT m = (1 << ldm); + const LC3_INT mh = (m >> 1); + LC3_INT j, r; + + trigstep = ((trigDataSize * 4) >> ldm) * trigdata_size / trigDataSize; + + for (j = 0; j < mh / 2; ++j) { + LC3_FLOAT c1, c2; + + c2 = aTrigData[j * trigstep]; + c1 = aTrigData[trigdata_size - j * trigstep]; + + for (r = 0; r < n; r += m) { + LC3_FLOAT vr, vi, ur, ui; + + LC3_INT t0 = r + j; + LC3_INT t1 = s * t0; + LC3_INT t2 = s * (t0 + mh); + + vr = re[t2] * c1 + im[t2] * c2; + vi = -re[t2] * c2 + im[t2] * c1; + + ur = re[t1]; + ui = im[t1]; + + re[t1] = re[t1] + vr; + im[t1] = im[t1] + vi; + + re[t2] = ur - vr; + im[t2] = ui - vi; + + t0 = r + j + mh / 2; + t1 = s * t0; + t2 = s * (t0 + mh); + + vr = -re[t2] * c2 + im[t2] * c1; + vi = -re[t2] * c1 - im[t2] * c2; + + ur = re[t1]; + ui = im[t1]; + re[t1] = re[t1] + vr; + im[t1] = im[t1] + vi; + + re[t2] = ur - vr; + im[t2] = ui - vi; + } + } + } +} + +/** + * \brief ifft + The function performs a radix-2, decimation in time complex inverse fft. The calculation takes place + inplace. The real and imaginary part can reside in separate buffers as well as interleaved in one buffer. + The stride length has to be set accordingly. + + * \param[i/o] re: real input / real output + * \param[i/o] im: imag input / imag output + * \param[i ] sizeOfFft: size of fft + * \param[i ] s: stride of real and imag input / output + + * \return none + */ +static void ifft(const LC3_FLOAT* aTrigData, LC3_INT trigdata_size, LC3_FLOAT* re, LC3_FLOAT* im, LC3_INT sizeOfFft, + LC3_INT s) +{ + LC3_INT trigstep, i, ldm, n; + LC3_INT trigDataSize; + LC3_INT ldn = 0; + + trigDataSize = sizeOfFft; + + while (sizeOfFft >>= 1) { + ldn++; + } + + n = 1 << ldn; + + scramble(re, im, n, s); + + /* 1+2 stage radix 4 */ + for (i = 0; i < n; i += 4) { + LC3_FLOAT a00, a01, a10, a11; + LC3_FLOAT a20, a21, a30, a31; + + a00 = re[s * (i + 0)] + re[s * (i + 1)]; + a10 = re[s * (i + 2)] + re[s * (i + 3)]; + a20 = im[s * (i + 0)] + im[s * (i + 1)]; + a30 = im[s * (i + 2)] + im[s * (i + 3)]; + + a01 = re[s * (i + 0)] - re[s * (i + 1)]; + a21 = re[s * (i + 2)] - re[s * (i + 3)]; + a31 = im[s * (i + 0)] - im[s * (i + 1)]; + a11 = im[s * (i + 2)] - im[s * (i + 3)]; + + re[s * (i + 0)] = a00 + a10; + re[s * (i + 2)] = a00 - a10; + im[s * (i + 0)] = a20 + a30; + im[s * (i + 2)] = a20 - a30; + + re[s * (i + 1)] = a01 - a11; + re[s * (i + 3)] = a01 + a11; + im[s * (i + 1)] = a31 + a21; + im[s * (i + 3)] = a31 - a21; + } + + for (ldm = 3; ldm <= ldn; ++ldm) { + const LC3_INT m = (1 << ldm); + const LC3_INT mh = (m >> 1); + LC3_INT j, r; + + trigstep = ((trigDataSize * 4) >> ldm) * trigdata_size / trigDataSize; + + for (j = 0; j < mh / 2; ++j) { + LC3_FLOAT c1, c2; + + c2 = aTrigData[j * trigstep]; + c1 = aTrigData[trigdata_size - j * trigstep]; + + for (r = 0; r < n; r += m) { + LC3_FLOAT vr, vi, ur, ui; + + LC3_INT t0 = r + j; + LC3_INT t1 = s * t0; + LC3_INT t2 = s * (t0 + mh); + + vr = re[t2] * c1 - im[t2] * c2; + vi = re[t2] * c2 + im[t2] * c1; + + ur = re[t1]; + ui = im[t1]; + + re[t1] = ur + vr; + im[t1] = ui + vi; + + re[t2] = ur - vr; + im[t2] = ui - vi; + + t0 = r + j + mh / 2; + t1 = s * t0; + t2 = s * (t0 + mh); + + vr = -re[t2] * c2 - im[t2] * c1; + vi = re[t2] * c1 - im[t2] * c2; + + ur = re[t1]; + ui = im[t1]; + + re[t1] = ur + vr; + im[t1] = ui + vi; + re[t2] = ur - vr; + im[t2] = ui - vi; + } + } + } +} + +/** + * \brief cfft + The function serves as wrapper for the forward and inverse fft. + + * \param[i/o] re: real input / real output + * \param[i/o] im: imag input / imag output + * \param[i ] sizeOfFft: size of fft + * \param[i ] s: stride of real and imag input / output + * \param[i ] iSign: forward fft: -1 / inverse fft: 1 + + * \return none + */ +void LC3_cfft(LC3_FLOAT* re, LC3_FLOAT* im, LC3_INT length, LC3_INT stride, LC3_INT sign) +{ + assert(abs(sign) == 1); + assert(CFFT_SUPPORT(length)); + + if (sign == -1) { + fft(static_table, MAX_TRIGDATA_SIZE, re, im, length, stride); + } else { + ifft(static_table, MAX_TRIGDATA_SIZE, re, im, length, stride); + } +} + +LC3_INT LC3_cfft_plan(Cfft* handle, LC3_INT length, LC3_INT sign) +{ + /* check if length is power of two */ + if (!CFFT_PLAN_SUPPORT(length) || (abs(sign) != 1)) + { + return 0; + } + + handle->len = length; + handle->sign = sign; + + if (length <= MAX_FFT_SIZE) { + handle->table = NULL; + } else { + LC3_INT i = 0; + handle->table = (LC3_FLOAT*)malloc((length / 2 + 1) * sizeof(LC3_FLOAT)); + for (i = 0; i < length / 2 + 1; i++) { + handle->table[i] = (LC3_FLOAT)LC3_SIN((LC3_FLOAT)M_PIl * i / length); + } + } + return 1; +} + +void LC3_cfft_apply(Cfft* handle, LC3_FLOAT* re, LC3_FLOAT* im, LC3_INT stride) +{ + if (handle->len <= MAX_FFT_SIZE) { + LC3_cfft(re, im, handle->len, stride, handle->sign); + } else if (handle->sign == -1) { + fft(handle->table, handle->len / 2, re, im, handle->len, stride); + } else { + ifft(handle->table, handle->len / 2, re, im, handle->len, stride); + } +} + +void LC3_cfft_free(Cfft* handle) +{ + if (handle->table) + { + free(handle->table); + } +} diff --git a/lib_lc3plus/fft/cfft.h b/lib_lc3plus/fft/cfft.h new file mode 100644 index 0000000000000000000000000000000000000000..18f1e80ad34893d157cad0b652b594cad3ce2fbe --- /dev/null +++ b/lib_lc3plus/fft/cfft.h @@ -0,0 +1,44 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.3 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + + + +#include "options.h" +#include "wmc_auto.h" +#include "../functions.h" + +#ifndef CFFT_H +#define CFFT_H + + +/* macro to check if cfft supports len */ +#define CFFT_IS_POWER_OF_TWO(n) ((n != 0) && ((n & (~n + 1)) == n)) +#define CFFT_SUPPORT(len) (len >= 4 && len <= 1024 && CFFT_IS_POWER_OF_TWO(len)) +#define CFFT_PLAN_SUPPORT(len) (len >= 4 && CFFT_IS_POWER_OF_TWO(len)) + +/** + * \brief fft_radix2 + The function serves as wrapper for the forward and inverse complex fft. + + * \param[i/o] re: real input / real output + * \param[i/o] im: imag input / imag output + * \param[i ] sizeOfFft: size of fft + * \param[i ] s: stride of real and imag input / output + * \param[i ] iSign: forward fft: -1 / inverse fft: 1 + + * \return none + */ + +void LC3_cfft(LC3_FLOAT* re, LC3_FLOAT* im, LC3_INT sizeOfFft, LC3_INT stride, LC3_INT sign); + +LC3_INT LC3_cfft_plan(Cfft* handle, LC3_INT length, LC3_INT sign); +void LC3_cfft_apply(Cfft* handle, LC3_FLOAT* re, LC3_FLOAT* im, LC3_INT stride); +void LC3_cfft_free(Cfft* handle); + +#endif /* FFT_RADIX2_H */ diff --git a/lib_lc3plus/fft/fft_15_16.h b/lib_lc3plus/fft/fft_15_16.h new file mode 100644 index 0000000000000000000000000000000000000000..c527f1bf5625413c85da3c5f7026f8ed71f66ea2 --- /dev/null +++ b/lib_lc3plus/fft/fft_15_16.h @@ -0,0 +1,401 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.3 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + + +/* guard against unindended includes */ +#ifndef INCLUDED_FROM_IISFFT_C +#error "this file must not be included" +#endif + +static void fft15(LC3_FLOAT* vec) +{ + LC3_FLOAT r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12, r13, r14, r15, r16, r17, i0, i1, i2, i3, i4, i5, + i6, i7, i8, i9, i10, i11, i12, i13, i14, i15, i16, i17, tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7, tmp8, + tmp9, tmp10, tmp11, tmp12, tmp13, tmp14, tmp15, tmp16, tmp17, tmp18, tmp19, tmp20, tmp21, tmp22, tmp23, tmp24, + tmp25, tmp26, tmp27, tmp28, tmp29; + + /* Pre-additions real part */ + r1 = vec[2] + vec[8]; + r2 = vec[2] - vec[8]; + r3 = vec[4] + vec[16]; + r4 = vec[4] - vec[16]; + r5 = vec[6] + vec[24]; + r6 = vec[6] - vec[24]; + r7 = vec[10] + vec[20]; + r8 = vec[10] - vec[20]; + r9 = vec[12] + vec[18]; + r10 = vec[12] - vec[18]; + r11 = vec[14] + vec[26]; + r12 = vec[14] - vec[26]; + r13 = vec[22] + vec[28]; + r14 = vec[22] - vec[28]; + + tmp2 = r1 + r3; + tmp4 = r1 - r3; + tmp6 = r2 + r14; + tmp8 = r2 - r14; + tmp10 = r4 + r12; + tmp12 = r4 - r12; + tmp14 = r5 + r9; + tmp16 = r5 - r9; + tmp18 = r11 + r13; + tmp20 = r11 - r13; + + /* Pre-additions imaginary part */ + i1 = vec[3] + vec[9]; + i2 = vec[3] - vec[9]; + i3 = vec[5] + vec[17]; + i4 = vec[5] - vec[17]; + i5 = vec[7] + vec[25]; + i6 = vec[7] - vec[25]; + i7 = vec[11] + vec[21]; + i8 = vec[11] - vec[21]; + i9 = vec[13] + vec[19]; + i10 = vec[13] - vec[19]; + i11 = vec[15] + vec[27]; + i12 = vec[15] - vec[27]; + i13 = vec[23] + vec[29]; + i14 = vec[23] - vec[29]; + + tmp3 = i1 + i3; + tmp5 = i1 - i3; + tmp7 = i2 + i14; + tmp9 = i2 - i14; + tmp11 = i4 + i12; + tmp13 = i4 - i12; + tmp15 = i5 + i9; + tmp17 = i5 - i9; + tmp19 = i11 + i13; + tmp21 = i11 - i13; + + /* Pre-additions and core multiplications */ + tmp28 = tmp4 + tmp20; + tmp29 = tmp5 + tmp21; + r4 = tmp2 + tmp18; + i4 = tmp3 + tmp19; + r3 = (r4 + tmp14) * (LC3_FLOAT)-1.25; + i3 = (i4 + tmp15) * (LC3_FLOAT)-1.25; + r2 = (tmp29 - i8) * (LC3_FLOAT)-8.660254037844387e-1; + i2 = (tmp28 - r8) * (LC3_FLOAT)8.660254037844387e-1; + r1 = r4 + r7; + i1 = i4 + i7; + r0 = r1 + vec[0] + tmp14; + i0 = i1 + vec[1] + tmp15; + r7 = tmp4 - tmp20; + i7 = tmp5 - tmp21; + r8 = (tmp3 - tmp19) * (LC3_FLOAT)-4.841229182759272e-1; + i8 = (tmp2 - tmp18) * (LC3_FLOAT)4.841229182759272e-1; + tmp0 = tmp6 + r10; + tmp1 = tmp7 + i10; + tmp2 = r6 - tmp10; + tmp3 = i6 - tmp11; + r10 = tmp7 * (LC3_FLOAT)-2.308262652881440; + i10 = tmp6 * (LC3_FLOAT)2.308262652881440; + r11 = tmp8 * (LC3_FLOAT)1.332676064001459; + i11 = tmp9 * (LC3_FLOAT)1.332676064001459; + r6 = (r7 - tmp16) * (LC3_FLOAT)5.590169943749475e-1; + i6 = (i7 - tmp17) * (LC3_FLOAT)5.590169943749475e-1; + r12 = (tmp1 + tmp3) * (LC3_FLOAT)5.877852522924733e-1; + i12 = (tmp0 + tmp2) * (LC3_FLOAT)-5.877852522924733e-1; + r13 = (tmp7 - tmp11) * (LC3_FLOAT)-8.816778784387098e-1; + i13 = (tmp6 - tmp10) * (LC3_FLOAT)8.816778784387098e-1; + r14 = (tmp8 + tmp12) * (LC3_FLOAT)5.090369604551274e-1; + i14 = (tmp9 + tmp13) * (LC3_FLOAT)5.090369604551274e-1; + r16 = tmp11 * (LC3_FLOAT)5.449068960040204e-1; + i16 = tmp10 * (LC3_FLOAT)-5.449068960040204e-1; + r17 = tmp12 * (LC3_FLOAT)3.146021430912046e-1; + i17 = tmp13 * (LC3_FLOAT)3.146021430912046e-1; + + r4 *= (LC3_FLOAT)1.875; + i4 *= (LC3_FLOAT)1.875; + r1 *= (LC3_FLOAT)-1.5; + i1 *= (LC3_FLOAT)-1.5; + r7 *= (LC3_FLOAT)-8.385254915624212e-1; + i7 *= (LC3_FLOAT)-8.385254915624212e-1; + r5 = tmp29 * (LC3_FLOAT)1.082531754730548; + i5 = tmp28 * (LC3_FLOAT)-1.082531754730548; + r9 = tmp1 * (LC3_FLOAT)1.538841768587627; + i9 = tmp0 * (LC3_FLOAT)-1.538841768587627; + r15 = tmp3 * (LC3_FLOAT)3.632712640026803e-1; + i15 = tmp2 * (LC3_FLOAT)-3.632712640026803e-1; + + /* Post-additions real part */ + tmp2 = r0 + r1; + tmp4 = r3 + r6; + tmp6 = r3 - r6; + tmp8 = r4 + r5; + tmp10 = r4 - r5; + tmp12 = r7 + r8; + tmp14 = r7 - r8; + tmp16 = r13 + r16; + tmp18 = r14 + r17; + tmp20 = r10 - r13; + tmp22 = r11 - r14; + tmp24 = r12 + r15; + tmp26 = r12 - r9; + + r1 = tmp2 + r2; + r2 = tmp2 - r2; + r3 = tmp4 + tmp26; + r4 = tmp4 - tmp26; + r5 = tmp6 + tmp24; + r6 = tmp6 - tmp24; + r7 = tmp16 + tmp18; + r8 = tmp16 - tmp18; + r9 = tmp20 - tmp22; + r10 = tmp20 + tmp22; + r11 = r1 + tmp8; + r12 = r2 + tmp10; + r13 = r11 - tmp12; + r14 = r12 - tmp14; + r15 = r12 + tmp14; + r16 = r11 + tmp12; + + /* Post-additions imaginary part */ + tmp3 = i0 + i1; + tmp5 = i3 + i6; + tmp7 = i3 - i6; + tmp9 = i4 + i5; + tmp11 = i4 - i5; + tmp13 = i7 + i8; + tmp15 = i7 - i8; + tmp17 = i13 + i16; + tmp19 = i14 + i17; + tmp21 = i10 - i13; + tmp23 = i11 - i14; + tmp25 = i12 + i15; + tmp27 = i12 - i9; + + i1 = tmp3 + i2; + i2 = tmp3 - i2; + i3 = tmp5 + tmp27; + i4 = tmp5 - tmp27; + i5 = tmp7 + tmp25; + i6 = tmp7 - tmp25; + i7 = tmp17 + tmp19; + i8 = tmp17 - tmp19; + i9 = tmp21 - tmp23; + i10 = tmp21 + tmp23; + i11 = i1 + tmp9; + i12 = i2 + tmp11; + i13 = i11 - tmp13; + i14 = i12 - tmp15; + i15 = i12 + tmp15; + i16 = i11 + tmp13; + + *vec++ = r0; + *vec++ = i0; + *vec++ = r13 + r5 + r7; + *vec++ = i13 + i5 + i7; + *vec++ = r15 + r3 - r9; + *vec++ = i15 + i3 - i9; + *vec++ = r0 + r4; + *vec++ = i0 + i4; + *vec++ = r13 + r6 - r7; + *vec++ = i13 + i6 - i7; + *vec++ = r2; + *vec++ = i2; + *vec++ = r0 + r5; + *vec++ = i0 + i5; + *vec++ = r16 + r3 - r10; + *vec++ = i16 + i3 - i10; + *vec++ = r15 + r4 + r9; + *vec++ = i15 + i4 + i9; + *vec++ = r0 + r6; + *vec++ = i0 + i6; + *vec++ = r1; + *vec++ = i1; + *vec++ = r14 + r5 + r8; + *vec++ = i14 + i5 + i8; + *vec++ = r0 + r3; + *vec++ = i0 + i3; + *vec++ = r16 + r4 + r10; + *vec++ = i16 + i4 + i10; + *vec++ = r14 + r6 - r8; + *vec++ = i14 + i6 - i8; +} + +static void fft16(LC3_FLOAT* vec) +{ + const LC3_FLOAT INV_SQRT2 = 7.071067811865475e-1; + const LC3_FLOAT COS_PI_DIV8 = 9.238795325112867e-1; + const LC3_FLOAT COS_3PI_DIV8 = 3.826834323650898e-1; + const LC3_FLOAT SQRT2PLUS1 = 2.414213562373095; + const LC3_FLOAT SQRT2MINUS1 = 4.142135623730952e-1; + + LC3_FLOAT temp10, temp11, temp12, temp13, temp14, temp15, temp16, temp17, temp18, temp19, temp110, temp111, temp112, + temp113, temp114, temp115, temp20, temp21, temp22, temp23, temp24, temp25, temp26, temp27, temp28, temp29, + temp210, temp211, temp212, temp213, temp214, temp215, vec0, vec1, vec2, vec3, vec4, vec5, vec6, vec7, vec8, + vec9, vec10, vec11, vec12, vec13, vec14, vec15; + + /* even */ + vec0 = vec[0] + vec[16]; + vec1 = vec[1] + vec[17]; + vec2 = vec[2] + vec[18]; + vec3 = vec[3] + vec[19]; + vec4 = vec[4] + vec[20]; + vec5 = vec[5] + vec[21]; + vec6 = vec[6] + vec[22]; + vec7 = vec[7] + vec[23]; + vec8 = vec[8] + vec[24]; + vec9 = vec[9] + vec[25]; + vec10 = vec[10] + vec[26]; + vec11 = vec[11] + vec[27]; + vec12 = vec[12] + vec[28]; + vec13 = vec[13] + vec[29]; + vec14 = vec[14] + vec[30]; + vec15 = vec[15] + vec[31]; + + /* Pre-additions */ + temp10 = vec0 + vec8; + temp12 = vec0 - vec8; + temp11 = vec1 + vec9; + temp13 = vec1 - vec9; + temp14 = vec2 + vec10; + temp16 = vec2 - vec10; + temp15 = vec3 + vec11; + temp17 = vec3 - vec11; + temp18 = vec4 + vec12; + temp110 = vec4 - vec12; + temp19 = vec5 + vec13; + temp111 = vec5 - vec13; + temp112 = vec6 + vec14; + temp114 = vec6 - vec14; + temp113 = vec7 + vec15; + temp115 = vec7 - vec15; + + /* Pre-additions and core multiplications */ + temp20 = temp10 + temp18; + temp24 = temp10 - temp18; + temp21 = temp11 + temp19; + temp25 = temp11 - temp19; + temp28 = temp12 - temp111; + temp210 = temp12 + temp111; + temp29 = temp13 + temp110; + temp211 = temp13 - temp110; + temp22 = temp14 + temp112; + temp27 = temp14 - temp112; + temp23 = temp15 + temp113; + temp26 = temp113 - temp15; + + temp11 = temp16 + temp114; + temp12 = temp16 - temp114; + temp10 = temp17 + temp115; + temp13 = temp17 - temp115; + temp212 = (temp10 + temp12) * INV_SQRT2; + temp214 = (temp10 - temp12) * INV_SQRT2; + temp213 = (temp13 - temp11) * INV_SQRT2; + temp215 = (temp11 + temp13) * -INV_SQRT2; + + /* odd */ + vec0 = vec[0] - vec[16]; + vec1 = vec[1] - vec[17]; + vec2 = vec[2] - vec[18]; + vec3 = vec[3] - vec[19]; + vec4 = vec[4] - vec[20]; + vec5 = vec[5] - vec[21]; + vec6 = vec[6] - vec[22]; + vec7 = vec[7] - vec[23]; + vec8 = vec[8] - vec[24]; + vec9 = vec[9] - vec[25]; + vec10 = vec[10] - vec[26]; + vec11 = vec[11] - vec[27]; + vec12 = vec[12] - vec[28]; + vec13 = vec[13] - vec[29]; + vec14 = vec[14] - vec[30]; + vec15 = vec[15] - vec[31]; + + /* Pre-additions and core multiplications */ + temp19 = (vec2 + vec14) * -COS_3PI_DIV8; + temp110 = (vec2 - vec14) * COS_PI_DIV8; + temp18 = (vec3 + vec15) * COS_3PI_DIV8; + temp111 = (vec3 - vec15) * COS_PI_DIV8; + temp15 = (vec4 + vec12) * -INV_SQRT2; + temp16 = (vec4 - vec12) * INV_SQRT2; + temp14 = (vec5 + vec13) * INV_SQRT2; + temp17 = (vec5 - vec13) * INV_SQRT2; + temp113 = (vec6 + vec10) * -COS_PI_DIV8; + temp114 = (vec6 - vec10) * COS_3PI_DIV8; + temp112 = (vec7 + vec11) * COS_PI_DIV8; + temp115 = (vec7 - vec11) * COS_3PI_DIV8; + + /* Core multiplications */ + vec2 = temp18 * SQRT2PLUS1 - temp112 * SQRT2MINUS1; + vec3 = temp19 * SQRT2PLUS1 - temp113 * SQRT2MINUS1; + vec4 = temp110 * SQRT2MINUS1 - temp114 * SQRT2PLUS1; + vec5 = temp111 * SQRT2MINUS1 - temp115 * SQRT2PLUS1; + + /* Post-additions */ + temp18 += temp112; + temp19 += temp113; + temp110 += temp114; + temp111 += temp115; + vec6 = vec0 + temp14; + vec10 = vec0 - temp14; + vec7 = vec1 + temp15; + vec11 = vec1 - temp15; + + vec12 = temp16 - vec9; + vec14 = temp16 + vec9; + vec13 = vec8 + temp17; + vec15 = vec8 - temp17; + + temp10 = vec6 - vec14; + temp12 = vec6 + vec14; + temp11 = vec7 + vec15; + temp13 = vec7 - vec15; + temp14 = vec10 + vec12; + temp16 = vec10 - vec12; + temp15 = vec11 + vec13; + temp17 = vec11 - vec13; + + vec10 = temp18 + temp110; + temp110 = temp18 - temp110; + vec11 = temp19 + temp111; + temp111 = temp19 - temp111; + + temp112 = vec2 + vec4; + temp114 = vec2 - vec4; + temp113 = vec3 + vec5; + temp115 = vec3 - vec5; + + /* Post-additions */ + *vec++ = temp20 + temp22; + *vec++ = temp21 + temp23; + *vec++ = temp12 + vec10; + *vec++ = temp13 + vec11; + *vec++ = temp210 + temp212; + *vec++ = temp211 + temp213; + *vec++ = temp10 + temp112; + *vec++ = temp11 + temp113; + *vec++ = temp24 - temp26; + *vec++ = temp25 - temp27; + *vec++ = temp16 + temp114; + *vec++ = temp17 + temp115; + *vec++ = temp28 + temp214; + *vec++ = temp29 + temp215; + *vec++ = temp14 + temp110; + *vec++ = temp15 + temp111; + *vec++ = temp20 - temp22; + *vec++ = temp21 - temp23; + *vec++ = temp12 - vec10; + *vec++ = temp13 - vec11; + *vec++ = temp210 - temp212; + *vec++ = temp211 - temp213; + *vec++ = temp10 - temp112; + *vec++ = temp11 - temp113; + *vec++ = temp24 + temp26; + *vec++ = temp25 + temp27; + *vec++ = temp16 - temp114; + *vec++ = temp17 - temp115; + *vec++ = temp28 - temp214; + *vec++ = temp29 - temp215; + *vec++ = temp14 - temp110; + *vec++ = temp15 - temp111; +} diff --git a/lib_lc3plus/fft/fft_240_480.h b/lib_lc3plus/fft/fft_240_480.h new file mode 100644 index 0000000000000000000000000000000000000000..18a0c8707a871b091ff60d0f59262e500d89ff9f --- /dev/null +++ b/lib_lc3plus/fft/fft_240_480.h @@ -0,0 +1,185 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.3 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + + +/* guard against unindended includes */ +#ifndef INCLUDED_FROM_IISFFT_C +#error "this file must not be included" +#endif + +static void fft240(LC3_FLOAT* in) +{ + const LC3_INT table1[240] = { + 0, 16, 32, 48, 64, 80, 96, 112, 128, 144, 160, 176, 192, 208, 224, 225, 1, 17, 33, 49, 65, 81, + 97, 113, 129, 145, 161, 177, 193, 209, 210, 226, 2, 18, 34, 50, 66, 82, 98, 114, 130, 146, 162, 178, + 194, 195, 211, 227, 3, 19, 35, 51, 67, 83, 99, 115, 131, 147, 163, 179, 180, 196, 212, 228, 4, 20, + 36, 52, 68, 84, 100, 116, 132, 148, 164, 165, 181, 197, 213, 229, 5, 21, 37, 53, 69, 85, 101, 117, + 133, 149, 150, 166, 182, 198, 214, 230, 6, 22, 38, 54, 70, 86, 102, 118, 134, 135, 151, 167, 183, 199, + 215, 231, 7, 23, 39, 55, 71, 87, 103, 119, 120, 136, 152, 168, 184, 200, 216, 232, 8, 24, 40, 56, + 72, 88, 104, 105, 121, 137, 153, 169, 185, 201, 217, 233, 9, 25, 41, 57, 73, 89, 90, 106, 122, 138, + 154, 170, 186, 202, 218, 234, 10, 26, 42, 58, 74, 75, 91, 107, 123, 139, 155, 171, 187, 203, 219, 235, + 11, 27, 43, 59, 60, 76, 92, 108, 124, 140, 156, 172, 188, 204, 220, 236, 12, 28, 44, 45, 61, 77, + 93, 109, 125, 141, 157, 173, 189, 205, 221, 237, 13, 29, 30, 46, 62, 78, 94, 110, 126, 142, 158, 174, + 190, 206, 222, 238, 14, 15, 31, 47, 63, 79, 95, 111, 127, 143, 159, 175, 191, 207, 223, 239}; + const LC3_INT table2[240] = { + 0, 16, 32, 48, 64, 80, 96, 112, 128, 144, 160, 176, 192, 208, 224, 15, 31, 47, 63, 79, 95, 111, + 127, 143, 159, 175, 191, 207, 223, 239, 30, 46, 62, 78, 94, 110, 126, 142, 158, 174, 190, 206, 222, 238, + 14, 45, 61, 77, 93, 109, 125, 141, 157, 173, 189, 205, 221, 237, 13, 29, 60, 76, 92, 108, 124, 140, + 156, 172, 188, 204, 220, 236, 12, 28, 44, 75, 91, 107, 123, 139, 155, 171, 187, 203, 219, 235, 11, 27, + 43, 59, 90, 106, 122, 138, 154, 170, 186, 202, 218, 234, 10, 26, 42, 58, 74, 105, 121, 137, 153, 169, + 185, 201, 217, 233, 9, 25, 41, 57, 73, 89, 120, 136, 152, 168, 184, 200, 216, 232, 8, 24, 40, 56, + 72, 88, 104, 135, 151, 167, 183, 199, 215, 231, 7, 23, 39, 55, 71, 87, 103, 119, 150, 166, 182, 198, + 214, 230, 6, 22, 38, 54, 70, 86, 102, 118, 134, 165, 181, 197, 213, 229, 5, 21, 37, 53, 69, 85, + 101, 117, 133, 149, 180, 196, 212, 228, 4, 20, 36, 52, 68, 84, 100, 116, 132, 148, 164, 195, 211, 227, + 3, 19, 35, 51, 67, 83, 99, 115, 131, 147, 163, 179, 210, 226, 2, 18, 34, 50, 66, 82, 98, 114, + 130, 146, 162, 178, 194, 225, 1, 17, 33, 49, 65, 81, 97, 113, 129, 145, 161, 177, 193, 209}; + + const LC3_INT L = 240; + const LC3_INT A = 15; + const LC3_INT B = 16; + const LC3_INT* idx1 = table1; + const LC3_INT* idx2 = table2; + + LC3_INT k, l; + LC3_FLOAT temp[32], out[480]; + + for (k = 0; k < A; k++) { + for (l = 0; l < B; l++) { + temp[2 * l] = in[2 * *idx1]; + temp[2 * l + 1] = in[2 * *idx1 + 1]; + idx1 += A; + } + + fft16(temp); /* 16-point FFT */ + idx1 -= L; + + for (l = 0; l < B; l++) { + in[2 * *idx1] = temp[2 * l]; + in[2 * *idx1 + 1] = temp[2 * l + 1]; + idx1 += A; + } + + idx1 -= L - 1; + } + + idx1 -= A; + + for (k = 0; k < B; k++) { + for (l = 0; l < A; l++) { + temp[2 * l] = in[2 * *idx1]; + temp[2 * l + 1] = in[2 * *idx1++ + 1]; + } + + fft15(temp); /* 15-point FFT */ + + for (l = 0; l < A; l++) { + out[2 * *idx2] = temp[2 * l]; + out[2 * *idx2++ + 1] = temp[2 * l + 1]; + } + } + + memmove(in, out, 2 * L * sizeof(LC3_FLOAT)); +} + +/* description in iis_fft.h */ +static void fft480(LC3_FLOAT* in) +{ + const LC3_INT table1[480] = { + 0, 256, 32, 288, 64, 320, 96, 352, 128, 384, 160, 416, 192, 448, 224, 225, 1, 257, 33, 289, 65, 321, + 97, 353, 129, 385, 161, 417, 193, 449, 450, 226, 2, 258, 34, 290, 66, 322, 98, 354, 130, 386, 162, 418, + 194, 195, 451, 227, 3, 259, 35, 291, 67, 323, 99, 355, 131, 387, 163, 419, 420, 196, 452, 228, 4, 260, + 36, 292, 68, 324, 100, 356, 132, 388, 164, 165, 421, 197, 453, 229, 5, 261, 37, 293, 69, 325, 101, 357, + 133, 389, 390, 166, 422, 198, 454, 230, 6, 262, 38, 294, 70, 326, 102, 358, 134, 135, 391, 167, 423, 199, + 455, 231, 7, 263, 39, 295, 71, 327, 103, 359, 360, 136, 392, 168, 424, 200, 456, 232, 8, 264, 40, 296, + 72, 328, 104, 105, 361, 137, 393, 169, 425, 201, 457, 233, 9, 265, 41, 297, 73, 329, 330, 106, 362, 138, + 394, 170, 426, 202, 458, 234, 10, 266, 42, 298, 74, 75, 331, 107, 363, 139, 395, 171, 427, 203, 459, 235, + 11, 267, 43, 299, 300, 76, 332, 108, 364, 140, 396, 172, 428, 204, 460, 236, 12, 268, 44, 45, 301, 77, + 333, 109, 365, 141, 397, 173, 429, 205, 461, 237, 13, 269, 270, 46, 302, 78, 334, 110, 366, 142, 398, 174, + 430, 206, 462, 238, 14, 15, 271, 47, 303, 79, 335, 111, 367, 143, 399, 175, 431, 207, 463, 239, 240, 16, + 272, 48, 304, 80, 336, 112, 368, 144, 400, 176, 432, 208, 464, 465, 241, 17, 273, 49, 305, 81, 337, 113, + 369, 145, 401, 177, 433, 209, 210, 466, 242, 18, 274, 50, 306, 82, 338, 114, 370, 146, 402, 178, 434, 435, + 211, 467, 243, 19, 275, 51, 307, 83, 339, 115, 371, 147, 403, 179, 180, 436, 212, 468, 244, 20, 276, 52, + 308, 84, 340, 116, 372, 148, 404, 405, 181, 437, 213, 469, 245, 21, 277, 53, 309, 85, 341, 117, 373, 149, + 150, 406, 182, 438, 214, 470, 246, 22, 278, 54, 310, 86, 342, 118, 374, 375, 151, 407, 183, 439, 215, 471, + 247, 23, 279, 55, 311, 87, 343, 119, 120, 376, 152, 408, 184, 440, 216, 472, 248, 24, 280, 56, 312, 88, + 344, 345, 121, 377, 153, 409, 185, 441, 217, 473, 249, 25, 281, 57, 313, 89, 90, 346, 122, 378, 154, 410, + 186, 442, 218, 474, 250, 26, 282, 58, 314, 315, 91, 347, 123, 379, 155, 411, 187, 443, 219, 475, 251, 27, + 283, 59, 60, 316, 92, 348, 124, 380, 156, 412, 188, 444, 220, 476, 252, 28, 284, 285, 61, 317, 93, 349, + 125, 381, 157, 413, 189, 445, 221, 477, 253, 29, 30, 286, 62, 318, 94, 350, 126, 382, 158, 414, 190, 446, + 222, 478, 254, 255, 31, 287, 63, 319, 95, 351, 127, 383, 159, 415, 191, 447, 223, 479}; + const LC3_INT table2[480] = { + 0, 32, 64, 96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448, 15, 47, 79, 111, 143, 175, 207, + 239, 271, 303, 335, 367, 399, 431, 463, 30, 62, 94, 126, 158, 190, 222, 254, 286, 318, 350, 382, 414, 446, + 478, 45, 77, 109, 141, 173, 205, 237, 269, 301, 333, 365, 397, 429, 461, 13, 60, 92, 124, 156, 188, 220, + 252, 284, 316, 348, 380, 412, 444, 476, 28, 75, 107, 139, 171, 203, 235, 267, 299, 331, 363, 395, 427, 459, + 11, 43, 90, 122, 154, 186, 218, 250, 282, 314, 346, 378, 410, 442, 474, 26, 58, 105, 137, 169, 201, 233, + 265, 297, 329, 361, 393, 425, 457, 9, 41, 73, 120, 152, 184, 216, 248, 280, 312, 344, 376, 408, 440, 472, + 24, 56, 88, 135, 167, 199, 231, 263, 295, 327, 359, 391, 423, 455, 7, 39, 71, 103, 150, 182, 214, 246, + 278, 310, 342, 374, 406, 438, 470, 22, 54, 86, 118, 165, 197, 229, 261, 293, 325, 357, 389, 421, 453, 5, + 37, 69, 101, 133, 180, 212, 244, 276, 308, 340, 372, 404, 436, 468, 20, 52, 84, 116, 148, 195, 227, 259, + 291, 323, 355, 387, 419, 451, 3, 35, 67, 99, 131, 163, 210, 242, 274, 306, 338, 370, 402, 434, 466, 18, + 50, 82, 114, 146, 178, 225, 257, 289, 321, 353, 385, 417, 449, 1, 33, 65, 97, 129, 161, 193, 240, 272, + 304, 336, 368, 400, 432, 464, 16, 48, 80, 112, 144, 176, 208, 255, 287, 319, 351, 383, 415, 447, 479, 31, + 63, 95, 127, 159, 191, 223, 270, 302, 334, 366, 398, 430, 462, 14, 46, 78, 110, 142, 174, 206, 238, 285, + 317, 349, 381, 413, 445, 477, 29, 61, 93, 125, 157, 189, 221, 253, 300, 332, 364, 396, 428, 460, 12, 44, + 76, 108, 140, 172, 204, 236, 268, 315, 347, 379, 411, 443, 475, 27, 59, 91, 123, 155, 187, 219, 251, 283, + 330, 362, 394, 426, 458, 10, 42, 74, 106, 138, 170, 202, 234, 266, 298, 345, 377, 409, 441, 473, 25, 57, + 89, 121, 153, 185, 217, 249, 281, 313, 360, 392, 424, 456, 8, 40, 72, 104, 136, 168, 200, 232, 264, 296, + 328, 375, 407, 439, 471, 23, 55, 87, 119, 151, 183, 215, 247, 279, 311, 343, 390, 422, 454, 6, 38, 70, + 102, 134, 166, 198, 230, 262, 294, 326, 358, 405, 437, 469, 21, 53, 85, 117, 149, 181, 213, 245, 277, 309, + 341, 373, 420, 452, 4, 36, 68, 100, 132, 164, 196, 228, 260, 292, 324, 356, 388, 435, 467, 19, 51, 83, + 115, 147, 179, 211, 243, 275, 307, 339, 371, 403, 450, 2, 34, 66, 98, 130, 162, 194, 226, 258, 290, 322, + 354, 386, 418, 465, 17, 49, 81, 113, 145, 177, 209, 241, 273, 305, 337, 369, 401, 433}; + + const LC3_INT L = 480; + const LC3_INT A = 15; + const LC3_INT B = 32; + const LC3_INT* idx1 = table1; + const LC3_INT* idx2 = table2; + + LC3_INT k, l; + LC3_FLOAT temp[64], out[960]; + + for (k = 0; k < A; k++) { + for (l = 0; l < B; l++) { + temp[2 * l] = in[2 * *idx1]; + temp[2 * l + 1] = in[2 * *idx1 + 1]; + idx1 += A; + } + + fft32(temp); /* 32-point FFT */ + idx1 -= L; + + for (l = 0; l < B; l++) { + in[2 * *idx1] = temp[2 * l]; + in[2 * *idx1 + 1] = temp[2 * l + 1]; + idx1 += A; + } + + idx1 -= L - 1; + } + + idx1 -= A; + + for (k = 0; k < B; k++) { + for (l = 0; l < A; l++) { + temp[2 * l] = in[2 * *idx1]; + temp[2 * l + 1] = in[2 * *idx1++ + 1]; + } + + fft15(temp); /* 15-point FFT */ + + for (l = 0; l < A; l++) { + out[2 * *idx2] = temp[2 * l]; + out[2 * *idx2++ + 1] = temp[2 * l + 1]; + } + } + + memmove(in, out, 2 * L * sizeof(LC3_FLOAT)); +} diff --git a/lib_lc3plus/fft/fft_2_9.h b/lib_lc3plus/fft/fft_2_9.h new file mode 100644 index 0000000000000000000000000000000000000000..55fe84f3b779057b5c65c63587b262cf20b7cf15 --- /dev/null +++ b/lib_lc3plus/fft/fft_2_9.h @@ -0,0 +1,278 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.3 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + + +/* guard against unindended includes */ +#ifndef INCLUDED_FROM_IISFFT_C +#error "this file must not be included" +#endif + +static __inline void butterfly(const LC3_FLOAT a, const LC3_FLOAT b, LC3_FLOAT* aPlusb, LC3_FLOAT* aMinusb) +{ + *aPlusb = a + b; + *aMinusb = a - b; +} + +static void fft2(LC3_FLOAT* vec) +{ + /* + 1.0000 1.0000 + 1.0000 -1.0000 + */ + LC3_FLOAT re1 = vec[0]; + LC3_FLOAT im1 = vec[1]; + LC3_FLOAT re2 = vec[2]; + LC3_FLOAT im2 = vec[3]; + + vec[0] = re1 + re2; + vec[1] = im1 + im2; + vec[2] = re1 - re2; + vec[3] = im1 - im2; +} + +static void fft3(LC3_FLOAT* vec) +{ + const LC3_FLOAT C31 = 0.5; /* cos(PI/3); sin(2*PI/3) */ + const LC3_FLOAT C32 = 0.866025403784439; /* cos(PI/3); sin(2*PI/3) */ + + LC3_FLOAT re1 = vec[0]; + LC3_FLOAT im1 = vec[1]; + LC3_FLOAT re2 = vec[2]; + LC3_FLOAT im2 = vec[3]; + LC3_FLOAT re3 = vec[4]; + LC3_FLOAT im3 = vec[5]; + /* + 1.0000 1.0000 1.0000 + C31 C32 + 1.0000 -0.5000 - 0.8660i -0.5000 + 0.8660i + 1.0000 -0.5000 + 0.8660i -0.5000 - 0.8660i + */ + LC3_FLOAT tmp1 = re2 + re3; + LC3_FLOAT tmp3 = im2 + im3; + LC3_FLOAT tmp2 = re2 - re3; + LC3_FLOAT tmp4 = im2 - im3; + + vec[0] = re1 + tmp1; + vec[1] = im1 + tmp3; + vec[2] = re1 - C31 * tmp1 + C32 * tmp4; + vec[4] = re1 - C31 * tmp1 - C32 * tmp4; + vec[3] = im1 - C32 * tmp2 - C31 * tmp3; + vec[5] = im1 + C32 * tmp2 - C31 * tmp3; +} + +static void fft4(LC3_FLOAT* vec) +{ + LC3_FLOAT temp0, temp1, temp2, temp3, temp4, temp5, temp6, temp7; + + /* Pre-additions */ + temp0 = vec[0] + vec[4]; + temp2 = vec[0] - vec[4]; + temp1 = vec[1] + vec[5]; + temp3 = vec[1] - vec[5]; + temp4 = vec[2] + vec[6]; + temp7 = vec[2] - vec[6]; + temp5 = vec[7] + vec[3]; + temp6 = vec[7] - vec[3]; + + /* Post-additions */ + vec[0] = temp0 + temp4; + vec[1] = temp1 + temp5; + vec[2] = temp2 - temp6; + vec[3] = temp3 - temp7; + vec[4] = temp0 - temp4; + vec[5] = temp1 - temp5; + vec[6] = temp2 + temp6; + vec[7] = temp3 + temp7; +} + +static void fft5(LC3_FLOAT* vec) +{ + const LC3_FLOAT C51 = 0.309016994374947; /* cos(2*PI/5); */ + const LC3_FLOAT C52 = 0.951056516295154; /* sin(2*PI/5); */ + const LC3_FLOAT C53 = 0.809016994374947; /* cos( PI/5); */ + const LC3_FLOAT C54 = 0.587785252292473; /* sin( PI/5); */ + + LC3_FLOAT re1, im1, re2, im2, re3, im3, re4, im4, re5, im5, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7, tmp8; + + re1 = vec[0]; + im1 = vec[1]; + re2 = vec[2]; + im2 = vec[3]; + re3 = vec[4]; + im3 = vec[5]; + re4 = vec[6]; + im4 = vec[7]; + re5 = vec[8]; + im5 = vec[9]; + /* + 1.0000 1.0000 1.0000 1.0000 1.0000 + C51 C52 C53 C54 + 1.0000 0.3090 - 0.9511i -0.8090 - 0.5878i -0.8090 + 0.5878i 0.3090 + 0.9511i + 1.0000 -0.8090 - 0.5878i 0.3090 + 0.9511i 0.3090 - 0.9511i -0.8090 + 0.5878i + 1.0000 -0.8090 + 0.5878i 0.3090 - 0.9511i 0.3090 + 0.9511i -0.8090 - 0.5878i + 1.0000 0.3090 + 0.9511i -0.8090 + 0.5878i -0.8090 - 0.5878i 0.3090 - 0.9511i + */ + tmp1 = re2 + re5; + tmp2 = re2 - re5; + tmp3 = im2 + im5; + tmp4 = im2 - im5; + tmp5 = re3 + re4; + tmp6 = re3 - re4; + tmp7 = im3 + im4; + tmp8 = im3 - im4; + + vec[0] = re1 + tmp1 + tmp5; + vec[1] = im1 + tmp3 + tmp7; + vec[2] = re1 + C51 * tmp1 - C53 * tmp5 + C52 * tmp4 + C54 * tmp8; + vec[8] = re1 + C51 * tmp1 - C53 * tmp5 - C52 * tmp4 - C54 * tmp8; + vec[3] = im1 - C52 * tmp2 - C54 * tmp6 + C51 * tmp3 - C53 * tmp7; + vec[9] = im1 + C52 * tmp2 + C54 * tmp6 + C51 * tmp3 - C53 * tmp7; + vec[4] = re1 - C53 * tmp1 + C51 * tmp5 + C54 * tmp4 - C52 * tmp8; + vec[6] = re1 - C53 * tmp1 + C51 * tmp5 - C54 * tmp4 + C52 * tmp8; + vec[5] = im1 - C54 * tmp2 + C52 * tmp6 - C53 * tmp3 + C51 * tmp7; + vec[7] = im1 + C54 * tmp2 - C52 * tmp6 - C53 * tmp3 + C51 * tmp7; +} + + + +static void fft8(LC3_FLOAT* vec) +{ + const LC3_FLOAT INV_SQRT2 = 7.071067811865475e-1; + LC3_FLOAT temp1[16], temp2[16]; + + /* Pre-additions */ + temp1[0] = vec[0] + vec[8]; + temp1[2] = vec[0] - vec[8]; + temp1[1] = vec[1] + vec[9]; + temp1[3] = vec[1] - vec[9]; + temp1[4] = vec[2] + vec[10]; + temp1[6] = vec[2] - vec[10]; + temp1[5] = vec[3] + vec[11]; + temp1[7] = vec[3] - vec[11]; + temp1[8] = vec[4] + vec[12]; + temp1[10] = vec[4] - vec[12]; + temp1[9] = vec[5] + vec[13]; + temp1[11] = vec[5] - vec[13]; + temp1[12] = vec[6] + vec[14]; + temp1[14] = vec[6] - vec[14]; + temp1[13] = vec[7] + vec[15]; + temp1[15] = vec[7] - vec[15]; + + /* Pre-additions and core multiplications */ + temp2[0] = temp1[0] + temp1[8]; + temp2[4] = temp1[0] - temp1[8]; + temp2[1] = temp1[1] + temp1[9]; + temp2[5] = temp1[1] - temp1[9]; + temp2[8] = temp1[2] - temp1[11]; + temp2[10] = temp1[2] + temp1[11]; + temp2[9] = temp1[3] + temp1[10]; + temp2[11] = temp1[3] - temp1[10]; + temp2[2] = temp1[4] + temp1[12]; + temp2[7] = temp1[4] - temp1[12]; + temp2[3] = temp1[5] + temp1[13]; + temp2[6] = temp1[13] - temp1[5]; + + temp1[1] = temp1[6] + temp1[14]; + temp1[2] = temp1[6] - temp1[14]; + temp1[0] = temp1[7] + temp1[15]; + temp1[3] = temp1[7] - temp1[15]; + temp2[12] = (temp1[0] + temp1[2]) * INV_SQRT2; + temp2[14] = (temp1[0] - temp1[2]) * INV_SQRT2; + temp2[13] = (temp1[3] - temp1[1]) * INV_SQRT2; + temp2[15] = (temp1[1] + temp1[3]) * -INV_SQRT2; + + /* Post-additions */ + vec[0] = temp2[0] + temp2[2]; + vec[8] = temp2[0] - temp2[2]; + vec[1] = temp2[1] + temp2[3]; + vec[9] = temp2[1] - temp2[3]; + vec[4] = temp2[4] - temp2[6]; + vec[12] = temp2[4] + temp2[6]; + vec[5] = temp2[5] - temp2[7]; + vec[13] = temp2[5] + temp2[7]; + vec[6] = temp2[8] + temp2[14]; + vec[14] = temp2[8] - temp2[14]; + vec[7] = temp2[9] + temp2[15]; + vec[15] = temp2[9] - temp2[15]; + vec[2] = temp2[10] + temp2[12]; + vec[10] = temp2[10] - temp2[12]; + vec[3] = temp2[11] + temp2[13]; + vec[11] = temp2[11] - temp2[13]; +} + + +static void fft9(LC3_FLOAT* vec) +{ + const LC3_FLOAT C91 = 0.766044443118978; /* cos(2*PI/5); */ + const LC3_FLOAT C92 = 0.642787609686539; + const LC3_FLOAT C93 = 0.17364817766693; + const LC3_FLOAT C94 = 0.984807753012208; + const LC3_FLOAT C95 = 0.5; + const LC3_FLOAT C96 = 0.866025403784439; + const LC3_FLOAT C97 = 0.939692620785908; + const LC3_FLOAT C98 = 0.342020143325669; + + LC3_FLOAT re1, im1, re2_9p, re2_9m, im2_9p, im2_9m, re3_8p, re3_8m, im3_8p, im3_8m, re4_7p, re4_7m, im4_7p, im4_7m, + re5_6p, re5_6m, im5_6p, im5_6m; + + re1 = vec[0]; + im1 = vec[1]; + + butterfly(vec[1 * 2], vec[8 * 2], &re2_9p, &re2_9m); + butterfly(vec[1 * 2 + 1], vec[8 * 2 + 1], &im2_9p, &im2_9m); + butterfly(vec[2 * 2], vec[7 * 2], &re3_8p, &re3_8m); + butterfly(vec[2 * 2 + 1], vec[7 * 2 + 1], &im3_8p, &im3_8m); + butterfly(vec[3 * 2], vec[6 * 2], &re4_7p, &re4_7m); + butterfly(vec[3 * 2 + 1], vec[6 * 2 + 1], &im4_7p, &im4_7m); + butterfly(vec[4 * 2], vec[5 * 2], &re5_6p, &re5_6m); + butterfly(vec[4 * 2 + 1], vec[5 * 2 + 1], &im5_6p, &im5_6m); + + /* + 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 + 1.0000 C91 - C92i C93 - C94i -C95 - C96i -C97 - C98i -C97 + C98i -C95 + C96i C93 + C94i C91 + C92i + 1.0000 C93 - C94i -C97 - C98i -C95 + C96i C91 + C92i C91 - C92i -C95 - C96i -C97 + C98i C93 + C94i + 1.0000 -C95 - C96i -C95 + C96i 1.0000 -C95 - C96i -C95 + C96i 1.0000 -C95 - C96i -C95 + C96i + 1.0000 -C97 - C98i C91 + C92i -C95 - C96i C93 + C94i C93 - C94i -C95 + C96i C91 - C92i -C97 + C98i + 1.0000 -C97 + C98i C91 - C92i -C95 + C96i C93 - C94i C93 + C94i -C95 - C96i C91 + C92i -C97 - C98i + 1.0000 -C95 + C96i -C95 - C96i 1.0000 -C95 + C96i -C95 - C96i 1.0000 -C95 + C96i -C95 - C96i + 1.0000 C93 + C94i -C97 + C98i -C95 - C96i C91 - C92i C91 + C92i -C95 + C96i -C97 - C98i C93 - C94i + 1.0000 C91 + C92i C93 + C94i -C95 + C96i -C97 + C98i -C97 - C98i -C95 - C96i C93 - C94i C91 - C92i + */ + vec[0] = re1 + re2_9p + re3_8p + re4_7p + re5_6p; + vec[1] = im1 + im2_9p + im3_8p + im4_7p + im5_6p; + vec[2] = re1 + C91 * re2_9p + C93 * re3_8p - C95 * re4_7p - C97 * re5_6p + C92 * im2_9m + C94 * im3_8m + + C96 * im4_7m + C98 * im5_6m; + vec[16] = re1 + C91 * re2_9p + C93 * re3_8p - C95 * re4_7p - C97 * re5_6p - C92 * im2_9m - C94 * im3_8m - + C96 * im4_7m - C98 * im5_6m; + vec[3] = im1 - C92 * re2_9m - C94 * re3_8m - C96 * re4_7m - C98 * re5_6m + C91 * im2_9p + C93 * im3_8p - + C95 * im4_7p - C97 * im5_6p; + vec[17] = im1 + C92 * re2_9m + C94 * re3_8m + C96 * re4_7m + C98 * re5_6m + C91 * im2_9p + C93 * im3_8p - + C95 * im4_7p - C97 * im5_6p; + vec[4] = re1 + C93 * re2_9p - C97 * re3_8p - C95 * re4_7p + C91 * re5_6p + C94 * im2_9m + C98 * im3_8m - + C96 * im4_7m - C92 * im5_6m; + vec[14] = re1 + C93 * re2_9p - C97 * re3_8p - C95 * re4_7p + C91 * re5_6p - C94 * im2_9m - C98 * im3_8m + + C96 * im4_7m + C92 * im5_6m; + vec[5] = im1 - C94 * re2_9m - C98 * re3_8m + C96 * re4_7m + C92 * re5_6m + C93 * im2_9p - C97 * im3_8p - + C95 * im4_7p + C91 * im5_6p; + vec[15] = im1 + C94 * re2_9m + C98 * re3_8m - C96 * re4_7m - C92 * re5_6m + C93 * im2_9p - C97 * im3_8p - + C95 * im4_7p + C91 * im5_6p; + vec[6] = re1 - C95 * (re2_9p + re3_8p + re5_6p) + re4_7p + C96 * (im2_9m - im3_8m + im5_6m); + vec[12] = re1 - C95 * (re2_9p + re3_8p + re5_6p) + re4_7p - C96 * (im2_9m - im3_8m + im5_6m); + vec[7] = im1 - C96 * (re2_9m - re3_8m + re5_6m) - C95 * (im2_9p + im3_8p + im5_6p) + im4_7p; + vec[13] = im1 + C96 * (re2_9m - re3_8m + re5_6m) - C95 * (im2_9p + im3_8p + im5_6p) + im4_7p; + vec[8] = re1 - C97 * re2_9p + C91 * re3_8p - C95 * re4_7p + C93 * re5_6p + C98 * im2_9m - C92 * im3_8m + + C96 * im4_7m - C94 * im5_6m; + vec[10] = re1 - C97 * re2_9p + C91 * re3_8p - C95 * re4_7p + C93 * re5_6p - C98 * im2_9m + C92 * im3_8m - + C96 * im4_7m + C94 * im5_6m; + vec[9] = im1 - C98 * re2_9m + C92 * re3_8m - C96 * re4_7m + C94 * re5_6m - C97 * im2_9p + C91 * im3_8p - + C95 * im4_7p + C93 * im5_6p; + vec[11] = im1 + C98 * re2_9m - C92 * re3_8m + C96 * re4_7m - C94 * re5_6m - C97 * im2_9p + C91 * im3_8p - + C95 * im4_7p + C93 * im5_6p; +} + diff --git a/lib_lc3plus/fft/fft_32.h b/lib_lc3plus/fft/fft_32.h new file mode 100644 index 0000000000000000000000000000000000000000..803923a0158c42dc3f0d88ae81cb5765e6acf8a5 --- /dev/null +++ b/lib_lc3plus/fft/fft_32.h @@ -0,0 +1,467 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.3 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + + +/* guard against unindended includes */ +#ifndef INCLUDED_FROM_IISFFT_C +#error "this file must not be included" +#endif + +static void fft32(LC3_FLOAT* vec) +{ + const LC3_FLOAT INV_SQRT2 = 7.071067811865475e-1; + const LC3_FLOAT COS_PI_DIV8 = 9.238795325112867e-1; + const LC3_FLOAT COS_3PI_DIV8 = 3.826834323650898e-1; + const LC3_FLOAT SQRT2PLUS1 = 2.414213562373095; + const LC3_FLOAT SQRT2MINUS1 = 4.142135623730952e-1; + + const LC3_FLOAT c[4] = {9.807852804032304e-1, 8.314696123025452e-1, 5.555702330196023e-1, 1.950903220161283e-1}; + + LC3_FLOAT tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7, tmp8, tmp9, tmp10, tmp11, tmp12, tmp13, tmp14, tmp15, + temp10, temp11, temp12, temp13, temp14, temp15, temp16, temp17, temp18, temp19, temp110, temp111, temp112, + temp113, temp114, temp115, temp20, temp21, temp22, temp23, temp24, temp25, temp26, temp27, temp28, temp29, + temp210, temp211, temp212, temp213, temp214, temp215, temp30, temp31, temp32, temp33, temp34, temp35, temp36, + temp37, temp38, temp39, temp310, temp311, temp312, temp313, temp314, temp315, temp316, temp317, temp318, + temp319, temp320, temp321, temp322, temp323, temp324, temp325, temp326, temp327, temp328, temp329, temp330, + temp331, temp40, temp41, temp42, temp43, temp44, temp45, temp46, temp47, temp48, temp49, temp410, temp411, + temp412, temp413, temp414, temp415; + + temp20 = vec[2] - vec[34]; + temp21 = vec[3] - vec[35]; + temp30 = vec[0] + vec[32]; + temp31 = vec[1] + vec[33]; + temp32 = vec[2] + vec[34]; + temp33 = vec[3] + vec[35]; + + temp22 = vec[6] - vec[38]; + temp23 = vec[7] - vec[39]; + temp34 = vec[4] + vec[36]; + temp35 = vec[5] + vec[37]; + temp36 = vec[6] + vec[38]; + temp37 = vec[7] + vec[39]; + + temp24 = vec[10] - vec[42]; + temp25 = vec[11] - vec[43]; + temp38 = vec[8] + vec[40]; + temp39 = vec[9] + vec[41]; + temp310 = vec[10] + vec[42]; + temp311 = vec[11] + vec[43]; + + temp26 = vec[14] - vec[46]; + temp27 = vec[15] - vec[47]; + temp312 = vec[12] + vec[44]; + temp313 = vec[13] + vec[45]; + temp314 = vec[14] + vec[46]; + temp315 = vec[15] + vec[47]; + + temp28 = vec[18] - vec[50]; + temp29 = vec[19] - vec[51]; + temp316 = vec[16] + vec[48]; + temp317 = vec[17] + vec[49]; + temp318 = vec[18] + vec[50]; + temp319 = vec[19] + vec[51]; + + temp210 = vec[22] - vec[54]; + temp211 = vec[23] - vec[55]; + temp320 = vec[20] + vec[52]; + temp321 = vec[21] + vec[53]; + temp322 = vec[22] + vec[54]; + temp323 = vec[23] + vec[55]; + + temp212 = vec[26] - vec[58]; + temp213 = vec[27] - vec[59]; + temp324 = vec[24] + vec[56]; + temp325 = vec[25] + vec[57]; + temp326 = vec[26] + vec[58]; + temp327 = vec[27] + vec[59]; + + temp214 = vec[30] - vec[62]; + temp215 = vec[31] - vec[63]; + temp328 = vec[28] + vec[60]; + temp329 = vec[29] + vec[61]; + temp330 = vec[30] + vec[62]; + temp331 = vec[31] + vec[63]; + + /* Pre-additions */ + temp41 = -(temp20 + temp214); + temp42 = temp20 - temp214; + temp40 = temp21 + temp215; + temp43 = temp21 - temp215; + temp45 = -(temp22 + temp212); + temp46 = temp22 - temp212; + temp44 = temp23 + temp213; + temp47 = temp23 - temp213; + temp49 = -(temp24 + temp210); + temp410 = temp24 - temp210; + temp48 = temp25 + temp211; + temp411 = temp25 - temp211; + temp413 = -(temp26 + temp28); + temp414 = temp26 - temp28; + temp412 = temp27 + temp29; + temp415 = temp27 - temp29; + + /* Core multiplications */ + temp20 = temp40 * c[3] + temp44 * c[2] + temp48 * c[1] + temp412 * c[0]; + temp24 = temp40 * c[2] + temp44 * c[0] + temp48 * c[3] - temp412 * c[1]; + temp28 = temp40 * c[1] + temp44 * c[3] - temp48 * c[0] + temp412 * c[2]; + temp212 = temp40 * c[0] - temp44 * c[1] + temp48 * c[2] - temp412 * c[3]; + temp21 = temp41 * c[3] + temp45 * c[2] + temp49 * c[1] + temp413 * c[0]; + temp25 = temp41 * c[2] + temp45 * c[0] + temp49 * c[3] - temp413 * c[1]; + temp29 = temp41 * c[1] + temp45 * c[3] - temp49 * c[0] + temp413 * c[2]; + temp213 = temp41 * c[0] - temp45 * c[1] + temp49 * c[2] - temp413 * c[3]; + temp22 = temp42 * c[0] + temp46 * c[1] + temp410 * c[2] + temp414 * c[3]; + temp26 = temp42 * c[1] - temp46 * c[3] - temp410 * c[0] - temp414 * c[2]; + temp210 = temp42 * c[2] - temp46 * c[0] + temp410 * c[3] + temp414 * c[1]; + temp214 = temp42 * c[3] - temp46 * c[2] + temp410 * c[1] - temp414 * c[0]; + temp23 = temp43 * c[0] + temp47 * c[1] + temp411 * c[2] + temp415 * c[3]; + temp27 = temp43 * c[1] - temp47 * c[3] - temp411 * c[0] - temp415 * c[2]; + temp211 = temp43 * c[2] - temp47 * c[0] + temp411 * c[3] + temp415 * c[1]; + temp215 = temp43 * c[3] - temp47 * c[2] + temp411 * c[1] - temp415 * c[0]; + + /* Post-additions */ + temp40 = temp20 + temp22; + temp414 = temp20 - temp22; + temp41 = temp21 + temp23; + temp415 = temp21 - temp23; + temp42 = temp24 + temp26; + temp412 = temp24 - temp26; + temp43 = temp25 + temp27; + temp413 = temp25 - temp27; + temp44 = temp28 + temp210; + temp410 = temp28 - temp210; + temp45 = temp29 + temp211; + temp411 = temp29 - temp211; + temp46 = temp212 + temp214; + temp48 = temp212 - temp214; + temp47 = temp213 + temp215; + temp49 = temp213 - temp215; + + /* fft16(temp3); */ + /* even */ + temp10 = temp30 + temp316; + temp11 = temp31 + temp317; + temp12 = temp32 + temp318; + temp13 = temp33 + temp319; + temp14 = temp34 + temp320; + temp15 = temp35 + temp321; + temp16 = temp36 + temp322; + temp17 = temp37 + temp323; + temp18 = temp38 + temp324; + temp19 = temp39 + temp325; + temp110 = temp310 + temp326; + temp111 = temp311 + temp327; + temp112 = temp312 + temp328; + temp113 = temp313 + temp329; + temp114 = temp314 + temp330; + temp115 = temp315 + temp331; + + /* Pre-additions */ + tmp0 = temp10 + temp18; + tmp2 = temp10 - temp18; + tmp1 = temp11 + temp19; + tmp3 = temp11 - temp19; + tmp4 = temp12 + temp110; + tmp6 = temp12 - temp110; + tmp5 = temp13 + temp111; + tmp7 = temp13 - temp111; + tmp8 = temp14 + temp112; + tmp10 = temp14 - temp112; + tmp9 = temp15 + temp113; + tmp11 = temp15 - temp113; + tmp12 = temp16 + temp114; + tmp14 = temp16 - temp114; + tmp13 = temp17 + temp115; + tmp15 = temp17 - temp115; + + /* Pre-additions and core multiplications */ + temp20 = tmp0 + tmp8; + temp24 = tmp0 - tmp8; + temp21 = tmp1 + tmp9; + temp25 = tmp1 - tmp9; + temp28 = tmp2 - tmp11; + temp210 = tmp2 + tmp11; + temp29 = tmp3 + tmp10; + temp211 = tmp3 - tmp10; + temp22 = tmp4 + tmp12; + temp27 = tmp4 - tmp12; + temp23 = tmp5 + tmp13; + temp26 = tmp13 - tmp5; + + tmp1 = tmp6 + tmp14; + tmp2 = tmp6 - tmp14; + tmp0 = tmp7 + tmp15; + tmp3 = tmp7 - tmp15; + temp212 = (tmp0 + tmp2) * INV_SQRT2; + temp214 = (tmp0 - tmp2) * INV_SQRT2; + temp213 = (tmp3 - tmp1) * INV_SQRT2; + temp215 = (tmp1 + tmp3) * -INV_SQRT2; + + /* odd */ + temp10 = temp30 - temp316; + temp11 = temp31 - temp317; + temp12 = temp32 - temp318; + temp13 = temp33 - temp319; + temp14 = temp34 - temp320; + temp15 = temp35 - temp321; + temp16 = temp36 - temp322; + temp17 = temp37 - temp323; + temp18 = temp38 - temp324; + temp19 = temp39 - temp325; + temp110 = temp310 - temp326; + temp111 = temp311 - temp327; + temp112 = temp312 - temp328; + temp113 = temp313 - temp329; + temp114 = temp314 - temp330; + temp115 = temp315 - temp331; + + /* Post-additions */ + temp30 = temp20 + temp22; + temp316 = temp20 - temp22; + temp31 = temp21 + temp23; + temp317 = temp21 - temp23; + temp38 = temp24 - temp26; + temp324 = temp24 + temp26; + temp39 = temp25 - temp27; + temp325 = temp25 + temp27; + temp312 = temp28 + temp214; + temp328 = temp28 - temp214; + temp313 = temp29 + temp215; + temp329 = temp29 - temp215; + temp34 = temp210 + temp212; + temp320 = temp210 - temp212; + temp35 = temp211 + temp213; + temp321 = temp211 - temp213; + + /* Pre-additions and core multiplications */ + tmp9 = (temp12 + temp114) * -COS_3PI_DIV8; + tmp10 = (temp12 - temp114) * COS_PI_DIV8; + tmp8 = (temp13 + temp115) * COS_3PI_DIV8; + tmp11 = (temp13 - temp115) * COS_PI_DIV8; + tmp5 = (temp14 + temp112) * -INV_SQRT2; + tmp6 = (temp14 - temp112) * INV_SQRT2; + tmp4 = (temp15 + temp113) * INV_SQRT2; + tmp7 = (temp15 - temp113) * INV_SQRT2; + tmp13 = (temp16 + temp110) * -COS_PI_DIV8; + tmp14 = (temp16 - temp110) * COS_3PI_DIV8; + tmp12 = (temp17 + temp111) * COS_PI_DIV8; + tmp15 = (temp17 - temp111) * COS_3PI_DIV8; + + /* Core multiplications */ + temp12 = tmp8 * SQRT2PLUS1 - tmp12 * SQRT2MINUS1; + temp13 = tmp9 * SQRT2PLUS1 - tmp13 * SQRT2MINUS1; + temp14 = tmp10 * SQRT2MINUS1 - tmp14 * SQRT2PLUS1; + temp15 = tmp11 * SQRT2MINUS1 - tmp15 * SQRT2PLUS1; + + /* Post-additions */ + tmp8 += tmp12; + tmp9 += tmp13; + tmp10 += tmp14; + tmp11 += tmp15; + temp16 = temp10 + tmp4; + temp110 = temp10 - tmp4; + temp17 = temp11 + tmp5; + temp111 = temp11 - tmp5; + + temp112 = tmp6 - temp19; + temp114 = tmp6 + temp19; + temp113 = temp18 + tmp7; + temp115 = temp18 - tmp7; + + tmp0 = temp16 - temp114; + tmp2 = temp16 + temp114; + tmp1 = temp17 + temp115; + tmp3 = temp17 - temp115; + tmp4 = temp110 + temp112; + tmp6 = temp110 - temp112; + tmp5 = temp111 + temp113; + tmp7 = temp111 - temp113; + + temp110 = tmp8 + tmp10; + tmp10 = tmp8 - tmp10; + temp111 = tmp9 + tmp11; + tmp11 = tmp9 - tmp11; + + tmp12 = temp12 + temp14; + tmp14 = temp12 - temp14; + tmp13 = temp13 + temp15; + tmp15 = temp13 - temp15; + + temp32 = tmp2 + temp110; + temp318 = tmp2 - temp110; + temp33 = tmp3 + temp111; + temp319 = tmp3 - temp111; + temp36 = tmp0 + tmp12; + temp322 = tmp0 - tmp12; + temp37 = tmp1 + tmp13; + temp323 = tmp1 - tmp13; + temp314 = tmp4 + tmp10; + temp330 = tmp4 - tmp10; + temp315 = tmp5 + tmp11; + temp331 = tmp5 - tmp11; + temp310 = tmp6 + tmp14; + temp326 = tmp6 - tmp14; + temp311 = tmp7 + tmp15; + temp327 = tmp7 - tmp15; + /* fft16(temp3); end */ + + /* fft8even(temp1); */ + temp10 = vec[0] - vec[32]; + temp11 = vec[1] - vec[33]; + temp12 = vec[4] - vec[36]; + temp13 = vec[5] - vec[37]; + temp14 = vec[8] - vec[40]; + temp15 = vec[9] - vec[41]; + temp16 = vec[12] - vec[44]; + temp17 = vec[13] - vec[45]; + temp18 = vec[16] - vec[48]; + temp19 = vec[17] - vec[49]; + temp110 = vec[20] - vec[52]; + temp111 = vec[21] - vec[53]; + temp112 = vec[24] - vec[56]; + temp113 = vec[25] - vec[57]; + temp114 = vec[28] - vec[60]; + temp115 = vec[29] - vec[61]; + + /* Pre-additions and core multiplications */ + tmp9 = (temp12 + temp114) * -COS_3PI_DIV8; + tmp10 = (temp12 - temp114) * COS_PI_DIV8; + tmp8 = (temp13 + temp115) * COS_3PI_DIV8; + tmp11 = (temp13 - temp115) * COS_PI_DIV8; + tmp5 = (temp14 + temp112) * -INV_SQRT2; + tmp6 = (temp14 - temp112) * INV_SQRT2; + tmp4 = (temp15 + temp113) * INV_SQRT2; + tmp7 = (temp15 - temp113) * INV_SQRT2; + tmp13 = (temp16 + temp110) * -COS_PI_DIV8; + tmp14 = (temp16 - temp110) * COS_3PI_DIV8; + tmp12 = (temp17 + temp111) * COS_PI_DIV8; + tmp15 = (temp17 - temp111) * COS_3PI_DIV8; + + /* Core multiplications */ + temp12 = tmp8 * SQRT2PLUS1 - tmp12 * SQRT2MINUS1; + temp13 = tmp9 * SQRT2PLUS1 - tmp13 * SQRT2MINUS1; + temp14 = tmp10 * SQRT2MINUS1 - tmp14 * SQRT2PLUS1; + temp15 = tmp11 * SQRT2MINUS1 - tmp15 * SQRT2PLUS1; + + /* Post-additions */ + tmp8 += tmp12; + tmp9 += tmp13; + tmp10 += tmp14; + tmp11 += tmp15; + temp16 = temp10 + tmp4; + temp110 = temp10 - tmp4; + temp17 = temp11 + tmp5; + temp111 = temp11 - tmp5; + + temp112 = tmp6 - temp19; + temp114 = tmp6 + temp19; + temp113 = temp18 + tmp7; + temp115 = temp18 - tmp7; + + tmp0 = temp16 - temp114; + tmp2 = temp16 + temp114; + tmp1 = temp17 + temp115; + tmp3 = temp17 - temp115; + tmp4 = temp110 + temp112; + tmp6 = temp110 - temp112; + tmp5 = temp111 + temp113; + tmp7 = temp111 - temp113; + + temp110 = tmp8 + tmp10; + tmp10 = tmp8 - tmp10; + temp111 = tmp9 + tmp11; + tmp11 = tmp9 - tmp11; + + tmp12 = temp12 + temp14; + tmp14 = temp12 - temp14; + tmp13 = temp13 + temp15; + tmp15 = temp13 - temp15; + + temp10 = tmp2 + temp110; + temp18 = tmp2 - temp110; + temp11 = tmp3 + temp111; + temp19 = tmp3 - temp111; + temp12 = tmp0 + tmp12; + temp110 = tmp0 - tmp12; + temp13 = tmp1 + tmp13; + temp111 = tmp1 - tmp13; + temp16 = tmp4 + tmp10; + temp114 = tmp4 - tmp10; + temp17 = tmp5 + tmp11; + temp115 = tmp5 - tmp11; + temp14 = tmp6 + tmp14; + temp112 = tmp6 - tmp14; + temp15 = tmp7 + tmp15; + temp113 = tmp7 - tmp15; + /* fft8even(temp1); end */ + + *vec++ = temp30; + *vec++ = temp31; + *vec++ = temp10 + temp40; + *vec++ = temp11 + temp41; + *vec++ = temp32; + *vec++ = temp33; + *vec++ = temp12 + temp42; + *vec++ = temp13 + temp43; + *vec++ = temp34; + *vec++ = temp35; + *vec++ = temp14 + temp44; + *vec++ = temp15 + temp45; + *vec++ = temp36; + *vec++ = temp37; + *vec++ = temp16 + temp46; + *vec++ = temp17 + temp47; + *vec++ = temp38; + *vec++ = temp39; + *vec++ = temp18 + temp48; + *vec++ = temp19 + temp49; + *vec++ = temp310; + *vec++ = temp311; + *vec++ = temp110 + temp410; + *vec++ = temp111 + temp411; + *vec++ = temp312; + *vec++ = temp313; + *vec++ = temp112 + temp412; + *vec++ = temp113 + temp413; + *vec++ = temp314; + *vec++ = temp315; + *vec++ = temp114 + temp414; + *vec++ = temp115 + temp415; + *vec++ = temp316; + *vec++ = temp317; + *vec++ = temp10 - temp40; + *vec++ = temp11 - temp41; + *vec++ = temp318; + *vec++ = temp319; + *vec++ = temp12 - temp42; + *vec++ = temp13 - temp43; + *vec++ = temp320; + *vec++ = temp321; + *vec++ = temp14 - temp44; + *vec++ = temp15 - temp45; + *vec++ = temp322; + *vec++ = temp323; + *vec++ = temp16 - temp46; + *vec++ = temp17 - temp47; + *vec++ = temp324; + *vec++ = temp325; + *vec++ = temp18 - temp48; + *vec++ = temp19 - temp49; + *vec++ = temp326; + *vec++ = temp327; + *vec++ = temp110 - temp410; + *vec++ = temp111 - temp411; + *vec++ = temp328; + *vec++ = temp329; + *vec++ = temp112 - temp412; + *vec++ = temp113 - temp413; + *vec++ = temp330; + *vec++ = temp331; + *vec++ = temp114 - temp414; + *vec++ = temp115 - temp415; +} diff --git a/lib_lc3plus/fft/fft_384_768.h b/lib_lc3plus/fft/fft_384_768.h new file mode 100644 index 0000000000000000000000000000000000000000..bd89393c174c8f14b4b2db5fee253f0a41e803c8 --- /dev/null +++ b/lib_lc3plus/fft/fft_384_768.h @@ -0,0 +1,103 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.3 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + + +/* guard against unindended includes */ +#ifndef INCLUDED_FROM_IISFFT_C +#error "this file must not be included" +#endif + +static void fft384(LC3_FLOAT* restrict in) +{ + const LC3_INT table1[384] = { + 0, 256, 128, 129, 1, 257, 258, 130, 2, 3, 259, 131, 132, 4, 260, 261, 133, 5, 6, 262, 134, 135, + 7, 263, 264, 136, 8, 9, 265, 137, 138, 10, 266, 267, 139, 11, 12, 268, 140, 141, 13, 269, 270, 142, + 14, 15, 271, 143, 144, 16, 272, 273, 145, 17, 18, 274, 146, 147, 19, 275, 276, 148, 20, 21, 277, 149, + 150, 22, 278, 279, 151, 23, 24, 280, 152, 153, 25, 281, 282, 154, 26, 27, 283, 155, 156, 28, 284, 285, + 157, 29, 30, 286, 158, 159, 31, 287, 288, 160, 32, 33, 289, 161, 162, 34, 290, 291, 163, 35, 36, 292, + 164, 165, 37, 293, 294, 166, 38, 39, 295, 167, 168, 40, 296, 297, 169, 41, 42, 298, 170, 171, 43, 299, + 300, 172, 44, 45, 301, 173, 174, 46, 302, 303, 175, 47, 48, 304, 176, 177, 49, 305, 306, 178, 50, 51, + 307, 179, 180, 52, 308, 309, 181, 53, 54, 310, 182, 183, 55, 311, 312, 184, 56, 57, 313, 185, 186, 58, + 314, 315, 187, 59, 60, 316, 188, 189, 61, 317, 318, 190, 62, 63, 319, 191, 192, 64, 320, 321, 193, 65, + 66, 322, 194, 195, 67, 323, 324, 196, 68, 69, 325, 197, 198, 70, 326, 327, 199, 71, 72, 328, 200, 201, + 73, 329, 330, 202, 74, 75, 331, 203, 204, 76, 332, 333, 205, 77, 78, 334, 206, 207, 79, 335, 336, 208, + 80, 81, 337, 209, 210, 82, 338, 339, 211, 83, 84, 340, 212, 213, 85, 341, 342, 214, 86, 87, 343, 215, + 216, 88, 344, 345, 217, 89, 90, 346, 218, 219, 91, 347, 348, 220, 92, 93, 349, 221, 222, 94, 350, 351, + 223, 95, 96, 352, 224, 225, 97, 353, 354, 226, 98, 99, 355, 227, 228, 100, 356, 357, 229, 101, 102, 358, + 230, 231, 103, 359, 360, 232, 104, 105, 361, 233, 234, 106, 362, 363, 235, 107, 108, 364, 236, 237, 109, 365, + 366, 238, 110, 111, 367, 239, 240, 112, 368, 369, 241, 113, 114, 370, 242, 243, 115, 371, 372, 244, 116, 117, + 373, 245, 246, 118, 374, 375, 247, 119, 120, 376, 248, 249, 121, 377, 378, 250, 122, 123, 379, 251, 252, 124, + 380, 381, 253, 125, 126, 382, 254, 255, 127, 383}; + const LC3_INT table2[384] = { + 0, 128, 256, 3, 131, 259, 6, 134, 262, 9, 137, 265, 12, 140, 268, 15, 143, 271, 18, 146, 274, 21, + 149, 277, 24, 152, 280, 27, 155, 283, 30, 158, 286, 33, 161, 289, 36, 164, 292, 39, 167, 295, 42, 170, + 298, 45, 173, 301, 48, 176, 304, 51, 179, 307, 54, 182, 310, 57, 185, 313, 60, 188, 316, 63, 191, 319, + 66, 194, 322, 69, 197, 325, 72, 200, 328, 75, 203, 331, 78, 206, 334, 81, 209, 337, 84, 212, 340, 87, + 215, 343, 90, 218, 346, 93, 221, 349, 96, 224, 352, 99, 227, 355, 102, 230, 358, 105, 233, 361, 108, 236, + 364, 111, 239, 367, 114, 242, 370, 117, 245, 373, 120, 248, 376, 123, 251, 379, 126, 254, 382, 129, 257, 1, + 132, 260, 4, 135, 263, 7, 138, 266, 10, 141, 269, 13, 144, 272, 16, 147, 275, 19, 150, 278, 22, 153, + 281, 25, 156, 284, 28, 159, 287, 31, 162, 290, 34, 165, 293, 37, 168, 296, 40, 171, 299, 43, 174, 302, + 46, 177, 305, 49, 180, 308, 52, 183, 311, 55, 186, 314, 58, 189, 317, 61, 192, 320, 64, 195, 323, 67, + 198, 326, 70, 201, 329, 73, 204, 332, 76, 207, 335, 79, 210, 338, 82, 213, 341, 85, 216, 344, 88, 219, + 347, 91, 222, 350, 94, 225, 353, 97, 228, 356, 100, 231, 359, 103, 234, 362, 106, 237, 365, 109, 240, 368, + 112, 243, 371, 115, 246, 374, 118, 249, 377, 121, 252, 380, 124, 255, 383, 127, 258, 2, 130, 261, 5, 133, + 264, 8, 136, 267, 11, 139, 270, 14, 142, 273, 17, 145, 276, 20, 148, 279, 23, 151, 282, 26, 154, 285, + 29, 157, 288, 32, 160, 291, 35, 163, 294, 38, 166, 297, 41, 169, 300, 44, 172, 303, 47, 175, 306, 50, + 178, 309, 53, 181, 312, 56, 184, 315, 59, 187, 318, 62, 190, 321, 65, 193, 324, 68, 196, 327, 71, 199, + 330, 74, 202, 333, 77, 205, 336, 80, 208, 339, 83, 211, 342, 86, 214, 345, 89, 217, 348, 92, 220, 351, + 95, 223, 354, 98, 226, 357, 101, 229, 360, 104, 232, 363, 107, 235, 366, 110, 238, 369, 113, 241, 372, 116, + 244, 375, 119, 247, 378, 122, 250, 381, 125, 253}; + + const LC3_INT L = 384; + const LC3_INT A = 3; + const LC3_INT B = 128; + const LC3_INT* idx1 = table1; + const LC3_INT* idx2 = table2; + + LC3_INT k, l; + LC3_FLOAT temp[256], out[768]; + + for (k = 0; k < A; k++) { + for (l = 0; l < B; l++) { + temp[2 * l] = in[2 * *idx1]; + temp[2 * l + 1] = in[2 * *idx1 + 1]; + idx1 += A; + } + + fft128(temp); /* 128-point FFT */ + idx1 -= L; + + for (l = 0; l < B; l++) { + in[2 * *idx1] = temp[2 * l]; + in[2 * *idx1 + 1] = temp[2 * l + 1]; + idx1 += A; + } + + idx1 -= L - 1; + } + + idx1 -= A; + + for (k = 0; k < B; k++) { + for (l = 0; l < A; l++) { + temp[2 * l] = in[2 * *idx1]; + temp[2 * l + 1] = in[2 * *idx1++ + 1]; + } + + fft3(temp); /* 3-point FFT */ + + for (l = 0; l < A; l++) { + out[2 * *idx2] = temp[2 * l]; + out[2 * *idx2++ + 1] = temp[2 * l + 1]; + } + } + + memmove(in, out, 2 * L * sizeof(LC3_FLOAT)); +} + diff --git a/lib_lc3plus/fft/fft_60_128.h b/lib_lc3plus/fft/fft_60_128.h new file mode 100644 index 0000000000000000000000000000000000000000..e5a88ccad873d19fb1757cc14df1be36d6502b50 --- /dev/null +++ b/lib_lc3plus/fft/fft_60_128.h @@ -0,0 +1,161 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.3 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + + +/* guard against unindended includes */ +#ifndef INCLUDED_FROM_IISFFT_C +#error "this file must not be included" +#endif + +static void fft60(LC3_FLOAT* in) +{ + const LC3_INT table1[] = {0, 45, 30, 15, 16, 1, 46, 31, 32, 17, 2, 47, 48, 33, 18, 3, 4, 49, 34, 19, + 20, 5, 50, 35, 36, 21, 6, 51, 52, 37, 22, 7, 8, 53, 38, 23, 24, 9, 54, 39, + 40, 25, 10, 55, 56, 41, 26, 11, 12, 57, 42, 27, 28, 13, 58, 43, 44, 29, 14, 59}; + const LC3_INT table2[] = {0, 15, 30, 45, 4, 19, 34, 49, 8, 23, 38, 53, 12, 27, 42, 57, 16, 31, 46, 1, + 20, 35, 50, 5, 24, 39, 54, 9, 28, 43, 58, 13, 32, 47, 2, 17, 36, 51, 6, 21, + 40, 55, 10, 25, 44, 59, 14, 29, 48, 3, 18, 33, 52, 7, 22, 37, 56, 11, 26, 41}; + const LC3_INT a = 4; + const LC3_INT b = 15; + const LC3_INT L = 60; + const LC3_INT* idx1 = table1; + const LC3_INT* idx2 = table2; + + LC3_FLOAT temp[30], out[120]; + LC3_INT k, l; + + for (k = 0; k < a; k++) { + for (l = 0; l < b; l++) { + temp[2 * l] = in[2 * *idx1]; + temp[2 * l + 1] = in[2 * *idx1 + 1]; + idx1 += a; + } + + fft15(temp); /* 15-point FFT */ + idx1 -= L; + + for (l = 0; l < b; l++) { + in[2 * *idx1] = temp[2 * l]; + in[2 * *idx1 + 1] = temp[2 * l + 1]; + idx1 += a; + } + idx1 -= L - 1; + } + + idx1 -= a; + + for (k = 0; k < b; k++) { + for (l = 0; l < a; l++) { + temp[2 * l] = in[2 * *idx1]; + temp[2 * l + 1] = in[2 * *idx1++ + 1]; + } + + fft4(temp); /* 4-point FFT */ + + for (l = 0; l < a; l++) { + out[2 * *idx2] = temp[2 * l]; + out[2 * *idx2++ + 1] = temp[2 * l + 1]; + } + } + memmove(in, out, 2 * L * sizeof(LC3_FLOAT)); +} + +static void fft64(LC3_FLOAT* vec) +{ + const LC3_FLOAT w[] = { + 1.0000000000f, 0.9951847267f, 0.9807852804f, 0.9569403357f, 0.9238795325f, 0.8819212643f, 0.8314696123f, + 0.7730104534f, 0.7071067812f, 0.6343932842f, 0.5555702330f, 0.4713967368f, 0.3826834324f, 0.2902846773f, + 0.1950903220f, 0.0980171403f, 0.0000000000f, -0.0980171403f, -0.1950903220f, -0.2902846773f, -0.3826834324f, + -0.4713967368f, -0.5555702330f, -0.6343932842f, -0.7071067812f, -0.7730104534f, -0.8314696123f, -0.8819212643f, + -0.9238795325f, -0.9569403357f, -0.9807852804f, -0.9951847267f, -1.0000000000f, -0.9951847267f, -0.9807852804f, + -0.9569403357f, -0.9238795325f, -0.8819212643f, -0.8314696123f, -0.7730104534f, -0.7071067812f, -0.6343932842f, + -0.5555702330f, -0.4713967368f, -0.3826834324f, -0.2902846773f, -0.1950903220f, -0.0980171403f}; + + LC3_FLOAT temp1[64], temp2[64]; + LC3_INT i; + + for (i = 0; i < 32; i++) { + temp1[2 * i] = vec[4 * i]; + temp1[2 * i + 1] = vec[4 * i + 1]; + temp2[2 * i] = vec[4 * i + 2]; + temp2[2 * i + 1] = vec[4 * i + 3]; + } + + fft32(temp1); + fft32(temp2); + + for (i = 0; i < 32; i++) { + LC3_FLOAT re, im, wre, wim, tre, tim; + + re = temp2[2 * i]; + im = temp2[2 * i + 1]; + + wre = w[i]; + wim = w[i + 16]; + + tre = re * wre - im * wim; + tim = re * wim + im * wre; + + vec[2 * i] = temp1[2 * i] + tre; + vec[2 * i + 1] = temp1[2 * i + 1] + tim; + vec[2 * i + 64] = temp1[2 * i] - tre; + vec[2 * i + 65] = temp1[2 * i + 1] - tim; + } +} + +static void fft128(LC3_FLOAT* vec) +{ + const LC3_FLOAT w[] = { + 1.0000000000f, 0.9987954562f, 0.9951847267f, 0.9891765100f, 0.9807852804f, 0.9700312532f, 0.9569403357f, + 0.9415440652f, 0.9238795325f, 0.9039892931f, 0.8819212643f, 0.8577286100f, 0.8314696123f, 0.8032075315f, + 0.7730104534f, 0.7409511254f, 0.7071067812f, 0.6715589548f, 0.6343932842f, 0.5956993045f, 0.5555702330f, + 0.5141027442f, 0.4713967368f, 0.4275550934f, 0.3826834324f, 0.3368898534f, 0.2902846773f, 0.2429801799f, + 0.1950903220f, 0.1467304745f, 0.0980171403f, 0.0490676743f, 0.0000000000f, -0.0490676743f, -0.0980171403f, + -0.1467304745f, -0.1950903220f, -0.2429801799f, -0.2902846773f, -0.3368898534f, -0.3826834324f, -0.4275550934f, + -0.4713967368f, -0.5141027442f, -0.5555702330f, -0.5956993045f, -0.6343932842f, -0.6715589548f, -0.7071067812f, + -0.7409511254f, -0.7730104534f, -0.8032075315f, -0.8314696123f, -0.8577286100f, -0.8819212643f, -0.9039892931f, + -0.9238795325f, -0.9415440652f, -0.9569403357f, -0.9700312532f, -0.9807852804f, -0.9891765100f, -0.9951847267f, + -0.9987954562f, -1.0000000000f, -0.9987954562f, -0.9951847267f, -0.9891765100f, -0.9807852804f, -0.9700312532f, + -0.9569403357f, -0.9415440652f, -0.9238795325f, -0.9039892931f, -0.8819212643f, -0.8577286100f, -0.8314696123f, + -0.8032075315f, -0.7730104534f, -0.7409511254f, -0.7071067812f, -0.6715589548f, -0.6343932842f, -0.5956993045f, + -0.5555702330f, -0.5141027442f, -0.4713967368f, -0.4275550934f, -0.3826834324f, -0.3368898534f, -0.2902846773f, + -0.2429801799f, -0.1950903220f, -0.1467304745f, -0.0980171403f, -0.0490676743f, + }; + + LC3_FLOAT temp1[128], temp2[128]; + LC3_INT i; + + for (i = 0; i < 64; i++) { + temp1[2 * i] = vec[4 * i]; + temp1[2 * i + 1] = vec[4 * i + 1]; + temp2[2 * i] = vec[4 * i + 2]; + temp2[2 * i + 1] = vec[4 * i + 3]; + } + + fft64(temp1); + fft64(temp2); + + for (i = 0; i < 64; i++) { + LC3_FLOAT re, im, wre, wim, tre, tim; + + re = temp2[2 * i]; + im = temp2[2 * i + 1]; + + wre = w[i]; + wim = w[i + 32]; + + tre = re * wre - im * wim; + tim = re * wim + im * wre; + + vec[2 * i] = temp1[2 * i] + tre; + vec[2 * i + 1] = temp1[2 * i + 1] + tim; + vec[2 * i + 128] = temp1[2 * i] - tre; + vec[2 * i + 129] = temp1[2 * i + 1] - tim; + } +} diff --git a/lib_lc3plus/fft/fft_generic.h b/lib_lc3plus/fft/fft_generic.h new file mode 100644 index 0000000000000000000000000000000000000000..903875ab5a7b6ef471e4898ca3a868d49bebeb67 --- /dev/null +++ b/lib_lc3plus/fft/fft_generic.h @@ -0,0 +1,699 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.3 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + + +/* guard against unindended includes */ +#ifndef INCLUDED_FROM_IISFFT_C +#error "this file must not be included" +#endif + +#define FFT_INTERNAL_TRIG_PREC double +#define BORDER_FOR_SECOND_SCRATCH 100 + +static const LC3_INT primeFactors[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, + 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, + 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, + 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 0}; + +/* fft, returns 1 if length is supported and fft was applied */ +static LC3_INT fft_n(LC3_FLOAT* x, LC3_INT length) +{ + switch (length) { + case 2: + fft2(x); + return 1; + case 3: + fft3(x); + return 1; + case 4: + fft4(x); + return 1; + case 5: + fft5(x); + return 1; + case 8: + fft8(x); + return 1; + case 9: + fft9(x); + return 1; + case 15: + fft15(x); + return 1; + case 16: + fft16(x); + return 1; + case 32: + fft32(x); + return 1; + case 60: + fft60(x); + return 1; + case 64: + fft64(x); + return 1; + case 128: + fft128(x); + return 1; + case 240: + fft240(x); + return 1; + case 256: + LC3_cfft(x, x + 1, 256, 2, -1); + return 1; + case 384: + fft384(x); + return 1; + case 480: + fft480(x); + return 1; + case 512: + LC3_cfft(x, x + 1, 512, 2, -1); + return 1; + case 1024: + LC3_cfft(x, x + 1, 1024, 2, -1); + return 1; + default: + return 0; + } +} + + +/* returns 1 on success or 0 if IISFFT_MAXFACTORS is too small */ +static LC3_INT factorize(LC3_INT length, LC3_INT* restrict numFactors, LC3_INT* restrict factor, + LC3_INT* restrict isPrime) +{ + LC3_INT remainder = length; + LC3_INT idx = 0, cnt = 0; + LC3_INT actFac = primeFactors[idx]; + LC3_INT inc = 0; + + *numFactors = 0; + + while (remainder > 1 && actFac != 0) { + if (remainder % actFac == 0) { + if (inc == 0) { + inc = 1; + (*numFactors)++; + } + remainder /= actFac; + } else { + actFac = primeFactors[++idx]; + inc = 0; + } + } + if (remainder > 1) { + (*numFactors)++; + } + + if (*numFactors > IISFFT_MAXFACTORS) + return 0; + + idx = 0, cnt = 0, inc = 0; + remainder = length; + actFac = primeFactors[idx]; + (factor)[cnt] = 1; + while (remainder > 1 && actFac != 0) { + if (remainder % actFac == 0) { + (factor)[cnt] *= actFac; + remainder /= actFac; + inc = 1; + if (factor[cnt] == actFac) { /* first appearance of the factor */ + isPrime[cnt] = 1; + } else { + isPrime[cnt] = 0; + } + } else { + actFac = primeFactors[++idx]; + if (inc == 1) { + cnt++; + } + inc = 0; + (factor)[cnt] = 1; + } + } + if (remainder > 1) { + factor[cnt] = remainder; + } + return 1; +} + +static void oddFFT(LC3_FLOAT* restrict x, LC3_INT length, LC3_FLOAT* restrict scratch) +{ + LC3_INT i, k, n; + LC3_FLOAT * src1, *src2, *dest1, *dest2; + FFT_INTERNAL_TRIG_PREC sinValOrg, cosValOrg; + + dest1 = scratch + 1; + dest2 = scratch + length + 1; + src1 = x + 2; + src2 = x + 2 * length - 1; + + scratch[0] = x[0]; + scratch[length] = x[1]; + + for (i = 2; i < length; i += 2) { + LC3_FLOAT tmp1R, tmp1I, tmp2R, tmp2I; + tmp1R = *src1++; + tmp1I = *src1++; + tmp2I = *src2--; + tmp2R = *src2--; + *dest1++ = tmp1R + tmp2R; + *dest1++ = tmp1R - tmp2R; + *dest2++ = tmp1I + tmp2I; + *dest2++ = tmp1I - tmp2I; + + x[0] += tmp1R + tmp2R; + x[1] += tmp1I + tmp2I; + } + + dest1 = x + 2; + dest2 = x + 2 * length - 2; + for (k = 2; k < length; k += 2) { + FFT_INTERNAL_TRIG_PREC sinVal = 0, cosVal = 1; + cosValOrg = LC3_COS(-M_PIl * k / length); + sinValOrg = LC3_SIN(-M_PIl * k / length); + + *dest1 = *dest2 = scratch[0]; + *(dest1 + 1) = *(dest2 + 1) = scratch[length]; + + src1 = scratch + 1; + src2 = scratch + length + 1; + + for (n = 2; n < length; n += 2) { + LC3_FLOAT rePre, reMre, imPim, imMim; + /* + cos(x+y) = cox(x) cos(y) - sin(x) sin(y); + sin(x+y) = sin(x) cos(y) + cos(x) sin(y); + */ + FFT_INTERNAL_TRIG_PREC tmp = cosVal * cosValOrg - sinVal * sinValOrg; + sinVal = sinVal * cosValOrg + cosVal * sinValOrg; + cosVal = tmp; + + rePre = *src1++; + reMre = *src1++; + imPim = *src2++; + imMim = *src2++; + + *dest1 += (LC3_FLOAT)cosVal * rePre - (LC3_FLOAT)sinVal * imMim; + *(dest1 + 1) += (LC3_FLOAT)sinVal * reMre + (LC3_FLOAT)cosVal * imPim; + *dest2 += (LC3_FLOAT)cosVal * rePre + (LC3_FLOAT)sinVal * imMim; + *(dest2 + 1) += (LC3_FLOAT)-sinVal * reMre + (LC3_FLOAT)cosVal * imPim; + } + dest1 += 2; + dest2 -= 2; + } +} + +static LC3_INT findInverse(LC3_INT a, LC3_INT b) +{ + LC3_INT b0 = b, t, q; + LC3_INT x0 = 0, x1 = 1; + + if (b == 1) { + return 1; + } + + while (a > 1) { + q = a / b; + t = b, b = a % b, a = t; + t = x0, x0 = x1 - q * x0, x1 = t; + } + + if (x1 < 0) { + x1 += b0; + } + + return x1; +} + +static LC3_INT getGeneratorStupid(LC3_INT groupLength) +{ + LC3_INT generator = 2; /* start value */ + LC3_INT count = 1, number = generator; + + while (generator < 100) { /* hopefully the generator is smaller than 100 */ + while (number != 1) { + number = (number * generator) % groupLength; + count++; + } + if (count == groupLength - 1) { + return generator; + } else { + generator++; + count = 1; + number = generator; + } + } + + return -1; +} + +static LC3_INT getGenerator(LC3_INT groupLength) +{ + LC3_INT generator = 2; /* start value */ + LC3_INT count, number, factorCount, found, count2; + LC3_INT factors[16] = {0}; + + /* factorize: only for a group length with factors < 300 */ + factorCount = 0; + number = groupLength - 1; + found = 0; + count = 0; + while (number != 1) { + if (primeFactors[count] == 0) { + /* Not all factors listed */ + return getGeneratorStupid(groupLength); + } + if (number % primeFactors[count] == 0) { + number /= primeFactors[count]; + if (found == 0) { + factors[factorCount++] = primeFactors[count]; + found = 1; + } + } else { + count++; + found = 0; + } + } + + for (count = 0; factors[count] != 0; count++) { + factors[count] = (groupLength - 1) / factors[count]; + } + + /* calculate generator */ + number = generator; + count = 0; + while (factors[count] != 0) { + for (count2 = 0; count2 < factors[count] - 1; count2++) { + number = (number * generator) % groupLength; + } + if (number != 1) { + count++; + number = generator; + if (factors[count] == 0) { + return generator; + } + } else { + count = 0; + generator++; + number = generator; + } + } + + return -1; +} + +static void primeFFT(LC3_FLOAT* restrict x, LC3_INT length, LC3_FLOAT* restrict scratch, LC3_INT* restrict scratch2) +{ + LC3_INT i, k, middle = (length - 1) / 2; + LC3_FLOAT *src1, *src2, *dest1, *dest2; + LC3_INT * mapping, *map; + LC3_INT generator; + + LC3_INT mappingTable[25][97] = { + {0, 2}, + {0, 2, 4}, + {0, 2, 4, 8, 6}, + {0, 2, 6, 4, 12, 8, 10}, + {0, 2, 4, 8, 16, 10, 20, 18, 14, 6, 12}, + {0, 2, 4, 8, 16, 6, 12, 24, 22, 18, 10, 20, 14}, + {0, 2, 6, 18, 20, 26, 10, 30, 22, 32, 28, 16, 14, 8, 24, 4, 12}, + {0, 2, 4, 8, 16, 32, 26, 14, 28, 18, 36, 34, 30, 22, 6, 12, 24, 10, 20}, + {0, 2, 10, 4, 20, 8, 40, 16, 34, 32, 22, 18, 44, 36, 42, 26, 38, 6, 30, 12, 14, 24, 28}, + {0, 2, 4, 8, 16, 32, 6, 12, 24, 48, 38, 18, 36, 14, 28, 56, 54, 50, 42, 26, 52, 46, 34, 10, 20, 40, 22, 44, 30}, + {0, 2, 6, 18, 54, 38, 52, 32, 34, 40, 58, 50, 26, 16, 48, 20, + 60, 56, 44, 8, 24, 10, 30, 28, 22, 4, 12, 36, 46, 14, 42}, + {0, 2, 4, 8, 16, 32, 64, 54, 34, 68, 62, 50, 26, 52, 30, 60, 46, 18, 36, + 72, 70, 66, 58, 42, 10, 20, 40, 6, 12, 24, 48, 22, 44, 14, 28, 56, 38}, + {0, 2, 12, 72, 22, 50, 54, 78, 58, 20, 38, 64, 56, 8, 48, 42, 6, 36, 52, 66, 68, + 80, 70, 10, 60, 32, 28, 4, 24, 62, 44, 18, 26, 74, 34, 40, 76, 46, 30, 16, 14}, + {0, 2, 6, 18, 54, 76, 56, 82, 74, 50, 64, 20, 60, 8, 24, 72, 44, 46, 52, 70, 38, 28, + 84, 80, 68, 32, 10, 30, 4, 12, 36, 22, 66, 26, 78, 62, 14, 42, 40, 34, 16, 48, 58}, + {0, 2, 10, 50, 62, 28, 46, 42, 22, 16, 80, 24, 26, 36, 86, 54, 82, 34, 76, 4, 20, 6, 30, 56, + 92, 84, 44, 32, 66, 48, 52, 72, 78, 14, 70, 68, 58, 8, 40, 12, 60, 18, 90, 74, 88, 64, 38}, + {0, 2, 4, 8, 16, 32, 64, 22, 44, 88, 70, 34, 68, 30, 60, 14, 28, 56, 6, 12, 24, 48, 96, 86, 66, 26, 52, + 104, 102, 98, 90, 74, 42, 84, 62, 18, 36, 72, 38, 76, 46, 92, 78, 50, 100, 94, 82, 58, 10, 20, 40, 80, 54}, + {0, 2, 4, 8, 16, 32, 64, 10, 20, 40, 80, 42, 84, 50, 100, 82, 46, 92, 66, 14, + 28, 56, 112, 106, 94, 70, 22, 44, 88, 58, 116, 114, 110, 102, 86, 54, 108, 98, 78, 38, + 76, 34, 68, 18, 36, 72, 26, 52, 104, 90, 62, 6, 12, 24, 48, 96, 74, 30, 60}, + {0, 2, 4, 8, 16, 32, 64, 6, 12, 24, 48, 96, 70, 18, 36, 72, 22, 44, 88, 54, 108, + 94, 66, 10, 20, 40, 80, 38, 76, 30, 60, 120, 118, 114, 106, 90, 58, 116, 110, 98, 74, 26, + 52, 104, 86, 50, 100, 78, 34, 68, 14, 28, 56, 112, 102, 82, 42, 84, 46, 92, 62}, + {0, 2, 4, 8, 16, 32, 64, 128, 122, 110, 86, 38, 76, 18, 36, 72, 10, 20, 40, 80, 26, 52, 104, + 74, 14, 28, 56, 112, 90, 46, 92, 50, 100, 66, 132, 130, 126, 118, 102, 70, 6, 12, 24, 48, 96, 58, + 116, 98, 62, 124, 114, 94, 54, 108, 82, 30, 60, 120, 106, 78, 22, 44, 88, 42, 84, 34, 68}, + {0, 2, 14, 98, 118, 116, 102, 4, 28, 54, 94, 90, 62, 8, 56, 108, 46, 38, 124, 16, 112, 74, 92, 76, + 106, 32, 82, 6, 42, 10, 70, 64, 22, 12, 84, 20, 140, 128, 44, 24, 26, 40, 138, 114, 88, 48, 52, 80, + 134, 86, 34, 96, 104, 18, 126, 30, 68, 50, 66, 36, 110, 60, 136, 100, 132, 72, 78, 120, 130, 58, 122}, + {0, 2, 10, 50, 104, 82, 118, 6, 30, 4, 20, 100, 62, 18, 90, 12, 60, 8, 40, + 54, 124, 36, 34, 24, 120, 16, 80, 108, 102, 72, 68, 48, 94, 32, 14, 70, 58, 144, + 136, 96, 42, 64, 28, 140, 116, 142, 126, 46, 84, 128, 56, 134, 86, 138, 106, 92, 22, + 110, 112, 122, 26, 130, 66, 38, 44, 74, 78, 98, 52, 114, 132, 76, 88}, + {0, 2, 6, 18, 54, 4, 12, 36, 108, 8, 24, 72, 58, 16, 48, 144, 116, 32, 96, 130, + 74, 64, 34, 102, 148, 128, 68, 46, 138, 98, 136, 92, 118, 38, 114, 26, 78, 76, 70, 52, + 156, 152, 140, 104, 154, 146, 122, 50, 150, 134, 86, 100, 142, 110, 14, 42, 126, 62, 28, 84, + 94, 124, 56, 10, 30, 90, 112, 20, 60, 22, 66, 40, 120, 44, 132, 80, 82, 88, 106}, + {0, 2, 4, 8, 16, 32, 64, 128, 90, 14, 28, 56, 112, 58, 116, 66, 132, 98, 30, 60, 120, + 74, 148, 130, 94, 22, 44, 88, 10, 20, 40, 80, 160, 154, 142, 118, 70, 140, 114, 62, 124, 82, + 164, 162, 158, 150, 134, 102, 38, 76, 152, 138, 110, 54, 108, 50, 100, 34, 68, 136, 106, 46, 92, + 18, 36, 72, 144, 122, 78, 156, 146, 126, 86, 6, 12, 24, 48, 96, 26, 52, 104, 42, 84}, + {0, 2, 6, 18, 54, 162, 130, 34, 102, 128, 28, 84, 74, 44, 132, 40, 120, 4, + 12, 36, 108, 146, 82, 68, 26, 78, 56, 168, 148, 88, 86, 80, 62, 8, 24, 72, + 38, 114, 164, 136, 52, 156, 112, 158, 118, 176, 172, 160, 124, 16, 48, 144, 76, 50, + 150, 94, 104, 134, 46, 138, 58, 174, 166, 142, 70, 32, 96, 110, 152, 100, 122, 10, + 30, 90, 92, 98, 116, 170, 154, 106, 140, 64, 14, 42, 126, 22, 66, 20, 60}, + {0, 2, 10, 50, 56, 86, 42, 16, 80, 12, 60, 106, 142, 128, 58, 96, 92, 72, 166, 54, + 76, 186, 154, 188, 164, 44, 26, 130, 68, 146, 148, 158, 14, 70, 156, 4, 20, 100, 112, 172, + 84, 32, 160, 24, 120, 18, 90, 62, 116, 192, 184, 144, 138, 108, 152, 178, 114, 182, 134, 88, + 52, 66, 136, 98, 102, 122, 28, 140, 118, 8, 40, 6, 30, 150, 168, 64, 126, 48, 46, 36, + 180, 124, 38, 190, 174, 94, 82, 22, 110, 162, 34, 170, 74, 176, 104, 132, 78}}; + + if (length < BORDER_FOR_SECOND_SCRATCH) { + for (i = 1;; i++) { + if (primeFactors[i] == length) { + mapping = mappingTable[i]; + break; + } + assert(primeFactors[i] != 0); + } + } else { + mapping = scratch2; + + /* get primitive root */ + generator = getGenerator(length); + assert(generator != -1); + + /* init mapping */ + mapping[0] = 0; + mapping[1] = 1; + for (i = 2; i < length; i++) { + mapping[i] = mapping[i - 1] * generator; + if (mapping[i] > length - 1) { + mapping[i] = (mapping[i] % length - 1) + 1; + } + } + + /* double mapping value */ + for (i = 1; i < length; i++) { + mapping[i] *= 2; + } + } + + /* remap input to scratch */ + scratch[0] = x[0]; + scratch[1] = x[1]; + scratch[2] = x[2]; + scratch[3] = x[3]; + map = mapping + length - 1; + for (i = 4; i < 2 * length; map--) { + scratch[i++] = x[(*map)]; + scratch[i++] = x[(*map) + 1]; + } + + /* print sums and diffs into scratch by using symmetry */ + x[length] = x[1]; /* imaginary und real part */ + dest1 = x + 1; + dest2 = x + length + 1; + src1 = scratch + 2; + src2 = scratch + length + 1; + + for (i = 2; i < length; i += 2) { + LC3_FLOAT tmp1R, tmp1I, tmp2R, tmp2I; + tmp1R = *src1++; + tmp1I = *src1++; + tmp2R = *src2++; + tmp2I = *src2++; + *dest1++ = tmp1R + tmp2R; + *dest1++ = tmp1R - tmp2R; + *dest2++ = tmp1I + tmp2I; + *dest2++ = tmp1I - tmp2I; + + scratch[0] += tmp1R + tmp2R; + scratch[1] += tmp1I + tmp2I; + } + + /* init with values from the first column */ + dest1 = scratch + 2; + for (i = 1; i < length; i++) { + *dest1++ = x[0]; /* add real part of x(0)(factor = 1) */ + *dest1++ = x[length]; /* add imaginary part of x(0)(factor = 1) */ + } + + for (k = 1; k <= middle; k++) { + /* loop through all cos/sin values */ + LC3_FLOAT sinVal, cosVal; + LC3_INT length1, length2; + LC3_FLOAT rePre, reMre, imPim, imMim; + + cosVal = (LC3_FLOAT)LC3_COS(-M_PIl * mapping[k] / length); + sinVal = (LC3_FLOAT)LC3_SIN(-M_PIl * mapping[k] / length); + + /* compute in two parts (length1, length2) to avoid if() in for loop */ + length1 = middle - k + 1; + length2 = middle - length1; + src1 = x + 1; + src2 = x + length + 1; + dest1 = scratch + 2 * k; + dest2 = scratch + 2 * (middle + k); + + for (i = 0; i < length1; i++) { + rePre = *src1++; + reMre = *src1++; + imPim = *src2++; + imMim = *src2++; + + *dest1++ += cosVal * rePre - sinVal * imMim; + *dest1++ += cosVal * imPim + sinVal * reMre; + + *dest2++ += cosVal * rePre + sinVal * imMim; + *dest2++ += cosVal * imPim - sinVal * reMre; + } + if (dest2 == scratch + 2 * length) { + dest2 = scratch + 2; + } + for (i = 0; i < length2; i++) { + rePre = *src1++; + reMre = *src1++; + imPim = *src2++; + imMim = *src2++; + + *dest1++ += cosVal * rePre - sinVal * imMim; + *dest1++ += cosVal * imPim + sinVal * reMre; + + *dest2++ += cosVal * rePre + sinVal * imMim; + *dest2++ += cosVal * imPim - sinVal * reMre; + } + } + + /* remap output to x */ + x[0] = scratch[0]; + x[1] = scratch[1]; + map = mapping + 1; + for (i = 2; i < 2 * length; map++) { + x[(*map)] = scratch[i++]; + x[(*map) + 1] = scratch[i++]; + } +} + +static void nextFFT(LC3_FLOAT* x, LC3_INT length, LC3_FLOAT* scratch) +{ + if (fft_n(x, length)) /* have function for length */ + return; + + assert(length % 2 != 0); + oddFFT(x, length, scratch); +} + +static inline LC3_INT findFactor(const LC3_INT length) +{ + static const LC3_INT factors[] = {16, 9, 8, 7, 5, 4, 3, 2, 0}; + LC3_INT i = 0, factor = 0; + for (i = 0; factors[i] != 0; i++) { + if (length % factors[i] == 0) { + factor = factors[i]; + break; + } + } + return factor; +} + +static inline void twiddle(LC3_FLOAT* x, const LC3_INT length, const LC3_INT n1, const LC3_INT n2) +{ + LC3_INT i, ii; + FFT_INTERNAL_TRIG_PREC sinValOrg, cosValOrg; + FFT_INTERNAL_TRIG_PREC sinVal = 0, cosVal = 1; + FFT_INTERNAL_TRIG_PREC twReal = 0, twImag = 1; + + cosValOrg = LC3_COS(-2 * (LC3_FLOAT)M_PIl / length); + sinValOrg = LC3_SIN(-2 * (LC3_FLOAT)M_PIl / length); + + for (i = 1; i < n1; i++) { + FFT_INTERNAL_TRIG_PREC tmp = 0.; + twReal = 1; + twImag = 0; + + tmp = cosVal * cosValOrg - sinVal * sinValOrg; + sinVal = sinVal * cosValOrg + cosVal * sinValOrg; + cosVal = tmp; + + for (ii = 1; ii < n2; ii++) { + LC3_FLOAT xRe, xIm; + FFT_INTERNAL_TRIG_PREC tmpReal; + + tmpReal = twReal * cosVal - twImag * sinVal; + twImag = twImag * cosVal + sinVal * twReal; + twReal = tmpReal; + + xRe = x[2 * (i * n2 + ii)]; + xIm = x[2 * (i * n2 + ii) + 1]; + + x[2 * (i * n2 + ii)] = (LC3_FLOAT)twReal * xRe - (LC3_FLOAT)twImag * xIm; + x[2 * (i * n2 + ii) + 1] = (LC3_FLOAT)twImag * xRe + (LC3_FLOAT)twReal * xIm; + } + } +} + +static void cooleyTukeyFFT(LC3_FLOAT* restrict x, const LC3_INT length, LC3_FLOAT* restrict scratch, + LC3_INT* restrict scratch2, LC3_INT isPrime) +{ + LC3_INT factor; + LC3_INT i, ii; + LC3_INT n1, n2; + LC3_INT cnt = 0; + LC3_FLOAT *src, *dest; + + if (fft_n(x, length)) + return; + + factor = findFactor(length); + if (factor > 0 && (length / factor > 1)) { + n1 = factor; + n2 = length / factor; + + /* DATA Resorting for stage1 */ + dest = scratch; + for (i = 0; i < 2 * n1; i += 2) { + src = x + i; + for (ii = 0; ii < n2; ii++) { + /* *dest++ = x[2*(i+ii*n1)]; */ + /* *dest++ = x[2*(i+ii*n1)+1]; */ + *dest++ = *src; + *dest++ = *(src + 1); + src += 2 * n1; + } + } + src = scratch; + dest = x; + for (i = 0; i < length; i++) { + *dest++ = *src++; + *dest++ = *src++; + } + /* perform n1 ffts of length n2 */ + for (i = 0; i < n1; i++) { + cooleyTukeyFFT(x + 2 * i * n2, n2, scratch + 2 * i * n2, scratch2, isPrime); + } + /*data twiddeling */ + twiddle(x, length, n1, n2); + /* DATA Resorting for stage2 */ + cnt = 0; + for (i = 0; i < n2; i++) { + for (ii = 0; ii < n1; ii++) { + scratch[2 * cnt] = x[2 * (i + ii * n2)]; + scratch[2 * cnt + 1] = x[2 * (i + ii * n2) + 1]; + cnt++; + } + } + /* perform n2 ffts of length n1 */ + for (i = 0; i < n2; i++) { + nextFFT(scratch + 2 * i * n1, n1, x + 2 * i * n1); + } + cnt = 0; + for (i = 0; i < n1; i++) { + for (ii = 0; ii < n2; ii++) { + x[2 * cnt] = scratch[2 * (i + ii * n1)]; + x[2 * cnt + 1] = scratch[2 * (i + ii * n1) + 1]; + cnt++; + } + } + } else { + if (isPrime == 1 && length > 23) { + primeFFT(x, length, scratch, scratch2); + } else { + oddFFT(x, length, scratch); + } + } +} + +static void pfaDFT(LC3_FLOAT* restrict x, const LC3_INT length, LC3_FLOAT* restrict scratch1, const LC3_INT numFactors, + const LC3_INT* const factor, LC3_INT* restrict scratch2, const LC3_INT* const isPrime) +{ + LC3_FLOAT* tmp = scratch1; + LC3_INT i, ii, n1, n2, idx, incr, cnt; + LC3_INT n1_inv = 1; + + if (numFactors <= 1) { + cooleyTukeyFFT(x, length, scratch1, scratch2, isPrime[0]); + return; + } + + n2 = factor[0]; + n1 = length / n2; + + n1_inv = findInverse(n1, n2); + + idx = 0; + incr = n1 * n1_inv; + cnt = 0; + for (i = 0; i < n1; i++) { + for (ii = 0; ii < n2 - 1; ii++) { + tmp[cnt++] = x[2 * idx]; + tmp[cnt++] = x[2 * idx + 1]; + + idx += incr; + if (idx > length) { + idx -= length; + } + } + tmp[cnt++] = x[2 * idx]; + tmp[cnt++] = x[2 * idx + 1]; + idx++; + } + + for (cnt = 0; cnt < length; cnt += n2) { + cooleyTukeyFFT(tmp + 2 * cnt, n2, x + 2 * cnt, scratch2, isPrime[0]); + } + for (cnt = 0; cnt < n1; cnt++) { + for (i = 0; i < n2; i++) { + x[2 * (cnt + i * n1)] = tmp[2 * (cnt * n2 + i)]; + x[2 * (cnt + i * n1) + 1] = tmp[2 * (cnt * n2 + i) + 1]; + } + } + for (cnt = 0; cnt < length; cnt += n1) { + pfaDFT(x + 2 * cnt, n1, tmp, numFactors - 1, &factor[1], scratch2, &isPrime[1]); + } + + cnt = 0; + for (i = 0; i < n2; i++) { + idx = i * n1; + for (ii = 0; ii < n1; ii++) { + tmp[2 * idx] = x[cnt++]; + tmp[2 * idx + 1] = x[cnt++]; + idx += n2; + if (idx > length) { + idx -= length; + } + } + } + + for (cnt = 0; cnt < length; cnt++) { + x[2 * cnt] = tmp[2 * cnt]; + x[2 * cnt + 1] = tmp[2 * cnt + 1]; + } +} diff --git a/lib_lc3plus/fft/iis_fft.c b/lib_lc3plus/fft/iis_fft.c new file mode 100644 index 0000000000000000000000000000000000000000..be71d8e4ab3957ffe7857e231c158a3cb9cebc45 --- /dev/null +++ b/lib_lc3plus/fft/iis_fft.c @@ -0,0 +1,172 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.3 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + + +#include "options.h" +#include "wmc_auto.h" +#include +#include +#include +#include +#include +#include +#include "iis_fft.h" + +/**************************************************************************************************/ + +/* AFFT uses two fft implementations + * cfft is used for lengths of power of two, >= 256. + * iisfft is used for everything else. it is optimized for certain lengths. for a list of + fast lengths, check the fft_n function. +*/ + +#define FFT_COMPLEX 1 +#define FFT_REAL 2 + + +static IIS_FFT_ERROR create(HANDLE_IIS_FFT* handle, LC3_INT type, LC3_INT len, IIS_FFT_DIR sign) +{ + IIS_FFT_ERROR err = IIS_FFT_MEMORY_ERROR; + + /* for real transforms the actual performed fft is half length */ + LC3_INT trlen = (type == FFT_COMPLEX) ? len : len / 2; + + /* check argument sanity */ + if ((sign != IIS_FFT_FWD) && (sign != IIS_FFT_BWD)) + { + return IIS_FFT_INTERNAL_ERROR; + } + + if (!(*handle)) + { + (*handle) = (HANDLE_IIS_FFT)calloc(1, sizeof(IIS_FFT)); + } + + if (!(*handle)) + { + return IIS_FFT_MEMORY_ERROR; + } + + (*handle)->len = len; + (*handle)->sign = sign; + + /* create sine lookup table for real ffts */ + if (type == FFT_REAL) + { + LC3_create_sine_table(len, (*handle)->sine_table); + if (!(*handle)->sine_table) + { + goto handle_error1; + } + } + + /* set default cfft_plan to 0(length). (and default iisfft_plan to zero length) */ + (*handle)->cfft.len = 0; /* 0 length means that cfft should not be called */ + (*handle)->iisfft.length = 0; /*saftey setting for iisfft length struct */ + + /* use cfft for legth of power two larger than 256. for length below iisfft is faster */ + if (trlen >= 256 && CFFT_PLAN_SUPPORT(trlen)) { + LC3_INT s = (type == FFT_REAL) ? IIS_FFT_FWD : sign; + err = LC3_cfft_plan(&(*handle)->cfft, trlen, s) ? IIS_FFT_NO_ERROR : IIS_FFT_INTERNAL_ERROR; + } else { + LC3_INT s = (type == FFT_REAL) ? IIS_FFT_FWD : sign; + err = LC3_iisfft_plan(&(*handle)->iisfft, trlen, s); + } + + return IIS_FFT_NO_ERROR; + +handle_error1: + free((*handle)); + + return err; +} + +IIS_FFT_ERROR LC3_IIS_RFFT_Create(HANDLE_IIS_FFT* handle, LC3_INT32 len, IIS_FFT_DIR sign) +{ + return create(handle, FFT_REAL, len, sign); +} + +static IIS_FFT_ERROR destroy(HANDLE_IIS_FFT* handle) +{ + if (handle && *handle) { + LC3_iisfft_free(&(*handle)->iisfft); + LC3_cfft_free(&(*handle)->cfft); + free(*handle); + *handle = NULL; + } + return IIS_FFT_NO_ERROR; +} + +IIS_FFT_ERROR LC3_IIS_CFFT_Create(HANDLE_IIS_FFT* handle, LC3_INT len, IIS_FFT_DIR sign) +{ + return create(handle, FFT_COMPLEX, len, sign); +} + + +IIS_FFT_ERROR LC3_IIS_xFFT_Destroy(HANDLE_IIS_FFT* handle) { return destroy(handle); } + +IIS_FFT_ERROR LC3_IIS_CFFT_Destroy(HANDLE_IIS_FFT* handle) { return destroy(handle); } + +static IIS_FFT_ERROR real_destroy(HANDLE_IIS_FFT* handle) +{ + if (handle && *handle) { + LC3_iisfft_free(&(*handle)->iisfft); + *handle = NULL; + } + return IIS_FFT_NO_ERROR; +} + +IIS_FFT_ERROR LC3_IIS_RFFT_Destroy(HANDLE_IIS_FFT* handle) { return real_destroy(handle); } + +IIS_FFT_ERROR LC3_IIS_FFT_Apply_CFFT(HANDLE_IIS_FFT handle, const Complex* input, Complex* output) +{ + LC3_FLOAT* dummy; + if (!handle) + { + return IIS_FFT_INTERNAL_ERROR; + } + + /* check for inplace operation */ + memmove(output, input, sizeof(*input) * handle->len); + dummy = (LC3_FLOAT*)output; + if (handle->cfft.len > 0) { + LC3_cfft_apply(&handle->cfft, dummy, dummy + 1, 2); + } else { + LC3_iisfft_apply(&handle->iisfft, dummy); + } + + return IIS_FFT_NO_ERROR; +} + + +IIS_FFT_ERROR LC3_IIS_FFT_Apply_RFFT(HANDLE_IIS_FFT handle, const LC3_FLOAT* in, LC3_FLOAT* out) +{ + if (!handle) { + return IIS_FFT_INTERNAL_ERROR; + } + + memmove(out, in, sizeof(LC3_FLOAT) * handle->len); + + if (handle->sign == IIS_FFT_BWD) { + LC3_rfft_pre(handle->sine_table, out, handle->len); + } + + if (handle->cfft.len > 0) { + LC3_cfft_apply(&handle->cfft, out, out + 1, 2); + } + else { + LC3_iisfft_apply(&handle->iisfft, out); + } + + if (handle->sign == IIS_FFT_FWD) { + LC3_rfft_post(handle->sine_table, out, handle->len); + } + + return IIS_FFT_NO_ERROR; +} diff --git a/lib_lc3plus/fft/iis_fft.h b/lib_lc3plus/fft/iis_fft.h new file mode 100644 index 0000000000000000000000000000000000000000..a145c490d1f859cba3f78ec03e17428ecd98d416 --- /dev/null +++ b/lib_lc3plus/fft/iis_fft.h @@ -0,0 +1,144 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.3 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + + +#ifndef IIS_FFT_H +#define IIS_FFT_H + +#include "options.h" +#include "wmc_auto.h" +#include "../structs.h" +#include "../defines.h" +#include "cfft.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +/*! + * \brief n-point complex FFT + * + * There are optimized FFTs for lengths 2, 3, 4, 7, 8, 9, 15, 16, 32, 60, 64, 128, + * 240, 256, 384, 480, 512, 768, 1024. Other lengths below 1024 use a stack allocated + * buffer and offer reasonable speed. Above 1024 a buffer is allocated each time + * iis_fftf() is called resulting in reduced performance. + * + * >>>>>> DO NOT USE UNOPTIMIZED LENGTHS IN PRODUCTION CODE! <<<<<< + * + * \param[in,out] vec pointer to data, interleaved real / imaginary + * \param[in] length length of fft (number of real/imaginary pairs) + * + * \return IIS_FFT_NO_ERROR on success + */ +IIS_FFT_ERROR LC3_iis_fftf(LC3_FLOAT* vec, LC3_INT length); +/*! + * \brief n-point inverse complex FFT + * + * The output is not normalized. See iis_fftf() for optimized lengths. + * + * >>>>>> DO NOT USE UNOPTIMIZED LENGTHS IN PRODUCTION CODE! <<<<<< + * + * \param[in,out] vec pointer to data, interleaved real / imaginary + * \param[in] length length of fft (number of real/imaginary pairs) + * + * \return IIS_FFT_NO_ERROR on success + */ +IIS_FFT_ERROR LC3_iis_ifftf(LC3_FLOAT* vec, LC3_INT length); + +/*! + * \brief allocate and initialize a new real FFT instance. + * + * \param[in,out] handle pointer to FFT handle + * \param[in] len transform length, must be an even number + * \param[in] sign IIS_FFT_FWD(-1) for forward, IIS_FFT_BWD(1) for backward transform + * BEWARE OF THE SIGNS! + * + * \return IIS_FFT_NO_ERROR on success + */ +IIS_FFT_ERROR LC3_IIS_RFFT_Create(HANDLE_IIS_FFT* handle, LC3_INT len, IIS_FFT_DIR sign); + +/*! + * \brief allocate and initialize a new complex FFT instance + * + * \param[in,out] handle pointer to FFT handle + * \param[in] len transform length + * \param[in] sign IIS_FFT_FWD(-1) for forward, IIS_FFT_BWD(1) for backward transform + * BEWARE OF THE SIGNS !!!!!! + * + * \return IIS_FFT_NO_ERROR on success + */ +IIS_FFT_ERROR LC3_IIS_CFFT_Create(HANDLE_IIS_FFT* handle, LC3_INT len, IIS_FFT_DIR sign); + +/*! + * \brief computes the forward or backward fourier transform of a real signal + * + * For complex data (in or out) the real part of the Nyquist band (len / 2 + 1) is stored + * in the imaginary part of the DC band (0). This allows for the complex data of + * real to complex transforms to fit into the same buffer. For this to work length must be even. + * + * Complex to real transforms are normalized (1.0/len). Input and ouput buffers may + *be identical. + * + * \param[in] handle FFT handle + * \param[in] in pointer to the input array containing real values for the forward transform (FFT) + * or packed complex values (Perm) for the backward transform (IFFT) + * \param[out] out pointer to the output array containing real values resulted from the backward transform + * (IFFT) or packed complex (perm) values reulted from the forward transform + * + * \return IIS_FFT_NO_ERROR on success + */ +IIS_FFT_ERROR LC3_IIS_FFT_Apply_RFFT(HANDLE_IIS_FFT handle, const LC3_FLOAT* in, LC3_FLOAT* out); + +/*! + * \brief compute complex backward or forward FFT + * + * Input and ouput buffers may be identical. Real/imaginary parts may be interleaved. + * The output is not normalized. + * + * \param[in] handle FFT handle + * \param[in] in_re pointer to the input array containing real parts of the signal for the + * forward transform (FFT) or for the backward transform (IFFT) + * \param[in] in_im pointer to the input array containing imaginary parts of the signal for + * the forward transform (FFT) or for the backward transform (IFFT) + * \param[out] out_re pointer to the output array containing real values resulted from the + * forward transform (FFT) or from the backward transform (IFFT) + * \param[out] out_im pointer to the output array containing imaginary values resulted from + * the forward transform (FFT) or from the backward transform (IFFT) + * + * \return IIS_FFT_NO_ERROR on success + */ +IIS_FFT_ERROR LC3_IIS_FFT_Apply_CFFT(HANDLE_IIS_FFT handle, const Complex* input, Complex* output); + +/*! + * \brief deallocate a FFT instance (complex or real) + * \param[in,out] handle pointer to FFT handle, set to NULL if call succeeds + * \return IIS_FFT_NO_ERROR on success + */ +IIS_FFT_ERROR LC3_IIS_xFFT_Destroy(HANDLE_IIS_FFT* handle); + +/*! + * \brief deallocate a real FFT instance + * \param[in,out] handle pointer to FFT handle, set to NULL if call succeeds + * \return IIS_FFT_NO_ERROR on success + */ +IIS_FFT_ERROR LC3_IIS_RFFT_Destroy(HANDLE_IIS_FFT* handle); + +/*! + * \brief deallocate a complex FFT instance + * \param[in,out] handle pointer to FFT handle, set to NULL if call succeeds + * \return IIS_FFT_NO_ERROR on success + */ +IIS_FFT_ERROR LC3_IIS_CFFT_Destroy(HANDLE_IIS_FFT* handle); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/lib_lc3plus/fft/iisfft.c b/lib_lc3plus/fft/iisfft.c new file mode 100644 index 0000000000000000000000000000000000000000..bcd00503fa943c6d991f3e009358008ac4404e31 --- /dev/null +++ b/lib_lc3plus/fft/iisfft.c @@ -0,0 +1,175 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.3 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + + + +#include "options.h" +#include "wmc_auto.h" +#include +#include /* for mmove */ +#include +#include +#include "iisfft.h" +#include "cfft.h" + +/* the fixed length fft functions have been split into sevelral headers to + have smaller files. to give the compiler more room to optimize the ffts + can't be in separate compilation units. the header approach seemed to be + the best compromise. to prevent them being included from anywhere else, + they are guarded by the INCLUDED_FROM_IISFFT_C macro. +*/ +#define INCLUDED_FROM_IISFFT_C +#include "fft_2_9.h" +#include "fft_15_16.h" +#include "fft_32.h" +#include "fft_60_128.h" +#include "fft_240_480.h" +#include "fft_384_768.h" +#include "fft_generic.h" + + +void LC3_iisfft_apply(Iisfft* handle, LC3_FLOAT* x) +{ + if (handle->sign == -1) { + if (!fft_n(x, handle->length)) + { + LC3_FLOAT scratch[2*MAX_LEN]; + pfaDFT(x, handle->length, scratch, handle->num_factors, handle->factors, handle->scratch2, + handle->isPrime); + } + } else { + assert(0); + } +} + +/* returns 1 if there is no specialized function for length or 1 if a scratch needs to be allocated. + check the fft_n function */ +static LC3_INT need_scratch(LC3_INT n) +{ + return n != 2 && n != 3 && n != 4 && n != 5 && n != 7 && n != 8 && n != 9 && n != 15 && n != 16 && n != 32 && + n != 60 && n != 64 && n != 128 && n != 192 && n != 240 && n != 256 && n != 384 && n != 480 && n != 512 && n != 768 && + n != 1024; +} + +IIS_FFT_ERROR LC3_iisfft_plan(Iisfft* handle, LC3_INT length, LC3_INT sign) +{ + memset(handle, 0, sizeof(Iisfft)); + if (length < 2) + { + return IIS_FFT_LENGTH_ERROR; + } + handle->length = length; + handle->sign = sign; + if (need_scratch(length)) { + /* only needed for prime numbers bigger than BORDER_FOR_SECOND_SCRATCH */ + LC3_INT i = 0; + LC3_INT lengthOfPrimeScratch = BORDER_FOR_SECOND_SCRATCH; + if (!factorize(length, &handle->num_factors, handle->factors, handle->isPrime)) + { + return IIS_FFT_LENGTH_ERROR; + } + /* create additional scratch for primeFFT() */ + for (i = 0; i < handle->num_factors; i++) { + if (handle->isPrime[i] == 1 && handle->factors[i] > lengthOfPrimeScratch) { + lengthOfPrimeScratch = handle->factors[i]; + } + } + if (lengthOfPrimeScratch > BORDER_FOR_SECOND_SCRATCH) { + handle->scratch2 = (LC3_INT*)malloc(sizeof(LC3_INT) * lengthOfPrimeScratch); + if (!handle->scratch2) + { + return IIS_FFT_MEMORY_ERROR; + } + } + } + + return IIS_FFT_NO_ERROR; +} + +void LC3_iisfft_free(Iisfft* handle) +{ + handle->length = 0; + if (handle->scratch2) + { + free(handle->scratch2); + } +} + + + +/* generate sine table needed by LC3_rfft_pre/rfft/post. the table must be freed with iisFree */ +void LC3_create_sine_table(LC3_INT32 len, LC3_FLOAT *sine_table) +{ + LC3_INT32 i; + + for (i = 0; i < len / 2 + 1; i++) { + sine_table[i] = (LC3_FLOAT)sin(2.0 * M_PIl * i / len); + } +} + +void LC3_rfft_post(const LC3_FLOAT* restrict sine_table, LC3_FLOAT* restrict buf, LC3_INT32 len) +{ + LC3_FLOAT tmp1, tmp2, tmp3, tmp4, s, c; + LC3_INT32 i; + + tmp1 = buf[0] + buf[1]; + buf[1] = buf[0] - buf[1]; + buf[0] = tmp1; + + for (i = 1; i <= (len + 2) / 4; i++) { + s = sine_table[i]; /* sin(pi*i/(len/2)) */ + c = sine_table[i + len / 4]; /* cos(pi*i/(len/2)) */ + + tmp1 = buf[2 * i] - buf[len - 2 * i]; + tmp2 = buf[2 * i + 1] + buf[len - 2 * i + 1]; + tmp3 = s * tmp1 - c * tmp2; /* real part of j*W(k,N)*[T(k) - T'(N-k)] */ + tmp4 = c * tmp1 + s * tmp2; /* imag part of j*W(k,N)*[T(k) - T'(N-k)] */ + tmp1 = buf[2 * i] + buf[len - 2 * i]; + tmp2 = buf[2 * i + 1] - buf[len - 2 * i + 1]; + + buf[2 * i] = 0.5f * (tmp1 - tmp3); + buf[2 * i + 1] = 0.5f * (tmp2 - tmp4); + buf[len - 2 * i] = 0.5f * (tmp1 + tmp3); + buf[len - 2 * i + 1] = -0.5f * (tmp2 + tmp4); + } + + return; +} + +void LC3_rfft_pre(const LC3_FLOAT* restrict sine_table, LC3_FLOAT* restrict buf, LC3_INT32 len) +{ + LC3_FLOAT scale ; + LC3_FLOAT tmp1, tmp2, tmp3, tmp4, s, c; + LC3_INT32 i; + + scale = 1.0f / len; /* constant */ + + tmp1 = buf[0] + buf[1]; + buf[1] = scale * (buf[0] - buf[1]); + buf[0] = scale * tmp1; + + for (i = 1; i <= (len + 2) / 4; i++) { + s = sine_table[i]; /* sin(pi*i/(len/2)) */ + c = sine_table[i + len / 4]; /* cos(pi*i/(len/2)) */ + + tmp1 = buf[2 * i] - buf[len - 2 * i]; + tmp2 = buf[2 * i + 1] + buf[len - 2 * i + 1]; + tmp3 = s * tmp1 + c * tmp2; /* real part of j*W(k,N)*[T(k) - T'(N-k)] */ + tmp4 = -c * tmp1 + s * tmp2; /* imag part of j*W(k,N)*[T(k) - T'(N-k)] */ + tmp1 = buf[2 * i] + buf[len - 2 * i]; + tmp2 = buf[2 * i + 1] - buf[len - 2 * i + 1]; + + buf[2 * i] = scale * (tmp1 + tmp3); + buf[2 * i + 1] = -scale * (tmp2 + tmp4); + buf[len - 2 * i] = scale * (tmp1 - tmp3); + buf[len - 2 * i + 1] = scale * (tmp2 - tmp4); + } + return; +} + diff --git a/lib_lc3plus/fft/iisfft.h b/lib_lc3plus/fft/iisfft.h new file mode 100644 index 0000000000000000000000000000000000000000..a77a1af7e8169778cecf8ff06844b07cbb87ae03 --- /dev/null +++ b/lib_lc3plus/fft/iisfft.h @@ -0,0 +1,88 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.3 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + + +#ifndef IISFFT_H +#define IISFFT_H + +#include "options.h" +#include "wmc_auto.h" +#include "../defines.h" + +#ifndef M_PIl +#define M_PIl 3.1415926535897932384626433832795029L /* pi */ +#endif + +/* compiler specific macros + + the restrict keyword only gives a improvelent if more than one pointers are + passed to a function. also note that the MSVC __restrict behaves differently + from c99, the restrict property is not transferred to aliases. + + alloca is a bit problematic because behavior is not defined in case of stack + overflow. most probably the program will crash. it might be possible to catch + those errors but it depends on compiler support. msvc has a safer _malloca + but gcc has nothing similar. */ +#if defined _MSC_VER || defined __INTEL_COMPILER +#include +#define ALLOCA(size) _alloca(size) +#define restrict __restrict +#define inline __inline +#elif defined __GNUC__ || defined __clang__ +#define ALLOCA(size) __builtin_alloca(size) +#define restrict __restrict__ +#define inline __inline +#elif defined __TI_COMPILER_VERSION__ +#include +#define ALLOCA(size) (assert(0 && "ALLOCA is not present for your compiler"), NULL) +#warn "no stack allocation for you compiler" +#else +#error "no stack allocation for your compiler" +#endif + + +#define IISFFT_MAXSTACKLENGTH 1024 +#define IISFFT_MAXFACTORS 10 + +typedef struct { + LC3_INT* scratch2; + LC3_INT length; + LC3_INT sign; + LC3_INT num_factors; + LC3_INT factors[IISFFT_MAXFACTORS]; + LC3_INT isPrime[IISFFT_MAXFACTORS]; +} Iisfft; + +typedef enum { + IIS_FFT_NO_ERROR = 0, + IIS_FFT_INTERNAL_ERROR, /**< a mystical error appeard */ + IIS_FFT_LENGTH_ERROR, /**< the requested fft length is not supported */ + IIS_FFT_MEMORY_ERROR /**< memory allocation failed */ +} IIS_FFT_ERROR; + +typedef enum { + IIS_FFT_FWD = -1, /**< forward transform */ + IIS_FFT_BWD = 1 /**< inverse / backward transform */ +} IIS_FFT_DIR; + +/* plan, apply and free forward / backward fft */ +IIS_FFT_ERROR LC3_iisfft_plan(Iisfft* handle, LC3_INT length, LC3_INT sign); +void LC3_iisfft_apply(Iisfft* handle, LC3_FLOAT* x); +void LC3_iisfft_free(Iisfft* handle); + +/* fft related helper functions */ +void LC3_create_sine_table(LC3_INT32 len, LC3_FLOAT *sine_table); + +void LC3_rfft_pre(const LC3_FLOAT* restrict sine_table, LC3_FLOAT* restrict buf, LC3_INT len); +void LC3_rfft_post(const LC3_FLOAT* restrict sine_table, LC3_FLOAT* restrict buf, LC3_INT len); +void LC3_fftf_interleave(const LC3_FLOAT* restrict re, const LC3_FLOAT* restrict im, LC3_FLOAT* restrict out, + LC3_INT len); +void LC3_fftf_deinterleave(const LC3_FLOAT* restrict in, LC3_FLOAT* restrict re, LC3_FLOAT* restrict im, LC3_INT len); + +#endif /* IISFFT_H */ diff --git a/lib_lc3plus/functions.h b/lib_lc3plus/functions.h new file mode 100644 index 0000000000000000000000000000000000000000..01ad936f00d8a34e5a15fd48ce54240fb5592483 --- /dev/null +++ b/lib_lc3plus/functions.h @@ -0,0 +1,351 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.3 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + + +#ifndef FUNCTIONS_H +#define FUNCTIONS_H + +#include "options.h" +#include "wmc_auto.h" +#include "clib.h" +#include "defines.h" +#include "float.h" +#include "lc3.h" +#include "setup_dec_lc3.h" +#include "setup_enc_lc3.h" +#include "structs.h" +#include "util.h" + +/* FFT */ +#include "fft/iisfft.h" + +/* fft.c */ +void real_fft_init(Fft* fft, LC3_INT32 length, HANDLE_IIS_FFT *handle); +void real_ifft_init(Fft* fft, LC3_INT32 length, HANDLE_IIS_FFT *handle); +void real_fft_apply(Fft* fft, const LC3_FLOAT* in, LC3_FLOAT* out); + +void fft_init(Fft* fft, LC3_INT length); +void fft_free(Fft* fft); +void real_fft_free(Fft* fft); +void fft_apply(Fft* fft, const Complex* input, Complex* output); + +/* dct.c */ +void dct2_init(Dct2* dct, LC3_INT length); +void dct2_free(Dct2* dct); +void dct2_apply(Dct2* dct, const LC3_FLOAT* input, LC3_FLOAT* output); + +void dct3_init(Dct3* dct, LC3_INT length); +void dct3_free(Dct3* dct); +void dct3_apply(Dct3* dct, const LC3_FLOAT* input, LC3_FLOAT* output); + +void dct4_init(Dct4* dct, LC3_INT length); +void dct4_free(Dct4* dct); +void dct4_apply(Dct4* dct, const LC3_FLOAT* input, LC3_FLOAT* output); + +/* mdct.c */ +void mdct_init(Mdct* mdct, LC3_INT length, LC3_INT frame_dms, LC3_INT fs_idx, LC3_INT hrmode); +void mdct_free(Mdct* mdct); +void mdct_apply(const LC3_FLOAT* input, LC3_FLOAT* output, Mdct* mdct); + +#ifdef ENABLE_PADDING +LC3_INT paddingDec_fl(LC3_UINT8* bytes, LC3_INT nbbits, LC3_INT L_spec, LC3_INT bw_cutoff_bits, LC3_INT ep_enabled, LC3_INT* total_padding, LC3_INT *np_zero); +#endif + +void processEncoderEntropy_fl(LC3_UINT8* bytes, LC3_INT* bp_side, LC3_INT* mask_side, LC3_INT numbytes, LC3_INT bw_cutoff_bits, + LC3_INT bw_cutoff_idx, LC3_INT lastnz, LC3_INT N, LC3_INT lsbMode, LC3_INT gg_idx, LC3_INT num_tns_filters, + LC3_INT* tns_order, LC3_INT* ltpf_idx, LC3_INT* scf_idx, LC3_INT fac_ns_idx + , LC3_INT bfi_ext, LC3_INT fs_idx + ); +void processDecoderEntropy_fl(LC3_UINT8* bytes, LC3_INT numbytes, LC3_INT* mask_side, LC3_INT* bp_side, LC3_INT N, LC3_INT fs_idx, + LC3_INT bw_cutoff_bits, LC3_INT* bfi, LC3_INT* gg_idx, LC3_INT* scf_idx, LC3_INT* fac_ns_idx, + LC3_INT* tns_numfilters, LC3_INT* tns_order, LC3_INT* ltpf_idx, LC3_INT* bw_cutoff_idx, LC3_INT* lastnz, + LC3_INT* lsbMode, LC3_INT frame_dms + ); +void processQuantizeSpec_fl(LC3_FLOAT x[], LC3_FLOAT gain, LC3_INT xq[], LC3_INT nt, LC3_INT totalBits, LC3_INT* nbits, LC3_INT* nbits2, LC3_INT fs, + LC3_INT* lastnzout, LC3_INT* codingdata, LC3_INT* lsbMode, LC3_INT mode, LC3_INT target, LC3_INT hrmode); + +void processEstimateGlobalGain_fl(LC3_FLOAT x[], LC3_INT lg, LC3_INT nbitsSQ, LC3_FLOAT* gain, LC3_INT* quantizedGain, + LC3_INT* quantizedGainMin, LC3_INT quantizedGainOff, LC3_FLOAT* targetBitsOff, + LC3_INT* old_targetBits, LC3_INT old_specBits, LC3_INT bq_mode + , LC3_INT regBits, LC3_FLOAT frame_ms +); + +void processAriDecoder_fl(LC3_UINT8* bytes, LC3_INT bp_side, LC3_INT mask_side, LC3_INT L_spec, LC3_INT fs_idx, LC3_INT enable_lpc_weighting, + LC3_INT tns_numfilters, LC3_INT lsbMode, LC3_INT lastnz, LC3_INT* bfi, LC3_INT* tns_order, LC3_INT fac_ns_idx, + LC3_INT gg_idx, uint8_t* resBits, LC3_INT* x, LC3_INT* nf_seed, LC3_INT* tns_idx, LC3_INT* zero_frame, LC3_INT numbytes, + LC3_INT* nbits_residual, LC3_INT* residualPresent, LC3_INT frame_dms, + LC3_INT32 n_pc, LC3_INT32 be_bp_left, LC3_INT32 be_bp_right, LC3_INT32 enc, LC3_INT32 *b_left, LC3_INT32 *spec_inv_idx, + LC3_INT hrmode + ); + +void processMdctShaping_fl(LC3_FLOAT x[], LC3_FLOAT gains[], const LC3_INT bands_offset[], LC3_INT fdns_npts); + +void processResidualCoding_fl(LC3_FLOAT x[], LC3_INT xq[], LC3_FLOAT gain, LC3_INT L_spec, LC3_INT targetBits, LC3_INT nBits, uint8_t * resBits, + LC3_INT* numResBits + , LC3_INT hrmode +); + +void processResidualDecoding_fl(LC3_INT* bitsRead, LC3_FLOAT x[], LC3_INT L_spec, uint8_t prm[], LC3_INT resQBits + , LC3_INT hrmode +); + +void processAdjustGlobalGain_fl(LC3_INT* gg_idx, LC3_INT gg_idx_min, LC3_INT gg_idx_off, LC3_FLOAT* gain, LC3_INT target, LC3_INT nBits, + LC3_INT* gainChange, LC3_INT fs_idx + , LC3_INT16 hrmode, LC3_INT16 frame_dms + ); + +void processApplyGlobalGain_fl(LC3_FLOAT x[], LC3_INT xLen, LC3_INT global_gain_idx, LC3_INT global_gain_off); + +void processNoiseFactor_fl(LC3_INT* fac_ns_idx, LC3_FLOAT x[], LC3_INT xq[], LC3_FLOAT gg, LC3_INT BW_cutoff_idx, LC3_INT frame_dms, + LC3_INT target_bytes + ); + +void processNoiseFilling_fl(LC3_FLOAT xq[], LC3_INT nfseed, LC3_INT fac_ns_idx, LC3_INT bw_stopband, LC3_INT frame_dms, LC3_FLOAT fac_ns_pc, LC3_INT spec_inv_idx); + +void processOlpa_fl(LC3_FLOAT* s_12k8, LC3_FLOAT* mem_s12k8, LC3_FLOAT* mem_s6k4, LC3_INT* mem_old_T0, +#ifdef CR9_F_PITCH_WIN_LEN_FIX + LC3_INT* pitch_flag, +#endif + LC3_INT* T0_out,LC3_FLOAT* normcorr_out, LC3_INT len, LC3_INT frame_dms); + +void processTnsCoder_fl(LC3_FLOAT* x, LC3_INT bw_cutoff_idx, LC3_INT bw_fcbin, LC3_INT fs, LC3_INT N, LC3_INT frame_dms, LC3_INT nBits, + LC3_INT* order_out, LC3_INT* rc_idx, LC3_INT* tns_numfilters, LC3_INT* bits_out + , LC3_INT16 near_nyquist_flag + ); +void levinsonDurbin(LC3_FLOAT* r, LC3_FLOAT* out_lev, LC3_FLOAT* rc_unq, LC3_FLOAT* error, LC3_INT len); + +void processTnsDecoder_fl(LC3_FLOAT* x, LC3_INT* rc_idx, LC3_INT* order, LC3_INT numfilters, LC3_INT bw_fcbin, LC3_INT N, LC3_INT fs); + +void processSnsComputeScf_fl(LC3_FLOAT* x, LC3_INT xLen, LC3_FLOAT* gains, LC3_INT smooth, LC3_FLOAT sns_damping, LC3_FLOAT attdec_damping_factor, LC3_INT fs_idx); + +void processSnsInterpolateScf_fl(LC3_FLOAT* gains, LC3_INT encoder_side, LC3_INT bands_number, LC3_FLOAT* gains_LC3_INT); + +void processDetectCutoffWarped_fl(LC3_FLOAT* d2, LC3_INT fs_idx, LC3_INT frame_dms, LC3_INT* bw_idx); +void processNearNyquistdetector_fl(LC3_INT16* near_nyquist_flag, const LC3_INT fs_idx, const LC3_INT near_nyquist_index, + const LC3_INT bands_number, const LC3_FLOAT* ener +#ifdef CR8_E_TONE_DETECTOR + , const LC3_INT16 frame_dms, const LC3_INT16 hrmode ); +#else + ); +#endif +void processPerBandEnergy_fl(LC3_INT bands_number, const LC3_INT* acc_coeff_per_band, LC3_INT16 hrmode, LC3_INT16 frame_dms, LC3_FLOAT* d2, LC3_FLOAT* d); + +void ProcessingIMDCT_fl(LC3_FLOAT* y, LC3_INT yLen, const LC3_FLOAT* win, LC3_INT winLen, LC3_INT last_zeros, LC3_FLOAT* mem, LC3_FLOAT* x, + Dct4* dct); + +void ProcessingITDA_WIN_OLA_fl(LC3_FLOAT* x_tda, LC3_INT32 yLen, const LC3_FLOAT* win, LC3_INT32 winLen, LC3_INT32 last_zeros, LC3_FLOAT* mem, LC3_FLOAT* x); + +void process_ltpf_coder_fl(LC3_FLOAT* xin, LC3_INT xLen, LC3_INT ltpf_enable, LC3_INT pitch_ol, LC3_FLOAT pitch_ol_norm_corr, LC3_INT frame_dms, + LC3_FLOAT* mem_old_x, LC3_INT memLen, LC3_FLOAT* mem_norm_corr_past, LC3_INT* mem_on, LC3_FLOAT* mem_pitch, + LC3_INT* param, LC3_FLOAT* mem_norm_corr_past_past, LC3_INT* bits +#ifdef CR9_K_REDUCE_NORM_CORR_TH + ,LC3_INT16 hrmode +#endif +); + +void process_ltpf_decoder_fl(LC3_FLOAT* x, LC3_INT xLen, LC3_FLOAT* y, LC3_INT fs, LC3_FLOAT* mem_old_x, LC3_FLOAT* mem_old_y, + LC3_INT* mem_pitch_LC3_INT, LC3_INT* mem_pitch_fr, LC3_FLOAT* mem_gain, LC3_INT* mem_beta_idx, LC3_INT bfi, + LC3_INT* param, LC3_INT* mem_param, LC3_INT conf_beta_idx, LC3_FLOAT conf_beta, LC3_INT concealMethod, LC3_FLOAT damping + , LC3_INT *mem_ltpf_active +#ifdef CR9_N_SHORT_FADE_FOR_UNSTABLE_PITCH + , LC3_FLOAT *rel_pitch_change, LC3_INT hrmode, LC3_INT frame_dms +#endif +); + +void process_resamp12k8_fl(LC3_FLOAT x[], LC3_INT x_len, LC3_FLOAT mem_in[], LC3_INT mem_in_len, LC3_FLOAT mem_50[], LC3_FLOAT mem_out[], + LC3_INT mem_out_len, LC3_FLOAT y[], LC3_INT* y_len, LC3_INT fs_idx, LC3_INT frame_dms, LC3_INT fs); + +void write_bit_backward_fl(LC3_UINT8* ptr, LC3_INT* bp_side, LC3_INT* mask_side, LC3_INT bit); +void write_uint_backward_fl(LC3_UINT8* ptr, LC3_INT* bp_side, LC3_INT* mask_side, LC3_INT val, LC3_INT numbits); + +void processAriEncoder_fl(LC3_UINT8* bytes, LC3_INT bp_side, LC3_INT mask_side, LC3_INT* x, LC3_INT* tns_order, LC3_INT tns_numfilters, + LC3_INT* tns_idx, LC3_INT lastnz, + LC3_INT* codingdata, uint8_t* res_bits, LC3_INT resBitsLen, LC3_INT lsbMode, + LC3_INT nbbits, LC3_INT enable_lpc_weighting); + +void attack_detector_fl(LC3_FLOAT* in, LC3_INT frame_size, LC3_INT fs, LC3_INT* lastAttackPosition, LC3_FLOAT* accNrg, LC3_INT* attackFlag, + LC3_FLOAT* attdec_filter_mem, LC3_INT attackHandlingOn, LC3_INT attdec_nblocks, LC3_INT attdec_hangover_threshold); + +void process_snsQuantizesScf_Enc(LC3_FLOAT* env, LC3_INT* index, LC3_FLOAT* envq, Dct2 dct2structSNS); + +void process_snsQuantizesScf_Dec(LC3_INT* scf_idx, LC3_FLOAT* scf_q); + +void processMdct_fl(LC3_FLOAT* in, LC3_FLOAT* out, Mdct* mdctStruct); + +int alloc_encoder(LC3PLUS_Enc* encoder, int channels); +void set_enc_frame_params(LC3PLUS_Enc* encoder); +LC3PLUS_Error update_enc_bitrate(LC3PLUS_Enc* encoder, int bitrate); + +LC3PLUS_Error FillEncSetup(LC3PLUS_Enc* encoder, int samplerate, int channels, int hrmode, int32_t lfe_channel_array[]); + +/* Setup Functions */ +int alloc_decoder(LC3PLUS_Dec* decoder, int samplerate, int channels); +void set_dec_frame_params(LC3PLUS_Dec* decoder); +LC3PLUS_Error update_dec_bitrate(LC3PLUS_Dec* decoder, int ch, int nBytes); + +LC3PLUS_Error FillDecSetup(LC3PLUS_Dec* decoder, int samplerate, int channels, LC3PLUS_PlcMode plc_mode, int hrmode); + +int Enc_LC3PLUS_fl(LC3PLUS_Enc* encoder, void** input, LC3_UINT8* output, int bps +, LC3_INT32 bfi_ext +); +LC3PLUS_Error Dec_LC3PLUS_fl(LC3PLUS_Dec* decoder, LC3_UINT8* input, int input_bytes, void** output, int bps, int bfi_ext); + +void* balloc(void* base, size_t* base_size, size_t size); + +void processPlcMain_fl(LC3_FLOAT *q_d_fl_c, LC3_FLOAT *syntM_fl_c, LC3PLUS_Dec* decoder, DecSetup* h_DecSetup, LC3_INT bfi, + PlcAdvSetup *PlcAdvSetup, PlcSetup *PlcSetup, LC3_INT plcMeth, LC3_INT ltpf_pitch_int, LC3_INT ltpf_pitch_fr, + LC3_INT tilt, const LC3_INT *bands_offset, LC3_INT bands_number, const LC3_INT *bands_offsetPLC, + LC3_INT n_bandsPLC, LC3_INT16 hrmode, pcState *statePC); + +void processPlcUpdate_fl(PlcAdvSetup *PlcAdvSetup, LC3_INT32 frame_length, LC3_FLOAT *syntM, LC3_FLOAT *scf_q, + LC3_INT32 *nbLostCmpt, LC3_FLOAT *cum_alpha, LC3_INT32 bfi, LC3_INT32 *prevBfi, LC3_INT32 *prevprevBfi); + +void processPlcUpdateSpec_fl(LC3_FLOAT *q_d_prev, LC3_FLOAT *q_d_fl_c, LC3_INT yLen); + +void processNoiseSubstitution_fl(LC3_FLOAT* spec, LC3_FLOAT* spec_prev, LC3_INT32 yLen); + +void process_cutoff_bandwidth(LC3_FLOAT* d_fl, LC3_INT len, LC3_INT bw_bin); +void update_enc_bandwidth(LC3PLUS_Enc* encoder, LC3_INT bandwidth); + +/* al_fec.c */ +LC3_INT16 fec_get_n_pccw(LC3_INT16 slot_bytes, LC3_INT16 fec_mode, LC3_INT16 ccc_flag); +LC3_INT16 fec_get_data_size(LC3_INT16 fec_mode, LC3_INT16 ccc_flag, LC3_INT16 slot_bytes); +LC3_INT16 fec_get_n_pc(LC3_INT16 fec_mode, LC3_INT16 n_pccw, LC3_INT16 slot_bytes); +void processReorderBitstream_fl(LC3_UINT8* bytes, LC3_INT32 n_pccw, LC3_INT32 n_pc, LC3_INT32 b_left, LC3_INT32 len); +void fec_encoder(LC3_INT16 mode, LC3_INT16 epmr, LC3_UINT8 *iobuf, LC3_INT16 data_bytes, LC3_INT16 slot_bytes, LC3_INT16 n_pccw); +LC3_INT32 fec_decoder(LC3_UINT8 *iobuf, LC3_INT16 slot_bytes, LC3_INT32 *data_bytes, LC3PLUS_EpModeRequest *epmr, LC3_INT16 ccc_flag, LC3_INT16 *n_pccw, LC3_INT32 *bfi, + LC3_INT16 *be_bp_left, LC3_INT16 *be_bp_right, LC3_INT16 *n_pc, LC3_INT16 *m_fec); + +LC3_FLOAT array_max_abs(LC3_FLOAT *in, LC3_INT32 len); + +void processPcClassify_fl(LC3_INT32 pitch_present, LC3_INT32 frame_dms, LC3_FLOAT *q_d_prev, LC3_FLOAT *q_old_res, LC3_INT32 yLen, LC3_INT32 spec_inv_idx, LC3_FLOAT stab_fac, LC3_INT32 *bfi); +void processPcMain_fl(LC3_INT32 *bfi, LC3PLUS_Dec* decoder, LC3_FLOAT *sqQdec, DecSetup* h_DecSetup, LC3_INT32 pitch_present, LC3_FLOAT stab_fac, LC3_INT32 gg_idx, LC3_INT32 gg_idx_off, LC3_INT32 fac_ns_idx, pcState *statePC, LC3_INT32 spec_inv_idx, LC3_INT32 yLen); +void processPcUpdate_fl(LC3_INT32 bfi, LC3_FLOAT *q_res, LC3_INT32 gg_idx, LC3_INT32 gg_idx_off, LC3_INT32 rframe, LC3_INT32 *BW_cutoff_idx_nf, LC3_INT32 *prev_BW_cutoff_idx_nf, LC3_INT32 fac_ns_idx, LC3_FLOAT *prev_fac_ns, LC3_FLOAT *fac, LC3_FLOAT *q_old_res, LC3_FLOAT *prev_gg, LC3_INT32 spec_inv_idx, LC3_INT32 yLen); +void processPcApply_fl(LC3_FLOAT *q_res, LC3_FLOAT *q_old_res, LC3_FLOAT *q_d_prev, LC3_INT32 spec_inv_idx, LC3_INT32 yLen, LC3_INT32 gg_idx, LC3_INT32 gg_idx_off, LC3_FLOAT *prev_gg, LC3_FLOAT *fac, LC3_INT32 *pc_nbLostCmpt); + +void processPlcClassify_fl(LC3_INT plcMeth, LC3_INT *concealMethod, LC3_INT32 *nbLostCmpt, LC3_INT32 bfi, + LC3_FLOAT *xcorr, LC3_INT32 framelength, LC3_INT32 frame_dms, LC3_INT32 pitch_int, + LC3_INT32 fs, const LC3_INT *band_offsets, LC3_INT32 bands_number, LC3_INT32 tilt, PlcAdvSetup *plcAd + , LC3_INT32 hrmode +); +void processPlcComputeStabFacMain_fl(LC3_FLOAT *scf_q, LC3_FLOAT *old_scf_q, LC3_FLOAT *old_old_scf_q, LC3_INT32 bfi, LC3_INT32 prev_bfi, LC3_INT32 prev_prev_bfi, LC3_FLOAT *stab_fac); + +void processPlcDampingScramblingMain_fl(LC3_INT32 *ns_seed, + LC3_INT32 *pc_seed, LC3_INT32 ns_nbLostCmpt_pc, + LC3_INT32 ns_nbLostCmpt, LC3_FLOAT *stabFac, LC3_FLOAT *cum_fading_slow, LC3_FLOAT *cum_fading_fast, + LC3_FLOAT *spec_prev, LC3_FLOAT *spec, LC3_INT32 spec_inv_idx, LC3_INT32 yLen, LC3_INT32 bfi, + LC3_INT32 frame_dms, LC3_INT32 concealMethod, LC3_INT32 pitch_present_bfi1, LC3_INT32 pitch_present_bfi2, + LC3_FLOAT *cum_fflcAtten +#ifdef CR8_A_PLC_FADEOUT_TUNING + , LC3_UINT8 plc_fadeout_type +#endif + ); + +void processPlcDampingScrambling_fl(LC3_FLOAT *spec, LC3_INT32 yLen, LC3_INT32 nbLostCmpt, LC3_FLOAT *stabFac, LC3_INT32 processDampScramb, + LC3_FLOAT *cum_fflcAtten, LC3_INT32 pitch_present, LC3_INT32 frame_dms, LC3_FLOAT *cum_fading_slow, + LC3_FLOAT *cum_fading_fast, LC3_INT32 *seed, LC3_INT32 spec_inv_idx +#ifdef CR8_A_PLC_FADEOUT_TUNING + , LC3_UINT8 plc_fadeout_type +#endif + ); + +void plc_phEcu_F0_refine_first(LC3_INT32 *plocs, LC3_INT32 n_plocs, LC3_FLOAT *f0est, const LC3_INT32 Xabs_len, + LC3_FLOAT *f0binPtr, LC3_FLOAT *f0gainPtr, const LC3_INT32 nSubm); +void processTdcLpcEstimation_fl(LC3_FLOAT *r, LC3_INT32 fs_idx, LC3_INT32 len, LC3_FLOAT *A, LC3_INT32 frame_dms); + +LC3_FLOAT plc_phEcuSetF0Hz(LC3_INT32 fs, LC3_FLOAT *old_pitchPtr); + +void plc_phEcu_processPLCspec2shape(LC3_INT16 prev_bfi, LC3_INT16 bfi, LC3_FLOAT q_d[], LC3_INT32 yLen, LC3_FLOAT *stPhECU_oold_grp_shape, LC3_FLOAT *stPhECU_old_grp_shape); +void plc_phEcu_LF_peak_analysis(LC3_INT32 *plocs, LC3_INT32 *n_plocs, LC3_FLOAT *f0est, const LC3_FLOAT *Xabs, + LC3_FLOAT *f0binPtr, LC3_FLOAT *f0gainPtr, const LC3_INT32 nSubm); + +void plc_phEcu_F0_refine_first(LC3_INT32 *plocs, LC3_INT32 n_plocs, LC3_FLOAT *f0est, const LC3_INT32 Xabs_len, + LC3_FLOAT *f0binPtr, LC3_FLOAT *f0gainPtr, const LC3_INT32 nSubm); + +LC3_FLOAT plc_phEcu_imax2_jacobsen_mag(const Complex *y, LC3_FLOAT *c_jacobPtr); +LC3_FLOAT plc_phEcu_interp_max(const LC3_FLOAT *y, LC3_INT32 y_len); +void plc_phEcu_fft_spec2_sqrt_approx(const Complex* x, LC3_INT32 x_len, LC3_FLOAT* x_abs); +LC3_INT32 plc_phEcu_pitch_in_plocs(LC3_INT32* plocs, LC3_INT32 n_plocs); +void plc_phEcu_spec_ana(LC3_FLOAT* xfp, LC3_INT32 xfp_len, const LC3_FLOAT* whr, + LC3_FLOAT* pfind_sensPtr, LC3_INT32* plocs, + LC3_INT32* n_plocs, LC3_FLOAT* f0est, Complex* x, LC3_INT32* x_len, + LC3_FLOAT* f0hzLtpBinPtr, LC3_FLOAT* f0gainLtpPtr, LC3_INT32 bw_idx, Fft* PhEcu_Fft); +void plc_phEcu_subst_spec(LC3_INT32* plocs, LC3_INT32 n_plocs, LC3_FLOAT* f0est, LC3_INT32 time_offs, Complex* X, LC3_INT32 X_len, + LC3_FLOAT* mag_chg_gr, LC3_INT32 *seed, LC3_FLOAT* alpha, LC3_FLOAT* beta, LC3_FLOAT* Xavg, + LC3_INT32 t_adv_in, LC3_INT32 Lprot, LC3_INT32 delta_corr, +#ifdef CR8_A_PLC_FADEOUT_TUNING + LC3_INT16 fadeout, /* needed for DC muting */ + LC3_INT16* nonpure_tone_flag_ptr, /* i/o: flag */ +#endif + LC3_FLOAT *corr_phase_dbg, + LC3_FLOAT *X_i_new_re_dbg, LC3_FLOAT *X_i_new_im_dbg); +void plc_phEcu_rec_frame(Complex *X_in, LC3_INT32 xfp_len, LC3_INT32 Lecu, const LC3_FLOAT *whr, const LC3_FLOAT *winMDCT, LC3_INT32 Lprot, + LC3_FLOAT *xfp, LC3_INT32 time_offs, LC3_FLOAT *x_out, + Complex *full_spec_dbg, LC3_FLOAT* ifft_out_dbg, LC3_FLOAT* xsubst_dbg, + LC3_INT32 LA_ZEROS, LC3_INT32 LA, Fft* PhEcu_Ifft + + ); +void plc_phEcu_tba_spect_Xavg(LC3_INT32 fs_idx, LC3_INT32 n_grp, LC3_FLOAT *oold_spec_shape, + LC3_FLOAT *oold_EwPtr, LC3_FLOAT *old_spec_shape, LC3_FLOAT *old_EwPtr, + LC3_FLOAT *gr_pow_left, LC3_FLOAT *gr_pow_right, LC3_FLOAT *Xavg); +void plc_phEcu_tba_per_band_gain(LC3_INT32 n_grp, LC3_FLOAT *gr_pow_left, LC3_FLOAT *gr_pow_right, LC3_FLOAT *trans, LC3_FLOAT *grp_pow_change); +void plc_phEcu_tba_trans_dect_gains(LC3_INT32 burst_len, LC3_INT32 n_grp, LC3_FLOAT *grp_pow_change, + LC3_FLOAT *stPhECU_beta_mute, LC3_FLOAT *stPhECU_mag_chg_1st, + LC3_FLOAT *alpha, LC3_FLOAT *beta, LC3_FLOAT *mag_chg, LC3_FLOAT *ph_dith, LC3_INT32 *tr_dec, + LC3_FLOAT *att_val, LC3_INT32 *attDegreeFrames, + LC3_FLOAT *thresh_dbg +#ifdef CR8_A_PLC_FADEOUT_TUNING + , LC3_UINT8 plc_fadeout_type +#endif + ); +void plc_phEcu_trans_burst_ana_sub(LC3_INT32 fs_idx, LC3_INT32 burst_len, LC3_INT32 n_grp, LC3_FLOAT *oold_spect_shape, + LC3_FLOAT *oold_EwPtr, LC3_FLOAT *old_spect_shape, + LC3_FLOAT *old_EwPtr, LC3_FLOAT *stPhECU_beta_mute, + LC3_FLOAT *stPhECU_mag_chg_1st, LC3_FLOAT *stPhECU_Xavg, LC3_FLOAT *alpha, LC3_FLOAT *beta, LC3_FLOAT *mag_chg, + LC3_INT32 *tr_dec_dbg, LC3_FLOAT *gpc_dbg +#ifdef CR8_A_PLC_FADEOUT_TUNING + , LC3_UINT8 plc_fadeout_type +#endif + ); +void plc_phEcu_hq_ecu( + LC3_FLOAT *f0binPtr, LC3_FLOAT *f0ltpGainPtr, + LC3_FLOAT *xfp, LC3_INT16 prev_bfi, LC3_INT32 *short_flag_prev, + LC3_INT32 fs, LC3_INT32 * time_offs, + Complex *X_sav_m, LC3_INT32 *n_plocs, LC3_INT32 *plocs, LC3_FLOAT *f0est, const LC3_FLOAT *mdctWin, + LC3_FLOAT *env_stabPtr, LC3_INT32 delta_corr, + LC3_FLOAT *pfind_sensPtr, + LC3_INT32 PhECU_LA, LC3_INT32 t_adv, const LC3_FLOAT *winWhr, LC3_FLOAT *oold_grp_shape, + LC3_FLOAT *oold_EwPtr, LC3_FLOAT *old_grp_shape, + LC3_FLOAT *old_EwPtr, + LC3_FLOAT *st_beta_mute, LC3_FLOAT *st_mag_chg_1st, LC3_FLOAT *st_Xavg, LC3_INT32 LA_ZEROS, LC3_FLOAT *x_tda, LC3_FLOAT *xsubst_dbg, Complex *X_out_m_dbg, + LC3_INT32 *seed_dbg, LC3_FLOAT *mag_chg_dbg, LC3_INT32 *tr_dec_dbg, LC3_FLOAT *gpc_dbg, LC3_FLOAT *X_i_new_re_dbg, LC3_FLOAT *X_i_new_im_dbg, LC3_FLOAT *corr_phase_dbg + ,Fft* PhEcu_Fft,Fft* PhEcu_Ifft +#ifdef CR8_A_PLC_FADEOUT_TUNING + , LC3_UINT8 plc_fadeout_type, + LC3_INT16 *nonpure_tone_flag_ptr +#endif +); + +void processTdcPreemphasis_fl(LC3_FLOAT *in, LC3_FLOAT *pre_emph_factor, LC3_INT32 n_bands); + +void processTdcTdac_fl(const LC3_FLOAT *synth_inp, const LC3_FLOAT *win, LC3_INT32 frame_length, LC3_INT32 la_zeroes, LC3_FLOAT *ola_mem); +void processTdcInverseOdft_fl(LC3_FLOAT *in, LC3_INT32 n_bands, LC3_FLOAT *out, LC3_INT32 lpc_order); + +void processTdcApply_fl(const LC3_INT32 pitch_LC3_INT, const LC3_FLOAT *preemphFac, const LC3_FLOAT* A, const LC3_INT32 lpc_order, const LC3_FLOAT* pcmbufHist, const LC3_INT32 max_len_pcm_plc, const LC3_INT32 N, const LC3_INT32 frame_dms, + const LC3_INT32 SampRate, const LC3_INT32 nbLostCmpt, const LC3_INT32 overlap, const LC3_FLOAT *stabFac, LC3_FLOAT harmonicBuf[MAX_PITCH], LC3_FLOAT synthHist[M], + LC3_INT32* fract, LC3_INT16* seed, LC3_FLOAT* gain_c, LC3_FLOAT* alpha, LC3_FLOAT* synth +#ifdef CR9_I_INC_TDC_FADEOUT_LEN + ,LC3_UINT8 plc_fadeout_type +#endif +); +void* balloc(void* base, size_t* base_size, size_t size); + + + +#endif diff --git a/lib_lc3plus/imdct.c b/lib_lc3plus/imdct.c new file mode 100644 index 0000000000000000000000000000000000000000..b2ef8ee9256adc5480d86d512077f83267332312 --- /dev/null +++ b/lib_lc3plus/imdct.c @@ -0,0 +1,103 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.3 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + + +#include "options.h" +#include "wmc_auto.h" +#include "functions.h" + +/* Function expects already flipped window */ +void ProcessingIMDCT_fl(LC3_FLOAT* y, LC3_INT yLen, const LC3_FLOAT* win, LC3_INT winLen, LC3_INT last_zeros, LC3_FLOAT* mem, LC3_FLOAT* x, Dct4* dct) +{ + LC3_FLOAT x_tda[MAX_LEN], x_ov[2 * MAX_LEN]; + LC3_INT i, j; + + /* Flip imdct window up to down */ + i = winLen - 1; + j = 0; + + dct4_apply(dct, y, x_tda); + + move_float(x_ov, &x_tda[yLen / 2], yLen / 2); + + j = yLen / 2; + for (i = 0; i < yLen / 2; i++) { + x_ov[j] = -x_tda[yLen - 1 - i]; + j++; + } + + j = yLen; + for (i = 0; i < yLen / 2; i++) { + x_ov[j] = -x_tda[yLen / 2 - 1 - i]; + j++; + } + + j = yLen + yLen / 2; + for (i = 0; i < yLen / 2; i++) { + x_ov[j] = -x_tda[i]; + j++; + } + + for (i = 0; i < winLen; i++) { + x_ov[i] = x_ov[i] * win[winLen - 1 - i]; + } + + /* Buffer update */ + j = 0; + for (i = last_zeros; i < yLen; i++) { + x_ov[i] = x_ov[i] + mem[j]; + j++; + } + + move_float(&x[0], &x_ov[last_zeros], yLen); + + move_float(&mem[0], &x_ov[yLen + last_zeros], (winLen - (yLen + last_zeros))); +} + +void ProcessingITDA_WIN_OLA_fl(LC3_FLOAT* x_tda, LC3_INT32 yLen, const LC3_FLOAT* win, LC3_INT32 winLen, LC3_INT32 last_zeros, LC3_FLOAT* mem, LC3_FLOAT* x) +{ + LC3_FLOAT x_ov[2 * MAX_LEN]; + LC3_INT32 i, j; + + move_float(x_ov, &x_tda[yLen / 2], yLen / 2); + + j = yLen / 2; + for (i = 0; i < yLen / 2; i++) { + x_ov[j] = -x_tda[yLen - 1 - i]; + j++; + } + + j = yLen; + for (i = 0; i < yLen / 2; i++) { + x_ov[j] = -x_tda[yLen / 2 - 1 - i]; + j++; + } + + j = yLen + yLen / 2; + for (i = 0; i < yLen / 2; i++) { + x_ov[j] = -x_tda[i]; + j++; + } + + for (i = 0; i < winLen; i++) { + x_ov[i] = x_ov[i] * win[winLen - 1 - i]; + } + + /* Buffer update */ + j = 0; + + for (i = last_zeros; i < yLen; i++) { + x[j] = x_ov[i] + mem[j]; + j++; + } + + move_float(&x[j], &x_ov[last_zeros+j], yLen-j); + + move_float(&mem[0], &x_ov[yLen + last_zeros], (winLen - (yLen + last_zeros))); +} diff --git a/lib_lc3plus/lc3.c b/lib_lc3plus/lc3.c new file mode 100644 index 0000000000000000000000000000000000000000..e3f4491d2bad6aa32dd98a9e65448c52f82cb860 --- /dev/null +++ b/lib_lc3plus/lc3.c @@ -0,0 +1,432 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.3 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + + +#include "options.h" +#include "wmc_auto.h" +#include "lc3.h" +#include "defines.h" +#include "functions.h" +#include + +#include "setup_dec_lc3.h" +#include "setup_enc_lc3.h" + +#define RETURN_IF(cond, error) \ + if (cond) \ + return (error) + +/* ensure api header constants are up to date */ +STATIC_ASSERT(LC3PLUS_MAX_SAMPLES >= MAX_LEN); +STATIC_ASSERT(LC3PLUS_MAX_CHANNELS >= MAX_CHANNELS); +STATIC_ASSERT(LC3PLUS_MAX_BYTES >= BYTESBUFSIZE); + +/* misc functions ************************************************************/ + +int lc3plus_version(void) +{ + return LC3PLUS_VERSION; +} + +int lc3plus_channels_supported(int channels) +{ + return channels >= 1 && channels <= MAX_CHANNELS; +} + +int lc3plus_samplerate_supported(int samplerate) +{ + switch (samplerate) + { + case 8000: return 1; + case 16000: return 1; + case 24000: return 1; + case 32000: return 1; + case 44100: return 1; + case 48000: return 1; + case 96000: return 1; + default: break; + } + return 0; +} + +static int lc3plus_plc_mode_supported(LC3PLUS_PlcMode plc_mode) +{ + switch ((int)plc_mode) + { + case LC3PLUS_PLC_ADVANCED: /* fallthru */ + return 1; + default: break; + } + return 0; +} + +static int lc3plus_frame_size_supported(float frame_ms) +{ + switch ((int)(ceil(frame_ms * 10))) + { + case 25: /* fallthru */ + case 50: /* fallthru */ +#ifdef CR8_G_ADD_75MS + case 75: /* fallthru */ +#endif + case 100: return 1; + default: break; + } + return 0; +} + +static int null_in_list(void **list, int n) +{ + while (--n >= 0) + RETURN_IF(list[n] == NULL, 1); + return 0; +} + +/* return pointer to aligned base + base_size, *base_size += size + 4 bytes align */ +void *balloc(void *base, size_t *base_size, size_t size) +{ + uintptr_t ptr = ((uintptr_t)base + *base_size + 3) & ~3; + assert((uintptr_t)base % 4 == 0); /* base must be 4-byte aligned */ + *base_size = (*base_size + size + 3) & ~3; + return (void *)ptr; +} + +int32_t lc3_enc_supported_lfe(void) +{ + return 1; +} + +/* encoder functions *********************************************************/ +LC3PLUS_Error lc3plus_enc_init(LC3PLUS_Enc *encoder, int samplerate, int channels, int hrmode, int32_t lfe_channel_array[]) +{ + int ch = 0; + RETURN_IF(encoder == NULL, LC3PLUS_NULL_ERROR); + RETURN_IF((uintptr_t)encoder % 4 != 0, LC3PLUS_ALIGN_ERROR); + RETURN_IF(!lc3plus_samplerate_supported(samplerate), LC3PLUS_SAMPLERATE_ERROR); + RETURN_IF(!lc3plus_channels_supported(channels), LC3PLUS_CHANNELS_ERROR); + RETURN_IF(samplerate==96000 && hrmode == 0, LC3PLUS_HRMODE_ERROR); + + for (ch = 0; ch < channels; ch++) + { + RETURN_IF(!lc3_enc_supported_lfe() && lfe_channel_array[ch], LC3PLUS_LFE_MODE_NOT_SUPPORTED); + } + + return FillEncSetup(encoder, samplerate, channels, hrmode, lfe_channel_array); /* real bitrate check happens here */ +} + +int lc3plus_enc_get_size(int samplerate, int channels) +{ + RETURN_IF(!lc3plus_samplerate_supported(samplerate), 0); + RETURN_IF(!lc3plus_channels_supported(channels), 0); + return alloc_encoder(NULL, channels); +} + +/* Dummy function for API alignment */ +int lc3plus_enc_get_scratch_size(const LC3PLUS_Enc *encoder) +{ + UNUSED(encoder); + return 0; +} + +int lc3plus_enc_get_input_samples(const LC3PLUS_Enc *encoder) +{ + RETURN_IF(encoder == NULL, 0); + return encoder->frame_length; +} + +int lc3plus_enc_get_num_bytes(const LC3PLUS_Enc *encoder) +{ + RETURN_IF(encoder == NULL, 0); + + return encoder->bitrate * encoder->frame_length / (8 * encoder->fs_in); +} + +int lc3plus_enc_get_real_bitrate(const LC3PLUS_Enc *encoder) +{ + int ch = 0, totalBytes = 0; + int bitrate; + RETURN_IF(encoder == NULL, 0); + RETURN_IF(!encoder->lc3_br_set, LC3PLUS_BITRATE_UNSET_ERROR); + + for (ch = 0; ch < encoder->channels; ch++) + { + totalBytes += encoder->channel_setup[ch]->targetBytes; + } + + bitrate = (totalBytes * 80000.0 + encoder->frame_dms - 1) / encoder->frame_dms; + + if (encoder->fs_in == 44100) + { + int rem = bitrate % 480; + bitrate = ((bitrate - rem) / 480) * 441 + (rem * 441) / 480; + } + + return bitrate; +} + + +LC3PLUS_Error lc3plus_enc_set_bitrate(LC3PLUS_Enc *encoder, int bitrate) +{ + RETURN_IF(encoder == NULL, LC3PLUS_NULL_ERROR); + RETURN_IF(bitrate <= 0, LC3PLUS_BITRATE_ERROR); +#ifndef STRIP_HR_MODE_API + RETURN_IF(encoder->fs_idx == 5 && encoder->hrmode == 0, LC3PLUS_HRMODE_ERROR); +#endif + return update_enc_bitrate(encoder, bitrate); +} + +int lc3plus_enc_get_delay(const LC3PLUS_Enc *encoder) +{ + RETURN_IF(encoder == NULL, 0); + return encoder->frame_length - 2 * encoder->la_zeroes; +} + +LC3PLUS_Error lc3plus_enc_set_frame_dms(LC3PLUS_Enc *encoder, int frame_dms) +{ + RETURN_IF(encoder == NULL, LC3PLUS_NULL_ERROR); + RETURN_IF(!lc3plus_frame_size_supported(frame_dms / 10.0), LC3PLUS_FRAMEMS_ERROR); + RETURN_IF(encoder->lc3_br_set, LC3PLUS_BITRATE_SET_ERROR); + encoder->frame_dms = frame_dms; + encoder->frame_ms = frame_dms / 10.0; + set_enc_frame_params(encoder); + return LC3PLUS_OK; +} + +LC3PLUS_Error lc3plus_enc_set_bandwidth(LC3PLUS_Enc *encoder, int bandwidth) +{ + LC3_INT effective_fs; + RETURN_IF(encoder == NULL, LC3PLUS_NULL_ERROR); +#ifdef ENABLE_HR_MODE_FL_FLAG + RETURN_IF(encoder->hrmode == 1, LC3PLUS_HRMODE_BW_ERROR); +#endif + effective_fs = encoder->fs_in; + if (encoder->bandwidth != bandwidth) { + if (encoder->fs_in > 40000) { + effective_fs = 40000; + } + if ((bandwidth * 2) > effective_fs) { + return LC3PLUS_BW_WARNING; + } + else { + encoder->bandwidth = bandwidth; + encoder->bandwidth_preset = bandwidth; + encoder->bw_ctrl_active = 1; + update_enc_bitrate(encoder, encoder->bitrate); + } + } + return LC3PLUS_OK; +} + + +LC3PLUS_Error lc3plus_enc16(LC3PLUS_Enc* encoder, int16_t** input_samples, void* output_bytes, int* num_bytes +, void *scratch +) +{ + UNUSED(scratch); + return lc3plus_enc_fl(encoder, (void**)input_samples, 16, output_bytes, num_bytes); +} + +LC3PLUS_Error lc3plus_enc24(LC3PLUS_Enc* encoder, int32_t** input_samples, void* output_bytes, int* num_bytes +, void *scratch +) +{ + UNUSED(scratch); + return lc3plus_enc_fl(encoder, (void**)input_samples, 24, output_bytes, num_bytes); +} + + +LC3PLUS_Error lc3plus_enc_fl(LC3PLUS_Enc* encoder, void** input_samples, int bitdepth, void* output_bytes, int* num_bytes) +{ + RETURN_IF(!encoder || !input_samples || !output_bytes || !num_bytes, LC3PLUS_NULL_ERROR); + RETURN_IF(null_in_list(input_samples, encoder->channels), LC3PLUS_NULL_ERROR); + RETURN_IF(bitdepth != 16 && bitdepth != 24, LC3PLUS_ERROR); + *num_bytes = Enc_LC3PLUS_fl(encoder, input_samples, output_bytes, bitdepth + , *num_bytes == -1 + ); + assert(*num_bytes == lc3plus_enc_get_num_bytes(encoder)); + return LC3PLUS_OK; +} + +/* decoder functions *********************************************************/ + +LC3PLUS_Error lc3plus_dec_init(LC3PLUS_Dec* decoder, int samplerate, int channels, LC3PLUS_PlcMode plc_mode, int hrmode) +{ + RETURN_IF(decoder == NULL, LC3PLUS_NULL_ERROR); + RETURN_IF(!lc3plus_samplerate_supported(samplerate), LC3PLUS_SAMPLERATE_ERROR); + RETURN_IF(!lc3plus_channels_supported(channels), LC3PLUS_CHANNELS_ERROR); + RETURN_IF(!lc3plus_plc_mode_supported(plc_mode), LC3PLUS_PLCMODE_ERROR); + RETURN_IF(samplerate==96000 && hrmode == 0, LC3PLUS_HRMODE_ERROR); + return FillDecSetup(decoder, samplerate, channels, plc_mode, hrmode); +} + +int lc3plus_dec_get_size(int samplerate, int channels) +{ + RETURN_IF(!lc3plus_samplerate_supported(samplerate), 0); + RETURN_IF(!lc3plus_channels_supported(channels), 0); + return alloc_decoder(NULL, samplerate, channels); +} + +/* Dummy function for API alignment */ +int lc3plus_dec_get_scratch_size(const LC3PLUS_Dec *decoder) +{ + UNUSED(decoder); + return 0; +} + +LC3PLUS_Error lc3plus_dec_set_frame_dms(LC3PLUS_Dec *decoder, int frame_dms) +{ + RETURN_IF(decoder == NULL, LC3PLUS_NULL_ERROR); + RETURN_IF(!lc3plus_frame_size_supported(frame_dms / 10.0), LC3PLUS_FRAMEMS_ERROR); + RETURN_IF(decoder->plcMeth == 2 && frame_dms != 100, LC3PLUS_FRAMEMS_ERROR); + + decoder->frame_dms = frame_dms; + decoder->frame_ms = frame_dms / 10.0; + set_dec_frame_params(decoder); + return LC3PLUS_OK; +} + +int lc3plus_dec_get_output_samples(const LC3PLUS_Dec* decoder) +{ + RETURN_IF(decoder == NULL, 0); + return decoder->frame_length; +} + +int lc3plus_dec_get_delay(const LC3PLUS_Dec* decoder) +{ + RETURN_IF(decoder == NULL, 0); + return decoder->frame_length - 2 * decoder->la_zeroes; +} + +LC3PLUS_Error lc3plus_dec_fl(LC3PLUS_Dec* decoder, void* input_bytes, int num_bytes, void** output_samples, int bps, int bfi_ext) +{ + RETURN_IF(!decoder || !input_bytes || !output_samples, LC3PLUS_NULL_ERROR); + RETURN_IF(null_in_list((void**)output_samples, decoder->channels), LC3PLUS_NULL_ERROR); + return Dec_LC3PLUS_fl(decoder, input_bytes, num_bytes, output_samples, bps, bfi_ext); +} + +LC3PLUS_Error lc3plus_dec16(LC3PLUS_Dec* decoder, void* input_bytes, int num_bytes, int16_t** output_samples, + void* scratch, + int bfi_ext) +{ + UNUSED(scratch); + return lc3plus_dec_fl(decoder, input_bytes, num_bytes, (void**)output_samples, 16, bfi_ext); +} + +LC3PLUS_Error lc3plus_dec24(LC3PLUS_Dec* decoder, void* input_bytes, int num_bytes, int32_t** output_samples, + void* scratch, + int bfi_ext) +{ + UNUSED(scratch); + return lc3plus_dec_fl(decoder, input_bytes, num_bytes, (void**)output_samples, 24, bfi_ext); +} + +/* memory functions *********************************************************/ + +LC3PLUS_Error lc3plus_enc_free_memory(LC3PLUS_Enc* encoder) +{ + RETURN_IF(!encoder, LC3PLUS_NULL_ERROR); + + lc3plus_free_encoder_structs(encoder); + + return LC3PLUS_OK; +} + +LC3PLUS_Error lc3plus_dec_free_memory(LC3PLUS_Dec* decoder) +{ + RETURN_IF(!decoder, LC3PLUS_NULL_ERROR); + + lc3plus_free_decoder_structs(decoder); + + return LC3PLUS_OK; +} + +LC3PLUS_Error lc3plus_free_encoder_structs(LC3PLUS_Enc* encoder) +{ + int ch = 0; + RETURN_IF(!encoder, LC3PLUS_NULL_ERROR); + + for (ch = 0; ch < encoder->channels; ch++) { + mdct_free(&encoder->channel_setup[ch]->mdctStruct); + dct2_free(&encoder->channel_setup[ch]->dct2StructSNS); + } + + return LC3PLUS_OK; +} + +LC3PLUS_Error lc3plus_free_decoder_structs(LC3PLUS_Dec* decoder) +{ + int ch = 0; + RETURN_IF(!decoder, LC3PLUS_NULL_ERROR); + + for (ch = 0; ch < decoder->channels; ch++) { + dct4_free(&decoder->channel_setup[ch]->dct4structImdct); + real_fft_free(&decoder->channel_setup[ch]->PlcAdvSetup->PlcPhEcuSetup.PhEcu_Fft); + real_fft_free(&decoder->channel_setup[ch]->PlcAdvSetup->PlcPhEcuSetup.PhEcu_Ifft); + } + + return LC3PLUS_OK; +} + + +LC3PLUS_EpModeRequest lc3plus_dec_get_ep_mode_request(const LC3PLUS_Dec *decoder) +{ + RETURN_IF(decoder == NULL, LC3PLUS_EPMR_ZERO); + return (LC3PLUS_EpModeRequest)decoder->epmr; +} + +int lc3plus_dec_get_error_report(const LC3PLUS_Dec *decoder) +{ + RETURN_IF(decoder == NULL, 0); + return decoder->error_report == 2047 ? -1 : decoder->error_report & 0x07FF; +} + +LC3PLUS_Error lc3plus_enc_set_ep_mode(LC3PLUS_Enc *encoder, LC3PLUS_EpMode epmode) +{ + LC3PLUS_EpMode oldEpmode; + LC3PLUS_Error error; + RETURN_IF(encoder == NULL, LC3PLUS_NULL_ERROR); + RETURN_IF((unsigned)epmode > LC3PLUS_EP_HIGH, LC3PLUS_EPMODE_ERROR); + oldEpmode = encoder->epmode; + encoder->epmode = epmode; + error = encoder->lc3_br_set ? update_enc_bitrate(encoder, encoder->bitrate) : LC3PLUS_OK; + if (error != LC3PLUS_OK) + { + encoder->epmode = oldEpmode; // preserve old epmode in case of failure + } + return error; +} + +LC3PLUS_Error lc3plus_enc_set_ep_mode_request(LC3PLUS_Enc *encoder, LC3PLUS_EpModeRequest epmr) +{ + RETURN_IF(encoder == NULL, LC3PLUS_NULL_ERROR); + RETURN_IF((unsigned)epmr > LC3PLUS_EPMR_HIGH, LC3PLUS_EPMODE_ERROR); + encoder->epmr = epmr; + return LC3PLUS_OK; +} + +LC3PLUS_Error lc3plus_dec_set_ep_enabled(LC3PLUS_Dec *decoder, int32_t ep_enabled) +{ + RETURN_IF(decoder == NULL, LC3PLUS_NULL_ERROR); + decoder->ep_enabled = ep_enabled != 0; + decoder->epmr = LC3PLUS_EPMR_ZERO; + return LC3PLUS_OK; +} + +int lc3plus_dec_get_epok_flags(const LC3PLUS_Dec *decoder) +{ + RETURN_IF(decoder == NULL, 0); + return decoder->error_report >> 11; +} + +#ifndef STRIP_ERROR_PROTECTION_API_FL +#endif /* STRIP_ERROR_PROTECTION_API_FL */ + +#ifndef STRIP_ERROR_PROTECTION_API_FL +#endif /* STRIP_ERROR_PROTECTION_API_FL */ + diff --git a/lib_lc3plus/lc3.h b/lib_lc3plus/lc3.h new file mode 100644 index 0000000000000000000000000000000000000000..fab259e96d15c968413876b3b1797c82b76e91c5 --- /dev/null +++ b/lib_lc3plus/lc3.h @@ -0,0 +1,519 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.3 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + + +/*! \file lc3.h + * This header provides the API for LC3plus. + * + * This library is targeting devices with extreme memory limitations, so memory management + * must be handeled by the user. This includes allocating memory for the structs. The structs are persistent + * between function calls. + * + * The amount of memory needed for various configurations can be obtained from the lc3plus_*_get_size + * function. The LC3PLUS_*_MAX_SIZE macro can be used for all configurations. + * + * Depending on the build configuration some functions might not be available. + */ + +#ifndef LC3PLUS_H +#define LC3PLUS_H + +#ifndef _MSC_VER +#include "options.h" +#include "wmc_auto.h" +#include +#else +typedef unsigned char uint8_t; +typedef __int16 int16_t; +typedef __int32 int32_t; +#endif + +/*! Construct version number from major/minor/micro values. */ +#define LC3PLUS_VERSION_INT(major, minor, micro) (((major) << 16) | ((minor) << 8) | (micro)) + +/*! Version number to ensure header and binary are matching. */ +#define LC3PLUS_VERSION LC3PLUS_VERSION_INT(1, 7, 2) + +/*! Maximum number of supported channels. The actual binary might support + * less, use lc3plus_channels_supported() to check. */ +#define LC3PLUS_MAX_CHANNELS 2 + +/*! Maximum number of samples per channel that can be stored in one LC3plus frame. + */ +#define LC3PLUS_MAX_SAMPLES 960 + +/*! Maximum number of bytes of one LC3plus frame. */ +#define LC3PLUS_MAX_BYTES 1250 + +/*! Maximum size needed to store encoder state. */ +#define LC3PLUS_ENC_MAX_SIZE 20392 + +/*! Maximum size needed to store decoder state. */ +#define LC3PLUS_DEC_MAX_SIZE 87528 + +/*! Error codes returned by functions. */ +typedef enum +{ + LC3PLUS_PLC_ADVANCED = 1 /*!< Enhanced concealment method */ +} LC3PLUS_PlcMode; + +/*! Error protection mode. LC3PLUS_EP_ZERO differs to LC3PLUS_EP_OFF in that + * errors can be detected but not corrected. */ +typedef enum +{ + LC3PLUS_EP_OFF = 0, /*!< Error protection is disabled */ + LC3PLUS_EP_ZERO = 1, /*!< Error protection with 0 bit correction */ + LC3PLUS_EP_LOW = 2, /*!< Error protection correcting one symbol per codeword */ + LC3PLUS_EP_MEDIUM = 3, /*!< Error protection correcting two symbols per codeword */ + LC3PLUS_EP_HIGH = 4 /*!< Error protection correcting three symbols per codeword */ +} LC3PLUS_EpMode; + +/*! Error protection mode request. On the encoder sidem, LC3PLUS_EPMR_ZERO to LC3PLUS_EPMR_HIGH + * can be set. The decoder returns mode requests with different confidences. */ +typedef enum +{ + LC3PLUS_EPMR_ZERO = 0, /*!< Request no error correction. High confidence if returned by decoder. */ + LC3PLUS_EPMR_LOW = 1, /*!< Request low error correction. High confidence if returned by decoder. */ + LC3PLUS_EPMR_MEDIUM = 2, /*!< Request medium error correction. High confidence if returned by decoder. */ + LC3PLUS_EPMR_HIGH = 3, /*!< Request high error correction. High confidence if returned by decoder. */ + LC3PLUS_EPMR_ZERO_MC = 4, /*!< No error correction requested, medium confidence. */ + LC3PLUS_EPMR_LOW_MC = 5, /*!< Low error correction requested, medium confidence. */ + LC3PLUS_EPMR_MEDIUM_MC = 6, /*!< Medium error correction requested, medium confidence. */ + LC3PLUS_EPMR_HIGH_MC = 7, /*!< High error correction requested, medium confidence. */ + LC3PLUS_EPMR_ZERO_NC = 8, /*!< No error correction requested, unvalidated. */ + LC3PLUS_EPMR_LOW_NC = 9, /*!< Low error correction requested, unvalidated. */ + LC3PLUS_EPMR_MEDIUM_NC = 10, /*!< Medium error correction requested, unvalidated. */ + LC3PLUS_EPMR_HIGH_NC = 11 /*!< High error correction requested, unvalidated. */ +} LC3PLUS_EpModeRequest; + +/*! Error codes returned by functions. */ +typedef enum +{ + LC3PLUS_OK = 0, /*!< No error occurred */ + LC3PLUS_ERROR = 1, /*!< Function call failed */ + LC3PLUS_DECODE_ERROR = 2, /*!< Frame failed to decode and was concealed */ + LC3PLUS_NULL_ERROR = 3, /*!< Pointer argument is null */ + LC3PLUS_SAMPLERATE_ERROR = 4, /*!< Invalid samplerate value */ + LC3PLUS_CHANNELS_ERROR = 5, /*!< Invalid channels value */ + LC3PLUS_BITRATE_ERROR = 6, /*!< Invalid bitrate value */ + LC3PLUS_NUMBYTES_ERROR = 7, /*!< Invalid num_bytes value */ + LC3PLUS_EPMODE_ERROR = 8, /*!< Invalid plc_method value */ + LC3PLUS_FRAMEMS_ERROR = 9, /*!< Invalid epmode value */ + LC3PLUS_ALIGN_ERROR = 10, /*!< Invalid frame_ms value */ + LC3PLUS_HRMODE_ERROR = 11, /*!< Unaligned pointer */ + LC3PLUS_BITRATE_UNSET_ERROR = 12, /*!< Invalid epmr value */ + LC3PLUS_BITRATE_SET_ERROR = 13, /*!< Invalid usage of hrmode, sampling rate and frame size */ + LC3PLUS_HRMODE_BW_ERROR = 14, /*!< Function called before bitrate has been set */ + LC3PLUS_PLCMODE_ERROR = 15, /*!< Function called after bitrate has been set */ + LC3PLUS_EPMR_ERROR = 16, /*!< Invalid external bad frame index */ + LC3PLUS_PADDING_ERROR = 17, /*!< Incorrect padding value */ + FRAMESIZE_ERROR = 18, /*!< Incorrect frame size during decoding */ + LC3PLUS_LFE_MODE_NOT_SUPPORTED = 19, /*!< LFE support not available */ + + /* START WARNING */ + LC3PLUS_WARNING = 20, + LC3PLUS_BW_WARNING = 21 /*!< Invalid bandwidth cutoff frequency */ + +} LC3PLUS_Error; + +typedef struct LC3PLUS_Enc LC3PLUS_Enc; /*!< Opaque encoder struct. */ +typedef struct LC3PLUS_Dec LC3PLUS_Dec; /*!< Opaque decoder struct. */ + +/*! \addtogroup Misc + * \{ */ + +/*! Test LFE mode support. + * + * Tests the support of the LFE mode. + * + * \return 1 for true, 0 for false. + */ +int32_t lc3_enc_supported_lfe(void); + +/*! Return library version number. It should match LC3PLUS_VERSION. */ +int lc3plus_version(void); + +/*! Tests if the library supports number of channels. + * + * \param[in] channels Number of channels. + * \return 1 for true, 0 for false. + */ +int lc3plus_channels_supported(int channels); + +/*! Tests if the library supports a sampling rate. + * + * \param[in] samplerate Sampling rate + * \return 1 for true, 0 for false + */ +int lc3plus_samplerate_supported(int samplerate); + +/*! \} + * \addtogroup Encoder + * \{ */ + +/*! + * Initialize LC3plus encoder. + * + * This function is used to fill a user-allocated encoder struct. This is typically + * called once for a samplerate / channel configuration. After init and before encoding + * the first frame you must call lc3plus_enc_set_bitrate(). + * + * \param[out] encoder Pointer to allocated encoder memory. It must have a size provided + * by lc3plus_enc_get_size() for matching samplerate / channels + * configuration or LC3PLUS_ENC_MAX_SIZE. + * \param[in] channels Number of channels. + * \param[in] samplerate Input sampling rate. Allowed sampling rates are: + * 8000, 16000, 24000, 32000, 44100, 48000 + * \param[in] hrmode High resolution mode. + * \return LC3PLUS_OK on success or appropriate error code. + */ +LC3PLUS_Error lc3plus_enc_init(LC3PLUS_Enc* encoder, int samplerate, int channels, int hrmode, int32_t lfe_channel_array[]); + +/*! + * Encode LC3plus frame with 16 bit input. + * + * Each call consumes a fixed number of samples. The number of input samples + * can be obtained from lc3plus_enc_get_input_samples(). + * Scratch parameter only works as dummy parameter to align fixed-point and floating-point APIs + * + * \param[in] encoder Encoder handle initialized by lc3plus_enc_init(). + * \param[in] input_samples Input samples. The left channel is stored in input_samples[0], + * the right channel in input_samples[1]. The input is not changed + * by the encoder. + * \param[out] output_bytes Output buffer. It must have a at least lc3plus_enc_get_num_bytes() + * or at most LC3PLUS_MAX_BYTES. + * \param[out] num_bytes Number of bytes written to output_bytes. + * \param scratch See comment above. + * \return LC3PLUS_OK on success or appropriate error code. + */ +LC3PLUS_Error lc3plus_enc16(LC3PLUS_Enc* encoder, int16_t** input_samples, void* output_bytes, int* num_bytes +, void *scratch +); + +/*! Encode LC3plus frame with 24 bit input. + * + * The input samples are expected to be 24-bit values, sign-extended to 32-bit. + * See lc3plus_enc16() for parameter documentation. + */ +LC3PLUS_Error lc3plus_enc24(LC3PLUS_Enc* encoder, int32_t** input_samples, void* output_bytes, int* num_bytes +, void *scratch +); + +/*! + * Internal function. Use lc3plus_enc16() or lc3plus_enc24() for encoding. + */ + +LC3PLUS_Error lc3plus_enc_fl(LC3PLUS_Enc* encoder, void** input_samples, int bitdepth, void* output_bytes, int* num_bytes); + +/*! Get the size of the LC3plus encoder struct for a samplerate / channel + * configuration. If memory is not restricted LC3PLUS_ENC_MAX_SIZE can be used for + * all configurations. + * + * \param[in] samplerate Sampling rate. + * \param[in] channels Number of channels. + * \return Size in bytes or 0 on error. + */ +int lc3plus_enc_get_size(int samplerate, int channels); + +/*! Dummy function as no scratch management available in floating-point code. Returns always zero. Used to align fixed-point and floating-point APIs. + * + * \param[in] encoder Encoder handle. + * \return Size in bytes or 0 on error. + */ +int lc3plus_enc_get_scratch_size(const LC3PLUS_Enc *encoder); + +/*! Get number of samples per channel expected by lc3plus_enc16() or lc3plus_enc24(). + * + * \param[in] encoder Encoder handle. + * \return Number of samples or 0 on error. + */ +int lc3plus_enc_get_input_samples(const LC3PLUS_Enc* encoder); + +/*! Get real internal bitrate of the encoder. It might differ from the requested + * bitrate due to 44.1 kHz input. + * + * \param[in] encoder Encoder handle. + * \return Bitrate in bits per second or 0 on error. + */ +int lc3plus_enc_get_real_bitrate(const LC3PLUS_Enc* encoder); + +/*! Get the maximum number of bytes produced by lc3plus_enc16() or lc3plus_enc24() for the current + * bitrate. It should be equal to the num_bytes output of lc3plus_enc16/24(). + * + * \param[in] encoder Encoder handle. + * \return Size in bytes or 0 on error. + */ +int lc3plus_enc_get_num_bytes(const LC3PLUS_Enc *encoder); + +/*! Set encoder bitrate for all channels. + * This function must be called at least once before encoding the first frame, but + * after other configuration functions such as lc3plus_enc_set_frame_ms(). + * + * Recommended bitrates for input sampling rates with 10 ms framing: + * kHz | kbps + * --------|----- + * 8 | 24 + * 16 | 32 + * 24 | 48 + * 32 | 64 + * 44.1/48 | 80(voice) 128(music) + * 96 | 128 + * + * \param[in] encoder Encoder handle. + * \param[in] bitrate Bitrate in bits per second. + * \return LC3PLUS_OK on success or appropriate error code. + */ +LC3PLUS_Error lc3plus_enc_set_bitrate(LC3PLUS_Enc* encoder, int bitrate); + +/*! Get the encoder delay in number of samples. + * + * \param[in] encoder Encoder handle. + * \return Encoder in samples or 0 on error. + */ +int lc3plus_enc_get_delay(const LC3PLUS_Enc *encoder); + +/*! Set the frame length for LC3plus decoder in deci milliseconds. + * Not all lengths may be enabled, in that case LC3PLUS_FRAMEMS_ERROR is returned. + * This only works correcly if the encoder was configured with the same vale. + * + * \param[in] decoder Decoder handle. + * \param[in] frame_ms Frame length in ms. + * \return LC3PLUS_OK on success or appropriate error code. + */ +LC3PLUS_Error lc3plus_enc_set_frame_dms(LC3PLUS_Enc *encoder, int frame_ms); + + +/*! Set encoder Low-frequency effect moded. deactivates LTPF, TNS, NF + * + * \param[in] encoder Encoder handle. + * \param[in] lfe LFE mode flag + * \return LC3PLUS_OK on success or appropriate error code. + */ +LC3PLUS_Error lc3plus_enc_set_lfe(LC3PLUS_Enc* encoder, int lfe); + +/*! Free memory allocated within LC3plus encoder struct. + * + * \param[in] encoder Encoder handle. + * \return LC3PLUS_OK on success or appropriate error code. + */ +LC3PLUS_Error lc3plus_enc_free_memory(LC3PLUS_Enc* encoder); + +/*! Set encoder bandwidth to a different value. All frequency bins above the cutoff + * frequency are cut off. Allowed frequencies are: 4 kHz, 8 kHz, 12 kHz, 16 kHz and 24 kHz. + * + * \param[in] encoder Encoder handle. + * \param[in] bandwidth Cutoff Frequency in Hz + * \return LC3PLUS_OK on success or appropriate error code. + */ +LC3PLUS_Error lc3plus_enc_set_bandwidth(LC3PLUS_Enc *encoder, int bandwidth); + +/*! Internal function called by lc3plus_enc_free_memory. + * + * \param[in] encoder Encoder handle. + * \return LC3PLUS_OK on success or appropriate error code. + */ +LC3PLUS_Error lc3plus_free_encoder_structs(LC3PLUS_Enc* encoder); + +/*! Sets error protection mode request transmitted in each channel encoded frame. + * The channel coder includes an error protection mode request (EPMR) in every frame. + * The EPMR takes value 0, 1, 2, and 3 which request ep modes 1, 2, 3, and 4 from the + * decoding device. The EPMR can be retrieved from the channel decoder via the interface + * routine lc3plus_dec_get_ep_mode_request(). + * + * \param[in] encoder Encoder handle. + * \param[in] epmr Error Protection Mode Request + * \return LC3PLUS_OK on success or appropriate error code. + */ +LC3PLUS_Error lc3plus_enc_set_ep_mode_request(LC3PLUS_Enc *encoder, LC3PLUS_EpModeRequest epmr); + +/*! Set error protection mode. The default is LC3PLUS_EP_OFF. It is possible to switch between + * different modees during encoding. Dynamic switching is only allowed between LC3PLUS_EP_ZERO, + * LC3PLUS_EP_LOW, LC3_EP_MEDIUM, and LC3PLUS_EP_HIGH. The the decoder must be notified with + * lc3plus_dec_set_ep_enabled() to expect protected data if epmode is other than LC3PLUS_EP_OFF. + * + * \param[in] encoder Encoder handle. + * \param[in] epmode Error protection mode. + * \return LC3PLUS_OK on success or appropriate error code. + */ +LC3PLUS_Error lc3plus_enc_set_ep_mode(LC3PLUS_Enc *encoder, LC3PLUS_EpMode epmode); + +/*! \} + * \addtogroup Decoder + * \{ */ + +/*! + * Initialize LC3plus decoder. + * + * This function is used to fill a user-allocated decoder struct. This is + * typically called once for a samplerate / channel configuration. + * + * The samplerate and channel arguments must have the same values that were + * used for encoding. LC3plus does not provide a signalling scheme, transporting + * these values is the responsibility of the application. + * + * \param[out] decoder Pointer to decoder memory. It must have as size + * of least lc3plus_dec_get_size() or at most LC3PLUS_DEC_MAX_SIZE. + * \param[in] samplerate Bitstream sampling rate. \param[in] channels Bitstream + * number of channels. + * + * \return LC3PLUS_OK on success or appropriate error code. + */ +LC3PLUS_Error lc3plus_dec_init(LC3PLUS_Dec* decoder, int samplerate, int channels, LC3PLUS_PlcMode plc_mode, int hrmode); + + + +/*! + * Decode compressed LC3plus frame to 16 bit PCM output. + * + * Each call decodes a fixed number of samples. Use lc3plus_dec_get_output_samples() to obtain this + * number. When the input is corrupted and can not be decoded, LC3PLUS_DECODE_ERROR is returned and + * packet loss concealment is applied, so the output is still usable. + * If error protection is enabled and the errors can be corrected the frame is corrected and + * normally decoded. Use lc3plus_dec_get_error_report() to check if errors were corrected. + * + * \param[in] decoder Decoder initialized by lc3plus_dec_init(). + * \param[in] input_bytes Input bytes. If error protection is enabled the input bytes can be + * altered when error correction is applied. This is why this buffer + * must be writable. + * \param[in] num_bytes Number of valid bytes in input_bytes. To signal a lost frame and + * generate concealment output this value must be set to 0. + * \param[out] output_samples Array of pointers to output channel buffers. Each channel buffer + * should provide enough space to hold at most LC3PLUS_MAX_SAMPLES. The + * left channel is stored in output_samples[0], the right channel in + * output_samples[1]. + * \param scratch Scratch parameter only works as dummy parameter to align fixed-point and floating-point APIs + * \return Returns LC3PLUS_OK on success or appropriate error code. Note there is + * a special case for LC3PLUS_DECODE_ERROR where the output is still valid. + */ +LC3PLUS_Error lc3plus_dec16(LC3PLUS_Dec* decoder, void* input_bytes, int num_bytes, int16_t** output_samples, + void* scratch, + int bfi_ext); + +/*! Decode compressed LC3plus frame to 24 bit PCM output. + * + * The output samples are 24-bit values, sign-extended to 32-bit. + * See lc3plus_dec16() for parameter documentation. + */ +LC3PLUS_Error lc3plus_dec24(LC3PLUS_Dec* decoder, void* input_bytes, int num_bytes, int32_t** output_samples, + void* scratch, + int bfi_ext); + +/* Internal function */ + LC3PLUS_Error lc3plus_dec_fl(LC3PLUS_Dec* decoder, void* input_bytes, int num_bytes, void** output_samples, int bps, int bfi_ext); + +/*! Get the size of the LC3plus decoder struct for a samplerate / channel + * configuration. If memory is not restricted LC3PLUS_DEC_MAX_SIZE can be used for + * all configurations. + * + * \param[in] channels Number of channels. + * \param[in] samplerate Sampling rate. + * \return Size in bytes or 0 on error. + */ +int lc3plus_dec_get_size(int samplerate, int channels); + +/*! Dummy function as no scratch management available in floating-point code. Returns always zero. Used to align fixed-point and floating-point APIs. + * + * \param[in] decoder Decoder handle. + * \return Size in bytes or 0 on error. + */ +int lc3plus_dec_get_scratch_size(const LC3PLUS_Dec *decoder); + +/*! Get the number of samples per channel produced by lc3plus_dec16() or lc3plus_dec24. + * + * \param[in] decoder Decoder handle. + * \return Number of samples or 0 on error. + */ +int lc3plus_dec_get_output_samples(const LC3PLUS_Dec* decoder); + +/*! Get the decoder delay in number of samples. + * + * \param[in] decoder Decoder handle. + * \return Delay in samples or 0 on error. + */ +int lc3plus_dec_get_delay(const LC3PLUS_Dec* decoder); + +/*! Set the frame length for LC3plus encoder in deci milliseconds. + * Not all lengths may be enabled, in that case LC3PLUS_FRAMEMS_ERROR is returned. + * This function must be called before lc3plus_enc_set_bitrate(). The decoder must be + * configured with lc3plus_dec_set_frame_dms() with the same value. + * + * \param[in] encoder Encoder handle. + * \param[in] frame_ms Frame length in ms. + * \return LC3PLUS_OK on success or appropriate error code. + */ +LC3PLUS_Error lc3plus_dec_set_frame_dms(LC3PLUS_Dec *decoder, int frame_ms); + + +/*! Free memory allocated within LC3plus decoder struct. + * + * \param[in] decoder Decoder handle. + * \return LC3PLUS_OK on success or appropriate error code. + */ +LC3PLUS_Error lc3plus_dec_free_memory(LC3PLUS_Dec* decoder); + +/*! Internal function called by lc3plus_dec_free_memory. + * + * \param[in] decoder Decoder handle. + * \return LC3PLUS_OK on success or appropriate error code. + */ +LC3PLUS_Error lc3plus_free_decoder_structs(LC3PLUS_Dec* decoder); + +/*! Enable or disable error protection. Default value is 0 (disabled). If error protection is + * enabled, the decoder expects that the frames were encoded with error protection mode + * LC3PLUS_EP_ZERO or higher. + * + * \param[in] decoder Decoder handle. + * \param[in] ep_enabled 1 (or any nonzero) for true, 0 for false. + * \return LC3PLUS_OK on success or appropriate error code. + */ +LC3PLUS_Error lc3plus_dec_set_ep_enabled(LC3PLUS_Dec *decoder, int ep_enabled); + +/*! Retrieves the error protection mode reqeust from channel decoder. + * + * The return value encodes both the error protection mode request (EPMR) + * and the confidence of the method by which it was retrieved. + * + * The requested error protection mode is (epmr % 4) + 1, where epmr is the + * function's return value. The confidence is specified as follows. + * + * Confidence | Range + * -----------|------------- + * high | 0 <= epmr < 4 + * medium | 4 <= epmr < 8 + * no | 8 <= epmr < 12 + * + * When receiving stereo content of separately channel encoded audio frames the + * return value is the minimum of two values retrieved from the individual channels. + * + * \param[in] decoder Decoder handle. + * \return Error protection mode reqeust. + */ +LC3PLUS_EpModeRequest lc3plus_dec_get_ep_mode_request(const LC3PLUS_Dec *decoder); + +/*! Get the number of corrected bit errors in the last decoded frame. This only works if + * error protection is active. If the number of errors is greater than the current error + * protection mode can correct, -1 is returned. If the last frame had no errors or the + * decoder handle is NULL, 0 is returned, + * + * \param[in] decoder Decoder handle. + * \return Number of corrected bits or -1. See description for details. + */ +int lc3plus_dec_get_error_report(const LC3PLUS_Dec *decoder); +/*! This function returns an set of flags indicating whether the last frame + * would have been channel decodable in epmode m, m ranging from 1 to 4. Note that + * this information is not available in case the last frame was not channel + * decodable in which case the return value is 0. If the last frame would have + * been decodable in epmode m, m-1th of the return value will be 1. + * Otherwise, if the frame would not have been decodable or if this information + * cannot be retrieved, the m-1th bit of the return value will be 0. + */ +int lc3plus_dec_get_epok_flags(const LC3PLUS_Dec *decoder); + +/*! \} */ +#endif /* LC3plus */ diff --git a/lib_lc3plus/lc3plus_fft.c b/lib_lc3plus/lc3plus_fft.c new file mode 100644 index 0000000000000000000000000000000000000000..c7911b92dd5a2b82bc9e69b4499c8fb6da7da883 --- /dev/null +++ b/lib_lc3plus/lc3plus_fft.c @@ -0,0 +1,101 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.3 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + + +#include "options.h" +#include "wmc_auto.h" +#include "functions.h" +#include "fft/iis_fft.c" +#include "fft/iisfft.c" +#include "fft/cfft.c" + +void fft_init(Fft* fft, int length) +{ + HANDLE_IIS_FFT handle = NULL; + IIS_FFT_ERROR error = 0; + assert(length % 2 == 0); + + fft->length = length; + + error = LC3_IIS_CFFT_Create(&handle, length, IIS_FFT_FWD); + + assert(error == IIS_FFT_NO_ERROR); + fft->handle = handle; +} + +void fft_free(Fft* fft) +{ + IIS_FFT_ERROR error = 0; + + if (fft) { + error = LC3_IIS_CFFT_Destroy((HANDLE_IIS_FFT *) &fft->handle); + + assert(error == IIS_FFT_NO_ERROR); + memset(fft, 0, sizeof(*fft)); + } +} + +void real_fft_free(Fft* fft) +{ + IIS_FFT_ERROR error = 0; + + if (fft) { + error = LC3_IIS_RFFT_Destroy((HANDLE_IIS_FFT *) &fft->handle); + + assert(error == IIS_FFT_NO_ERROR); + memset(fft, 0, sizeof(*fft)); + } +} + +void real_fft_init(Fft* fft, LC3_INT32 length, HANDLE_IIS_FFT *handle) +{ + IIS_FFT_ERROR error = IIS_FFT_NO_ERROR; + assert(length % 4 == 0); /* due to current limitation of core complex FFTs*/ + + fft->length = length; + + error = LC3_IIS_RFFT_Create(handle, length, IIS_FFT_FWD); + assert(error == IIS_FFT_NO_ERROR); + fft->handle = *handle; +} + + +void real_ifft_init(Fft* fft, LC3_INT32 length, HANDLE_IIS_FFT *handle) +{ + IIS_FFT_ERROR error = IIS_FFT_NO_ERROR; + assert(length % 4 == 0); /* due to current limitation of core complex FFTs*/ + + fft->length = length; + + error = LC3_IIS_RFFT_Create(handle, length, IIS_FFT_BWD); + + assert(error == IIS_FFT_NO_ERROR); + fft->handle = *handle; +} + +void fft_apply(Fft* fft, const Complex* input, Complex* output) +{ + IIS_FFT_ERROR error = 0; + error = LC3_IIS_FFT_Apply_CFFT(fft->handle, input, output); + + assert(error == IIS_FFT_NO_ERROR); +} + + +void real_fft_apply(Fft* fft, const LC3_FLOAT* input, LC3_FLOAT* output) +{ + IIS_FFT_ERROR error = IIS_FFT_NO_ERROR; + + UNUSED(error); + + error = LC3_IIS_FFT_Apply_RFFT(fft->handle, input, output); + + assert(error == IIS_FFT_NO_ERROR); +} + diff --git a/lib_lc3plus/license.h b/lib_lc3plus/license.h new file mode 100644 index 0000000000000000000000000000000000000000..077df126eafb26248c86497e270f6a454c51e04d --- /dev/null +++ b/lib_lc3plus/license.h @@ -0,0 +1,24 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.3 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + + +#include "options.h" +#include "wmc_auto.h" +#include "defines.h" + +static const char *const LICENSE = + "*******************************************************************************\n" + "* ETSI TS 103 634 V1.4.3 *\n" + "* Low Complexity Communication Codec Plus (LC3plus) *\n" + "* Floating Point Software V%i.%i.%iETSI, " __DATE__ " *\n" + "* Copyright licence is solely granted through ETSI Intellectual Property *\n" + "* Rights Policy, 3rd April 2019. No patent licence is granted by implication, *\n" + "* estoppel or otherwise. *\n" + "*******************************************************************************\n" + "\n"; diff --git a/lib_lc3plus/ltpf_coder.c b/lib_lc3plus/ltpf_coder.c new file mode 100644 index 0000000000000000000000000000000000000000..81a491ab93ac2fbc9621a89984ce4ccdbafccd8d --- /dev/null +++ b/lib_lc3plus/ltpf_coder.c @@ -0,0 +1,268 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.3 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + + +#include "options.h" +#include "wmc_auto.h" +#include "functions.h" + +static LC3_INT searchMaxIndice(LC3_FLOAT* in, LC3_INT len); + +LC3_INT searchMaxIndice(LC3_FLOAT* in, LC3_INT len) +{ + LC3_INT max_i = 0, i; + LC3_FLOAT max = 0; + + if (len <= 0) { + return -128; + } + + for (i = 0; i < len; i++) { + if (in[i] > max) { + max = in[i]; + max_i = i; + } + } + + return max_i; +} + +void process_ltpf_coder_fl(LC3_FLOAT* xin, LC3_INT xLen, LC3_INT ltpf_enable, LC3_INT pitch_ol, LC3_FLOAT pitch_ol_norm_corr, LC3_INT frame_dms, + LC3_FLOAT* mem_old_x, LC3_INT memLen, LC3_FLOAT* mem_norm_corr_past, LC3_INT* mem_on, LC3_FLOAT* mem_pitch, + LC3_INT* param, LC3_FLOAT* mem_norm_corr_past_past, LC3_INT* bits +#ifdef CR9_K_REDUCE_NORM_CORR_TH + , LC3_INT16 hrmode +#endif +) +{ + LC3_FLOAT buffer[LTPF_MEMIN_LEN + LEN_12K8 + 1 + (LEN_12K8 >> 2)], sum = 0, cor_up[(MAX_PITCH_12K8 - MIN_PITCH_12K8) / 2] = {0}, *x; + LC3_INT i, j, n, step, N, ltpf_active, pitch_search_delta, + pitch_search_upsamp = 0, pitch_search_L_interpol1 = 0, + t0_min = 0, t0_max = 0, t_min = 0, t_max = 0, temp2 = 0, t1 = 0, pitch_int = 0, pitch_fr = 0, midpoint = 0, + delta_up = 0, delta_down = 0, pitch_index = 0, gain = 0, acflen = 0; + LC3_FLOAT cor_tmp, cor_int_tmp, norm_corr = 0, cor[MAX_LEN_NR], cor_int[MAX_LEN_NR], sum1 = 0, sum2 = 0, sum3 = 0; + LC3_FLOAT pitch = 0; + +#ifdef CR9_K_REDUCE_NORM_CORR_TH + LC3_FLOAT normCorrTh = 0.0f; + if (hrmode) { + normCorrTh = 0.4; + } else { + normCorrTh = 0.6; + } +#endif + + /* Signal Buffer */ + N = xLen - 1; + x = &buffer[memLen]; + + move_float(buffer, mem_old_x, memLen); + move_float(x, xin, xLen); + move_float(mem_old_x, &buffer[N], xLen + memLen - N); + + ltpf_active = 0; + norm_corr = 0; + + pitch_search_delta = 4; + pitch_search_upsamp = 4; + pitch_search_L_interpol1 = 4; + +#ifdef CR9_K_REDUCE_NORM_CORR_TH + if (pitch_ol_norm_corr > normCorrTh) +#else + if (pitch_ol_norm_corr > 0.6) +#endif + { + /* Search Bounds */ + t0_min = pitch_ol - pitch_search_delta; + t0_max = pitch_ol + pitch_search_delta; + t0_min = MAX(t0_min, MIN_PITCH_12K8); + t0_max = MIN(t0_max, MAX_PITCH_12K8); + acflen = N; + + if (frame_dms == 25) + { + acflen = 2 * N; + x = x - N; + } + + /* Cross-Correlation Bounds */ + t_min = t0_min - pitch_search_L_interpol1; + t_max = t0_max + pitch_search_L_interpol1; + + /* Compute norm */ + sum1 = sum2 = 0; + for (j = 0; j < acflen; j++) { + sum1 += x[j] * x[j]; + sum2 += x[j - t_min] * x[j - t_min]; + } + + /* Do first iteration outside of loop */ + sum = mac_loop(x, &x[-t_min], acflen); + + sum3 = LC3_SQRT(sum1 * sum2) + 1.00e-05; + norm_corr = sum / sum3; + + norm_corr = MAX(0, norm_corr); + cor[0] = norm_corr; + + /* Compute Cross-Correlation */ + for (i = t_min + 1; i <= t_max; i++) { + sum = mac_loop(x, &x[-i], acflen); + + sum2 = sum2 + x[-i]*x[-i] + - x[acflen - 1 - ( i - 1 )]*x[acflen - 1 - ( i - 1 )]; + + sum3 = LC3_SQRT(sum1 * sum2) + 1.00e-05; + norm_corr = sum / sum3; + + norm_corr = MAX(0, norm_corr); + cor[i - t_min] = norm_corr; + + } + + /* Find Integer Pitch-Lag */ + temp2 = searchMaxIndice(&cor[pitch_search_L_interpol1], t_max - t_min - pitch_search_L_interpol1 - pitch_search_L_interpol1 + 1); + + t1 = temp2 + t0_min; + assert(t1 >= t0_min && t1 <= t0_max); + + /* Find Fractional Pitch-Lag */ + if (t1 >= RES2_PITCH_12K8) { + pitch_int = t1; + pitch_fr = 0; + } else { + j = 0; + + for (i = 0; i < pitch_search_upsamp * (t_max - t_min) + 1; i = i + pitch_search_upsamp) { + cor_up[i] = cor[j]; + j++; + } + + for (i = 0; i < pitch_search_upsamp * (t0_max - t0_min + 1); i++) { + sum = mac_loop(&cor_up[i], (const LC3_FLOAT *)inter4_1, 32); + + cor_int[i] = sum; + } + + if (t1 >= RES4_PITCH_12K8) { + step = 2; + } else { + step = 1; + } + + midpoint = pitch_search_upsamp * (t1 - t0_min) + 1; + delta_up = pitch_search_upsamp - step; + + if (t1 == t0_min) { + delta_down = 0; + } else { + delta_down = pitch_search_upsamp - step; + } + + j = 0; + for (i = midpoint - delta_down - 1; i <= midpoint + delta_up; i = i + step) { + cor[j] = cor_int[i]; + j++; + } + + + temp2 = searchMaxIndice(cor, ((midpoint + delta_up) - (midpoint - delta_down)) / step + 1); + pitch_fr = temp2 * step - delta_down; + + if (pitch_fr >= 0) { + pitch_int = t1; + } else { + pitch_int = t1 - 1; + pitch_fr = pitch_search_upsamp + pitch_fr; + } + } + + assert((pitch_int <= MAX_PITCH_12K8 && pitch_int >= RES2_PITCH_12K8 && pitch_fr == 0) || + (pitch_int < RES2_PITCH_12K8 && pitch_int >= RES4_PITCH_12K8 && (pitch_fr == 0 || pitch_fr == 2)) || + (pitch_int < RES4_PITCH_12K8 && pitch_int >= MIN_PITCH_12K8 && + (pitch_fr == 0 || pitch_fr == 1 || pitch_fr == 2 || pitch_fr == 3))); + + if (pitch_int < RES4_PITCH_12K8) { + pitch_index = pitch_int * 4 + pitch_fr - (MIN_PITCH_12K8 * 4); + } else if (pitch_int < RES2_PITCH_12K8) { + pitch_index = pitch_int * 2 + floor(pitch_fr / 2) - (RES4_PITCH_12K8 * 2) + ((RES4_PITCH_12K8 - MIN_PITCH_12K8) * 4); + } else { + pitch_index = pitch_int - RES2_PITCH_12K8 + ((RES4_PITCH_12K8 - MIN_PITCH_12K8) * 4) + ((RES2_PITCH_12K8 - RES4_PITCH_12K8) * 2); + } + + assert(pitch_index >= 0 && pitch_index < 512); + pitch = (LC3_FLOAT) pitch_int + (LC3_FLOAT) pitch_fr / 4.0; + + + /* Normalized Correlation */ + sum1 = sum2 = sum3 = 0; + for (n = 0; n < acflen; n++) + { + cor_tmp = x[n + 1] * enc_inter_filter[0][0] + + x[n] * enc_inter_filter[0][1] + + x[n - 1] * enc_inter_filter[0][2]; + + cor_int_tmp = x[n - pitch_int + 1] * enc_inter_filter[pitch_fr][0] + + x[n - pitch_int] * enc_inter_filter[pitch_fr][1] + + x[n - pitch_int - 1] * enc_inter_filter[pitch_fr][2] + + x[n - pitch_int - 2] * enc_inter_filter[pitch_fr][3]; + + sum1 += cor_tmp * cor_int_tmp; + sum2 += cor_tmp * cor_tmp; + sum3 += cor_int_tmp * cor_int_tmp; + } + + sum2 = LC3_SQRT(sum2 * sum3) + 1.00e-05; + norm_corr = sum1 / sum2; + + assert(norm_corr >= -1.00001 && norm_corr <= 1.00001); + norm_corr = MIN(1, MAX(-1, norm_corr)); + if (norm_corr < 0) { + norm_corr = 0; + } + + if (ltpf_enable == 1) { + /* Decision if ltpf active */ + if ((*mem_on == 0 && (frame_dms == 100 || *mem_norm_corr_past_past > 0.94) && *mem_norm_corr_past > 0.94 && + norm_corr > 0.94) || + (*mem_on == 1 && norm_corr > 0.9) || + (*mem_on == 1 && LC3_FABS(pitch - *mem_pitch) < 2 && (norm_corr - *mem_norm_corr_past) > -0.1 && + norm_corr > 0.84)) { + ltpf_active = 1; + } + } + + gain = 4; + + } else { + gain = 0; + norm_corr = pitch_ol_norm_corr; + pitch = 0; + } + + if (gain > 0) { + param[0] = 1; + param[1] = ltpf_active; + param[2] = pitch_index; + *bits = 11; + } else { + zero_int(param, 3); + + *bits = 1; + } + + if (frame_dms < 100) { + *mem_norm_corr_past_past = *mem_norm_corr_past; + } + + *mem_norm_corr_past = norm_corr; + *mem_on = ltpf_active; + *mem_pitch = pitch; +} diff --git a/lib_lc3plus/ltpf_decoder.c b/lib_lc3plus/ltpf_decoder.c new file mode 100644 index 0000000000000000000000000000000000000000..d51c7ffe3c70928dc74212628343c968d26ccef0 --- /dev/null +++ b/lib_lc3plus/ltpf_decoder.c @@ -0,0 +1,498 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.3 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + + +#include "options.h" +#include "wmc_auto.h" +#include "functions.h" + +void process_ltpf_decoder_fl(LC3_FLOAT* x, LC3_INT xLen, LC3_FLOAT* y, LC3_INT fs, LC3_FLOAT* mem_old_x, LC3_FLOAT* mem_old_y, + LC3_INT* mem_pitch_int, LC3_INT* mem_pitch_fr, LC3_FLOAT* mem_gain, LC3_INT* mem_beta_idx, LC3_INT bfi, + LC3_INT* param, LC3_INT* mem_param, LC3_INT conf_beta_idx, LC3_FLOAT conf_beta, LC3_INT concealMethod, + LC3_FLOAT damping + , LC3_INT *mem_ltpf_active +#ifdef CR9_N_SHORT_FADE_FOR_UNSTABLE_PITCH + , LC3_FLOAT *rel_pitch_change, LC3_INT hrmode, LC3_INT frame_dms +#endif +) +{ + LC3_INT i, j, n, N, L_past_x, N4, N34, + pitch_int, pitch_fr, p1, p2, L_past_y, inter_len, tilt_len = 0, + tilt_len_r, inter_len_r, old_x_len, old_y_len; + + LC3_FLOAT conf_alpha, gain, a1[12], a2[12], b1[11], b2[11], + buf_x[4 * MAX_LEN], buf_y[4 * MAX_LEN], buf_z[4 * MAX_LEN], pitch, sum1, sum2; +#ifdef CR9_LTPF_REWRITE + LC3_FLOAT *p_x, *p_y, *p_y2, *p_x_init, *p_y_init, *p_a1, *p_b1, *p_a2, *p_b2, fade_fac, current_fade_fac_up, current_fade_fac_down; +#endif +#ifdef CR9_N_SHORT_FADE_FOR_UNSTABLE_PITCH + LC3_FLOAT pitch_fl_c_old, pitch_delta; +#endif + const LC3_FLOAT *inter_filter[4], *tilt_filter[4]; + +#ifdef WMOPS + push_wmops("process_ltpf_decoder_fl"); +#endif +#ifdef CR9_N_SHORT_FADE_FOR_UNSTABLE_PITCH + pitch_fl_c_old = (LC3_FLOAT) *mem_pitch_int + (LC3_FLOAT)*mem_pitch_fr / 4.0; +#endif + conf_alpha = 0.85; + + if (bfi != 1) { + /* Decode pitch */ + if (param[0] == 1) { + if (param[2] < (RES4_PITCH_12K8 - MIN_PITCH_12K8) * 4) { + pitch_int = MIN_PITCH_12K8 + floor(param[2] / 4); + pitch_fr = param[2] - ((pitch_int - MIN_PITCH_12K8) * 4); + } else if (param[2] < ((RES4_PITCH_12K8 - MIN_PITCH_12K8) * 4) + ((RES2_PITCH_12K8 - RES4_PITCH_12K8) * 2)) { + param[2] = param[2] - ((RES4_PITCH_12K8 - MIN_PITCH_12K8) * 4); + pitch_int = RES4_PITCH_12K8 + floor(param[2] / 2); + pitch_fr = param[2] - ((pitch_int - RES4_PITCH_12K8) * 2); + pitch_fr = pitch_fr * 2; + } else { + pitch_int = + param[2] + (RES2_PITCH_12K8 - ((RES4_PITCH_12K8 - MIN_PITCH_12K8) * 4) - ((RES2_PITCH_12K8 - RES4_PITCH_12K8) * 2)); + pitch_fr = 0; + } + + pitch = ((LC3_FLOAT)pitch_int + (LC3_FLOAT)pitch_fr / 4.0) * (LC3_FLOAT)fs / 12800.0; + pitch = round(pitch * 4.0) / 4.0; + pitch_int = floor(pitch); + pitch_fr = (LC3_INT)((pitch - (LC3_FLOAT)pitch_int) * 4.0); + } else { + pitch_int = 0; + pitch_fr = 0; + } + + /* Decode gain */ + if (conf_beta_idx < 0) { + param[1] = 0; + } + + if (param[1] == 1) { + gain = conf_beta; + } else { + gain = 0; + } + } + else if (concealMethod > 0) { + if (conf_beta_idx < 0) { + if (mem_param[1] && *mem_beta_idx >= 0) + { + conf_beta_idx = *mem_beta_idx; + } + } + + memmove(param, mem_param, sizeof(LC3_INT32) * 3); + if (concealMethod == 2) + { + /* cause the ltpf to "fade_out" and only filter during initial 2.5 ms and then its buffer during 7.5 ms */ + assert(bfi == 1); + param[1] = 0; /* ltpf_active = 0 */ + } + + pitch_int = *mem_pitch_int; + pitch_fr = *mem_pitch_fr; + gain = (LC3_FLOAT) *mem_gain * damping; + } + + if ((conf_beta <= 0) && (*mem_ltpf_active == 0)) + { + if (fs == 8000 || fs == 16000) { + tilt_len = 4 - 2; + } + else if (fs == 24000) { + tilt_len = 6 - 2; + } + else if (fs == 32000) { + tilt_len = 8 - 2; + } + else if (fs == 44100 || fs == 48000) { + tilt_len = 12 - 2; + } + + N = xLen; + old_x_len = tilt_len; + inter_len = MAX(fs, 16000) / 8000; + old_y_len = ceilf((LC3_FLOAT)228.0 * fs / 12800.0) + inter_len; /* 228.0 needed to make use of ceil */ + + move_float(mem_old_y, &mem_old_y[N], (old_y_len - N)); + move_float(&mem_old_y[old_y_len - N], x, N); + move_float(mem_old_x, &x[N - old_x_len], old_x_len); + + *mem_ltpf_active = 0; + } + else + { + inter_len_r = 0; tilt_len_r = 0; + if (fs == 8000 || fs == 16000) { + inter_filter[0] = conf_inter_filter_16[0]; + inter_filter[1] = conf_inter_filter_16[1]; + inter_filter[2] = conf_inter_filter_16[2]; + inter_filter[3] = conf_inter_filter_16[3]; + inter_len_r = 4; + + tilt_filter[0] = conf_tilt_filter_16[0]; + tilt_filter[1] = conf_tilt_filter_16[1]; + tilt_filter[2] = conf_tilt_filter_16[2]; + tilt_filter[3] = conf_tilt_filter_16[3]; + tilt_len = 4 - 2; + tilt_len_r = 3; + } else if (fs == 24000) { + inter_filter[0] = conf_inter_filter_24[0]; + inter_filter[1] = conf_inter_filter_24[1]; + inter_filter[2] = conf_inter_filter_24[2]; + inter_filter[3] = conf_inter_filter_24[3]; + inter_len_r = 6; + + tilt_filter[0] = conf_tilt_filter_24[0]; + tilt_filter[1] = conf_tilt_filter_24[1]; + tilt_filter[2] = conf_tilt_filter_24[2]; + tilt_filter[3] = conf_tilt_filter_24[3]; + tilt_len = 6 - 2; + tilt_len_r = 5; + } else if (fs == 32000) { + inter_filter[0] = conf_inter_filter_32[0]; + inter_filter[1] = conf_inter_filter_32[1]; + inter_filter[2] = conf_inter_filter_32[2]; + inter_filter[3] = conf_inter_filter_32[3]; + inter_len_r = 8; + + tilt_filter[0] = conf_tilt_filter_32[0]; + tilt_filter[1] = conf_tilt_filter_32[1]; + tilt_filter[2] = conf_tilt_filter_32[2]; + tilt_filter[3] = conf_tilt_filter_32[3]; + tilt_len = 8 - 2; + tilt_len_r = 7; + } else if (fs == 44100 || fs == 48000) { + inter_filter[0] = conf_inter_filter_48[0]; + inter_filter[1] = conf_inter_filter_48[1]; + inter_filter[2] = conf_inter_filter_48[2]; + inter_filter[3] = conf_inter_filter_48[3]; + inter_len_r = 12; + + tilt_filter[0] = conf_tilt_filter_48[0]; + tilt_filter[1] = conf_tilt_filter_48[1]; + tilt_filter[2] = conf_tilt_filter_48[2]; + tilt_filter[3] = conf_tilt_filter_48[3]; + tilt_len = 12 - 2; + tilt_len_r = 11; + } + + inter_len = MAX(fs, 16000) / 8000; + + /* Init buffers */ + N = xLen; + old_x_len = tilt_len; + old_y_len = ceilf(228.0 * fs / 12800.0) + inter_len; + L_past_x = old_x_len; + move_float(buf_x, mem_old_x, old_x_len); + move_float(&buf_x[old_x_len], x, xLen); + L_past_y = old_y_len; + move_float(buf_y, mem_old_y, old_y_len); + zero_float(&buf_y[old_y_len], xLen); + + N4 = fs * 0.0025; + N34 = N - N4; + + /* Init filter parameters */ + if (mem_param[1] == 1) { + for (i = 0; i < inter_len_r; i++) { + a1[i] = *mem_gain * inter_filter[*mem_pitch_fr][i]; + } + + for (i = 0; i < tilt_len_r; i++) { + b1[i] = conf_alpha * (*mem_gain) * tilt_filter[*mem_beta_idx][i]; + } + + p1 = *mem_pitch_int; + } + + if (param[1] == 1) { + for (i = 0; i < tilt_len_r; i++) { + b2[i] = conf_alpha * gain * tilt_filter[conf_beta_idx][i]; + } + + for (i = 0; i < inter_len_r; i++) { + a2[i] = gain * inter_filter[pitch_fr][i]; + } + + p2 = pitch_int; + } + + /* First quarter of the current frame: cross-fading */ +#ifdef CR9_LTPF_REWRITE + fade_fac = 1. / (LC3_FLOAT) N4; + current_fade_fac_up = 0.f; + current_fade_fac_down = 1.f; + (void) p_x; (void) p_y; (void) p_a1; (void) p_b1; +#endif + + if (mem_param[1] == 0 && param[1] == 0) { + memmove(&buf_y[L_past_y], &buf_x[L_past_x], sizeof(LC3_FLOAT) * N4); + + } else if (mem_param[1] == 1 && param[1] == 0) { + for (n = 0; n < N4; n++) { + sum1 = 0; + sum2 = 0; + j = 0; + for (i = L_past_x + n; i >= L_past_x + n - tilt_len; i--) { + sum1 += b1[j] * buf_x[i]; + j++; + } + + j = 0; + for (i = L_past_y + n - p1 + inter_len - 1; i >= L_past_y + n - p1 - inter_len; i--) { + sum2 += a1[j] * buf_y[i]; + j++; + } + +#ifdef CR9_LTPF_REWRITE + buf_y[L_past_y + n] = buf_x[L_past_x + n] - current_fade_fac_down * sum1 + + current_fade_fac_down * sum2; + current_fade_fac_down -= fade_fac; +#else + buf_y[L_past_y + n] = buf_x[L_past_x + n] - (((LC3_FLOAT)N4 - (LC3_FLOAT)n) / (LC3_FLOAT)N4) * sum1 + + (((LC3_FLOAT)N4 - (LC3_FLOAT)n) / (LC3_FLOAT)N4) * sum2; +#endif + } + + } else if (mem_param[1] == 0 && param[1] == 1) { + for (n = 0; n < N4; n++) { + sum1 = 0; + sum2 = 0; + j = 0; + for (i = L_past_x + n; i >= L_past_x + n - tilt_len; i--) { + sum1 += b2[j] * buf_x[i]; + j++; + } + + j = 0; + for (i = L_past_y + n - p2 + inter_len - 1; i >= L_past_y + n - p2 - inter_len; i--) { + sum2 += a2[j] * buf_y[i]; + j++; + } + +#ifdef CR9_LTPF_REWRITE + buf_y[L_past_y + n] = buf_x[L_past_x + n] - current_fade_fac_up * sum1 + current_fade_fac_up * sum2; + current_fade_fac_up += fade_fac; +#else + buf_y[L_past_y + n] = buf_x[L_past_x + n] - ((LC3_FLOAT)n / (LC3_FLOAT)N4) * sum1 + ((LC3_FLOAT)n / (LC3_FLOAT)N4) * sum2; +#endif + } + } else if (*mem_pitch_int == pitch_int && *mem_pitch_fr == pitch_fr) { + for (n = 0; n < N4; n++) { + sum1 = 0; + sum2 = 0; + j = 0; + for (i = L_past_x + n; i >= L_past_x + n - tilt_len; i--) { + sum1 += b2[j] * buf_x[i]; + j++; + } + + j = 0; + for (i = L_past_y + n - p2 + inter_len - 1; i >= L_past_y + n - p2 - inter_len; i--) { + sum2 += a2[j] * buf_y[i]; + j++; + } + + buf_y[L_past_y + n] = buf_x[L_past_x + n] - sum1 + sum2; + } + } else { +#ifdef CR9_LTPF_REWRITE + p_x_init = &buf_x[L_past_x]; + p_y_init = &buf_y[L_past_y - p1 + inter_len - 1]; + p_y2 = &buf_y[L_past_y]; + for (n = 0; n < N4; n++) { + sum1 = 0; + sum2 = 0; + p_b1 = b1; + p_x = p_x_init; + for (i = tilt_len; i >= 0; i--) { + sum1 += *p_b1 * *p_x; + p_b1++; + p_x--; + } + + p_y = p_y_init; + p_a1 = a1; + for (i = 2*inter_len - 1; i >= 0; i--) { + sum2 += *p_a1 * *p_y; + p_a1++; + p_y--; + } + + *p_y2 = *p_x_init - current_fade_fac_down * sum1 + + current_fade_fac_down * sum2; + current_fade_fac_down -= fade_fac; + p_x_init++; + p_y_init++; + p_y2++; + } + + move_float(buf_z, buf_y, (old_y_len + xLen)); + p_x_init = &buf_z[L_past_y]; /* buf z in this case */ + p_y_init = &buf_y[L_past_y - p2 + inter_len - 1]; + p_y2 = &buf_y[L_past_y]; + + for (n = 0; n < N4; n++) { + sum1 = 0; + sum2 = 0; + j = 0; + p_x = p_x_init; + p_b2 = b2; + for (i = tilt_len; i >= 0; i--) { + sum1 += *p_b2 * *p_x; + p_b2++; + p_x--; + } + + p_y = p_y_init; + p_a2 = a2; + for (i = 2*inter_len - 1; i >= 0; i--) { + sum2 += *p_a2 * *p_y; + p_a2++; + p_y--; + } + + *p_y2 = *p_x_init - current_fade_fac_up * sum1 + current_fade_fac_up * sum2; + current_fade_fac_up += fade_fac; + p_x_init++; + p_y_init++; + p_y2++; + } +#else + for (n = 0; n < N4; n++) { + sum1 = 0; + sum2 = 0; + j = 0; + for (i = L_past_x + n; i >= L_past_x + n - tilt_len; i--) { + sum1 += b1[j] * buf_x[i]; + j++; + } + + j = 0; + for (i = L_past_y + n - p1 + inter_len - 1; i >= L_past_y + n - p1 - inter_len; i--) { + sum2 += a1[j] * buf_y[i]; + j++; + } + + buf_y[L_past_y + n] = buf_x[L_past_x + n] - (((LC3_FLOAT)N4 - (LC3_FLOAT)n) / (LC3_FLOAT)N4) * sum1 + + (((LC3_FLOAT)N4 - (LC3_FLOAT)n) / (LC3_FLOAT)N4) * sum2; + } + + memmove(buf_z, buf_y, sizeof(LC3_FLOAT) * (old_y_len + xLen)); + + for (n = 0; n < N4; n++) { + sum1 = 0; + sum2 = 0; + j = 0; + for (i = L_past_y + n; i >= L_past_y + n - tilt_len; i--) { + sum1 += b2[j] * buf_z[i]; + j++; + } + + j = 0; + for (i = L_past_y + n - p2 + inter_len - 1; i >= L_past_y + n - p2 - inter_len; i--) { + sum2 += a2[j] * buf_y[i]; + j++; + } + + buf_y[L_past_y + n] = buf_z[L_past_y + n] - ((LC3_FLOAT)n / (LC3_FLOAT)N4) * sum1 + ((LC3_FLOAT)n / (LC3_FLOAT)N4) * sum2; + } +#endif + } + +#ifdef CR9_LTPF_REWRITE + /* Second quarter of the current frame */ + if (param[1] == 0) { + move_float(&buf_y[L_past_y + N4], &buf_x[L_past_x + N4], + ((L_past_x + N4 + N34) - (L_past_x + N4))); + } else { + p_x_init = &buf_x[L_past_x + N4]; + p_y_init = &buf_y[L_past_y + N4 - p2 + inter_len - 1]; + p_y2 = &buf_y[L_past_y + N4]; + for (n = 0; n < N34; n++) { + sum1 = 0; + sum2 = 0; + p_b2 = b2; + p_x = p_x_init; + + for (i = 0; i <= tilt_len; i++) { + sum1 += *p_b2 * *p_x; + p_b2++; + p_x--; + } + + p_a2 = a2; + p_y = p_y_init; + + for (i = 2*inter_len - 1; i >= 0; i--) { + sum2 += *p_a2 * *p_y; + p_a2++; + p_y--; + } + p_y_init++; + *p_y2 = *p_x_init - sum1 + sum2; + p_x_init++; + p_y2++; + } + } +#else + /* Second quarter of the current frame */ + if (param[1] == 0) { + memmove(&buf_y[L_past_y + N4], &buf_x[L_past_x + N4], + sizeof(LC3_FLOAT) * ((L_past_x + N4 + N34) - (L_past_x + N4))); + } else { + for (n = 0; n < N34; n++) { + sum1 = 0; + sum2 = 0; + j = 0; + for (i = L_past_x + N4 + n; i >= L_past_x + n + N4 - tilt_len; i--) { + sum1 += b2[j] * buf_x[i]; + j++; + } + + j = 0; + for (i = L_past_y + N4 + n - p2 + inter_len - 1; i >= L_past_y + N4 + n - p2 - inter_len; i--) { + sum2 += a2[j] * buf_y[i]; + j++; + } + + buf_y[L_past_y + N4 + n] = buf_x[L_past_x + N4 + n] - sum1 + sum2; + } + } +#endif + /* Output */ + move_float(y, &buf_y[L_past_y], N); + + /* Update memory */ + move_float(mem_old_x, &buf_x[N], old_x_len); + move_float(mem_old_y, &buf_y[N], old_y_len); + + *mem_ltpf_active = (conf_beta > 0); + } + + /* Update ltpf param memory */ + move_int(mem_param, param, 3); + *mem_pitch_int = pitch_int; + *mem_pitch_fr = pitch_fr; + *mem_gain = gain; + *mem_beta_idx = conf_beta_idx; +#ifdef CR9_N_SHORT_FADE_FOR_UNSTABLE_PITCH + if (bfi == 0 && hrmode == 1 && (frame_dms == 50 || frame_dms == 25)){ + pitch_delta = LC3_FABS(pitch_fl_c_old - (LC3_FLOAT)pitch_int - (LC3_FLOAT)(pitch_fr / 4.0)); + *rel_pitch_change = pitch_delta / MAX(pitch_fl_c_old, 1); + } +#endif + +#ifdef WMOPS + pop_wmops(); +#endif +} diff --git a/lib_lc3plus/mdct.c b/lib_lc3plus/mdct.c new file mode 100644 index 0000000000000000000000000000000000000000..ef2d7c087a5b3ae6560f7d45988663f788df00bb --- /dev/null +++ b/lib_lc3plus/mdct.c @@ -0,0 +1,157 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.3 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + + +#include "options.h" +#include "wmc_auto.h" +#include "functions.h" + +static const LC3_FLOAT* mdct_window(LC3_INT length, LC3_INT frame_dms, LC3_INT hrmode) +{ + if (frame_dms == 100) { + switch (length) { + case 80: + return MDCT_WINS_10ms[hrmode][0]; + case 160: + return MDCT_WINS_10ms[hrmode][1]; + case 240: + return MDCT_WINS_10ms[hrmode][2]; + case 320: + return MDCT_WINS_10ms[hrmode][3]; + case 480: + return MDCT_WINS_10ms[hrmode][4]; + case 960: + return MDCT_WINS_10ms[hrmode][5]; + default: + return NULL; + } + } +#ifdef CR8_G_ADD_75MS + else if (frame_dms == 75) { + switch (length) { + case 60: + return MDCT_WINS_7_5ms[hrmode][0]; + case 120: + return MDCT_WINS_7_5ms[hrmode][1]; + case 180: + return MDCT_WINS_7_5ms[hrmode][2]; + case 240: + return MDCT_WINS_7_5ms[hrmode][3]; + case 360: + return MDCT_WINS_7_5ms[hrmode][4]; + case 720: + return MDCT_WINS_7_5ms[hrmode][5]; + default: + return NULL; + } + } +#endif + else if (frame_dms == 50) { + switch (length) { + case 40: + return MDCT_WINS_5ms[hrmode][0]; + case 80: + return MDCT_WINS_5ms[hrmode][1]; + case 120: + return MDCT_WINS_5ms[hrmode][2]; + case 160: + return MDCT_WINS_5ms[hrmode][3]; + case 240: + return MDCT_WINS_5ms[hrmode][4]; + case 480: + return MDCT_WINS_5ms[hrmode][5]; + default: + return NULL; + } + } + else if (frame_dms == 25) { + switch (length) { + case 20: + return MDCT_WINS_2_5ms[hrmode][0]; + case 40: + return MDCT_WINS_2_5ms[hrmode][1]; + case 60: + return MDCT_WINS_2_5ms[hrmode][2]; + case 80: + return MDCT_WINS_2_5ms[hrmode][3]; + case 120: + return MDCT_WINS_2_5ms[hrmode][4]; + case 240: + return MDCT_WINS_2_5ms[hrmode][5]; + default: + return NULL; + } + } + return NULL; +} + +void mdct_init(Mdct* mdct, LC3_INT length, LC3_INT frame_dms, LC3_INT fs_idx, LC3_INT hrmode) +{ + if (frame_dms == 100) { + mdct->leading_zeros = MDCT_la_zeroes[fs_idx]; + } +#ifdef CR8_G_ADD_75MS + else if (frame_dms == 75) { + mdct->leading_zeros = MDCT_la_zeroes_7_5ms[fs_idx]; + } +#endif + else if (frame_dms == 50) { + mdct->leading_zeros = MDCT_la_zeroes_5ms[fs_idx]; + } + else if (frame_dms == 25) { + mdct->leading_zeros = MDCT_la_zeroes_2_5ms[fs_idx]; + } + else { + assert(!"invalid frame_ms"); + } + + mdct->length = length; + mdct->mem_length = length - mdct->leading_zeros; + mdct->window = mdct_window(length, frame_dms, hrmode); + mdct->mem = calloc(sizeof(*mdct->mem), mdct->mem_length); + dct4_init(&mdct->dct, length); +} + +void mdct_free(Mdct* mdct) +{ + if (mdct) { + free(mdct->mem); + dct4_free(&mdct->dct); + memset(mdct, 0, sizeof(*mdct)); + } +} + +void mdct_apply(const LC3_FLOAT* input, LC3_FLOAT* output, Mdct* mdct) +{ + LC3_FLOAT tmp[MAX_LEN * 2]; + LC3_INT i; + LC3_INT hlen; + + move_float(tmp, mdct->mem, mdct->mem_length); + move_float(tmp + mdct->mem_length, input, mdct->length); + zero_float(tmp + mdct->length * 2 - mdct->leading_zeros, mdct->leading_zeros); + move_float(mdct->mem, tmp + mdct->length, mdct->mem_length); + + mult_vec(tmp, mdct->window, mdct->length * 2); + + hlen = mdct->length / 2; + for (i = 0; i < hlen; i++) { + output[i] = -tmp[hlen * 3 - i - 1] - tmp[hlen * 3 + i]; + output[hlen + i] = tmp[i] - tmp[hlen * 2 - i - 1]; + } + + move_float(tmp, output, mdct->length); + + dct4_apply(&mdct->dct, tmp, output); +} + +void processMdct_fl(LC3_FLOAT* in, LC3_FLOAT* out, Mdct* mdctStruct) +{ + mdct_apply(in, out, mdctStruct); +} diff --git a/lib_lc3plus/mdct_shaping.c b/lib_lc3plus/mdct_shaping.c new file mode 100644 index 0000000000000000000000000000000000000000..eba6f32704f08fa58359057905578a5b58d2c0f2 --- /dev/null +++ b/lib_lc3plus/mdct_shaping.c @@ -0,0 +1,28 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.3 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + + +#include "options.h" +#include "wmc_auto.h" +#include "functions.h" + +void processMdctShaping_fl(LC3_FLOAT x[], LC3_FLOAT scf[], const LC3_INT bands_offset[], LC3_INT fdns_npts) +{ + LC3_INT i, j; + LC3_FLOAT val; + + j = 0; + for (i = 0; i < fdns_npts; i++) { + val = scf[i]; + + for (; j < bands_offset[i + 1]; j++) { + x[j] = x[j] * val; + } + } +} diff --git a/lib_lc3plus/near_nyquist_detector.c b/lib_lc3plus/near_nyquist_detector.c new file mode 100644 index 0000000000000000000000000000000000000000..ee34361ef2b6e27b4ef36c58b1d3fa5182c68f98 --- /dev/null +++ b/lib_lc3plus/near_nyquist_detector.c @@ -0,0 +1,93 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.3 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + +#include "options.h" +#include "wmc_auto.h" +#include "functions.h" + + +void processNearNyquistdetector_fl(LC3_INT16* near_nyquist_flag, const LC3_INT fs_idx, const LC3_INT near_nyquist_index, + const LC3_INT bands_number, const LC3_FLOAT* ener +#ifdef CR8_E_TONE_DETECTOR + , const LC3_INT16 frame_dms, const LC3_INT16 hrmode +#endif +) +{ + *near_nyquist_flag = 0; +#ifdef CR8_E_TONE_DETECTOR + if (hrmode == 0) +#endif + { + if (fs_idx < 4) + { + LC3_INT i = 0; + LC3_FLOAT ener_low = FLT_EPSILON, ener_high = 0; + + for (i=0; i NN_thresh * ener_low){ + *near_nyquist_flag = 1; + } + } + } +#ifdef CR8_E_TONE_DETECTOR + else // hrmode == 1 + { + // inverse spectral flatness = mean(energy) ./ 2^(mean(log2(energy))); + LC3_INT32 td_thresh, i = 0; + LC3_FLOAT mean_ener = 0, mean_ener_log2 = 0, inv_flatness = 0; + + switch (frame_dms) + { + case 25: + td_thresh = TD_HR_thresh_2_5ms; + break; + case 50: + td_thresh = TD_HR_thresh_5ms; + break; + case 75: + td_thresh = TD_HR_thresh_7_5ms; + break; + default: /* 100 */ + td_thresh = TD_HR_thresh_10ms; + break; + } + + // calculate arithmetic mean + for (i = 0; i < bands_number; i++) + { + mean_ener += ener[i]; + } + mean_ener = mean_ener / bands_number; + + // calculate geometric mean + for (i = 0; i < bands_number; i++) + { + if (ener[i] != 0) { + mean_ener_log2 += LC3_LOGTWO(ener[i]); + } + } + mean_ener_log2 = mean_ener_log2 / bands_number; + + inv_flatness = mean_ener / LC3_POW(2,mean_ener_log2); + + if (inv_flatness > td_thresh) { + *near_nyquist_flag = 1; + } + } +#endif // CR8_E_TONE_DETECTOR +} diff --git a/lib_lc3plus/noise_factor.c b/lib_lc3plus/noise_factor.c new file mode 100644 index 0000000000000000000000000000000000000000..5e4ecd7b9ac4075a01b1cdb33cbbb151ccb61229 --- /dev/null +++ b/lib_lc3plus/noise_factor.c @@ -0,0 +1,130 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.3 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + + +#include "options.h" +#include "wmc_auto.h" +#include "functions.h" + +void processNoiseFactor_fl(LC3_INT* fac_ns_idx, LC3_FLOAT x[], LC3_INT xq[], LC3_FLOAT gg, LC3_INT BW_cutoff_idx, LC3_INT frame_dms, + LC3_INT target_bytes +) +{ + LC3_INT sumZeroLines = 0, kZeroLines = 0, startOffset = 0, nTransWidth = 0, i = 0, j = 0, k = 0, m = 0, nzeros = 0; + LC3_FLOAT fac_ns_unq = 0, idx = 0, nsf1 = 0, nsf2 = 0; + LC3_INT zeroLines[MAX_LEN]; + + switch (frame_dms) + { + case 25: + nTransWidth = 1; + startOffset = 6; + break; + case 50: + nTransWidth = 1; + startOffset = 12; + break; +#ifdef CR8_G_ADD_75MS + case 75: + nTransWidth = 2; + startOffset = 18; + break; +#endif + case 100: + nTransWidth = 3; + startOffset = 24; + break; + } + + for (k = startOffset - nTransWidth; k < startOffset + nTransWidth; k++) + { + if (xq[k] != 0) + { + nzeros = -2 * nTransWidth - 1; + } + if (xq[k] == 0) + { + nzeros ++; + } + } + for (k = startOffset; k < BW_cutoff_idx - nTransWidth; k++) + { + if (xq[k + nTransWidth] != 0) + { + nzeros = -2 * nTransWidth - 1; + } + if (xq[k + nTransWidth] == 0) + { + nzeros ++; + } + if (nzeros >= 0) + { + zeroLines[j++] = k; + } + } + + for (k = BW_cutoff_idx - nTransWidth; k < BW_cutoff_idx; k++) + { + nzeros ++; + if (nzeros >= 0) + { + zeroLines[j++] = k; + } + } + + if (j == 0) { + fac_ns_unq = 0; + } + else + { + kZeroLines = j; + + fac_ns_unq = 0; + for (j = 0; j < kZeroLines; j++) { + fac_ns_unq += LC3_FABS(x[zeroLines[j]]); + } + + fac_ns_unq /= (gg) * kZeroLines; + + + + if (kZeroLines > 1 && target_bytes <= 20 && frame_dms == 100) { + + j = 0, k = 0, nsf1 = 0, nsf2 = 0, sumZeroLines = 0; + + for (i = 0; i < kZeroLines; i++) { + sumZeroLines += zeroLines[i]; + } + + m = floor(sumZeroLines / kZeroLines); + + for (i = 0; i < kZeroLines; i++) { + if (zeroLines[i] <= m) { + j++; + nsf1 += LC3_FABS(x[zeroLines[i]]); + } + else { + nsf2 += LC3_FABS(x[zeroLines[i]]); + k++; + } + } + + nsf1 /= (gg) * j; + nsf2 /= (gg) * k; + + fac_ns_unq = MIN(nsf1, nsf2); + } + + } + + idx = round(8 - 16 * fac_ns_unq); + idx = MIN(MAX(idx, 0), 7); + + *fac_ns_idx = idx; +} diff --git a/lib_lc3plus/noise_filling.c b/lib_lc3plus/noise_filling.c new file mode 100644 index 0000000000000000000000000000000000000000..b844aef080c34a44b1e319fd17062bd7ed89650c --- /dev/null +++ b/lib_lc3plus/noise_filling.c @@ -0,0 +1,107 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.3 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + + +#include "options.h" +#include "wmc_auto.h" +#include "functions.h" + +void processNoiseFilling_fl(LC3_FLOAT xq[], LC3_INT nfseed, LC3_INT fac_ns_idx, LC3_INT bw_stopband, LC3_INT frame_dms, LC3_FLOAT fac_ns_pc, LC3_INT spec_inv_idx) +{ + LC3_INT zeroLines[MAX_LEN]; + LC3_INT nTransWidth, startOffset, j, k, nzeros = 0, kZeroLines; + LC3_FLOAT fac_ns = 0; + + switch (frame_dms) + { + case 25: + nTransWidth = 1; + startOffset = 6; + break; + case 50: + nTransWidth = 1; + startOffset = 12; + break; +#ifdef CR8_G_ADD_75MS + case 75: + nTransWidth = 2; + startOffset = 18; + break; +#endif + case 100: + nTransWidth = 3; + startOffset = 24; + break; + } + + fac_ns = (8.0 - fac_ns_idx) / 16.0; + + j = 0; + + for (k = startOffset - nTransWidth; k < startOffset + nTransWidth; k++) + { + if (xq[k] != 0) + { + nzeros = -2 * nTransWidth - 1; + } + if (xq[k] == 0) + { + nzeros ++; + } + } + for (k = startOffset; k < bw_stopband - nTransWidth; k++) + { + if (xq[k + nTransWidth] != 0) + { + nzeros = -2 * nTransWidth - 1; + } + if (xq[k + nTransWidth] == 0) + { + nzeros ++; + } + if (nzeros >= 0) + { + zeroLines[j++] = k; + } + } + + for (k = bw_stopband - nTransWidth; k < bw_stopband; k++) + { + nzeros ++; + if (nzeros >= 0) + { + zeroLines[j++] = k; + } + } + + kZeroLines = j; + + for (k = 0; k < kZeroLines; k++) { + nfseed = (13849 + (nfseed + 32768) * 31821) & 65535; + nfseed -= 32768; + + if (nfseed >= 0) { + if (zeroLines[k] < spec_inv_idx) + { + xq[zeroLines[k]] = fac_ns; + } else { + xq[zeroLines[k]] = fac_ns_pc; + } + } else { + if (zeroLines[k] < spec_inv_idx) + { + xq[zeroLines[k]] = -fac_ns; + } else { + xq[zeroLines[k]] = -fac_ns_pc; + } + } + } + + return; +} diff --git a/lib_lc3plus/olpa.c b/lib_lc3plus/olpa.c new file mode 100644 index 0000000000000000000000000000000000000000..62a303f26fbfd7cb03eb0baa59b53ab432467e3f --- /dev/null +++ b/lib_lc3plus/olpa.c @@ -0,0 +1,201 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.3 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + + +#include "options.h" +#include "wmc_auto.h" +#include "functions.h" + +static void filter_olpa(LC3_FLOAT* in, LC3_FLOAT* out, const LC3_FLOAT* buf, LC3_INT32 len_input); +static LC3_INT searchMaxIndice(LC3_FLOAT* in, LC3_INT32 len); + +void filter_olpa(LC3_FLOAT* in, LC3_FLOAT* out, const LC3_FLOAT* buf, LC3_INT32 len_input) +{ + /* a = 1, so denominator == 1, nothing to do here */ + LC3_INT32 i, j; + + + j = 0; + for (i = 4; i < len_input; i += 2) { + out[j++] = (buf[0] * in[i]) + (buf[1] * in[i - 1]) + (buf[2] * in[i - 2]) + (buf[3] * in[i - 3]) + (buf[4] * in[i - 4]); + } +} + +LC3_INT searchMaxIndice(LC3_FLOAT* in, LC3_INT len) +{ + LC3_INT max_i = 0, i; + LC3_FLOAT max = in[0]; + + if (len <= 0) { + return -128; + } + + for (i = 0; i < len; i++) { + if (in[i] > max) { + max = in[i]; + max_i = i; + } + } + + return max_i; +} + +void processOlpa_fl(LC3_FLOAT* s_12k8, LC3_FLOAT* mem_s12k8, LC3_FLOAT* mem_s6k4, LC3_INT* mem_old_T0, +#ifdef CR9_F_PITCH_WIN_LEN_FIX + LC3_INT* pitch_flag, +#endif + LC3_INT* T0_out, LC3_FLOAT* normcorr_out, LC3_INT len, LC3_INT frame_dms) +{ + LC3_FLOAT norm_corr = 0, sum = 0, sum0 = 0, sum1 = 0, sum2 = 0, norm_corr2 = 0, *s6k4; + LC3_FLOAT buf[LEN_6K4 + MAX_PITCH_6K4 + MAX_LEN], R0[RANGE_PITCH_6K4]; /* constant length */ + LC3_INT i = 0, len2 = 0, T0 = 0, T02 = 0, min_pitch = 0, max_pitch = 0, L = 0, mem_in_len = 0, acflen = 0, delta = 0; + + len2 = len / 2; +#ifdef CR9_F_PITCH_WIN_LEN_FIX + switch(frame_dms) + { + case 50: + delta = len / 2; + acflen = len2 * 2; + break; + + case 25: + delta = 3*(len /2); + acflen = len2*4; + break; + + default: +#endif + delta = 0; + acflen = len2; +#ifdef CR9_F_PITCH_WIN_LEN_FIX + } +#endif + + mem_in_len = MAX_PITCH_6K4 + delta; + +#ifndef CR9_F_PITCH_WIN_LEN_FIX + if (frame_dms == 25) + { + mem_in_len += 16; + acflen += 16; + } +#endif + + /* Downsampling */ + move_float(buf, mem_s12k8, 3); + move_float(&buf[3], s_12k8, len); + move_float(mem_s12k8, &buf[len], 3); + filter_olpa(buf, R0, olpa_down2, len + 3); + + /* Compute autocorrelation */ +#ifdef CR9_F_PITCH_WIN_LEN_FIX + s6k4 = &buf[mem_in_len - delta]; + move_float(&buf[mem_in_len], R0, len2); + move_float(buf, mem_s6k4, mem_in_len); + move_float(mem_s6k4, &buf[len2], mem_in_len); +#else + s6k4 = &buf[mem_in_len]; + move_float(buf, mem_s6k4, mem_in_len); + move_float(s6k4, R0, len2); + move_float(mem_s6k4, &buf[len2], mem_in_len); + if (frame_dms == 25) + { + s6k4 = s6k4 - 16; + } +#endif + for (i = MIN_PITCH_6K4; i <= MAX_PITCH_6K4; i++) { + sum = mac_loop(s6k4, &s6k4[-i], acflen); + R0[i - MIN_PITCH_6K4] = sum; + } + + /* Weight autocorrelation and find maximum */ + + /* Second try in the neighborhood of the previous pitch */ + min_pitch = MAX(MIN_PITCH_6K4, *mem_old_T0 - 4); + max_pitch = MIN(MAX_PITCH_6K4, *mem_old_T0 + 4); + + L = searchMaxIndice(&R0[min_pitch - MIN_PITCH_6K4], max_pitch - min_pitch + 1 ); + T02 = L + min_pitch; + + for (i = 0; i < RANGE_PITCH_6K4; i++) { + R0[i] = R0[i] * olpa_acw[i]; + } + L = searchMaxIndice(R0, RANGE_PITCH_6K4); + T0 = L + MIN_PITCH_6K4; + + /* Compute normalized correlation */ + sum0 = sum1 = sum2 = 0; + + for (i = 0; i < acflen; i++) { + sum0 += s6k4[i] * s6k4[i - T0]; + sum1 += s6k4[i - T0] * s6k4[i - T0]; + sum2 += s6k4[i] * s6k4[i]; + } + sum1 = sum1 * sum2; + sum1 = LC3_SQRT(sum1) + 1.00e-05; + norm_corr = sum0 / sum1; + norm_corr = MAX(0, norm_corr); + + if (T02 != T0) { + sum0 = sum1 = sum2 = 0; + for (i = 0; i < acflen; i++) { + sum0 += s6k4[i] * s6k4[i - T02]; + sum1 += s6k4[i - T02] * s6k4[i - T02]; + sum2 += s6k4[i] * s6k4[i]; + } + sum1 = sum1 * sum2; + sum1 = LC3_SQRT(sum1) + 1.00e-05; + norm_corr2 = sum0 / sum1; + norm_corr2 = MAX(0, norm_corr2); + + if (norm_corr2 > (norm_corr * 0.85)) { + T0 = T02; + norm_corr = norm_corr2; + } + } + +#ifdef CR9_F_PITCH_WIN_LEN_FIX + switch(frame_dms) + { + case 50: + if (*pitch_flag == 1) + { + *mem_old_T0 = T0; + *pitch_flag = 0; + } + else + { + *pitch_flag += 1; + } + break; + + case 25: + if (*pitch_flag == 3) + { + *mem_old_T0 = T0; + *pitch_flag = 0; + } + else + { + *pitch_flag += 1; + } + break; + + default: +#endif + *mem_old_T0 = T0; +#ifdef CR9_F_PITCH_WIN_LEN_FIX + } +#endif + + *T0_out = T0 * 2.0; + *normcorr_out = norm_corr; + +} diff --git a/lib_lc3plus/pc_apply.c b/lib_lc3plus/pc_apply.c new file mode 100644 index 0000000000000000000000000000000000000000..89bab44eb6da53ce624c226645ffd75de0a81c25 --- /dev/null +++ b/lib_lc3plus/pc_apply.c @@ -0,0 +1,74 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.3 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + + +#include "options.h" +#include "wmc_auto.h" +#include "functions.h" + + +void processPcApply_fl(LC3_FLOAT *q_res, LC3_FLOAT *q_old_res, LC3_FLOAT *q_d_prev, LC3_INT32 spec_inv_idx, LC3_INT32 yLen, LC3_INT32 gg_idx, LC3_INT32 gg_idx_off, LC3_FLOAT *prev_gg, LC3_FLOAT *fac, LC3_INT32 *pc_nbLostCmpt) +{ + LC3_FLOAT gg, mean_nrg_low, mean_nrg_high, ener_prev, ener_curr, fac_local; + LC3_INT32 i; + + ener_prev = 0; ener_curr = 0; mean_nrg_low = 0; mean_nrg_high = 0; + + *pc_nbLostCmpt = *pc_nbLostCmpt + 1; + + assert(spec_inv_idx > 1); + + gg = LC3_POW(10, (((LC3_FLOAT) (gg_idx + gg_idx_off)) / 28.0)); + + for (i = 0; i < spec_inv_idx; i++) + { + mean_nrg_low += LC3_POW(q_d_prev[i], 2); + } + + mean_nrg_low /= (LC3_FLOAT) spec_inv_idx; + + if (spec_inv_idx < yLen) + { + for (i = spec_inv_idx; i < yLen; i++) + { + mean_nrg_high += LC3_POW(q_d_prev[i], 2); + } + } + + mean_nrg_high /= (LC3_FLOAT) (yLen - spec_inv_idx); + + for (i = 0; i < spec_inv_idx; i++) + { + ener_prev += LC3_POW(q_old_res[i], 2); + ener_curr += LC3_POW(q_res[i], 2); + } + + *fac = 1; + if (ener_prev > 0) + { + *fac = LC3_SQRT(ener_curr / ener_prev); + } + + fac_local = *fac; + if (mean_nrg_low <= mean_nrg_high || ener_prev * LC3_POW(*prev_gg, 2) <= ener_curr * LC3_POW(gg, 2)) + { + fac_local = *prev_gg / gg; + } + + for (i = spec_inv_idx; i < yLen; i++) + { + q_res[i] = q_old_res[i] * fac_local; + + if (LC3_FABS(q_res[i]) < (1 - 0.375)) + { + q_res[i] = 0; + } + } +} + diff --git a/lib_lc3plus/pc_classify.c b/lib_lc3plus/pc_classify.c new file mode 100644 index 0000000000000000000000000000000000000000..9ea5e02daee48d796be0504199f7852e8217e270 --- /dev/null +++ b/lib_lc3plus/pc_classify.c @@ -0,0 +1,171 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.3 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + + +#include "options.h" +#include "wmc_auto.h" +#include "functions.h" + + +LC3_FLOAT pc_peak_detector(LC3_FLOAT *q_d_prev, LC3_INT32 yLen); + +void processPcClassify_fl(LC3_INT32 pitch_present, LC3_INT32 frame_dms, LC3_FLOAT *q_d_prev, LC3_FLOAT *q_old_res, LC3_INT32 yLen, LC3_INT32 spec_inv_idx, LC3_FLOAT stab_fac, LC3_INT32 *bfi) +{ + LC3_INT32 maxPitchBin, xover, i; + LC3_FLOAT part_nrg, full_nrg; + + part_nrg = 0; full_nrg = 0; + + if (spec_inv_idx < (4 * frame_dms / 10)) + { + if (stab_fac < 0.5) + { + *bfi = 1; + } else if (pitch_present == 1) + { + maxPitchBin = 8; + if (frame_dms == 50) + { + maxPitchBin = 4; + } + xover = pc_peak_detector(q_d_prev, yLen); + if (spec_inv_idx < xover || spec_inv_idx < maxPitchBin) + { + *bfi = 1; + } + } else { + for (i = 0; i < spec_inv_idx; i++) + { + part_nrg += LC3_POW(q_old_res[i], 2); + } + + for (i = 0; i < yLen; i++) + { + full_nrg += LC3_POW(q_old_res[i], 2); + } + + if (part_nrg < (0.3 * full_nrg)) + { + *bfi = 1; + } + } + } +} + +LC3_FLOAT pc_peak_detector(LC3_FLOAT *q_d_prev, LC3_INT32 yLen) +{ + LC3_INT32 block_size, thresh1, i, peak, j, k; + LC3_FLOAT fac, mean_block_nrg, cur_max, block_cent, maxPeak, next_max, prev_max; + + mean_block_nrg = 0; + + block_size = 3; + thresh1 = 8; + fac = 0.3; + + for (i = 0; i < yLen; i++) + { + mean_block_nrg += LC3_POW(q_d_prev[i], 2); + } + + mean_block_nrg /= yLen; + + maxPeak = 0; + peak = 0; + + if (LC3_FABS(q_d_prev[0]) > LC3_FABS(q_d_prev[1])) + { + block_cent = LC3_POW(q_d_prev[0], 2) + LC3_POW(q_d_prev[1], 2); + + if ((block_cent / block_size) > (thresh1 * mean_block_nrg)) + { + cur_max = MAX(LC3_FABS(q_d_prev[0]), LC3_FABS(q_d_prev[1])); + next_max = array_max_abs(&q_d_prev[2], 3); + + if (cur_max > next_max) + { + maxPeak = block_cent; + peak = 1; + } + } + } + + for (i = 0; i < block_size; i++) + { + if ((LC3_FABS(q_d_prev[i + 1]) >= LC3_FABS(q_d_prev[i])) && LC3_FABS(q_d_prev[i + 1]) >= LC3_FABS(q_d_prev[i + 2])) + { + block_cent = 0; + for (j = i; j < i + block_size; j++) + { + block_cent += LC3_POW(q_d_prev[j], 2); + } + + if ((block_cent / block_size) > (thresh1 * mean_block_nrg)) + { + cur_max = array_max_abs(&q_d_prev[i], block_size); + prev_max = 0; + + for (k = i - block_size; k < i; k++) + { + if (k > 0) + { + prev_max = MAX(LC3_FABS(q_d_prev[k]), prev_max); + } + } + next_max = array_max_abs(&q_d_prev[i + block_size], block_size); + + if ((cur_max >= prev_max) && (cur_max > next_max)) + { + if (block_cent > (fac * maxPeak)) + { + peak = i + block_size - 1; + if (block_cent >= maxPeak) + { + maxPeak = block_cent; + } + } + } + } + } + } + + for (i = block_size; i < yLen - (2 * block_size); i++) + { + if ((LC3_FABS(q_d_prev[i + 1]) >= LC3_FABS(q_d_prev[i])) && LC3_FABS(q_d_prev[i + 1]) >= LC3_FABS(q_d_prev[i + 2])) + { + block_cent = 0; + for (j = i; j < i + block_size; j++) + { + block_cent += LC3_POW(q_d_prev[j], 2); + } + + if ((block_cent / block_size) > (thresh1 * mean_block_nrg)) + { + cur_max = array_max_abs(&q_d_prev[i], block_size); + prev_max = array_max_abs(&q_d_prev[i - block_size], block_size); + next_max = array_max_abs(&q_d_prev[i + block_size], block_size); + + if ((cur_max >= prev_max) && (cur_max > next_max)) + { + if (block_cent > (fac * maxPeak)) + { + peak = i + block_size - 1; + if (block_cent >= maxPeak) + { + maxPeak = block_cent; + } + } + } + } + } + } + + return peak; +} + diff --git a/lib_lc3plus/pc_main.c b/lib_lc3plus/pc_main.c new file mode 100644 index 0000000000000000000000000000000000000000..6ee2bc07276ce8b0ea578c9eb89c121d94d85d68 --- /dev/null +++ b/lib_lc3plus/pc_main.c @@ -0,0 +1,44 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.3 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + + +#include "options.h" +#include "wmc_auto.h" +#include "functions.h" + + +void processPcMain_fl(LC3_INT32 *bfi, LC3PLUS_Dec* decoder, LC3_FLOAT *sqQdec, DecSetup* h_DecSetup, LC3_INT32 pitch_present, LC3_FLOAT stab_fac, LC3_INT32 gg_idx, LC3_INT32 gg_idx_off, LC3_INT32 fac_ns_idx, pcState *statePC, LC3_INT32 spec_inv_idx, LC3_INT32 yLen) +{ + LC3_FLOAT fac; + + /* PC Classifier */ + if (*bfi == 2) + { + processPcClassify_fl(pitch_present, decoder->frame_dms, h_DecSetup->PlcSetup.q_d_prev, statePC->q_old_res, decoder->yLen, h_DecSetup->spec_inv_idx, stab_fac, bfi); + } + + /* PC Apply */ + if (*bfi == 2) + { + processPcApply_fl(sqQdec, statePC->q_old_res, h_DecSetup->PlcSetup.q_d_prev, h_DecSetup->spec_inv_idx, decoder->yLen, gg_idx, gg_idx_off, &statePC->prev_gg, &fac, &statePC->ns_nbLostCmpt_pc); + } + + /* PC Update */ + if (*bfi != 1) + { + processPcUpdate_fl(*bfi, sqQdec, gg_idx, gg_idx_off, decoder->rframe, &h_DecSetup->BW_cutoff_idx_nf, &h_DecSetup->prev_BW_cutoff_idx_nf, fac_ns_idx, &h_DecSetup->prev_fac_ns, &fac, statePC->q_old_res, &statePC->prev_gg, spec_inv_idx, yLen); + } + + /* Reset counter */ + if (*bfi == 0) + { + statePC->ns_nbLostCmpt_pc = 0; + } +} + diff --git a/lib_lc3plus/pc_update.c b/lib_lc3plus/pc_update.c new file mode 100644 index 0000000000000000000000000000000000000000..e57016d401535f93af3759c6ee49e623ca90c057 --- /dev/null +++ b/lib_lc3plus/pc_update.c @@ -0,0 +1,38 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.3 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + + +#include "options.h" +#include "wmc_auto.h" +#include "functions.h" + + +void processPcUpdate_fl(LC3_INT32 bfi, LC3_FLOAT *q_res, LC3_INT32 gg_idx, LC3_INT32 gg_idx_off, LC3_INT32 rframe, LC3_INT32 *BW_cutoff_idx_nf, LC3_INT32 *prev_BW_cutoff_idx_nf, + LC3_INT32 fac_ns_idx, LC3_FLOAT *prev_fac_ns, LC3_FLOAT *fac, LC3_FLOAT *q_old_res, LC3_FLOAT *prev_gg, LC3_INT32 spec_inv_idx, LC3_INT32 yLen) +{ + LC3_FLOAT gg; + + gg = LC3_POW(10.0, ((LC3_FLOAT) (gg_idx + gg_idx_off)) / 28.0); + *prev_gg = gg; + move_float(q_old_res, q_res, yLen); + + if (rframe == 0) + { + *prev_BW_cutoff_idx_nf = *BW_cutoff_idx_nf; + *prev_fac_ns = (8.0 - (LC3_FLOAT) fac_ns_idx) / 16.0; + } else if ((bfi == 2) && (*BW_cutoff_idx_nf != *prev_BW_cutoff_idx_nf) && (spec_inv_idx < yLen)) + { + *BW_cutoff_idx_nf = *prev_BW_cutoff_idx_nf; + *prev_fac_ns = *prev_fac_ns * (*fac); + *prev_fac_ns = MAX(*prev_fac_ns, (8.0 - 7.0) / 16.0); + *prev_fac_ns = MIN(*prev_fac_ns, (8.0 - 0.0) / 16.0); + } + +} + diff --git a/lib_lc3plus/per_band_energy.c b/lib_lc3plus/per_band_energy.c new file mode 100644 index 0000000000000000000000000000000000000000..5785ef82bad4685feea93d494f1a1d67e0831ffe --- /dev/null +++ b/lib_lc3plus/per_band_energy.c @@ -0,0 +1,65 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.3 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + + +#include "options.h" +#include "wmc_auto.h" +#include "functions.h" + +void processPerBandEnergy_fl(LC3_INT bands_number, const LC3_INT* acc_coeff_per_band, LC3_INT16 hrmode, LC3_INT16 frame_dms, LC3_FLOAT* d2, LC3_FLOAT* d) +{ + LC3_INT i, j, start, stop, maxBwBin; + LC3_FLOAT sum; + +#ifdef ENABLE_HR_MODE_FL + if (hrmode) + { + maxBwBin = MAX_BW_HR; + } + else +#else + UNUSED(hrmode); +#endif + { + maxBwBin = MAX_BW; + } + switch (frame_dms) + { +#ifdef ENABLE_2_5MS_MODE + case 25: + maxBwBin = maxBwBin >> 2; + break; +#endif +#ifdef ENABLE_5MS_MODE + case 50: + maxBwBin = maxBwBin >> 1; + break; +#endif +#ifdef CR8_G_ADD_75MS + case 75: + maxBwBin = (maxBwBin >> 2) * 3; + break; +#endif + } + + for (i = 0; i < bands_number; i++) { + sum = 0; + start = acc_coeff_per_band[i]; + stop = MIN(acc_coeff_per_band[i + 1], maxBwBin); + + for (j = start; j < stop; j++) { + sum += d[j] * d[j]; + } + + if (stop - start > 0) { + sum = sum / (LC3_FLOAT)(stop - start); + } + d2[i] = sum; + } +} diff --git a/lib_lc3plus/plc_classify.c b/lib_lc3plus/plc_classify.c new file mode 100644 index 0000000000000000000000000000000000000000..fe650f44bf6eb7e730e349d71a6c64447c870ff9 --- /dev/null +++ b/lib_lc3plus/plc_classify.c @@ -0,0 +1,335 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.3 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + + +#include "options.h" +#include "wmc_auto.h" +#include "functions.h" + +#ifdef CR8_A_PLC_FADEOUT_TUNING + +static LC3_INT32 change_bit_at_position(LC3_INT32 value, LC3_UINT8 bit_position, LC3_INT8 bit) +{ + LC3_INT32 helper_mask = ~(1 << bit_position); + LC3_INT32 tmp = value & helper_mask; + tmp = tmp | (bit << bit_position); + return tmp; +} + +static void update_bit_and_byte_positions(LC3_INT16 longterm_analysis_counter_max_bytebuffer, LC3_INT8 *byte_position, LC3_INT8 *bit_position) +{ + if (*bit_position == 30) + { + *bit_position = 0; + + if ((*byte_position - longterm_analysis_counter_max_bytebuffer) < -1) + { + *byte_position = *byte_position + 1; + } else { + *byte_position = 0; + } + } else { + *bit_position = *bit_position + 1; + } +} + +static void array_insert_and_shift(LC3_INT32 *array, LC3_UINT8 value, LC3_INT16 longterm_analysis_counter_max, LC3_INT16 *overall_counter, LC3_INT8 *byte_position, LC3_INT8 *bit_position) +{ + LC3_INT32 current_byte = 0; + + if (overall_counter != NULL) + { + *overall_counter = MIN(*overall_counter + 1, longterm_analysis_counter_max); + } + + current_byte = array[*byte_position]; + + current_byte = change_bit_at_position(current_byte, *bit_position, value); + + array[*byte_position] = current_byte; +} + +#ifdef CR9_L_RETRAIN_FADEOUT_TYPE_CLASSIFIER +static void array_calculate(LC3_INT32 *array_tdc, LC3_INT32 *array_ns, int length, LC3_INT16 *counter_tdc, LC3_INT16 *counter_ns, LC3_INT16 longterm_analysis_counter_max) +#else +static void array_calculate(LC3_INT32 *array_tdc, LC3_INT32 *array_ns, int length, LC3_INT16 *counter_tdc, LC3_INT16 *counter_ns, LC3_INT16 *counter_phecu, LC3_INT16 overall_counter, LC3_INT16 longterm_analysis_counter_max) +#endif +{ + int i, k; + LC3_INT32 current_byte_tdc = 0, current_byte_ns = 0; + LC3_INT16 counter_loc_tdc = 0, counter_loc_ns = 0, counter_tmp = 0; + + for (i = length - 1; i >= 0; i--) + { + current_byte_tdc = array_tdc[i]; + current_byte_ns = array_ns[i]; + + for (k = 0; k < 30; k++) + { + counter_loc_tdc += ((current_byte_tdc >> k) & 1); + counter_loc_ns += ((current_byte_ns >> k) & 1); + counter_tmp++; + + /* Break from both loops if full 2s buffer has been evaluated */ + if (counter_tmp >= longterm_analysis_counter_max) + { + i = -1; + k = 30; + break; + } + } + } + + *counter_tdc = counter_loc_tdc; + *counter_ns = counter_loc_ns; +#ifndef CR9_L_RETRAIN_FADEOUT_TYPE_CLASSIFIER + *counter_phecu = overall_counter - counter_loc_tdc - counter_loc_ns; +#endif +} +#endif + +static void plc_xcorr_lc(LC3_FLOAT *pcmbufHist, LC3_INT32 max_len_pcm_plc, LC3_INT32 pitch_int, LC3_INT32 framelength, LC3_INT32 frame_dms, LC3_INT32 fs, LC3_FLOAT *xcorr); +static void spectral_centroid_lc(LC3_FLOAT *gains, LC3_INT32 tilt, const LC3_INT *bands_offset, LC3_INT32 bands_number, LC3_INT32 framelength, LC3_INT32 fs, LC3_FLOAT *sc); + +void processPlcClassify_fl(LC3_INT plcMeth, LC3_INT *concealMethod, LC3_INT32 *nbLostCmpt, LC3_INT32 bfi, + LC3_FLOAT *xcorr, LC3_INT32 framelength, LC3_INT32 frame_dms, LC3_INT32 pitch_int, + LC3_INT32 fs, const LC3_INT *band_offsets, LC3_INT32 bands_number, LC3_INT32 tilt, PlcAdvSetup *plcAd + , LC3_INT32 hrmode +) +{ + LC3_FLOAT sc, class; +#ifdef CR8_A_PLC_FADEOUT_TUNING + int fs_idx_tmp; +#endif + + if (plcAd) + { + *xcorr = 0; + } + +#ifdef CR8_A_PLC_FADEOUT_TUNING + fs_idx_tmp = FS2FS_IDX(fs); + /* Save statistics for 24 kHz, 48 kHz and 96 kHz */ + if ((bfi == 1) || ((bfi >= 0) && (bfi <= 2) && ((fs_idx_tmp == 2) || (fs_idx_tmp == 4) || (fs_idx_tmp == 5)))) /* Partial Concealment PC(bfi==2) requires allowing value 2 to pass thru as well */ +#else + if (bfi == 1) +#endif + { +#ifdef CR8_A_PLC_FADEOUT_TUNING + if (bfi == 1) + { + *nbLostCmpt = *nbLostCmpt + 1; + } +#else + *nbLostCmpt = *nbLostCmpt + 1; +#endif + + /* Use pitch correlation at ltpf integer lag if available */ +#ifdef CR8_A_PLC_FADEOUT_TUNING + if ((*nbLostCmpt == 1) || (bfi != 1) )/* PC(bfi==2) requires allowing 2 to pass thru as well */ +#else + if (*nbLostCmpt == 1) +#endif + { +#ifdef CR8_A_PLC_FADEOUT_TUNING + *concealMethod = 4; /* Noise Substitution */ + UNUSED(plcMeth); +#else + *concealMethod = plcMeth; // this is a dangerous mapping! +#endif + + /* Advanced PLC */ + if (pitch_int > 0) + { + *concealMethod = 3; /* Timedomain PLC assumed */ + plc_xcorr_lc(plcAd->pcmbufHist, plcAd->max_len_pcm_plc, pitch_int, framelength, frame_dms, fs, xcorr); + + spectral_centroid_lc(plcAd->scf_q_old, tilt, band_offsets, bands_number, framelength, fs, &sc); + class = *xcorr * 7640.0 / 32768.0 - sc - 5112.0 / 32768.0; + + if (class <= 0) + { + if (frame_dms == 100 && hrmode == 0) + { + *concealMethod = 2; /* PhaseEcu selected */ +#ifdef CR8_A_PLC_FADEOUT_TUNING + array_insert_and_shift(plcAd->plc_longterm_advc_tdc, 0, plcAd->longterm_analysis_counter_max, &plcAd->overall_counter, &plcAd->longterm_counter_byte_position, &plcAd->longterm_counter_bit_position); + array_insert_and_shift(plcAd->plc_longterm_advc_ns, 0, plcAd->longterm_analysis_counter_max, NULL, &plcAd->longterm_counter_byte_position, &plcAd->longterm_counter_bit_position); +#endif + } + else + { +#ifndef CR9_G_PLC_NS_TDC_FIX + *concealMethod = 4; /* Noise Substitution */ +#endif +#ifdef CR8_A_PLC_FADEOUT_TUNING + array_insert_and_shift(plcAd->plc_longterm_advc_tdc, 0, plcAd->longterm_analysis_counter_max, &plcAd->overall_counter, &plcAd->longterm_counter_byte_position, &plcAd->longterm_counter_bit_position); + array_insert_and_shift(plcAd->plc_longterm_advc_ns, 0, plcAd->longterm_analysis_counter_max, NULL, &plcAd->longterm_counter_byte_position, &plcAd->longterm_counter_bit_position); +#endif + } + } +#ifdef CR8_A_PLC_FADEOUT_TUNING + else { + array_insert_and_shift(plcAd->plc_longterm_advc_tdc, 1, plcAd->longterm_analysis_counter_max, &plcAd->overall_counter, &plcAd->longterm_counter_byte_position, &plcAd->longterm_counter_bit_position); + array_insert_and_shift(plcAd->plc_longterm_advc_ns, 0, plcAd->longterm_analysis_counter_max, NULL, &plcAd->longterm_counter_byte_position, &plcAd->longterm_counter_bit_position); + } +#endif + } + else + { + *concealMethod = 4; /* Noise Substitution */ +#ifdef CR8_A_PLC_FADEOUT_TUNING + array_insert_and_shift(plcAd->plc_longterm_advc_tdc, 0, plcAd->longterm_analysis_counter_max, &plcAd->overall_counter, &plcAd->longterm_counter_byte_position, &plcAd->longterm_counter_bit_position); + array_insert_and_shift(plcAd->plc_longterm_advc_ns, 1, plcAd->longterm_analysis_counter_max, NULL, &plcAd->longterm_counter_byte_position, &plcAd->longterm_counter_bit_position); +#endif + } + +#ifdef CR8_A_PLC_FADEOUT_TUNING +#ifdef CR9_L_RETRAIN_FADEOUT_TYPE_CLASSIFIER + array_calculate(plcAd->plc_longterm_advc_tdc, plcAd->plc_longterm_advc_ns, plcAd->longterm_analysis_counter_max_bytebuffer, &plcAd->longterm_counter_plcTdc, &plcAd->longterm_counter_plcNsAdv, plcAd->longterm_analysis_counter_max); +#else + array_calculate(plcAd->plc_longterm_advc_tdc, plcAd->plc_longterm_advc_ns, plcAd->longterm_analysis_counter_max_bytebuffer, &plcAd->longterm_counter_plcTdc, &plcAd->longterm_counter_plcNsAdv, &plcAd->longterm_counter_plcPhaseEcu, plcAd->overall_counter, plcAd->longterm_analysis_counter_max); +#endif + update_bit_and_byte_positions(plcAd->longterm_analysis_counter_max_bytebuffer, &plcAd->longterm_counter_byte_position, &plcAd->longterm_counter_bit_position); +#endif + } + } +} + +static void spectral_centroid_lc(LC3_FLOAT *gains, LC3_INT32 tilt, const LC3_INT *band_offsets, LC3_INT32 bands_number, LC3_INT32 framelength, LC3_INT32 fs, LC3_FLOAT *sc) +{ + LC3_FLOAT gains_lin[M], gains_dee[M], numerator, denumerator; + LC3_INT32 i, j, sum, len, start, stop; + LC3_INT band_offsets_local[MAX_BANDS_NUMBER + 1]; + + numerator = 0; + + for (i = 0; i < M; i++) + { + gains_lin[i] = LC3_POW(2, gains[i]); + } + + for (i = 0; i < M; i++) + { + gains_dee[i] = gains_lin[i] / LC3_POW(10, i * (LC3_FLOAT) tilt / (LC3_FLOAT) (M - 1) / 10.0); + } + + if (bands_number == 64) + { + memmove(band_offsets_local, band_offsets, (bands_number + 1) * sizeof(LC3_INT)); + } + + if (bands_number < 32) + { + band_offsets_local[0] = 0; + j = 32 - bands_number; + for (i = bands_number - 1; i >= j; i--) + { + band_offsets_local[(i + j) * 2 + 1 + 1] = band_offsets[i + 1]; + band_offsets_local[(i + j) * 2 + 0 + 1] = band_offsets[i + 1]; + } + for (i = j - 1; i >= 0; i--) + { + band_offsets_local[i * 4 + 3 + 1] = band_offsets[i + 1]; + band_offsets_local[i * 4 + 2 + 1] = band_offsets[i + 1]; + band_offsets_local[i * 4 + 1 + 1] = band_offsets[i + 1]; + band_offsets_local[i * 4 + 0 + 1] = band_offsets[i + 1]; + } + } + else + if (bands_number < 64) + { + band_offsets_local[0] = 0; + j = 64 - bands_number; + for (i = bands_number - 1; i >= j; i--) + { + band_offsets_local[i + j + 1] = band_offsets[i + 1]; + } + for (i = j - 1; i >= 0; i--) + { + band_offsets_local[i * 2 + 1 + 1] = band_offsets[i + 1]; + band_offsets_local[i * 2 + 0 + 1] = band_offsets[i + 1]; + } + } + + denumerator = 0.001; + + for (i = 0; i < M; i++) + { + sum = 0; len = 0; + start = band_offsets_local[i * 4] + 1; stop = band_offsets_local[i * 4 + 4]; + + for (j = stop; j >= start; j--) + { + sum += j; + len++; + } + + numerator += gains_dee[i] * ((LC3_FLOAT) sum / (LC3_FLOAT) framelength); + denumerator += gains_dee[i] * len; + } + + *sc = numerator / denumerator; + *sc = *sc * (LC3_FLOAT) fs / 48000.0; /* scaling, because training is for 48kHz */ +} + +static void plc_xcorr_lc(LC3_FLOAT *pcmbufHist, LC3_INT32 max_len_pcm_plc, LC3_INT32 pitch_int, LC3_INT32 framelength, + LC3_INT32 frame_dms, LC3_INT32 fs, LC3_FLOAT *xcorr) +{ + LC3_INT32 max_corr_len, pitch_min, corr_len, min_corr_len, pcm_max_corr_len, range1Start, range2Start, i; + LC3_FLOAT norm_w, norm_w_t; + + norm_w_t = 0; norm_w = 0; + + assert(pitch_int >= 0); + assert(pitch_int <= MAX_LEN*100*MAX_PITCH_12K8/12800); + + *xcorr = 0; + + if (pitch_int > 0) + { + pitch_min = fs * MIN_PITCH_12K8/12800; + pcm_max_corr_len = max_len_pcm_plc - pitch_int; + + min_corr_len = 2 * pitch_min; /* at least 5 ms (=2*pitchmin*) corr length */ + max_corr_len = framelength*100/frame_dms; /* maximum 10 ms */ + max_corr_len = MIN( max_corr_len, pcm_max_corr_len ); + + corr_len = MIN( max_corr_len, pitch_int ); /* pitch_int is prefered, but maximum 10ms or left pcm buf size */ + corr_len = MAX( min_corr_len, corr_len ); + + range1Start = max_len_pcm_plc - corr_len; + range2Start = range1Start - pitch_int; + + assert( corr_len >= min_corr_len ); + assert( corr_len <= max_corr_len ); + assert( range2Start >= 0 ); + + for (i = 0; i < corr_len; i++) + { + norm_w += pcmbufHist[range1Start + i] * pcmbufHist[range1Start + i]; + } + + for (i = 0; i < corr_len; i++) + { + norm_w_t += pcmbufHist[range2Start + i] * pcmbufHist[range2Start + i]; + } + + for (i = 0; i < corr_len; i++) + { + *xcorr = *xcorr + pcmbufHist[range1Start + i] * pcmbufHist[range2Start + i]; + } + + *xcorr = *xcorr / sqrt(norm_w * norm_w_t + 0.1); + *xcorr = MAX(0, *xcorr); + } else { + *xcorr = 0; + } +} + diff --git a/lib_lc3plus/plc_compute_stab_fac.c b/lib_lc3plus/plc_compute_stab_fac.c new file mode 100644 index 0000000000000000000000000000000000000000..5c7a736e6808aa4f0232682a03345d563ad952af --- /dev/null +++ b/lib_lc3plus/plc_compute_stab_fac.c @@ -0,0 +1,65 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.3 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + + +#include "options.h" +#include "wmc_auto.h" +#include "functions.h" + + +static void processPlcComputeStabFac_fl(LC3_FLOAT *scf_q, LC3_FLOAT *old_scf_q, LC3_INT32 prev_bfi, LC3_FLOAT *stab_fac); + +void processPlcComputeStabFacMain_fl(LC3_FLOAT *scf_q, LC3_FLOAT *old_scf_q, LC3_FLOAT *old_old_scf_q, LC3_INT32 bfi, LC3_INT32 prev_bfi, + LC3_INT32 prev_prev_bfi, LC3_FLOAT *stab_fac) +{ + if (bfi == 1) + { + if (prev_bfi != 1) + { + processPlcComputeStabFac_fl(old_scf_q, old_old_scf_q, prev_prev_bfi, stab_fac); + } + } + else if (bfi == 2) + { + processPlcComputeStabFac_fl(scf_q, old_scf_q, prev_bfi, stab_fac); + } +} + +static void processPlcComputeStabFac_fl(LC3_FLOAT *scf_q, LC3_FLOAT *old_scf_q, LC3_INT32 prev_bfi, LC3_FLOAT *stab_fac) +{ + LC3_FLOAT tmp; + LC3_INT32 i; + + tmp = 0; + + if (prev_bfi == 1) + { + *stab_fac = 0.8; + } + else + { + for (i = 0; i < M; i++) + { + tmp += (scf_q[i] - old_scf_q[i]) * (scf_q[i] - old_scf_q[i]); + } + + *stab_fac = 1.25 - tmp / 25.0; + + if (*stab_fac > 1) + { + *stab_fac = 1; + } + + if (*stab_fac < 0) + { + *stab_fac = 0; + } + } +} + diff --git a/lib_lc3plus/plc_damping_scrambling.c b/lib_lc3plus/plc_damping_scrambling.c new file mode 100644 index 0000000000000000000000000000000000000000..fd9efd7c0e926e978e1787e6a84f658f8ff4a79d --- /dev/null +++ b/lib_lc3plus/plc_damping_scrambling.c @@ -0,0 +1,290 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.3 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + + +#include "options.h" +#include "wmc_auto.h" +#include "functions.h" + + +void processPlcDampingScramblingMain_fl(LC3_INT32 *ns_seed, + LC3_INT32 *pc_seed, LC3_INT32 ns_nbLostCmpt_pc, + LC3_INT32 ns_nbLostCmpt, LC3_FLOAT *stabFac, LC3_FLOAT *cum_fading_slow, LC3_FLOAT *cum_fading_fast, + LC3_FLOAT *spec_prev, LC3_FLOAT *spec, LC3_INT32 spec_inv_idx, LC3_INT32 yLen, LC3_INT32 bfi, + LC3_INT32 frame_dms, LC3_INT32 concealMethod, LC3_INT32 pitch_present_bfi1, LC3_INT32 pitch_present_bfi2, + LC3_FLOAT *cum_fflcAtten +#ifdef CR8_A_PLC_FADEOUT_TUNING + , LC3_UINT8 plc_fadeout_type +#endif + ) +{ + + LC3_INT32 processDampScramb; + + processDampScramb = 0; + + + if ( bfi != 0 ) + { + if (concealMethod == 4 || bfi == 2) + { + processDampScramb = 1; + } + +#ifdef CR8_A_PLC_FADEOUT_TUNING + if (ns_nbLostCmpt == 1) + { + *cum_fading_slow = 1; + *cum_fading_fast = 1; + *cum_fflcAtten = 1; + } +#endif + + if ( bfi == 1 ) + { + processPlcDampingScrambling_fl(spec, yLen, ns_nbLostCmpt, stabFac, processDampScramb, cum_fflcAtten, + pitch_present_bfi1, frame_dms, cum_fading_slow, cum_fading_fast, ns_seed, 0 +#ifdef CR8_A_PLC_FADEOUT_TUNING + , plc_fadeout_type +#endif + ); + } + else /* bfi == 2 */ + { + processPlcDampingScrambling_fl(spec, yLen, ns_nbLostCmpt_pc, stabFac, processDampScramb, cum_fflcAtten, + pitch_present_bfi2, frame_dms, cum_fading_slow, cum_fading_fast, pc_seed, spec_inv_idx +#ifdef CR8_A_PLC_FADEOUT_TUNING + , plc_fadeout_type +#endif + ); + processPlcUpdateSpec_fl(spec_prev, spec, yLen); + } + } +} + +void processPlcDampingScrambling_fl(LC3_FLOAT *spec, LC3_INT32 yLen, LC3_INT32 nbLostCmpt, LC3_FLOAT *stabFac, LC3_INT32 processDampScramb, + LC3_FLOAT *cum_fflcAtten, LC3_INT32 pitch_present, LC3_INT32 frame_dms, LC3_FLOAT *cum_fading_slow, + LC3_FLOAT *cum_fading_fast, LC3_INT32 *seed, LC3_INT32 spec_inv_idx +#ifdef CR8_A_PLC_FADEOUT_TUNING + , LC3_UINT8 plc_fadeout_type +#endif + ) +{ + LC3_INT32 plc_start_inFrames, plc_end_inFrames, plc_duration_inFrames, x, b, i, ad_ThreshFac_start; + LC3_FLOAT slow, fast, linFuncStartStop, randThreshold, ad_ThreshFac_end, ad_threshFac, frame_energy, mean_energy, energThreshold, fac, m, n, fflcAtten, cum_fading_slow_local, cum_fading_fast_local; + + frame_energy = 0; + +#ifndef CR8_A_PLC_FADEOUT_TUNING + /* Main process */ + if (nbLostCmpt == 1) + { + *cum_fading_slow = 1; + *cum_fading_fast = 1; + *cum_fflcAtten = 1; + } +#endif + + slow = 0.8 + 0.2 * (*stabFac); + fast = 0.3 + 0.2 * (*stabFac); + + switch (frame_dms) + { + case 25: + slow = LC3_SQRT(LC3_SQRT(slow)); + fast = LC3_SQRT(LC3_SQRT(fast)); + break; + case 50: + slow = LC3_SQRT(slow); + fast = LC3_SQRT(fast); + break; +#ifdef CR8_G_ADD_75MS + case 75: + slow = LC3_SQRT(LC3_SQRT(slow*slow*slow)); + fast = LC3_SQRT(LC3_SQRT(fast*fast*fast)); + break; +#endif + } + +#ifdef CR8_A_PLC_FADEOUT_TUNING + if (plc_fadeout_type == 0) + { +#endif + *cum_fading_slow = *cum_fading_slow * slow; + *cum_fading_fast = *cum_fading_fast * fast; +#ifdef CR8_A_PLC_FADEOUT_TUNING + } +#endif + + if (processDampScramb == 1) + { +#ifdef CR8_A_PLC_FADEOUT_TUNING + if (plc_fadeout_type != 0) + { + if (nbLostCmpt < (4 * (100.0 / (LC3_FLOAT)frame_dms))) { + cum_fading_slow_local = 1.0; + } + else if (nbLostCmpt < (8 * (100.0 / (LC3_FLOAT)frame_dms))) { + cum_fading_slow_local = 0.9; + } + else { + cum_fading_slow_local = 0.85; + } + + *cum_fading_slow = *cum_fading_slow * cum_fading_slow_local; + cum_fading_slow_local = *cum_fading_slow; + } + else { +#endif + fflcAtten = 1; + cum_fading_slow_local = *cum_fading_slow; + cum_fading_fast_local = *cum_fading_fast; + + if (spec_inv_idx == 0) + { + if (nbLostCmpt * frame_dms > PLC_FADEOUT_IN_MS * 10) + { + fflcAtten = 0; + *cum_fflcAtten = 0; + } + else if (nbLostCmpt * frame_dms > 200) + { + switch (frame_dms) + { + case 25: fflcAtten = PLC34_ATTEN_FAC_025; break; + case 50: fflcAtten = PLC34_ATTEN_FAC_050; break; +#ifdef CR8_G_ADD_75MS + case 75: fflcAtten = PLC34_ATTEN_FAC_075; break; +#endif + case 100: fflcAtten = PLC34_ATTEN_FAC_100; break; + } + } + + + *cum_fflcAtten = *cum_fflcAtten * fflcAtten; + cum_fading_slow_local = *cum_fading_slow * *cum_fflcAtten; + cum_fading_fast_local = *cum_fading_fast * *cum_fflcAtten; + } + + if (pitch_present == 0) + { + plc_start_inFrames = 1; + } + else { + plc_start_inFrames = floor(PLC4_TRANSIT_START_IN_MS / (frame_dms / 10.0)); + } + + plc_end_inFrames = floor(PLC4_TRANSIT_END_IN_MS / (frame_dms / 10.0)); + plc_duration_inFrames = plc_end_inFrames - plc_start_inFrames; + + if (nbLostCmpt <= plc_start_inFrames) + { + linFuncStartStop = 1; + } + else if (nbLostCmpt >= plc_end_inFrames) + { + linFuncStartStop = 0; + } + else { + x = nbLostCmpt; + m = -1.0 / plc_duration_inFrames; + b = -plc_end_inFrames; + linFuncStartStop = m * (x + b); + } + + randThreshold = -32768 * linFuncStartStop; +#ifdef CR8_A_PLC_FADEOUT_TUNING + } +#endif + + for (i = spec_inv_idx; i < yLen; i++) + { + *seed = 16831 + *seed * 12821; + + *seed = (LC3_INT16)(*seed); + if (*seed == 32768) + { + *seed -= 32768; + } + + if (*seed < 0) + { +#ifdef CR8_A_PLC_FADEOUT_TUNING + if (plc_fadeout_type != 0 || pitch_present == 0 || *seed < randThreshold ) +#else + if (pitch_present == 0 || *seed < randThreshold) +#endif + { + spec[i] = -spec[i]; + } + } + } + +#ifdef CR8_A_PLC_FADEOUT_TUNING + if (plc_fadeout_type == 0) + { +#endif + ad_ThreshFac_start = 10; + ad_ThreshFac_end = 1.2; + ad_threshFac = (ad_ThreshFac_start - ad_ThreshFac_end) * linFuncStartStop + ad_ThreshFac_end; + + if (spec_inv_idx < yLen) + { + for (i = spec_inv_idx; i < yLen; i++) + { + frame_energy = frame_energy + (spec[i] * spec[i]); + } + + mean_energy = frame_energy * 1 / (yLen - spec_inv_idx); + } + else + { + mean_energy = 0; + } + + energThreshold = LC3_SQRT(ad_threshFac * mean_energy); + fac = (cum_fading_slow_local - cum_fading_fast_local) * energThreshold; +#ifdef CR8_A_PLC_FADEOUT_TUNING + } +#endif + + for (i = spec_inv_idx; i < yLen; i++) + { +#ifdef CR8_A_PLC_FADEOUT_TUNING + if (plc_fadeout_type != 0 || LC3_FABS(spec[i]) < energThreshold ) +#else + if (LC3_FABS(spec[i]) < energThreshold) +#endif + { + m = cum_fading_slow_local; + n = 0; + } + else + { + m = cum_fading_fast_local; + + if (spec[i] > 0) + { + n = fac; + } + else if (spec[i] == 0) + { + n = 0; + } + else + { + n = -fac; + } + } + + spec[i] = m * spec[i] + n; + } + } +} + diff --git a/lib_lc3plus/plc_main.c b/lib_lc3plus/plc_main.c new file mode 100644 index 0000000000000000000000000000000000000000..ca4a6bbcb2584a9d4b82fc50877e80280b1472dd --- /dev/null +++ b/lib_lc3plus/plc_main.c @@ -0,0 +1,327 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.3 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + + +#include "options.h" +#include "wmc_auto.h" +#include "functions.h" + +void processPlcMain_fl(LC3_FLOAT *q_d_fl_c, LC3_FLOAT *syntM_fl_c, LC3PLUS_Dec* decoder, DecSetup* h_DecSetup, LC3_INT bfi, + PlcAdvSetup *PlcAdvSetup, PlcSetup *PlcSetup, LC3_INT plcMeth, LC3_INT ltpf_pitch_int, LC3_INT ltpf_pitch_fr, + LC3_INT tilt, const LC3_INT *bands_offset, LC3_INT bands_number, const LC3_INT *bands_offsetPLC, + LC3_INT n_bandsPLC, LC3_INT16 hrmode, pcState *statePC +) +{ + LC3_FLOAT r[MAX_BANDS_NUMBER_PLC], A[M + 1], synth[MAX_LEN + MDCT_MEM_LEN_MAX], energies[MAX_BANDS_NUMBER_PLC]; + LC3_INT32 pitch_classifier; + LC3_FLOAT xcorr; + LC3_INT32 yLen; + LC3_INT16 prev_bfi_plc2; + LC3_FLOAT phEcu_env_stab_local[1]; + LC3_FLOAT phEcu_pfind_sens[1]; + +#ifdef CR8_A_PLC_FADEOUT_TUNING + LC3_INT16 consecutiveLostThreshold = 0; +#endif + +#ifdef CR9_L_RETRAIN_FADEOUT_TYPE_CLASSIFIER + LC3_INT16 thresh_tdc_cnt; + LC3_INT16 thresh_ns_cnt; + LC3_INT16 thresh_tdc_ns_cnt; +#endif + + prev_bfi_plc2 = 1; + if (PlcSetup->nbLostCmpt == 0) + { + prev_bfi_plc2 = 0; + } + assert((h_DecSetup->PlcSetup.prevBfi == 1) == (prev_bfi_plc2 == 1)); + + if (bfi == 1 && PlcAdvSetup) + { + /* FFLC increases the PFLC counter */ + statePC->ns_nbLostCmpt_pc = statePC->ns_nbLostCmpt_pc + 1; + } + + pitch_classifier = ltpf_pitch_int; +#ifdef NONBE_PLC_CLASSIFER_LAG_FIX + if (ltpf_pitch_fr > 2) + { + pitch_classifier++; + } +#endif + + processPlcClassify_fl(plcMeth, &h_DecSetup->concealMethod, &PlcSetup->nbLostCmpt, bfi, &xcorr, + decoder->frame_length, decoder->frame_dms, pitch_classifier, decoder->fs, + bands_offset, bands_number, tilt, PlcAdvSetup, hrmode + ); + + if (bfi == 1) + { +#ifdef CR8_A_PLC_FADEOUT_TUNING + switch(decoder->frame_dms) + { + case 25: + consecutiveLostThreshold = 16; +#ifdef CR9_L_RETRAIN_FADEOUT_TYPE_CLASSIFIER + thresh_tdc_cnt = THRESH_025_DMS_TDC_CNT; + thresh_ns_cnt = THRESH_025_DMS_NS_CNT; + thresh_tdc_ns_cnt = THRESH_025_DMS_TDC_NS_CNT; +#endif + break; + case 50: consecutiveLostThreshold = 8; +#ifdef CR9_L_RETRAIN_FADEOUT_TYPE_CLASSIFIER + thresh_tdc_cnt = THRESH_050_DMS_TDC_CNT; + thresh_ns_cnt = THRESH_050_DMS_NS_CNT; + thresh_tdc_ns_cnt = THRESH_050_DMS_TDC_NS_CNT; +#endif + break; + case 75: consecutiveLostThreshold = 6; +#ifdef CR9_L_RETRAIN_FADEOUT_TYPE_CLASSIFIER + thresh_tdc_cnt = THRESH_075_DMS_TDC_CNT; + thresh_ns_cnt = THRESH_075_DMS_NS_CNT; + thresh_tdc_ns_cnt = THRESH_075_DMS_TDC_NS_CNT; +#endif + break; + case 100: consecutiveLostThreshold = 4; +#ifdef CR9_L_RETRAIN_FADEOUT_TYPE_CLASSIFIER + thresh_tdc_cnt = THRESH_100_DMS_TDC_CNT; + thresh_ns_cnt = THRESH_100_DMS_NS_CNT; + thresh_tdc_ns_cnt = THRESH_100_DMS_TDC_NS_CNT; +#endif + break; + default: assert(0); + } + + if (decoder->fs_idx == 2 || decoder->fs_idx >= 4) + { +#ifdef CR9_L_RETRAIN_FADEOUT_TYPE_CLASSIFIER + if (PlcAdvSetup->longterm_counter_plcTdc < thresh_tdc_cnt){ + PlcAdvSetup->plc_fadeout_type = 1; + } + else if (PlcAdvSetup->longterm_counter_plcNsAdv < thresh_ns_cnt){ + PlcAdvSetup->plc_fadeout_type = 1; + } + else if (PlcAdvSetup->longterm_counter_plcTdc + PlcAdvSetup->longterm_counter_plcNsAdv < thresh_tdc_ns_cnt){ + PlcAdvSetup->plc_fadeout_type = 1; + } + else { + PlcAdvSetup->plc_fadeout_type = 0; + } +#else + if (((PlcAdvSetup->longterm_counter_plcPhaseEcu < PlcAdvSetup->longterm_counter_plcTdc*FAC1_FADEOUT) || + (PlcAdvSetup->longterm_counter_plcPhaseEcu < PlcAdvSetup->longterm_counter_plcNsAdv*FAC1_FADEOUT)) && + (PlcAdvSetup->longterm_counter_plcTdc / (PlcAdvSetup->longterm_counter_plcNsAdv + LC3_EPS) < FAC2_FADEOUT)) + { + PlcAdvSetup->plc_fadeout_type = 0; + } else { + if ((PlcAdvSetup->longterm_counter_plcPhaseEcu > FAC3_FADEOUT * PlcAdvSetup->longterm_counter_plcTdc) || + (PlcAdvSetup->longterm_counter_plcPhaseEcu > FAC3_FADEOUT * PlcAdvSetup->longterm_counter_plcNsAdv)) + { + PlcAdvSetup->plc_fadeout_type = 1; + } else { + PlcAdvSetup->plc_fadeout_type = 0; + } + } +#endif + + if ((PlcAdvSetup->overall_counter - (int)(PLC_LONGTERM_ANALYSIS_STARTUP_FILL * PlcAdvSetup->longterm_analysis_counter_max)) < 0) + { + PlcAdvSetup->plc_fadeout_type = 0; + } +#ifndef CR9_H_REMOVE_SWITCH_TO_PLC_NS + if (PlcSetup->nbLostCmpt >= consecutiveLostThreshold && PlcAdvSetup->plc_fadeout_type == 1) + { + if ( h_DecSetup->concealMethod == 3 ) + { + h_DecSetup->concealMethod = 4; + } + } +#endif +#ifdef CR9_N_SHORT_FADE_FOR_UNSTABLE_PITCH + if (h_DecSetup->rel_pitch_change > REL_PITCH_THRESH && hrmode == 1 && (decoder->frame_dms == 50 || decoder->frame_dms == 25) ){ + PlcAdvSetup->plc_fadeout_type = 2; + } else +#endif + if ( h_DecSetup->concealMethod != 2 ) { + /* not PhECU */ + if (PlcSetup->nbLostCmpt < consecutiveLostThreshold ) + { + PlcAdvSetup->plc_fadeout_type = 0; + } + } + } else { + PlcAdvSetup->plc_fadeout_type = 0; + } +#endif + +#ifdef PLC_CR8_A_PRINTF + printf("plc_fadeout_type = %d\n", PlcAdvSetup->plc_fadeout_type); +#endif + switch (h_DecSetup->concealMethod) + { + case 2: + { + LC3_FLOAT pitch_fl_c; + + assert(decoder->fs_idx == floor(decoder->fs / 10000)); + /* phaseECU supports only 10ms framing*/ + assert(PlcSetup->nbLostCmpt != 0 || decoder->frame_dms == 100); + + if (decoder->frame_dms != 100) + { + // muting, if frame size changed during phaseECU concealment + memset(q_d_fl_c, 0, sizeof(LC3_FLOAT) * decoder->frame_length); + h_DecSetup->alpha = 0; + break; + } + + /* call phaseEcu */ + pitch_fl_c = (LC3_FLOAT)ltpf_pitch_int + (LC3_FLOAT)ltpf_pitch_fr / 4.0; /* use non-rounded pitch indeces */ + + + if (prev_bfi_plc2 == 0) + { + /* convert fractional pitch lag info at current fs to a normalized fractional bin-frequency */ + PlcAdvSetup->PlcPhEcuSetup.PhECU_f0hzLtpBin = plc_phEcuSetF0Hz(decoder->fs, &pitch_fl_c); + /* several buffers used in Cflt , a copy pcmbufHist, right before calling PhEcu in bad frames */ + assert(bfi == 1); + move_float(PlcAdvSetup->PlcPhEcuSetup.PhECU_xfp, + &(PlcAdvSetup->pcmbufHist[PlcAdvSetup->max_len_pcm_plc - PlcAdvSetup->PlcPhEcuSetup.PhECU_Lprot]), + PlcAdvSetup->PlcPhEcuSetup.PhECU_Lprot); + + /* a first bfi frame:: calc windowed 16 ms energy twice in a 26 ms buffer separated by 10 ms*/ + { + const LC3_FLOAT *w, *prev_xfp; + LC3_INT32 i, oold_start; + + oold_start = PlcAdvSetup->max_len_pcm_plc - (decoder->frame_length + PlcAdvSetup->PlcPhEcuSetup.PhECU_Lprot); + assert(oold_start > 0); + w = PhECU_whr16ms_wins[decoder->fs_idx]; /* hammrect table */ + prev_xfp = &(PlcAdvSetup->pcmbufHist[oold_start + 0]); + + PlcAdvSetup->PlcPhEcuSetup.PhECU_L_oold_xfp_w_E = 0; + PlcAdvSetup->PlcPhEcuSetup.PhECU_L_old_xfp_w_E = 0; + for (i = 0; i < PlcAdvSetup->PlcPhEcuSetup.PhECU_Lprot; i++) + { + PlcAdvSetup->PlcPhEcuSetup.PhECU_L_oold_xfp_w_E += sqrf(prev_xfp[i] * w[i]); + PlcAdvSetup->PlcPhEcuSetup.PhECU_L_old_xfp_w_E += sqrf(PlcAdvSetup->PlcPhEcuSetup.PhECU_xfp[i] * w[i]); + } + + } + + } /* (prev_bfi_plc2 == 0)*/ + else + { + /* overwrite last 3.75 ms of xfp with most recent pcmbufHist tail , right before calling PhEcu in bursts of bad frames */ + LC3_INT32 lenCopyOla = decoder->la_zeroes; /*copy_part + ola_part = 3.75 ms for 10 ms frame*/ + + assert(bfi == 1 && prev_bfi_plc2); + move_float(&(PlcAdvSetup->PlcPhEcuSetup.PhECU_xfp[PlcAdvSetup->PlcPhEcuSetup.PhECU_Lprot-lenCopyOla]), + &(PlcAdvSetup->pcmbufHist[PlcAdvSetup->max_len_pcm_plc - lenCopyOla]), lenCopyOla); + + } + + { + LC3_FLOAT x_tda[MAX_LEN]; /* 960/2 */ + PlcAdvSetup->PlcPhEcuSetup.PhECU_norm_corr = xcorr; + phEcu_env_stab_local[0] = (LC3_FLOAT)PHECU_ENV_STAB_LOCAL; + phEcu_pfind_sens[0] = (LC3_FLOAT)PHECU_PFIND_SENS; + + plc_phEcu_hq_ecu(&(PlcAdvSetup->PlcPhEcuSetup.PhECU_f0hzLtpBin), + &(PlcAdvSetup->PlcPhEcuSetup.PhECU_norm_corr), + PlcAdvSetup->PlcPhEcuSetup.PhECU_xfp, + prev_bfi_plc2, + &(PlcAdvSetup->PlcPhEcuSetup.PhECU_short_flag_prev), + decoder->fs, + &(PlcAdvSetup->PlcPhEcuSetup.PhECU_time_offs), + PlcAdvSetup->PlcPhEcuSetup.PhECU_X_sav_m, /* Complex */ + &(PlcAdvSetup->PlcPhEcuSetup.PhECU_num_plocs), + PlcAdvSetup->PlcPhEcuSetup.PhECU_plocs, + PlcAdvSetup->PlcPhEcuSetup.PhECU_f0est, + MDCT_WINS_10ms[hrmode][decoder->fs_idx], + + phEcu_env_stab_local, + PHECU_DELTA_CORR, + phEcu_pfind_sens, + PHECU_LA, + PlcAdvSetup->PlcPhEcuSetup.PhECU_t_adv, + PhECU_whr16ms_wins[decoder->fs_idx], + PlcAdvSetup->PlcPhEcuSetup.PhECU_oold_grp_shape, + &(PlcAdvSetup->PlcPhEcuSetup.PhECU_L_oold_xfp_w_E), + PlcAdvSetup->PlcPhEcuSetup.PhECU_old_grp_shape, + &(PlcAdvSetup->PlcPhEcuSetup.PhECU_L_old_xfp_w_E), + &(PlcAdvSetup->PlcPhEcuSetup.PhECU_beta_mute), + PlcAdvSetup->PlcPhEcuSetup.PhECU_mag_chg_1st, + PlcAdvSetup->PlcPhEcuSetup.PhECU_Xavg, + decoder->la_zeroes, + x_tda, /* time domain aliased output */ + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL + , + &(PlcAdvSetup->PlcPhEcuSetup.PhEcu_Fft), + &(PlcAdvSetup->PlcPhEcuSetup.PhEcu_Ifft) +#ifdef CR8_A_PLC_FADEOUT_TUNING + ,PlcAdvSetup->plc_fadeout_type, + &(PlcAdvSetup->PlcPhEcuSetup.PhECU_nonpure_tone_flag) /* nonpure tone flag */ +#endif + ); + + + ProcessingITDA_WIN_OLA_fl(x_tda, decoder->frame_length, decoder->imdct_win, decoder->imdct_winLen, decoder->imdct_laZeros, + h_DecSetup->imdct_mem, synth); + move_float(syntM_fl_c, synth, decoder->frame_length); + + + } + } + break; + case 3: + if (PlcSetup->nbLostCmpt == 1) + { + PlcAdvSetup->PlcTdcSetup.fract = ltpf_pitch_fr; + } + + processPerBandEnergy_fl(n_bandsPLC, bands_offsetPLC, hrmode, decoder->frame_dms, energies, PlcSetup->q_d_prev); + processTdcPreemphasis_fl(energies, &PlcAdvSetup->PlcTdcSetup.preemphFac, n_bandsPLC); + processTdcInverseOdft_fl(energies, n_bandsPLC, r, PlcAdvSetup->PlcTdcSetup.lpcorder); + processTdcLpcEstimation_fl(r, decoder->fs_idx, PlcAdvSetup->PlcTdcSetup.lpcorder + 1, A, decoder->frame_dms); + processTdcApply_fl(ltpf_pitch_int, &PlcAdvSetup->PlcTdcSetup.preemphFac, A, PlcAdvSetup->PlcTdcSetup.lpcorder, PlcAdvSetup->pcmbufHist, PlcAdvSetup->max_len_pcm_plc, decoder->frame_length, + decoder->frame_dms, decoder->fs, PlcSetup->nbLostCmpt, decoder->frame_length - decoder->la_zeroes, &PlcAdvSetup->stabFac, PlcAdvSetup->PlcTdcSetup.harmonicBuf, + PlcAdvSetup->PlcTdcSetup.synthHist, &PlcAdvSetup->PlcTdcSetup.fract, &PlcAdvSetup->PlcTdcSetup.seed, &PlcAdvSetup->PlcTdcSetup.gain_c, + &h_DecSetup->alpha, synth +#ifdef CR9_I_INC_TDC_FADEOUT_LEN + ,PlcAdvSetup->plc_fadeout_type +#endif +); + + processTdcTdac_fl(synth, decoder->imdct_win, decoder->frame_length, decoder->la_zeroes, h_DecSetup->imdct_mem); + memmove(syntM_fl_c, synth, sizeof(LC3_FLOAT) * decoder->frame_length); + break; + case 4: + processNoiseSubstitution_fl(q_d_fl_c, PlcSetup->q_d_prev, decoder->yLen); + break; + default: + assert("Invalid PLC method!"); + } + } + + if (bfi == 0) + { + processPlcUpdateSpec_fl(PlcSetup->q_d_prev, q_d_fl_c, decoder->yLen); + } + + yLen = MIN(decoder->frame_length, MAX_PLC_LMEM); + if (PlcAdvSetup != NULL && (decoder->frame_dms == 100) && (hrmode == 0)) + { + /* BASOP processPLCspec2shape_fx(prev_bfi, bfi, q_old_d_fx, yLen, plcAd->PhECU_oold_grp_shape_fx, plcAd->PhECU_old_grp_shape_fx);*/ + plc_phEcu_processPLCspec2shape(prev_bfi_plc2, bfi, q_d_fl_c, yLen, + PlcAdvSetup->PlcPhEcuSetup.PhECU_oold_grp_shape, PlcAdvSetup->PlcPhEcuSetup.PhECU_old_grp_shape); + } +} + diff --git a/lib_lc3plus/plc_noise_substitution.c b/lib_lc3plus/plc_noise_substitution.c new file mode 100644 index 0000000000000000000000000000000000000000..c366015fc0942022a026dd4b019bcbee05f7c047 --- /dev/null +++ b/lib_lc3plus/plc_noise_substitution.c @@ -0,0 +1,23 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.3 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + + +#include "options.h" +#include "wmc_auto.h" +#include "functions.h" + + +void processNoiseSubstitution_fl(LC3_FLOAT* spec, LC3_FLOAT* spec_prev, LC3_INT32 yLen) +{ + memmove(spec, spec_prev, sizeof(LC3_FLOAT) * yLen); + + spec[0] *= 0.2; + spec[1] *= 0.5; +} + diff --git a/lib_lc3plus/plc_phecu_f0_refine_first.c b/lib_lc3plus/plc_phecu_f0_refine_first.c new file mode 100644 index 0000000000000000000000000000000000000000..c3f8edfab2098213459486466b680f6c1b4ff03b --- /dev/null +++ b/lib_lc3plus/plc_phecu_f0_refine_first.c @@ -0,0 +1,76 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.3 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + + +#include "options.h" +#include "wmc_auto.h" +#include "defines.h" +#include "functions.h" + + +void plc_phEcu_F0_refine_first( LC3_INT32 *plocs, /* i/o 0 ... Lprot/2 +1*/ + LC3_INT32 n_plocs, + LC3_FLOAT *f0est, /* i/o f0est */ + const LC3_INT32 Xabs_len, + LC3_FLOAT *f0binPtr, /* i */ + LC3_FLOAT *f0gainPtr, /* i */ + const LC3_INT32 nSubm + ) +{ + LC3_FLOAT sens; + LC3_INT32 i, j, high_idx, breakflag; + LC3_FLOAT f0est_lim[MAX_PLC_NPLOCS]; + LC3_FLOAT f0bin; + LC3_FLOAT f0gain; + + f0bin = *f0binPtr; + f0gain = *f0gainPtr; + + if (n_plocs > 0 && f0gain > 0.25) { + + sens = 0.5; + if (f0gain < 0.75) { + sens = 0.25; + } + + high_idx = -1; + for (i = 0; i < n_plocs; i++) { + if (plocs[i] <= 25) { /* 25 ~= 1550 Hz */ + high_idx = MAX(high_idx, i); + } else { + /* Optimization, only works if plocs vector is sorted. Which it should be. */ + break; + } + } + + if (high_idx != -1) { + high_idx++; + move_float(f0est_lim, f0est, high_idx); + + breakflag = 0; + for (i = 0; i < nSubm; i++) { + for (j = 0; j < high_idx; j++) { + if (LC3_FABS(f0est_lim[j] - (i+1) * f0bin) < sens) { + f0est[j] = (i+1)*f0bin; + plocs[j] = MIN(Xabs_len-1, MAX(1,(LC3_INT32) LC3_ROUND(f0est[j]))); + breakflag = 1; + break; + } + } + if (breakflag) { + break; + } + sens *= 0.875; + } + } + } + + return; +} + diff --git a/lib_lc3plus/plc_phecu_fec_hq.c b/lib_lc3plus/plc_phecu_fec_hq.c new file mode 100644 index 0000000000000000000000000000000000000000..9213b9ea532bfe89411a0cb269296ebb58f303e5 --- /dev/null +++ b/lib_lc3plus/plc_phecu_fec_hq.c @@ -0,0 +1,160 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.3 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + + +#include "options.h" +#include "wmc_auto.h" +#include "defines.h" +#include "functions.h" + + +LC3_FLOAT plc_phEcu_imax2_jacobsen_mag(const Complex *y, LC3_FLOAT *c_jacobPtr) { + + LC3_FLOAT posi; + const Complex *pY; + Complex y_m1, y_0, y_p1; + Complex N; + Complex D; + LC3_FLOAT numer, denom; + + /* Jacobsen estimates peak offset relative y_0 using + * X_m1 - X_p1 + * d = REAL ( ------------------- ) * c_jacob + * 2*X_0 - X_m1 -Xp1 + * + * Where c_jacob is a window dependent constant + */ + + /* Get the parameters into variables */ + pY = y; + y_m1 = *pY++; + y_0 = *pY++; + y_p1 = *pY++; + + /* prepare numerator real and imaginary parts*/ + N = csub(y_m1, y_p1); + + /* prepare denominator real and imaginary parts */ + D = cmul(cmplx(2.0, 0.0), y_0); + D = csub(D, y_m1); + D = csub(D, y_p1); + + /* REAL part of complex division */ + numer = N.r*D.r + N.i*D.i; + denom = D.r*D.r + D.i*D.i; + + if (numer != 0 && denom != 0) { + posi = numer / denom * (*c_jacobPtr); + } else { + posi = 0.0; /* flat top, division is not possible choose center freq */ + } + + + posi = fclampf(-1.0, posi, 1.0); + return posi; +} + +/*-------------------------------------------------------------------* + * imax() + * + * Get interpolated maximum position + *-------------------------------------------------------------------*/ + +LC3_FLOAT plc_phEcu_interp_max(const LC3_FLOAT *y, LC3_INT32 y_len) { + LC3_FLOAT posi, y1, y2, y3, y3_y1, y2i; + LC3_FLOAT ftmp_den1, ftmp_den2; + + /* Seek the extrema of the parabola P(x) defined by 3 consecutive points so that P([-1 0 1]) = [y1 y2 y3] */ + y1 = y[0]; + y2 = y[1]; + + /* If interp between two values only */ + if (y_len == 2) { + if (y1 < y2) { + return 1.0; + } else { + return 0.0; + } + } + + y3 = y[2]; + y3_y1 = y3-y1; + ftmp_den1 = (y1+y3-2*y2); + ftmp_den2 = (4*y2 - 2*y1 - 2*y3); + + if(ftmp_den2 == 0.0 || ftmp_den1 == 0.0) { + return 0.0; /* early exit with left-most value */ + } + + y2i = ((LC3_FLOAT)-0.125) * sqrf(y3_y1) /(ftmp_den1) + y2; + /* their corresponding normalized locations */ + posi = y3_y1/(ftmp_den2); + /* Interpolated maxima if locations are not within [-1,1], calculated extrema are ignored */ + if (posi >= (LC3_FLOAT)1.0 || posi <= (LC3_FLOAT)-1.0) { + posi = y3 > y1 ? (LC3_FLOAT)1.0 : (LC3_FLOAT)-1.0; + } else { + if (y1 >= y2i) { + posi = (y1 > y3) ? (LC3_FLOAT)-1.0 :(LC3_FLOAT) 1.0; + } else if (y3 >= y2i) { + posi = (LC3_FLOAT)1.0; + } + } + + return posi + (LC3_FLOAT)1.0; +} + +/*----------------------------------------------------------------------------- + * fft_spec2_sqrt_approx_ () + * + * Approximation of sqrt(Square magnitude) of fft spectrum + * if min_abs <= 0.4142135*max_abs + * abs = 0.99 max_abs + 0.197*min_abs + * else + * abs = 0.84 max_abs + 0.561*min_abs + * end + * + + *----------------------------------------------------------------------------*/ + +void plc_phEcu_fft_spec2_sqrt_approx(const Complex* x, LC3_INT32 x_len, LC3_FLOAT* x_abs) { + LC3_INT32 i; + LC3_FLOAT max_abs, min_abs, re, im; + + for (i = 0; i < x_len; i++) { + re = LC3_FABS(x[i].r); + im = LC3_FABS(x[i].i); + max_abs = MAX(re, im); + min_abs = MIN(re, im); + + if (min_abs <= (LC3_FLOAT)0.4142135 * max_abs) { + x_abs[i] = (LC3_FLOAT)0.99*max_abs + (LC3_FLOAT)0.197*min_abs; + } else { + x_abs[i] = (LC3_FLOAT)0.84*max_abs + (LC3_FLOAT)0.561*min_abs; + } + } + + return; +} + +LC3_INT32 plc_phEcu_pitch_in_plocs(LC3_INT32* plocs, LC3_INT32 n_plocs) { + + LC3_INT32 i; + LC3_INT32 p_in_plocs; + + p_in_plocs = 0; + + for (i = 0; i < n_plocs; i++) { + if (plocs[i] > 0 && plocs[i] < 7) { + p_in_plocs++; + } + } + + return p_in_plocs; +} + diff --git a/lib_lc3plus/plc_phecu_hq_ecu.c b/lib_lc3plus/plc_phecu_hq_ecu.c new file mode 100644 index 0000000000000000000000000000000000000000..577a56e83a8817c21216b6909d91c569b34019bd --- /dev/null +++ b/lib_lc3plus/plc_phecu_hq_ecu.c @@ -0,0 +1,143 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.3 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + + +#include "options.h" +#include "wmc_auto.h" +#include "defines.h" +#include "functions.h" + + + +void plc_phEcu_hq_ecu( + LC3_FLOAT *f0binPtr, LC3_FLOAT *f0ltpGainPtr, LC3_FLOAT *xfp, + LC3_INT16 prev_bfi, LC3_INT32 *short_flag_prev, LC3_INT32 fs, + LC3_INT32 *time_offs, Complex *X_sav_m, LC3_INT32 *n_plocs, LC3_INT32 *plocs, LC3_FLOAT *f0est, + const LC3_FLOAT *mdctWin, LC3_FLOAT *env_stabPtr, LC3_INT32 delta_corr, LC3_FLOAT *pfind_sensPtr, + LC3_INT32 PhECU_LA, LC3_INT32 t_adv, const LC3_FLOAT *winWhr, + LC3_FLOAT *oold_grp_shape, LC3_FLOAT *oold_EwPtr, LC3_FLOAT *old_grp_shape, LC3_FLOAT *old_EwPtr, + LC3_FLOAT *st_beta_mute, LC3_FLOAT *st_mag_chg_1st, LC3_FLOAT *st_Xavg, LC3_INT32 LA_ZEROS, LC3_FLOAT *x_tda, + LC3_FLOAT *xsubst_dbg, Complex *X_out_m_dbg, + LC3_INT32 *seed_dbg, LC3_FLOAT *mag_chg_dbg, LC3_INT32 *tr_dec_dbg, LC3_FLOAT *gpc_dbg, LC3_FLOAT *X_i_new_re_dbg, LC3_FLOAT *X_i_new_im_dbg, + LC3_FLOAT *corr_phase_dbg, + Fft *PhEcu_Fft, Fft *PhEcu_Ifft +#ifdef CR8_A_PLC_FADEOUT_TUNING + , LC3_UINT8 plc_fadeout_type, LC3_INT16 *nonpure_tone_flag_ptr /* nonpure tone flag */ +#endif + + ) +{ + LC3_INT32 i; + LC3_INT32 fs_idx, L, Lprot, n_grp, Lecu, LXsav, Lxfp_inuse; + LC3_FLOAT alpha[8]; + LC3_FLOAT beta[8]; + LC3_FLOAT mag_chg[8]; + LC3_FLOAT xfp_local_rnd[2*MAX_LEN]; + Complex X_out_m[2*MAX_LEN]; + LC3_INT32 seed; + LC3_INT32 burst_len; + + + fs_idx = (LC3_INT32)floor(fs / 10000.0); + L = (LC3_INT32)floor(0.01 * fs); + Lprot = (LC3_INT32)(1.6 * L); + n_grp = xavg_N_grp[fs_idx]; + Lecu = 2 * L; + LXsav = Lprot / 2 + 1; /* 48 kHz may be optimized , to save only up to 20 kHz as in BASOP */ + Lxfp_inuse = Lprot ; + if (prev_bfi == 1){ + Lxfp_inuse = (LC3_INT32)(L*(3.75/10.0)); + } + + + + UNUSED(env_stabPtr); + UNUSED(xsubst_dbg); + UNUSED(X_out_m_dbg); + UNUSED(seed_dbg); + UNUSED(mag_chg_dbg); + UNUSED(tr_dec_dbg); + UNUSED(gpc_dbg); + UNUSED(X_i_new_re_dbg); + UNUSED(X_i_new_im_dbg); + UNUSED(corr_phase_dbg); + + + if (prev_bfi != 1) + { + for (i = (Lprot-Lxfp_inuse); i < Lprot; i++) { + xfp_local_rnd[i] = xfp[i]; + /* hysteresis of low level input aligns float fft analysis and peak picking to BASOP performance for low level noisy signals */ + if (xfp[i] >= -0.5 && xfp[i] <= 0.5) { + xfp_local_rnd[i] = 0.0; + } + } +#ifdef CR8_A_PLC_FADEOUT_TUNING + *nonpure_tone_flag_ptr = -1; /* set nonpure tone flag for new analysis */ +#endif + + + *time_offs = 0; + burst_len = (*time_offs / L + 1); + plc_phEcu_trans_burst_ana_sub(fs_idx, burst_len, n_grp, oold_grp_shape, oold_EwPtr , old_grp_shape, old_EwPtr, st_beta_mute, + st_mag_chg_1st, st_Xavg, alpha, beta, mag_chg, NULL, NULL + +#ifdef CR8_A_PLC_FADEOUT_TUNING + ,plc_fadeout_type +#endif + ); + + plc_phEcu_spec_ana(xfp_local_rnd, Lprot, winWhr, pfind_sensPtr, plocs, n_plocs, f0est, X_sav_m, &LXsav, f0binPtr, f0ltpGainPtr, fs_idx, PhEcu_Fft); + } + else + { + *time_offs = *time_offs + L; + *time_offs = imin(32767 ,*time_offs); /* limit to Word16 range as in BASOP ~= 70 10ms frames@48kHz */ + burst_len = ((*time_offs / L) + 1); + + plc_phEcu_trans_burst_ana_sub(fs_idx, burst_len, n_grp, oold_grp_shape, oold_EwPtr, old_grp_shape, old_EwPtr, st_beta_mute, + st_mag_chg_1st, st_Xavg, alpha, beta, mag_chg, NULL, NULL +#ifdef CR8_A_PLC_FADEOUT_TUNING + ,plc_fadeout_type +#endif + ); + + } + + seed = *time_offs; + + if (*short_flag_prev != 0) + { + *n_plocs = 0; + } + + move_cmplx( X_out_m, X_sav_m, LXsav); + + /* inplace X_out_m update */ + plc_phEcu_subst_spec(plocs, *n_plocs, f0est, *time_offs, X_out_m, LXsav, mag_chg, &seed, alpha, beta, st_Xavg, t_adv, Lprot, delta_corr, +#ifdef CR8_A_PLC_FADEOUT_TUNING + plc_fadeout_type, + nonpure_tone_flag_ptr, /* nonpure_tone_flag , a state updated here */ +#endif + + + NULL, NULL, NULL); + + + + + plc_phEcu_rec_frame(X_out_m, L, Lecu, winWhr, mdctWin, Lprot, + xfp, /* last 3.75ms of non-rounded xfp used here */ + *time_offs, + x_tda /* output */, + NULL, NULL, NULL, + LA_ZEROS, PhECU_LA, PhEcu_Ifft); + +} + diff --git a/lib_lc3plus/plc_phecu_lf_peak_analysis.c b/lib_lc3plus/plc_phecu_lf_peak_analysis.c new file mode 100644 index 0000000000000000000000000000000000000000..53c10410c0cd4db440deb72785795eeba351b67e --- /dev/null +++ b/lib_lc3plus/plc_phecu_lf_peak_analysis.c @@ -0,0 +1,113 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.3 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + + +#include "options.h" +#include "wmc_auto.h" +#include "defines.h" +#include "functions.h" + + +void plc_phEcu_LF_peak_analysis(LC3_INT32 *plocs, /* i/o 0 ... Lprot/2 +1*/ + LC3_INT32 *n_plocs, /* i/o 0.. MAX_PLOCS */ + LC3_FLOAT *f0est, /* i/o Q16*/ + const LC3_FLOAT *Xabs, + LC3_FLOAT *f0binPtr, + LC3_FLOAT *f0gainPtr, + const LC3_INT32 nSubm +) +{ + LC3_INT32 i, j, fin, f_ind, prel_low, prel_high, start; + LC3_FLOAT f0est_prel[3]; + LC3_INT32 plocs_prel[3]; + LC3_INT32 n_prel; + LC3_FLOAT f0est_old[MAX_PLC_NPLOCS]; + LC3_INT32 plocs_old[MAX_PLC_NPLOCS]; + LC3_FLOAT peakLF_Xval, f; + LC3_FLOAT f0bin ; + LC3_FLOAT f0gain ; + + f0bin = *f0binPtr; + f0gain = *f0gainPtr; + + if (*n_plocs > 0 && f0gain > 0.25 && f0bin < 2.75) { + + /* Assumes sorted plocs */ + if (plocs[0] < 3) { + fin = MIN(3, *n_plocs); + peakLF_Xval = Xabs[plocs[0]]; + for (i = 1; i < fin; i++) { + peakLF_Xval = MAX(peakLF_Xval, Xabs[plocs[i]]); + } + + n_prel = 0; + for (i = 0; i < nSubm; i++) { + f = (i+1)*f0bin; + f_ind = (LC3_INT32)LC3_ROUND(f); + if (f*PHECU_FRES <= 400 && Xabs[f_ind] > peakLF_Xval*0.375) { + f0est_prel[n_prel] = f; + plocs_prel[n_prel] = f_ind; + n_prel++; + } + } + + if (n_prel > 0) { + prel_low = plocs_prel[0]; + prel_high = plocs_prel[n_prel-1]; + + /* initial assumption:: all original peaks (1 or 2 of them) are positioned below prel_low */ + start = (*n_plocs); /* at this point 'start' is the location_c where to add any harmonics peaks */ + for (i = (*n_plocs)-1; i >= 0; i--) { + if (plocs[i] >= prel_low) { + start = i; + } + } + + /* found position_c where to start adding */ + start = (start-1 ); /* one step lower, now start is of original LF peaks to keep */ + start = MAX(start, -1); /* limit for loop */ + + if (prel_high < plocs[0]) { + fin = 0; + } else { + fin = (*n_plocs)+1; + for (i = 0; i < *n_plocs; i++) { + if (plocs[i] <= prel_high) { + fin = i; + } + } + fin++; + } + + move_int(plocs_old, plocs, *n_plocs); + move_float(f0est_old, f0est, *n_plocs); + + j = (start+1); /* [0..(j-1)] of original LF peaks will be kept */ + /* j now points to first location_c where to add peaks */ + + for (i = 0; i < n_prel; i++) { + plocs[j] = plocs_prel[i]; + f0est[j] = f0est_prel[i]; + j++; + } + for (i = fin; i < *n_plocs; i++) { + plocs[j] = plocs_old[i]; + f0est[j] = f0est_old[i]; + j++; + } + + *n_plocs = j; + + } + } + } + + return; +} + diff --git a/lib_lc3plus/plc_phecu_rec_frame.c b/lib_lc3plus/plc_phecu_rec_frame.c new file mode 100644 index 0000000000000000000000000000000000000000..4586e1d625d0dfdaad7a332315c98901a1179089 --- /dev/null +++ b/lib_lc3plus/plc_phecu_rec_frame.c @@ -0,0 +1,153 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.3 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + + +#include "options.h" +#include "wmc_auto.h" +#include "defines.h" +#include "functions.h" + + +void plc_phEcu_rec_frame(Complex *X_in, + LC3_INT32 L, + LC3_INT32 Lecu, + const LC3_FLOAT *whr, + const LC3_FLOAT *winMDCT, + LC3_INT32 Lprot, + LC3_FLOAT *xfp, + LC3_INT32 time_offs, + LC3_FLOAT *x_out, + Complex *full_spec_dbg, + LC3_FLOAT* ifft_out_dbg, + LC3_FLOAT* xsubst_dbg, + LC3_INT32 LA_ZEROS, + LC3_INT32 LA, + Fft* PhEcu_ifft +) +{ + + LC3_INT32 i; + + LC3_FLOAT xrec[2*MAX_LEN]; + LC3_FLOAT xsubst[2*MAX_LEN]; + LC3_FLOAT xsubst_LL[2*MAX_LEN]; + LC3_FLOAT *pXsubst_LL; + + LC3_INT32 fs_idx; + + LC3_FLOAT *pXfp, *pOlaXsubst, *pXOut; + LC3_INT32 work_part, copy_part, ola_part; + + const LC3_FLOAT *hannOla; + const LC3_FLOAT *pHannOla; + + UNUSED(time_offs); + UNUSED(full_spec_dbg); + UNUSED(ifft_out_dbg); + UNUSED(xsubst_dbg); + UNUSED(xsubst_LL); + +#ifdef CR8_A_PLC_FADEOUT_TUNING + fs_idx = FRAME2FS_IDX_10MS(L); +#else + fs_idx = FRAME2FS_IDX(L); +#endif + hannOla = hannOla_wins[fs_idx]; + + X_in[0].i = X_in[Lprot / 2].r; /* move fs/2 real to imag part of X_in[0]*/ + + real_fft_apply(PhEcu_ifft, (LC3_FLOAT*)X_in, xrec); + + move_float(xsubst, xrec, Lprot); + + + + + { + for (i = 0; i < Lprot; i++) { + + if (whr[i] != 0) { + xsubst[i] = xsubst[i] / whr[i]; /* inverse stored in BASOP */ + } + + } + + assert(xsubst_LL != NULL); + zero_float(xsubst_LL, (Lecu-Lprot)/2); /* initial 2ms */ + zero_float(&(xsubst_LL[ Lecu- (Lecu-Lprot)/2]), (Lecu-Lprot)/2); /* tail 2ms */ + { + /* position reconstruction properly */ + /* pXsubst_LL = &xsubst_LL[Lecu - Lprot - (Lecu - Lprot) / 2]; */ + pXsubst_LL = &xsubst_LL[(Lecu - Lprot) / 2]; + for (i = 0; i < Lprot ; i++) { + *pXsubst_LL++ = xsubst[i]; /* copy required 14.25 ms into center */ + } + } + + } + + + + work_part = LA_ZEROS + LA; + copy_part = (Lecu - Lprot) / 2; + ola_part = work_part - copy_part; + + pXfp = &xfp[Lprot - work_part]; + for (i = 0; i < copy_part; i++) { + xsubst_LL[i] = *pXfp++; + } + + assert(xsubst_LL != NULL); + pOlaXsubst = &(xsubst_LL[copy_part]); + pHannOla = hannOla; + for (i = 0; i < ola_part; i++) { + *pOlaXsubst = *pOlaXsubst * *pHannOla++; + pOlaXsubst++; + } + + pOlaXsubst = &(xsubst_LL[copy_part]); + for (i = 0; i < ola_part; i++) { + *pOlaXsubst = *pOlaXsubst + *pXfp++ * *pHannOla--; + pOlaXsubst++; + } + + + /* clear x_out to start with */ + assert(x_out != NULL); + zero_float(x_out, L); + + + for (i = 0; i < (Lecu - LA_ZEROS); i++) { + + xsubst_LL[i] = xsubst_LL[i] * winMDCT[i]; /* xsubstLL windowing up to 16.25 ms i.e not last 3.75 ms */ + + } + zero_float(&(xsubst_LL[Lecu - LA_ZEROS]), LA_ZEROS); /* tail 3.75ms always zero */ + + /* perform tda */ + + /* first half */ + pXsubst_LL = &xsubst_LL[3 * Lecu / 4]; + pXfp = &xsubst_LL[(3 * Lecu / 4) - 1]; + + pXOut = x_out; + for (i = 0; i < Lecu / 4; i++) { + *pXOut++ = -*pXsubst_LL++ - *pXfp--; /* 3.75 ms mults with 0 . may be skipped, see BASOP */ + } + + /* second half */ + /* */ + + pXsubst_LL = &(xsubst_LL[0]); + pXfp = &xsubst_LL[(Lecu / 2) - 1]; + for (i = 0; i < Lecu / 4; i++) { + *pXOut++ = *pXsubst_LL++ - *pXfp--; + } +} + diff --git a/lib_lc3plus/plc_phecu_setf0hz.c b/lib_lc3plus/plc_phecu_setf0hz.c new file mode 100644 index 0000000000000000000000000000000000000000..79a82d092832535ee5476afbd2159530b14e16e6 --- /dev/null +++ b/lib_lc3plus/plc_phecu_setf0hz.c @@ -0,0 +1,29 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.3 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + + +#include "options.h" +#include "wmc_auto.h" +#include "defines.h" +#include "functions.h" + + +LC3_FLOAT plc_phEcuSetF0Hz(LC3_INT32 fs, LC3_FLOAT * old_pitchPtr) +{ + LC3_FLOAT result; + + result = 0; + if (*old_pitchPtr != 0) + { + result = LC3_ROUND(fs/(*old_pitchPtr)/PHECU_FRES * 128.0) / 128.0; + } + + return result; +} + diff --git a/lib_lc3plus/plc_phecu_spec_ana.c b/lib_lc3plus/plc_phecu_spec_ana.c new file mode 100644 index 0000000000000000000000000000000000000000..463d3d1ae67283e82a46035780b239eaf0854e67 --- /dev/null +++ b/lib_lc3plus/plc_phecu_spec_ana.c @@ -0,0 +1,600 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.3 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + + +#include "options.h" +#include "wmc_auto.h" +#include "defines.h" +#include "functions.h" + + +#define PEAK_LOCATOR_RES_FX 1 /* fixed point resolution minimum value */ + + +static LC3_INT16 plc_phEcu_find_ind_fx( /* o : output maximum indx 0.. len-1 */ + const LC3_INT16 *inp, /* i : vector */ + const LC3_INT16 len, /* i : length */ + const LC3_INT16 val /* i : value to find */ +); + +static void plc_phEcu_peak_locator_fxlike(const LC3_INT16 *inp, /* i: vector with values >=0 ,Qx */ + const LC3_INT16 inp_len, /* i: length of inp */ + LC3_INT16 * int_plocs, /* o: array of filtered integer plocs Q0 */ + LC3_INT16 * n_fsc, /* o: total_ number of filtered located highs Q0 */ + const LC3_INT16 sens, /* i sensitivity, Qx */ + const LC3_INT16 inp_high, /* i global high , Qx */ + const LC3_INT16 inp_low /* i: global low, Qx */ +); + + +void plc_phEcu_spec_ana(LC3_FLOAT* xfp, + LC3_INT32 xfp_len, + const LC3_FLOAT* whr, + LC3_FLOAT *pfind_sensPtr, + LC3_INT32* plocs, + LC3_INT32* n_plocs, + LC3_FLOAT* f0est, + Complex* x, + LC3_INT32* x_len, + LC3_FLOAT * f0hzLtpBinPtr, + LC3_FLOAT * f0gainLtpPtr, + LC3_INT32 bw_idx, + Fft* PhEcu_fft +) +{ + + + LC3_INT32 i, peak_range_1, curr; + LC3_FLOAT xfp_w[MAX_PLC_LPROT]; + + LC3_FLOAT Xabs[MAX_LEN] = {0}; + LC3_FLOAT inp_high, inp_low, sens; + LC3_FLOAT interPos; + Complex Xana_p[3]; + LC3_INT32 P_in_plocs; + LC3_INT32 nSubs; + LC3_INT32 n_plocs_in; + LC3_FLOAT phEcu_c_jacob[1]; + + LC3_FLOAT fx_fft_scale; + LC3_FLOAT fft_fs_scale; + + LC3_FLOAT max_xfp_abs; + LC3_FLOAT PLC2_Q_flt; + LC3_FLOAT Q_scale_flt; + + LC3_INT16 Xabs_fx[MAX_LEN]; + LC3_INT16 plocs_fx[MAX_LEN]; + + LC3_INT16 sens_fx; + LC3_INT16 inp_high_fx; + LC3_INT16 inp_low_fx; + LC3_INT16 n_plocs_fx; + + LC3_FLOAT pfind_sens ; + LC3_FLOAT f0hzLtpBin ; + LC3_FLOAT f0gainLtp ; + + pfind_sens = *pfind_sensPtr; + f0hzLtpBin = *f0hzLtpBinPtr; + f0gainLtp = *f0gainLtpPtr; + + for (i = 0; i < xfp_len; i++) + { + xfp_w[i] = xfp[i] * whr[i]; /* whr windowing may be split into three segments , two loops, and possibly inplace */ + } + real_fft_apply(PhEcu_fft, xfp_w, (LC3_FLOAT *)x); + + x[xfp_len/2].r = x[0].i; /* move the real Fs/2 value to end */ + x[xfp_len/2].i = 0; /* safety clear imaginary Fs/2 value at end */ + x[0].i = 0.0; /* safety, make DC value only real */ + + + *x_len = xfp_len/2 + 1; + + i =(LC3_INT32) LC3_FLOOR(20000.0/PHECU_FRES)+1; + zero_cmplx( &(x[i]), *x_len - i); + + peak_range_1 = (LC3_INT32) MIN(*x_len, (40000.0 / 100 * 1.6) / 2 + 1); + + plc_phEcu_fft_spec2_sqrt_approx(x, peak_range_1, Xabs); + + zero_float(&(Xabs[peak_range_1]), *x_len - peak_range_1); + + inp_high = Xabs[0]; + inp_low = Xabs[0]; + + for (i = 1; i < peak_range_1; i++) { + inp_high = MAX(inp_high, Xabs[i]); + inp_low = MIN(inp_low, Xabs[i]); + } + + sens = (inp_high-inp_low)*(1-pfind_sens); + + if (inp_high > ((LC3_FLOAT) PEAK_LOCATOR_RES_FX)/2.0) + { + { + /* from ROM constants.c */ + LC3_FLOAT fx_fft_scales[5] = { 6, 7, 7, 8, 8 }; /*NB,WB, sSWB, SWB, FB*/ + fx_fft_scale = LC3_POW(2.0, fx_fft_scales[bw_idx]); /*% scaling due to up / dn pre shifts in fx FFT */ + } + { /* from ROM constants.c */ + LC3_FLOAT fx_fs_scales[5] = { 1.0, 1.0, 1.5, 1.0, 1.5 }; /*NB,WB, sSWB, SWB, FB*/ + fft_fs_scale = fx_fs_scales[bw_idx]; + } + + + max_xfp_abs = (LC3_FLOAT) LC3_FABS(xfp[0]); + for (i = 1; i < xfp_len; i++) { + max_xfp_abs = (LC3_FLOAT) MAX(max_xfp_abs, LC3_FABS(xfp[i])); + } + + if (max_xfp_abs >= 0.5) + { + PLC2_Q_flt = (LC3_FLOAT)LC3_FLOOR(LC3_LOGTWO(32768 / 2 / 2 / max_xfp_abs)); + Q_scale_flt = LC3_POW(2.0, PLC2_Q_flt) / fx_fft_scale / fft_fs_scale; /* basop way using xfp scale */ + + /* C-Float additional safety limit/verification of the integer xfp based scaling using the available C-float Xabs max value inp_high as well */ + { + LC3_FLOAT tmp_scale; + tmp_scale = LC3_POW(2.0, LC3_FLOOR(LC3_LOGTWO(32768 / 2 / 2 / inp_high))); + if (Q_scale_flt > tmp_scale) { + Q_scale_flt = tmp_scale; + } + } + /* Round sens, inp_high, inp_low according to BASOP fix-point scaling */ + + for (i = 0; i < peak_range_1; i++) { + Xabs_fx[i] = (LC3_INT16) LC3_ROUND(Xabs[i] * Q_scale_flt) ; + } + sens_fx = (LC3_INT16) LC3_ROUND(sens * Q_scale_flt) ; + inp_high_fx = (LC3_INT16) LC3_ROUND(inp_high * Q_scale_flt) ; + inp_low_fx = (LC3_INT16) LC3_ROUND(inp_low * Q_scale_flt) ; + plc_phEcu_peak_locator_fxlike(Xabs_fx, peak_range_1, plocs_fx, &n_plocs_fx, sens_fx, inp_high_fx, inp_low_fx); + + *n_plocs = (LC3_INT32)n_plocs_fx; + for (i = 0; i < *n_plocs; i++) { + plocs[i] = (LC3_INT32)plocs_fx[i]; /* short Word16 values now stored/saved as Word32 */ + } + } + else + { + *n_plocs = 0; /* time domain xfp level near zero */ + } + } + else + { + *n_plocs = 0; /* Freq domain Xabs max level near zero */ + } + + for (i = 0; i < *n_plocs; i++) { + curr = plocs[i]; + if (curr == 0) { + interPos = plc_phEcu_interp_max(Xabs, 3); /* returns 0.0 ... 2.0 */ + if (interPos == 2) { + /* integer peak was at DC, restrict to one of coeffs at [DC or DC+1] */ + interPos = plc_phEcu_interp_max(Xabs, 2); /* returns 0.0 or 1.0 */ + } + interPos += plocs[i]; + } else if (curr == 1) { + interPos = plc_phEcu_interp_max(Xabs, 3); + interPos += plocs[i] - 1; + } else if (curr == *x_len - 2) { + interPos = plc_phEcu_interp_max(&Xabs[*x_len - 3], 3); + interPos += plocs[i] - 1; + } else if (curr == *x_len - 1) { + /* integer curr at Fs/2, a real coeff */ + interPos = plc_phEcu_interp_max(&Xabs[*x_len - 3], 3); /* returns 0.0 ... 2.0 */ + interPos += plocs[i] - 2; /* valid for range ]... 1.0 ... 2.0] , where 1 is fs/2-1 and 2.0 is Fs/2 */ + if (interPos == 0) { + /* restrict to one of coeffs at [fs/2-1, fs/2 ] */ + interPos = plc_phEcu_interp_max(&Xabs[*x_len - 2], 2); /* returns 0.0 or 1.0 */ + interPos += plocs[i] - 1; + } + + if (interPos > (*x_len - 1) ) { /* interPos only defined up to Fs/2 */ + interPos = (LC3_FLOAT)(*x_len - 1); + } + } else { + Xana_p[0] = x[plocs[i]-1]; + Xana_p[1] = x[plocs[i]]; + Xana_p[2] = x[plocs[i]+1]; + phEcu_c_jacob[0] = (LC3_FLOAT)PHECU_C_JACOB; + interPos = plc_phEcu_imax2_jacobsen_mag(Xana_p, phEcu_c_jacob ); + interPos += (LC3_FLOAT) plocs[i]; + } + f0est[i] = interPos; + } + + if (*n_plocs >= 2 && plocs[0] == 0 && + f0est[0] > f0est[1] && plocs[1] <= 2 && Xabs[0] < Xabs[plocs[1]+1]) + { + f0est[0] = f0est[1]; + } + + P_in_plocs = plc_phEcu_pitch_in_plocs(plocs, *n_plocs); + + if (f0hzLtpBin > 0.0 && P_in_plocs > 0) { + nSubs = 2; + n_plocs_in = *n_plocs; + plc_phEcu_LF_peak_analysis(plocs, n_plocs, f0est, Xabs, &f0hzLtpBin, &f0gainLtp, nSubs); + + if (n_plocs_in == *n_plocs) { + nSubs = 3; + plc_phEcu_F0_refine_first(plocs, *n_plocs, f0est, *x_len, &f0hzLtpBin, &f0gainLtp, nSubs); + } + } + + if (f0gainLtp > 0.0 && f0gainLtp < 0.5 && *n_plocs > 14) { + if (P_in_plocs > 0) { + *n_plocs = 0; + } + } + + return; +} + + +#define sub(a,b) (a - b) +#define add(a,b) (a + b) +#define s_xor(a,b) (a ^ b) + +/* in case a value (e.g max or min) is already known , find the first corresponding array index */ +static LC3_INT16 plc_phEcu_find_ind_fx( /* o : output maximum indx 0.. len-1 */ + const LC3_INT16 *inp, /* i : vector */ + const LC3_INT16 len, /* i : length */ + const LC3_INT16 val /* i : value to find */ +) +{ + LC3_INT16 val_ind; + LC3_INT16 pos; + + val_ind = -1; + + for(pos = 0; pos < len; pos++) + { + if (sub(inp[pos], val) == 0) + { + val_ind = pos; + } + } + + return val_ind; +} + + + +/* BASOP function adapted to compile in float/integer environment */ +/*----------------------------------------------------------------------------- + * plc_phEcu_peak_locator_fxlike() + *----------------------------------------------------------------------------*/ +static void plc_phEcu_peak_locator_fxlike(const LC3_INT16 *inp, /* i: vector with values >=0 ,Qx */ + const LC3_INT16 inp_len, /* i: length of inp */ + LC3_INT16 * int_plocs, /* o: array of filtered integer plocs Q0 */ + LC3_INT16 * n_fsc, /* o: total_ number of filtered located highs Q0 */ + const LC3_INT16 sens, /* i sensitivity, Qx */ + const LC3_INT16 inp_high, /* i global high , Qx */ + const LC3_INT16 inp_low /* i: global low, Qx */ +) +{ + + LC3_INT16 j, k, n, idx_high, idx_low; + LC3_INT16 inp_len_minus1; + LC3_INT16 pairs_start, pairs_end; + LC3_INT16 *p_tmp; + LC3_INT16 prev_delta, curr_delta; + LC3_INT16 delta_predc, delta_fin; + LC3_INT16 add_dc_flag, add_fin_flag; + LC3_INT16 low_val_cand_pairs, val_range; + LC3_INT16 num_pairs, n_tail_values; + LC3_INT16 cand_phase_start, cand_idx, prev_low_plus_sens, tmp; + LC3_INT16 cand_high, prev_low; + LC3_INT16 *cand_pairs; /* actually [DC ] + pairs + [FS/2] */ + + LC3_INT16 sc_idx[1 + 368 + 1]; + LC3_INT16 cand_pairs_buf[1 + 1 + 368 + 1]; + LC3_INT16 fsc_idx[1 + 368 / 2 + 1]; + + + inp_len_minus1 = sub(inp_len, 1); /* size of delta=derivative array ,and last index in inp */ + + cand_pairs = &cand_pairs_buf[1]; /* ptr init , make space for storing a lowest amplitude value in location -1 */ + pairs_start = 1; /* adjusted to zero or 1 or 2 when/if, DC is injected as sc_idx[0], or initial plateau skipped */ + + p_tmp = &(sc_idx[pairs_start]); /* ptr init */ + + + /* xor high/low pairs of delta_inp and save sign changes */ + prev_delta = sub(inp[1], inp[0]); /* precompute very first delta */ + + for(n = 1; n < inp_len_minus1; n++) + { /* sign change analysis */ + curr_delta = sub(inp[n + 1], inp[n]); /* n+1 ,n , are loop ptrs */ + if (s_xor(prev_delta, curr_delta) < 0) /* a "0" delta treated as a positive sign */ + { + *p_tmp++ = n; /* store sign change bin locations , location n in the inp[] signal */ + } + prev_delta = curr_delta; + } + + k = (LC3_INT16)(p_tmp - &(sc_idx[pairs_start])); + + /* copy sign change location values to a pairs array */ + /* leave one initial sc_idx location open for a potential initial DC value */ + + for(j = 0; j < k; j++){ + cand_pairs[j + pairs_start] = inp[sc_idx[j + pairs_start]]; + } + + /* filter away a potential single initial/trailing plateau + to enable correct analysis for adding DC or fs/2 bins */ + + + if((sub(k, 2) >= 0) && + (sub(cand_pairs[pairs_start], cand_pairs[pairs_start + 1]) == 0)){ + pairs_start = add(pairs_start, 1); + k = sub(k, 1); + } + + /* filter away potential single trailing plateu */ + pairs_end = sub(add(pairs_start, k), 1); /* point to last established sign change element */ + + if ((sub(k, 2) >= 0) && + (sub(cand_pairs[sub(pairs_end, 1)], cand_pairs[pairs_end]) == 0)){ + k = sub(k, 1); + } + pairs_end = sub(add(pairs_start, k), 1); /* recalc ptr to last element */ + + + /* conditionally add high/lows on both sides of input (pre_dc or fin) as candidates */ + add_dc_flag = 0; + add_fin_flag = 0; + + + if(sub(k, 1) == 0) /* one single sign change found special case */ + { + if (sub(inp[0], cand_pairs[pairs_start]) != 0) + { + add_dc_flag = 1; /* not plateau */ + } + + if (sub(cand_pairs[pairs_end], inp[inp_len_minus1]) != 0) + { + add_fin_flag = 1; /* not plateau */ + } + } + + if(sub(k, 2) >= 0) + { + delta_predc = sub(cand_pairs[pairs_start + 1], cand_pairs[pairs_start]); + delta_fin = sub(cand_pairs[pairs_end], cand_pairs[pairs_end - 1]); + + /* plateaus are allowed to be detected by xor sign change, + but still not allowed at the start nor at the end */ + + add_dc_flag = 1; + if (sub(inp[0], cand_pairs[pairs_start]) == 0) + { + add_dc_flag = 0; /* plateau down or , plateaus up., --> do not add DC */ + } + + + if ((sub(inp[0], cand_pairs[pairs_start]) < 0) && (delta_predc > 0)) + { + add_dc_flag = -1; /*UP - up ... replace */ + } + + if ((sub(inp[0], cand_pairs[pairs_start]) > 0) && (delta_predc < 0)) + { + add_dc_flag = -1; /* DOWN - down ... % replace */ + } + + add_fin_flag = 1; + if (sub(cand_pairs[pairs_end], inp[inp_len_minus1]) == 0) + { + add_fin_flag = 0; /* up - plateau ... */ + } + + if ((delta_fin > 0) && (sub(cand_pairs[pairs_end], inp[inp_len_minus1]) < 0)) + { + add_fin_flag = -1; /* up - UP ... % replace , hard to hit */ + } + + if ((delta_fin < 0) && (sub(cand_pairs[pairs_end], inp[inp_len_minus1]) > 0)) + { + add_fin_flag = -1; /*down - DOWN ... % replace */ + } + + } + + if(add_dc_flag > 0) + { /* add DC */ + pairs_start = sub(pairs_start, 1); + cand_pairs[pairs_start] = inp[0]; + sc_idx[pairs_start] = 0; + k = add(k, 1); + } + if(add_dc_flag < 0) + { /* -1 --> replace with DC*/ + cand_pairs[pairs_start] = inp[0]; + sc_idx[pairs_start] = 0; + } + + if(add_fin_flag > 0) + { /* add FS/2 */ + pairs_end = add(pairs_end, 1); + cand_pairs[pairs_end] = inp[inp_len_minus1]; + sc_idx[pairs_end] = inp_len_minus1; + k = add(k, 1); + } + if(add_fin_flag < 0) + { /* -1, replace tail with FS/2*/ + cand_pairs[pairs_end] = inp[inp_len_minus1]; + sc_idx[pairs_end] = inp_len_minus1; + } + /* preliminary cand_pairs now only have highs , lows , no initial/trailing plateaus */ + + + /* we allow the DC/FsBy2 lows to be used as the candidatelLow */ + low_val_cand_pairs = inp_low; + val_range = sub(inp_high, low_val_cand_pairs); /* used to determine if search is useful at all */ + + + if ((sub(val_range, PEAK_LOCATOR_RES_FX) < 0) || + (sub(inp_high, sens) < 0)) + { + k = 0; + } + + + if ((k == 0) && (sub(val_range, sens) >= 0)) + { + k = 1; + } + + + if(sub(k, 2) > 0) + { + /* low, high, low, ... or + high, low, high, ...*/ + + cand_phase_start = pairs_start; /*assume first candidate is a high */ + if (sub(cand_pairs[pairs_start], cand_pairs[pairs_start + 1]) < 0) + { + cand_phase_start = add(pairs_start, 1); /* first is a low, --> skip to next higher cand */ + } + + /* high, low, high, ... */ + tmp = k; + if (sub(cand_phase_start, pairs_start) != 0) + { + tmp = sub(tmp, 1); + } + num_pairs = tmp / 2; // shr(tmp, 1); + n_tail_values = sub(tmp, num_pairs * 2); // shl(num_pairs, 1)); + + /* filter preliminary sign changes into sensitivity filtered sign changes */ + + *n_fsc = 0; /* counter of filtered fsc_idx */ + cand_high = low_val_cand_pairs; + cand_idx = -1; /* sentinel location for no high cand found yet. */ + cand_pairs[-1] = low_val_cand_pairs; + + prev_low = low_val_cand_pairs; + prev_low_plus_sens = add(prev_low, sens); + + /* filter loop for high - low sign change pairs */ + /* idx_high, idx_low are raw pointers into the cand_pairs and sc_idx arrays */ + + for(idx_high = cand_phase_start; idx_high < (cand_phase_start + 2 * num_pairs); idx_high += 2) + { + idx_low = idx_high + 1; /* loop ptr increase */ + + /* new high candidate larger than previous candidate and */ + /* sensitivity still larger than the the previous low */ + tmp = MAX(cand_high, prev_low_plus_sens); + if (sub(cand_pairs[idx_high], tmp) > 0) + { + cand_idx = idx_high; /* enable or shift candidate position fwd */ + } + cand_high = cand_pairs[cand_idx]; /* NB, cand_pairs[-1] , has the low_val_cand_pairs value stored */ + + /* now check the fwd idx_low of the current {high,low} pair */ + prev_low = MIN(cand_pairs[idx_low], prev_low); + + tmp = sub(cand_high, sens); + if(sub(tmp, cand_pairs[idx_low]) > 0) + { + /* this low point is now low enough to fix a previous high candidate */ + + fsc_idx[*n_fsc] = cand_idx; /*% add cand high idx -> output idx list*/ + *n_fsc = add(*n_fsc, 1); + + prev_low = cand_pairs[idx_low]; /* use this value as new low estimate */ + cand_idx = -1; /* no candidate until next pair or tail bin, and pt to lowVal */ + cand_high = low_val_cand_pairs; /* enable next candidate to be selected immediately */ + } + prev_low_plus_sens = add(prev_low, sens); + } /* { high, low} for loop */ + + + if((n_tail_values == 0) && (cand_idx >= 0)) + { + /* no tail low or high value to analyze + still may need to lock a non-locked but qualified candidate */ + fsc_idx[*n_fsc] = cand_idx; + *n_fsc = add(*n_fsc, 1); + } + + + /* cand_pairs vector may have a last orphan value */ + if(n_tail_values > 0) + { + /* cand_pairs vector may have a last orphan tail value */ + /* + logic boils down to if (nTailValues > 0) && (cand_pairs(n_end) > tmp) + there is a last one trailing high to process + + a) the last high, may be a new high Peak if we have not yet + locked the current candidate + b) if we have locked the last candidate, the last high may also be + a highpeak if it is high enough from the(newly set previous) valley floor. + + tmp=a||b + */ + + tmp = MAX(cand_high, prev_low_plus_sens); + tmp = sub(cand_pairs[pairs_end], tmp); + if(tmp > 0) + { + fsc_idx[*n_fsc] = pairs_end; + *n_fsc = add(*n_fsc, 1); + } + else + { + if(cand_idx >= 0) + { /* we have a previously established high candidate */ + fsc_idx[*n_fsc] = cand_idx; + *n_fsc = add(*n_fsc, 1); + } + + } + } + + /* move high locations info from fsc_idx , to output */ + for(j = 0; j < *n_fsc; j++) + { + int_plocs[j] = sc_idx[fsc_idx[j]]; + + } + + } /* end of pairs + [tail] section filtering */ + else + { + /* constant/single rise or constant decay or very low overall values, cases */ + *n_fsc = 0; + + tmp = sub(inp_high, sens); + if((k != 0) && (sub(tmp, low_val_cand_pairs) > 0)) + { + /* low,high */ + /* high,low */ + tmp = plc_phEcu_find_ind_fx(inp, inp_len, inp_high); + int_plocs[0] = tmp; /* simply locate the high peak*/ + *n_fsc = 1; + if (tmp < 0) + { /*safety in case max value index was not found */ + *n_fsc = 0; + } + } + } + + return; +} + diff --git a/lib_lc3plus/plc_phecu_subst_spec.c b/lib_lc3plus/plc_phecu_subst_spec.c new file mode 100644 index 0000000000000000000000000000000000000000..388ae3cb80923a78e42e447b552524c40542bf3c --- /dev/null +++ b/lib_lc3plus/plc_phecu_subst_spec.c @@ -0,0 +1,456 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.3 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + + +#include "options.h" +#include "wmc_auto.h" +#include "defines.h" +#include "functions.h" +#include "constants.h" + +static LC3_INT32 own_rand(LC3_INT32 seed); +static Complex valley_magnitude_adj(Complex X_i_in, LC3_INT32 uni_seed, LC3_FLOAT cos_F); +static LC3_INT32 rand_phase(LC3_INT32 seed_in, LC3_FLOAT* cos_F); + +#ifdef CR8_A_PLC_FADEOUT_TUNING + +#define ONE_SIDED_SINE_WIDTH (4) /* expected pure sine main lobe maximum width (4+1+4) bins *62.5 hz/bin => approx 560 Hz total width */ + +static LC3_INT16 plc_phEcu_nonpure_tone_ana(const LC3_INT32* plocs, const LC3_INT32 n_plocs, const Complex* X, const LC3_FLOAT* Xavg, const LC3_INT32 Lprot); +#endif + +void plc_phEcu_subst_spec(LC3_INT32* plocs, LC3_INT32 n_plocs, LC3_FLOAT* f0est, LC3_INT32 time_offs, Complex* X, LC3_INT32 X_len, + LC3_FLOAT* mag_chg_gr, LC3_INT32 *seed, LC3_FLOAT* alpha, LC3_FLOAT* beta, LC3_FLOAT* Xavg, + LC3_INT32 t_adv_in, LC3_INT32 Lprot, LC3_INT32 delta_corr, +#ifdef CR8_A_PLC_FADEOUT_TUNING + LC3_INT16 fadeout, /* need for DC muting */ + LC3_INT16* nonpure_tone_flag_ptr, +#endif + LC3_FLOAT *corr_phase_dbg, + LC3_FLOAT *X_i_new_re_dbg, LC3_FLOAT *X_i_new_im_dbg) { + + LC3_INT32 i, i2, lprotBy2Minus1, one_peak_flag_mask, noise_mag_scale; + LC3_INT32 t_adv; + LC3_FLOAT corr_phase[MAX_PLC_NPLOCS] = {0}; + LC3_FLOAT cos_F, mag_chg_local, alpha_local, beta_local, tmp; + Complex X_i, X_i_new; + LC3_INT32 segmentLen, e; + LC3_FLOAT Xph; + LC3_FLOAT seed_local; + LC3_INT32 binCounter = 1, subInd = 0; +#ifdef CR8_A_PLC_FADEOUT_TUNING + LC3_INT16 fs_idx; +#endif + + UNUSED(corr_phase_dbg); + UNUSED(X_i_new_re_dbg); + UNUSED(X_i_new_im_dbg); + + seed_local = (LC3_FLOAT) *seed; + + lprotBy2Minus1 = imin(320, Lprot/2 - 1); /* limit to 20 KHz */ + + t_adv = t_adv_in + time_offs; + + for (i = 0; i < n_plocs; i++) { + corr_phase[i] = (LC3_FLOAT)2.0 * (LC3_FLOAT)M_PI * (f0est[i]/Lprot)*(LC3_FLOAT)t_adv; + } + + // EVOLVE PHASE ----------------- + + one_peak_flag_mask = -1; +#ifdef CR8_A_PLC_FADEOUT_TUNING + fs_idx = (LC3_INT16)LC3_FLOOR((LC3_FLOAT)Lprot / 160.0); /* aquire, fs_idx for 10 ms frame sizes */ + if (n_plocs < 3 && n_plocs > 0) + { + one_peak_flag_mask = 0; /* initial crude single tone detection, only using n_plocs as a result from peak_locator() dynamics as input */ + + if ( (*nonpure_tone_flag_ptr < 0 ) + && ( (fs_idx == 2) /*SemiSWB 24 kHz */ || (fs_idx >= 4) /* FB 48 kHz */ ) + ) + { + /* in the first lost frame analyze spectra to possibly reverse initial pure sine assumption */ + *nonpure_tone_flag_ptr = plc_phEcu_nonpure_tone_ana(plocs, n_plocs, X, Xavg, Lprot ); + } + + if ( *nonpure_tone_flag_ptr > 0 ) { + one_peak_flag_mask = -1; /* actually revert single pure tone detection */ /* 0-> mute all surrounding valley bins in evolution , 0xff -> generate noise in all valleys */ + } + + } +#else + if (n_plocs < 3 && n_plocs > 0) { + one_peak_flag_mask = 0; + } +#endif + + noise_mag_scale = 0; + if (n_plocs == 0 || time_offs != 0) { + noise_mag_scale = 1; + } + + if (n_plocs == 0) { + X[0] = realtoc(0); + X[X_len-1] = realtoc(0); + } + +#ifdef CR8_A_PLC_FADEOUT_TUNING + /* binary selection of fadeout scheme */ + assert(PLC2_FADEOUT_LONG_IN_MS >= PLC2_FADEOUT_IN_MS_MIN && PLC2_FADEOUT_IN_MS >= PLC2_FADEOUT_IN_MS_MIN); + assert(PLC2_FADEOUT_LONG_IN_MS <= PLC2_FADEOUT_IN_MS_MAX && PLC2_FADEOUT_IN_MS <= PLC2_FADEOUT_IN_MS_MAX); + i = (PLC2_FADEOUT_IN_MS - PLC2_FADEOUT_IN_MS_MIN) / PLC2_FADEOUT_RES; + + if (fadeout != 0) + { + i = (PLC2_FADEOUT_LONG_IN_MS - PLC2_FADEOUT_IN_MS_MIN) / PLC2_FADEOUT_RES; + } + + /* calculate local burst_len for securing DC and fs/2 muting */ + i2 = (time_offs / ((Lprot * 100) / 160)) + 1; /* burst_len */ + + if (i2 > (fade_scheme_tab[i][1] + 1)) + { + /* start DC scaling attenuation */ + X[0].r = alpha[0] * X[0].r; + + /* start fs/by2 attenuation */ + X[X_len - 1].r = alpha[(xavg_N_grp[fs_idx] - 1)] * X[X_len - 1].r; + } +#endif + + if (n_plocs != 0) { + for (i = 0; i < n_plocs; i++) { + LC3_INT32 delta_corr_dn = delta_corr; + LC3_INT32 delta_corr_up = delta_corr; + + if (i > 0) { + delta_corr_dn = imin( ((plocs[i] - plocs[i - 1] - 1) / 2), delta_corr_dn); + } + + if (i < n_plocs - 1) { + delta_corr_up = imin( ((plocs[i + 1] - plocs[i] - 1) / 2), delta_corr_up); + } + + segmentLen = (plocs[i] - delta_corr_dn) - binCounter; + + for (i2 = 0; i2 < segmentLen; i2++) { + seed_local = (LC3_FLOAT)rand_phase((LC3_INT32)seed_local, &cos_F); + + X_i = X[binCounter]; + X_i_new = cmul(X_i, cexpi((LC3_FLOAT)M_PI*seed_local / (LC3_FLOAT)32768.0)); + + + seed_local = (LC3_FLOAT)own_rand((LC3_INT32)seed_local); + + if (noise_mag_scale != 0) { + X_i = valley_magnitude_adj(X_i_new,(LC3_INT32) seed_local, cos_F); + X_i_new = X_i; + } + + mag_chg_local = mag_chg_gr[subInd]; + alpha_local = alpha[subInd]; + + if (beta[subInd] != 0) { + tmp = beta[subInd] * Xavg[subInd]; + if (one_peak_flag_mask == 0) { + tmp = 0; + X_i_new = realtoc(0); + } + X[binCounter] = cadd(cmul(realtoc(alpha_local), X_i_new), cmul(realtoc(tmp), cexpi((LC3_FLOAT)M_PI*seed_local / (LC3_FLOAT)32768.0))); + } + else { + if (one_peak_flag_mask == 0) { + X_i_new = realtoc(0); + } + + X[binCounter] = cmul(realtoc(mag_chg_local), X_i_new); + } + + binCounter++; + + if (binCounter >= gwlpr[subInd + 1]) { + subInd++; + } + } + + e = plocs[i] + delta_corr_up; + if (e > lprotBy2Minus1) { + e = lprotBy2Minus1; + } + + Xph = corr_phase[i]; + + segmentLen = e - (binCounter - 1); + + for (i2 = 0; i2 < segmentLen; i2++) + { + seed_local = (LC3_FLOAT)own_rand((LC3_INT32)seed_local); + X_i = X[binCounter]; + + { + LC3_INT32 nrep =(LC3_INT32) LC3_FLOOR(Xph / (2.0f*(LC3_FLOAT)M_PI)); + + X_i_new = cmul(X_i, cexpi(Xph - (2.0f*(LC3_FLOAT)M_PI*(LC3_FLOAT)nrep))); + } + + + seed_local = (LC3_FLOAT)own_rand((LC3_INT32)seed_local); + + mag_chg_local = mag_chg_gr[subInd]; + alpha_local = alpha[subInd]; + beta_local = beta[subInd]; + if (beta_local != 0) { + + assert(alpha_local == mag_chg_local); + tmp = beta_local * Xavg[subInd]; + + X[binCounter] = cadd(cmul(realtoc(alpha_local), X_i_new), cmul(realtoc(tmp), cexpi((LC3_FLOAT)M_PI*seed_local / (LC3_FLOAT)32768.0))); + } + else + { + X[binCounter] = cmul(realtoc(mag_chg_local), X_i_new); + } + + binCounter++; + + if (binCounter >= gwlpr[subInd + 1]) { + subInd++; + } + } + } + } + + segmentLen = lprotBy2Minus1 - (binCounter - 1); + + for (i = 0; i < segmentLen; i++) { + seed_local = (LC3_FLOAT)rand_phase((LC3_INT32)seed_local, &cos_F); + + X_i = X[binCounter]; + X_i_new = cmul(X_i, cexpi((LC3_FLOAT)M_PI*seed_local/(LC3_FLOAT)32768.0)); + + seed_local = (LC3_FLOAT)own_rand((LC3_INT32)seed_local); + + if (noise_mag_scale != 0) { + X_i = valley_magnitude_adj(X_i_new, (LC3_INT32)seed_local, cos_F); + X_i_new = X_i; + } + + if (one_peak_flag_mask == 0) { + X_i_new = realtoc(0); + } + + alpha_local = alpha[subInd]; + mag_chg_local = mag_chg_gr[subInd]; + + if (beta[subInd] != 0) { + assert(alpha_local == mag_chg_local); + tmp = beta[subInd]*Xavg[subInd]; + + if (one_peak_flag_mask == 0) { + tmp = 0; + } + + X[binCounter] = cadd(cmul(realtoc(alpha_local), X_i_new), cmul(realtoc(tmp), cexpi((LC3_FLOAT)M_PI*seed_local/(LC3_FLOAT)32768.0))); + } + else + { + X[binCounter] = cmul(realtoc(mag_chg_local), X_i_new); + } + + binCounter++; + + if (binCounter >= gwlpr[subInd + 1]) { + subInd++; + } + } + + + *seed = (LC3_INT32)seed_local; +} + +static LC3_INT32 own_rand(LC3_INT32 seed) { + LC3_INT32 retSeed; + assert(seed <= 32767 && seed >= -32768); + retSeed = (13849 + (seed + 32768) * 31821) & 65535; + retSeed -= 32768; + assert(retSeed <= 32767 && retSeed >= -32768); + return retSeed; +} + +static Complex valley_magnitude_adj(Complex X_i_in, LC3_INT32 uni_seed, LC3_FLOAT cos_F) { + LC3_FLOAT scale = ((LC3_FLOAT)0.5*(LC3_FLOAT)uni_seed/(LC3_FLOAT)32768.0) + (LC3_FLOAT)0.5*cos_F; + scale = (LC3_FLOAT)1.0 + (LC3_FLOAT)0.25*scale; + + assert(scale <= (LC3_FLOAT)1.25); + assert(scale >= (LC3_FLOAT)0.75); + + return cmul(X_i_in, realtoc(scale)); +} + +static LC3_INT32 rand_phase(LC3_INT32 seed_in, LC3_FLOAT* cos_F) { + LC3_FLOAT seed = (LC3_FLOAT)own_rand(seed_in); + *cos_F = LC3_COS((LC3_FLOAT)M_PI*seed/(LC3_FLOAT)32768.0); + return (LC3_INT32) seed; +} + + +#ifdef CR8_A_PLC_FADEOUT_TUNING + +static LC3_INT16 plc_phEcu_nonpure_tone_ana(const LC3_INT32* plocs, const LC3_INT32 n_plocs, const Complex* X, const LC3_FLOAT* Xavg, const LC3_INT32 Lprot) +{ + + LC3_INT16 nonpure_tone_detect; + LC3_INT16 n_ind, tone_ind, low_ind, high_ind; + LC3_FLOAT peak_amp, peak_amp2, valley_amp, x_abs[(1 + 2 * ONE_SIDED_SINE_WIDTH + 2 * 1)]; + LC3_INT16 sineband_ind_low, sineband_ind_high; + LC3_INT16 i, fs_idx, N_grp; + LC3_FLOAT tmp, tmp_dB, tot_inc_HF, tot_inc_LF; + + + + /* use compressed hearing sensitivity curve to allow more deviation in highest and lowest bands */ + /* ROM table LC3_FLOAT scATHFx[MAX_LGW - 1] */ + + /* init */ + nonpure_tone_detect = 0; + tot_inc_HF = 0.0; + tot_inc_LF = 0.0; + + /* limit single sine optimization to when 2 peaks are close enough to represent a single sinusoid */ + if (n_plocs == 2 && (plocs[1] - plocs[0]) >= ONE_SIDED_SINE_WIDTH) /* NB, plocs is an ordered vector */ + { + nonpure_tone_detect |= 0x1; + } + + /* local bin wise dynamics analysis, if 2 peaks, we do the analysis based on the location of the largest peak */ + { + tone_ind = 0; + plc_phEcu_fft_spec2_sqrt_approx(&(X[plocs[0]]), 1, &peak_amp); /* get 1st peak amplitude = approx_sqrt(Re^2+Im^2) */ + + + if ((n_plocs - 2) == 0) + { + plc_phEcu_fft_spec2_sqrt_approx(&(X[plocs[1]]), 1, &peak_amp2); /* get 2nd peak amplitude */ + if (peak_amp2 > peak_amp) + { + tone_ind = 1; + peak_amp = peak_amp2; + } + } + + low_ind = MAX(1, plocs[tone_ind] - (ONE_SIDED_SINE_WIDTH + 1)); /* DC is not allowed as valley */ + high_ind = MIN((Lprot >> 1) - 2, plocs[tone_ind] + (ONE_SIDED_SINE_WIDTH + 1)); /* Fs/2 is not allowed as valley */ + + n_ind = high_ind - low_ind + 1; + + /* find lowest amplitudes around the assumed main lobe center location */ + plc_phEcu_fft_spec2_sqrt_approx(&(X[low_ind]), n_ind, x_abs); + valley_amp = peak_amp; + for (i = 0; i < n_ind; i++) { + valley_amp = MIN(x_abs[i], valley_amp); + } + + /* at least a localized amplitude ratio of 16 (24 dB) required to declare a pure sinusoid */ + if (peak_amp < 16 * valley_amp) /* 1/16 easily implemented in BASOP */ + { + + nonpure_tone_detect |= 0x2;/* not a pure tone due to too low local SNR */ + + } + } + + /* analyze LF/ HF bands energy dynamics vs the assumed single tone band ( one or two peaks found) */ + { + fs_idx = (LC3_INT16)floor(Lprot / 160); /* fs_idx */ + assert(fs_idx < 5); + + /* Xavg , is a vector of rather rough MDCT based band energy estimates in perceptually motivated bands. from approx the last 26 ms of synthesis */ + + /* eval amplitude relations for assumed tonal band vs lower and higher bands */ + N_grp = xavg_N_grp[fs_idx]; /* { 4 NB , 5 WB , 6 SSWB , 7 SWB, 8 FB }; */ + + /* establish band(s) with assumed sinusoid tone */ + /* if tone freq location is below first MDCT-band definition, use first band as location anyway */ + i = 0; /* band 0 , 1 , 2 , 3 , ...*/ + while (plocs[tone_ind] >= gwlpr[i + 1]) { /* gwplr= [ 1, 12(750Hz), 20(1250Hz) , 36 , .. */ + /* dct-inds "0"...11, 12...19, 20...35, 36 ... */ + i++; + } + sineband_ind_low = i; + sineband_ind_high = i; /* typically in the same band as low */ + + /* a single tone may end up on a band border + , handle case when assumed tone is more or less right in between two perceptual bands +/-4 62.5 Hz */ + if ((sineband_ind_high > 0) && + (plocs[tone_ind] - ONE_SIDED_SINE_WIDTH) >= gwlpr[sineband_ind_high + 1] + ) { + sineband_ind_low = sineband_ind_high - 1; + } + + if ( (sineband_ind_low < (N_grp - 1)) && + (plocs[tone_ind] + ONE_SIDED_SINE_WIDTH) >= gwlpr[sineband_ind_low + 1] + ) { + sineband_ind_high = sineband_ind_low + 1; + } + } + + + + /* intraframe(26 ms), weighted LB and HB envelope dynamics/variation analysis */ + /* envelope analysis , + require at least two HF or two LF bands in the envelope taper/roll-off analysis , otherwise skip this condition */ + + + if (nonpure_tone_detect == 0 && + (((sineband_ind_high + 2) < N_grp) || + ((sineband_ind_low - 2) >= 1) + ) + ) + { + /* delta taper-off analysis solution, less sensitive to input bandwidth limitation and levels */ + + /* verify that an assumed clean sine does not have any odd HF content indications by thresholding the accumulated delta rise in LF/HF side lobes */ + for (i = (sineband_ind_high + 1); i < (N_grp - 1); i++) { + tmp = (Xavg[i + 1] + LC3_EPS) / (Xavg[i] + LC3_EPS); + tmp_dB = 20.0*LC3_LOGTEN(tmp); + if ((Xavg[i] + LC3_EPS) > (Xavg[i + 1] + LC3_EPS)) { + tmp_dB = 0; + } + tot_inc_HF += scATHFx[i] * tmp_dB; /* i is ATH factor between band i, i+1 based on Hearing sensitivity */ + } + + /* verify that an assumed clean sine does not have any odd LF content by thresholding the accumulated LF reverse up tilt */ + for (i = MAX(0, (sineband_ind_low - 1)); i > 0; i--) { + tmp = (Xavg[i - 1] + LC3_EPS) / (Xavg[i] + LC3_EPS); + tmp_dB = 20.0*LC3_LOGTEN(tmp); /* switch to log2() to simplify BASOP */ + + if ((Xavg[i - 1] + LC3_EPS) < (Xavg[i] + LC3_EPS)) { + tmp_dB = 0; + } + tot_inc_LF += scATHFx[i - 1] * tmp_dB; /* "psycho" scale using i-1 is ATH factor between band i-1, i , based on Hearing sensitivity */ + } + + if (tot_inc_HF > 4.5){ /* 4.5 dB in log2 is 0.7474 */ + nonpure_tone_detect |= 0x10; /* still not a pure tone, too great HF side increase */ + } + + if (tot_inc_LF > 4.5) { /* 4.5 dB limit in 4.5 = 20log10(x) corresponds to limit value 0.7474 in log2(x) */ + nonpure_tone_detect |= 0x20; /* still not a pure tone, too great accumulated LF side increase */ + } + + /* verify that an assumed clean sine does not have any odd LF+HF content by thresholding the accumulated LF+HF unexpected tilt */ + if ((tot_inc_LF + tot_inc_HF) > 6.0) { /* 6 dB limit in 20log10(x) corresponds to limit value 1.0 in log2(x) */ + nonpure_tone_detect |= 0x40; /* still not a pure tone, to great LF+HF side variation/increase */ + } + } /* bands available*/ + + return nonpure_tone_detect; +} +#endif /* CR8_A_PLC_FADEOUT_TUNING */ + diff --git a/lib_lc3plus/plc_phecu_tba_per_band_gain.c b/lib_lc3plus/plc_phecu_tba_per_band_gain.c new file mode 100644 index 0000000000000000000000000000000000000000..10aef923460bbea1ce1d80ffa7bf32cf923f7d90 --- /dev/null +++ b/lib_lc3plus/plc_phecu_tba_per_band_gain.c @@ -0,0 +1,44 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.3 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + + +#include "options.h" +#include "wmc_auto.h" +#include "defines.h" +#include "functions.h" + + +void plc_phEcu_tba_per_band_gain(LC3_INT32 n_grp, LC3_FLOAT *gr_pow_left, LC3_FLOAT *gr_pow_right, LC3_FLOAT *trans, LC3_FLOAT *grp_pow_change) +{ + LC3_INT32 i; + + /* per band gain */ + for (i = 0; i < n_grp; i++) { + if (gr_pow_left[i] > 0) + { + trans[i] = gr_pow_right[i] / gr_pow_left[i]; + } + else + { + /* handle division by zero case */ + if (gr_pow_right[i] > 0) + { + trans[i] = 10.0; /* positive/0 transient */ + } + else + { + trans[i] = 1.0; /* 0/0 no transient , no power change */ + } + } + grp_pow_change[i] = (LC3_FLOAT) 10.0 * LC3_LOGTEN(trans[i]); + + } + + return; +} diff --git a/lib_lc3plus/plc_phecu_tba_spect_Xavg.c b/lib_lc3plus/plc_phecu_tba_spect_Xavg.c new file mode 100644 index 0000000000000000000000000000000000000000..20baf4e7962e2e46c664c3275d28ac34ef1e6926 --- /dev/null +++ b/lib_lc3plus/plc_phecu_tba_spect_Xavg.c @@ -0,0 +1,46 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.3 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + + +#include "options.h" +#include "wmc_auto.h" +#include "defines.h" +#include "functions.h" + + +void plc_phEcu_tba_spect_Xavg(LC3_INT32 fs_idx, LC3_INT32 n_grp, LC3_FLOAT *oold_spec_shape, + LC3_FLOAT *oold_EwPtr, LC3_FLOAT *old_spec_shape, + LC3_FLOAT *old_EwPtr, LC3_FLOAT *gr_pow_left, LC3_FLOAT *gr_pow_right, LC3_FLOAT *Xavg) +{ + LC3_INT32 i; + LC3_FLOAT XavgEn[MAX_LGW]; + LC3_FLOAT xfp_w_scale, oold_Escale, old_Escale; + + /* 8k 16k 24k 32k 48k */ + LC3_FLOAT flt_xfp_wE_MDCT2FFT_target[5] = { (LC3_FLOAT) 1.9906, (LC3_FLOAT) 4.0445, (LC3_FLOAT) 6.0980, (LC3_FLOAT) 8.1533, (LC3_FLOAT) 12.2603 }; + LC3_INT32 gw_0[10] = { 1, 3, 5, 9, 17, 33, 49, 65, 81, 97 }; + + /* prepare scale factor */ + + xfp_w_scale = LC3_ROUND(flt_xfp_wE_MDCT2FFT_target[fs_idx]/(LC3_FLOAT)16.0*(LC3_FLOAT) 32768.0) / (LC3_FLOAT) LC3_POW(2,11); + + /* prepare left and right subband energies */ + oold_Escale = (*oold_EwPtr) * xfp_w_scale; + old_Escale = (*old_EwPtr) * xfp_w_scale; + for (i = 0;i < n_grp;i++) { + gr_pow_left[i] = oold_spec_shape[i] * oold_Escale; + gr_pow_right[i] = old_spec_shape[i] * old_Escale; + + XavgEn[i] = ((LC3_FLOAT) 0.5) * (gr_pow_left[i] + gr_pow_right[i]) / (gw_0[i + 1] - gw_0[i]); + Xavg[i] = LC3_SQRT(XavgEn[i]); + } + + return; +} + diff --git a/lib_lc3plus/plc_phecu_tba_trans_dect_gains.c b/lib_lc3plus/plc_phecu_tba_trans_dect_gains.c new file mode 100644 index 0000000000000000000000000000000000000000..69d6bf3968a859d66b062ca34f396c5bebd208ff --- /dev/null +++ b/lib_lc3plus/plc_phecu_tba_trans_dect_gains.c @@ -0,0 +1,387 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.3 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + + +#include "options.h" +#include "wmc_auto.h" +#include "defines.h" +#include "functions.h" + + +#define BETA_MUTE_FAC 0.5 /* % attenuation factor per additional bad frame, FX uses 0.5 (shift right with 1 bit) */ +#define BETA_MUTE_FAC_INI 0.5 + + +#define OFF_FRAMES_LIMIT 30 /* 300 ms for LC3 10 ms */ + + + +#define LGW32k 7 +#define LGW16k 5 + + +/* Tables for attentuation of mag_chg, copied from FX */ +/* Tables are in Q15 */ +/* 0.3 dB attenuation per frame for 16 frames, then 6 dB attenuation per frame */ +const LC3_INT32 POW_ATT_TABLE1[OFF_FRAMES_LIMIT + 1] = { 32767, 31656, 30581, 29543, 28540, 27571, 26635, 25731, 24857, 24013, + 23198, 22410, 21650, 20915, 20205, 19519, 9759, 4880, 2440, 1220, + 610, 305, 152, 76, 38, 19, 10, 5, 2, 1, + 0 }; +/* % 0.4 dB attenuation per frame for 16 frames, then 6 dB attenuation per frame */ +const LC3_INT32 POW_ATT_TABLE0[OFF_FRAMES_LIMIT + 1] = { 32767, 31293, 29885, 28540, 27255, 26029, 24857, 23738, 22670, 21650, + 20675, 19745, 18856, 18007, 17197, 16423, 8211, 4106, 2053, 1026, + 513, 257, 128, 64, 32, 16, 8, 4, 2, 1, + 0 }; + +#ifdef PLC2_FADEOUT_IN_MS +#if PLC2_FADEOUT_IN_MS == 0 +#ifndef CR8_A_PLC_FADEOUT_TUNING +/* default setting only requires two tables */ +const Word16* const POW_ATT_TABLES[1 + 2] = +{ NULL, POW_ATT_TABLE1/*1 0.3dB steps */ , POW_ATT_TABLE0/*2 0.4 dB steps*/, +}; +#endif +#else + +#ifdef CR8_A_PLC_FADEOUT_TUNING +const LC3_INT32 POW_ATT_TABLE_p3x9_14_7[OFF_FRAMES_LIMIT + 1] = { + 32767, + 31656, 30581, 29543, 28540, 27571, 26635, 25731, 24857, 24013, /* 9 times .3dB steps , 14 6 dB steps, 7 muted steps */ + 12007, 6003, 3002, 1501, 750, 375, 188, 94, 47, 23, 12, 6, 3, 1, + 0, 0, 0, 0, 0, 0, 0 }; + +const LC3_INT32 POW_ATT_TABLE_p4x9_14_7[OFF_FRAMES_LIMIT + 1] = +{ 32767, + 31293, 29885, 28540, 27255, 26029, 24857, 23738, 22670, 21650, /* 9 times .4dB steps , 14 6 dB steps, 7 muted steps */ + 10825, 5413, 2706, 1353, 677, 338, 169, 85, 42, 21, 11, 5, 3, 1, + 0, 0,0,0,0,0,0 }; +#endif + + +const LC3_INT32 POW_ATT_TABLE_p3x8_6[] = { + 32767, 31656, 30581, 29543, 28540, 27571, 26635, 25731, 12865, 6433, + 3216, 1608, 804, 402, 201, 101, 50, 25, 13, 6, + 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0 }; +const LC3_INT32 POW_ATT_TABLE_p4x8_6[OFF_FRAMES_LIMIT + 1] = { + 32767, 31293, 29885, 28540, 27255, 26029, 24857, 23738, 11869, 5935, + 2967, 1484, 742, 371, 185, 93, 46, 23, 12, 6, + 3, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0 }; + +const LC3_INT32 POW_ATT_TABLE_p3x4_6[OFF_FRAMES_LIMIT + 1] = { + 32767, 31656, 30581, 29543, 14772, 7386, 3693, 1847, 923, 462, + 231, 115, 58, 29, 14, 7, 4, 2, 1, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +const LC3_INT32 POW_ATT_TABLE_p4x4_6[OFF_FRAMES_LIMIT + 1] = { + 32767, 31293, 29885, 28540, 14270, 7135, 3568, 1784, 892, 446, + 223, 111, 56, 28, 14, 7, 3, 2, 1, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + +const LC3_INT32 POW_ATT_TABLE_p3x2_6[OFF_FRAMES_LIMIT + 1] = { + 32767, 31656, 15828, 7914, 3957, 1979, 989, 495, 247, 124, + 62, 31, 15, 8, 4, 2, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +const LC3_INT32 POW_ATT_TABLE_p4x2_6[OFF_FRAMES_LIMIT + 1] = { + 32767, 31293, 15647, 7823, 3912, 1956, 978, 489, 244, 122, + 61, 31, 15, 8, 4, 2, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + +const LC3_INT32 POW_ATT_TABLE_p3x1_6[OFF_FRAMES_LIMIT + 1] = { + 32767, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, + 32, 16, 8, 4, 2, 1, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +const LC3_INT32 POW_ATT_TABLE_p4x1_6[OFF_FRAMES_LIMIT + 1] = { + 32767, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, + 32, 16, 8, 4, 2, 1, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + +#ifdef CR8_A_PLC_FADEOUT_TUNING +const LC3_INT32 *const POW_ATT_TABLES[1 + 12] = +{ NULL, +/*0.3dB col , 0.4dB col */ +/* 1*/POW_ATT_TABLE_p3x1_6, POW_ATT_TABLE_p4x1_6, /* 0 0.3dB, 16 6dB, 14mute */ /* 0.4dB version */ /* old short mute tabs */ +/* 3*/POW_ATT_TABLE_p3x2_6, POW_ATT_TABLE_p4x2_6, /* 1 0.3dB, 15 6dB ,14mute */ /* 0.4dB version */ +/* 5*/POW_ATT_TABLE_p3x4_6, POW_ATT_TABLE_p4x4_6, /* 3 0.3dB, 15 6dB , 12 mute */ /* 0.4dB version */ +/* 7*/POW_ATT_TABLE_p3x8_6, POW_ATT_TABLE_p4x8_6, /* 7 0.3dB, 15 6dB , 8 mute */ /* 0.4dB version */ +/* 9*/POW_ATT_TABLE_p3x9_14_7, POW_ATT_TABLE_p4x9_14_7, /* 9 0.3dB, 14 6dB , 7 mute */ /* 0.4dB version */ /* opt 120 ms */ +/*11*/POW_ATT_TABLE1, POW_ATT_TABLE0, /* 15 0.3dB, 14 6dB , 1 mute */ /* 0.4dB version */ /* original curves */ +}; + +#else + +const LC3_INT32* const POW_ATT_TABLES[1 + 10] = +{ NULL, + POW_ATT_TABLE1 , POW_ATT_TABLE0, /* .3dB x16,16 6dB steps */ /* .4dB x16, 16 6dB steps */ /*original/default */ + POW_ATT_TABLE_p3x8_6, POW_ATT_TABLE_p4x8_6, /* .3dB x8, 24 6dB steps */ /* .4dB x8, 24 6dB steps */ + POW_ATT_TABLE_p3x4_6, POW_ATT_TABLE_p4x4_6, /* .3dB x4, 28 6dB steps */ /* .4dB x4, 28 6dB steps */ + POW_ATT_TABLE_p3x2_6, POW_ATT_TABLE_p4x2_6, /* .3dB x2, 30 6dB steps */ /* .4dB x2, 30 6dB steps */ + POW_ATT_TABLE_p3x1_6, POW_ATT_TABLE_p4x1_6 /* .3dB x1, 30 6dB steps */ /* .4dB x1, 30 6dB steps */ +}; +#endif +#endif +#endif + +void plc_phEcu_tba_trans_dect_gains(LC3_INT32 burst_len, LC3_INT32 n_grp, LC3_FLOAT *grp_pow_change, + LC3_FLOAT *stPhECU_beta_mute, LC3_FLOAT *stPhECU_mag_chg_1st, + LC3_FLOAT *alpha, LC3_FLOAT *beta, LC3_FLOAT *mag_chg, LC3_FLOAT *ph_dith, LC3_INT32 *tr_dec, + LC3_FLOAT *att_val, LC3_INT32 *attDegreeFrames_dbg, LC3_FLOAT *thresh_dbg +#ifdef CR8_A_PLC_FADEOUT_TUNING + , LC3_UINT8 plc_fadeout_type +#endif + ) +{ + + LC3_INT32 i; + LC3_FLOAT thresh_tr_dB, max_increase_grp_pow; + LC3_FLOAT max_increase_grp_pow_lin; + LC3_FLOAT grp_pow_change_lin[MAX_LGW]; + LC3_FLOAT XavgFadeinFactor; + + LC3_INT32 burst_att_thresh; + LC3_INT32 att_per_frame_idx; + LC3_INT32 att_always, attDegreeFrames; +#ifndef CR8_A_PLC_FADEOUT_TUNING + LC3_INT32 FADEOUT_IN_MS, PLC_P800_SPEECH_FADEOUT_IN_FRAMES, + PLC2_FADEOUT_IN_FRAMES, BURST_ATT_THRESH_PRE; +#endif + const LC3_INT32 *TABLEQ15; +#ifdef CR8_A_PLC_FADEOUT_TUNING + LC3_INT32 beta_mute_thr; /* time threshold in 10 ms frames to start beta - noise attenuation */ +#endif +#ifndef CR8_A_PLC_FADEOUT_TUNING + LC3_INT32 BURST_ATT_THRESH; /* start attenuate with losses in a row, also starts FADE2AVG actions */ + LC3_INT32 ATT_PER_FRAME; /* initial msuic attenuation table ptr, actually implemented in table lookup! */ + LC3_INT32 BETA_MUTE_THR; /* time threshold in 10 ms frames to start beta - noise attenuation */ +#endif + UNUSED(attDegreeFrames_dbg); + + /* constants setup */ + att_always = 0; + + XavgFadeinFactor = -1.0; + +#ifndef CR8_A_PLC_FADEOUT_TUNING + if (PLC2_FADEOUT_IN_MS < 0) + { + FADEOUT_IN_MS = PLC_FADEOUT_IN_MS; /* % use TDC - SETTING as basic input */ + } + else + { + FADEOUT_IN_MS = PLC2_FADEOUT_IN_MS; /* % use a PLC2 individual settings */ + } +#endif + +#ifndef CR8_A_PLC_FADEOUT_TUNING + PLC_P800_SPEECH_FADEOUT_IN_FRAMES = (LC3_INT32)LC3_FLOOR((LC3_FLOAT)FADEOUT_IN_MS / (LC3_FLOAT)10.0); /* % nominal value for speech */ + + PLC2_FADEOUT_IN_FRAMES = MIN(OFF_FRAMES_LIMIT, MAX(6, 3 * PLC_P800_SPEECH_FADEOUT_IN_FRAMES)); /* for PLC2 we typically maintain energy 3x longer */ + + BURST_ATT_THRESH_PRE = MIN(5, MAX(1, (1 * PLC2_FADEOUT_IN_FRAMES) / 6)); /* nominal 20-40 ms to start actual muting, will be thresh +1 */ + ATT_PER_FRAME = MIN(10, MAX(2, 2 * (6 - BURST_ATT_THRESH_PRE))); /* % we let the BURST_ATT_thresh control the initial table selection */ + BURST_ATT_THRESH = MIN(BURST_ATT_THRESH_PRE, 4); + BETA_MUTE_THR = MIN(4 + (OFF_FRAMES_LIMIT / 2) + 1, MAX(4, BURST_ATT_THRESH + 1 + (LC3_INT32)LC3_POW((LC3_FLOAT)2.0, BURST_ATT_THRESH_PRE - (LC3_FLOAT)1))); /* nominal time to start mandatory decrease of Xavg */ + +/* Initialize in the same way as done in trans_burst_ana_fx(), even though this is not really needed */ + burst_att_thresh = BURST_ATT_THRESH; + att_per_frame_idx = ATT_PER_FRAME; +#endif + + + /* 10ms constants */ + thresh_tr_dB = 10.0; /* dB threshold kept same as for 20ms, even though transient analysis frame size was shortened */ + max_increase_grp_pow = 0; /* maximum amplification(dB) in case of onset transients, offset always deacy */ + + max_increase_grp_pow_lin = (LC3_FLOAT)1.0*LC3_POW((LC3_FLOAT)10.0, max_increase_grp_pow / (LC3_FLOAT)10.0)*(LC3_FLOAT)(32767.0 / 32768.0); + + +#ifndef CR8_A_PLC_FADEOUT_TUNING + /* envelope setting */ + burst_att_thresh = BURST_ATT_THRESH + 1; + att_per_frame_idx = ATT_PER_FRAME - 1; +#endif + +#ifdef CR8_A_PLC_FADEOUT_TUNING + if (plc_fadeout_type != 0) + { + i = (PLC2_FADEOUT_LONG_IN_MS - PLC2_FADEOUT_IN_MS_MIN) / PLC2_FADEOUT_RES; /*a long fading table entry in fade_scheme_tab */ + } else { + i = (PLC2_FADEOUT_IN_MS - PLC2_FADEOUT_IN_MS_MIN) / PLC2_FADEOUT_RES; /* a shorter fading entry in fade_scheme_tab */ + } + assert(i >= 0 && i <= ((PLC2_FADEOUT_IN_MS_MAX - PLC2_FADEOUT_IN_MS_MIN) / PLC2_FADEOUT_RES) && "fade_scheme_tab index error"); + + att_per_frame_idx = fade_scheme_tab[i][0]; + burst_att_thresh = fade_scheme_tab[i][1]; /* number of 1.0 frames before muting/mixing phase */ + /* band gain muting may can take place earlier due to a band transient */ + beta_mute_thr = fade_scheme_tab[i][2]; /* muting of Xavg contribution start when slow fadeout is over */ +#endif + + attDegreeFrames = 0; + if (burst_len > burst_att_thresh) + { + att_always = 1; + + /* Added to be able to able to use tables to be aligned with FX */ + /* Limit attDegreeFrames to OFF_FRAMES_LIMIT */ + attDegreeFrames = burst_len - burst_att_thresh; + + if (attDegreeFrames > OFF_FRAMES_LIMIT) + { + attDegreeFrames = OFF_FRAMES_LIMIT; + } + } + + + set_vec(1.0 * (32767.0/32768.0), mag_chg, n_grp); + set_vec(0.0, ph_dith, n_grp); + + set_vec(1.0 * (32767.0/32768.0), alpha, n_grp); + set_vec(0.0, beta, n_grp); + set_vec_int(0, tr_dec, n_grp); + + set_vec(1.0 * (32767.0/32768.0), att_val, n_grp); + + + + /* transient detection per band */ + for (i = 0;i < n_grp; i++) { + if(burst_len == 1) + { + /* first bad frame */ + grp_pow_change_lin[i] = LC3_POW((LC3_FLOAT)10.0, grp_pow_change[i]/(LC3_FLOAT)10.0); + + *stPhECU_beta_mute = BETA_MUTE_FAC_INI; + *stPhECU_beta_mute = *stPhECU_beta_mute / (LC3_FLOAT)2.0; + + /* transient processing */ + /* transients may be both rise and decay transients !! */ + + if(LC3_FABS(grp_pow_change[i]) >= thresh_tr_dB) + { + + tr_dec[i] = 1; + } + + + /* magnitude modification */ + att_val[i] = 0.0f; + if(tr_dec[i] || att_always) { + + att_val[i] = MIN(max_increase_grp_pow_lin, grp_pow_change_lin[i]); /* % linear values !! */ + att_val[i] = LC3_SQRT(att_val[i]); + mag_chg[i] = att_val[i]; + stPhECU_mag_chg_1st[i] = att_val[i]; + } + else + { + mag_chg[i] = 1.0 * (LC3_FLOAT)(32767.0/32768.0); + stPhECU_mag_chg_1st[i] = (LC3_FLOAT)1.0; + } + } + else + { + /* burst handling based on states */ + + assert(burst_len >= 2); /* states used here */ + tr_dec[i] = 0; + +#ifndef CR8_A_PLC_FADEOUT_TUNING + if (PLC_FADEOUT_IN_MS > 0) +#endif + { +#ifdef CR8_A_PLC_FADEOUT_TUNING + assert(att_per_frame_idx >= 1 && att_per_frame_idx <= (10+2)); +#else + assert(att_per_frame_idx >= 1 && att_per_frame_idx <= 10); +#endif + TABLEQ15 = POW_ATT_TABLES[att_per_frame_idx]; + att_val[i] = (LC3_FLOAT)1.0 * ( (LC3_FLOAT) TABLEQ15[MIN(OFF_FRAMES_LIMIT, attDegreeFrames )] / (LC3_FLOAT)32768.0); /* Table idx 0...N-1 therefore no + 1 */ + att_val[i] = att_val[i]; + } +#ifndef CR8_A_PLC_FADEOUT_TUNING + else + { + + if (att_per_frame_idx == ATT_PER_FRAME) + { + att_val[i] = (LC3_FLOAT)1.0 * ( (LC3_FLOAT)POW_ATT_TABLE0[MIN(OFF_FRAMES_LIMIT, attDegreeFrames)] / (LC3_FLOAT)32768.0); + } + else + { + att_val[i] = (LC3_FLOAT)1.0 * ( (LC3_FLOAT)POW_ATT_TABLE1[MIN(OFF_FRAMES_LIMIT, attDegreeFrames)] / (LC3_FLOAT)32768.0); + } + } +#endif + + if ( (att_val[i] != 0) && (att_val[i] * (LC3_FLOAT)32768.0 < (LC3_FLOAT)0.5) ) + { + att_val[i] = 0.0; /* for SNR measurments match in float lowest possible level to BASOP representation */ + } + + /* Apply attenuation */ + mag_chg[i] = stPhECU_mag_chg_1st[i]; + + mag_chg[i] = mag_chg[i] * att_val[i]; /* add additional attenuation from burst attenation logic */ + + if ((mag_chg[i] != 0) && (mag_chg[i] * (LC3_FLOAT)32768.0 < (LC3_FLOAT)0.5)) + { + mag_chg[i] = 0; /* for SNR measurments match in float lowest possible level to BASOP representation */ + } + + +#ifdef CR8_A_PLC_FADEOUT_TUNING + /* note beta_mute decreased once per frame, not once per band */ + if (i == 0 && burst_len > beta_mute_thr) +#else + if(burst_len > BETA_MUTE_THR) +#endif + { + *stPhECU_beta_mute = *stPhECU_beta_mute * (LC3_FLOAT)BETA_MUTE_FAC; + } + + alpha[i] = mag_chg[i]; + + if (alpha[i] >= (LC3_FLOAT)(32766.0 / 32768.0)) + { + beta[i] = 0; /* align to BASOP more efficent use of beta */ + } + else + { + beta[i] = LC3_SQRT((LC3_FLOAT)1.0 - alpha[i]* alpha[i]) * *stPhECU_beta_mute; + } + + if ( i >= LGW32k-1) { + beta[i] = beta[i] * (LC3_FLOAT)0.1; + } + else if( i >= LGW16k-1) + { + beta[i] = beta[i] * (LC3_FLOAT)0.5; + } + + + /* limit Xavg noise contribution further in case of offset / tr_decay */ + + if ((burst_len <= burst_att_thresh) && (stPhECU_mag_chg_1st[i] < (LC3_FLOAT)(32767.0 / 32768.0))) + { + XavgFadeinFactor = (LC3_FLOAT)(burst_len - (LC3_FLOAT)1.0) / burst_att_thresh; + + XavgFadeinFactor = MIN((LC3_FLOAT)1.0, XavgFadeinFactor); + + beta[i] = beta[i] * XavgFadeinFactor; + + } + } + } + + if (thresh_dbg != NULL) + { + *thresh_dbg = XavgFadeinFactor; + } + + return; +} + diff --git a/lib_lc3plus/plc_phecu_trans_burst_ana_sub.c b/lib_lc3plus/plc_phecu_trans_burst_ana_sub.c new file mode 100644 index 0000000000000000000000000000000000000000..a25947a1864a0c43eef673860f191e9de6e2579d --- /dev/null +++ b/lib_lc3plus/plc_phecu_trans_burst_ana_sub.c @@ -0,0 +1,60 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.3 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + + +#include "options.h" +#include "wmc_auto.h" +#include "defines.h" +#include "functions.h" + + + + +void plc_phEcu_trans_burst_ana_sub(LC3_INT32 fs_idx, LC3_INT32 burst_len, LC3_INT32 n_grp, LC3_FLOAT *oold_spect_shape, + LC3_FLOAT *oold_EwPtr, LC3_FLOAT *old_spect_shape, + LC3_FLOAT *old_EwPtr, LC3_FLOAT *stPhECU_beta_mute, + LC3_FLOAT *stPhECU_mag_chg_1st, LC3_FLOAT *stPhECU_Xavg, LC3_FLOAT *alpha, LC3_FLOAT *beta, LC3_FLOAT *mag_chg, LC3_INT32 *tr_dec_dbg, LC3_FLOAT *gpc_dbg +#ifdef CR8_A_PLC_FADEOUT_TUNING + , LC3_UINT8 plc_fadeout_type +#endif +) +{ + LC3_FLOAT gr_pow_left[MAX_LGW]; + LC3_FLOAT gr_pow_right[MAX_LGW]; + LC3_FLOAT trans[MAX_LGW]; + LC3_FLOAT grp_pow_change[MAX_LGW]; + LC3_FLOAT ph_dith[MAX_LGW]; + LC3_FLOAT att_val[MAX_LGW]; + LC3_INT32 tr_dec[MAX_LGW]; + + LC3_INT32 attDegreeFrames; + LC3_FLOAT thresh_dbg; + + UNUSED(tr_dec_dbg); + UNUSED(gpc_dbg); + + if (burst_len <= 1) + { + plc_phEcu_tba_spect_Xavg(fs_idx, n_grp, oold_spect_shape, oold_EwPtr, old_spect_shape, old_EwPtr, gr_pow_left, gr_pow_right, stPhECU_Xavg); + + plc_phEcu_tba_per_band_gain(n_grp, gr_pow_left, gr_pow_right, trans, grp_pow_change); + + } + + plc_phEcu_tba_trans_dect_gains(burst_len, n_grp, grp_pow_change, stPhECU_beta_mute, stPhECU_mag_chg_1st, alpha, beta, mag_chg, ph_dith, tr_dec, att_val, &attDegreeFrames, &thresh_dbg +#ifdef CR8_A_PLC_FADEOUT_TUNING + , plc_fadeout_type +#endif + ); + + + + return; +} + diff --git a/lib_lc3plus/plc_tdc.c b/lib_lc3plus/plc_tdc.c new file mode 100644 index 0000000000000000000000000000000000000000..25c4aa06407a6c68b674f0c84113dcb814c62a63 --- /dev/null +++ b/lib_lc3plus/plc_tdc.c @@ -0,0 +1,803 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.3 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + + +/***************************************************************************\ + * contents/description: Main function for Time domain concealment +\***************************************************************************/ + +#include "options.h" +#include "wmc_auto.h" +#include +#include "functions.h" + + +static LC3_INT16 TDC_random_short(LC3_INT16 *seed); +static LC3_FLOAT TDC_get_gainp(const LC3_FLOAT x[], const LC3_FLOAT y[], LC3_INT32 n); +static LC3_FLOAT TDC_get_gainc(const LC3_FLOAT x[], const LC3_FLOAT y[], const LC3_FLOAT *gain_p, const LC3_INT32 n, const LC3_INT32 frame_dms); +static void TDC_LPC_synthesis(const LC3_FLOAT a[], LC3_FLOAT x[], LC3_FLOAT y[], LC3_INT32 l, const LC3_FLOAT mem[], LC3_INT32 lpcorder, LC3_FLOAT *buf); +static void TDC_LPC_residu(const LC3_FLOAT *a, LC3_FLOAT *x, LC3_FLOAT *y, LC3_INT32 l, LC3_INT32 lpcorder); +static void TDC_highPassFiltering(const LC3_INT32 L_buffer, LC3_FLOAT exc2[], const LC3_FLOAT hp_filt[], const LC3_INT32 l_fir_fer); +static void TDC_f_preemph(LC3_FLOAT *signal, const LC3_FLOAT *mu, LC3_INT32 L, LC3_FLOAT *mem); +static void TDC_deemph(LC3_FLOAT *signal, const LC3_FLOAT *mu, LC3_INT32 L, const LC3_FLOAT *mem); +const LC3_FLOAT TDC_high_16[TDC_L_FIR_HP] = { 0.f, -0.0205f, -0.0651f, -0.1256f, -0.1792f, 0.8028f, -0.1792f, -0.1256f, -0.0651f, -0.0205f, 0.f }; +const LC3_FLOAT TDC_high_32[TDC_L_FIR_HP] = {-0.0517f, -0.0587f, -0.0820f, -0.1024f, -0.1164f, 0.8786f, -0.1164f, -0.1024f, -0.0820f, -0.0587f, -0.0517f}; +const LC3_FLOAT TDC_high_16_harm[TDC_L_FIR_HP] = { 0.0053f, 0.0000f, -0.0440f, 0.0000f, 0.2637f, 0.5500f, 0.2637f, 0.0000f, -0.0440f, 0.0000f, 0.0053f}; +const LC3_FLOAT TDC_high_32_harm[TDC_L_FIR_HP] = {-0.0053f, -0.0037f, -0.0140f, 0.0180f, 0.2668f, 0.4991f, 0.2668f, 0.0180f, -0.0140f, -0.0037f, -0.0053f}; +static void TDC_levinson(LC3_FLOAT *acf, LC3_INT32 len, LC3_FLOAT *out); +static void TDC_copyFLOAT(const LC3_FLOAT * X, LC3_FLOAT * Z, LC3_INT32 n); +static LC3_FLOAT TDC_dotFLOAT(const LC3_FLOAT * X, const LC3_FLOAT * Y, LC3_INT32 n); + +const LC3_INT32 beforeNextIncArray[4][4] = {{0,0,0,1}, + {0,1,0,1}, + {0,1,1,1}, + {1,1,1,1}}; +const LC3_INT32 nextIncArray[4][4] = {{1,0,0,0}, + {1,0,1,0}, + {1,0,1,1}, + {1,1,1,1}}; + +void processTdcApply_fl(const LC3_INT32 pitch_int, + const LC3_FLOAT *preemphFac, + const LC3_FLOAT* A, + const LC3_INT32 lpc_order, + const LC3_FLOAT* pcmbufHist, + const LC3_INT32 max_len_pcm_plc, + const LC3_INT32 N, + const LC3_INT32 frame_dms, + const LC3_INT32 SampRate, + const LC3_INT32 nbLostFramesInRow, + const LC3_INT32 overlap, + const LC3_FLOAT *stabFac, + LC3_FLOAT harmonicBuf[MAX_PITCH], + LC3_FLOAT synthHist[M], + LC3_INT32* fract, + LC3_INT16* seed, + LC3_FLOAT* gain_c, + LC3_FLOAT* alpha, + LC3_FLOAT* synth +#ifdef CR9_I_INC_TDC_FADEOUT_LEN + ,LC3_UINT8 plc_fadeout_type +#endif + ) +{ + LC3_FLOAT step, step_n; + LC3_INT32 i, len, Tc, nbLostCmpt_loc, nextInc, beforeNextInc; + LC3_FLOAT gain_h, tmp, gain_p; + LC3_FLOAT *exc2, *exc_buf, *exc, *x_pre, *buf, *pt_exc, *pt1_exc, *synthMemPtr; + LC3_FLOAT *harmonicBufPtr; + LC3_FLOAT synth_mem[M]; + const LC3_FLOAT *hp_filt, *high_harm; + LC3_FLOAT gainInov; + LC3_FLOAT hpBlendFac; + char *scratchSpace1st, *scratchSpaceTmp; + char scratchSpace[(MAX_LEN_PCM_PLC + MDCT_MEM_LEN_MAX + MAX_LEN_PCM_PLC + 1 + M) * sizeof(LC3_FLOAT)]; + LC3_FLOAT alphaPrev; + LC3_FLOAT throttle; + LC3_INT32 frame_dms_idx, nbLostFramesInRow_mod; +#ifdef CR9_I_INC_TDC_FADEOUT_LEN + LC3_INT32 plc_fadeout_len = 0; +#endif + + memset(synth_mem, 0, M * sizeof(LC3_FLOAT)); + memset(scratchSpace, 0, (MAX_LEN_PCM_PLC + MDCT_MEM_LEN_MAX + MAX_LEN_PCM_PLC + 1 + M) * sizeof(LC3_FLOAT)); + + /* len of synthesized signal */ + len = N + overlap; + + nbLostCmpt_loc = floor(frame_dms/100.0 * (nbLostFramesInRow - 1) + 1); + frame_dms_idx = frame_dms / 25 - 1; /* 0,1,2,3 */ + nbLostFramesInRow_mod = (nbLostFramesInRow - 1) % 4; + + beforeNextInc = beforeNextIncArray[frame_dms_idx][nbLostFramesInRow_mod]; + nextInc = nextIncArray [frame_dms_idx][nbLostFramesInRow_mod]; + +#ifdef CR9_I_INC_TDC_FADEOUT_LEN + if (plc_fadeout_type == 1){ + plc_fadeout_len = PLC_FADEOUT_TYPE_1_IN_MS; + } + else{ + plc_fadeout_len = PLC_FADEOUT_IN_MS; + } +#endif + +#ifdef CR9_I_INC_TDC_FADEOUT_LEN + if (nbLostCmpt_loc > plc_fadeout_len/10) +#else + if (nbLostCmpt_loc > PLC_FADEOUT_IN_MS/10) +#endif + { + gain_p = 0; + *gain_c = 0; + *alpha = 0; + memset(synth, 0, len * sizeof(LC3_FLOAT)); + return; + } + + Tc = pitch_int; + if (*fract > 0) { + Tc++; + } + + /*---------------------------------------------------------------- + * Buffer Initialization for timeDomainConcealment_Apply + * + * 1st + * |--exc_buf--|--x_pre--| + * | |--exc2--| + * | |--buf (LPC Syn)--| + * + *---------------------------------------------------------------*/ + + scratchSpace1st = scratchSpace; + exc_buf = (LC3_FLOAT*)scratchSpace1st; scratchSpace1st += (LC3_INT32)sizeof(LC3_FLOAT) * (Tc + N/2 + len); + exc = exc_buf + (Tc + N/2); + + scratchSpaceTmp = scratchSpace1st; + x_pre = (LC3_FLOAT*)scratchSpaceTmp; scratchSpaceTmp += (LC3_INT32)sizeof(LC3_FLOAT) * (lpc_order + Tc + N/2 + 1); + + /*---------------------------------------------------------------* + * LPC Residual * + *---------------------------------------------------------------*/ + if (nbLostFramesInRow == 1) + { + /* copy buffer to pre-emphasis buffer */ + TDC_copyFLOAT(&(pcmbufHist[max_len_pcm_plc-(lpc_order+Tc+N/2+1)]), &(x_pre[0]), lpc_order+Tc+N/2+1); + + /* apply pre-emphasis to the signal */ + TDC_f_preemph(&(x_pre[1]), preemphFac, lpc_order+Tc+N/2, &x_pre[0]); + + /* copy memory for LPC synth */ + TDC_copyFLOAT(&(x_pre[Tc+N/2+1]), synth_mem, lpc_order); + + /* LPC Residual */ + TDC_LPC_residu(A, &(x_pre[lpc_order+1]), &(exc[-(Tc+N/2)]), Tc+N/2, lpc_order); + } + + /*---------------------------------------------------------------* + * Calculate gains * + *---------------------------------------------------------------*/ + if (nbLostFramesInRow == 1) + { + if (pitch_int == Tc) + { + gain_p = TDC_get_gainp( &(x_pre[lpc_order+Tc+1]), &(x_pre[lpc_order+1]), N/2 ); + } + else + { + tmp = TDC_get_gainp( &(x_pre[lpc_order+Tc+1]), &(x_pre[lpc_order+2]), N/2 ); + gain_p = TDC_get_gainp( &(x_pre[lpc_order+Tc+1]), &(x_pre[lpc_order+1]), N/2 ); + + if (tmp > gain_p) { + Tc = pitch_int; + gain_p = tmp; + *fract = 0; + } + } + + if(gain_p < 0.0f) + { + gain_p = 0.0f; + } + + if(gain_p > 1.0f) + { + gain_p = 1.0f; + } + + *gain_c = 0.0f; + + if (pitch_int == Tc) + { + *gain_c = TDC_get_gainc( &(exc[-1]), &(exc[-1-Tc]), &gain_p, N/2, frame_dms ); + } + else + { + tmp = TDC_get_gainc( &(exc[-1]), &(exc[-1-pitch_int]), &gain_p, N/2, frame_dms ); + *gain_c = TDC_get_gainc( &(exc[-1]), &(exc[-1-Tc]) , &gain_p, N/2, frame_dms ); + *gain_c = MIN(*gain_c, tmp); + } + } + else + { + gain_p = *alpha; + } + + /*---------------------------------------------------------------* + * Damping factor * + *---------------------------------------------------------------*/ + + alphaPrev = 1; + if (nbLostFramesInRow > 1) + { + alphaPrev = *alpha; + } + +#ifdef CR9_N_SHORT_FADE_FOR_UNSTABLE_PITCH + if (plc_fadeout_type == 2){ + *alpha = LC3_POW(0.5,(nbLostFramesInRow + LC3_ROUND(100.0/frame_dms) - 1) * frame_dms/100.0); + } + else{ +#endif + + if (nextInc != 0) + { + switch (nbLostCmpt_loc) + { + case 1: + *alpha = (LC3_FLOAT)sqrt(gain_p); + if ( *alpha > 0.98f ) + { + *alpha = 0.98f; + } + else if ( *alpha < 0.925f ) + { + *alpha = 0.925f; + } + break; + case 2: + *alpha = (0.63f + 0.35f * (*stabFac)) * gain_p; + if ( *alpha < 0.919f ) + { + *alpha = 0.919f; + } + break; + default: + *alpha = (0.652f + 0.328f * (*stabFac)) * gain_p; + } + } + + if (nbLostCmpt_loc > 3) + { + switch (frame_dms) + { + case 25: *alpha *= PLC34_ATTEN_FAC_025; break; +#ifdef CR9_J_SLOW_TDC_FADEOUT + case 50: *alpha *= PLC34_ATTEN_FAC_025; break; +#else + case 50: *alpha *= PLC34_ATTEN_FAC_050; break; +#endif +#ifdef CR8_G_ADD_75MS + case 75: *alpha *= PLC34_ATTEN_FAC_075; break; +#endif + case 100: *alpha *= PLC34_ATTEN_FAC_100; break; + } + } + + if (nbLostCmpt_loc > 5) + { + gain_p = *alpha; + } +#ifdef CR9_N_SHORT_FADE_FOR_UNSTABLE_PITCH + } +#endif + /*---------------------------------------------------------------* + * Construct the harmonic part * + * Last pitch cycle of the previous frame is repeatedly copied. * + *---------------------------------------------------------------*/ + + pt_exc = harmonicBuf; + pt1_exc = exc - Tc; + + if( nbLostFramesInRow == 1 ) + { + if (*stabFac >= 1) + { + TDC_copyFLOAT(pt1_exc, pt_exc, Tc); + } + else + { + /* These values are necessary for the last five filtered samples */ + TDC_copyFLOAT(&exc[-Tc], exc, (TDC_L_FIR_HP-1)/2); + + high_harm = TDC_high_32_harm; + if (SampRate <= 16000) + { + high_harm = TDC_high_16_harm; + } + + for( i = 0; i < Tc; i++ ) + { + pt_exc[i] = TDC_dotFLOAT(&pt1_exc[i-(TDC_L_FIR_HP-1)/2], high_harm, TDC_L_FIR_HP); + } + } + } + + /*---------------------------------------------------------------* + * Construct the random part of excitation * + *---------------------------------------------------------------*/ + scratchSpaceTmp = scratchSpace1st; + exc2 = (LC3_FLOAT*)scratchSpaceTmp; scratchSpaceTmp += (LC3_INT32)sizeof(LC3_FLOAT) * (len + TDC_L_FIR_HP - 1); + + for (i = 0; i < len + TDC_L_FIR_HP - 1; i++) { + exc2[i] = (LC3_FLOAT)TDC_random_short(seed); + } + + /* high pass noise */ + if (SampRate <= 16000 ) + { + hp_filt = TDC_high_16; + } else { + hp_filt = TDC_high_32; + } + + if ( nbLostFramesInRow == 1 ) + { + TDC_highPassFiltering(len, exc2, hp_filt, TDC_L_FIR_HP); + } + else + { + /* moves from 0 to 1, speed is defined by PLC3_HPBLENDTHROTTLE */ + throttle = (LC3_FLOAT)nbLostCmpt_loc / (nbLostCmpt_loc + PLC3_HPBLENDTHROTTLE); + hpBlendFac = (1 - *alpha) * throttle; + + for (i = 0; i < len; i++) + { + exc2[i] = hpBlendFac * exc2[i+TDC_L_FIR_HP/2] + (1 - hpBlendFac) * TDC_dotFLOAT(&exc2[i], hp_filt, TDC_L_FIR_HP ); + } + } + + /* normalize energy */ + gainInov = 1.0f / (LC3_FLOAT)sqrt(TDC_dotFLOAT( exc2, exc2, N ) / (LC3_FLOAT)N + 0.01f ); + gainInov *= (1.1f - 0.75* gain_p); + + /* gains */ + gain_h = alphaPrev; + tmp = *gain_c * *alpha / alphaPrev; + + /* update steps */ + step = (1.0f/(LC3_FLOAT)N) * (gain_h - *alpha); + step_n = (1.0f/(LC3_FLOAT)N) * (*gain_c - tmp); + + /*---------------------------------------------------------------* + * Construct the total excitation * + *---------------------------------------------------------------*/ + harmonicBufPtr = harmonicBuf + ((nbLostFramesInRow - 1) * N) % Tc; + + for ( i = 0; i < len; i++ ) { + /* harmonic */ + if (harmonicBufPtr - harmonicBuf >= Tc) { + harmonicBufPtr = harmonicBuf; + } + exc[i] = *harmonicBufPtr++; + exc[i] *= gain_h; + + /* random */ + exc2[i] *= *gain_c * gainInov; + + /* total */ + exc[i] = exc[i] + exc2[i]; + + /* update */ + gain_h -= step; + gain_h = MAX(gain_h, 0); + *gain_c -= step_n; + *gain_c = MAX(*gain_c, 0); + } + + *gain_c = tmp; + + /*----------------------------------------------------------* + * Compute the synthesis speech * + *----------------------------------------------------------*/ + buf = (LC3_FLOAT*)scratchSpace1st; scratchSpace1st += (LC3_INT32)sizeof(LC3_FLOAT) * (len + lpc_order); + synthMemPtr = synth_mem; + if (nbLostFramesInRow != 1) + { + synthMemPtr = synthHist; + } + + TDC_LPC_synthesis(A, + &exc[0], + synth, + len, + synthMemPtr, + lpc_order, + buf); + + TDC_copyFLOAT(&synth[N-lpc_order], synthHist, lpc_order); + + /*----------------------------------------------------------* + * Deemphasis * + *----------------------------------------------------------*/ + TDC_deemph( synth, preemphFac, len, &pcmbufHist[max_len_pcm_plc-1] ); + + /*----------------------------------------------------------* + * Fade to zero * + *----------------------------------------------------------*/ + if (beforeNextInc != 0) + { +#ifdef CR9_I_INC_TDC_FADEOUT_LEN + if (nbLostCmpt_loc == plc_fadeout_len/10) +#else + if (nbLostCmpt_loc == PLC_FADEOUT_IN_MS/10) +#endif + { + gain_h = 1; + step = 1.0f/(LC3_FLOAT)N; + for ( i = 0; i < N; i++ ) { + synth[i] *= gain_h; + gain_h -= step; + } + memset(&synth[N], 0, overlap * sizeof(LC3_FLOAT)); + } + } +} + +/* Take only real part */ +void processTdcInverseOdft_fl(LC3_FLOAT *in, LC3_INT32 n_bands, LC3_FLOAT *out, LC3_INT32 lpc_order) +{ + LC3_INT32 i, j, k; + LC3_FLOAT buf[2*MAX_BANDS_NUMBER_PLC]; + Complex sum; + Complex res; + + /* Buffer for ifft */ + j = 0; + for (i = 0; i < n_bands - 1; i += 2) + { + buf[j] = in[i]; + j++; + } + + for (i = n_bands - 1; i > 0; i -= 2) + { + buf[j] = in[i]; + j++; + } + + for (i = 0; i < n_bands; i++) + { + buf[j] = in[i]; + j++; + } + + /* ifft */ + for (j = 0; j < n_bands; j++) + { + sum.r = 0, sum.i = 0; + res.r = 0, res.i = 0; + for (k = 0; k < n_bands; k++) + { + res = cexpi((2 * M_PI * (LC3_FLOAT) (j * k)) / (LC3_FLOAT) n_bands); + res.r = res.r * buf[k]; + res.i = res.i * buf[k]; + sum = cadd(sum, res); + } + + res = cexpi((LC3_FLOAT) j * M_PI / (2.0 * (LC3_FLOAT) n_bands)); + out[j] = (sum.r * res.r - sum.i * res.i); + } + + out[0] = out[0] * 1.0001; + if (out[0] == 0) + { + out[0] = 1; + zero_float(&out[1], lpc_order); + } +} + +void processTdcPreemphasis_fl(LC3_FLOAT *in, LC3_FLOAT *pre_emph_factor, LC3_INT32 n_bands) +{ + LC3_INT32 i; + + for (i = 0; i < n_bands; i++) + { + in[i] = in[i] * (1.0 - 2.0 * (*pre_emph_factor) * LC3_COS(2.0 * M_PI * (0.5 + (LC3_FLOAT) i) / (2.0 * (LC3_FLOAT) n_bands)) + (*pre_emph_factor) * (*pre_emph_factor)); + } +} + +void processTdcLpcEstimation_fl(LC3_FLOAT *r, LC3_INT32 fs_idx, LC3_INT32 len, LC3_FLOAT *A, LC3_INT32 frame_dms) +{ + LC3_INT32 i; + const LC3_FLOAT *lpc_array; + + lpc_array = plc_tdc_lpc_all[fs_idx]; + + if (fs_idx == 0 && frame_dms == 25) + { + lpc_array = plc_tdc_lpc_8_25ms; + } + + /* r[0] = r[0] * 1 */ + for (i = 1; i < len; i++) + { + r[i] = r[i] * lpc_array[i]; + } + + TDC_levinson(r, len - 1, A); +} + +/** random + * + * Parameters: + * seed I/O: seed for random number + * + * Function: + * Signed 16 bits random generator. + * + * Returns: + * random number + */ +static LC3_INT16 TDC_random_short(LC3_INT16 *seed) +{ + *seed = (LC3_INT16) (*seed * 12821L + 16831L); + return(*seed); +} + +static LC3_FLOAT TDC_get_gainp( /* output: gain of pitch */ + const LC3_FLOAT x[], /* input : input signal */ + const LC3_FLOAT y[], /* input : shifted input signal */ + LC3_INT32 n /* input : vector length */ +) +{ + LC3_FLOAT corr, ener; + LC3_INT16 i; + + corr = 0; ener = 1e-6f; + + for (i = 0; i < n; i++) + { + corr += x[i]*y[i]; + ener += y[i]*y[i]; + } + + return(corr/ener); +} + +static LC3_FLOAT TDC_get_gainc( /* output: gain of code */ + const LC3_FLOAT x[], /* input : input signal */ + const LC3_FLOAT y[], /* input : shifted input signal */ + const LC3_FLOAT *gain_p, /* input : gain of pitch */ + const LC3_INT32 n, /* input : vector length */ + const LC3_INT32 frame_dms /* input : frame length in dms */ +) +{ + LC3_FLOAT gain_c; + LC3_FLOAT gain_c_max; + LC3_INT16 i; + + gain_c = 0; gain_c_max = 0; + + for (i = 0; i < n; i++) + { + gain_c += ( x[-i] - *gain_p * y[-i] ) * ( x[-i] - *gain_p * y[-i] ); + } + + if (frame_dms < 100) + { + for (i = 0; i < n; i++) + { + gain_c_max += (x[-i] * x[-i]); + } + gain_c = MIN(gain_c, gain_c_max); + } + + gain_c = (LC3_FLOAT)sqrt(gain_c / n ); + + return gain_c; +} + +static void TDC_highPassFiltering(const LC3_INT32 L_buffer, /* i: buffer length */ + LC3_FLOAT exc2[], /* i/o: unvoiced excitation before the high pass filtering */ + const LC3_FLOAT hp_filt[], /* i: high pass filter coefficients */ + const LC3_INT32 l_fir_fer) /* i: high pass filter length */ +{ + LC3_INT32 i; + + for( i=0 ; i< L_buffer; i++ ) { + exc2[i] = TDC_dotFLOAT(&exc2[i], hp_filt, l_fir_fer); + } +} + +static void TDC_LPC_synthesis( + const LC3_FLOAT a[], + LC3_FLOAT x[], + LC3_FLOAT y[], + LC3_INT32 l, + const LC3_FLOAT mem[], + LC3_INT32 lpcorder, + LC3_FLOAT *buf + ) +{ + LC3_FLOAT s, *yy; + LC3_INT32 i, j; + + /* copy initial filter states into synthesis buffer */ + for (i=0; i < lpcorder; i++) + { + buf[i] = mem[i]; + } + yy = &buf[i]; + + for (i = 0; i < l; i++) + { + s = x[i]; + for (j = 1; j <= lpcorder; j++) + { + s -= a[j] * yy[i- j]; + } + y[i] = s; + yy[i] = y[i]; + } + + return; +} + + +/** TDC_LPC_residu + * + * Parameters: + * a I: LP filter coefficients (Q12) + * x I: input signal (usually speech) + * y O: output signal (usually residual) + * l I: size of filtering + * lpcorder I: Order of LP filter + * + * Function: + * Compute the LP residual by filtering the input speech through A(z). + * + * Returns: + * void + */ +static void TDC_LPC_residu(const LC3_FLOAT *a, LC3_FLOAT *x, LC3_FLOAT *y, LC3_INT32 l, LC3_INT32 lpcorder) +{ + LC3_FLOAT s; + LC3_INT32 i, j; + + for (i = 0; i < l; i++) + { + s = x[i]; + for (j = 1; j <= lpcorder; j++) + { + s += a[j] * x[i - j]; + } + y[i] = s; + } + + return; +} + + +/** TDC_f_preemph + * + * Parameters: + * signal I/O: signal + * mu I: preemphasis factor + * L I: vector size + * mem I: memory (x[-1]) + * + * Function: + * Filtering through 1 - mu z^-1 + * + * + * Returns: + * void + */ + +static void TDC_f_preemph(LC3_FLOAT *signal, const LC3_FLOAT *mu, LC3_INT32 L, LC3_FLOAT *mem) +{ + LC3_INT32 i; + + for (i = L - 1; i > 0; i--) + { + signal[i] = signal[i] - *mu * signal[i - 1]; + } + + signal[0] -= *mu * (*mem); + + return; +} + +/* + * TDC_deemph + * + * Parameters: + * signal I/O: signal + * mu I: deemphasis factor + * L I: vector size + * mem I: memory (signal[-1]) + * + * Function: + * Filtering through 1/(1-mu z^-1) + * Signal is divided by 2. + * + * Returns: + * void + */ +static void TDC_deemph(LC3_FLOAT *signal, const LC3_FLOAT *mu, LC3_INT32 L, const LC3_FLOAT *mem) +{ + LC3_INT32 i; + + signal[0] = signal[0] + *mu * (*mem); + + for (i = 1; i < L; i++) + { + signal[i] = signal[i] + *mu * signal[i - 1]; + } + + return; +} + +static void TDC_copyFLOAT(const LC3_FLOAT * X, LC3_FLOAT * Z, LC3_INT32 n) +{ + /* no values to copy */ + if ( (n < 1) || (X == Z) ){ + return; + } + /* If overlapping */ + if ( ( (Z > X) && (Z < X+n) ) || ( (Z < X) && (X < Z+n) ) ) { + memmove(Z, X, sizeof(LC3_FLOAT)*n); + } + else{ + memcpy(Z, X, sizeof(LC3_FLOAT)*n); + } +} + +static LC3_FLOAT TDC_dotFLOAT(const LC3_FLOAT * X, const LC3_FLOAT * Y, LC3_INT32 n) +{ + LC3_FLOAT acc; + LC3_INT32 i; + + acc = 0; + if (n) { + acc = X[0]*Y[0]; + } + + for (i=1; i= 0; i--) + { + out[j] = buf[k] - g * buf2[i]; + j++; k++; + } + + v = v * (1.0 - g * g); + } + + move_float(buf, out, len); + out[0] = 1; + + j = 1; + for (i = len - 1; i >= 0; i--) + { + out[j] = -buf[i]; + j++; + } +} + diff --git a/lib_lc3plus/plc_tdc_tdac.c b/lib_lc3plus/plc_tdc_tdac.c new file mode 100644 index 0000000000000000000000000000000000000000..596c23db034d8568b4b0109465249e2f323d9471 --- /dev/null +++ b/lib_lc3plus/plc_tdc_tdac.c @@ -0,0 +1,81 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.3 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + + +#include "options.h" +#include "wmc_auto.h" +#include "functions.h" + + +void processTdcTdac_fl(const LC3_FLOAT *synth_inp, const LC3_FLOAT *win, LC3_INT32 frame_length, LC3_INT32 la_zeroes, LC3_FLOAT *ola_mem) +{ + LC3_INT32 i, L, LD2, NZ, synth_len; + LC3_FLOAT synth[(MAX_LEN + MDCT_MEM_LEN_MAX)], *synth1, *synth2, *ola_mem1, *ola_mem2, sz; + const LC3_FLOAT *win1, *win2, *win3, *win4; + + assert(la_zeroes <= frame_length / 2); + + L = frame_length; + LD2 = L/2; + NZ = LD2 - la_zeroes; + synth_len = 2*L - la_zeroes; + + move_float(synth, synth_inp, synth_len); + + /* calculate x_ov[L+la_zeroes] ... x_ov[2*L-1] */ + win1 = &win[L + LD2 - 1]; + win2 = &win[L + LD2]; + + win3 = &win[LD2 - 1]; + win4 = &win[LD2]; + + synth1 = &synth[L + LD2 - 1 - la_zeroes]; + synth2 = &synth[L + LD2 - la_zeroes]; + + ola_mem1 = &ola_mem[LD2 - la_zeroes]; + ola_mem2 = &ola_mem[LD2 - la_zeroes - 1]; + + for (i = 0; i < NZ; i++) + { + /* analysis windowing + 2N -> N */ + sz = *synth1 * *win1 + *synth2 * *win2; + + /* N -> 2N + synthesis windowing */ + *ola_mem1 = sz * *win3; + *ola_mem2 = sz * *win4; + + /* pointer update */ + win1--; + win2++; + win3--; + win4++; + synth1--; + synth2++; + ola_mem1++; + ola_mem2--; + } + + for (; i < LD2; i++) + { + /* analysis windowing + 2N -> N */ + sz = *synth1 * *win1; + + /* N -> 2N + synthesis windowing */ + *ola_mem1 = sz * *win3; + + /* pointer update */ + win1--; + win2++; + win3--; + synth1--; + synth2++; + ola_mem1++; + } +} + diff --git a/lib_lc3plus/plc_update.c b/lib_lc3plus/plc_update.c new file mode 100644 index 0000000000000000000000000000000000000000..40520fb2560e6942a8e2fa7a92955b94c349d206 --- /dev/null +++ b/lib_lc3plus/plc_update.c @@ -0,0 +1,126 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.3 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + +#include "options.h" +#include "wmc_auto.h" +#include "functions.h" + + +void processPlcUpdate_fl(PlcAdvSetup *PlcAdvSetup, LC3_INT32 frame_length, LC3_FLOAT *syntM, LC3_FLOAT *scf_q, + LC3_INT32 *nbLostCmpt, LC3_FLOAT *cum_alpha, LC3_INT32 bfi, LC3_INT32 *prevBfi, LC3_INT32 *prevprevBfi) +{ + LC3_FLOAT tmp[MAX_LEN_PCM_PLC]; + + move_float(tmp, &PlcAdvSetup->pcmbufHist[frame_length], PlcAdvSetup->max_len_pcm_plc - frame_length); + move_float(&PlcAdvSetup->pcmbufHist[0], tmp, PlcAdvSetup->max_len_pcm_plc - frame_length); + move_float(&PlcAdvSetup->pcmbufHist[PlcAdvSetup->max_len_pcm_plc - frame_length], syntM, frame_length); + + if (bfi != 1) + { + *nbLostCmpt = 0; + *cum_alpha = 1; + + if (PlcAdvSetup) + { + move_float(PlcAdvSetup->scf_q_old_old, PlcAdvSetup->scf_q_old, M); + move_float(PlcAdvSetup->scf_q_old, scf_q, M); + /* PLC fullband transient detector setting for non-bfi frames */ + PlcAdvSetup->PlcPhEcuSetup.PhECU_short_flag_prev = 0; /* fullband transient not active */ + } + } + + *prevprevBfi = *prevBfi; + *prevBfi = bfi; +} + +void plc_phEcu_processPLCspec2shape(LC3_INT16 prev_bfi, LC3_INT16 bfi, LC3_FLOAT q_d[], LC3_INT32 yLen, + LC3_FLOAT *stPhECU_oold_grp_shape, LC3_FLOAT *stPhECU_old_grp_shape) +{ + LC3_INT32 i, j, N_grp; + LC3_INT32 local_prev_bfi; + LC3_INT32 fs_idx; + LC3_FLOAT E_tot = 0.0; + LC3_INT32 l_grp; + LC3_FLOAT *pX; + + if (bfi != 1) /* compute only for bfi== 0 or 2 */ + { + fs_idx = (LC3_INT32)floor(yLen / 100); + assert(fs_idx < 5); + N_grp = xavg_N_grp[fs_idx]; + + local_prev_bfi = prev_bfi; + if (local_prev_bfi == 2) { + local_prev_bfi = 0; + } + + + /* Copy old to oold grp shape */ + for (i = 0; i < MAX_LGW; i++) + { + stPhECU_oold_grp_shape[i] = stPhECU_old_grp_shape[i]; + } + + /* Accumulate DC-coupled bins to total */ + E_tot = 0; + pX = q_d; /* ptr setup */ + for (i = 0; i < mdct_grp_bins[0]; i++) + { + E_tot += sqrf( *pX ); + pX++; + } + + /* Accumulate middle grps and add to total */ + for (i = 0; i < (N_grp - 1); i++) + { + l_grp = mdct_grp_bins[i + 1] - mdct_grp_bins[i]; ; + stPhECU_old_grp_shape[i] = 0.0; + for (j = 0; j < l_grp; j++) { + stPhECU_old_grp_shape[i] += sqrf( *pX ); + pX++; + } + E_tot += stPhECU_old_grp_shape[i]; + } + + /* Accumulate last subbband and add to total */ + stPhECU_old_grp_shape[(N_grp - 1)] = 0.0; + l_grp = mdct_grp_bins[N_grp] - mdct_grp_bins[N_grp - 1] - mdct_grp_bins[0]; + assert( (mdct_grp_bins[N_grp] - mdct_grp_bins[0]) <= yLen); + for (j = 0; j < l_grp; j++) + { + stPhECU_old_grp_shape[(N_grp - 1)] += sqrf( *pX ); + pX++; + } + E_tot += stPhECU_old_grp_shape[(N_grp - 1)]; + + + /* Normalize shape */ + for (i = 0; i < (N_grp); i++) { + if (E_tot > 0.0) { + stPhECU_old_grp_shape[i] /= E_tot; + } + else + { + stPhECU_old_grp_shape[i] = 0.0; + } + } + if (local_prev_bfi == 1) { + for (i = 0; i < MAX_LGW; i++) { + stPhECU_oold_grp_shape[i] = stPhECU_old_grp_shape[i]; + } + } + }/*bfi*/ + return; +} + +void processPlcUpdateSpec_fl(LC3_FLOAT *q_d_prev, LC3_FLOAT *q_d_fl_c, LC3_INT32 yLen) +{ + move_float(q_d_prev, q_d_fl_c, yLen); +} + diff --git a/lib_lc3plus/quantize_spec.c b/lib_lc3plus/quantize_spec.c new file mode 100644 index 0000000000000000000000000000000000000000..fdaee2890ae8c46cdb0015b8ef34b71ad8409049 --- /dev/null +++ b/lib_lc3plus/quantize_spec.c @@ -0,0 +1,283 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.3 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + + +#include "options.h" +#include "wmc_auto.h" +#include "functions.h" + +LC3_INT32 find_last_nz_pair(LC3_INT32 x[], LC3_INT32 length); +LC3_INT32 find_last_nz_pair(LC3_INT32 x[], LC3_INT32 length) +{ + LC3_INT32 last_nz, lobs[4]; LC3_INT32 stage, i; + + lobs[0] = 4; + + lobs[1] = (length >> 1); /* length/2 */ + + lobs[2] = (lobs[1]+ (length >> 2)); + + lobs[3] = (lobs[2]+ (length >> 3)); + + + last_nz = 0; + + i = length; + + for (stage = 3; stage >= 0; --stage) + { + /* unmapped kernel */ + for (; i >= lobs[stage]; i -= 2) + { + if (x[i - 2] != 0) + { + last_nz = MAX(last_nz, i); + } + if (x[i - 1] != 0) + { + last_nz = MAX(last_nz, i); + } + } + if (last_nz > 0) + { + break; + } + } + + return MAX(last_nz, 2); +} + + +void processQuantizeSpec_fl(LC3_FLOAT x[], LC3_FLOAT gain, LC3_INT xq[], LC3_INT nt, LC3_INT totalBits, LC3_INT* nbits, LC3_INT* nbits2, LC3_INT fs, + LC3_INT* lastnzout, LC3_INT* codingdata, LC3_INT* lsbMode, LC3_INT mode, LC3_INT target, LC3_INT hrmode) +{ + + LC3_INT rateFlag, i, lastnz2, m, maxlev, k; + LC3_INT nbits_lsb; + LC3_INT c; + LC3_INT a, b, lev1, sym, t, pki; + LC3_INT a1_msb, b1_msb; + LC3_INT lastnz = 1, nt_half; + LC3_FLOAT offset = 0.375; + LC3_INT32 bits, bits2; +#ifdef CR9_QUANT_SPEC_REWRITE + LC3_FLOAT inv_gain; +#endif + + assert(target >= 0); + + nbits_lsb = 0; + + nt_half = nt >> 1; + rateFlag = 0; c = 0; + + + if (hrmode) + { + offset = 0.5; + } + + /* Quantization */ + +#ifdef CR9_QUANT_SPEC_REWRITE + inv_gain = 1.0 / gain; +#endif + + for (i = 0; i < nt; i++) { + if (x[i] > 0) + { +#ifdef CR9_QUANT_SPEC_REWRITE + xq[i] = (LC3_INT32) ( x[i] * inv_gain + offset); +#else + xq[i] = (LC3_INT32) ( x[i] / gain + offset); +#endif + } + else + { +#ifdef CR9_QUANT_SPEC_REWRITE + xq[i] = -((LC3_INT32) (-x[i] * inv_gain + offset)); +#else + xq[i] = -((LC3_INT32) (-x[i] / gain + offset)); +#endif + } + if (hrmode == 0) { + assert(xq[i] <= 32767 && xq[i] >= -32768); + } + } + + /* Rate flag */ + if (fs != 96000 && (totalBits > (160 + FS2FS_IDX(fs) * 160))) + { + rateFlag = 512; + } + + /* Init */ + if (fs != 96000 && (mode == 0 && (totalBits >= (480 + FS2FS_IDX(fs) * 160)))) + { + mode = 1; + } + + /* Last non-zero 2-tuple */ + for (i = nt - 2; i >= 2; i = i - 2) { + if (xq[i + 1] != 0 || xq[i] != 0) { + lastnz = i + 1; + break; + } + } + + if (mode < 0) + { + lastnz2 = lastnz + 1; + } + else + { + lastnz2 = 2; + } + + bits = bits2 = 0; + + /* Calculate number of estimated bits */ + + for (k = 0; k < lastnz; k = k + 2) + { + t = c + rateFlag; + if (k > nt_half) + { + t += 256; + } + + codingdata[0] = t; + + a = abs(xq[k]); + b = abs(xq[k + 1]); + m = MAX(a, b); + + if (m == 0) + { + maxlev = -1; + } + else + { + maxlev = 29 - (clz_func(MAX(m, 3)) - 1); + } + + codingdata[1] = maxlev; + + if (mode <= 0) { + bits = bits + (MIN(a, 1) << 11); + bits = bits + (MIN(b, 1) << 11); + } + + lev1 = 0; + + while (MAX(a, b) >= 4) + { + pki = ari_spec_lookup_fl[t + lev1 * 1024]; + bits = bits + ari_spec_bits_fl[pki][16]; + + if (lev1 == 0 && mode > 0) + { + nbits_lsb += 2; + } + else + { + bits = bits + 2 * 2048; + } + + a = a >> 1; + b = b >> 1; + lev1 = MIN(lev1 + 1, 3); + } + + pki = ari_spec_lookup_fl[t + lev1 * 1024]; + sym = a + 4 * b; + codingdata[2] = sym; + codingdata += 3; + bits = bits + ari_spec_bits_fl[pki][sym]; + + if (mode > 0) + { + a1_msb = abs(xq[k]); + b1_msb = abs(xq[k + 1]); + + if (lev1 > 0) + { + a1_msb = a1_msb >> 1; + b1_msb = b1_msb >> 1; + + if (a1_msb == 0 && xq[k] != 0) + { + nbits_lsb++; + } + + if (b1_msb == 0 && xq[k + 1] != 0) + { + nbits_lsb++; + } + } + + bits = bits + (MIN(a1_msb, 1) << 11); + bits = bits + (MIN(b1_msb, 1) << 11); + } + + if (mode >= 0 && (abs(xq[k]) != 0 || abs(xq[k + 1]) != 0) && bits <= target * 2048) + { + lastnz2 = k + 2; + bits2 = bits; + } + + lev1 = lev1 - 1; + + if (lev1 <= 0) + { + t = 1 + (a + b) * (lev1 + 2); + } + else + { + t = 13 + lev1; + } + + c = (c & 15) * 16 + t; + } + + *nbits = (bits + 2047) >> 11; // Exactly same as ceil((LC3_FLOAT)*nbits / 2048.0); + + if (mode >= 0) + { + *nbits2 = (bits2 + 2047) >> 11; //ceil((LC3_FLOAT)*nbits2 / 2048.0); + } + else + { + *nbits2 = *nbits; + } + + if (mode > 0) + { + *nbits += nbits_lsb; + *nbits2 += nbits_lsb; + } + + /* Truncation of high-frequency coefficients */ + for (i = lastnz2; i <= lastnz; i++) + { + xq[i] = 0; + } + + /* Truncation of LSBs */ + if (mode > 0 && *nbits > target) + { + *lsbMode = 1; + } + else + { + *lsbMode = 0; + } + + *lastnzout = lastnz2; +} diff --git a/lib_lc3plus/reorder_bitstream.c b/lib_lc3plus/reorder_bitstream.c new file mode 100644 index 0000000000000000000000000000000000000000..118a05b6ef8ca8f04ae3f714e9e47f270fc2877e --- /dev/null +++ b/lib_lc3plus/reorder_bitstream.c @@ -0,0 +1,42 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.3 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + + +#include "options.h" +#include "wmc_auto.h" +#include "functions.h" + + +void processReorderBitstream_fl(LC3_UINT8* bytes, LC3_INT32 n_pccw, LC3_INT32 n_pc, LC3_INT32 b_left, LC3_INT32 len) +{ + LC3_UINT8 bytes_local[MAX_NBYTES2]; + LC3_INT32 i, block_bytes; + + assert(b_left > 0); + + memcpy(bytes_local, bytes, len * sizeof(LC3_UINT8)); + + if (n_pccw == 0) + { + return; + } + + block_bytes = ceil((LC3_FLOAT) n_pc / 2.0); + + for (i = 0; i < block_bytes; i++) + { + bytes[i] = bytes_local[b_left + i]; + } + + for (i = 0; i < b_left; i++) + { + bytes[block_bytes + i] = bytes_local[i]; + } +} + diff --git a/lib_lc3plus/resamp12k8.c b/lib_lc3plus/resamp12k8.c new file mode 100644 index 0000000000000000000000000000000000000000..295b6e7f29143c11db908ce0d9798c3174b0aa8b --- /dev/null +++ b/lib_lc3plus/resamp12k8.c @@ -0,0 +1,109 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.3 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + + +#include "options.h" +#include "wmc_auto.h" +#include "functions.h" + +void process_resamp12k8_fl(LC3_FLOAT x[], LC3_INT x_len, LC3_FLOAT mem_in[], LC3_INT mem_in_len, LC3_FLOAT mem_50[], LC3_FLOAT mem_out[], + LC3_INT mem_out_len, LC3_FLOAT y[], LC3_INT* y_len, LC3_INT fs_idx, LC3_INT frame_dms, LC3_INT fs) +{ + + + LC3_INT len_12k8, N12k8, i, k; + LC3_FLOAT mac, bufdown[128], buf[120 + MAX_LEN]; + LC3_INT32 index_int, index_frac, resamp_upfac, resamp_delay, resamp_off_int, resamp_off_frac; + LC3_FLOAT u_11, u_21, u_1, u_2; + const LC3_FLOAT *filter; + const LC3_FLOAT *filt_input, *filt_coeff; + + switch (frame_dms) + { + case 25: + len_12k8 = LEN_12K8 / 4; + break; + case 50: + len_12k8 = LEN_12K8 / 2; + break; +#ifdef CR8_G_ADD_75MS + case 75: + len_12k8 = (LEN_12K8 / 4) * 3; + break; +#endif + case 100: + len_12k8 = LEN_12K8; + break; + } + + *y_len = len_12k8; + N12k8 = x_len * 12800 / fs; + + /* Init Input Buffer */ + memmove(buf, mem_in, mem_in_len * sizeof(LC3_FLOAT)); + memmove(&buf[mem_in_len], x, x_len * sizeof(LC3_FLOAT)); + memmove(mem_in, &buf[x_len], mem_in_len * sizeof(LC3_FLOAT)); + + filter = lp_filter[fs_idx]; + + /* Upsampling & Low-pass Filtering & Downsampling */ + + index_int = 1; + index_frac = 0; + resamp_upfac = resamp_params[fs_idx][0]; + resamp_delay = resamp_params[fs_idx][1]; + resamp_off_int = resamp_params[fs_idx][2]; + resamp_off_frac = resamp_params[fs_idx][3]; + + k = 0; + for (i = 0; i < N12k8; i++) { + + filt_input = &buf[index_int]; + filt_coeff = &filter[index_frac * resamp_delay * 2]; + + mac = mac_loop(filt_input, filt_coeff, (2 * resamp_delay)); + + bufdown[k++] = mac; + + index_int = index_int + resamp_off_int; + index_frac = index_frac + resamp_off_frac; + + if ((resamp_upfac - index_frac) <= 0) + { + index_int = index_int + 1; + index_frac = index_frac - resamp_upfac; + } + } + + + /* 50Hz High-Pass */ + u_11 = mem_50[0]; + u_21 = mem_50[1]; + + for (i = 0; i < len_12k8; i++) { + LC3_FLOAT y1 = (highpass50_filt_b[0] * bufdown[i] + u_11); + u_1 = (highpass50_filt_b[1] * bufdown[i] + u_21) - highpass50_filt_a[1] * y1; + u_2 = highpass50_filt_b[2] * bufdown[i] - highpass50_filt_a[2] * y1; + u_11 = u_1; + u_21 = u_2; + bufdown[i] = (LC3_FLOAT)y1; + } + + mem_50[0] = (LC3_FLOAT)u_11; + mem_50[1] = (LC3_FLOAT)u_21; + + /* Output Buffer */ + memmove(buf, mem_out, mem_out_len * sizeof(LC3_FLOAT)); + + memmove(&buf[mem_out_len], bufdown, len_12k8 * sizeof(LC3_FLOAT)); + + memmove(y, buf, (*y_len + 1) * sizeof(LC3_FLOAT)); + + memmove(mem_out, &buf[N12k8], mem_out_len * sizeof(LC3_FLOAT)); +} diff --git a/lib_lc3plus/residual_coding.c b/lib_lc3plus/residual_coding.c new file mode 100644 index 0000000000000000000000000000000000000000..777b97d73a5f0ede5168a539c3eade6135a05815 --- /dev/null +++ b/lib_lc3plus/residual_coding.c @@ -0,0 +1,77 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.3 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + + +#include "options.h" +#include "wmc_auto.h" +#include "functions.h" + +void processResidualCoding_fl(LC3_FLOAT x[], LC3_INT xq[], LC3_FLOAT gain, LC3_INT L_spec, LC3_INT targetBits, LC3_INT nBits, uint8_t* resBits, LC3_INT* numResBits + , LC3_INT hrmode +) +{ + LC3_INT n = 0, m = 0, k = 0; + LC3_INT iter=0; + LC3_FLOAT offset; + LC3_INT iter_max = 1; + LC3_INT nz_idx[MAX_LEN]; + LC3_INT N_nz = 0, idx = 0; + + + memset(resBits, 0, MAX_RESBITS_LEN); + + m = targetBits - nBits + 4; + if (hrmode) + { + m += 10; + } + + assert(m <= MAX_RESBITS); + + offset = .25; + if (hrmode) + { + iter_max = EXT_RES_ITER_MAX; + + } + for (k = 0; k < L_spec; k ++) + { + if (xq[k]) + { + nz_idx[N_nz ++] = k; + } + } + while (iter < iter_max && n < m) + { + k = 0; + while (k < N_nz && n < m) + { + idx = nz_idx[k]; + + if (x[idx] >= (LC3_FLOAT)xq[idx] * gain) + { + resBits[n >> 3] |= 1 << (n & 7); + x[idx] -= gain * offset; + } + else + { + resBits[n >> 3] &= ~(1 << (n & 7)); + x[idx] += gain * offset; + } + + n++; + + k++; + } + iter ++; + offset *= .5; + } + + *numResBits = n; +} diff --git a/lib_lc3plus/residual_decoding.c b/lib_lc3plus/residual_decoding.c new file mode 100644 index 0000000000000000000000000000000000000000..90084c9811001398aabd6096644c1f848d72f0f9 --- /dev/null +++ b/lib_lc3plus/residual_decoding.c @@ -0,0 +1,98 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.3 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + + +#include "options.h" +#include "wmc_auto.h" +#include "functions.h" + +void processResidualDecoding_fl(LC3_INT* bitsRead, LC3_FLOAT x[], LC3_INT L_spec, uint8_t prm[], LC3_INT resQBits + , LC3_INT hrmode +) +{ + LC3_INT k = 0, n = 0; + LC3_FLOAT offset1 = 0, offset2 = 0; + LC3_FLOAT offset = 0; + LC3_INT nz_idx[MAX_LEN]; + LC3_INT N_nz = 0, idx = 0; + + LC3_INT iter = 0, iter_max = 1; + + if (hrmode) + { + iter_max = EXT_RES_ITER_MAX; + offset = offset1 = offset2 = 0.25; + } + else + { + offset1 = 0.1875; + offset2 = 0.3125; + } + + if (hrmode) + { + /* enumerat non-zero coefficients */ + for (k = 0; k < L_spec; k ++) + { + if (x[k]) + { + nz_idx[N_nz ++] = k; + } + } + /* apply residual corrections */ + while (n < resQBits && iter < iter_max) + { + for (k = 0; k < N_nz; k ++) + { + idx = nz_idx[k]; + + if ((prm[n >> 3] & 1 << (n & 7)) == 0) + { + x[idx] -= offset; + } + else + { + + x[idx] += offset; + } + if (++n >= resQBits) + { + break; + } + } + offset *= 0.5; + iter ++; + } + } + else + { + while (k < L_spec && n < resQBits) { + if (x[k] != 0) { + if ((prm[n >> 3] & 1 << (n & 7)) == 0) + { + if (x[k] > 0) { + x[k] -= offset1; + } else { + x[k] -= offset2; + } + } else { + if (x[k] > 0) { + x[k] += offset2; + } else { + x[k] += offset1; + } + } + n++; + } + + k++; + } + } + *bitsRead = n; +} diff --git a/lib_lc3plus/setup_com_lc3.c b/lib_lc3plus/setup_com_lc3.c new file mode 100644 index 0000000000000000000000000000000000000000..33574f577ec125da3fbfc565577d0045322fda8d --- /dev/null +++ b/lib_lc3plus/setup_com_lc3.c @@ -0,0 +1,31 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.3 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + +#include "options.h" +#include "wmc_auto.h" +#include "functions.h" + +LC3_FLOAT array_max_abs(LC3_FLOAT *in, LC3_INT32 len) +{ + LC3_FLOAT max; + LC3_INT32 i; + + max = LC3_FABS(in[0]); + + for (i = 0; i < len; i++) + { + if (LC3_FABS(in[i]) > LC3_FABS(max)) + { + max = LC3_FABS(in[i]); + } + } + + return max; +} + diff --git a/lib_lc3plus/setup_dec_lc3.c b/lib_lc3plus/setup_dec_lc3.c new file mode 100644 index 0000000000000000000000000000000000000000..1a6e4e7cc38d9a07488b4fc1b22dc3ca5ad540b6 --- /dev/null +++ b/lib_lc3plus/setup_dec_lc3.c @@ -0,0 +1,542 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.3 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + + +#include "options.h" +#include "wmc_auto.h" +#include "setup_dec_lc3.h" +#include "functions.h" +#include +#include + +/* if decoder is null only size is reported */ +# include "fft/iis_fft.h" + +int alloc_decoder(LC3PLUS_Dec* decoder, int samplerate, int channels) +{ + int ch = 0; + size_t size = sizeof(LC3PLUS_Dec); + size_t frame_len = DYN_MAX_LEN_EXT(samplerate); + + void *PlcAdvSetup = NULL; + LC3_FLOAT *pcmbufHist, *harmonicBuf; + LC3_FLOAT *PhECU_oold_grp_shape, *PhECU_old_grp_shape; + LC3_FLOAT *PhECU_xfp; + Complex *PhECU_X_sav_m; + LC3_INT32 *PhECU_plocs; + LC3_FLOAT *PhECU_f0est, *PhECU_mag_chg_1st, *PhECU_Xavg; + LC3_FLOAT *sine_table1_phecu, *sine_table2_phecu; + HANDLE_IIS_FFT handle_fft_phaseecu; + HANDLE_IIS_FFT handle_ifft_phaseecu; + LC3_FLOAT *q_old_res; + +#ifdef CR8_A_PLC_FADEOUT_TUNING + LC3_INT32 * plc_longterm_advc_tdc = NULL, *plc_longterm_advc_ns = NULL; + LC3_INT16 longterm_analysis_counter_max = 0, longterm_analysis_counter_max_bytebuffer = 0; +#endif + + for (ch = 0; ch < channels; ch++) { + DecSetup* setup = balloc(decoder, &size, sizeof(DecSetup)); + + size_t max_pitch = ceilf(228.0 * CODEC_FS(samplerate) / 12800.0); + size_t pcm_plc_len = max_pitch + frame_len; + pcmbufHist = balloc(decoder, &size, sizeof(LC3_FLOAT) * pcm_plc_len); + harmonicBuf = balloc(decoder, &size, sizeof(LC3_FLOAT) * max_pitch); + PlcAdvSetup = balloc(decoder, &size, sizeof(*setup->PlcAdvSetup)); + PhECU_oold_grp_shape = balloc(decoder, &size, sizeof(LC3_FLOAT) *MAX_LGW); /* BASOP Word16 PhECU_oold_grp_shape_fx[MAX_LGW]; */ + PhECU_old_grp_shape = balloc(decoder, &size, sizeof(LC3_FLOAT) *MAX_LGW); /* BASOP Word16 PhECU_old_grp_shape_fx[MAX_LGW] ; */ + PhECU_xfp = balloc(decoder, &size, sizeof(LC3_FLOAT) *(frame_len * 16 / 10)); + PhECU_X_sav_m = balloc(decoder, &size, sizeof(Complex) *(((frame_len * 16 / 10) / 2) + 1));/*MAX_PLC_LMSPEC*/ + PhECU_plocs = balloc(decoder, &size, sizeof(LC3_INT32) * (((frame_len * 16 / 10) / 4) + 1 + 1)); /* BASOP Word16 *PhECU_plocs; */ + + handle_fft_phaseecu = balloc(decoder, &size, sizeof(IIS_FFT) * 1); + handle_ifft_phaseecu = balloc(decoder, &size, sizeof(IIS_FFT) * 1); + PhECU_f0est = balloc(decoder, &size, sizeof(LC3_FLOAT) * (((frame_len * 16 / 10) / 4) + 1)); /*BASOP Word32 *PhECU_f0est;*/ + PhECU_mag_chg_1st = balloc(decoder, &size, sizeof(LC3_FLOAT) *MAX_LGW); /* BASOP Word16 PhECU_mag_chg_1st[MAX_LGW];*/ + PhECU_Xavg = balloc(decoder, &size, sizeof(LC3_FLOAT) * MAX_LGW); /* BASOP Word16 PhECU_Xavg[MAX_LGW] ; */ + + sine_table1_phecu = balloc(decoder, &size, sizeof(LC3_FLOAT) * (((CODEC_FS(samplerate) * 16) / 1000) / 2 + 1)); + sine_table2_phecu = balloc(decoder, &size, sizeof(LC3_FLOAT) * (((CODEC_FS(samplerate) * 16) / 1000) / 2 + 1)); + +#ifdef CR8_A_PLC_FADEOUT_TUNING + longterm_analysis_counter_max = plc_fadeout_param_maxlen[0]; + longterm_analysis_counter_max_bytebuffer = plc_fadeout_param_maxbytes[0]; + + + plc_longterm_advc_tdc = balloc(decoder, &size, sizeof(LC3_INT32) * longterm_analysis_counter_max_bytebuffer); + plc_longterm_advc_ns = balloc(decoder, &size, sizeof(LC3_INT32) * longterm_analysis_counter_max_bytebuffer); +#endif + + q_old_res = balloc(decoder, &size, sizeof(LC3_FLOAT) * frame_len); + + if (decoder) { + decoder->channel_setup[ch] = setup; + + setup->PlcAdvSetup = PlcAdvSetup; + + setup->PlcAdvSetup->pcmbufHist = pcmbufHist; + setup->PlcAdvSetup->PlcTdcSetup.harmonicBuf = harmonicBuf; + setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_oold_grp_shape = PhECU_oold_grp_shape; + setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_old_grp_shape = PhECU_old_grp_shape; + setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_xfp = PhECU_xfp; + setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_X_sav_m = PhECU_X_sav_m; + setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_plocs = PhECU_plocs; + setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_f0est = PhECU_f0est; + setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_mag_chg_1st = PhECU_mag_chg_1st; + setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_Xavg = PhECU_Xavg; + setup->PlcAdvSetup->PlcPhEcuSetup.handle_fft_phaseecu = handle_fft_phaseecu; + setup->PlcAdvSetup->PlcPhEcuSetup.handle_ifft_phaseecu = handle_ifft_phaseecu; + + setup->PlcAdvSetup->PlcPhEcuSetup.handle_fft_phaseecu->sine_table = sine_table1_phecu; + setup->PlcAdvSetup->PlcPhEcuSetup.handle_ifft_phaseecu->sine_table = sine_table2_phecu; + +#ifdef CR8_A_PLC_FADEOUT_TUNING + setup->PlcAdvSetup->longterm_analysis_counter_max = longterm_analysis_counter_max; + setup->PlcAdvSetup->longterm_analysis_counter_max_bytebuffer = longterm_analysis_counter_max_bytebuffer; + + setup->PlcAdvSetup->plc_longterm_advc_tdc = plc_longterm_advc_tdc; + setup->PlcAdvSetup->plc_longterm_advc_ns = plc_longterm_advc_ns; +#endif + + setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_Lprot = (CODEC_FS(samplerate) * 16) / 1000; + real_fft_init(&(setup->PlcAdvSetup->PlcPhEcuSetup.PhEcu_Fft), setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_Lprot, &(setup->PlcAdvSetup->PlcPhEcuSetup.handle_fft_phaseecu)); + real_ifft_init(&(setup->PlcAdvSetup->PlcPhEcuSetup.PhEcu_Ifft), setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_Lprot, &(setup->PlcAdvSetup->PlcPhEcuSetup.handle_ifft_phaseecu)); + setup->statePC.q_old_res = q_old_res; + } + } + + return (int)size; +} + +LC3PLUS_Error FillDecSetup(LC3PLUS_Dec* decoder, int samplerate, int channels, LC3PLUS_PlcMode plc_mode + , int hrmode +) +{ + memset(decoder, 0, lc3plus_dec_get_size(samplerate, channels)); + alloc_decoder(decoder, samplerate, channels); + + decoder->fs = CODEC_FS(samplerate); + decoder->fs_out = samplerate; + decoder->fs_idx = FS2FS_IDX(decoder->fs); + decoder->plcMeth = plc_mode; + + decoder->hrmode = hrmode != 0; + +#ifndef CR8_A_PLC_FADEOUT_TUNING + if (decoder->fs_idx > 4) { + decoder->fs_idx = 5; + } +#endif + decoder->channels = channels; + decoder->frame_ms = 10; + decoder->frame_dms = 100; + decoder->BW_cutoff_bits = BW_cutoff_bits_all[decoder->fs_idx]; + + if (decoder->fs == 8000) { + decoder->tilt = 14; + } else if (decoder->fs == 16000) { + decoder->tilt = 18; + } else if (decoder->fs == 24000) { + decoder->tilt = 22; + } else if (decoder->fs == 32000) { + decoder->tilt = 26; + } else if (decoder->fs == 48000) { + decoder->tilt = 30; + } + else if (decoder->fs == 96000) { + decoder->tilt = 34; + } + + set_dec_frame_params(decoder); + + lc3plus_dec_set_ep_enabled(decoder, 0); + + return LC3PLUS_OK; +} + +/* set frame config params */ +void set_dec_frame_params(LC3PLUS_Dec* decoder) +{ + int ch = 0; + + if (decoder->fs_idx == 5) + { + decoder->hrmode = 1; + } + + decoder->frame_length = ceil(decoder->fs * 10 / 1000); /* fs * 0.01*2^6 */ + if (decoder->hrmode == 1) + { + decoder->yLen = decoder->frame_length; + } + else + { + decoder->yLen = MIN(MAX_BW, decoder->frame_length); + } + + decoder->bands_number = 64; + if (decoder->frame_ms == 2.5) + { + decoder->frame_length = decoder->frame_length >> 2; + decoder->yLen /= 4; + if (decoder->hrmode) + { + decoder->bands_number = bands_number_2_5ms_HR[decoder->fs_idx]; + } + else + { + decoder->bands_number = bands_number_2_5ms[decoder->fs_idx]; + } + } + if (decoder->frame_ms == 5) + { + decoder->frame_length = decoder->frame_length >> 1; + decoder->yLen /= 2; + decoder->bands_number = bands_number_5ms[decoder->fs_idx]; + } +#ifdef CR8_G_ADD_75MS + if (decoder->frame_ms == 7.5) + { + decoder->frame_length = (decoder->frame_length >> 2) * 3; + decoder->yLen = (decoder->yLen / 4) * 3; + if (decoder->hrmode) + { + decoder->bands_number = bands_number_7_5ms_HR[decoder->fs_idx]; + } + else + { + decoder->bands_number = bands_number_7_5ms[decoder->fs_idx]; + } + } +#endif + + if (decoder->hrmode) + { + decoder->BW_cutoff_bits = 0; + } + else + { + decoder->BW_cutoff_bits = BW_cutoff_bits_all[decoder->fs_idx]; + } + + if (decoder->frame_ms == 10) + { + if (decoder->hrmode) + { + decoder->bands_offset = ACC_COEFF_PER_BAND_HR[decoder->fs_idx]; + } + else + { + decoder->bands_offset = ACC_COEFF_PER_BAND[decoder->fs_idx]; + } + decoder->cutoffBins = BW_cutoff_bin_all; + } + else if (decoder->frame_ms == 2.5) + { + if (decoder->hrmode) + { + decoder->bands_offset = ACC_COEFF_PER_BAND_2_5ms_HR[decoder->fs_idx]; + } + else + { + decoder->bands_offset = ACC_COEFF_PER_BAND_2_5ms[decoder->fs_idx]; + } + decoder->cutoffBins = BW_cutoff_bin_all_2_5ms; + } + else if (decoder->frame_ms == 5) + { + if (decoder->hrmode) + { + decoder->bands_offset = ACC_COEFF_PER_BAND_5ms_HR[decoder->fs_idx]; + } + else + { + decoder->bands_offset = ACC_COEFF_PER_BAND_5ms[decoder->fs_idx]; + } + decoder->cutoffBins = BW_cutoff_bin_all_5ms; + } +#ifdef CR8_G_ADD_75MS + else if (decoder->frame_ms == 7.5) + { + if (decoder->hrmode) + { + decoder->bands_offset = ACC_COEFF_PER_BAND_7_5ms_HR[decoder->fs_idx]; + } + else + { + decoder->bands_offset = ACC_COEFF_PER_BAND_7_5ms[decoder->fs_idx]; + } + decoder->cutoffBins = BW_cutoff_bin_all_7_5ms; + } +#endif + + decoder->n_bandsPLC = MIN(decoder->frame_length, 80); + + if (decoder->frame_ms == 10) + { + decoder->bands_offsetPLC = ACC_COEFF_PER_BAND_PLC[decoder->fs_idx]; + } + else if (decoder->frame_ms == 5) + { + decoder->bands_offsetPLC = ACC_COEFF_PER_BAND_PLC_5ms[decoder->fs_idx]; + + if (decoder->fs == 24000) + { + decoder->n_bandsPLC = 40; + } + } + else if (decoder->frame_ms == 2.5) + { + decoder->bands_offsetPLC = ACC_COEFF_PER_BAND_PLC_2_5ms[decoder->fs_idx]; + + if (decoder->fs == 48000) + { + decoder->n_bandsPLC = 60; + } + } +#ifdef CR8_G_ADD_75MS + else if (decoder->frame_ms == 7.5) + { + decoder->bands_offsetPLC = ACC_COEFF_PER_BAND_PLC_7_5ms[decoder->fs_idx]; + +#ifdef FIX_1082_INSTRUM_FAILED_LC3PLUS + if (decoder->fs != 32000 && decoder->fs != 96000) +#else + if (decoder->fs != 32000 && decoder->fs != 96000) + if (decoder->fs != 32000) +#endif + { + decoder->n_bandsPLC = 60; + } + } +#endif + + assert(decoder->bands_offsetPLC); + + if (decoder->frame_ms == 10) { + decoder->imdct_win = MDCT_WINS_10ms[decoder->hrmode][decoder->fs_idx]; + decoder->imdct_laZeros = MDCT_la_zeroes[decoder->fs_idx]; + decoder->imdct_winLen = MDCT_WINDOWS_LENGTHS_10ms[decoder->fs_idx]; + } + else if (decoder->frame_ms == 2.5) { + decoder->imdct_win = MDCT_WINS_2_5ms[decoder->hrmode][decoder->fs_idx]; + decoder->imdct_laZeros = MDCT_la_zeroes_2_5ms[decoder->fs_idx]; + decoder->imdct_winLen = MDCT_WINDOWS_LENGTHS_2_5ms[decoder->fs_idx]; + } + else if (decoder->frame_ms == 5) { + decoder->imdct_win = MDCT_WINS_5ms[decoder->hrmode][decoder->fs_idx]; + decoder->imdct_laZeros = MDCT_la_zeroes_5ms[decoder->fs_idx]; + decoder->imdct_winLen = MDCT_WINDOWS_LENGTHS_5ms[decoder->fs_idx]; + } +#ifdef CR8_G_ADD_75MS + else if (decoder->frame_ms == 7.5) { + decoder->imdct_win = MDCT_WINS_7_5ms[decoder->hrmode][decoder->fs_idx]; + decoder->imdct_laZeros = MDCT_la_zeroes_7_5ms[decoder->fs_idx]; + decoder->imdct_winLen = MDCT_WINDOWS_LENGTHS_7_5ms[decoder->fs_idx]; + } +#endif + + decoder->la_zeroes = decoder->imdct_laZeros; + + decoder->imdct_memLen = decoder->frame_length - decoder->imdct_laZeros; + + for (ch = 0; ch < decoder->channels; ch++) { + DecSetup* setup = decoder->channel_setup[ch]; + + setup->ltpf_mem_beta_idx = -1; + + setup->statePC.seed = 24607; + + if (decoder) { + /* Init DCT4 structs */ + if (setup->dct4structImdct.length != 0) { + dct4_free(&setup->dct4structImdct); + dct4_init(&setup->dct4structImdct, decoder->frame_length); + } else { + dct4_init(&setup->dct4structImdct, decoder->frame_length); + } + + setup->PlcNsSetup.cum_alpha = 1; + setup->PlcNsSetup.seed = 24607; + setup->alpha = 1; + if (setup->PlcAdvSetup) + { + LC3_INT32 pitch_max = 0, pitch_ana_len = 0, tdc_synt_len = 0; + pitch_max = ceil(228.0 * (LC3_FLOAT) decoder->fs / 12800.0); + pitch_ana_len = pitch_max + decoder->frame_length * (LC3_FLOAT) 100 / decoder->frame_dms; + tdc_synt_len = 16 + 1 + pitch_max + ceil(decoder->frame_length / 2); + setup->PlcAdvSetup->max_len_pcm_plc = MAX(pitch_ana_len, tdc_synt_len); + setup->PlcAdvSetup->PlcTdcSetup.preemphFac = plc_preemph_fac[decoder->fs_idx]; + setup->PlcAdvSetup->PlcTdcSetup.seed = 24607; + setup->PlcAdvSetup->PlcTdcSetup.lpcorder = 16; + + if (decoder->fs_idx == 0 && decoder->frame_dms == 25) + { + setup->PlcAdvSetup->PlcTdcSetup.lpcorder = 8; + } + + setup->PlcAdvSetup->stabFac = 1; + setup->PlcAdvSetup->cum_fading_fast = 1; + setup->PlcAdvSetup->cum_fading_slow = 1; + setup->PlcAdvSetup->cum_fflcAtten = 1; + +#ifdef CR8_A_PLC_FADEOUT_TUNING + setup->PlcAdvSetup->longterm_analysis_counter_max = plc_fadeout_param_maxlen[(decoder->frame_dms / 25) - 1]; + setup->PlcAdvSetup->longterm_analysis_counter_max_bytebuffer = plc_fadeout_param_maxbytes[(decoder->frame_dms / 25) - 1]; +#endif + + if (decoder->fs_idx <= 4 && decoder->frame_dms == 100) + { + setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_Lprot = (decoder->fs * 16) / 1000; /* 16 ms of samples at fs*/ + + setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_f0hzLtpBin = 0; + setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_norm_corr = 0; + + set_vec(PHECU_GRP_SHAPE_INIT, setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_oold_grp_shape, MAX_LGW); + set_vec(PHECU_GRP_SHAPE_INIT, setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_old_grp_shape, MAX_LGW); + + setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_L_oold_xfp_w_E = (LC3_FLOAT)PHECU_LTOT_MIN_MAN * LC3_POW(2.0, PHECU_LTOT_MIN_EXP - 31); + setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_L_old_xfp_w_E = (LC3_FLOAT)PHECU_LTOT_MIN_MAN * LC3_POW(2.0, PHECU_LTOT_MIN_EXP - 31); + + /* CFL uses separate buffers for pcmHist, xfp and Xsav and q_d , BASOP uses an optimized joint buffer*/ + zero_float(setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_xfp, setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_Lprot); + zero_cmplx(setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_X_sav_m, (setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_Lprot/2 + 1)); + + set_vec(POS_ONE_Q15, setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_mag_chg_1st, MAX_LGW); + + setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_beta_mute = (16384.0/32768.0); + setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_seed = 21845; + + assert(decoder->frame_dms == 100); + setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_LDWIN_OLAP = (decoder->frame_length / 4 ); /* 2.5 ms for regular 10 ms MDCT */ + + setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_t_adv = ( + decoder->frame_length + + setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_Lprot + + setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_LDWIN_OLAP )/ 2; + } + setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_short_flag_prev = 0; /* fullband transient */ + setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_num_plocs = 0; +#ifdef CR8_A_PLC_FADEOUT_TUNING + setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_nonpure_tone_flag = -1; /* nonpure tone flag, -1==new calc., 0==pure, 1==nonpure */ +#endif + } + } + } +} + +LC3PLUS_Error update_dec_bitrate(LC3PLUS_Dec* decoder, int ch, int nBytes) +{ + int totalBits = 0, bitsTmp = 0, channel_bytes = 0, maxBytes = 0, minBytes = 0; + DecSetup* setup; + + if (decoder->hrmode) + { + switch (decoder->frame_dms) + { + case 25: + maxBytes = 210; + minBytes = MIN_NBYTES; + break; + case 50: + maxBytes = 375; + minBytes = MIN_NBYTES; + break; +#ifdef CR8_G_ADD_75MS + case 75: + maxBytes = 625; + minBytes = MIN_NBYTES; + break; +#endif + case 100: + maxBytes = 625; + minBytes = MIN_NBYTES; + break; + default: + return LC3PLUS_HRMODE_ERROR; + } + } + else + { + minBytes = MIN_NBYTES; + maxBytes = MAX_NBYTES_100; // for backward compatibility, MAX_NBYTES_100 is used for all frame lengths + } + + channel_bytes = nBytes; + + setup = decoder->channel_setup[ch]; + + if (channel_bytes < minBytes || channel_bytes > maxBytes) + { + return LC3PLUS_NUMBYTES_ERROR; + } + + setup->targetBytes = channel_bytes; + setup->total_bits = setup->targetBytes << 3; + setup->enable_lpc_weighting = (setup->total_bits < 480); + setup->quantizedGainOff = + -(MIN(115, setup->total_bits / (10 * (decoder->fs_idx + 1))) + 105 + 5 * (decoder->fs_idx + 1)); + + if (decoder->hrmode && decoder->fs_idx == 5) + { + setup->quantizedGainOff = MAX(setup->quantizedGainOff, -181); + } + + totalBits = setup->total_bits; + + if (decoder->frame_ms == 2.5) { + setup->enable_lpc_weighting = setup->total_bits < 120; + totalBits = setup->total_bits * 4.0 * (1.0 - 0.4); + } + if (decoder->frame_ms == 5) { + setup->enable_lpc_weighting = (setup->total_bits < 240); + totalBits = setup->total_bits * 2 - 160; + } +#ifdef CR8_G_ADD_75MS + if (decoder->frame_ms == 7.5) { + setup->enable_lpc_weighting = (setup->total_bits < 360); + totalBits = round(setup->total_bits * 10 / 7.5); + } +#endif + + if (decoder->frame_length > 40 * ((LC3_FLOAT) (decoder->frame_dms) / 10.0)) { + setup->N_red_tns = 40 * ((LC3_FLOAT) (decoder->frame_dms) / 10.0); + setup->fs_red_tns = 40000; + } else { + setup->N_red_tns = decoder->frame_length; + setup->fs_red_tns = decoder->fs; + } + + bitsTmp = totalBits; + + if (bitsTmp < 400 + (decoder->fs_idx - 1) * 80) { + setup->ltpf_conf_beta = 0.4; + setup->ltpf_conf_beta_idx = 0; + } else if (bitsTmp < 480 + (decoder->fs_idx - 1) * 80) { + setup->ltpf_conf_beta = 0.35; + setup->ltpf_conf_beta_idx = 1; + } else if (bitsTmp < 560 + (decoder->fs_idx - 1) * 80) { + setup->ltpf_conf_beta = 0.3; + setup->ltpf_conf_beta_idx = 2; + } else if (bitsTmp < 640 + (decoder->fs_idx - 1) * 80) { + setup->ltpf_conf_beta = 0.25; + setup->ltpf_conf_beta_idx = 3; + } else { + setup->ltpf_conf_beta = 0; + setup->ltpf_conf_beta_idx = -1; + } + + /* No LTPF in hrmode */ + if (decoder->hrmode == 1) { + setup->ltpf_conf_beta = 0; + setup->ltpf_conf_beta_idx = -1; + } + + return LC3PLUS_OK; +} diff --git a/lib_lc3plus/setup_dec_lc3.h b/lib_lc3plus/setup_dec_lc3.h new file mode 100644 index 0000000000000000000000000000000000000000..17201a4a931a40bc5ac55b39b82bd9a490bec8dd --- /dev/null +++ b/lib_lc3plus/setup_dec_lc3.h @@ -0,0 +1,117 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.3 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + + +#ifndef SETUP_DEC_LC3_FL_H +#define SETUP_DEC_LC3_FL_H + +#include "options.h" +#include "wmc_auto.h" +#include "constants.h" + +/* Channel state and bitrate-derived values go in this struct */ +typedef struct { + LC3_INT* stDec_ola_mem_fx; /* MDCT_MEM_LEN_MAX */ + LC3_INT total_bits; + LC3_INT enable_lpc_weighting; + LC3_INT targetBytes; + LC3_INT quantizedGainOff; + LC3_INT ltpf_param[3]; + LC3_INT ltpf_param_mem[3]; + LC3_INT ltpf_mem_pitch; + LC3_INT ltpf_mem_active; + LC3_INT ltpf_mem_pitch_fr; + LC3_INT ltpf_mem_beta_idx; + LC3_INT ltpf_conf_beta_idx; + LC3_INT spec_inv_idx; + LC3_INT concealMethod; + LC3_INT last_size; + LC3_INT BW_cutoff_idx_nf; + LC3_INT prev_BW_cutoff_idx_nf; + LC3_INT fs_red_tns; + LC3_INT N_red_tns; + LC3_INT scf_idx[SCF_MAX_PARAM]; + uint8_t resBits[MAX_RESBITS_LEN]; + LC3_INT tns_idx[TNS_NUMFILTERS_MAX * MAXLAG]; + + LC3_FLOAT prev_fac_ns; + LC3_FLOAT ltpf_mem_x[3 * MAX_LEN]; + LC3_FLOAT ltpf_mem_y[3 * MAX_LEN]; + LC3_FLOAT ltpf_mem_gain; + LC3_FLOAT ltpf_conf_beta; + LC3_FLOAT sqQdec_fl[MAX_LEN]; + LC3_FLOAT scf_q[M]; + LC3_FLOAT int_scf[MAX_BANDS_NUMBER]; + LC3_FLOAT x_fl[MAX_LEN]; + LC3_FLOAT imdct_mem[MAX_LEN]; + LC3_FLOAT alpha; +#ifdef CR9_N_SHORT_FADE_FOR_UNSTABLE_PITCH + LC3_FLOAT rel_pitch_change; +#endif + + Dct4 dct4structImdct; + + PlcSetup PlcSetup; + PlcNsSetup PlcNsSetup; + + pcState statePC; + PlcAdvSetup* PlcAdvSetup; +} DecSetup; + +/* Constants and sampling rate derived values go in this struct */ +struct LC3PLUS_Dec { + DecSetup* channel_setup[MAX_CHANNELS]; + const LC3_INT* W_fx; + const LC3_INT* bands_offset; + const LC3_INT* cutoffBins; + + LC3_INT fs; /* sampling rate, 44.1 maps to 48 */ + LC3_INT fs_out; /* output sampling rate */ + LC3_INT fs_idx; /* sampling rate index */ + LC3_INT frame_length; /* sampling rate index */ + LC3_INT channels; /* number of channels */ + LC3_FLOAT frame_ms; /* frame length in ms (wrong for 44.1) */ + LC3_INT frame_dms; /* frame length in ms * 10 (wrong for 44.1) */ + LC3_INT last_size; /* size of last frame, without error protection */ + LC3_INT ep_enabled; /* error protection enabled */ + LC3_INT error_report; /* corrected errors in last frame or -1 on error */ + + LC3_INT imdct_memLen; + LC3_INT imdct_winLen; + LC3_INT imdct_laZeros; + const LC3_FLOAT* imdct_win; + + LC3_INT yLen; + LC3_INT W_size; + LC3_INT la_zeroes; + LC3_INT bands_number; + LC3_INT ltpf_mem_x_len; + LC3_INT ltpf_mem_y_len; + LC3_INT BW_cutoff_bits; + LC3_INT tilt; + + LC3_INT hrmode; + LC3_INT specflip; + + const LC3_INT* bands_offsetPLC; + LC3_INT n_bandsPLC; + + LC3_INT32 rframe; + int plcMeth; /* PLC method for all channels */ + LC3_INT16 n_pccw; + LC3_INT16 be_bp_left; + LC3_INT16 be_bp_right; + LC3_INT16 n_pc; + LC3_INT16 m_fec; + int epmr; + LC3_INT16 combined_channel_coding; + int last_error; +}; + +#endif diff --git a/lib_lc3plus/setup_enc_lc3.c b/lib_lc3plus/setup_enc_lc3.c new file mode 100644 index 0000000000000000000000000000000000000000..e991c50f4677f68f84e084307ab35d13f87abd3c --- /dev/null +++ b/lib_lc3plus/setup_enc_lc3.c @@ -0,0 +1,633 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.3 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + + +#include "options.h" +#include "wmc_auto.h" +#include "setup_enc_lc3.h" +#include "functions.h" +#include + +/* if encoder is null only size is reported */ +int alloc_encoder(LC3PLUS_Enc* encoder, int channels) +{ + int ch = 0; + size_t size = sizeof(LC3PLUS_Enc); + + for (ch = 0; ch < channels; ch++) { + EncSetup* setup = balloc(encoder, &size, sizeof(EncSetup)); + if (encoder) { + encoder->channel_setup[ch] = setup; + } + } + + return (int)size; +} + +LC3PLUS_Error FillEncSetup(LC3PLUS_Enc* encoder, int samplerate, int channels + , int hrmode + , int32_t lfe_channel_array[] +) +{ + int ch = 0; + memset(encoder, 0, lc3plus_enc_get_size(samplerate, channels)); + alloc_encoder(encoder, channels); + + encoder->fs = CODEC_FS(samplerate); + encoder->fs_in = samplerate; + encoder->fs_idx = FS2FS_IDX(encoder->fs); + encoder->frame_dms = 100; + +#ifndef CR8_A_PLC_FADEOUT_TUNING + if (encoder->fs_idx > 4) { + encoder->fs_idx = 5; + } +#endif + + encoder->hrmode = hrmode != 0; + + encoder->channels = channels; + encoder->frame_ms = 10; + encoder->envelope_bits = 38; + encoder->global_gain_bits = 8; + encoder->noise_fac_bits = 3; + encoder->BW_cutoff_bits = BW_cutoff_bits_all[encoder->fs_idx]; + + encoder->r12k8_mem_in_len = 2 * 8 * encoder->fs / 12800; + encoder->r12k8_mem_out_len = 24; + + for (ch = 0; ch < encoder->channels; ch++) + { + encoder->channel_setup[ch]->lfe = lfe_channel_array[ch] != 0; + } + + encoder->bw_ctrl_active = 0; + encoder->bandwidth = encoder->fs / 2; + encoder->bandwidth_preset = encoder->fs / 2; + + + if (encoder->fs == 8000) { + encoder->tilt = 14; + } else if (encoder->fs == 16000) { + encoder->tilt = 18; + } else if (encoder->fs == 24000) { + encoder->tilt = 22; + } else if (encoder->fs == 32000) { + encoder->tilt = 26; + } else if (encoder->fs == 48000) { + encoder->tilt = 30; + } + else if (encoder->fs == 96000) { + encoder->tilt = 34; + } + + set_enc_frame_params(encoder); + return LC3PLUS_OK; +} + +/* set frame config params */ +void set_enc_frame_params(LC3PLUS_Enc* encoder) +{ + int ch = 0; + EncSetup* setup; + + encoder->frame_length = ceil(encoder->fs * 10 / 1000); /* fs * 0.01*2^6 */ + if (encoder->hrmode == 1) + { + encoder->yLen = encoder->frame_length; + } + else + { + encoder->yLen = MIN(MAX_BW, encoder->frame_length); + encoder->sns_damping = 0.85; + } + + encoder->stEnc_mdct_mem_len = encoder->frame_length - encoder->la_zeroes; + encoder->bands_number = 64; + encoder->nSubdivisions = 3; + encoder->near_nyquist_index = encoder->bands_number - 2; + encoder->near_nyquist_flag = 0; + encoder->ltpf_mem_in_len = LTPF_MEMIN_LEN; + + if (encoder->fs_idx == 5) + { + encoder->hrmode = 1; + } + + if (encoder->hrmode) + { + encoder->BW_cutoff_bits = 0; + } + else + { + encoder->BW_cutoff_bits = BW_cutoff_bits_all[encoder->fs_idx]; + } + + if (encoder->frame_ms == 10) { + encoder->la_zeroes = MDCT_la_zeroes[encoder->fs_idx]; + if (encoder->hrmode) + { + encoder->bands_offset = ACC_COEFF_PER_BAND_HR[encoder->fs_idx]; + } + else + { + encoder->bands_offset = ACC_COEFF_PER_BAND[encoder->fs_idx]; + } + encoder->cutoffBins = BW_cutoff_bin_all; + + encoder->attdec_nblocks = 4; + encoder->attdec_damping = 0.5; + encoder->attdec_hangover_thresh = 2; + } +#ifdef CR8_G_ADD_75MS + else if (encoder->frame_ms == 7.5) { + if (encoder->hrmode) + { + encoder->bands_offset = ACC_COEFF_PER_BAND_7_5ms_HR[encoder->fs_idx]; + } + else + { + encoder->bands_offset = ACC_COEFF_PER_BAND_7_5ms[encoder->fs_idx]; + } + encoder->la_zeroes = MDCT_la_zeroes_7_5ms[encoder->fs_idx]; + encoder->cutoffBins = BW_cutoff_bin_all_7_5ms; + encoder->attdec_nblocks = 3; + encoder->attdec_damping = 0.3; + encoder->attdec_hangover_thresh = 1; + + encoder->frame_length = (encoder->frame_length >> 2) * 3; + encoder->yLen = (encoder->yLen >> 2) * 3; + + encoder->stEnc_mdct_mem_len = encoder->frame_length - encoder->la_zeroes; + if (encoder->hrmode) + { + encoder->bands_number = bands_number_7_5ms_HR[encoder->fs_idx]; + } + else + { + encoder->bands_number = bands_number_7_5ms[encoder->fs_idx]; + } + encoder->nSubdivisions = 3; + encoder->near_nyquist_index = encoder->bands_number - 4; + encoder->r12k8_mem_out_len = ceil(2.0 * ((LC3_FLOAT) encoder->frame_length / 2.0 - (LC3_FLOAT) encoder->la_zeroes) * 12800.0 / (LC3_FLOAT) encoder->fs - 8.0); + } +#endif + else if (encoder->frame_ms == 5) { + encoder->frame_length = encoder->frame_length >> 1; + encoder->yLen /= 2; + encoder->stEnc_mdct_mem_len = encoder->frame_length - encoder->la_zeroes; + encoder->bands_number = bands_number_5ms[encoder->fs_idx]; + encoder->nSubdivisions = 2; + encoder->near_nyquist_index = encoder->bands_number - 3; + encoder->la_zeroes = MDCT_la_zeroes_5ms[encoder->fs_idx]; + if (encoder->hrmode) + { + encoder->bands_offset = ACC_COEFF_PER_BAND_5ms_HR[encoder->fs_idx]; + } + else + { + encoder->bands_offset = ACC_COEFF_PER_BAND_5ms[encoder->fs_idx]; + } + encoder->cutoffBins = BW_cutoff_bin_all_5ms; + } + else if (encoder->frame_ms == 2.5) { + encoder->la_zeroes = MDCT_la_zeroes_2_5ms[encoder->fs_idx]; + if (encoder->hrmode) + { + encoder->bands_offset = ACC_COEFF_PER_BAND_2_5ms_HR[encoder->fs_idx]; + } + else + { + encoder->bands_offset = ACC_COEFF_PER_BAND_2_5ms[encoder->fs_idx]; + } + encoder->cutoffBins = BW_cutoff_bin_all_2_5ms; + encoder->frame_length = encoder->frame_length >> 2; + encoder->yLen /= 4; + encoder->stEnc_mdct_mem_len = encoder->frame_length - encoder->la_zeroes; + if (encoder->hrmode) + { + encoder->bands_number = bands_number_2_5ms_HR[encoder->fs_idx]; + } + else + { + encoder->bands_number = bands_number_2_5ms[encoder->fs_idx]; + } + + encoder->nSubdivisions = 2; + encoder->near_nyquist_index = encoder->bands_number - 2; + encoder->ltpf_mem_in_len = LTPF_MEMIN_LEN + (LEN_12K8 >> 2); + } + + for (ch = 0; ch < encoder->channels; ch++) { + setup = encoder->channel_setup[ch]; + + setup->olpa_mem_pitch = 17; +#ifdef CR9_F_PITCH_WIN_LEN_FIX + setup->pitch_flag = 0; +#endif + if (setup->mdctStruct.mem != NULL) { + mdct_free(&setup->mdctStruct); + mdct_init(&setup->mdctStruct, encoder->frame_length, encoder->frame_dms, encoder->fs_idx, encoder->hrmode); + + dct2_free(&setup->dct2StructSNS); + dct2_init(&setup->dct2StructSNS, M); + } + else + { + mdct_init(&setup->mdctStruct, encoder->frame_length, encoder->frame_dms, encoder->fs_idx, encoder->hrmode); + dct2_init(&setup->dct2StructSNS, M); + } + } +} + +/* change encoder bitrate */ +LC3PLUS_Error update_enc_bitrate(LC3PLUS_Enc* encoder, int bitrate) +{ + int ch = 0, bitsTmp = 0, minBR = 0, maxBR = 0, totalBytes = 0; + LC3_INT channel_bytes = 0, max_bytes = 0; + +#ifdef ENABLE_HR_MODE_FL + if (encoder->hrmode) + { + switch (encoder->frame_dms) + { + case 25: + maxBR = 672000; + if (encoder->fs == 48000) {minBR = MIN_BR_25MS_48KHZ_HR;} + else if (encoder->fs == 96000) {minBR = MIN_BR_25MS_96KHZ_HR;} + else { return LC3PLUS_HRMODE_ERROR;} + break; + case 50: + maxBR = 600000; + if (encoder->fs == 48000) {minBR = MIN_BR_50MS_48KHZ_HR;} + else if (encoder->fs == 96000) {minBR = MIN_BR_50MS_96KHZ_HR;} + else { return LC3PLUS_HRMODE_ERROR;} + break; +#ifdef CR8_G_ADD_75MS + case 75: + maxBR = 500000; + if (encoder->fs == 48000) {minBR = MIN_BR_075DMS_48KHZ_HR;} + else if (encoder->fs == 96000) {minBR = MIN_BR_075DMS_96KHZ_HR;} + else {return LC3PLUS_HRMODE_ERROR;} + break; +#endif + case 100: + maxBR = 500000; + if (encoder->fs == 48000) {minBR = MIN_BR_100MS_48KHZ_HR;} + else if (encoder->fs == 96000) {minBR = MIN_BR_100MS_96KHZ_HR;} + else { return LC3PLUS_HRMODE_ERROR;} + break; + default: + return LC3PLUS_HRMODE_ERROR; + } + } + else +#endif /* ENABLE_HR_MODE_FL */ + { + minBR = (MIN_NBYTES << 3); + maxBR = MAX_BR; + + switch (encoder->frame_dms) + { + case 25: + minBR = MIN_BR_025DMS; + maxBR = MAX_BR; + break; + case 50: + minBR = MIN_BR_050DMS; + maxBR = MAX_BR; + /* have additional limitations for 5.0ms */ + switch (encoder->fs_in) + { + case 8000: maxBR = MAX_BR_050DMS_NB; break; + default: break; + } + break; +#ifdef CR8_G_ADD_75MS + case 75: + minBR = MIN_BR_075DMS; + maxBR = MAX_BR_075DMS; + /* have additional limitations for 7.5ms */ + switch (encoder->fs_in) + { + case 8000: maxBR = MAX_BR_075DMS_NB ; break; + case 16000: maxBR = MAX_BR_075DMS_WB ; break; + case 24000: maxBR = MAX_BR_075DMS_SSWB; break; + default: break; + } + break; +#endif + case 100: + /* have additional limitations for 10ms */ + minBR = MIN_BR_100DMS; + maxBR = MAX_BR; + switch (encoder->fs_in) + { + case 8000: maxBR = MAX_BR_100DMS_NB ; break; + case 16000: maxBR = MAX_BR_100DMS_WB ; break; + case 24000: maxBR = MAX_BR_100DMS_SSWB; break; + default: maxBR = MAX_BR; break; + } + break; + default: return LC3PLUS_FRAMEMS_ERROR; + } + maxBR *= (encoder->fs_in == 44100 ? 441. / 480 : 1); + } + minBR *= encoder->channels; + maxBR *= encoder->channels; + + encoder->combined_channel_coding = 0; + + if (encoder->channels > 1 && encoder->epmode) + { + if (encoder->bitrate * encoder->frame_length / (8 * encoder->fs_in) <= 160) + { + encoder->combined_channel_coding = 1; + } + } + + if (encoder->epmode > 0) + { + max_bytes = bitrate * encoder->frame_length / (8 * encoder->fs_in * encoder->channels); + if (max_bytes < FEC_SLOT_BYTES_MIN || max_bytes > FEC_SLOT_BYTES_MAX) + { + encoder->lc3_br_set = 0; + return LC3PLUS_BITRATE_ERROR; + } + } + + if (encoder->combined_channel_coding) + { + totalBytes = fec_get_data_size(encoder->epmode, encoder->combined_channel_coding, + bitrate * encoder->frame_length / (8 * encoder->fs_in)); + + encoder->channel_setup[0]->n_pccw = + fec_get_n_pccw(bitrate * encoder->frame_length / (8 * encoder->fs_in), encoder->epmode, + encoder->combined_channel_coding); + + encoder->channel_setup[0]->n_pc = fec_get_n_pc(encoder->epmode, encoder->channel_setup[0]->n_pccw, + bitrate * encoder->frame_length / (8 * encoder->fs_in)); + } + else + { + totalBytes = bitrate * encoder->frame_length / (8 * encoder->fs_in); + } + + if (encoder->frame_dms <= 50) + { + encoder->tnsMaxOrder = 4; + } else { + encoder->tnsMaxOrder = 8; + } + + if (bitrate < minBR || bitrate > maxBR) { + return LC3PLUS_BITRATE_ERROR; + } + + encoder->lc3_br_set = 1; + for (ch = 0; ch < encoder->channels; ch++) { + + EncSetup* setup = encoder->channel_setup[ch]; + + setup->targetBytes = totalBytes / encoder->channels + (ch < (totalBytes % encoder->channels)); + channel_bytes = totalBytes / encoder->channels + (ch < (totalBytes % encoder->channels)); + + if (encoder->combined_channel_coding) + { + setup->targetBytes = channel_bytes; + } + else + { + setup->targetBytes = fec_get_data_size(encoder->epmode, encoder->combined_channel_coding, channel_bytes); + setup->n_pccw = fec_get_n_pccw(channel_bytes, encoder->epmode, encoder->combined_channel_coding); + setup->n_pc = fec_get_n_pc(encoder->epmode, setup->n_pccw, channel_bytes); + } + // reduce bandwith to 12kHz if bitrate is low + if (encoder->frame_dms == 100 && + ((setup->targetBytes < 40 && encoder->fs == 48000) || + (setup->targetBytes < 36 && encoder->fs == 32000))) + { + encoder->bandwidth = MIN(12000, encoder->bandwidth_preset); + } + else + { + /* channel with highest index has lowest bitrate. + For a second channel with lower targetBytes, bandwidth is overwritten */ + encoder->bandwidth = encoder->bandwidth_preset; + } + encoder->bw_ctrl_cutoff_bin = encoder->bandwidth * encoder->frame_dms / 5000; + encoder->bw_index = (encoder->bandwidth / 4000) - 1; + setup->total_bits = setup->targetBytes << 3; + setup->targetBitsInit = setup->total_bits - encoder->envelope_bits - encoder->global_gain_bits - + encoder->noise_fac_bits - encoder->BW_cutoff_bits - + ceil(LC3_LOGTWO(encoder->frame_length / 2)) - 2 - 1; + + if (setup->total_bits > 1280) { + setup->targetBitsInit = setup->targetBitsInit - 1; + } + if (setup->total_bits > 2560) { + setup->targetBitsInit = setup->targetBitsInit - 1; + } + + if (encoder->hrmode) + { + setup->targetBitsInit -= 1; + } + + setup->targetBitsAri = setup->total_bits; + setup->enable_lpc_weighting = setup->total_bits < 480; + +#ifdef CR8_G_ADD_75MS + if (encoder->frame_ms == 7.5) { + setup->enable_lpc_weighting = setup->total_bits < 360; + } +#endif + if (encoder->frame_ms == 5) { + setup->enable_lpc_weighting = setup->total_bits < 240; + } + if (encoder->frame_ms == 2.5) { + setup->enable_lpc_weighting = setup->total_bits < 120; + } + + setup->quantizedGainOff = + -(MIN(115, setup->total_bits / (10 * (encoder->fs_idx + 1))) + 105 + 5 * (encoder->fs_idx + 1)); + + if (encoder->hrmode && encoder->fs_idx == 5) + { + setup->quantizedGainOff = MAX(setup->quantizedGainOff, -181); + } + + if (encoder->frame_ms == 10 && ((encoder->fs_in >= 44100 && setup->targetBytes >= 100) || + (encoder->fs_in == 32000 && setup->targetBytes >= 81)) && setup->targetBytes < 340 && encoder->hrmode == 0) { + setup->attack_handling = 1; + + } + else if (encoder->frame_dms == 75 && ((encoder->fs_in >= 44100 && setup->targetBytes >= 75) || + (encoder->fs_in == 32000 && setup->targetBytes >= 61)) && setup->targetBytes < 150 && encoder->hrmode == 0) + { + setup->attack_handling = 1; + } + else + { + /* reset for bitrate switching */ + setup->attack_handling = 0; + + setup->attdec_filter_mem[0] = 0; + setup->attdec_filter_mem[1] = 0; + + setup->attdec_detected = 0; + setup->attdec_position = 0; + setup->attdec_acc_energy = 0; + } + + bitsTmp = setup->total_bits; + if (encoder->frame_ms == 2.5) { + bitsTmp = bitsTmp * 4.0 * (1.0 - 0.4); + } + if (encoder->frame_ms == 5) { + bitsTmp = bitsTmp * 2 - 160; + } +#ifdef CR8_G_ADD_75MS + if (encoder->frame_ms == 7.5) { + bitsTmp = round(bitsTmp * 10 / 7.5); + } +#endif + + if (bitsTmp < 400 + (encoder->fs_idx - 1) * 80) { + setup->ltpf_enable = 1; + } else if (bitsTmp < 480 + (encoder->fs_idx - 1) * 80) { + setup->ltpf_enable = 1; + } else if (bitsTmp < 560 + (encoder->fs_idx - 1) * 80) { + setup->ltpf_enable = 1; + } else if (bitsTmp < 640 + (encoder->fs_idx - 1) * 80) { + setup->ltpf_enable = 1; + } else { + setup->ltpf_enable = 0; + } + if (encoder->hrmode) { + setup->ltpf_enable = 0; + } + + /* turn down SNS shaping for higher rates */ + if (encoder->hrmode == 0) { + encoder->sns_damping = 0.85; + } else { + encoder->sns_damping = 0.6; + if (encoder->fs_idx >= 4) { + if (encoder->frame_ms == 10) + { + if (setup->total_bits > 4400) { + encoder->sns_damping = 6881.0/32768.0; + } + } +#ifdef CR8_G_ADD_75MS + if (encoder->frame_ms == 7.5) + { + if (setup->total_bits > 3*4400/4) { + encoder->sns_damping = 5898.0/32768.0; + } + } +#endif + if (encoder->frame_ms == 5) + { + if (setup->total_bits > 4600/2) { + encoder->sns_damping = 4915.0/32768.0; + } + } + if (encoder->frame_ms == 2.5) + { + if (setup->total_bits > 4600/4) { + encoder->sns_damping = 4915.0/32768.0; + } + } + } + } + + if (encoder->hrmode && encoder->fs_idx >= 4) + { + int real_rate = setup->targetBytes * 8000 / encoder->frame_ms; + setup->regBits = real_rate / 12500; + + if (encoder->fs_idx == 5) + { + if (encoder->frame_ms == 10) + { + setup->regBits +=2; + } +#ifdef CR8_G_ADD_75MS + if (encoder->frame_ms == 7.5) + { + setup->regBits +=1; + } +#endif + if (encoder->frame_ms == 2.5) + { + setup->regBits -= 6; + } + } + else + { + if (encoder->frame_ms == 2.5) + { + setup->regBits -= 6; + } + else if (encoder->frame_ms == 5) + { + setup->regBits += 0; + } +#ifdef CR8_G_ADD_75MS + if (encoder->frame_ms == 7.5) + { + setup->regBits +=2; + } +#endif + if (encoder->frame_ms == 10) + { + setup->regBits += 5; + } + } + if (setup->regBits < 6) + { + setup->regBits = 6; + } + if (setup->regBits > 23) + { + setup->regBits = 23; + } + } + else + { + setup->regBits = -1; + } + } + + encoder->bitrate = bitrate; + + return LC3PLUS_OK; +} + +void update_enc_bandwidth(LC3PLUS_Enc* encoder, int bandwidth) +{ + int index = 0; + + if (bandwidth >= encoder->fs_in) { + encoder->bandwidth = 0; + } + else + { + encoder->bandwidth = bandwidth; + index = FS2FS_IDX(bandwidth); +#ifndef CR8_A_PLC_FADEOUT_TUNING + if (index > 4) { + index = 5; + } +#endif + encoder->bw_ctrl_cutoff_bin = encoder->cutoffBins[index]; + } +} diff --git a/lib_lc3plus/setup_enc_lc3.h b/lib_lc3plus/setup_enc_lc3.h new file mode 100644 index 0000000000000000000000000000000000000000..e3f62ba5567172542e10de4de6ceed10b1bee43f --- /dev/null +++ b/lib_lc3plus/setup_enc_lc3.h @@ -0,0 +1,128 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.3 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + + +#ifndef SETUP_ENC_LC3_FL_H +#define SETUP_ENC_LC3_FL_H + +#include "options.h" +#include "wmc_auto.h" +#include "constants.h" + +/* Channel state and bitrate-derived values go in this struct */ +typedef struct { + LC3_FLOAT targetBitsOff; + LC3_FLOAT ltpf_mem_normcorr; + LC3_FLOAT ltpf_mem_mem_normcorr; + LC3_FLOAT attdec_filter_mem[2]; + LC3_FLOAT attdec_acc_energy; + LC3_FLOAT r12k8_mem_50[2]; + LC3_FLOAT r12k8_mem_in[120]; +#ifdef CR8_G_ADD_75MS + LC3_FLOAT r12k8_mem_out[44]; +#else + LC3_FLOAT r12k8_mem_out[24]; +#endif + LC3_FLOAT olpa_mem_s12k8[3]; + LC3_FLOAT olpa_mem_s6k4[LEN_6K4 + MAX_PITCH_6K4 + 16]; + LC3_FLOAT ltpf_mem_in[LTPF_MEMIN_LEN + LEN_12K8 + 1]; + LC3_FLOAT s_in_scaled[MAX_LEN]; + LC3_FLOAT s_12k8[LEN_12K8 + 1]; + LC3_FLOAT ener[MAX_BANDS_NUMBER]; + LC3_FLOAT scf_q[M]; + LC3_FLOAT scf[M]; + LC3_FLOAT int_scf[MAX_BANDS_NUMBER]; + LC3_FLOAT ltpf_mem_pitch; + + LC3_INT targetBytes; + LC3_INT total_bits; + LC3_INT targetBitsInit; + LC3_INT targetBitsAri; + LC3_INT enable_lpc_weighting; + LC3_INT ltpf_enable; + LC3_INT quantizedGainOff; + LC3_INT tns_bits; + LC3_INT targetBitsQuant; + LC3_INT olpa_mem_pitch; +#ifdef CR9_F_PITCH_WIN_LEN_FIX + LC3_INT pitch_flag; +#endif + LC3_INT ltpf_mem_ltpf_on; + LC3_INT mem_targetBits; + LC3_INT mem_specBits; + LC3_INT attack_handling; /* flag to enable attack handling */ + LC3_INT attdec_detected; + LC3_INT attdec_position; + LC3_INT ltpf_param[3]; + LC3_INT L_scf_idx[SCF_MAX_PARAM]; + LC3_INT codingdata[3 * MAX_LEN]; + uint8_t resBits[MAX_RESBITS_LEN]; + LC3_INT regBits; + + LC3_INT16 n_pc; + LC3_INT16 n_pccw; + LC3_INT16 be_bp_left; + LC3_INT16 be_bp_right; + + Mdct mdctStruct; + Dct2 dct2StructSNS; + + LC3_INT lfe; +} EncSetup; + +/* Constants and sampling rate derived values go in this struct */ +struct LC3PLUS_Enc { + EncSetup* channel_setup[MAX_CHANNELS]; + const LC3_INT* W_fx; + const LC3_INT* bands_offset; + const LC3_INT* cutoffBins; + + LC3_INT fs; /* encoder sampling rate 44.1 -> 48 */ + LC3_INT fs_in; /* input sampling rate */ + LC3_INT bitrate; /* global bitrate */ + LC3_INT fs_idx; /* sampling rate index */ + LC3_INT frame_length; /* audio samples / frame */ + LC3_INT channels; /* number of channels */ + LC3_INT epmode; /* error protection mode */ + LC3_FLOAT frame_ms; /* frame length in ms (wrong for 44.1) */ + LC3_INT frame_dms; /* frame length in ms * 10 (wrong for 44.1) */ + LC3_INT tilt; + LC3_INT lc3_br_set; + LC3_INT yLen; + LC3_INT W_size; + LC3_INT la_zeroes; + LC3_INT stEnc_mdct_mem_len; + LC3_INT bands_number; + LC3_INT nSubdivisions; + LC3_INT ltpf_mem_in_len; + LC3_INT envelope_bits; + LC3_INT global_gain_bits; + LC3_INT noise_fac_bits; + LC3_INT BW_cutoff_bits; + LC3_INT r12k8_mem_in_len; + LC3_INT r12k8_mem_out_len; + LC3_INT16 near_nyquist_index; + LC3_INT16 near_nyquist_flag; + LC3_INT tnsMaxOrder; + LC3_INT hrmode; + LC3_INT bandwidth; + LC3_INT bandwidth_preset; + LC3_INT bw_ctrl_active; + LC3_INT bw_ctrl_cutoff_bin; + LC3_INT bw_index; + LC3_FLOAT sns_damping; + LC3_INT attdec_nblocks; + LC3_FLOAT attdec_damping; + LC3_INT attdec_hangover_thresh; + + LC3_INT16 combined_channel_coding; + LC3_INT16 epmr; +}; + +#endif diff --git a/lib_lc3plus/sns_compute_scf.c b/lib_lc3plus/sns_compute_scf.c new file mode 100644 index 0000000000000000000000000000000000000000..7f78b36667f31201bad612c4fc520f20a4f19bce --- /dev/null +++ b/lib_lc3plus/sns_compute_scf.c @@ -0,0 +1,175 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.3 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + + +#include "options.h" +#include "wmc_auto.h" +#include "functions.h" + +void processSnsComputeScf_fl(LC3_FLOAT* x, LC3_INT xLen, LC3_FLOAT* gains, LC3_INT smooth, LC3_FLOAT sns_damping, LC3_FLOAT attdec_damping_factor, LC3_INT fs_idx) +{ + LC3_INT bands_number, d, i, j, n, n2, n4, mapping[64]; + LC3_FLOAT x_tmp1[MAX_LEN], sum, mean, nf, gains_smooth[M], ratio; + LC3_FLOAT sum_gains_smooth; + const LC3_FLOAT* sns_preemph; + + sum_gains_smooth = 0; sum = 0; + sns_preemph = sns_preemph_all[fs_idx]; + + bands_number = xLen; + assert(bands_number <= 64); + + /* 5 ms */ + if (bands_number < 64) { + d = 64 - bands_number; + + if (d < xLen) + { + j = 0; + for (i = 0; i < 2 * d; i = i + 2) { + x_tmp1[i] = x[j]; + x_tmp1[i + 1] = x[j]; + j++; + } + + move_float(&x_tmp1[2 * d], &x[d], 64 - 2 * d); + } + else if (bands_number < 32) + { + ratio = LC3_FABS((LC3_FLOAT) (1.0 - 32.0 / (LC3_FLOAT) xLen)); + n4 = round(ratio * xLen); + n2 = xLen - n4; + + j = 0; + for(i = 1; i <= n4; i++) + { + mapping[j] = i; + mapping[j + 1] = i; + mapping[j + 2] = i; + mapping[j + 3] = i; + j += 4; + } + + for (i = n4 + 1; i <= n4 + n2; i++) + { + mapping[j] = i; + mapping[j + 1] = i; + j += 2; + } + + + for (i = 0; i < 64; i++) + { + x_tmp1[i] = x[mapping[i] - 1]; + } + } else { + assert(0 && "Unsupported number of bands!"); + } + + move_float(x, x_tmp1, 64); + + bands_number = 64; + xLen = bands_number; + } + + + /* Smoothing */ + + x_tmp1[0] = x[0]; + move_float(&x_tmp1[1], &x[0], 63); + + for (i = 0; i < 63; i++) { + x[i] = 0.5 * x[i] + 0.25 * (x_tmp1[i] + x[i + 1]); + } + + x[63] = 0.5 * x[63] + 0.25 * (x_tmp1[63] + x[63]); + + /* Pre-emphasis */ + for (i = 0; i < 64; i++) { + x[i] = x[i] * sns_preemph[i]; + } + + /* Noise floor at -40dB */ + for (i = 0; i < 64; i++) { + sum += x[i]; + } + + mean = sum * 0.015625; /* 1/64 */ + + nf = mean * 1.00e-04; + nf = MAX(nf, 2.328306436538696e-10); + + for (i = 0; i < 64; i++) { + if (x[i] < nf) { + x[i] = nf; + } + } + + /* Log-domain */ + for (i = 0; i < 64; i++) { + x[i] = LC3_LOGTWO(x[i]) * 0.5; + } + + /* Downsampling */ + for (n = 0; n < 16; n++) { + if (n == 0) { + x_tmp1[0] = x[0]; + + move_float(&x_tmp1[1], &x[0], 5); + + } else if (n == 15) { + move_float(x_tmp1, &x[59], 5); + + x_tmp1[5] = x[63]; + + } else { + move_float(x_tmp1, &x[n * 4 - 1], ((n * 4 + 5 - 1) - (n * 4 - 1) + 1)); + } + + sum = 0; + for (i = 0; i < 6; i++) { + sum += x_tmp1[i] * sns_W[i]; + } + + gains_smooth[n] = sum; + sum_gains_smooth += sum; + } + + + /* Remove mean and scaling */ + mean = sum_gains_smooth / 16.0; + + for (i = 0; i < 16; i++) { + gains[i] = sns_damping * (gains_smooth[i] - mean); + } + + /* Smoothing */ + if (smooth) { + gains_smooth[0] = (gains[0] + gains[1] + gains[2]) / 3.0; + gains_smooth[1] = (gains[0] + gains[1] + gains[2] + gains[3]) / 4.0; + + for (i = 2; i < 14; i++) { + gains_smooth[i] = (gains[i - 2] + gains[i - 1] + gains[i] + gains[i + 1] + gains[i + 2]) / 5.0; + } + + gains_smooth[M - 2] = (gains[M - 4] + gains[M - 3] + gains[M - 2] + gains[M - 1]) / 4.0; + gains_smooth[M - 1] = (gains[M - 3] + gains[M - 2] + gains[M - 1]) / 3.0; + + sum = 0; + for (i = 0; i < M; i++) { + sum += gains_smooth[i]; + } + + mean = sum / (LC3_FLOAT)M; + + for (i = 0; i < M; i++) { + gains[i] = attdec_damping_factor * (gains_smooth[i] - mean); + } + } +} diff --git a/lib_lc3plus/sns_interpolate_scf.c b/lib_lc3plus/sns_interpolate_scf.c new file mode 100644 index 0000000000000000000000000000000000000000..98b54909b70ca5159b3bfbedc5323b8165d54ed6 --- /dev/null +++ b/lib_lc3plus/sns_interpolate_scf.c @@ -0,0 +1,92 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.3 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + + +#include "options.h" +#include "wmc_auto.h" +#include "functions.h" + +void processSnsInterpolateScf_fl(LC3_FLOAT* gains, LC3_INT encoder_side, LC3_INT bands_number, LC3_FLOAT* gains_int) +{ + LC3_INT i, n, d, n4; + LC3_FLOAT tmp[MAX_BANDS_NUMBER_PLC], ratio; + + /* Interpolation */ + + gains_int[0] = gains[0]; + gains_int[1] = gains[0]; + + for (n = 0; n <= 14; n++) { + gains_int[n * 4 + 2] = gains[n] + (gains[n + 1] - gains[n]) * 0.125; + gains_int[n * 4 + 3] = gains[n] + (gains[n + 1] - gains[n]) * 0.375; + gains_int[n * 4 + 4] = gains[n] + (gains[n + 1] - gains[n]) * 0.625; + gains_int[n * 4 + 5] = gains[n] + (gains[n + 1] - gains[n]) * 0.875; + } + + gains_int[62] = gains[15] + (gains[15] - gains[14]) * 0.125; + gains_int[63] = gains[15] + (gains[15] - gains[14]) * 0.375; + + /* For 5ms */ + + if (bands_number < 64) { + d = 64 - bands_number; + + if (d < 32) + { + i = 0; + for (n = 0; n < 2 * d; n = n + 2) { + tmp[i] = (gains_int[n] + gains_int[n + 1]) / (LC3_FLOAT)2.0; + i++; + } + + for (n = 1; n < d; n++) { + gains_int[n] = gains_int[2 * n]; + } + + for (n = 2 * d; n < 64; n++) { + gains_int[n - d] = gains_int[n]; + } + + move_float(gains_int, tmp, d); + } + else if (bands_number < 32) + { + ratio = LC3_FABS((LC3_FLOAT) ((LC3_FLOAT)1.0 - (LC3_FLOAT)32.0 / (LC3_FLOAT) bands_number)); + n4 = LC3_ROUND(ratio * (LC3_FLOAT)bands_number); + + for (i = 0; i < n4; i++) + { + tmp[i] = (gains_int[4 * i] + gains_int[4 * i + 1] + gains_int[4 * i + 2] + gains_int[4 * i + 3]) / 4.0; + } + + for (i = 0; i < bands_number - n4; i++) + { + tmp[n4 + i] = (gains_int[4 * n4 + 2 * i] + gains_int[4 * n4 + 2 * i + 1]) / 2.0; + } + + move_float(gains_int, tmp, bands_number); + } else { + assert(0 && "Unsupported number of bands!"); + } + } + + /* Inversion at encoder-side */ + + if (encoder_side == 1) { + for (n = 0; n < bands_number; n++) { + gains_int[n] = -gains_int[n]; + } + } + + /* Linear domain */ + + for (n = 0; n < bands_number; n++) { + gains_int[n] = LC3_POW(2, gains_int[n]); + } +} diff --git a/lib_lc3plus/sns_quantize_scf.c b/lib_lc3plus/sns_quantize_scf.c new file mode 100644 index 0000000000000000000000000000000000000000..e3fa34d832adb5114ccbe555d0368078f5a770c3 --- /dev/null +++ b/lib_lc3plus/sns_quantize_scf.c @@ -0,0 +1,523 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.3 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + + +#include "options.h" +#include "wmc_auto.h" +#include "functions.h" + +static void pvq_dec(LC3_INT k, LC3_INT m, LC3_INT LS_ind, LC3_INT MPVQ_ind, LC3_INT* pulses); +static LC3_INT find_last_indice_le(LC3_INT compare, const LC3_INT* array, LC3_INT len); +static void idct_II(LC3_FLOAT* in, LC3_FLOAT* out, LC3_INT len); + +void idct_II(LC3_FLOAT* in, LC3_FLOAT* out, LC3_INT len) +{ + LC3_INT i; + LC3_FLOAT norm1, sum; + + norm1 = 0.353553390593274; /* sqrt(2 / 16) */ + + for (i = 0; i < len; i++) { + sum = mac_loop(in, idct_lookup[i], len); + out[i] = norm1 * sum; + } +} + +static LC3_INT pvq_pulse_search(LC3_FLOAT *xabs, LC3_FLOAT *ener, LC3_FLOAT *corr, LC3_INT *y, LC3_INT start, LC3_INT end) +{ + LC3_INT i; + LC3_INT nBest; + LC3_FLOAT bestCorrSq, bestEn; + LC3_FLOAT corrSq, currCorr, currEn; + + nBest = 0; + bestCorrSq = 0.0; + bestEn = 0.0; + + *ener += 1; // Added once for the entire loop + + i = start; + + currCorr = *corr + xabs[i]; + currEn = *ener + (2 * y[i]); + + corrSq = currCorr * currCorr; + + bestEn = currEn; + bestCorrSq = corrSq; + nBest = i; + + /* Iterative max search as recommended in the spec */ + for (; i < end; i++) + { + currCorr = *corr + xabs[i]; + currEn = *ener + (2 * y[i]); + + corrSq = currCorr * currCorr; + + if ((corrSq * bestEn) > (bestCorrSq * currEn)) + { + bestEn = currEn; + bestCorrSq = corrSq; + nBest = i; + } + } + + *corr += xabs[nBest]; + *ener += (2 * y[nBest]); + + y[nBest] += 1; /* Add the selected unit pulse */ + + return nBest; +} + +static void pvq_enc_vec_normalize(LC3_FLOAT *vec, LC3_INT N) +{ + LC3_FLOAT mag = 0.0, norm_fac; + LC3_INT i; + + for (i = 0; i < N; i++) + { + mag += (vec[i] * vec[i]); + } + + norm_fac = 1.0 / LC3_SQRT(mag); + + for (i = 0; i < N; i++) + { + vec[i] = vec[i] * norm_fac; + } + + return; +} + +static void pvq_enc_search(LC3_FLOAT* x_in, LC3_INT y[4][M]) +{ + LC3_INT i, N, K, pulse_total, N_setA; + LC3_FLOAT abs_sum, projfac; + LC3_FLOAT xabs[16]; + LC3_FLOAT yy, xy; + + abs_sum = 0.0; + + /* Step 1 : Projection to pyramid N=16, K=6 */ + N = 16; + K = 6; + pulse_total = 0; + N_setA = 10; + + yy = xy = 0.0f; + + for (i = 0; i < N; i++) + { + xabs[i] = LC3_FABS(x_in[i]); + abs_sum += xabs[i]; + } + + projfac = (K - 1) / abs_sum; + + for (i = 0; i < N; i++) + { + y[3][i] = floor(xabs[i] * projfac); + + pulse_total += y[3][i]; + + yy += (y[3][i] * y[3][i]); + xy += (xabs[i] * y[3][i]); + } + + /* Step 2: Adding unit pulses up to K = 6 */ + for (; pulse_total < K; pulse_total++) + { + pvq_pulse_search(xabs, &yy, &xy, y[3], 0, N); + } + + /* Step 3: Adding unit pulses up to K = 8 */ + memcpy(y[2], y[3], sizeof(LC3_INT)*N); + K = 8; + + for (; pulse_total < K; pulse_total++) + { + pvq_pulse_search(xabs, &yy, &xy, y[2], 0, N); + } + + memcpy(y[1], y[2], sizeof(LC3_INT)*N_setA); + + /* Step 4: Remove unit pulses not belonging to set A */ + for (i = N_setA; i < N; i++) + { + y[1][i] = 0; + } + + /* Step 5: Update yy and xy terms to reflect y1 */ + yy = 0; + xy = 0; + pulse_total = 0; + + for (i = 0; i < N_setA; i++) + { + yy += (y[1][i] * y[1][i]); + xy += (xabs[i] * y[1][i]); + + pulse_total += y[1][i]; + } + + /* Step 6: Add unit pulses until K = 10 over N = 10 */ + K = 10; + for (; pulse_total < K; pulse_total++) + { + pvq_pulse_search(xabs, &yy, &xy, y[1], 0, N_setA); + } + + memcpy(y[0], y[1], sizeof(LC3_INT)*N); + + /* Step 7: Add unit pulses until K = 1 over N = 6 in set B*/ + pvq_pulse_search(xabs, &yy, &xy, y[0], N_setA, N); + + /* Step 8: Add signs to each of the 4 vectors from x */ + for (i = 0; i < N; i++) + { + if (x_in[i] < 0) + { + y[0][i] = -y[0][i]; + y[1][i] = -y[1][i]; + y[2][i] = -y[2][i]; + y[3][i] = -y[3][i]; + } + } + + return; +} + +static inline LC3_FLOAT calc_mse(LC3_FLOAT *t2rot, LC3_FLOAT *y, LC3_FLOAT gain, LC3_INT N) +{ + LC3_FLOAT mse; + LC3_INT i; + + mse = 0.0; + + for (i = 0; i < N; i++) + { + LC3_FLOAT err = (t2rot[i] - gain * y[i]); + mse += (err * err); + } + + return mse; +} + +static void sns_quant_adj_gain_shape_search(LC3_FLOAT *t2rot, LC3_INT y[4][M] , + LC3_INT *gain_idx, LC3_INT *shape_idx, LC3_FLOAT *y_norm, LC3_FLOAT *scq_gain) +{ + LC3_INT gidx, sidx; + LC3_FLOAT min_mse, mse; + LC3_INT N; + LC3_FLOAT yCur[4][16]; + LC3_INT i; + + const LC3_INT gain_levels[4] = { 2, 4, 4, 8 }; + const LC3_FLOAT *sns_vq_gains[4] = { sns_vq_reg_adj_gains_fl , sns_vq_reg_lf_adj_gains_fl , + sns_vq_near_adj_gains_fl , sns_vq_far_adj_gains_fl }; + + min_mse = -1.0; + N = 16; + + + *gain_idx = *shape_idx = 0; + + for (sidx = 0; sidx < 4; sidx++) + { + for (i = 0; i < N; i++) + { + yCur[sidx][i] = (LC3_FLOAT)y[sidx][i]; + } + + /* Step 9: Normalize the vectors */ + pvq_enc_vec_normalize(yCur[sidx], N); + + for (gidx = 0; gidx < gain_levels[sidx]; gidx++) + { + mse = calc_mse(t2rot, yCur[sidx], sns_vq_gains[sidx][gidx], N); + + if ((mse < min_mse) || (min_mse < 0)) + { + *gain_idx = gidx; + *shape_idx = sidx; + min_mse = mse; + } + } + } + + for (i = 0; i < N; i++) + { + y_norm[i] = yCur[*shape_idx][i]; + } + + *scq_gain = sns_vq_gains[*shape_idx][*gain_idx]; + + return; +} + +static void enc_push_sign(LC3_FLOAT val, LC3_UINT32 *next_sign_ind, LC3_INT *index) +{ + if (((*next_sign_ind & 0x80000000U) == 0) && (val != 0)) { + *index = 2 * (*index) + *next_sign_ind; + } + if (val < 0) { + *next_sign_ind = 1; + } + if (val > 0) { + *next_sign_ind = 0; + } + + return; +} + +static void MPVQ_enum(LC3_INT dim, LC3_INT *sns_vec, LC3_INT *index_val, LC3_INT *lead_sign_ind) +{ + LC3_UINT32 next_sign_ind; + LC3_INT k_val_acc; + LC3_INT pos; + LC3_INT index, n; + LC3_INT const *row_ptr; + + /* MPVQ-index composition loop */ + LC3_INT tmp_h_row; + LC3_INT tmp_val; + + next_sign_ind = 0x80000000U; + k_val_acc = 0; + pos = dim; + index = 0; + n = 0; + + row_ptr = (LC3_INT const *)&(pvq_enc_A[n]); + tmp_h_row = row_ptr[0]; + + for (pos--; pos >= 0; pos--) + { + tmp_val = sns_vec[pos]; + enc_push_sign(tmp_val, &next_sign_ind, &index); + + index += tmp_h_row; + k_val_acc += abs(tmp_val); + if (pos != 0) { + n += 1; /* switch row in offset table MPVQ_offsets(n, k) */ + } + row_ptr = (LC3_INT const *)&(pvq_enc_A[n]); + + tmp_h_row = row_ptr[k_val_acc]; + } + + *index_val = index; + *lead_sign_ind = next_sign_ind; + + return; +} + +static LC3_INT MSEsearch (LC3_FLOAT *scf, const LC3_FLOAT sns_CB[8][32]) +{ + LC3_FLOAT distance, mse; + LC3_INT i, n, ind; + + ind = 0; + + distance = (LC3_FLOAT) LC3_CONST_POW_2_100; + for (i = 0; i < 32; i++) { + mse = 0; + for (n = 0; n < 8; n++) { + mse += (scf[n] - sns_CB[n][i]) * (scf[n] - sns_CB[n][i]); + } + + if (mse < distance) { + distance = mse; + ind = i; + } + } + return ind; +} + +void process_snsQuantizesScf_Enc(LC3_FLOAT* env, LC3_INT* index, LC3_FLOAT* envq, Dct2 dct2structSNS) +{ + LC3_FLOAT stage2_en1_norm_sub[M]; + LC3_INT i, j; + LC3_FLOAT st1_vector[M]; + LC3_FLOAT pvq_target_pre[M]; + LC3_FLOAT pvq_target[M]; + LC3_FLOAT stage2_en1_norm_pre_sub[M]; + LC3_INT gain, shape; + LC3_FLOAT scfq_gain; + LC3_INT y[4][M]; + + /* Stage 1 split VQ */ + index[0] = MSEsearch(&env[0], sns_LFCB); /* ind_LF */ + index[1] = MSEsearch(&env[8], sns_HFCB); /* ind_HF */ + + j = 8; + for (i = 0; i < 8; i++, j++) { + st1_vector[i] = sns_LFCB[i][index[0]]; + st1_vector[j] = sns_HFCB[i][index[1]]; + } + + /* STAGE 2 */ + for (i = 0; i < 16; i++) { + pvq_target_pre[i] = env[i] - st1_vector[i]; + } + + dct2_apply(&dct2structSNS, pvq_target_pre, pvq_target); + pvq_enc_search(pvq_target, y); + sns_quant_adj_gain_shape_search(pvq_target, y, &gain, &shape, stage2_en1_norm_pre_sub, &scfq_gain); + + /* Inverse transform */ + idct_II(stage2_en1_norm_pre_sub, stage2_en1_norm_sub, M); + + index[2] = shape; + index[3] = gain; + + if (shape < 2) { + MPVQ_enum(10, y[shape], &index[5], &index[4]); + } + else { + MPVQ_enum(M, y[shape], &index[5], &index[4]); + } + + if (shape == 0) { + LC3_INT ls_ind, ind; + MPVQ_enum(6, &y[shape][10], &ind, &ls_ind); + index[6] = ind * 2 + ls_ind; + } + else if (shape == 2) { + index[6] = -1; + } + else { + index[6] = -2; + } + + for (i = 0; i < M; i++) { + envq[i] = st1_vector[i] + (stage2_en1_norm_sub[i] * scfq_gain); + } +} + +LC3_INT find_last_indice_le(LC3_INT compare, const LC3_INT* array, LC3_INT len) +{ + LC3_INT idx = 0, i = 0; + + for (i = 0; i < len; i++) { + if (compare >= array[i]) { + idx++; + } + } + + if (idx > 0) { + idx--; + } + + return idx; +} + +void pvq_dec(LC3_INT k, LC3_INT m, LC3_INT LS_ind, LC3_INT MPVQ_ind, LC3_INT* pulses) +{ + LC3_INT leading_sign, idx, k_delta = 0, pos; + + leading_sign = 1 - 2 * LS_ind; + + /* Decoding loop */ + + for (pos = 0; pos < m; pos++) { + if (MPVQ_ind != 0) { + /* Find last indice */ + idx = find_last_indice_le(MPVQ_ind, &pvq_enc_A[m - pos - 1][0], k + 1); + MPVQ_ind = MPVQ_ind - pvq_enc_A[m - pos - 1][idx]; + k_delta = k - idx; + } else { + pulses[pos] = leading_sign * k; + break; + } + + if (k_delta != 0) { + pulses[pos] = leading_sign * k_delta; + if ((MPVQ_ind % 2) != 0) { + leading_sign = -1; + } else { + leading_sign = 1; + } + + MPVQ_ind = floor(MPVQ_ind / 2); + k = k - k_delta; + } + } +} + +void process_snsQuantizesScf_Dec(LC3_INT* scf_idx, LC3_FLOAT* scf_q) +{ + LC3_INT i, submode; + LC3_INT pulses2[6] = {0}, pulses[M] = {0}; + LC3_FLOAT st2_vector[M], st2_vector_idct[M], sum = 0; + + /* Decode first stage */ + + for (i = 0; i < 8; i++) { + scf_q[i] = sns_LFCB[i][scf_idx[0]]; + scf_q[i + 8] = sns_HFCB[i][scf_idx[1]]; + } + + /* STAGE 2 */ + /* Decode submode */ + + submode = scf_idx[2]; + + /* Decode pulses */ + + if (submode < 2) { + pvq_dec(10, 10, scf_idx[4], scf_idx[5], pulses); + + if (submode == 0) { + pvq_dec(1, 6, (scf_idx[6] % 2), floor(scf_idx[6] / 2), pulses2); + + move_int(&pulses[10], pulses2, 6); + + } else { + pulses[15] = 0; + } + } else if (submode == 2) { + pvq_dec(8, 16, scf_idx[4], scf_idx[5], pulses); + } else { + pvq_dec(6, 16, scf_idx[4], scf_idx[5], pulses); + } + + /* Normalization */ + + for (i = 0; i < M; i++) { + sum += pulses[i] * pulses[i]; + } + + sum = 1.0 / LC3_SQRT(sum); + + for (i = 0; i < M; i++) { + st2_vector[i] = pulses[i] * sum; + } + + /* Inverse transform */ + idct_II(st2_vector, st2_vector_idct, M); + + /* Gain */ + /* Add stage 1 and stage 2 */ +#ifdef CR9_SIMPLIFY_LOOP + for (i = 0; i < M; i++) { + scf_q[i] += st2_vector_idct[i] * sns_dec_gains[submode][scf_idx[3]]; + } +#else + for (i = 0; i < M; i++) { + st2_vector_idct[i] = st2_vector_idct[i] * sns_dec_gains[submode][scf_idx[3]]; + } + + for (i = 0; i < M; i++) { + scf_q[i] = scf_q[i] + st2_vector_idct[i]; + } +#endif +} diff --git a/lib_lc3plus/structs.h b/lib_lc3plus/structs.h new file mode 100644 index 0000000000000000000000000000000000000000..59425744eda6bbb5d0a73ab585d6e65014c506f4 --- /dev/null +++ b/lib_lc3plus/structs.h @@ -0,0 +1,208 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.3 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + + +#ifndef STRUCTS_H +#define STRUCTS_H + +#include "options.h" +#include "wmc_auto.h" +#include "defines.h" +#include "fft/iisfft.h" + +typedef struct { + LC3_FLOAT r; /* real part */ + LC3_FLOAT i; /* imaginary part */ +} Complex; + +typedef struct { + LC3_INT length; + void *handle; +} Fft; + +typedef struct { + LC3_INT length; + Fft fft; +} Dct2; + +typedef struct { + LC3_INT length; + Fft fft; +} Dct3; + +typedef struct { + LC3_INT length; + Complex *twid1; + Complex *twid2; + Fft fft; +} Dct4; + +typedef struct { + LC3_INT length; + LC3_INT leading_zeros; + LC3_INT mem_length; + const LC3_FLOAT *window; + LC3_FLOAT *mem; + Dct4 dct; +} Mdct; + +typedef struct { + uint32_t ac_low_fl; + uint32_t ac_range_fl; + int BER_detect; + + LC3_INT32 pc_c_bp; + LC3_INT32 pc_c_bp_side; + LC3_INT32 pc_bytes; + LC3_INT32 pc_b_left; + LC3_INT32 pc_b_right; + LC3_INT32 pc_enc; + LC3_INT32 pc_bfi; + LC3_INT32 pc_bbi; + LC3_INT32 pc_be_bp_left; + LC3_INT32 pc_be_bp_right; + LC3_INT32 pc_return; + LC3_INT16 pc_inv_bin; +} Decoder_State_fl; + +typedef struct { + LC3_INT bp; + LC3_INT low; + LC3_INT range; + LC3_INT cache; + LC3_INT carry; + LC3_INT carry_count; + uint8_t *ptr; + LC3_INT *bp_side; + LC3_INT *mask_side; +} Encoder_State_fl; + +typedef struct { + LC3_INT nbLostCmpt; + LC3_INT prevBfi; + LC3_INT prevprevBfi; + LC3_FLOAT q_d[MAX_LEN]; + LC3_FLOAT q_d_prev[MAX_LEN]; +} PlcSetup; + + +typedef struct { + LC3_FLOAT cum_alpha; + LC3_INT seed; +} PlcNsSetup; + +typedef struct { + LC3_INT32 seed; + LC3_INT32 ns_nbLostCmpt_pc; + LC3_FLOAT *q_old_res; + LC3_FLOAT prev_gg; +} pcState; + +typedef struct { + LC3_INT len; + LC3_INT sign; + LC3_FLOAT* table; +} Cfft; + +typedef struct T_IIS_FFT { + IIS_FFT_DIR sign; + LC3_INT32 len; + LC3_FLOAT* buffer; + LC3_FLOAT* sine_table; + Iisfft iisfft; + Cfft cfft; +} IIS_FFT; + +typedef struct T_IIS_FFT* HANDLE_IIS_FFT; + +typedef struct { + Fft PhEcu_Fft; /*no counterpart in BASOP */ + Fft PhEcu_Ifft; /*no counterpart in BASOP */ + + + LC3_FLOAT PhECU_f0hzLtpBin; /* BASOP Word16 PhECU_f0hzLtpBinQ7 */ + LC3_FLOAT PhECU_norm_corr; /* BASOP Word16 norm_corrQ15 */ + + LC3_FLOAT *PhECU_oold_grp_shape; /* BASOP Word16 PhECU_oold_grp_shape_fx[MAX_LGW]; */ + LC3_FLOAT *PhECU_old_grp_shape; /* BASOP Word16 PhECU_old_grp_shape_fx[MAX_LGW] ; */ + + LC3_FLOAT PhECU_L_oold_xfp_w_E; /* BASOP Word32 PhECU_L_oold_xfp_w_E_fx;*/ + LC3_FLOAT PhECU_L_old_xfp_w_E; /* BASOP Word32 PhECU_L_old_xfp_w_E_fx; */ + + LC3_INT32 PhECU_Lprot ; /* BASOP Word16 PhECU_Lprot_fx;*/ + + LC3_FLOAT *PhECU_xfp; + Complex *PhECU_X_sav_m; + LC3_INT32 *PhECU_plocs; /* BASOP Word16 *PhECU_plocs; */ /* MAX_PLOCS */ + LC3_FLOAT *PhECU_f0est; /*BASOP Word32 *PhECU_f0est;*/ + + LC3_FLOAT *PhECU_mag_chg_1st; /* BASOP Word16 PhECU_mag_chg_1st[MAX_LGW];*/ + LC3_FLOAT *PhECU_Xavg; /* BASOP Word16 PhECU_Xavg[MAX_LGW] ; */ + + LC3_FLOAT PhECU_beta_mute; /* BASOP Word16 PhECU_beta_mute*/ + + LC3_INT16 PhECU_seed; /* BASOP Word16 PhECU_seed_fx;*/ + + LC3_INT32 PhECU_LDWIN_OLAP; /* BASOP Word16 PhECU_LDWIN_OLAP; */ + LC3_INT32 PhECU_t_adv; /* BASOP Word16 t_adv; */ + + LC3_INT32 PhECU_short_flag_prev; + LC3_INT32 PhECU_time_offs; + LC3_INT32 PhECU_num_plocs; + HANDLE_IIS_FFT handle_fft_phaseecu; + HANDLE_IIS_FFT handle_ifft_phaseecu; +#ifdef CR8_A_PLC_FADEOUT_TUNING + LC3_INT16 PhECU_nonpure_tone_flag; /* BASOP Word16 PhECU_nonpure_tone_flag*/ +#endif + +} PlcPhEcuSetup; + +typedef struct { + LC3_INT16 seed; + LC3_FLOAT gain_c; + LC3_INT32 lpcorder; + LC3_FLOAT A[M+1]; + LC3_INT32 fract; + LC3_INT32 lagw_bw; + LC3_FLOAT preemphFac; + LC3_FLOAT *harmonicBuf; + LC3_FLOAT synthHist[M]; +} PlcTdcSetup; + +typedef struct { + LC3_FLOAT *pcmbufHist; + LC3_INT32 max_len_pcm_plc; + PlcTdcSetup PlcTdcSetup; + LC3_FLOAT stabFac; + LC3_FLOAT cum_fading_slow; + LC3_FLOAT cum_fading_fast; + LC3_FLOAT cum_fflcAtten; + LC3_FLOAT scf_q_old[M]; + LC3_FLOAT scf_q_old_old[M]; + PlcPhEcuSetup PlcPhEcuSetup; + +#ifdef CR8_A_PLC_FADEOUT_TUNING + LC3_INT16 longterm_counter_plcTdc; +#ifndef CR9_L_RETRAIN_FADEOUT_TYPE_CLASSIFIER + LC3_INT16 longterm_counter_plcPhaseEcu; +#endif + LC3_INT16 longterm_counter_plcNsAdv; + LC3_INT16 longterm_analysis_counter_max; /* Maximum longterm frames number */ + LC3_INT16 longterm_analysis_counter_max_bytebuffer; /* Same as above but reduced for circular bit-buffer */ + LC3_INT32 *plc_longterm_advc_tdc; + LC3_INT32 *plc_longterm_advc_ns; + LC3_UINT8 plc_fadeout_type; + LC3_UINT8 plc_fadeout_type_first; + LC3_INT16 overall_counter; + LC3_INT8 longterm_counter_byte_position; + LC3_INT8 longterm_counter_bit_position; +#endif +} PlcAdvSetup; + +#endif diff --git a/lib_lc3plus/tns_coder.c b/lib_lc3plus/tns_coder.c new file mode 100644 index 0000000000000000000000000000000000000000..6870ba1e14a03899214080fed53ed5aa458187f9 --- /dev/null +++ b/lib_lc3plus/tns_coder.c @@ -0,0 +1,393 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.3 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + + +#include "options.h" +#include "wmc_auto.h" +#include "functions.h" + +static void xcorr(LC3_FLOAT* in, LC3_FLOAT* out, LC3_INT lag, LC3_INT inLen); +static void levdown(LC3_FLOAT* anxt, LC3_FLOAT* out_a, LC3_INT* len); +static void poly2rc(LC3_FLOAT* a, LC3_FLOAT* out, LC3_INT len); + +void xcorr(LC3_FLOAT* in, LC3_FLOAT* out, LC3_INT lag, LC3_INT inLen) +{ + LC3_INT32 m; + + + for (m = 0; m <= lag; m++) { + /* Calculate correlation */ + out[m] = mac_loop(in, &in[m], (inLen - m)); + } +} + +void levinsonDurbin(LC3_FLOAT* r, LC3_FLOAT* out_lev, LC3_FLOAT* rc_unq, LC3_FLOAT* error, LC3_INT len) +{ + LC3_INT t, i, j; + LC3_FLOAT g, v, sum, buf_tmp[10]; + + g = r[1] / r[0]; + out_lev[0] = g; + + v = (1.0 - g * g) * r[0]; + rc_unq[0] = -g; + + for (t = 1; t < len; t++) { + + sum = 0; + for (i = 1; i <= t; i++) { + sum += out_lev[i - 1] * r[i]; + } + + g = (r[t + 1] - sum) / v; + + j = 1; + for (i = t - 1; i >= 0; i--) { + buf_tmp[j] = out_lev[j - 1] - g * out_lev[i]; + j++; + } + + move_float(&out_lev[1], &buf_tmp[1], len); + + out_lev[0] = g; + + v = v * (1 - g * g); + rc_unq[t] = -g; + } + + /* Reorder out_lev */ + out_lev[0] = 1; + j = 1; + for (i = len - 1; i >= 0; i--) { + buf_tmp[j] = -out_lev[i]; + j++; + } + + move_float(&out_lev[1], &buf_tmp[1], (len - 1)); + + out_lev[len] = rc_unq[len - 1]; + + *error = v; +} + +void levdown(LC3_FLOAT* anxt, LC3_FLOAT* out_a, LC3_INT* len) +{ + LC3_INT32 i, j; + LC3_FLOAT tmp_buf[8], knxt; + LC3_FLOAT norm; + + memset(tmp_buf, 0, 8 * sizeof(LC3_FLOAT)); + /* Initial length = 9 */ + + /* Drop the leading 1 */ + + *len = *len - 1; /* Lenght = 8 */ + + /* Last coefficient */ + knxt = anxt[*len]; /* At [7] */ + + *len = *len - 1; /* Lenght = 7 */ + + j = 0; + for (i = *len - 1; i >= 0; i--) { + tmp_buf[j] = knxt * anxt[i + 1]; + j++; + } + + norm = 1.0 / (1.0 - (LC3_FABS(knxt)) * (LC3_FABS(knxt))); + + out_a[0] = 1; + for (i = 0; i < *len; i++) { + out_a[i + 1] = (anxt[i + 1] - tmp_buf[i]) * norm; + } + + *len = *len + 1; /* Length = 8 */ +} + +void poly2rc(LC3_FLOAT* a, LC3_FLOAT* out, LC3_INT len) +{ + LC3_INT k, i, len_old; + LC3_FLOAT buf[9]; + + len_old = len; + + zero_float(out, len - 1); + + /* Length = 9 */ + + /* Normalize */ + for (i = 0; i < len; i++) { + a[i] = a[i] / a[0]; + } + + out[len - 1] = a[len - 1]; + + /* Process */ + for (k = len - 2; k >= 0; k--) { + levdown(a, buf, &len); + out[k] = buf[len - 1]; /* Store last value */ + + move_float(a, buf, len); + } + + /* Shift output array by one to the left to lose leading 1 */ + for (i = 0; i < len_old - 1; i++) { + out[i] = out[i + 1]; + } +} + + +void processTnsCoder_fl(LC3_FLOAT* x, LC3_INT bw_cutoff_idx, LC3_INT bw_fcbin, LC3_INT fs, LC3_INT N, LC3_INT frame_dms, LC3_INT nBits, + LC3_INT* order_out, LC3_INT* rc_idx, LC3_INT* tns_numfilters, LC3_INT* bits_out + , LC3_INT16 near_nyquist_flag +) +{ + LC3_INT i, stopfreq[2], startfreq[2], f, numfilters, maxOrder, bits, sub, + subdiv_startfreq, subdiv_stopfreq, j, rc_idx_tmp[MAXLAG], order_tmp, tmp, tns; + LC3_FLOAT minPGfac, minPredictionGain, maxPG, xcorr_out[MAXLAG + 1], sum, + subdiv_len, nSubdivisions, r[MAXLAG + 1], rc_unq[MAXLAG + 1], error_lev, predGain, + alpha, rc[MAXLAG], st[MAXLAG + 1] = {0}, s, tmpSave, tmp_fl; + const LC3_INT* order; + LC3_FLOAT inv_sum, x_val; + LC3_FLOAT alpha_loc; + LC3_INT32 iIndex; + + /* Init */ + + if (fs >= 32000 && frame_dms >= 50) { + numfilters = 2; + } else { + numfilters = 1; + } + + /* 40 * frame_dms / 10 = 4 * frame_dms */ + if (N > 4 * frame_dms) + { + N = 4 * frame_dms; + fs = 40000; + } + + if (numfilters == 1) { + startfreq[0] = floor(600 * N * 2 / fs) + 1; + stopfreq[0] = N; + } else { + startfreq[0] = floor(600 * N * 2 / fs) + 1; + startfreq[1] = N / 2 + 1; + stopfreq[0] = N / 2; + stopfreq[1] = N; + } + + switch (frame_dms) + { + case 25: + maxOrder = 4; + nSubdivisions = 2.0; + break; + case 50: + maxOrder = 4; + nSubdivisions = 2.0; + break; +#ifdef CR8_G_ADD_75MS + case 75: + maxOrder = 8; + nSubdivisions = 3; + break; +#endif + case 100: + maxOrder = 8; + nSubdivisions = 3.0; + break; + } + + minPredictionGain = 1.5; + + if (nBits >= 4.8 * frame_dms) { + order = order1_tns; + } else { + order = order2_tns; + } + + /* Processing */ + if (bw_cutoff_idx >= 3 && numfilters == 2) { + numfilters = 2; + startfreq[1] = bw_fcbin / 2 + 1; + stopfreq[0] = bw_fcbin / 2; + stopfreq[1] = bw_fcbin; + } else { + numfilters = 1; + stopfreq[0] = bw_fcbin; + } + + bits = 0; + + for (f = 0; f < numfilters; f++) { + subdiv_len = ((LC3_FLOAT)stopfreq[f] + 1.0 - (LC3_FLOAT)startfreq[f]) / nSubdivisions; + + zero_float(r, MAXLAG+1); + + for (sub = 1; sub <= nSubdivisions; sub++) { + subdiv_startfreq = floor(subdiv_len * (sub - 1)) + startfreq[f] - 1; + subdiv_stopfreq = floor(subdiv_len * sub) + startfreq[f] - 1; + +#ifdef CR8_G_ADD_75MS + if (fs == 32000 && frame_dms == 75) + { + if (subdiv_startfreq == 83) + { + subdiv_startfreq = 82; + } + + if (subdiv_stopfreq == 83) + { + subdiv_stopfreq = 82; + } + + if (subdiv_startfreq == 160) + { + subdiv_startfreq = 159; + } + + if (subdiv_stopfreq == 160) + { + subdiv_stopfreq = 159; + } + } +#endif + + sum = 0; + for (i = subdiv_startfreq; i < subdiv_stopfreq; i++) { + sum += x[i] * x[i]; + } + + if (sum < LC3_EPS) { + zero_float(r, MAXLAG+1); + r[0] = 1; + break; + } + + xcorr(&x[subdiv_startfreq], xcorr_out, maxOrder, subdiv_stopfreq - subdiv_startfreq); + + inv_sum = 1.0 / sum; + for (i = 0; i <= maxOrder; i++) { + r[i] = r[i] + xcorr_out[i] * inv_sum; + } + } + + for (i = 0; i <= maxOrder; i++) { + r[i] = r[i] * lagw_tns[i]; + } + + levinsonDurbin(r, xcorr_out, rc_unq, &error_lev, maxOrder); + + predGain = r[0] / error_lev; + + if (predGain > minPredictionGain && near_nyquist_flag == 0) { + tns = 1; + } else { + tns = 0; + } + + bits++; + + if (tns == 1) { + minPGfac = 0.85; + maxPG = 2; + if (nBits >= 4.8 * frame_dms) { + maxPG = minPredictionGain; + } + + /* LPC weighting */ + if (predGain < maxPG) { + alpha = (maxPG - predGain) * (minPGfac - 1.0) / (maxPG - minPredictionGain) + 1.0; + + alpha_loc = 1; + for (i = 0; i <= maxOrder; i++) { + xcorr_out[i] = xcorr_out[i] * alpha_loc; + alpha_loc *= alpha; + } + + poly2rc(xcorr_out, rc_unq, maxOrder + 1); + } + + /* PARCOR Quantization */ + for (i = 0; i < maxOrder; i++) + { + iIndex = 1; + x_val = rc_unq[i]; + + while ((iIndex < 17) && (x_val > quants_thr_tns[iIndex - 1])) + { + iIndex = (iIndex + 1); + } + rc_idx_tmp[i] = (iIndex - 2); + } + + /* Filter Order */ + order_tmp = 0; + for (i = 0; i < maxOrder; i++) { + rc[i] = quants_pts_tns[rc_idx_tmp[i]]; + + if (rc[i] != 0) { + order_tmp = i + 1; + } + } + + order_out[f] = order_tmp; + + // Disable TNS if order is 0: + if (order_out[f] == 0) { + tns = 0; + + // Jump to else statement + goto tns_disabled; + } + tmp = order[order_out[f] - 1]; + + /* Huffman Coding of PARCOR coefficients */ + for (i = 0; i <= order_out[f] - 1; i++) { + tmp += huff_bits_tns[i][rc_idx_tmp[i]]; + } + + bits = bits + ceil((LC3_FLOAT)tmp / 2048.0); + + j = 0; + for (i = f * 8; i <= f * 8 + order_out[f] - 1; i++) { + rc_idx[i] = rc_idx_tmp[j]; + j++; + } + } else { +tns_disabled: + order_out[f] = 0; + } + + /* Filtering */ + if (tns == 1) { + for (i = startfreq[f]; i <= stopfreq[f]; i++) { + s = x[i - 1]; + tmpSave = s; + + for (j = 0; j < order_out[f] - 1; j++) { + tmp_fl = rc[j] * s + st[j]; + s += rc[j] * st[j]; + + st[j] = tmpSave; + tmpSave = tmp_fl; + } + + s += rc[order_out[f] - 1] * st[order_out[f] - 1]; + + st[order_out[f] - 1] = tmpSave; + x[i - 1] = s; + } + } + } + + *tns_numfilters = numfilters; + *bits_out = bits; +} diff --git a/lib_lc3plus/tns_decoder.c b/lib_lc3plus/tns_decoder.c new file mode 100644 index 0000000000000000000000000000000000000000..dbdadaeaff9fd4d6dd0ee951bf3b7f92c2def937 --- /dev/null +++ b/lib_lc3plus/tns_decoder.c @@ -0,0 +1,55 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.3 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + + +#include "options.h" +#include "wmc_auto.h" +#include "functions.h" + +void processTnsDecoder_fl(LC3_FLOAT* x, LC3_INT* rc_idx, LC3_INT* order, LC3_INT numfilters, LC3_INT bw_fcbin, LC3_INT N, LC3_INT fs) +{ + LC3_INT startfreq[2], stopfreq[2], f, i, j, m, l; + LC3_FLOAT rc[9], s, st[9] = {0}; + LC3_INT order_tmp; + + if (numfilters == 2) { + startfreq[0] = floor(600 * N * 2 / fs) + 1; + stopfreq[0] = bw_fcbin / 2; + startfreq[1] = bw_fcbin / 2 + 1; + stopfreq[1] = bw_fcbin; + } else { + startfreq[0] = floor(600 * N * 2 / fs) + 1; + stopfreq[0] = bw_fcbin; + } + + for (f = 0; f < numfilters; f++) { + order_tmp = order[f]; + + if (order_tmp > 0) { + j = 0; + + for (i = f * 8; i < f * 8 + order_tmp; i++) { + rc[j] = quants_pts_tns[rc_idx[i]]; + j++; + } + + for (m = startfreq[f]; m <= stopfreq[f]; m++) { + s = x[m - 1] - rc[order_tmp - 1] * st[order_tmp - 1]; + + for (l = order_tmp - 2; l >= 0; l--) { + s = s - rc[l] * st[l]; + st[l + 1] = rc[l] * s + st[l]; + } + + st[0] = s; + x[m - 1] = s; + } + } + } +} diff --git a/lib_lc3plus/util.h b/lib_lc3plus/util.h new file mode 100644 index 0000000000000000000000000000000000000000..069e89371442237cbe80ffef26bc756bc2a63f15 --- /dev/null +++ b/lib_lc3plus/util.h @@ -0,0 +1,256 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.4.3 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + + +#ifndef UTIL_H +#define UTIL_H + +#include "options.h" +#include "wmc_auto.h" +#include "clib.h" +#include "math.h" + +#ifdef _MSC_VER +/* strcasecmp is not available on visual studio */ +static LC3_INT strcasecmp(const char* a, const char* b) { + return _stricmp(a,b); +} +#endif + +/* restrict is not available on visual studio */ +#ifdef _MSC_VER +#define restrict __restrict +/* inline is not recognized in visual studio 13 required by matlab r2015a in win10 */ +#define inline __inline +#endif + +/* number of elements in array */ +#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) + +/* min max with no side effects */ +static inline LC3_INT imin(LC3_INT a, LC3_INT b) { return a < b ? a : b; } +static inline LC3_INT imax(LC3_INT a, LC3_INT b) { return a > b ? a : b; } + +/* restrict x to range [min, max] */ +static inline LC3_INT iclamp(LC3_INT min, LC3_INT x, LC3_INT max) { + return x < min ? min : x > max ? max : x; +} +static inline double fcmamp(double min, double x, double max) { + return x < min ? min : x > max ? max : x; +} +static inline LC3_FLOAT fclampf(LC3_FLOAT min, LC3_FLOAT x, LC3_FLOAT max) { + return x < min ? min : x > max ? max : x; +} + +/* x² */ +static inline LC3_FLOAT sqrf(LC3_FLOAT x) { return x * x; } + +/* convenience wrappers around memmove */ +static inline void move_float(LC3_FLOAT *dst, const LC3_FLOAT *src, LC3_INT len) { +#ifdef WMOPS + LC3_INT i; + for (i = 0; i < len; i++) + { + dst[i] = src[i]; + } +#else + memmove(dst, src, len * sizeof(LC3_FLOAT)); +#endif +} +static inline void move_int(LC3_INT *dst, const LC3_INT *src, LC3_INT len) { +#ifdef WMOPS + LC3_INT i; + for (i = 0; i < len; i++) + { + dst[i] = src[i]; + } +#else + memmove(dst, src, len * sizeof(LC3_INT)); +#endif +} + +/* convenience wrappers around memset */ +static inline void zero_float(LC3_FLOAT *x, LC3_INT len) { +#ifdef WMOPS + LC3_INT i; + for (i = 0; i < len; i++) + { + x[i] = 0; + } +#else + memset(x, 0, len * sizeof(LC3_FLOAT)); +#endif +} +static inline void zero_int(LC3_INT *x, LC3_INT len) { +#ifdef WMOPS + LC3_INT i; + for (i = 0; i < len; i++) + { + x[i] = 0; + } +#else + memset(x, 0, len * sizeof(LC3_INT)); +#endif +} + +/* multiply float vectors element by element, in-place */ +static inline void mult_vec(LC3_FLOAT *a, const LC3_FLOAT *b, + LC3_INT len) { + LC3_INT i = 0; + for (i = 0; i < len; i++) { + a[i] *= b[i]; + } +} + +/* multiply float vector with constant, in-place */ +static inline void mult_const(LC3_FLOAT *a, LC3_FLOAT b, LC3_INT len) { + LC3_INT i = 0; + for (i = 0; i < len; i++) { + a[i] *= b; + } +} + +/* sum of vector */ +static inline LC3_FLOAT sum_vec(const LC3_FLOAT *x, LC3_INT len) { + LC3_FLOAT sum = 0; + LC3_INT i = 0; + for (i = 0; i < len; i++) { + sum += x[i]; + } + return sum; +} + +/* complex constructor */ +static inline Complex cmplx(LC3_FLOAT r, LC3_FLOAT i) { return (Complex){r, i}; } + +/* complex a + b */ +static inline Complex cadd(Complex a, Complex b) { + return cmplx(a.r + b.r, a.i + b.i); +} + +/* complex a * b */ +static inline Complex cmul(Complex a, Complex b) { + return cmplx(a.r * b.r - a.i * b.i, a.i * b.r + a.r * b.i); +} + +/* mac operator */ +static inline LC3_FLOAT mac_loop(const LC3_FLOAT *array1, const LC3_FLOAT *array2, LC3_INT len) +{ + LC3_INT i; + LC3_FLOAT sum = 0.0; + + for (i = 0; i < len; i++) + { + sum += (*array1++) * (*array2++); + } + + return sum; +} + +/* complex eᶦˣ */ +static inline Complex cexpi(LC3_FLOAT x) { return cmplx(LC3_COS(x), LC3_SIN(x)); } + +/* complex -x */ +static inline Complex cneg(Complex x) { return cmplx(-x.r, -x.i); } + +/* convert string to number. return true on success */ +static inline bool str_to_int(const char *str, LC3_INT *value) { + char *end = NULL; + long v = str ? strtol(str, &end, 0) : 0; + *value = (LC3_INT)v; + return str && *end == 0 && v >= INT_MIN && v <= INT_MAX; +} + +/* returns true if str ends with str ends with suffix. ignoring case. str may be + * NULL */ +static inline bool str_ends_with(const char *str, const char *suffix) { + char *tmp = str ? strrchr(str, suffix[0]) : NULL; + return tmp && !strcasecmp(tmp, suffix); +} + +/* complex a - b */ +static inline Complex csub(Complex a, Complex b) { + return cmplx(a.r - b.r, a.i - b.i); +} + +static inline void move_cmplx(Complex *dst, const Complex *src, LC3_INT32 len) { + if (len > 0) { + memmove(dst, src, len * sizeof(Complex)); + assert(src[len - 1].r == dst[len - 1].r && src[len - 1].i == dst[len - 1].i); /*check that Cmplx is stored contiguously*/ + assert(src[0].r == dst[0].r && src[0].i == dst[0].i); /*check that Cmplx is stored contiguously*/ + } +} + +static inline void zero_cmplx(Complex *x, LC3_INT32 len) { + if(len > 0) { + memset(x, 0, len * sizeof(Complex)); + assert(x[0].r == 0 && x[0].i == 0 && x[len-1].r == 0 && x[len-1].i == 0); + } +} + +static inline Complex realtoc(LC3_FLOAT r) { return cmplx(r, 0); } + +/* set float vector to constant */ +static inline void set_vec(const LC3_FLOAT c, LC3_FLOAT *x, LC3_INT32 len) { + LC3_INT32 i = 0; + for (i = 0; i < len; i++) { + x[i] = c; + } +} + +/* set float vector to constant */ +static inline void set_vec_int(const LC3_INT32 c, LC3_INT32 *x, LC3_INT32 len) { + LC3_INT32 i = 0; + for (i = 0; i < len; i++) { + x[i] = c; + } +} + +static inline LC3_INT32 clz_func(LC3_INT32 inp) +{ +#if defined(__clang__) || defined(__GNUC__) + if (inp == 0) + { + return 0; + } + return __builtin_clz(inp); + +#elif defined(_WIN32) || defined(_WIN64) + LC3_INT32 leading_zero = 0; + + if (_BitScanReverse(&leading_zero, inp)) + { + return 31 - leading_zero; + } + else + return 0; + +#else + LC3_INT32 i = 0; + int64_t x = inp; + + if (inp == 0) + { + return 0; + } + + inp = (inp < 0) ? ~inp : inp; + + while (x < (int64_t)0x80000000L) + { + inp <<= 1; + i += 1; + } + + return i; +#endif +} + + +#endif diff --git a/lib_rend/ivas_allrad_dec.c b/lib_rend/ivas_allrad_dec.c index a7d915cf0119f92822b07f5b79d9db038645cb6f..784793627d1b77309697c4878a7df3a13bd85505 100644 --- a/lib_rend/ivas_allrad_dec.c +++ b/lib_rend/ivas_allrad_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_crend.c b/lib_rend/ivas_crend.c index a17f6ecbfa77d3fb7d57aaf14ca328bb7b5cdb2f..06e91135c2fc2a92f8fd13007433e7191b229dad 100644 --- a/lib_rend/ivas_crend.c +++ b/lib_rend/ivas_crend.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other @@ -179,7 +179,11 @@ static ivas_error ivas_rend_initCrend( return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Encountered unsupported input config in Crend" ); } - if ( outConfig != IVAS_AUDIO_CONFIG_BINAURAL && outConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR && outConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) + if ( outConfig != IVAS_AUDIO_CONFIG_BINAURAL && outConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR && outConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB +#ifdef SPLIT_REND_WITH_HEAD_ROT + && outConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && outConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM +#endif + ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Encountered unsupported output type in Crend" ); } @@ -1121,10 +1125,19 @@ static ivas_error ivas_er_init_handle( *------------------------------------------------------------------------*/ ivas_error ivas_rend_initCrendWrapper( - CREND_WRAPPER_HANDLE *pCrend ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + CREND_WRAPPER_HANDLE *pCrend, + const int16_t num_poses +#else + CREND_WRAPPER_HANDLE *pCrend +#endif +) { int16_t i; CREND_HANDLE hCrend; +#ifdef SPLIT_REND_WITH_HEAD_ROT + int16_t pos_idx; +#endif if ( pCrend == NULL ) { @@ -1139,6 +1152,9 @@ ivas_error ivas_rend_initCrendWrapper( ( *pCrend )->binaural_latency_ns = 0; ( *pCrend )->hHrtfCrend = NULL; +#ifdef SPLIT_REND_WITH_HEAD_ROT + for ( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) +#endif { hCrend = NULL; if ( ( hCrend = (CREND_HANDLE) malloc( sizeof( CREND_DATA ) ) ) == NULL ) @@ -1170,13 +1186,48 @@ ivas_error ivas_rend_initCrendWrapper( hCrend->m_fPitch = 0; hCrend->m_fRoll = 0; +#ifdef SPLIT_REND_WITH_HEAD_ROT + ( *pCrend )->hCrend[pos_idx] = hCrend; +#else ( *pCrend )->hCrend = hCrend; +#endif } return IVAS_ERR_OK; } +#ifdef SPLIT_REND_WITH_HEAD_ROT +/*------------------------------------------------------------------------- + * ivas_rend_openMultiBinCrend() + * + * Allocate and initialize crend renderer handle + *------------------------------------------------------------------------*/ + +ivas_error +ivas_rend_openMultiBinCrend( + CREND_WRAPPER_HANDLE *pCrend, + const AUDIO_CONFIG inConfig, + const AUDIO_CONFIG outConfig, + const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + const int32_t output_Fs ) +{ + ivas_error error; + +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( error = ivas_rend_openCrend( pCrend, inConfig, outConfig, NULL /*hRendCfg*/, NULL, output_Fs, pMultiBinPoseData->num_poses ) ) != IVAS_ERR_OK ) +#else + if ( ( error = ivas_rend_openCrend( pCrend, inConfig, outConfig, NULL /*hRendCfg*/, NULL, output_Fs ) ) != IVAS_ERR_OK ) +#endif + { + return error; + } + + return error; +} +#endif + + /*------------------------------------------------------------------------- * ivas_rend_openCrend() * @@ -1189,17 +1240,30 @@ ivas_error ivas_rend_openCrend( const AUDIO_CONFIG outConfig, RENDER_CONFIG_DATA *hRendCfg, HRTFS_CREND_HANDLE hSetOfHRTF, - const int32_t output_Fs ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + const int32_t output_Fs, + const int16_t num_poses +#else + const int32_t output_Fs +#endif +) { int16_t i, subframe_length; int16_t max_total_ir_len; HRTFS_HANDLE hHrtf; CREND_HANDLE hCrend; ivas_error error; +#ifdef SPLIT_REND_WITH_HEAD_ROT + int16_t pos_idx; +#endif error = IVAS_ERR_OK; +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( error = ivas_rend_initCrendWrapper( pCrend, num_poses ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_rend_initCrendWrapper( pCrend ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -1214,8 +1278,15 @@ ivas_error ivas_rend_openCrend( } } +#ifdef SPLIT_REND_WITH_HEAD_ROT + for ( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) +#endif { +#ifdef SPLIT_REND_WITH_HEAD_ROT + hCrend = ( *pCrend )->hCrend[pos_idx]; +#else hCrend = ( *pCrend )->hCrend; +#endif hHrtf = ( *pCrend )->hHrtfCrend; if ( hHrtf != NULL ) @@ -1332,7 +1403,11 @@ ivas_error ivas_rend_openCrend( ( *pCrend )->binaural_latency_ns = (int32_t) ( ( *pCrend )->hHrtfCrend->latency_s * 1000000000.f ); } +#ifdef SPLIT_REND_WITH_HEAD_ROT + ( *pCrend )->hCrend[pos_idx] = hCrend; +#else ( *pCrend )->hCrend = hCrend; +#endif } return IVAS_ERR_OK; @@ -1346,9 +1421,18 @@ ivas_error ivas_rend_openCrend( *------------------------------------------------------------------------*/ void ivas_rend_closeCrend( - CREND_WRAPPER_HANDLE *pCrend ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + CREND_WRAPPER_HANDLE *pCrend, + const int16_t num_poses +#else + CREND_WRAPPER_HANDLE *pCrend +#endif +) { int16_t i; +#ifdef SPLIT_REND_WITH_HEAD_ROT + int16_t pos_idx; +#endif CREND_HANDLE hCrend; if ( pCrend == NULL || *pCrend == NULL ) @@ -1361,8 +1445,15 @@ void ivas_rend_closeCrend( ivas_hrtf_close( &( *pCrend )->hHrtfCrend ); } +#ifdef SPLIT_REND_WITH_HEAD_ROT + for ( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) +#endif { +#ifdef SPLIT_REND_WITH_HEAD_ROT + hCrend = ( *pCrend )->hCrend[pos_idx]; +#else hCrend = ( *pCrend )->hCrend; +#endif if ( hCrend != NULL ) { for ( i = 0; i < MAX_INTERN_CHANNELS; i++ ) @@ -1434,7 +1525,11 @@ void ivas_rend_closeCrend( free( hCrend ); hCrend = NULL; +#ifdef SPLIT_REND_WITH_HEAD_ROT + ( *pCrend )->hCrend[pos_idx] = hCrend; +#else ( *pCrend )->hCrend = hCrend; +#endif } } @@ -1445,6 +1540,31 @@ void ivas_rend_closeCrend( } +#ifdef SPLIT_REND_WITH_HEAD_ROT +/*------------------------------------------------------------------------- + * ivas_rend_closeCldfbRend() + * + * Close CLDFB based fastconv binaural renderer memories + *------------------------------------------------------------------------*/ + +void ivas_rend_closeCldfbRend( + CLDFB_REND_WRAPPER *pCldfbRend ) +{ + if ( pCldfbRend->hCldfbRend->hInputSetup != NULL ) + { + free( pCldfbRend->hCldfbRend->hInputSetup ); + pCldfbRend->hCldfbRend->hInputSetup = NULL; + } + + ivas_binRenderer_close( &pCldfbRend->hCldfbRend ); + ivas_binaural_hrtf_close( &pCldfbRend->hHrtfFastConv ); + ivas_HRTF_fastconv_binary_close( &pCldfbRend->hHrtfFastConv ); + + return; +} +#endif + + /*-----------------------------------------------------------------------------------------* * Function ivas_rend_crendConvolver() * @@ -1458,7 +1578,13 @@ static ivas_error ivas_rend_crendConvolver( float *pcm_in[], float *pcm_out[], const int32_t output_Fs, - const int16_t i_ts ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + const int16_t i_ts, + const int16_t pos_idx +#else + const int16_t i_ts +#endif +) { int16_t i, j, k, m; int16_t subframe_length, idx_in; @@ -1473,7 +1599,11 @@ static ivas_error ivas_rend_crendConvolver( CREND_HANDLE hCrend; ivas_error error; +#ifdef SPLIT_REND_WITH_HEAD_ROT + hCrend = pCrend->hCrend[pos_idx]; +#else hCrend = pCrend->hCrend; +#endif if ( ( error = getAudioConfigNumChannels( inConfig, &nchan_in ) ) != IVAS_ERR_OK ) { @@ -1626,7 +1756,12 @@ ivas_error ivas_rend_crendProcess( EFAP_HANDLE hEFAPdata, float *output[], /* i/o: input/output audio channels */ const int32_t output_Fs, +#ifdef SPLIT_REND_WITH_HEAD_ROT + const int16_t num_subframes /* i : number of subframes to render */, + const int16_t pos_idx +#else const int16_t num_subframes /* i : number of subframes to render */ +#endif ) { int16_t i, subframe_idx, subframe_len; @@ -1638,7 +1773,11 @@ ivas_error ivas_rend_crendProcess( ivas_error error; CREND_HANDLE hCrend; +#ifdef SPLIT_REND_WITH_HEAD_ROT + hCrend = pCrend->hCrend[pos_idx]; +#else hCrend = pCrend->hCrend; +#endif combinedOrientationEnabled = 0; if ( hCombinedOrientationData != NULL ) @@ -1703,14 +1842,22 @@ ivas_error ivas_rend_crendProcess( if ( inConfigType == IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED || inConfigType == IVAS_REND_AUDIO_CONFIG_TYPE_AMBISONICS ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( error = ivas_rend_crendConvolver( pCrend, inConfig, outConfig, output, p_pcm_tmp, output_Fs, subframe_idx, pos_idx ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_rend_crendConvolver( pCrend, inConfig, outConfig, output, p_pcm_tmp, output_Fs, subframe_idx ) ) != IVAS_ERR_OK ) +#endif { return error; } if ( hCrend->hReverb != NULL ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( error = ivas_reverb_process( pCrend->hCrend[pos_idx]->hReverb, inConfig, 1, output, p_pcm_tmp, subframe_idx ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_reverb_process( pCrend->hCrend->hReverb, inConfig, 1, output, p_pcm_tmp, subframe_idx ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -1755,6 +1902,10 @@ ivas_error ivas_rend_crendProcessSubframe( float *output[], /* i/o: input/output audio channels */ const int16_t n_samples_to_render, /* i : output frame length per channel */ const int32_t output_Fs /* i : output sampling rate */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + , + const int16_t pos_idx +#endif ) { int16_t subframe_idx, subframe_len; @@ -1767,7 +1918,11 @@ ivas_error ivas_rend_crendProcessSubframe( int8_t combinedOrientationEnabled; CREND_HANDLE hCrend; +#ifdef SPLIT_REND_WITH_HEAD_ROT + hCrend = pCrend->hCrend[pos_idx]; +#else hCrend = pCrend->hCrend; +#endif combinedOrientationEnabled = 0; if ( hCombinedOrientationData != NULL ) @@ -1801,22 +1956,35 @@ ivas_error ivas_rend_crendProcessSubframe( p_pcm_tmp[ch] = pcm_tmp[ch]; } - slot_size = hTcBuffer->n_samples_granularity; + if ( hTcBuffer != NULL ) + { + slot_size = hTcBuffer->n_samples_granularity; - /* loop for synthesis, assume we always have to render in multiples of 5ms subframes with spills */ - slots_to_render = min( hTcBuffer->num_slots - hTcBuffer->slots_rendered, n_samples_to_render / slot_size ); - first_sf = hTcBuffer->subframes_rendered; - last_sf = first_sf; + /* loop for synthesis, assume we always have to render in multiples of 5ms subframes with spills */ + slots_to_render = min( hTcBuffer->num_slots - hTcBuffer->slots_rendered, n_samples_to_render / slot_size ); + first_sf = hTcBuffer->subframes_rendered; + last_sf = first_sf; - while ( slots_to_render > 0 ) + while ( slots_to_render > 0 ) + { + slots_to_render -= hTcBuffer->subframe_nbslots[last_sf]; + last_sf++; + } + subframe_len = -1; /* will be set later */ + } + else { - slots_to_render -= hTcBuffer->subframe_nbslots[last_sf]; - last_sf++; + subframe_len = (int16_t) ( output_Fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ); + first_sf = 0; + last_sf = n_samples_to_render / subframe_len; } for ( subframe_idx = first_sf; subframe_idx < last_sf; subframe_idx++ ) { - subframe_len = hTcBuffer->subframe_nbslots[subframe_idx] * hTcBuffer->n_samples_granularity; + if ( hTcBuffer != NULL ) + { + subframe_len = hTcBuffer->subframe_nbslots[subframe_idx] * hTcBuffer->n_samples_granularity; + } /* Early Reflections */ if ( hCrend->reflections != NULL ) @@ -1849,12 +2017,25 @@ ivas_error ivas_rend_crendProcessSubframe( if ( ( inConfigType == IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED ) || ( inConfigType == IVAS_REND_AUDIO_CONFIG_TYPE_AMBISONICS ) ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( error = ivas_rend_crendConvolver( pCrend, inConfig, outConfig, tc_local, p_pcm_tmp, output_Fs, 0, pos_idx ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_rend_crendConvolver( pCrend, inConfig, outConfig, tc_local, p_pcm_tmp, output_Fs, 0 ) ) != IVAS_ERR_OK ) +#endif { return error; } +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( pCrend->hCrend[0]->hReverb != NULL ) + { + if ( ( error = ivas_reverb_process( pCrend->hCrend[pos_idx]->hReverb, inConfig, 1, tc_local, p_pcm_tmp, 0 ) ) != IVAS_ERR_OK ) + { + return error; + } + } +#else if ( pCrend->hCrend->hReverb != NULL ) { if ( ( error = ivas_reverb_process( pCrend->hCrend->hReverb, inConfig, 1, tc_local, p_pcm_tmp, 0 ) ) != IVAS_ERR_OK ) @@ -1862,6 +2043,7 @@ ivas_error ivas_rend_crendProcessSubframe( return error; } } +#endif for ( ch = 0; ch < nchan_in; ch++ ) { @@ -1871,7 +2053,11 @@ ivas_error ivas_rend_crendProcessSubframe( { p_pcm_tmp[ch] += subframe_len; } - hTcBuffer->slots_rendered += hTcBuffer->subframe_nbslots[subframe_idx]; + + if ( hTcBuffer != NULL ) + { + hTcBuffer->slots_rendered += hTcBuffer->subframe_nbslots[subframe_idx]; + } } else { @@ -1888,8 +2074,317 @@ ivas_error ivas_rend_crendProcessSubframe( mvr2r( pcm_tmp[ch], output[ch], n_samples_to_render ); } - hTcBuffer->subframes_rendered = last_sf; + if ( hTcBuffer != NULL ) + { + hTcBuffer->subframes_rendered = last_sf; + } + pop_wmops(); return IVAS_ERR_OK; } + + +#ifdef SPLIT_REND_WITH_HEAD_ROT +/*-----------------------------------------------------------------------------------------* + * Function ivas_rend_crend_ProcessSplitBin() + * + * Process call for IVAS Crend renderer + *-----------------------------------------------------------------------------------------*/ + +ivas_error +ivas_rend_crendProcessSplitBin( + const CREND_WRAPPER *pCrend, + const AUDIO_CONFIG inConfig, + const AUDIO_CONFIG outConfig, + const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + const DECODER_CONFIG_HANDLE hDecoderConfig, + const COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, + const IVAS_OUTPUT_SETUP_HANDLE hIntSetup, + EFAP_HANDLE hEFAPdata, + float *output[], + const int32_t output_Fs ) +{ + int16_t i, j; + int16_t sf; + int16_t pos_idx, output_frame; + ivas_error error; + float gain_lfe; + float tmpLfeBuffer[L_FRAME48k]; + float tmpInputBuffer[MAX_OUTPUT_CHANNELS][L_FRAME48k]; + float *p_tmpInputBuffer[MAX_OUTPUT_CHANNELS]; + float tmpSplitBinBuffer[MAX_OUTPUT_CHANNELS][L_FRAME48k]; + COMBINED_ORIENTATION_DATA combinedOrientationDataLocal; + COMBINED_ORIENTATION_HANDLE pCombinedOrientationDataLocal; + + output_frame = (int16_t) ( output_Fs / FRAMES_PER_SEC ); + + /* copy input */ + for ( i = 0; i < hIntSetup->nchan_out_woLFE; ++i ) + { + mvr2r( output[i], tmpInputBuffer[i], output_frame ); + } + + for ( i = 0; i < MAX_OUTPUT_CHANNELS; ++i ) + { + p_tmpInputBuffer[i] = tmpInputBuffer[i]; + } + + /* save current head positions */ + pCombinedOrientationDataLocal = hCombinedOrientationData; + combinedOrientationDataLocal = *pCombinedOrientationDataLocal; + if ( pMultiBinPoseData->poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) + { + for ( sf = 1; sf < hCombinedOrientationData->num_subframes; ++sf ) + { + combinedOrientationDataLocal.Quaternions[sf] = combinedOrientationDataLocal.Quaternions[0]; + for ( i = 0; i < 3; i++ ) + { + for ( j = 0; j < 3; j++ ) + { + combinedOrientationDataLocal.Rmat[sf][i][j] = combinedOrientationDataLocal.Rmat[0][i][j]; + } + } + } + } + + /* copy LFE to tmpLfeBuffer and apply gain only once */ + if ( hIntSetup->num_lfe > 0 && hIntSetup->index_lfe[0] != -1 ) + { + mvr2r( output[hIntSetup->index_lfe[0]], tmpLfeBuffer, output_frame ); + gain_lfe = ( ( pCrend != NULL ) && ( pCrend->hHrtfCrend != NULL ) ) ? pCrend->hHrtfCrend->gain_lfe : GAIN_LFE; + v_multc( tmpLfeBuffer, gain_lfe, tmpLfeBuffer, output_frame ); + } + else + { + set_zero( tmpLfeBuffer, output_frame ); + } + + for ( pos_idx = 0; pos_idx < pMultiBinPoseData->num_poses; ++pos_idx ) + { + /* Update head positions */ + + IVAS_QUATERNION Quaternions_orig[MAX_PARAM_SPATIAL_SUBFRAMES], Quaternions_abs; + for ( i = 0; i < hCombinedOrientationData->num_subframes; i++ ) + { + Quaternions_orig[i] = combinedOrientationDataLocal.Quaternions[i]; + Quaternions_abs.w = -3.0f; + Quat2EulerDegree( combinedOrientationDataLocal.Quaternions[i], &Quaternions_abs.z, &Quaternions_abs.y, &Quaternions_abs.x ); /*order in Quat2Euler seems to be reversed ?*/ + + Quaternions_abs.x += pMultiBinPoseData->relative_head_poses[pos_idx][0]; + Quaternions_abs.y += pMultiBinPoseData->relative_head_poses[pos_idx][1]; + Quaternions_abs.z += pMultiBinPoseData->relative_head_poses[pos_idx][2]; + combinedOrientationDataLocal.Quaternions[i] = Quaternions_abs; + QuatToRotMat( combinedOrientationDataLocal.Quaternions[i], combinedOrientationDataLocal.Rmat[i] ); + } + + + /* render inplace to first two channels of tmpInputBuffer */ + pCombinedOrientationDataLocal = &combinedOrientationDataLocal; + + for ( i = 0; i < 3; i++ ) + { + mvr2r( hCombinedOrientationData->Rmat_prev[pos_idx][i], pCombinedOrientationDataLocal->Rmat_prev[0][i], 3 ); + } + + if ( ( error = ivas_rend_crendProcessSubframe( pCrend, inConfig, outConfig, hDecoderConfig, pCombinedOrientationDataLocal, hIntSetup, hEFAPdata, + NULL, p_tmpInputBuffer, p_tmpInputBuffer, output_frame, output_Fs, pos_idx ) ) != IVAS_ERR_OK ) + { + return error; + } + + for ( i = 0; i < 3; i++ ) + { + mvr2r( pCombinedOrientationDataLocal->Rmat_prev[0][i], hCombinedOrientationData->Rmat_prev[pos_idx][i], 3 ); + } + + for ( i = 0; i < BINAURAL_CHANNELS; ++i ) + { + /* accumulate LFE to output */ + v_add( tmpInputBuffer[i], tmpLfeBuffer, tmpInputBuffer[i], output_frame ); + + /* move to split bin output buffer */ + mvr2r( tmpInputBuffer[i], tmpSplitBinBuffer[pos_idx * BINAURAL_CHANNELS + i], output_frame ); + } + + /* overwrite rendered channels with input again for next iteration */ + for ( i = 0; i < hIntSetup->nchan_out_woLFE; ++i ) + { + mvr2r( output[i], tmpInputBuffer[i], output_frame ); + } + + /* restore original headrotation data */ + for ( i = 0; i < hCombinedOrientationData->num_subframes; i++ ) + { + combinedOrientationDataLocal.Quaternions[i] = Quaternions_orig[i]; + } + } + + /* copy split binaural rendered signals to final output */ + for ( i = 0; i < BINAURAL_CHANNELS * pMultiBinPoseData->num_poses; ++i ) + { + mvr2r( tmpSplitBinBuffer[i], output[i], output_frame ); + } + + return IVAS_ERR_OK; +} + + +/*-----------------------------------------------------------------------------------------* + * Function ivas_rend_crend_ProcessSubframesSplitBin() + * + * Process call for IVAS Crend renderer + *-----------------------------------------------------------------------------------------*/ + +ivas_error ivas_rend_crendProcessSubframesSplitBin( + const CREND_WRAPPER *pCrend, /* i/o: Crend wrapper handle */ + const AUDIO_CONFIG inConfig, /* i : input audio configuration */ + const AUDIO_CONFIG outConfig, /* i : output audio configuration */ + const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + const DECODER_CONFIG_HANDLE hDecoderConfig, /* i : decoder config. structure */ + const COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined orientation handle */ + const IVAS_OUTPUT_SETUP_HANDLE hIntSetup, /* i : internal setup handle */ + const EFAP_HANDLE hEFAPdata, /* i : EFAP handle */ + DECODER_TC_BUFFER_HANDLE hTcBuffer, /* i/o: JBM handle */ + float *input_f[], /* i : transport channels */ + float *output[], /* i/o: input/output audio channels */ + const int16_t n_samples_to_render, /* i : output frame length per channel */ + const int32_t output_Fs /* i : output sampling rate */ +) +{ + int16_t i, j; + int16_t sf; + int16_t pos_idx; + ivas_error error; + float gain_lfe; + float tmpLfeBuffer[L_FRAME48k]; + int16_t original_subframes_rendered, original_slots_rendered; + float tmpInputBuffer[MAX_OUTPUT_CHANNELS][L_FRAME48k]; + float *p_tmpInputBuffer[MAX_OUTPUT_CHANNELS]; + float tmpSplitBinBuffer[MAX_OUTPUT_CHANNELS][L_FRAME48k]; + + COMBINED_ORIENTATION_DATA combinedOrientationDataLocal; + COMBINED_ORIENTATION_HANDLE pCombinedOrientationDataLocal; + + /* save current head positions */ + pCombinedOrientationDataLocal = hCombinedOrientationData; + combinedOrientationDataLocal = *pCombinedOrientationDataLocal; + original_subframes_rendered = hTcBuffer->subframes_rendered; + original_slots_rendered = hTcBuffer->slots_rendered; + + /* copy input */ + for ( i = 0; i < hIntSetup->nchan_out_woLFE; ++i ) + { + mvr2r( input_f[i], tmpInputBuffer[i], n_samples_to_render ); + } + + for ( i = 0; i < MAX_OUTPUT_CHANNELS; ++i ) + { + p_tmpInputBuffer[i] = tmpInputBuffer[i]; + } + + /* save current head positions */ + pCombinedOrientationDataLocal = hCombinedOrientationData; + combinedOrientationDataLocal = *pCombinedOrientationDataLocal; + if ( pMultiBinPoseData->poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) + { + for ( sf = 1; sf < hCombinedOrientationData->num_subframes; ++sf ) + { + combinedOrientationDataLocal.Quaternions[sf] = combinedOrientationDataLocal.Quaternions[0]; + for ( i = 0; i < 3; i++ ) + { + for ( j = 0; j < 3; j++ ) + { + combinedOrientationDataLocal.Rmat[sf][i][j] = combinedOrientationDataLocal.Rmat[0][i][j]; + } + } + } + } + + /* copy LFE to tmpLfeBuffer and apply gain only once */ + if ( hIntSetup->num_lfe > 0 && hIntSetup->index_lfe[0] != -1 ) + { + mvr2r( output[hIntSetup->index_lfe[0]], tmpLfeBuffer, n_samples_to_render ); + gain_lfe = ( ( pCrend != NULL ) && ( pCrend->hHrtfCrend != NULL ) ) ? pCrend->hHrtfCrend->gain_lfe : GAIN_LFE; + v_multc( tmpLfeBuffer, gain_lfe, tmpLfeBuffer, n_samples_to_render ); + } + else + { + set_zero( tmpLfeBuffer, n_samples_to_render ); + } + + for ( pos_idx = 0; pos_idx < pMultiBinPoseData->num_poses; ++pos_idx ) + { + /* Update head positions */ + IVAS_QUATERNION Quaternions_orig[MAX_PARAM_SPATIAL_SUBFRAMES], Quaternions_abs; + for ( i = 0; i < hCombinedOrientationData->num_subframes; i++ ) + { + Quaternions_orig[i] = combinedOrientationDataLocal.Quaternions[i]; + Quaternions_abs.w = -3.0f; + Quat2EulerDegree( combinedOrientationDataLocal.Quaternions[i], &Quaternions_abs.z, &Quaternions_abs.y, &Quaternions_abs.x ); /*order in Quat2Euler seems to be reversed ?*/ + + Quaternions_abs.x += pMultiBinPoseData->relative_head_poses[pos_idx][0]; + Quaternions_abs.y += pMultiBinPoseData->relative_head_poses[pos_idx][1]; + Quaternions_abs.z += pMultiBinPoseData->relative_head_poses[pos_idx][2]; + combinedOrientationDataLocal.Quaternions[i] = Quaternions_abs; + QuatToRotMat( combinedOrientationDataLocal.Quaternions[i], combinedOrientationDataLocal.Rmat[i] ); + } + + pCombinedOrientationDataLocal = &combinedOrientationDataLocal; + + hTcBuffer->subframes_rendered = original_subframes_rendered; + hTcBuffer->slots_rendered = original_slots_rendered; + + /* update combined orientation access index */ + ivas_combined_orientation_set_to_start_index( pCombinedOrientationDataLocal ); + + for ( i = 0; i < 3; i++ ) + { + mvr2r( hCombinedOrientationData->Rmat_prev[pos_idx][i], pCombinedOrientationDataLocal->Rmat_prev[0][i], 3 ); + } + + if ( ( error = ivas_rend_crendProcessSubframe( pCrend, inConfig, outConfig, hDecoderConfig, pCombinedOrientationDataLocal, + hIntSetup, hEFAPdata, hTcBuffer, p_tmpInputBuffer, p_tmpInputBuffer, n_samples_to_render, output_Fs, pos_idx ) ) != IVAS_ERR_OK ) + { + return error; + } + + for ( i = 0; i < 3; i++ ) + { + mvr2r( pCombinedOrientationDataLocal->Rmat_prev[0][i], hCombinedOrientationData->Rmat_prev[pos_idx][i], 3 ); + } + + for ( i = 0; i < BINAURAL_CHANNELS; ++i ) + { + /* accumulate LFE to output */ + v_add( tmpInputBuffer[i], tmpLfeBuffer, tmpInputBuffer[i], n_samples_to_render ); + + /* move to split bin output buffer */ + mvr2r( tmpInputBuffer[i], tmpSplitBinBuffer[pos_idx * BINAURAL_CHANNELS + i], n_samples_to_render ); + } + + /* overwrite rendered channels with input again for next iteration */ + for ( i = 0; i < hIntSetup->nchan_out_woLFE; ++i ) + { + mvr2r( input_f[i], tmpInputBuffer[i], n_samples_to_render ); + } + + /* restore original headrotation data */ + for ( i = 0; i < hCombinedOrientationData->num_subframes; i++ ) + { + combinedOrientationDataLocal.Quaternions[i] = Quaternions_orig[i]; + } + } + + /* copy split binaural rendered signals to final output */ + for ( i = 0; i < BINAURAL_CHANNELS * pMultiBinPoseData->num_poses; ++i ) + { + mvr2r( tmpSplitBinBuffer[i], output[i], n_samples_to_render ); + } + + /* update main combined orientation access index */ + ivas_combined_orientation_update_index( hCombinedOrientationData, n_samples_to_render ); + + return IVAS_ERR_OK; +} +#endif diff --git a/lib_rend/ivas_dirac_ana.c b/lib_rend/ivas_dirac_ana.c index 2391d7cfac42fc5de7d549d0b369efb067d39288..f6273106de5b51828202c0d4b1704c2c95f34725 100644 --- a/lib_rend/ivas_dirac_ana.c +++ b/lib_rend/ivas_dirac_ana.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index f3fa0a604f6d4c47ef9cefdb7b8511b0260d1d8e..21a171c69649533761bdecaabd63eb4c8382ca30 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other @@ -98,11 +98,21 @@ static void ivas_dirac_dec_binaural_internal( Decoder_Struct *st_ivas, COMBINED_ static void ivas_dirac_dec_decorrelate_slot( DIRAC_DEC_BIN_HANDLE hDiracDecBin, const int16_t num_freq_bands, const int16_t slot, float inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float decRe[][CLDFB_NO_CHANNELS_MAX], float decIm[][CLDFB_NO_CHANNELS_MAX] ); +#ifdef SPLIT_REND_WITH_HEAD_ROT +static void ivas_dirac_dec_binaural_formulate_input_covariance_matrices( DIRAC_DEC_BIN_HANDLE hDiracDecBin, const SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, const PARAMBIN_REND_CONFIG_HANDLE hConfig, float inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], const int16_t subframe, float *subFrameTotalEne, float *IIReneLimiter ); + +static void ivas_dirac_dec_binaural_formulate_target_covariance_matrices( DIRAC_DEC_BIN_HANDLE hDiracDecBin, const SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, const PARAMBIN_REND_CONFIG_HANDLE hConfig, float Rmat[3][3], const int16_t subframe, const int16_t isHeadtracked, const float *subFrameTotalEne, const float *IIReneLimiter, const MASA_ISM_DATA_HANDLE hMasaIsmData ); +#else static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matrices( DIRAC_DEC_BIN_HANDLE hDiracDecBin, SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, PARAMBIN_REND_CONFIG_HANDLE hConfig, float inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float Rmat[3][3], const int16_t subframe, const int16_t isHeadtracked, const MASA_ISM_DATA_HANDLE hMasaIsmData ); +#endif static void ivas_dirac_dec_binaural_determine_processing_matrices( DIRAC_DEC_BIN_HANDLE hDiracDecBin, SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, PARAMBIN_REND_CONFIG_HANDLE hConfig, const int16_t max_band_decorr, float Rmat[3][3], const int16_t subframe, const int16_t isHeadtracked, const int16_t nchanSeparateChannels, const MASA_ISM_DATA_HANDLE hMasaIsmData ); +#ifdef SPLIT_REND_WITH_HEAD_ROT +static void ivas_dirac_dec_binaural_process_output( DIRAC_DEC_BIN_HANDLE hDiracDecBin, SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, HANDLE_CLDFB_FILTER_BANK cldfbSynDec[MAX_OUTPUT_CHANNELS], float *output_f[], float inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], const int16_t max_band_decorr, const int16_t numInChannels, const int16_t processReverb, const int16_t subframe, float outRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float outIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float reverbRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float reverbIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float decorrRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float decorrIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], const uint8_t recompute ); +#else static void ivas_dirac_dec_binaural_process_output( DIRAC_DEC_BIN_HANDLE hDiracDecBin, SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, HANDLE_CLDFB_FILTER_BANK cldfbSynDec[MAX_OUTPUT_CHANNELS], float *output_f[], float inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], const int16_t max_band_decorr, const int16_t numInChannels, const int16_t processReverb, const int16_t subframe ); +#endif static void adaptTransportSignalsHeadtracked( COMBINED_ORIENTATION_HANDLE hHeadTrackData, float inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], const int16_t nBins, const int16_t nSlots, float Rmat[3][3] ); @@ -118,7 +128,11 @@ static void matrixMul( float Are[BINAURAL_CHANNELS][BINAURAL_CHANNELS], float Ai static void matrixTransp2Mul( float Are[BINAURAL_CHANNELS][BINAURAL_CHANNELS], float Aim[BINAURAL_CHANNELS][BINAURAL_CHANNELS], float Bre[BINAURAL_CHANNELS][BINAURAL_CHANNELS], float Bim[BINAURAL_CHANNELS][BINAURAL_CHANNELS], float outRe[BINAURAL_CHANNELS][BINAURAL_CHANNELS], float outIm[BINAURAL_CHANNELS][BINAURAL_CHANNELS] ); +#ifdef SPLIT_REND_WITH_HEAD_ROT +static void ivas_masa_ext_rend_parambin_internal( MASA_EXT_REND_HANDLE hMasaExtRend, COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, float *output_f[], const int16_t subframe, const SPLIT_REND_WRAPPER *hSplitRendWrapper, float Cldfb_Out_Real[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], float Cldfb_Out_Imag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX] ); +#else static void ivas_masa_ext_rend_parambin_internal( MASA_EXT_REND_HANDLE hMasaExtRend, COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, float *output_f[], const int16_t subframe ); +#endif /*------------------------------------------------------------------------- * ivas_dirac_dec_init_binaural_data() @@ -139,136 +153,170 @@ ivas_error ivas_dirac_dec_init_binaural_data( float binCenterFreq, tmpFloat; ivas_error error; float frequency_axis[CLDFB_NO_CHANNELS_MAX]; - hDiracDecBin = st_ivas->hDiracDecBin; +#ifdef SPLIT_REND_WITH_HEAD_ROT + int16_t num_poses, pos_idx; - if ( hDiracDecBin == NULL ) + num_poses = 1; + if ( st_ivas->hSplitBinRend != NULL ) { - if ( ( hDiracDecBin = (DIRAC_DEC_BIN_HANDLE) malloc( sizeof( DIRAC_DEC_BIN_DATA ) ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC binaural handle " ); - } - - hDiracDecBin->hTdDecorr = NULL; - hDiracDecBin->hReverb = NULL; - hDiracDecBin->h_freq_domain_decorr_ap_params = NULL; - hDiracDecBin->h_freq_domain_decorr_ap_state = NULL; + num_poses = st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses; } - output_Fs = st_ivas->hDecoderConfig->output_Fs; - nBins = st_ivas->hSpatParamRendCom->num_freq_bands; - renderer_type = st_ivas->renderer_type; - - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) + for ( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) { - for ( k = 0; k < BINAURAL_CHANNELS + MAX_NUM_OBJECTS; k++ ) - { - set_zero( hDiracDecBin->processMtxRe[j][k], nBins ); - set_zero( hDiracDecBin->processMtxIm[j][k], nBins ); - } + hDiracDecBin = st_ivas->hDiracDecBin[pos_idx]; +#else + hDiracDecBin = st_ivas->hDiracDecBin; +#endif - for ( k = 0; k < BINAURAL_CHANNELS; k++ ) + if ( hDiracDecBin == NULL ) { - set_zero( hDiracDecBin->processMtxDecRe[j][k], nBins ); - set_zero( hDiracDecBin->processMtxDecIm[j][k], nBins ); + if ( ( hDiracDecBin = (DIRAC_DEC_BIN_HANDLE) malloc( sizeof( DIRAC_DEC_BIN_DATA ) ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC binaural handle " ); + } + + hDiracDecBin->hTdDecorr = NULL; + hDiracDecBin->hReverb = NULL; + hDiracDecBin->h_freq_domain_decorr_ap_params = NULL; + hDiracDecBin->h_freq_domain_decorr_ap_state = NULL; } - set_zero( hDiracDecBin->ChEnePrev[j], nBins ); - set_zero( hDiracDecBin->ChEneOutPrev[j], nBins ); - } - set_zero( hDiracDecBin->ChCrossRePrev, nBins ); - set_zero( hDiracDecBin->ChCrossImPrev, nBins ); - set_zero( hDiracDecBin->ChCrossReOutPrev, nBins ); - set_zero( hDiracDecBin->ChCrossImOutPrev, nBins ); - hDiracDecBin->renderStereoOutputInsteadOfBinaural = 0; + output_Fs = st_ivas->hDecoderConfig->output_Fs; + nBins = st_ivas->hSpatParamRendCom->num_freq_bands; + renderer_type = st_ivas->renderer_type; - for ( bin = 0; bin < nBins; bin++ ) - { - binCenterFreq = ( (float) bin + CLDFB_HALF_BIN_FREQUENCY_OFFSET ) / (float) nBins * ( (float) output_Fs / 2.0f ); - /* These formulas and values are from Christian Borss's publication for binaural diffuse field coherence */ - tmpFloat = max( 0.0f, 1.0f - binCenterFreq / 2700.0f ); - hDiracDecBin->diffuseFieldCoherence[bin] = tmpFloat * sinf( binCenterFreq * EVS_PI / 550.0f ) / ( binCenterFreq * EVS_PI / 550.0f ); - } + for ( j = 0; j < BINAURAL_CHANNELS; j++ ) + { + for ( k = 0; k < BINAURAL_CHANNELS + MAX_NUM_OBJECTS; k++ ) + { + set_zero( hDiracDecBin->processMtxRe[j][k], nBins ); + set_zero( hDiracDecBin->processMtxIm[j][k], nBins ); + } - for ( bin = 0; bin < BINAURAL_COHERENCE_DIFFERENCE_BINS; bin++ ) - { - hDiracDecBin->diffuseFieldCoherenceX[bin] = hDiracDecBin->diffuseFieldCoherence[bin] + diffuseFieldCoherenceDifferenceX[bin]; - hDiracDecBin->diffuseFieldCoherenceY[bin] = hDiracDecBin->diffuseFieldCoherence[bin] + diffuseFieldCoherenceDifferenceY[bin]; - hDiracDecBin->diffuseFieldCoherenceZ[bin] = hDiracDecBin->diffuseFieldCoherence[bin] + diffuseFieldCoherenceDifferenceZ[bin]; - } + for ( k = 0; k < BINAURAL_CHANNELS; k++ ) + { + set_zero( hDiracDecBin->processMtxDecRe[j][k], nBins ); + set_zero( hDiracDecBin->processMtxDecIm[j][k], nBins ); + } + set_zero( hDiracDecBin->ChEnePrev[j], nBins ); + set_zero( hDiracDecBin->ChEneOutPrev[j], nBins ); + } + set_zero( hDiracDecBin->ChCrossRePrev, nBins ); + set_zero( hDiracDecBin->ChCrossImPrev, nBins ); + set_zero( hDiracDecBin->ChCrossReOutPrev, nBins ); + set_zero( hDiracDecBin->ChCrossImOutPrev, nBins ); + hDiracDecBin->renderStereoOutputInsteadOfBinaural = 0; - if ( renderer_type == RENDERER_BINAURAL_PARAMETRIC ) /* Indication of binaural rendering without room effect */ - { - set_f( hDiracDecBin->earlyPartEneCorrection, 1.0f, CLDFB_NO_CHANNELS_MAX ); - hDiracDecBin->hReverb = NULL; - } - else if ( renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) /* Indication of binaural rendering with room effect */ - { - mvr2r( hHrtfParambin->parametricEarlyPartEneCorrection, hDiracDecBin->earlyPartEneCorrection, nBins ); - /* reconfiguration needed when Reverb. parameters are changed -> close and open the handle again */ - if ( hDiracDecBin->hReverb != NULL && ( ( hDiracDecBin->hReverb->numBins != nBins ) || - ( hDiracDecBin->hReverb->blockSize != CLDFB_SLOTS_PER_SUBFRAME ) ) ) + for ( bin = 0; bin < nBins; bin++ ) + { + binCenterFreq = ( (float) bin + CLDFB_HALF_BIN_FREQUENCY_OFFSET ) / (float) nBins * ( (float) output_Fs / 2.0f ); + /* These formulas and values are from Christian Borss's publication for binaural diffuse field coherence */ + tmpFloat = max( 0.0f, 1.0f - binCenterFreq / 2700.0f ); + hDiracDecBin->diffuseFieldCoherence[bin] = tmpFloat * sinf( binCenterFreq * EVS_PI / 550.0f ) / ( binCenterFreq * EVS_PI / 550.0f ); + } + + for ( bin = 0; bin < BINAURAL_COHERENCE_DIFFERENCE_BINS; bin++ ) { - ivas_binaural_reverb_close( &( hDiracDecBin->hReverb ) ); + hDiracDecBin->diffuseFieldCoherenceX[bin] = hDiracDecBin->diffuseFieldCoherence[bin] + diffuseFieldCoherenceDifferenceX[bin]; + hDiracDecBin->diffuseFieldCoherenceY[bin] = hDiracDecBin->diffuseFieldCoherence[bin] + diffuseFieldCoherenceDifferenceY[bin]; + hDiracDecBin->diffuseFieldCoherenceZ[bin] = hDiracDecBin->diffuseFieldCoherence[bin] + diffuseFieldCoherenceDifferenceZ[bin]; } - if ( hDiracDecBin->hReverb == NULL ) + if ( renderer_type == RENDERER_BINAURAL_PARAMETRIC ) /* Indication of binaural rendering without room effect */ + { + set_f( hDiracDecBin->earlyPartEneCorrection, 1.0f, CLDFB_NO_CHANNELS_MAX ); + hDiracDecBin->hReverb = NULL; + } + else if ( renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) /* Indication of binaural rendering with room effect */ { - /* Todo Philips: Room acoustics should be passed here once the underlying part works. Probably enough to pick it from st_ivas but you know best. */ - if ( ( error = ivas_binaural_reverb_open_parambin( &hDiracDecBin->hReverb, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, NULL, output_Fs, st_ivas->hHrtfParambin ) ) != IVAS_ERR_OK ) + mvr2r( hHrtfParambin->parametricEarlyPartEneCorrection, hDiracDecBin->earlyPartEneCorrection, nBins ); + + /* reconfiguration needed when Reverb. parameters are changed -> close and open the handle again */ + if ( hDiracDecBin->hReverb != NULL && ( ( hDiracDecBin->hReverb->numBins != nBins ) || + ( hDiracDecBin->hReverb->blockSize != CLDFB_SLOTS_PER_SUBFRAME ) ) ) { - return error; + ivas_binaural_reverb_close( &( hDiracDecBin->hReverb ) ); + } + + if ( hDiracDecBin->hReverb == NULL +#ifdef SPLIT_REND_WITH_HEAD_ROT + && pos_idx == 0 +#endif + ) /* open reverb only for the main direction */ + { + /* Todo Philips: Room acoustics should be passed here once the underlying part works. Probably enough to pick it from st_ivas but you know best. */ + if ( ( error = ivas_binaural_reverb_open_parambin( &hDiracDecBin->hReverb, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, NULL, output_Fs, st_ivas->hHrtfParambin ) ) != IVAS_ERR_OK ) + { + return error; + } } } - } - else if ( renderer_type == RENDERER_STEREO_PARAMETRIC ) - { - set_f( hDiracDecBin->earlyPartEneCorrection, 1.0f, CLDFB_NO_CHANNELS_MAX ); - hDiracDecBin->hReverb = NULL; - hDiracDecBin->renderStereoOutputInsteadOfBinaural = 1; - } - else /* Not valid renderer type for this renderer */ - { - assert( false ); - } + else if ( renderer_type == RENDERER_STEREO_PARAMETRIC ) + { + set_f( hDiracDecBin->earlyPartEneCorrection, 1.0f, CLDFB_NO_CHANNELS_MAX ); + hDiracDecBin->hReverb = NULL; + hDiracDecBin->renderStereoOutputInsteadOfBinaural = 1; + } + else /* Not valid renderer type for this renderer */ + { + assert( false ); + } - hDiracDecBin->hDiffuseDist = NULL; /* Memory is allocated from stack during runtime when needed */ + hDiracDecBin->hDiffuseDist = NULL; /* Memory is allocated from stack during runtime when needed */ - if ( hDiracDecBin->hTdDecorr == NULL ) - { - hDiracDecBin->useTdDecorr = 0; - } + if ( hDiracDecBin->hTdDecorr == NULL ) + { + hDiracDecBin->useTdDecorr = 0; + } - if ( hDiracDecBin->h_freq_domain_decorr_ap_params != NULL ) - { - ivas_dirac_dec_decorr_close( &hDiracDecBin->h_freq_domain_decorr_ap_params, &hDiracDecBin->h_freq_domain_decorr_ap_state ); - } + if ( hDiracDecBin->h_freq_domain_decorr_ap_params != NULL ) + { + ivas_dirac_dec_decorr_close( &hDiracDecBin->h_freq_domain_decorr_ap_params, &hDiracDecBin->h_freq_domain_decorr_ap_state ); + } - if ( ( error = ivas_td_decorr_reconfig_dec( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hDecoderConfig->output_Fs, &( hDiracDecBin->hTdDecorr ), &( hDiracDecBin->useTdDecorr ) ) ) != IVAS_ERR_OK ) - { - return error; - } +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( pos_idx == 0 ) /* open decorrelator only for the main direction */ + { +#endif + if ( ( error = ivas_td_decorr_reconfig_dec( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hDecoderConfig->output_Fs, &( hDiracDecBin->hTdDecorr ), &( hDiracDecBin->useTdDecorr ) ) ) != IVAS_ERR_OK ) + { + return error; + } - if ( !hDiracDecBin->useTdDecorr && !( st_ivas->ivas_format == ISM_FORMAT && st_ivas->ism_mode == ISM_MODE_PARAM ) ) - { - ivas_dirac_dec_get_frequency_axis( frequency_axis, output_Fs, nBins ); - if ( ( error = ivas_dirac_dec_decorr_open( &( hDiracDecBin->h_freq_domain_decorr_ap_params ), - &( hDiracDecBin->h_freq_domain_decorr_ap_state ), - nBins, - BINAURAL_CHANNELS, - BINAURAL_CHANNELS, - DIRAC_SYNTHESIS_PSD_LS, - frequency_axis, - BINAURAL_CHANNELS, - output_Fs ) ) != IVAS_ERR_OK ) + if ( !hDiracDecBin->useTdDecorr && !( st_ivas->ivas_format == ISM_FORMAT && st_ivas->ism_mode == ISM_MODE_PARAM ) ) + { + ivas_dirac_dec_get_frequency_axis( frequency_axis, output_Fs, nBins ); + if ( ( error = ivas_dirac_dec_decorr_open( &( hDiracDecBin->h_freq_domain_decorr_ap_params ), + &( hDiracDecBin->h_freq_domain_decorr_ap_state ), + nBins, + BINAURAL_CHANNELS, + BINAURAL_CHANNELS, + DIRAC_SYNTHESIS_PSD_LS, + frequency_axis, + BINAURAL_CHANNELS, + output_Fs ) ) != IVAS_ERR_OK ) + { + return error; + } + } +#ifdef SPLIT_REND_WITH_HEAD_ROT + } + else { - return error; + hDiracDecBin->useTdDecorr = st_ivas->hDiracDecBin[0]->useTdDecorr; /* copy the flag, but the implementation re-uses the decorrelated signal */ } - } +#endif - hDiracDecBin->reqularizationFactor = configure_reqularization_factor( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate ); + hDiracDecBin->reqularizationFactor = configure_reqularization_factor( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate ); +#ifdef SPLIT_REND_WITH_HEAD_ROT + st_ivas->hDiracDecBin[pos_idx] = hDiracDecBin; + } +#else st_ivas->hDiracDecBin = hDiracDecBin; +#endif /* allocate transport channels */ if ( st_ivas->hTcBuffer == NULL ) @@ -307,12 +355,37 @@ void ivas_dirac_dec_close_binaural_data( DIRAC_DEC_BIN_HANDLE *hBinaural /* i/o: decoder DirAC binaural data handle */ ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT + int16_t pos_idx; +#endif if ( hBinaural == NULL || *hBinaural == NULL ) { return; } +#ifdef SPLIT_REND_WITH_HEAD_ROT + for ( pos_idx = 0; pos_idx < MAX_HEAD_ROT_POSES; pos_idx++ ) + { + if ( hBinaural[pos_idx] != NULL ) + { + if ( hBinaural[pos_idx]->hReverb != NULL ) + { + ivas_binaural_reverb_close( &( hBinaural[pos_idx]->hReverb ) ); + } + + ivas_td_decorr_dec_close( &( hBinaural[pos_idx]->hTdDecorr ) ); + + if ( hBinaural[pos_idx]->h_freq_domain_decorr_ap_params != NULL ) + { + ivas_dirac_dec_decorr_close( &( hBinaural[pos_idx]->h_freq_domain_decorr_ap_params ), &( hBinaural[pos_idx]->h_freq_domain_decorr_ap_state ) ); + } + + free( hBinaural[pos_idx] ); + hBinaural[pos_idx] = NULL; + } + } +#else if ( ( *hBinaural )->hReverb != NULL ) { ivas_binaural_reverb_close( &( ( *hBinaural )->hReverb ) ); @@ -326,6 +399,7 @@ void ivas_dirac_dec_close_binaural_data( free( *hBinaural ); *hBinaural = NULL; +#endif return; } @@ -515,7 +589,23 @@ static void ivas_dirac_dec_binaural_internal( DIFFUSE_DISTRIBUTION_DATA diffuseDistData; int16_t nBins, offsetSamples; int16_t i, j; +#ifdef SPLIT_REND_WITH_HEAD_ROT + int16_t pos_idx; + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData; + float tmp_Cldfb_out_re[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; + float tmp_Cldfb_out_im[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; + /* these allow re-using the reverb and freq-domain decorrelator signals from ivas_dirac_dec_binaural_process_output() in split rendering for the side renderings */ + float reverbRe[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; + float reverbIm[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; + float decorrRe[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; + float decorrIm[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; + float subFrameTotalEne[CLDFB_NO_CHANNELS_MAX]; + float IIReneLimiter[CLDFB_NO_CHANNELS_MAX]; + + hDiracDecBin = st_ivas->hDiracDecBin[0]; +#else hDiracDecBin = st_ivas->hDiracDecBin; +#endif assert( hDiracDecBin ); hSpatParamRendCom = st_ivas->hSpatParamRendCom; nBins = hSpatParamRendCom->num_freq_bands; @@ -657,136 +747,765 @@ static void ivas_dirac_dec_binaural_internal( v_multc( Cldfb_ImagBuffer_in[ch][slot], INV_SQRT_2, Cldfb_ImagBuffer_in[ch][slot], nBins ); } } - } - } + } + } + + if ( config_data.ivas_format == SBA_FORMAT || config_data.ivas_format == SBA_ISM_FORMAT ) + { + hDiracDecBin->hDiffuseDist = &diffuseDistData; + + ivas_spar_param_to_masa_param_mapping( st_ivas, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, subframe ); + ivas_sba_prototype_renderer( st_ivas, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, subframe ); + } + + if ( st_ivas->ivas_format == MASA_ISM_FORMAT && nchan_transport == 2 && st_ivas->ism_mode != ISM_MASA_MODE_DISC && st_ivas->ism_mode != ISM_MASA_MODE_MASA_ONE_OBJ ) + { + ivas_omasa_preProcessStereoTransportsForMovedObjects( st_ivas, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, nBins, subframe ); + } + + if ( hCombinedOrientationData ) + { + for ( i = 0; i < 3; i++ ) + { + for ( j = 0; j < 3; j++ ) + { + Rmat[i][j] = hCombinedOrientationData->Rmat[hCombinedOrientationData->subframe_idx][i][j]; + } + } + + if ( nchan_transport == 2 ) + { +#ifdef SPLIT_REND_WITH_HEAD_ROT + /* in case of split rendering, determine the prototype rotation based on the main direction and use the same prototypes for the offset directions */ +#endif + adaptTransportSignalsHeadtracked( hCombinedOrientationData, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, nBins, hSpatParamRendCom->subframe_nbslots[subframe], Rmat ); + + ivas_dirac_dec_binaural_check_and_switch_transports_headtracked( hCombinedOrientationData, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, nBins, hSpatParamRendCom->subframe_nbslots[subframe], Rmat ); + } + } + +#ifndef SPLIT_REND_WITH_HEAD_ROT + ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matrices( hDiracDecBin, hSpatParamRendCom, &config_data, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, Rmat, subframe, + hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[hCombinedOrientationData->subframe_idx] > 0, st_ivas->hMasaIsmData ); + +#endif + if ( config_data.ivas_format == ISM_FORMAT ) + { + max_band_decorr = 0; + } + else if ( hDiracDecBin->useTdDecorr ) + { + max_band_decorr = CLDFB_NO_CHANNELS_MAX; + } + else + { + max_band_decorr = hDiracDecBin->h_freq_domain_decorr_ap_params->max_band_decorr; + } + + +#ifdef SPLIT_REND_WITH_HEAD_ROT + ivas_dirac_dec_binaural_formulate_input_covariance_matrices( hDiracDecBin, hSpatParamRendCom, &config_data, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, subframe, + subFrameTotalEne, IIReneLimiter ); + + ivas_dirac_dec_binaural_formulate_target_covariance_matrices( hDiracDecBin, hSpatParamRendCom, &config_data, Rmat, subframe, + hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[hCombinedOrientationData->subframe_idx] > 0, subFrameTotalEne, IIReneLimiter, st_ivas->hMasaIsmData ); +#endif + + nchanSeparateChannels = 0; + if ( config_data.separateCenterChannelRendering || ( st_ivas->ivas_format == MASA_ISM_FORMAT && ( st_ivas->ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ || st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ ) ) ) + { + nchanSeparateChannels = 1; + } + else if ( st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->ism_mode == ISM_MASA_MODE_DISC && ( st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) + { + nchanSeparateChannels = (uint8_t) st_ivas->nchan_ism; + } + + ivas_dirac_dec_binaural_determine_processing_matrices( hDiracDecBin, hSpatParamRendCom, &config_data, max_band_decorr, Rmat, subframe, + hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[hCombinedOrientationData->subframe_idx] > 0, nchanSeparateChannels, st_ivas->hMasaIsmData ); + +#ifdef SPLIT_REND_WITH_HEAD_ROT + pMultiBinPoseData = NULL; + if ( st_ivas->hSplitBinRend != NULL ) + { + pMultiBinPoseData = &st_ivas->hSplitBinRend->splitrend.multiBinPoseData; + } + +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) +#else + if ( pMultiBinPoseData != NULL && pMultiBinPoseData->num_poses > 1 ) +#endif + { + ivas_dirac_dec_binaural_process_output( hDiracDecBin, hSpatParamRendCom, st_ivas->cldfbSynDec, output_f, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, + max_band_decorr, numInChannels, config_data.processReverb, subframe, tmp_Cldfb_out_re, tmp_Cldfb_out_im, + reverbRe, reverbIm, decorrRe, decorrIm, 1 ); + + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + for ( i = 0; i < hSpatParamRendCom->subframe_nbslots[subframe]; i++ ) + { + mvr2r( tmp_Cldfb_out_re[ch][i], st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_RealBuffer_Binaural[ch][hSpatParamRendCom->slots_rendered + i], CLDFB_NO_CHANNELS_MAX ); + mvr2r( tmp_Cldfb_out_im[ch][i], st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural[ch][hSpatParamRendCom->slots_rendered + i], CLDFB_NO_CHANNELS_MAX ); + } + } + } + else + { + ivas_dirac_dec_binaural_process_output( hDiracDecBin, hSpatParamRendCom, st_ivas->cldfbSynDec, output_f, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, + max_band_decorr, numInChannels, config_data.processReverb, subframe, NULL, NULL, + reverbRe, reverbIm, decorrRe, decorrIm, 1 ); + } +#else + ivas_dirac_dec_binaural_process_output( hDiracDecBin, hSpatParamRendCom, st_ivas->cldfbSynDec, output_f, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, max_band_decorr, numInChannels, config_data.processReverb, subframe ); +#endif + + hDiracDecBin->hDiffuseDist = NULL; + +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( pMultiBinPoseData != NULL && pMultiBinPoseData->num_poses > 1 ) + { + /* quaternion-based rotation from ivas_binRenderer_internal.c:ivas_binRenderer(), but using absolute rotation instead of delta rotations */ + IVAS_QUATERNION Quaternions_rot, Quaternions_abs, *Quaternions_ref; + float Rmat_local[3][3]; + + if ( hCombinedOrientationData ) + { + Quaternions_ref = &hCombinedOrientationData->Quaternions[0]; + Quaternions_rot.w = -3.0f; /* signal to use Euler */ + Quaternions_abs.w = -3.0f; /* signal to use Euler */ + Quat2EulerDegree( *Quaternions_ref, &Quaternions_abs.z, &Quaternions_abs.y, &Quaternions_abs.x ); /*order in Quat2Euler seems to be reversed ?*/ + + for ( pos_idx = 1; pos_idx < pMultiBinPoseData->num_poses; pos_idx++ ) + { + Quaternions_rot.x = Quaternions_abs.x + pMultiBinPoseData->relative_head_poses[pos_idx][0]; + Quaternions_rot.y = Quaternions_abs.y + pMultiBinPoseData->relative_head_poses[pos_idx][1]; + Quaternions_rot.z = Quaternions_abs.z + pMultiBinPoseData->relative_head_poses[pos_idx][2]; + + QuatToRotMat( Quaternions_rot, Rmat_local ); + + hDiracDecBin = st_ivas->hDiracDecBin[pos_idx]; + assert( hDiracDecBin != NULL && "No DiracDecBin handle for this position" ); + if ( config_data.ivas_format == SBA_FORMAT || config_data.ivas_format == SBA_ISM_FORMAT ) + { + hDiracDecBin->hDiffuseDist = &diffuseDistData; + } + + /* re-use input covariance for the side renderings */ + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + mvr2r( st_ivas->hDiracDecBin[0]->ChEne[ch], hDiracDecBin->ChEne[ch], hSpatParamRendCom->num_freq_bands ); + } + mvr2r( st_ivas->hDiracDecBin[0]->ChCrossRe, hDiracDecBin->ChCrossRe, hSpatParamRendCom->num_freq_bands ); + mvr2r( st_ivas->hDiracDecBin[0]->ChCrossIm, hDiracDecBin->ChCrossIm, hSpatParamRendCom->num_freq_bands ); + + ivas_dirac_dec_binaural_formulate_target_covariance_matrices( hDiracDecBin, hSpatParamRendCom, &config_data, Rmat_local, subframe, + hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[subframe] > 0, + subFrameTotalEne, IIReneLimiter, st_ivas->hMasaIsmData ); + + ivas_dirac_dec_binaural_determine_processing_matrices( hDiracDecBin, hSpatParamRendCom, &config_data, max_band_decorr, Rmat_local, subframe, + hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[subframe] > 0, + nchanSeparateChannels, st_ivas->hMasaIsmData ); + + + /* re-use reverb and decorr from main direction for the sides */ + ivas_dirac_dec_binaural_process_output( hDiracDecBin, hSpatParamRendCom, st_ivas->cldfbSynDec, output_f, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, + max_band_decorr, numInChannels, config_data.processReverb, subframe, tmp_Cldfb_out_re, tmp_Cldfb_out_im, + reverbRe, reverbIm, decorrRe, decorrIm, 0 ); + + /* copy from temporary buffer to the main split rendering buffer */ + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + for ( i = 0; i < hSpatParamRendCom->subframe_nbslots[subframe]; i++ ) + { + mvr2r( tmp_Cldfb_out_re[ch][i], st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_RealBuffer_Binaural[pos_idx * BINAURAL_CHANNELS + ch][hSpatParamRendCom->slots_rendered + i], CLDFB_NO_CHANNELS_MAX ); + mvr2r( tmp_Cldfb_out_im[ch][i], st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural[pos_idx * BINAURAL_CHANNELS + ch][hSpatParamRendCom->slots_rendered + i], CLDFB_NO_CHANNELS_MAX ); + } + } + + hDiracDecBin->hDiffuseDist = NULL; + } + } + } + + /* update this counter only after the last rendering of split directions */ +#endif + hSpatParamRendCom->slots_rendered += hSpatParamRendCom->subframe_nbslots[subframe]; + hSpatParamRendCom->subframes_rendered++; + + return; +} + + +static void ivas_dirac_dec_decorrelate_slot( + DIRAC_DEC_BIN_HANDLE hDiracDecBin, + const int16_t num_freq_bands, + const int16_t slot, + float inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], + float inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], + float decRe[][CLDFB_NO_CHANNELS_MAX], + float decIm[][CLDFB_NO_CHANNELS_MAX] ) +{ + int16_t offset, ch, bin; + float onset_filter[BINAURAL_CHANNELS * CLDFB_NO_CHANNELS_MAX]; /* 2 ch, 60 bins */ + float decorrelatedFrameInterleaved[2 * BINAURAL_CHANNELS * CLDFB_NO_CHANNELS_MAX]; /* 2 ch, real + imag, 60 bins */ + float protoFrameF[2 * BINAURAL_CHANNELS * CLDFB_NO_CHANNELS_MAX]; /* 2 ch, real + imag, 60 bins */ + const int16_t protoIndexDir[BINAURAL_CHANNELS] = { 0, 1 }; + + /* Decorrelation needs interleaved data. Copy left and right signals to proto_frame_f */ + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + offset = num_freq_bands * BINAURAL_CHANNELS * ch; + for ( bin = 0; bin < num_freq_bands; bin++ ) + { + protoFrameF[( bin * BINAURAL_CHANNELS ) + offset] = inRe[ch][slot][bin]; + protoFrameF[( bin * BINAURAL_CHANNELS ) + offset + 1] = inIm[ch][slot][bin]; + } + } + + /* Decorrelate proto signal to decorrelatedFrameInterleaved */ + ivas_dirac_dec_decorr_process( num_freq_bands, + BINAURAL_CHANNELS, + BINAURAL_CHANNELS, + DIRAC_SYNTHESIS_PSD_LS, + BINAURAL_CHANNELS, + protoFrameF, + BINAURAL_CHANNELS, + protoIndexDir, + decorrelatedFrameInterleaved, + onset_filter, + hDiracDecBin->h_freq_domain_decorr_ap_params, + hDiracDecBin->h_freq_domain_decorr_ap_state ); + + /* De-interleave decorrelated signals*/ + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + offset = num_freq_bands * BINAURAL_CHANNELS * ch; + for ( bin = 0; bin < num_freq_bands; bin++ ) + { + decRe[ch][bin] = decorrelatedFrameInterleaved[( bin * BINAURAL_CHANNELS ) + offset]; + decIm[ch][bin] = decorrelatedFrameInterleaved[( bin * BINAURAL_CHANNELS ) + offset + 1]; + } + } + + return; +} + + +#ifdef SPLIT_REND_WITH_HEAD_ROT +static void ivas_dirac_dec_binaural_formulate_input_covariance_matrices( + DIRAC_DEC_BIN_HANDLE hDiracDecBin, + const SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, + const PARAMBIN_REND_CONFIG_HANDLE hConfig, + float inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], + float inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], + const int16_t subframe, + float *subFrameTotalEne, + float *IIReneLimiter ) +{ + int16_t ch, slot, bin; + int16_t nBins; + float IIReneLimiterFactor; + float qualityBasedSmFactor; + float lowBitRateEQ[CLDFB_NO_CHANNELS_MAX]; + uint8_t applyLowBitRateEQ; + IVAS_FORMAT ivas_format; + int32_t ivas_total_brate; + int16_t nchan_transport; + + ivas_format = hConfig->ivas_format; + ivas_total_brate = hConfig->ivas_total_brate; + nchan_transport = hConfig->nchan_transport; + qualityBasedSmFactor = hConfig->qualityBasedSmFactor; + qualityBasedSmFactor *= qualityBasedSmFactor; + nBins = hSpatParamRendCom->num_freq_bands; /* Actually bins */ + + set_zero( hDiracDecBin->ChCrossRe, nBins ); + set_zero( hDiracDecBin->ChCrossIm, nBins ); + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + set_zero( hDiracDecBin->ChEne[ch], nBins ); + } + + /* Determine EQ for low bit rates (13.2 and 16.4 kbps) */ + applyLowBitRateEQ = 0; + if ( ( ivas_format == MASA_FORMAT || ivas_format == MC_FORMAT ) && ivas_total_brate < MASA_STEREO_MIN_BITRATE ) + { + applyLowBitRateEQ = 1; + if ( ivas_total_brate == IVAS_16k4 ) + { + for ( bin = 0; bin < LOW_BIT_RATE_BINAURAL_EQ_BINS; bin++ ) + { + lowBitRateEQ[bin + LOW_BIT_RATE_BINAURAL_EQ_OFFSET] = lowBitRateBinauralEQ[bin] * 0.5f + 0.5f; + } + } + else + { + for ( bin = 0; bin < LOW_BIT_RATE_BINAURAL_EQ_BINS; bin++ ) + { + lowBitRateEQ[bin + LOW_BIT_RATE_BINAURAL_EQ_OFFSET] = lowBitRateBinauralEQ[bin]; + } + } + } + + /* Formulate input and target covariance matrices for this subframe */ + set_zero( subFrameTotalEne, CLDFB_NO_CHANNELS_MAX ); + + /* Calculate input covariance matrix */ + for ( slot = 0; slot < hSpatParamRendCom->subframe_nbslots[subframe]; slot++ ) + { + for ( bin = 0; bin < nBins; bin++ ) + { + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + float instEne; + + instEne = ( inRe[ch][slot][bin] * inRe[ch][slot][bin] ); + instEne += ( inIm[ch][slot][bin] * inIm[ch][slot][bin] ); + hDiracDecBin->ChEne[ch][bin] += instEne; + subFrameTotalEne[bin] += instEne; + } + hDiracDecBin->ChCrossRe[bin] += inRe[0][slot][bin] * inRe[1][slot][bin]; + hDiracDecBin->ChCrossRe[bin] += inIm[0][slot][bin] * inIm[1][slot][bin]; + hDiracDecBin->ChCrossIm[bin] += inRe[0][slot][bin] * inIm[1][slot][bin]; + hDiracDecBin->ChCrossIm[bin] -= inIm[0][slot][bin] * inRe[1][slot][bin]; + } + } + + /* Apply EQ at low bit rates */ + if ( applyLowBitRateEQ ) + { + int16_t lastEqBin = LOW_BIT_RATE_BINAURAL_EQ_OFFSET + LOW_BIT_RATE_BINAURAL_EQ_BINS - 1; + + for ( bin = LOW_BIT_RATE_BINAURAL_EQ_OFFSET; bin < lastEqBin; bin++ ) + { + subFrameTotalEne[bin] *= lowBitRateEQ[bin]; + } + for ( ; bin < nBins; bin++ ) + { + subFrameTotalEne[bin] *= lowBitRateEQ[lastEqBin]; + } + } + + if ( ( ivas_format == SBA_FORMAT || ivas_format == SBA_ISM_FORMAT ) && nchan_transport == 2 ) + { + float tempRe, tempIm; + float subFrameSumEne[CLDFB_NO_CHANNELS_MAX]; + + v_multc( subFrameTotalEne, SBA_CARDI_TARGET_ENERGY_GAIN, subFrameTotalEne, nBins ); + + set_zero( subFrameSumEne, CLDFB_NO_CHANNELS_MAX ); + for ( slot = 0; slot < hSpatParamRendCom->subframe_nbslots[subframe]; slot++ ) + { + for ( bin = 0; bin < nBins; bin++ ) + { + tempRe = inRe[0][slot][bin] + inRe[1][slot][bin]; + tempIm = inIm[0][slot][bin] + inIm[1][slot][bin]; + subFrameSumEne[bin] += tempRe * tempRe + tempIm * tempIm; + } + } + + for ( bin = 0; bin < nBins; bin++ ) + { + subFrameTotalEne[bin] = max( subFrameTotalEne[bin], subFrameSumEne[bin] ); + } + } + + /* Temporal IIR-type smoothing of covariance matrices. Also apply encoding quality based smoothing factor. */ + if ( ivas_format == MASA_FORMAT && ivas_total_brate < MASA_STEREO_MIN_BITRATE ) + { + IIReneLimiterFactor = 16.0f + ( 1.0f - qualityBasedSmFactor ); + } + else + { + IIReneLimiterFactor = 8.0f + ( 1.0f - qualityBasedSmFactor ); + } + for ( bin = 0; bin < nBins; bin++ ) + { + float eneRatio; + + /* Temporally smooth cov mtx estimates for resulting mixing matrix stability. The design principle is that + * the energy history (IIR) must not be more than double of the current frame energy. This provides more + * robust performance at energy offsets when compared to typical IIR averaging. */ + eneRatio = ( hDiracDecBin->ChEne[0][bin] + hDiracDecBin->ChEne[1][bin] ) / fmaxf( 1e-12f, ( hDiracDecBin->ChEnePrev[0][bin] + hDiracDecBin->ChEnePrev[1][bin] ) ); + IIReneLimiter[bin] = fminf( 1.0f, eneRatio * IIReneLimiterFactor ); + + hDiracDecBin->ChCrossRe[bin] *= qualityBasedSmFactor; + hDiracDecBin->ChCrossIm[bin] *= qualityBasedSmFactor; + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + hDiracDecBin->ChEne[ch][bin] *= qualityBasedSmFactor; + } + + hDiracDecBin->ChCrossRe[bin] += IIReneLimiter[bin] * hDiracDecBin->ChCrossRePrev[bin]; + hDiracDecBin->ChCrossIm[bin] += IIReneLimiter[bin] * hDiracDecBin->ChCrossImPrev[bin]; + + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + hDiracDecBin->ChEne[ch][bin] += IIReneLimiter[bin] * hDiracDecBin->ChEnePrev[ch][bin]; + } + + /* Store energy values and coefficients for next round */ + hDiracDecBin->ChCrossRePrev[bin] = hDiracDecBin->ChCrossRe[bin]; + hDiracDecBin->ChCrossImPrev[bin] = hDiracDecBin->ChCrossIm[bin]; + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + hDiracDecBin->ChEnePrev[ch][bin] = hDiracDecBin->ChEne[ch][bin]; + } + } + + return; +} + +static void ivas_dirac_dec_binaural_formulate_target_covariance_matrices( + DIRAC_DEC_BIN_HANDLE hDiracDecBin, + const SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, + const PARAMBIN_REND_CONFIG_HANDLE hConfig, + float Rmat[3][3], + const int16_t subframe, + const int16_t isHeadtracked, + const float *subFrameTotalEne, + const float *IIReneLimiter, + const MASA_ISM_DATA_HANDLE hMasaIsmData ) +{ + int16_t ch, bin; + int16_t separateCenterChannelRendering; + int16_t nBins, idx; + float frameMeanDiffusenessEneWeight[CLDFB_NO_CHANNELS_MAX]; + float qualityBasedSmFactor; + int16_t dirac_read_idx; + PARAMBIN_HRTF_GAIN_CACHE gainCache[MAX_GAIN_CACHE_SIZE]; + IVAS_FORMAT ivas_format; + MC_MODE mc_mode; + int16_t gainCacheBaseIndex; + + separateCenterChannelRendering = hConfig->separateCenterChannelRendering; + ivas_format = hConfig->ivas_format; + mc_mode = hConfig->mc_mode; + qualityBasedSmFactor = hConfig->qualityBasedSmFactor; + qualityBasedSmFactor *= qualityBasedSmFactor; + nBins = hSpatParamRendCom->num_freq_bands; /* Actually bins */ + + set_zero( hDiracDecBin->ChCrossReOut, nBins ); + set_zero( hDiracDecBin->ChCrossImOut, nBins ); + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + set_zero( hDiracDecBin->ChEneOut[ch], nBins ); + } + set_zero( hDiracDecBin->frameMeanDiffuseness, nBins ); + + set_zero( frameMeanDiffusenessEneWeight, CLDFB_NO_CHANNELS_MAX ); + + for ( idx = 0; idx < MAX_GAIN_CACHE_SIZE; idx++ ) + { + gainCache[idx].azi = -1000; /* Use -1000 as value for uninitialized cache. */ + } + + dirac_read_idx = hSpatParamRendCom->render_to_md_map[subframe]; + + /* Determine target covariance matrix containing target binaural properties */ + for ( bin = 0; bin < nBins; bin++ ) + { + float diffuseness = 1.0f; /* ratio1 and ratio2 are subtracted from diffuseness further below */ + float diffusenessValForDecorrelationReduction = 1.0f; + float diffEneValForDecorrelationReduction; + float surCoh = 0.0f, spreadCoh = 0.0f; /* Default values if spreadSurroundCoherenceApplied == false */ + float diffEne, dirEne, meanEnePerCh; + int16_t dirIndex; + + /* When BINAURAL_ROOM is not indicated, hBinaural->earlyPartEneCorrection[bin] values are all 1.0f. + * When BINAURAL_ROOM is indicated, the binaural audio output is based on combined use of the + * HRTF data set and a BRIR-based data set. The HRTF data set is spectrally corrected to match + * the early spectrum of the BRIR data, using the spectral correction data in + * hBinaural->earlyPartEneCorrection[bin], based on the BRIR set. */ + meanEnePerCh = hDiracDecBin->earlyPartEneCorrection[bin] * subFrameTotalEne[bin] / 2.0f; + + /* Determine direct part target covariance matrix (for 1 or 2 directions) */ + for ( dirIndex = 0; dirIndex < hSpatParamRendCom->numSimultaneousDirections; dirIndex++ ) + { + int16_t aziDeg, eleDeg; + float lRealp, lImagp, rRealp, rImagp; + float lRealpTmp, lImagpTmp, rRealpTmp, rImagpTmp; + float hrtfEne[BINAURAL_CHANNELS], hrtfCrossRe, hrtfCrossIm, ratio; + uint8_t isIsmDirection = 0; + + if ( dirIndex == 0 ) /* For first of the two simultaneous directions */ + { + aziDeg = hSpatParamRendCom->azimuth[dirac_read_idx][bin]; + eleDeg = hSpatParamRendCom->elevation[dirac_read_idx][bin]; + ratio = hSpatParamRendCom->energy_ratio1[dirac_read_idx][bin]; + spreadCoh = hSpatParamRendCom->spreadCoherence[dirac_read_idx][bin]; + gainCacheBaseIndex = 0; + } + else if ( ivas_format != MASA_ISM_FORMAT || ( ivas_format == MASA_ISM_FORMAT && dirIndex < hSpatParamRendCom->numParametricDirections ) ) /* For second of the two simultaneous directions */ + { + if ( ( ratio = hSpatParamRendCom->energy_ratio2[dirac_read_idx][bin] ) < 0.001 ) + { + /* This touches only MASA path where second direction always has smaller ratio and + * for non-2dir it is zero. As the whole direction contribution is multiplied with + * the ratio, a very small ratio does not contribute any energy to output. Thus, + * it is better to save complexity. */ + continue; + } + aziDeg = hSpatParamRendCom->azimuth2[dirac_read_idx][bin]; + eleDeg = hSpatParamRendCom->elevation2[dirac_read_idx][bin]; + spreadCoh = hSpatParamRendCom->spreadCoherence2[dirac_read_idx][bin]; + gainCacheBaseIndex = 3; + } + else /* For object directions of MASA_ISM_FORMAT */ + { + isIsmDirection = 1; + uint16_t ismDirIndex; + ismDirIndex = dirIndex - hSpatParamRendCom->numParametricDirections; + assert( hMasaIsmData != NULL && "hMasaIsmData should not be NULL if we use it" ); + if ( hMasaIsmData->ism_is_edited[ismDirIndex] ) + { + aziDeg = hMasaIsmData->azimuth_ism_edited[ismDirIndex]; + eleDeg = hMasaIsmData->elevation_ism_edited[ismDirIndex]; + } + else + { + aziDeg = hMasaIsmData->azimuth_ism[ismDirIndex][dirac_read_idx]; + eleDeg = hMasaIsmData->elevation_ism[ismDirIndex][dirac_read_idx]; + } + ratio = hMasaIsmData->energy_ratio_ism[ismDirIndex][dirac_read_idx][bin]; + spreadCoh = 0.0f; + gainCacheBaseIndex = 6 + ismDirIndex; + } + + diffuseness -= ratio; /* diffuseness = 1 - ratio1 - ratio2 */ + + if ( diffuseness < 0.0f ) + { + diffuseness = 0.0f; + } + if ( isIsmDirection ) + { + /* Objects cause lesser decorrelation reduction, to avoid removing all decorrelation when only objects are present */ + diffusenessValForDecorrelationReduction -= ratio * 0.5f; + } + else + { + diffusenessValForDecorrelationReduction -= ratio; + } + + if ( separateCenterChannelRendering ) + { + /* In masa + mono rendering mode, the center directions originate from phantom sources, so the + * spread coherence is increased */ + float aziRad, eleRad, doaVectorX, spatialAngleDeg, altSpreadCoh; + + aziRad = (float) aziDeg * PI_OVER_180; + eleRad = (float) eleDeg * PI_OVER_180; + doaVectorX = cosf( aziRad ) * cosf( eleRad ); + spatialAngleDeg = acosf( doaVectorX ) * _180_OVER_PI; + altSpreadCoh = 1.0f - ( spatialAngleDeg / 30.0f ); + spreadCoh = max( spreadCoh, altSpreadCoh ); + } + + getDirectPartGains( bin, aziDeg, eleDeg, &lRealp, &lImagp, &rRealp, &rImagp, hDiracDecBin->renderStereoOutputInsteadOfBinaural, Rmat, &gainCache[gainCacheBaseIndex], isHeadtracked ); + + if ( hDiracDecBin->renderStereoOutputInsteadOfBinaural ) + { + /* Synthesizing spread coherence is not needed for stereo loudspeaker output, + * as directional sound is reproduced with two loudspeakers in any case */ + spreadCoh = 0.0f; + } + + if ( spreadCoh > 0.0f ) + { + float centerMul, sidesMul; + float hrtfEneCenter, hrtfEneSides, hrtfEneRealized, eneCorrectionFactor; + float w1, w2, w3, eq; + + hrtfEneCenter = ( lRealp * lRealp ) + ( lImagp * lImagp ) + ( rRealp * rRealp ) + ( rImagp * rImagp ); + + /* Spread coherence is synthesized as coherent sources at 30 degree horizontal spacing. + * The following formulas determine the gains for these sources. + * spreadCoh = 0: Only panning + * spreadCoh = 0.5: Three sources coherent panning (e.g. 30 0 -30 deg azi) + * spreadCoh = 1.0: Two sources coherent panning with gap (as above, but center is silent) */ + if ( spreadCoh < 0.5f ) + { + /* 0.0f < spreadCoh < 0.5f */ + sidesMul = 0.5774f * spreadCoh * 2.0f; /* sqrt(1/3) = 0.5774f */ + centerMul = 1.0f - ( spreadCoh * 2.0f ) + sidesMul; + } + else + { + /* 0.5f <= spreadCoh < 1.0f */ + centerMul = 2.0f - ( 2.0f * spreadCoh ); + sidesMul = inv_sqrt( centerMul + 2.0f ); + centerMul *= sidesMul; + } + + /* Apply the gain for the center source of the three coherent sources */ + lRealp *= centerMul; + lImagp *= centerMul; + rRealp *= centerMul; + rImagp *= centerMul; + + /* Apply the gain for the left source of the three coherent sources */ + getDirectPartGains( bin, aziDeg + 30, eleDeg, &lRealpTmp, &lImagpTmp, &rRealpTmp, &rImagpTmp, hDiracDecBin->renderStereoOutputInsteadOfBinaural, Rmat, &gainCache[gainCacheBaseIndex + 1], isHeadtracked ); + + hrtfEneSides = ( lRealpTmp * lRealpTmp ) + ( lImagpTmp * lImagpTmp ) + ( rRealpTmp * rRealpTmp ) + ( rImagpTmp * rImagpTmp ); + lRealp += sidesMul * lRealpTmp; + lImagp += sidesMul * lImagpTmp; + rRealp += sidesMul * rRealpTmp; + rImagp += sidesMul * rImagpTmp; + + /* Apply the gain for the right source of the three coherent sources. + * -30 degrees to 330 wrapping due to internal functions. */ + getDirectPartGains( bin, aziDeg + 330, eleDeg, &lRealpTmp, &lImagpTmp, &rRealpTmp, &rImagpTmp, hDiracDecBin->renderStereoOutputInsteadOfBinaural, Rmat, &gainCache[gainCacheBaseIndex + 2], isHeadtracked ); + hrtfEneSides += ( lRealpTmp * lRealpTmp ) + ( lImagpTmp * lImagpTmp ) + ( rRealpTmp * rRealpTmp ) + ( rImagpTmp * rImagpTmp ); + lRealp += sidesMul * lRealpTmp; + lImagp += sidesMul * lImagpTmp; + rRealp += sidesMul * rRealpTmp; + rImagp += sidesMul * rImagpTmp; + + /* Formulate an eneCorrectionFactor that compensates for the coherent summation of the HRTFs */ + hrtfEneRealized = ( lRealp * lRealp ) + ( lImagp * lImagp ) + ( rRealp * rRealp ) + ( rImagp * rImagp ); + eneCorrectionFactor = ( ( hrtfEneSides * sidesMul * sidesMul ) + + ( hrtfEneCenter * centerMul * centerMul ) ) / + max( 1e-12f, hrtfEneRealized ); + + /* Weighting factors to determine appropriate target spectrum for spread coherent sound */ + if ( spreadCoh < 0.5 ) + { + w1 = 1.0f - 2.0f * spreadCoh; + w2 = 2.0f * spreadCoh; + w3 = 0.0f; + } + else + { + w1 = 0.0f; + w2 = 2.0f - 2.0f * spreadCoh; + w3 = 2.0f * spreadCoh - 1.0f; + } + + if ( ( ivas_format == MC_FORMAT && mc_mode == MC_MODE_MCMASA ) ) + { + idx = min( bin, MASA_NUM_DEFINED_SUR_SPR_COH_ENE_BINS - 1 ); + + /* Apply the target spectrum to the eneCorrectionFactor */ + if ( separateCenterChannelRendering ) /* spreadCoh mostly originates from phantom sources in separate channel rendering mode */ + { + eneCorrectionFactor *= w1 * 1.0f + ( w2 + w3 ) * spreadCohEne1[idx]; + } + else + { + eneCorrectionFactor *= w1 * 1.0f + w2 * spreadCohEne05[idx] + w3 * spreadCohEne1[idx]; + } + } + + /* Equalize the spread coherent combined HRTFs */ + eq = min( 4.0f, sqrtf( eneCorrectionFactor ) ); + lRealp *= eq; + lImagp *= eq; + rRealp *= eq; + rImagp *= eq; + } - if ( config_data.ivas_format == SBA_FORMAT || config_data.ivas_format == SBA_ISM_FORMAT ) - { - hDiracDecBin->hDiffuseDist = &diffuseDistData; + hrtfEne[0] = ( lRealp * lRealp ) + ( lImagp * lImagp ); + hrtfEne[1] = ( rRealp * rRealp ) + ( rImagp * rImagp ); + hrtfCrossRe = ( lRealp * rRealp ) + ( lImagp * rImagp ); + hrtfCrossIm = ( -lImagp * rRealp ) + ( lRealp * rImagp ); - ivas_spar_param_to_masa_param_mapping( st_ivas, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, subframe ); - ivas_sba_prototype_renderer( st_ivas, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, subframe ); - } + /* Add direct part (1 or 2) covariance matrix */ + dirEne = ratio * meanEnePerCh; + hDiracDecBin->ChEneOut[0][bin] += dirEne * hrtfEne[0]; /* Dir ene part*/ + hDiracDecBin->ChEneOut[1][bin] += dirEne * hrtfEne[1]; + hDiracDecBin->ChCrossReOut[bin] += dirEne * hrtfCrossRe; /* Dir cross re */ + hDiracDecBin->ChCrossImOut[bin] += dirEne * hrtfCrossIm; /* Dir cross im */ + } - if ( st_ivas->ivas_format == MASA_ISM_FORMAT && nchan_transport == 2 && st_ivas->ism_mode != ISM_MASA_MODE_DISC && st_ivas->ism_mode != ISM_MASA_MODE_MASA_ONE_OBJ ) - { - ivas_omasa_preProcessStereoTransportsForMovedObjects( st_ivas, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, nBins, subframe ); - } + /* Add diffuse / ambient part covariance matrix */ + diffuseness = max( 0.0f, diffuseness ); + diffEne = diffuseness * meanEnePerCh; + surCoh = hSpatParamRendCom->surroundingCoherence[dirac_read_idx][bin]; - if ( hCombinedOrientationData ) - { - for ( i = 0; i < 3; i++ ) + diffusenessValForDecorrelationReduction = max( 0.0f, diffusenessValForDecorrelationReduction ); + diffEneValForDecorrelationReduction = diffusenessValForDecorrelationReduction * meanEnePerCh; + + if ( ( ivas_format == MC_FORMAT && mc_mode == MC_MODE_MCMASA ) ) { - for ( j = 0; j < 3; j++ ) + if ( !hDiracDecBin->renderStereoOutputInsteadOfBinaural ) { - Rmat[i][j] = hCombinedOrientationData->Rmat[hCombinedOrientationData->subframe_idx][i][j]; + float spectrumModVal; + + idx = min( bin, MASA_NUM_DEFINED_SUR_SPR_COH_ENE_BINS - 1 ); + /* Apply target spectrum that emphasizes low frequencies when the sound is surround coherent */ + spectrumModVal = ( 1.0f - surCoh ) + surCoh * surCohEne[idx]; + diffEne *= spectrumModVal; + + /* Modify also the value for decorrelation reduction */ + diffEneValForDecorrelationReduction *= spectrumModVal; } } + hDiracDecBin->ChEneOut[0][bin] += diffEne; /* Diff ene part*/ + hDiracDecBin->ChEneOut[1][bin] += diffEne; - if ( nchan_transport == 2 ) + if ( hDiracDecBin->renderStereoOutputInsteadOfBinaural ) { - adaptTransportSignalsHeadtracked( hCombinedOrientationData, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, nBins, hSpatParamRendCom->subframe_nbslots[subframe], Rmat ); - - ivas_dirac_dec_binaural_check_and_switch_transports_headtracked( hCombinedOrientationData, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, nBins, hSpatParamRendCom->subframe_nbslots[subframe], Rmat ); + /* When rendering stereo, ambience (except for surround coherent sound) has zero ICC. */ + hDiracDecBin->ChCrossReOut[bin] += surCoh * diffEne; + } + else /* When rendering binaural, ambience has frequency dependent ICC. */ + { + if ( ( ivas_format == SBA_FORMAT || ivas_format == SBA_ISM_FORMAT ) && bin < BINAURAL_COHERENCE_DIFFERENCE_BINS ) + { + float diffuseFieldCoherence; + diffuseFieldCoherence = hDiracDecBin->hDiffuseDist->diffuseRatioX[bin] * hDiracDecBin->diffuseFieldCoherenceX[bin] + hDiracDecBin->hDiffuseDist->diffuseRatioY[bin] * hDiracDecBin->diffuseFieldCoherenceY[bin] + hDiracDecBin->hDiffuseDist->diffuseRatioZ[bin] * hDiracDecBin->diffuseFieldCoherenceZ[bin]; + hDiracDecBin->ChCrossReOut[bin] += ( ( 1.0f - surCoh ) * diffuseFieldCoherence + surCoh ) * diffEne; + } + else + { + hDiracDecBin->ChCrossReOut[bin] += ( ( 1.0f - surCoh ) * hDiracDecBin->diffuseFieldCoherence[bin] + surCoh ) * diffEne; + } } - } - - ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matrices( hDiracDecBin, hSpatParamRendCom, &config_data, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, Rmat, subframe, - hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[hCombinedOrientationData->subframe_idx] > 0, st_ivas->hMasaIsmData ); - if ( config_data.ivas_format == ISM_FORMAT ) - { - max_band_decorr = 0; - } - else if ( hDiracDecBin->useTdDecorr ) - { - max_band_decorr = CLDFB_NO_CHANNELS_MAX; - } - else - { - max_band_decorr = hDiracDecBin->h_freq_domain_decorr_ap_params->max_band_decorr; + /* Store parameters for formulating average diffuseness over frame */ + hDiracDecBin->frameMeanDiffuseness[bin] += diffEneValForDecorrelationReduction; + frameMeanDiffusenessEneWeight[bin] += meanEnePerCh; } - - nchanSeparateChannels = 0; - if ( config_data.separateCenterChannelRendering || ( st_ivas->ivas_format == MASA_ISM_FORMAT && ( st_ivas->ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ || st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ ) ) ) - { - nchanSeparateChannels = 1; - } - else if ( st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->ism_mode == ISM_MASA_MODE_DISC && ( st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) + /* Formulate average diffuseness over frame */ + for ( bin = 0; bin < nBins; bin++ ) { - nchanSeparateChannels = (uint8_t) st_ivas->nchan_ism; + hDiracDecBin->frameMeanDiffuseness[bin] /= fmaxf( 1e-12f, frameMeanDiffusenessEneWeight[bin] ); } - ivas_dirac_dec_binaural_determine_processing_matrices( hDiracDecBin, hSpatParamRendCom, &config_data, max_band_decorr, Rmat, subframe, - hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[hCombinedOrientationData->subframe_idx] > 0, nchanSeparateChannels, st_ivas->hMasaIsmData ); - - ivas_dirac_dec_binaural_process_output( hDiracDecBin, hSpatParamRendCom, st_ivas->cldfbSynDec, output_f, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, max_band_decorr, numInChannels, config_data.processReverb, subframe ); - - hDiracDecBin->hDiffuseDist = NULL; - - hSpatParamRendCom->slots_rendered += hSpatParamRendCom->subframe_nbslots[subframe]; - hSpatParamRendCom->subframes_rendered++; - - return; -} + for ( bin = 0; bin < nBins; bin++ ) + { + hDiracDecBin->ChCrossReOut[bin] *= qualityBasedSmFactor; + hDiracDecBin->ChCrossImOut[bin] *= qualityBasedSmFactor; + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + hDiracDecBin->ChEneOut[ch][bin] *= qualityBasedSmFactor; + } -static void ivas_dirac_dec_decorrelate_slot( - DIRAC_DEC_BIN_HANDLE hDiracDecBin, - const int16_t num_freq_bands, - const int16_t slot, - float inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], - float inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], - float decRe[][CLDFB_NO_CHANNELS_MAX], - float decIm[][CLDFB_NO_CHANNELS_MAX] ) -{ - int16_t offset, ch, bin; - float onset_filter[BINAURAL_CHANNELS * CLDFB_NO_CHANNELS_MAX]; /* 2 ch, 60 bins */ - float decorrelatedFrameInterleaved[2 * BINAURAL_CHANNELS * CLDFB_NO_CHANNELS_MAX]; /* 2 ch, real + imag, 60 bins */ - float protoFrameF[2 * BINAURAL_CHANNELS * CLDFB_NO_CHANNELS_MAX]; /* 2 ch, real + imag, 60 bins */ - const int16_t protoIndexDir[BINAURAL_CHANNELS] = { 0, 1 }; + hDiracDecBin->ChCrossReOut[bin] += IIReneLimiter[bin] * hDiracDecBin->ChCrossReOutPrev[bin]; + hDiracDecBin->ChCrossImOut[bin] += IIReneLimiter[bin] * hDiracDecBin->ChCrossImOutPrev[bin]; - /* Decorrelation needs interleaved data. Copy left and right signals to proto_frame_f */ - for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) - { - offset = num_freq_bands * BINAURAL_CHANNELS * ch; - for ( bin = 0; bin < num_freq_bands; bin++ ) + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { - protoFrameF[( bin * BINAURAL_CHANNELS ) + offset] = inRe[ch][slot][bin]; - protoFrameF[( bin * BINAURAL_CHANNELS ) + offset + 1] = inIm[ch][slot][bin]; + hDiracDecBin->ChEneOut[ch][bin] += IIReneLimiter[bin] * hDiracDecBin->ChEneOutPrev[ch][bin]; } - } - /* Decorrelate proto signal to decorrelatedFrameInterleaved */ - ivas_dirac_dec_decorr_process( num_freq_bands, - BINAURAL_CHANNELS, - BINAURAL_CHANNELS, - DIRAC_SYNTHESIS_PSD_LS, - BINAURAL_CHANNELS, - protoFrameF, - BINAURAL_CHANNELS, - protoIndexDir, - decorrelatedFrameInterleaved, - onset_filter, - hDiracDecBin->h_freq_domain_decorr_ap_params, - hDiracDecBin->h_freq_domain_decorr_ap_state ); + /* Store energy values and coefficients for next round */ + hDiracDecBin->ChCrossReOutPrev[bin] = hDiracDecBin->ChCrossReOut[bin]; + hDiracDecBin->ChCrossImOutPrev[bin] = hDiracDecBin->ChCrossImOut[bin]; - /* De-interleave decorrelated signals*/ - for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) - { - offset = num_freq_bands * BINAURAL_CHANNELS * ch; - for ( bin = 0; bin < num_freq_bands; bin++ ) + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { - decRe[ch][bin] = decorrelatedFrameInterleaved[( bin * BINAURAL_CHANNELS ) + offset]; - decIm[ch][bin] = decorrelatedFrameInterleaved[( bin * BINAURAL_CHANNELS ) + offset + 1]; + hDiracDecBin->ChEneOutPrev[ch][bin] = hDiracDecBin->ChEneOut[ch][bin]; } } return; } - - +#else static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matrices( DIRAC_DEC_BIN_HANDLE hDiracDecBin, SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, @@ -1254,6 +1973,7 @@ static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matric return; } +#endif static void ivas_dirac_dec_binaural_determine_processing_matrices( DIRAC_DEC_BIN_HANDLE hDiracDecBin, @@ -1495,14 +2215,27 @@ static void ivas_dirac_dec_binaural_process_output( const int16_t max_band_decorr, const int16_t numInChannels, const int16_t processReverb, - const int16_t subframe ) + const int16_t subframe +#ifdef SPLIT_REND_WITH_HEAD_ROT + , + float outRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], + float outIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], + float reverbRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], + float reverbIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], + float decorrRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], + float decorrIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], + const uint8_t recompute +#endif +) { int16_t slot, bin, chA, chB; int16_t nBins; float outSlotRe[CLDFB_NO_CHANNELS_MAX], outSlotIm[CLDFB_NO_CHANNELS_MAX]; float decSlotRe[BINAURAL_CHANNELS][CLDFB_NO_CHANNELS_MAX], decSlotIm[BINAURAL_CHANNELS][CLDFB_NO_CHANNELS_MAX]; +#ifndef SPLIT_REND_WITH_HEAD_ROT float reverbRe[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; float reverbIm[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; +#endif float interpVal; float *decSlotRePointer; float *decSlotImPointer; @@ -1516,7 +2249,14 @@ static void ivas_dirac_dec_binaural_process_output( if ( processReverb ) { /* Process second / room effect part of binaural output when needed */ - ivas_binaural_reverb_processSubframe( hDiracDecBin->hReverb, numInChannels, nSlots, inRe, inIm, reverbRe, reverbIm ); +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( recompute == 1 ) + { +#endif + ivas_binaural_reverb_processSubframe( hDiracDecBin->hReverb, numInChannels, nSlots, inRe, inIm, reverbRe, reverbIm ); +#ifdef SPLIT_REND_WITH_HEAD_ROT + } +#endif } interpVal = 0.0f; @@ -1525,7 +2265,27 @@ static void ivas_dirac_dec_binaural_process_output( interpVal += 1.0f / (float) nSlots; if ( !hDiracDecBin->useTdDecorr && max_band_decorr > 0 ) { - ivas_dirac_dec_decorrelate_slot( hDiracDecBin, nBins, slot, inRe, inIm, decSlotRe, decSlotIm ); +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( recompute == 1 ) + { +#endif + ivas_dirac_dec_decorrelate_slot( hDiracDecBin, nBins, slot, inRe, inIm, decSlotRe, decSlotIm ); +#ifdef SPLIT_REND_WITH_HEAD_ROT + for ( chA = 0; chA < BINAURAL_CHANNELS; chA++ ) + { + mvr2r( decSlotRe[chA], decorrRe[chA][slot], CLDFB_NO_CHANNELS_MAX ); + mvr2r( decSlotIm[chA], decorrIm[chA][slot], CLDFB_NO_CHANNELS_MAX ); + } + } + else + { + for ( chA = 0; chA < BINAURAL_CHANNELS; chA++ ) + { + mvr2r( decorrRe[chA][slot], decSlotRe[chA], CLDFB_NO_CHANNELS_MAX ); + mvr2r( decorrIm[chA][slot], decSlotIm[chA], CLDFB_NO_CHANNELS_MAX ); + } + } +#endif } for ( chA = 0; chA < BINAURAL_CHANNELS; chA++ ) @@ -1603,8 +2363,22 @@ static void ivas_dirac_dec_binaural_process_output( outSlotRePr = &( outSlotRe[0] ); outSlotImPr = &( outSlotIm[0] ); +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( outRe != NULL && outIm != NULL ) + { + /* provide the data outside in CLDFB domain => mainly for split rendering */ + mvr2r( outSlotRePr, outRe[chA][slot], CLDFB_NO_CHANNELS_MAX ); + mvr2r( outSlotImPr, outIm[chA][slot], CLDFB_NO_CHANNELS_MAX ); + } + if ( recompute == 1 ) + { + /* Inverse filter bank */ + cldfbSynthesis( &outSlotRePr, &outSlotImPr, &( output_f[chA][nBins * slot + offsetSamples] ), nBins, cldfbSynDec[chA] ); + } +#else /* Inverse filter bank */ cldfbSynthesis( &outSlotRePr, &outSlotImPr, &( output_f[chA][nBins * slot + offsetSamples] ), nBins, cldfbSynDec[chA] ); +#endif } } @@ -2600,7 +3374,15 @@ static void ivas_masa_ext_rend_parambin_internal( MASA_EXT_REND_HANDLE hMasaExtRend, COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, float *output_f[], - const int16_t subframe ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + const int16_t subframe, + const SPLIT_REND_WRAPPER *hSplitRendWrapper, + float Cldfb_Out_Real[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + float Cldfb_Out_Imag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX] +#else + const int16_t subframe +#endif +) { DIRAC_DEC_BIN_HANDLE hDiracDecBin; SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; @@ -2614,7 +3396,24 @@ static void ivas_masa_ext_rend_parambin_internal( int16_t i, j; int16_t nchan_transport; +#ifdef SPLIT_REND_WITH_HEAD_ROT + int16_t pos_idx; + const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData; + float tmp_Cldfb_out_re[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; + float tmp_Cldfb_out_im[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; + + /* these allow re-using the reverb and freq-domain decorrelator signals from ivas_dirac_dec_binaural_process_output() in split rendering for the side renderings */ + float reverbRe[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; + float reverbIm[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; + float decorrRe[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; + float decorrIm[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; + float subFrameTotalEne[CLDFB_NO_CHANNELS_MAX]; + float IIReneLimiter[CLDFB_NO_CHANNELS_MAX]; + + hDiracDecBin = hMasaExtRend->hDiracDecBin[0]; +#else hDiracDecBin = hMasaExtRend->hDiracDecBin; +#endif assert( hDiracDecBin ); hSpatParamRendCom = hMasaExtRend->hSpatParamRendCom; nBins = hSpatParamRendCom->num_freq_bands; @@ -2685,6 +3484,9 @@ static void ivas_masa_ext_rend_parambin_internal( if ( nchan_transport == 2 ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT + /* in case of split rendering, determine the prototype rotation based on the main direction and use the same prototypes for the offset directions */ +#endif adaptTransportSignalsHeadtracked( hCombinedOrientationData, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, nBins, hSpatParamRendCom->subframe_nbslots[subframe], Rmat ); ivas_dirac_dec_binaural_check_and_switch_transports_headtracked( hCombinedOrientationData, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, nBins, hSpatParamRendCom->subframe_nbslots[subframe], Rmat ); @@ -2692,21 +3494,122 @@ static void ivas_masa_ext_rend_parambin_internal( } +#ifndef SPLIT_REND_WITH_HEAD_ROT ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matrices( hDiracDecBin, hSpatParamRendCom, &config_data, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, Rmat, subframe, hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[hCombinedOrientationData->subframe_idx] > 0, NULL ); +#endif /* Always using CLDFB decorrelation in MASA EXT renderer */ max_band_decorr = hDiracDecBin->h_freq_domain_decorr_ap_params->max_band_decorr; +#ifdef SPLIT_REND_WITH_HEAD_ROT + ivas_dirac_dec_binaural_formulate_input_covariance_matrices( hDiracDecBin, hSpatParamRendCom, &config_data, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, subframe, + subFrameTotalEne, IIReneLimiter ); + ivas_dirac_dec_binaural_formulate_target_covariance_matrices( hDiracDecBin, hSpatParamRendCom, &config_data, Rmat, subframe, + hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[hCombinedOrientationData->subframe_idx] > 0, + subFrameTotalEne, IIReneLimiter, NULL ); +#endif + ivas_dirac_dec_binaural_determine_processing_matrices( hDiracDecBin, hSpatParamRendCom, &config_data, max_band_decorr, Rmat, subframe, hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[hCombinedOrientationData->subframe_idx] > 0, 0, NULL ); +#ifdef SPLIT_REND_WITH_HEAD_ROT + pMultiBinPoseData = NULL; + if ( hSplitRendWrapper != NULL ) + { + pMultiBinPoseData = &( hSplitRendWrapper->multiBinPoseData ); + + ivas_dirac_dec_binaural_process_output( hDiracDecBin, hSpatParamRendCom, hMasaExtRend->cldfbSynRend, output_f, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, + max_band_decorr, numInChannels, config_data.processReverb, subframe, tmp_Cldfb_out_re, tmp_Cldfb_out_im, + reverbRe, reverbIm, decorrRe, decorrIm, 1 ); + + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + for ( i = 0; i < CLDFB_SLOTS_PER_SUBFRAME; i++ ) + { + mvr2r( tmp_Cldfb_out_re[ch][i], Cldfb_Out_Real[ch][subframe * CLDFB_SLOTS_PER_SUBFRAME + i], CLDFB_NO_CHANNELS_MAX ); + mvr2r( tmp_Cldfb_out_im[ch][i], Cldfb_Out_Imag[ch][subframe * CLDFB_SLOTS_PER_SUBFRAME + i], CLDFB_NO_CHANNELS_MAX ); + } + } + } + else + { + ivas_dirac_dec_binaural_process_output( hDiracDecBin, hSpatParamRendCom, hMasaExtRend->cldfbSynRend, output_f, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, + max_band_decorr, numInChannels, config_data.processReverb, subframe, NULL, NULL, + reverbRe, reverbIm, decorrRe, decorrIm, 1 ); + } +#else ivas_dirac_dec_binaural_process_output( hDiracDecBin, hSpatParamRendCom, hMasaExtRend->cldfbSynRend, output_f, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, max_band_decorr, numInChannels, config_data.processReverb, subframe ); +#endif hDiracDecBin->hDiffuseDist = NULL; +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( pMultiBinPoseData != NULL && pMultiBinPoseData->num_poses > 1 ) + { + /* quaternion-based rotation from ivas_binRenderer_internal.c:ivas_binRenderer(), but using absolute rotation instead of delta rotations */ + IVAS_QUATERNION Quaternions_rot, Quaternions_abs, *Quaternions_ref; + float Rmat_local[3][3]; + + if ( hCombinedOrientationData ) + { + Quaternions_ref = &hCombinedOrientationData->Quaternions[0]; + Quaternions_rot.w = -3.0f; /* signal to use Euler */ + Quaternions_abs.w = -3.0f; /* signal to use Euler */ + Quat2EulerDegree( *Quaternions_ref, &Quaternions_abs.z, &Quaternions_abs.y, &Quaternions_abs.x ); /*order in Quat2Euler seems to be reversed ?*/ + + for ( pos_idx = 1; pos_idx < pMultiBinPoseData->num_poses; pos_idx++ ) + { + Quaternions_rot.x = Quaternions_abs.x + pMultiBinPoseData->relative_head_poses[pos_idx][0]; + Quaternions_rot.y = Quaternions_abs.y + pMultiBinPoseData->relative_head_poses[pos_idx][1]; + Quaternions_rot.z = Quaternions_abs.z + pMultiBinPoseData->relative_head_poses[pos_idx][2]; + + QuatToRotMat( Quaternions_rot, Rmat_local ); + + hDiracDecBin = hMasaExtRend->hDiracDecBin[pos_idx]; + assert( hDiracDecBin != NULL && "No DiracDecBin handle for this position" ); + + /* re-use input covariance for the side renderings */ + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + mvr2r( hMasaExtRend->hDiracDecBin[0]->ChEne[ch], hDiracDecBin->ChEne[ch], hSpatParamRendCom->num_freq_bands ); + } + mvr2r( hMasaExtRend->hDiracDecBin[0]->ChCrossRe, hDiracDecBin->ChCrossRe, hSpatParamRendCom->num_freq_bands ); + mvr2r( hMasaExtRend->hDiracDecBin[0]->ChCrossIm, hDiracDecBin->ChCrossIm, hSpatParamRendCom->num_freq_bands ); + + ivas_dirac_dec_binaural_formulate_target_covariance_matrices( hDiracDecBin, hSpatParamRendCom, &config_data, Rmat_local, subframe, + hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[subframe] > 0, + subFrameTotalEne, IIReneLimiter, NULL ); + + ivas_dirac_dec_binaural_determine_processing_matrices( hDiracDecBin, hSpatParamRendCom, &config_data, max_band_decorr, Rmat_local, subframe, + hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[subframe] > 0, + 0, NULL ); + + + /* re-use reverb and decorr from main direction for the sides */ + ivas_dirac_dec_binaural_process_output( hDiracDecBin, hSpatParamRendCom, hMasaExtRend->cldfbSynRend, output_f, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, + max_band_decorr, numInChannels, config_data.processReverb, subframe, tmp_Cldfb_out_re, tmp_Cldfb_out_im, + reverbRe, reverbIm, decorrRe, decorrIm, 0 ); + + /* copy from temporary buffer to the main split rendering buffer */ + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + for ( i = 0; i < CLDFB_SLOTS_PER_SUBFRAME; i++ ) + { + mvr2r( tmp_Cldfb_out_re[ch][i], Cldfb_Out_Real[pos_idx * BINAURAL_CHANNELS + ch][subframe * CLDFB_SLOTS_PER_SUBFRAME + i], CLDFB_NO_CHANNELS_MAX ); + mvr2r( tmp_Cldfb_out_im[ch][i], Cldfb_Out_Imag[pos_idx * BINAURAL_CHANNELS + ch][subframe * CLDFB_SLOTS_PER_SUBFRAME + i], CLDFB_NO_CHANNELS_MAX ); + } + } + + hDiracDecBin->hDiffuseDist = NULL; + } + } + } + + /* update this counter only after the last rendering of split directions */ +#endif hSpatParamRendCom->slots_rendered += hSpatParamRendCom->subframe_nbslots[subframe]; hSpatParamRendCom->subframes_rendered++; @@ -2718,7 +3621,15 @@ void ivas_masa_ext_rend_parambin_render( MASA_EXT_REND_HANDLE hMasaExtRend, /* i/o: MASA ext rend structure */ COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined orientation handle */ float *output_f[], /* i/o: synthesized core-coder transport channels/DirAC output */ - const int16_t num_subframes ) /* i : number of subframes to render */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + const int16_t num_subframes, /* i : number of subframes to render */ + const SPLIT_REND_WRAPPER *hSplitRendWrapper, /* i : split rendering orientation data */ + float Cldfb_Out_Real[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* o : rendered orientations for split rend. real part of cldfb */ + float Cldfb_Out_Imag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX] /* o : rendered orientations for split rend. imag part of cldfb */ +#else + const int16_t num_subframes /* i : number of subframes to render */ +#endif +) { int16_t subframe; SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; @@ -2739,7 +3650,11 @@ void ivas_masa_ext_rend_parambin_render( int16_t n_samples_sf = hSpatParamRendCom->slot_size * CLDFB_SLOTS_PER_SUBFRAME; hSpatParamRendCom->slots_rendered = 0; +#ifdef SPLIT_REND_WITH_HEAD_ROT + ivas_masa_ext_rend_parambin_internal( hMasaExtRend, hCombinedOrientationData, p_output, hSpatParamRendCom->dirac_read_idx, hSplitRendWrapper, Cldfb_Out_Real, Cldfb_Out_Imag ); +#else ivas_masa_ext_rend_parambin_internal( hMasaExtRend, hCombinedOrientationData, p_output, hSpatParamRendCom->dirac_read_idx ); +#endif for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { diff --git a/lib_rend/ivas_dirac_decorr_dec.c b/lib_rend/ivas_dirac_decorr_dec.c index 89c2c4a086068ac02468268de25227c6215464bc..f119ff64e41b0775adb8fb2a84a3bbf621ee756a 100644 --- a/lib_rend/ivas_dirac_decorr_dec.c +++ b/lib_rend/ivas_dirac_decorr_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_dirac_onsets_dec.c b/lib_rend/ivas_dirac_onsets_dec.c index 8a03dc2c50da814c0788b1c81325e87633e0ec46..36d85954379bdcc9e49a746237c1f70735cb55b7 100644 --- a/lib_rend/ivas_dirac_onsets_dec.c +++ b/lib_rend/ivas_dirac_onsets_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_dirac_output_synthesis_dec.c b/lib_rend/ivas_dirac_output_synthesis_dec.c index 8ee3b1e4f588cd0f478e888a3b1b74333721b420..e5ef02ceb2fb635d24940f41e2ae44936a6da1a1 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_dirac_rend.c b/lib_rend/ivas_dirac_rend.c index 9fa1ddd8e4e32a535345742066662495495ebc2a..ae0e86c80e07a02ab8ecb3e5594323d289b9d68c 100644 --- a/lib_rend/ivas_dirac_rend.c +++ b/lib_rend/ivas_dirac_rend.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_efap.c b/lib_rend/ivas_efap.c index 40f5e731202e300447975a2abfd3f5ee6c3ad57a..0dae663aec886bdcabdc6185f0213908fcb16370 100644 --- a/lib_rend/ivas_efap.c +++ b/lib_rend/ivas_efap.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_hrtf.c b/lib_rend/ivas_hrtf.c index 3394e018b7a88685c789deb42ea2afa69238a9e5..523ebd833a2826b19e27d80e333946049f595354 100644 --- a/lib_rend/ivas_hrtf.c +++ b/lib_rend/ivas_hrtf.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_masa_merge.c b/lib_rend/ivas_masa_merge.c index 434dca3fbf0ac939e8b848361377220259c989c2..1af9be61c5fa402a372968884feaf5ab4d948b2a 100644 --- a/lib_rend/ivas_masa_merge.c +++ b/lib_rend/ivas_masa_merge.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_mcmasa_ana.c b/lib_rend/ivas_mcmasa_ana.c index 7ed4aeb0df58e8bae9796b8def729febb8a93240..5128eb96983c207b57c4428eb1aa4b4a5dba2876 100644 --- a/lib_rend/ivas_mcmasa_ana.c +++ b/lib_rend/ivas_mcmasa_ana.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_objectRenderer.c b/lib_rend/ivas_objectRenderer.c index a5db79929f075975fcc645a8220970cbaf901a84..ceba6f5008923d96a6ec8ed1d8193a276992a7e8 100644 --- a/lib_rend/ivas_objectRenderer.c +++ b/lib_rend/ivas_objectRenderer.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_objectRenderer_hrFilt.c b/lib_rend/ivas_objectRenderer_hrFilt.c index ef7966f6bfc357c31e0a80b83c06d8df774f687a..2f49c9319ff6e97d7b5f2b6f71be46cfb82def6e 100644 --- a/lib_rend/ivas_objectRenderer_hrFilt.c +++ b/lib_rend/ivas_objectRenderer_hrFilt.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_objectRenderer_mix.c b/lib_rend/ivas_objectRenderer_mix.c index f65f6a45224f312969c8acc85d668af9e60edc3a..060a580a7acaed93a81710f6c7602e53336c0032 100644 --- a/lib_rend/ivas_objectRenderer_mix.c +++ b/lib_rend/ivas_objectRenderer_mix.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_objectRenderer_sfx.c b/lib_rend/ivas_objectRenderer_sfx.c index fd1c44060f7256bd13b7950578c2071be276ba54..64b8fa5be4143056094b42d21e0b563cac2d8b57 100644 --- a/lib_rend/ivas_objectRenderer_sfx.c +++ b/lib_rend/ivas_objectRenderer_sfx.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_objectRenderer_sources.c b/lib_rend/ivas_objectRenderer_sources.c index 2706a9c5c85604f398c3bcddb4341fb3e78a94db..e772192c3d7bff8e854759a0d9e387b24070125b 100644 --- a/lib_rend/ivas_objectRenderer_sources.c +++ b/lib_rend/ivas_objectRenderer_sources.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_objectRenderer_vec.c b/lib_rend/ivas_objectRenderer_vec.c index 061b790e1b46e9010d14a0b0162b528bbd3768fb..9f75f8904dbb8e58ef9bc4184ce80392d0e98c3f 100644 --- a/lib_rend/ivas_objectRenderer_vec.c +++ b/lib_rend/ivas_objectRenderer_vec.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_omasa_ana.c b/lib_rend/ivas_omasa_ana.c index 16f0e0b5d9961f2dc9048fd77ce8829f897c5f5e..95d67ee4fe130c0b5bd45d9068f77f1c5f723328 100644 --- a/lib_rend/ivas_omasa_ana.c +++ b/lib_rend/ivas_omasa_ana.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_orient_trk.c b/lib_rend/ivas_orient_trk.c index ee380cb6eb4b177a9c7889b942b23b6b7ba50da4..e8377e54bab67e4ae61a5bbad69989a3c6071c07 100644 --- a/lib_rend/ivas_orient_trk.c +++ b/lib_rend/ivas_orient_trk.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_output_init.c b/lib_rend/ivas_output_init.c index 2e53001449ed54c9416abf074cbf129d915e6286..c9894e4885cb27b9deb6270f474deca4eb86ff9e 100644 --- a/lib_rend/ivas_output_init.c +++ b/lib_rend/ivas_output_init.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other @@ -93,6 +93,10 @@ int16_t audioCfg2channels( nchan_out = 8; break; case IVAS_AUDIO_CONFIG_BINAURAL: +#ifdef SPLIT_REND_WITH_HEAD_ROT + case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED: + case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM: +#endif case IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR: case IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB: nchan_out = 2; @@ -220,6 +224,10 @@ void ivas_output_init( hOutSetup->is_planar_setup = 0; break; case IVAS_AUDIO_CONFIG_BINAURAL: +#ifdef SPLIT_REND_WITH_HEAD_ROT + case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED: + case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM: +#endif case IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR: case IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB: case IVAS_AUDIO_CONFIG_ISM1: @@ -316,7 +324,11 @@ int16_t ivas_get_nchan_buffers_dec( { nchan_out_buff = max( nchan_out_buff, st_ivas->hOutSetup.nchan_out_woLFE + st_ivas->hOutSetup.num_lfe ); } +#ifdef SPLIT_REND_WITH_HEAD_ROT + else if ( output_config == IVAS_AUDIO_CONFIG_STEREO || output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) +#else else if ( output_config == IVAS_AUDIO_CONFIG_STEREO || output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) +#endif { nchan_out_buff = 2 * CPE_CHANNELS; } @@ -395,6 +407,12 @@ int16_t ivas_get_nchan_buffers_dec( } } +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + { + nchan_out_buff = max( nchan_out_buff, st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses * BINAURAL_CHANNELS ); + } +#endif return nchan_out_buff; } diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index 20c375b611f9453891efc9b85e9af2bdd1c2476e..d48d4e853accbb7220c38d9a35b4b25ff7edc3dc 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other @@ -77,43 +77,6 @@ int16_t ivas_get_nchan_buffers_dec( const int32_t ivas_total_brate /* i : total IVAS bitrate */ ); -ivas_error get_channel_config( - const AUDIO_CONFIG config, - char *str -); - - -/*----------------------------------------------------------------------------------* - * Limiter prototypes - *----------------------------------------------------------------------------------*/ - - -ivas_error ivas_limiter_open( - IVAS_LIMITER_HANDLE *hLimiter_out, /* o : limiter struct handle */ - const int16_t num_channels, /* i : number of I/O channels */ - const int32_t sampling_rate /* i : sampling rate for processing */ -); - -void ivas_limiter_close( - IVAS_LIMITER_HANDLE* phLimiter /* i/o: pointer to limiter handle, can be NULL */ -); - -void ivas_limiter_dec -( - IVAS_LIMITER_HANDLE hLimiter, /* i/o: limiter struct handle */ - float *output[MAX_OUTPUT_CHANNELS], /* i/o: input/output buffer */ - const int16_t num_channels, /* i : number of channels to be processed */ - const int16_t output_frame, /* i : number of samples per channel in the buffer */ - const int16_t BER_detect /* i : BER detect flag */ -); - -void limiter_process( - IVAS_LIMITER_HANDLE hLimiter, /* i/o: limiter struct handle */ - const int16_t output_frame, /* i : number of samples to be processed per channel in the I/O buffer */ - const float threshold, /* i : signal amplitude above which limiting starts to be applied */ - const int16_t BER_detect, /* i : BER detect flag */ - int16_t *strong_saturation_cnt /* i/o: counter of strong saturations (can be NULL) */ -); /*----------------------------------------------------------------------------------* * TD decorr. function prototypes @@ -240,7 +203,14 @@ void ivas_masa_ext_rend_parambin_render( MASA_EXT_REND_HANDLE hMasaExtRend, /* i/o: MASA ext rend structure */ COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined orientation handle */ float *output_f[], /* i/o: synthesized core-coder transport channels/DirAC output */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + const int16_t num_subframes, /* i : number of subframes to render */ + const SPLIT_REND_WRAPPER *hSplitRendWrapper, /* i : split rendering orientation data */ + float Cldfb_Out_Real[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* o : rendered orientations for split rend. real part of cldfb */ + float Cldfb_Out_Imag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX] /* o : rendered orientations for split rend. imag part of cldfb */ +#else const int16_t num_subframes /* i : number of subframes to render */ +#endif ); ivas_error ivas_dirac_dec_init_binaural_data( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ @@ -887,11 +857,21 @@ ivas_error ivas_rend_openCrend( const AUDIO_CONFIG outConfig, RENDER_CONFIG_DATA *hRendCfg, HRTFS_CREND_HANDLE hSetOfHRTF, +#ifdef SPLIT_REND_WITH_HEAD_ROT + const int32_t output_Fs, + const int16_t num_poses +#else const int32_t output_Fs +#endif ); void ivas_rend_closeCrend( +#ifdef SPLIT_REND_WITH_HEAD_ROT + CREND_WRAPPER_HANDLE *pCrend , + const int16_t num_poses +#else CREND_WRAPPER_HANDLE *pCrend +#endif ); ivas_error ivas_hrtf_init( @@ -899,7 +879,12 @@ ivas_error ivas_hrtf_init( ); ivas_error ivas_rend_initCrendWrapper( +#ifdef SPLIT_REND_WITH_HEAD_ROT + CREND_WRAPPER_HANDLE *pCrend, + const int16_t num_poses +#else CREND_WRAPPER_HANDLE *pCrend +#endif ); ivas_error ivas_rend_crendProcess( @@ -912,7 +897,12 @@ ivas_error ivas_rend_crendProcess( EFAP_HANDLE hEFAPdata, float *output[], /* i/o: input/output audio channels */ const int32_t output_Fs, +#ifdef SPLIT_REND_WITH_HEAD_ROT + const int16_t num_subframes, /* i : number of subframes to render */ + const int16_t pos_idx /* i : pose index */ +#else const int16_t num_subframes /* i : number of subframes to render */ +#endif ); ivas_error ivas_rend_crendProcessSubframe( @@ -928,6 +918,10 @@ ivas_error ivas_rend_crendProcessSubframe( float *output[], /* i/o: input/output audio channels */ const int16_t n_samples_to_render, /* i : output frame length per channel */ const int32_t output_Fs /* i : output sampling rate */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + , + const int16_t pos_idx +#endif ); @@ -1237,10 +1231,6 @@ void Euler2Quat( IVAS_QUATERNION *quat /* o : quaternion describing the rotation */ ); -float deg2rad( - float degrees -); - float rad2deg( float radians ); @@ -1250,6 +1240,14 @@ void QuatToRotMat( float Rmat[3][3] /* o : real-space rotation matrix for this rotation */ ); +#ifdef SPLIT_REND_WITH_HEAD_ROT +void Quat2EulerDegree( + const IVAS_QUATERNION quat, /* i : quaternion describing the rotation */ + float *yaw, /* o : yaw */ + float *pitch, /* o : pitch */ + float *roll /* o : roll */ +); +#endif void rotateAziEle( float azi_in, /* i : output elevation */ @@ -1538,6 +1536,86 @@ void masaPrerendClose( ); +#ifdef SPLIT_REND_WITH_HEAD_ROT +/*----------------------------------------------------------------------------------* + * Split rendering + *----------------------------------------------------------------------------------*/ + +ivas_error ivas_td_binaural_renderer_sf_splitBinaural( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + float *output[], /* i/o: SCE channels / Binaural synthesis */ + const int16_t nSamplesRendered /* i : number of samples to render */ +); + +ivas_error ivas_rend_crendProcessSubframesSplitBin( + const CREND_WRAPPER *pCrend, /* i/o: Crend wrapper handle */ + const AUDIO_CONFIG inConfig, /* i : input audio configuration */ + const AUDIO_CONFIG outConfig, /* i : output audio configuration */ + const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + const DECODER_CONFIG_HANDLE hDecoderConfig, /* i : decoder config. structure */ + const COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined orientation handle */ + const IVAS_OUTPUT_SETUP_HANDLE hIntSetup, /* i : internal setup handle */ + const EFAP_HANDLE hEFAPdata, /* i : EFAP handle */ + DECODER_TC_BUFFER_HANDLE hTcBuffer, /* i/o: JBM handle */ + float *input_f[], /* i : transport channels */ + float *output[], /* i/o: input/output audio channels */ + const int16_t n_samples_to_render, /* i : output frame length per channel */ + const int32_t output_Fs /* i : output sampling rate */ +); + +ivas_error ivas_rend_crendProcessSplitBin( + const CREND_WRAPPER *pCrend, + const AUDIO_CONFIG inConfig, + const AUDIO_CONFIG outConfig, + const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + const DECODER_CONFIG_HANDLE hDecoderConfig, + const COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, + const IVAS_OUTPUT_SETUP_HANDLE hIntSetup, + EFAP_HANDLE hEFAPdata, + float *output[], + const int32_t output_Fs +); + +ivas_error ivas_rend_openMultiBinCrend( + CREND_WRAPPER_HANDLE *pCrend, + const AUDIO_CONFIG inConfig, + const AUDIO_CONFIG outConfig, + const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + const int32_t output_Fs +); + +void ivas_rend_CldfbMultiBinRendProcess( + const BINAURAL_RENDERER_HANDLE hCldfbRend, + const COMBINED_ORIENTATION_HANDLE *pCombinedOrientationData, + const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + float Cldfb_In_Real[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + float Cldfb_In_Imag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + float Cldfb_Out_Real[MAX_HEAD_ROT_POSES*BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* o : Binaural signals */ + float Cldfb_Out_Imag[MAX_HEAD_ROT_POSES*BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + const int16_t low_res_pre_rend_rot, + const int16_t num_subframes +); + +ivas_error ivas_rend_openCldfb( + HANDLE_CLDFB_FILTER_BANK cldfbAna[MAX_INPUT_CHANNELS], + const AUDIO_CONFIG inConfig, + const int32_t output_Fs +); + +ivas_error ivas_rend_openCldfbRend( + CLDFB_REND_WRAPPER *pCldfbRend, + const AUDIO_CONFIG inConfig, + const AUDIO_CONFIG outConfig, + const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + const int32_t output_Fs +); + +void ivas_rend_closeCldfbRend( + CLDFB_REND_WRAPPER *pCldfbRend +); + +#endif + /* clang-format on */ #endif /* IVAS_PROT_REND_H */ diff --git a/lib_rend/ivas_reflections.c b/lib_rend/ivas_reflections.c index 47143e20c3e97682454a78dc039a35ce06367344..9bc214d312cf7ed29a1730aa69e133d0e8a12ee6 100644 --- a/lib_rend/ivas_reflections.c +++ b/lib_rend/ivas_reflections.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_render_config.c b/lib_rend/ivas_render_config.c index 1e5aec6d4350e17b4f391581e633f1722d5c7a23..5226c0dcbd5801454acbccbdc53f8a37e03b213b 100644 --- a/lib_rend/ivas_render_config.c +++ b/lib_rend/ivas_render_config.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other @@ -131,6 +131,22 @@ ivas_error ivas_render_config_init_from_rom( ( *hRenderConfig )->directivity[i * 3 + 1] = 360.0f; /* Back cone */ ( *hRenderConfig )->directivity[i * 3 + 2] = 1.0f; /* Back attenuation */ } +#ifdef SPLIT_REND_WITH_HEAD_ROT + ( *hRenderConfig )->split_rend_config.splitRendBitRate = SPLIT_REND_768k; + ( *hRenderConfig )->split_rend_config.dof = 3; + ( *hRenderConfig )->split_rend_config.hq_mode = 0; + ( *hRenderConfig )->split_rend_config.codec_delay_ms = 0; +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + ( *hRenderConfig )->split_rend_config.isar_frame_size_ms = 20; +#endif + ( *hRenderConfig )->split_rend_config.codec_frame_size_ms = 0; /* 0 means "use default for selected codec" */ + ( *hRenderConfig )->split_rend_config.codec = ISAR_SPLIT_REND_CODEC_DEFAULT; + ( *hRenderConfig )->split_rend_config.poseCorrectionMode = ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB; + ( *hRenderConfig )->split_rend_config.rendererSelection = ISAR_SPLIT_REND_RENDERER_SELECTION_DEFAULT; +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + ( *hRenderConfig )->split_rend_config.lc3plus_highres = 0; +#endif +#endif return IVAS_ERR_OK; } diff --git a/lib_rend/ivas_reverb.c b/lib_rend/ivas_reverb.c index 537ecde2c294e90f1f6f071000ad4f6fc24cb1c1..a72df8603aee1e32d5776c5eb1fe490622911c48 100644 --- a/lib_rend/ivas_reverb.c +++ b/lib_rend/ivas_reverb.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_reverb_delay_line.c b/lib_rend/ivas_reverb_delay_line.c index a91551f71d63d0edf763ba24077ad3e3a34126e9..933cdb3958eea9334c178f99b4cfac0590d1911a 100644 --- a/lib_rend/ivas_reverb_delay_line.c +++ b/lib_rend/ivas_reverb_delay_line.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_reverb_fft_filter.c b/lib_rend/ivas_reverb_fft_filter.c index 8b14d2d41ed9ef41881162e79a3e2e8fb5950845..00ece5acbc9d45f7d8951eef8d008b3ae0c0b687 100644 --- a/lib_rend/ivas_reverb_fft_filter.c +++ b/lib_rend/ivas_reverb_fft_filter.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_reverb_filter_design.c b/lib_rend/ivas_reverb_filter_design.c index 2c4dc75303e0aba1873da883eee29d81a0132307..0dd7e4d5c2d716e2267d44099094d8254ab67126 100644 --- a/lib_rend/ivas_reverb_filter_design.c +++ b/lib_rend/ivas_reverb_filter_design.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_reverb_iir_filter.c b/lib_rend/ivas_reverb_iir_filter.c index ce73c9d864ed12705a82e739e891aef31c558b30..e7db89f379f9baf9e2ac49685dba061c8340de0b 100644 --- a/lib_rend/ivas_reverb_iir_filter.c +++ b/lib_rend/ivas_reverb_iir_filter.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_reverb_utils.c b/lib_rend/ivas_reverb_utils.c index 23d7592ce6a219c6ec2d153b512fa3e46cf9b11a..b1f9822fd8028f11fbf191395c01324dced1dc4e 100644 --- a/lib_rend/ivas_reverb_utils.c +++ b/lib_rend/ivas_reverb_utils.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_rom_TdBinauralRenderer.c b/lib_rend/ivas_rom_TdBinauralRenderer.c index c3c8ae11826ef28e0b25f12a1b5c5b58fc0432b7..02200c7d50c4ef9ba6477925ebd89a74df2a3e50 100644 --- a/lib_rend/ivas_rom_TdBinauralRenderer.c +++ b/lib_rend/ivas_rom_TdBinauralRenderer.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_rom_TdBinauralRenderer.h b/lib_rend/ivas_rom_TdBinauralRenderer.h index e60a72783a8e18ef6559b3abedf4966627c8c88e..43aa30acfab6e77c3c401ac3525d68f3d7f79af5 100644 --- a/lib_rend/ivas_rom_TdBinauralRenderer.h +++ b/lib_rend/ivas_rom_TdBinauralRenderer.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_rom_binauralRenderer.c b/lib_rend/ivas_rom_binauralRenderer.c index 5708cc7e6a4199b18d6a0b18a06b4f9475bc2c05..84077a581c71be9fcbdef0514b583c03a281c8df 100644 --- a/lib_rend/ivas_rom_binauralRenderer.c +++ b/lib_rend/ivas_rom_binauralRenderer.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_rom_binauralRenderer.h b/lib_rend/ivas_rom_binauralRenderer.h index 97ec8f390dd0d0d2d605f5502aaf2e3d995beef2..8b0b05e630b24740a04e892e153b84cca5311333 100644 --- a/lib_rend/ivas_rom_binauralRenderer.h +++ b/lib_rend/ivas_rom_binauralRenderer.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_rom_binaural_crend_head.c b/lib_rend/ivas_rom_binaural_crend_head.c index b313ffa5344387fcf8ffba232d49973bed34abd6..d03ccf65214c365db4080a61853899b891b8b113 100644 --- a/lib_rend/ivas_rom_binaural_crend_head.c +++ b/lib_rend/ivas_rom_binaural_crend_head.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_rom_binaural_crend_head.h b/lib_rend/ivas_rom_binaural_crend_head.h index 4853122a2dc04f26e53b3b15e22c06612391bb09..72ad3b2f192e304bcb88bf66810d74bdea5730da 100644 --- a/lib_rend/ivas_rom_binaural_crend_head.h +++ b/lib_rend/ivas_rom_binaural_crend_head.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_rom_rend.c b/lib_rend/ivas_rom_rend.c index 99ffe44285b7e806b6fd600bd96f37d2ea61312a..e0d35a3c156fcd8413a735502358b86ca34e9ff7 100644 --- a/lib_rend/ivas_rom_rend.c +++ b/lib_rend/ivas_rom_rend.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_rom_rend.h b/lib_rend/ivas_rom_rend.h index a6f309c267cdb81dd4568e9db5c95c9d0c8e9156..d103acae6bfb726d83222ddb08c0387cb6c9369c 100644 --- a/lib_rend/ivas_rom_rend.h +++ b/lib_rend/ivas_rom_rend.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_rotation.c b/lib_rend/ivas_rotation.c index a87d3c31a299ff4888d663376d179ae24fbd4497..28f2a6e9df873e5d130f44dcb97db4eef66f1663 100644 --- a/lib_rend/ivas_rotation.c +++ b/lib_rend/ivas_rotation.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other @@ -37,6 +37,7 @@ #include #include "cnst.h" #include "prot.h" +#include "ivas_prot.h" #include "ivas_prot_rend.h" #ifdef DEBUGGING #include "debug.h" @@ -51,6 +52,9 @@ static ivas_error combine_external_and_head_orientations( IVAS_QUATERNION *headRotQuaternions, IVAS_VECTOR3 *listenerPos, +#ifdef SPLIT_REND_WITH_HEAD_ROT + ISAR_SPLIT_REND_ROT_AXIS sr_pose_pred_axis, /* i : split rend pose prediction axis*/ +#endif EXTERNAL_ORIENTATION_HANDLE hExtOrientationData, COMBINED_ORIENTATION_HANDLE hCombinedOrientationData ); @@ -102,6 +106,9 @@ ivas_error ivas_headTrack_open( ( *hHeadTrackData )->Rmat_prev[i][i] = 1.0f; } +#ifdef SPLIT_REND_WITH_HEAD_ROT + ( *hHeadTrackData )->sr_pose_pred_axis = DEFAULT_AXIS; +#endif set_zero( ( *hHeadTrackData )->chEneIIR[0], MASA_FREQUENCY_BANDS ); set_zero( ( *hHeadTrackData )->chEneIIR[1], MASA_FREQUENCY_BANDS ); @@ -151,72 +158,34 @@ void QuatToRotMat( float Rmat[3][3] /* o : real-space rotation matrix for this rotation */ ) { - Rmat[0][0] = quat.w * quat.w + quat.x * quat.x - quat.y * quat.y - quat.z * quat.z; - Rmat[0][1] = 2.0f * ( quat.x * quat.y - quat.w * quat.z ); - Rmat[0][2] = 2.0f * ( quat.x * quat.z + quat.w * quat.y ); - - Rmat[1][0] = 2.0f * ( quat.x * quat.y + quat.w * quat.z ); - Rmat[1][1] = quat.w * quat.w - quat.x * quat.x + quat.y * quat.y - quat.z * quat.z; - Rmat[1][2] = 2.0f * ( quat.y * quat.z - quat.w * quat.x ); - - Rmat[2][0] = 2.0f * ( quat.x * quat.z - quat.w * quat.y ); - Rmat[2][1] = 2.0f * ( quat.y * quat.z + quat.w * quat.x ); - Rmat[2][2] = quat.w * quat.w - quat.x * quat.x - quat.y * quat.y + quat.z * quat.z; - - return; -} - - -/*------------------------------------------------------------------------- - * Euler2Quat() - * - * Calculate corresponding Quaternion from Euler angles in radians - *------------------------------------------------------------------------*/ - -void Euler2Quat( - const float yaw, /* i : yaw (x) */ - const float pitch, /* i : pitch (y) */ - const float roll, /* i : roll (z) */ - IVAS_QUATERNION *quat /* o : quaternion describing the rotation */ -) -{ - float cr = cosf( roll * 0.5f ); - float sr = sinf( roll * 0.5f ); - float cp = cosf( pitch * 0.5f ); - float sp = sinf( pitch * 0.5f ); - float cy = cosf( yaw * 0.5f ); - float sy = sinf( yaw * 0.5f ); - quat->w = cr * cp * cy + sr * sp * sy; - quat->x = sr * cp * cy - cr * sp * sy; - quat->y = sr * cp * sy + cr * sp * cy; - quat->z = cr * cp * sy - sr * sp * cy; - - return; -} - - -/*------------------------------------------------------------------------- - * deg2rad() - * - * Converts degrees to normalized radians - *------------------------------------------------------------------------*/ - -float deg2rad( - float degrees ) -{ - while ( degrees >= 180.0f ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( quat.w == -3.0 ) { - degrees = degrees - 360.0f; + IVAS_QUATERNION quat_local; + Euler2Quat( deg2rad( quat.x ), deg2rad( quat.y ), deg2rad( quat.z ), &quat_local ); + QuatToRotMat( quat_local, Rmat ); } - while ( degrees <= -180.0f ) + else { - degrees = degrees + 360.0f; +#endif + Rmat[0][0] = quat.w * quat.w + quat.x * quat.x - quat.y * quat.y - quat.z * quat.z; + Rmat[0][1] = 2.0f * ( quat.x * quat.y - quat.w * quat.z ); + Rmat[0][2] = 2.0f * ( quat.x * quat.z + quat.w * quat.y ); + + Rmat[1][0] = 2.0f * ( quat.x * quat.y + quat.w * quat.z ); + Rmat[1][1] = quat.w * quat.w - quat.x * quat.x + quat.y * quat.y - quat.z * quat.z; + Rmat[1][2] = 2.0f * ( quat.y * quat.z - quat.w * quat.x ); + + Rmat[2][0] = 2.0f * ( quat.x * quat.z - quat.w * quat.y ); + Rmat[2][1] = 2.0f * ( quat.y * quat.z + quat.w * quat.x ); + Rmat[2][2] = quat.w * quat.w - quat.x * quat.x - quat.y * quat.y + quat.z * quat.z; +#ifdef SPLIT_REND_WITH_HEAD_ROT } +#endif - return PI_OVER_180 * degrees; + return; } - /*------------------------------------------------------------------------- * rad2deg() * @@ -325,7 +294,11 @@ void rotateFrame_shd( } /* calculate ambisonics rotation matrices for the previous and current frames */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + SHrotmatgen( SHrotmat_prev, hCombinedOrientationData->Rmat_prev[0], shd_rot_max_order ); +#else SHrotmatgen( SHrotmat_prev, hCombinedOrientationData->Rmat_prev, shd_rot_max_order ); +#endif SHrotmatgen( SHrotmat, hCombinedOrientationData->Rmat[hCombinedOrientationData->subframe_idx], shd_rot_max_order ); @@ -382,7 +355,11 @@ void rotateFrame_shd( { mvr2r( hCombinedOrientationData->Rmat[hCombinedOrientationData->subframe_idx][i], +#ifdef SPLIT_REND_WITH_HEAD_ROT + hCombinedOrientationData->Rmat_prev[0][i], +#else hCombinedOrientationData->Rmat_prev[i], +#endif 3 ); } @@ -448,7 +425,11 @@ void rotateFrame_sd( ch_in_woLFE = ( ch_in >= index_lfe ) ? ch_in - 1 : ch_in; /* gains for previous subframe rotation */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + rotateAziEle( hTransSetup.ls_azimuth[ch_in_woLFE], hTransSetup.ls_elevation[ch_in_woLFE], &azimuth, &elevation, hCombinedOrientationData->Rmat_prev[0], hTransSetup.is_planar_setup ); +#else rotateAziEle( hTransSetup.ls_azimuth[ch_in_woLFE], hTransSetup.ls_elevation[ch_in_woLFE], &azimuth, &elevation, hCombinedOrientationData->Rmat_prev, hTransSetup.is_planar_setup ); +#endif if ( hEFAPdata != NULL && ( hTransSetup.ls_azimuth[ch_in_woLFE] != azimuth || hTransSetup.ls_elevation[ch_in_woLFE] != elevation ) ) { @@ -509,7 +490,11 @@ void rotateFrame_sd( { mvr2r( hCombinedOrientationData->Rmat[hCombinedOrientationData->subframe_idx][i], +#ifdef SPLIT_REND_WITH_HEAD_ROT + hCombinedOrientationData->Rmat_prev[0][i], +#else hCombinedOrientationData->Rmat_prev[i], +#endif 3 ); } @@ -801,6 +786,9 @@ ivas_error ivas_combined_orientation_open( int16_t j; IVAS_QUATERNION identity; IVAS_VECTOR3 origo; +#ifdef SPLIT_REND_WITH_HEAD_ROT + int16_t pos_idx; +#endif identity.w = 1.0f; identity.x = identity.y = identity.z = 0.0f; @@ -845,11 +833,24 @@ ivas_error ivas_combined_orientation_open( } } +#ifdef SPLIT_REND_WITH_HEAD_ROT + for ( pos_idx = 0; pos_idx < MAX_HEAD_ROT_POSES; pos_idx++ ) + { + for ( j = 0; j < 3; j++ ) + { + set_zero( ( *hCombinedOrientationData )->Rmat_prev[pos_idx][j], 3 ); + ( *hCombinedOrientationData )->Rmat_prev[pos_idx][j][j] = 1.0f; + } + } + ( *hCombinedOrientationData )->sr_pose_pred_axis = DEFAULT_AXIS; + ( *hCombinedOrientationData )->sr_low_res_flag = 0; +#else for ( j = 0; j < 3; j++ ) { set_zero( ( *hCombinedOrientationData )->Rmat_prev[j], 3 ); ( *hCombinedOrientationData )->Rmat_prev[j][j] = 1.0f; } +#endif ( *hCombinedOrientationData )->Quaternion_prev_extOrientation = identity; ( *hCombinedOrientationData )->Quaternion_frozen_ext = identity; @@ -906,6 +907,9 @@ ivas_error combine_external_and_head_orientations_dec( COMBINED_ORIENTATION_HANDLE hCombinedOrientationData /* i/o: combined orientation handle */ ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT + ISAR_SPLIT_REND_ROT_AXIS sr_pose_pred_axis; +#endif IVAS_QUATERNION *pHeadRotQuaternion = NULL; IVAS_VECTOR3 *listenerPos = NULL; @@ -913,9 +917,21 @@ ivas_error combine_external_and_head_orientations_dec( { pHeadRotQuaternion = hHeadTrackData->Quaternions; listenerPos = hHeadTrackData->Pos; +#ifdef SPLIT_REND_WITH_HEAD_ROT + sr_pose_pred_axis = hHeadTrackData->sr_pose_pred_axis; +#endif } +#ifdef SPLIT_REND_WITH_HEAD_ROT + else + { + sr_pose_pred_axis = DEFAULT_AXIS; + } +#endif return combine_external_and_head_orientations( pHeadRotQuaternion, listenerPos, +#ifdef SPLIT_REND_WITH_HEAD_ROT + sr_pose_pred_axis, +#endif hExtOrientationData, hCombinedOrientationData ); } @@ -932,10 +948,16 @@ ivas_error combine_external_and_head_orientations_rend( COMBINED_ORIENTATION_HANDLE hCombinedOrientationData /* i/o: combined orientation handle */ ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT + ISAR_SPLIT_REND_ROT_AXIS sr_pose_pred_axis; +#endif IVAS_QUATERNION *headRotQuaternions = NULL; IVAS_VECTOR3 *listenerPos = NULL; int16_t i; +#ifdef SPLIT_REND_WITH_HEAD_ROT + sr_pose_pred_axis = DEFAULT_AXIS; +#endif if ( hHeadTrackData != NULL ) { if ( hHeadTrackData->headRotEnabled ) @@ -943,6 +965,9 @@ ivas_error combine_external_and_head_orientations_rend( headRotQuaternions = hHeadTrackData->headPositions; listenerPos = hHeadTrackData->Pos; } +#ifdef SPLIT_REND_WITH_HEAD_ROT + sr_pose_pred_axis = hHeadTrackData->sr_pose_pred_axis; +#endif } else if ( hExtOrientationData != NULL ) { @@ -957,6 +982,9 @@ ivas_error combine_external_and_head_orientations_rend( } return combine_external_and_head_orientations( headRotQuaternions, listenerPos, +#ifdef SPLIT_REND_WITH_HEAD_ROT + sr_pose_pred_axis, +#endif hExtOrientationData, hCombinedOrientationData ); } @@ -969,8 +997,11 @@ ivas_error combine_external_and_head_orientations_rend( *------------------------------------------------------------------------*/ ivas_error combine_external_and_head_orientations( - IVAS_QUATERNION *headRotQuaternions, /* i : quaternions for head rotation */ - IVAS_VECTOR3 *listenerPos, /* i : listener position */ + IVAS_QUATERNION *headRotQuaternions, /* i : quaternions for head rotation */ + IVAS_VECTOR3 *listenerPos, /* i : listener position */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + ISAR_SPLIT_REND_ROT_AXIS sr_pose_pred_axis, /* i : split rend pose prediction axis */ +#endif EXTERNAL_ORIENTATION_HANDLE hExtOrientationData, /* i : external orientation handle */ COMBINED_ORIENTATION_HANDLE hCombinedOrientationData /* i/o: combined orientation handle */ ) @@ -1206,6 +1237,9 @@ ivas_error combine_external_and_head_orientations( } } +#ifdef SPLIT_REND_WITH_HEAD_ROT + hCombinedOrientationData->sr_pose_pred_axis = sr_pose_pred_axis; +#endif hCombinedOrientationData->subframe_idx = 0; hCombinedOrientationData->cur_subframe_samples_rendered = 0; hCombinedOrientationData->subframe_idx_start = 0; @@ -1426,7 +1460,11 @@ static float SHrot_w( if ( m == 0 ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT + assert( 0 && "ERROR should not be called\n" ); +#else printf( "ERROR should not be called\n" ); +#endif return 0.0f; } else @@ -1573,7 +1611,11 @@ void ivas_combined_orientation_update_index( { if ( hCombinedOrientationData != NULL ) { - if ( hCombinedOrientationData->num_subframes == 1 ) + if ( hCombinedOrientationData->num_subframes == 1 +#ifdef SPLIT_REND_WITH_HEAD_ROT + || hCombinedOrientationData->sr_low_res_flag +#endif + ) { /* only one orientation available anyway or split rendering with low resolution*/ hCombinedOrientationData->subframe_idx = 0; @@ -1624,7 +1666,11 @@ void ivas_combined_orientation_update_start_index( { if ( hCombinedOrientationData != NULL ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( hCombinedOrientationData->num_subframes == 1 || hCombinedOrientationData->sr_low_res_flag ) +#else if ( hCombinedOrientationData->num_subframes == 1 ) +#endif { /* only one orientation available anyway or split rendering with low resolution*/ hCombinedOrientationData->subframe_idx = 0; diff --git a/lib_rend/ivas_sba_rendering.c b/lib_rend/ivas_sba_rendering.c index 6fc30a4770c8ec8f36898aecd5f49d720ae76966..6533c3c44f5793ac7b56319cdd898afeacc4fd58 100644 --- a/lib_rend/ivas_sba_rendering.c +++ b/lib_rend/ivas_sba_rendering.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_shoebox.c b/lib_rend/ivas_shoebox.c index 12368f5fde5ae8a4af31a898e1e962ceef9c9336..fced52304b2f94fa14b17c7ad8d39240471d79f0 100644 --- a/lib_rend/ivas_shoebox.c +++ b/lib_rend/ivas_shoebox.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other @@ -33,6 +33,7 @@ #include "options.h" #include #include +#include "ivas_prot.h" #include "ivas_prot_rend.h" #include "ivas_stat_rend.h" #include "ivas_cnst.h" diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index 09376064e60092dc627240105cb48f728ff2100a..2ea4ca819c4f610f953eb8265cbeb32ea639c42c 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other @@ -39,6 +39,7 @@ #include "ivas_stat_com.h" // note: needed for DIRAC_DEC_BIN_HANDLE until #156 is solved #include "stat_com.h" /* Note: Currently needed for CLDFB. */ #include "common_api_types.h" +#include "isar_stat.h" /*----------------------------------------------------------------------------------* @@ -544,8 +545,13 @@ typedef struct ivas_binaural_rendering_conv_module_struct float ***filterTapsRightReal; float ***filterTapsRightImag; +#ifdef SPLIT_REND_WITH_HEAD_ROT + float ****filterStatesLeftReal; + float ****filterStatesLeftImag; +#else float ***filterStatesLeftReal; float ***filterStatesLeftImag; +#endif int16_t numTapsArray[BINAURAL_CONVBANDS]; int16_t numTaps; @@ -643,6 +649,9 @@ typedef struct IVAS_QUATERNION headPositions[MAX_PARAM_SPATIAL_SUBFRAMES]; IVAS_VECTOR3 Pos[MAX_PARAM_SPATIAL_SUBFRAMES]; float crossfade[L_FRAME48k / MAX_PARAM_SPATIAL_SUBFRAMES]; +#ifdef SPLIT_REND_WITH_HEAD_ROT + ISAR_SPLIT_REND_ROT_AXIS sr_pose_pred_axis; +#endif ivas_orient_trk_state_t *hOrientationTracker; } IVAS_REND_HeadRotData; @@ -664,6 +673,9 @@ typedef struct ivas_binaural_head_track_struct int16_t shd_rot_max_order; ivas_orient_trk_state_t *OrientationTracker; +#ifdef SPLIT_REND_WITH_HEAD_ROT + ISAR_SPLIT_REND_ROT_AXIS sr_pose_pred_axis; +#endif } HEAD_TRACK_DATA, *HEAD_TRACK_DATA_HANDLE; @@ -701,11 +713,19 @@ typedef struct ivas_combined_orientation_struct IVAS_QUATERNION Quaternions_ext_interpolation_start; IVAS_QUATERNION Quaternions_ext_interpolation_target; float Rmat[MAX_PARAM_SPATIAL_SUBFRAMES][3][3]; +#ifdef SPLIT_REND_WITH_HEAD_ROT + float Rmat_prev[MAX_HEAD_ROT_POSES][3][3]; +#else float Rmat_prev[3][3]; +#endif float chEneIIR[2][MASA_FREQUENCY_BANDS]; /* independent of the format. MASA bands are suitable for the task and readily available in ROM. */ float procChEneIIR[2][MASA_FREQUENCY_BANDS]; int16_t shd_rot_max_order; IVAS_VECTOR3 listenerPos[MAX_PARAM_SPATIAL_SUBFRAMES]; +#ifdef SPLIT_REND_WITH_HEAD_ROT + ISAR_SPLIT_REND_ROT_AXIS sr_pose_pred_axis; + int16_t sr_low_res_flag; +#endif IVAS_QUATERNION Quaternion_frozen_ext; IVAS_QUATERNION Quaternion_frozen_head; int8_t isExtOrientationFrozen; @@ -1196,12 +1216,44 @@ typedef struct ivas_crend_state_t typedef struct ivas_binaural_crend_wrapper_struct { int32_t binaural_latency_ns; +#ifdef SPLIT_REND_WITH_HEAD_ROT + CREND_HANDLE hCrend[MAX_HEAD_ROT_POSES]; +#else CREND_HANDLE hCrend; +#endif HRTFS_HANDLE hHrtfCrend; } CREND_WRAPPER, *CREND_WRAPPER_HANDLE; +#ifdef SPLIT_REND_WITH_HEAD_ROT +/* Fastconv binaural data structure */ +typedef struct ivas_binaural_rendering_struct +{ + /* Common variables for all modules */ + IVAS_OUTPUT_SETUP_HANDLE hInputSetup; /* pointer to input spatial format for binaural renderer*/ + EFAP_HANDLE hEFAPdata; /* EFAP structure*/ + float *hoa_dec_mtx; /* pointer to HOA decoder mtx */ + int8_t rotInCldfb; /* Flag to enable rotation within bin Renderer in CLDFB*/ + int16_t max_band; /* band upto which rendering is performed */ + int16_t conv_band; /* band upto which convolution in cldfb domain is performed */ + int16_t timeSlots; /* number of time slots of binaural renderer */ + int16_t nInChannels; /* number input channels */ + int8_t render_lfe; /* Flag to render LFE in binaural rendering*/ + IVAS_FORMAT ivas_format; /* format; corresponds to st_ivas->ivas_format, unless the signal gets transormed to a different domain for rendering */ + + /* Convolution module structure */ + BINRENDERER_CONV_MODULE_HANDLE hBinRenConvModule; + + /* Variables related to reverberator module */ + float earlyPartEneCorrection[CLDFB_NO_CHANNELS_MAX]; + REVERB_STRUCT_HANDLE hReverb; + + int16_t numPoses; + +} BINAURAL_RENDERER, *BINAURAL_RENDERER_HANDLE; +#endif + /*------------------------------------------------------------------------------------------* * HRTF structures - hrtfs from binary files *------------------------------------------------------------------------------------------*/ @@ -1268,6 +1320,150 @@ typedef struct ivas_hrtfs_parambin_struct } HRTFS_PARAMBIN, *HRTFS_PARAMBIN_HANDLE; +#ifdef SPLIT_REND_WITH_HEAD_ROT +/*----------------------------------------------------------------------------------* + * Binaural split rendering structures + *----------------------------------------------------------------------------------*/ + +/* binaural split rendering head rotation data structure */ +typedef struct ivas_binaural_head_rot_split_rendering_md_struct +{ + float pred_mat_re[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + float pred_mat_im[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + float gd; + float gd2; + int16_t pred_mat_re_idx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + int16_t pred_mat_im_idx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + int16_t gd_idx; + int16_t gd2_idx; + +} BIN_HR_SPLIT_REND_MD, *BIN_HR_SPLIT_REND_MD_HANDLE; + +typedef struct ivas_split_rend_huffman_cfg_t +{ + const int32_t *codebook; + int16_t min_len; + int16_t max_len; + int16_t sym_len; + +} ivas_split_rend_huffman_cfg_t; + +typedef struct ivas_binaural_head_rot_split_rendering_huff_struct +{ + ivas_split_rend_huffman_cfg_t pred[2]; + int16_t pred_idx_trav[2][ISAR_SPLIT_REND_PRED_63QUANT_PNTS]; + int16_t pred_base2_code_len[2]; + ivas_split_rend_huffman_cfg_t pred_roll; + int16_t pred_roll_idx_trav[ISAR_SPLIT_REND_ROLL_PRED_QUANT_PNTS]; + int16_t pred_roll_base2_code_len; + ivas_split_rend_huffman_cfg_t gd; + int16_t gd_base2_code_len; + int16_t gd_idx_trav[ISAR_SPLIT_REND_D_QUANT_PNTS]; + ivas_split_rend_huffman_cfg_t p_gd; + int16_t p_gd_base2_code_len; + int16_t p_gd_idx_trav[ISAR_SPLIT_REND_D_QUANT_PNTS]; + ivas_split_rend_huffman_cfg_t p_gd_diff; + int16_t p_gd_diff_base2_code_len; + int16_t p_gd_diff_idx_trav[ISAR_SPLIT_REND_D_QUANT_PNTS]; + +} BIN_HR_SPLIT_REND_HUFF, *BIN_HR_SPLIT_REND_HUFF_HANDLE; + + +typedef struct ivas_binaural_head_rot_split_post_rendering_struct +{ + BIN_HR_SPLIT_REND_MD rot_md[MAX_HEAD_ROT_POSES][MAX_SPLIT_MD_SUBFRAMES][MAX_SPLIT_REND_MD_BANDS]; + IVAS_QUATERNION QuaternionsPre[MAX_PARAM_SPATIAL_SUBFRAMES]; + int16_t low_Res; + + float fix_pos_rot_mat[MAX_HEAD_ROT_POSES - 1][BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + ISAR_SPLIT_REND_POSE_TYPE pose_type[MAX_HEAD_ROT_POSES - 1]; + BIN_HR_SPLIT_REND_HUFF huff_cfg; +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG + float mixer_mat_re[MAX_HEAD_ROT_POSES][MAX_SPLIT_REND_MD_BANDS][BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + float mixer_mat_im[MAX_HEAD_ROT_POSES][MAX_SPLIT_REND_MD_BANDS][BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + float gd_mem[MAX_HEAD_ROT_POSES][MAX_SPLIT_REND_MD_BANDS]; +#else + float mixer_mat_re[1][MAX_SPLIT_REND_MD_BANDS][BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + float mixer_mat_im[1][MAX_SPLIT_REND_MD_BANDS][BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + float gd_mem[1][MAX_SPLIT_REND_MD_BANDS]; +#endif + int16_t cf_flag; + HANDLE_CLDFB_FILTER_BANK cldfbAna[BINAURAL_CHANNELS]; + HANDLE_CLDFB_FILTER_BANK cldfbSyn[BINAURAL_CHANNELS]; +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG + HANDLE_CLDFB_FILTER_BANK cldfbSynReconsBinDec[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS]; +#endif + +} BIN_HR_SPLIT_POST_REND, *BIN_HR_SPLIT_POST_REND_HANDLE; + +typedef struct ivas_binaural_head_rot_split_pre_rendering_struct +{ + BIN_HR_SPLIT_REND_MD rot_md[MAX_HEAD_ROT_POSES - 1][MAX_SPLIT_MD_SUBFRAMES][MAX_SPLIT_REND_MD_BANDS]; + float fix_pos_rot_mat[MAX_HEAD_ROT_POSES - 1][BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + ISAR_SPLIT_REND_POSE_TYPE pose_type[MAX_HEAD_ROT_POSES - 1]; + BIN_HR_SPLIT_REND_HUFF huff_cfg; +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG + HANDLE_CLDFB_FILTER_BANK cldfbSynRotBinDec[MAX_HEAD_ROT_POSES + 1][BINAURAL_CHANNELS]; +#endif + +#ifdef SPLIT_POSE_CORRECTION_DEBUG + BIN_HR_SPLIT_POST_REND_HANDLE hBinHrSplitPostRend; +#endif + +} BIN_HR_SPLIT_PRE_REND, *BIN_HR_SPLIT_PRE_REND_HANDLE; + +typedef struct ivas_binaural_head_rot_split_rendering_lcld_enc_struct +{ + void *pLcld_enc; + int16_t iChannels; + LCLDEncoder *psLCLDEncoder; + float ***pppfLCLDReal; + float ***pppfLCLDImag; +#ifdef CLDFB_DEBUG + FILE *cldfbIn; + int16_t numFrame; +#endif + int16_t iNumIterations; + int16_t iNumBlocks; + +} BIN_HR_SPLIT_LCLD_ENC, *BIN_HR_SPLIT_LCLD_ENC_HANDLE; + +typedef struct +{ + float Cldfb_Prev_BinReal[BINAURAL_CHANNELS][CLDFB_NO_COL_MAX + CLDFB_PLC_XF][CLDFB_NO_CHANNELS_MAX]; + float Cldfb_Prev_BinImag[BINAURAL_CHANNELS][CLDFB_NO_COL_MAX + CLDFB_PLC_XF][CLDFB_NO_CHANNELS_MAX]; + float xf_bet[2][CLDFB_NO_CHANNELS_MAX][CLDFB_PLC_XF]; +} CLDFB_PLC, *CLDFB_PLC_HANDLE; + +typedef struct +{ + CLDFB_PLC CldfbPLC_state; + int16_t prev_bfi; + int16_t bf_count; + int16_t iNumSubSets; + +} SPLIT_REND_PLC_STRUCT, *SPLIT_REND_PLC_HANDLE; + +typedef struct ivas_binaural_head_rot_split_rendering_lcld_dec_struct +{ + void *pLcld_dec; + int32_t iChannels; + LCLDDecoder *psLCLDDecoder; + float ***pppfDecLCLDReal; + float ***pppfDecLCLDImag; +#ifdef CLDFB_DEBUG + FILE *cldfbOut; + int16_t numFrame; +#endif + SPLIT_REND_PLC_HANDLE hSplitRendPLC; + int16_t iNumBlocks; + int16_t iNumIterations; + +} BIN_HR_SPLIT_LCLD_DEC, *BIN_HR_SPLIT_LCLD_DEC_HANDLE; + +#endif + + /*----------------------------------------------------------------------------------* * Limiter structure *----------------------------------------------------------------------------------*/ @@ -1341,6 +1537,21 @@ typedef struct ivas_LS_setup_custom } LSSETUP_CUSTOM_STRUCT, *LSSETUP_CUSTOM_HANDLE; +#ifdef SPLIT_REND_WITH_HEAD_ROT + +/*----------------------------------------------------------------------------------* + * CLDFB renderer wrapper + *----------------------------------------------------------------------------------*/ + +typedef struct +{ + int32_t binaural_latency_ns; + BINAURAL_RENDERER_HANDLE hCldfbRend; + HRTFS_FASTCONV_HANDLE hHrtfFastConv; + +} CLDFB_REND_WRAPPER; + +#endif /* Channel types in a channel-based config */ typedef enum @@ -1362,7 +1573,11 @@ typedef struct ivas_masa_external_rendering_struct RENDERER_TYPE renderer_type; DIRAC_REND_HANDLE hDirACRend; SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; +#ifdef SPLIT_REND_WITH_HEAD_ROT + DIRAC_DEC_BIN_HANDLE hDiracDecBin[MAX_HEAD_ROT_POSES]; +#else DIRAC_DEC_BIN_HANDLE hDiracDecBin; +#endif REVERB_STRUCT_HANDLE hReverb; HRTFS_PARAMBIN_HANDLE hHrtfParambin; diff --git a/lib_rend/ivas_td_decorr.c b/lib_rend/ivas_td_decorr.c index beff2ae367bd5079ab4959f357818251e6c95014..cf1f0c2f84333c76dbb741d835e33387267a19b8 100644 --- a/lib_rend/ivas_td_decorr.c +++ b/lib_rend/ivas_td_decorr.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/ivas_vbap.c b/lib_rend/ivas_vbap.c index 602d64df6890670bccee4c2d6a8e6d28ffdf257a..8d183fe39c793acab158a119eb5d1da57e8d4378 100644 --- a/lib_rend/ivas_vbap.c +++ b/lib_rend/ivas_vbap.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index ab29964b7df19f3cc09f79394e9d8fbd03344ac5..2622b6f112927248c40e968232345ef904f11769 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other @@ -35,6 +35,9 @@ #include "prot.h" #include "ivas_prot.h" #include "ivas_prot_rend.h" +#include "isar_prot.h" +#include "isar_stat.h" +#include "lib_isar_pre_rend.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" #include "ivas_rom_rend.h" @@ -48,19 +51,9 @@ * Local constants *-------------------------------------------------------------------*/ -/* Maximum buffer length (per channel) in samples. - * Keep this separate from L_FRAME48k in case we want to support different size later */ -#define MAX_BUFFER_LENGTH_PER_CHANNEL ( L_FRAME48k ) - -/* Maximum buffer length (total) in samples. */ /* Maximum buffer length (total) in samples. */ -#define MAX_BUFFER_LENGTH ( MAX_BUFFER_LENGTH_PER_CHANNEL * MAX_INPUT_CHANNELS ) - -#define MAX_BIN_DELAY_SAMPLES 50 /* Maximum supported rendering latency for binaural IRs */ - -/* Frame size required when rendering to binaural */ -#define BINAURAL_RENDERING_FRAME_SIZE_MS 5 - +#define MAX_BUFFER_LENGTH ( MAX_BUFFER_LENGTH_PER_CHANNEL * MAX_INPUT_CHANNELS ) +#define MAX_BIN_DELAY_SAMPLES 150 /* Maximum supported rendering latency for binaural IRs */ /*-------------------------------------------------------------------* * Local types @@ -93,6 +86,11 @@ typedef struct const LSSETUP_CUSTOM_STRUCT *pCustomLsOut; const EFAP_WRAPPER *pEfapOutWrapper; const IVAS_REND_HeadRotData *pHeadRotData; +#ifdef SPLIT_REND_WITH_HEAD_ROT + const RENDER_CONFIG_HANDLE *hhRendererConfig; + const int16_t *pSplitRendBFI; + const SPLIT_REND_WRAPPER *pSplitRendWrapper; +#endif const COMBINED_ORIENTATION_HANDLE *pCombinedOrientationData; } rendering_context; @@ -118,6 +116,9 @@ typedef struct rotation_matrix rot_mat_prev; pan_vector prev_pan_gains; int8_t firstFrameRendered; +#ifdef SPLIT_REND_WITH_HEAD_ROT + TDREND_WRAPPER splitTdRendWrappers[MAX_HEAD_ROT_POSES - 1]; /* Additional TD Rend instances used for split rendering */ +#endif float *bufferData; int16_t nonDiegeticPan; float nonDiegeticPanGain; @@ -148,8 +149,15 @@ typedef struct EFAP_WRAPPER efapInWrapper; TDREND_WRAPPER tdRendWrapper; CREND_WRAPPER_HANDLE crendWrapper; +#ifdef SPLIT_REND_WITH_HEAD_ROT + TDREND_WRAPPER splitTdRendWrappers[MAX_HEAD_ROT_POSES - 1]; /* Additional TD Rend instances used for split rendering */ +#endif REVERB_HANDLE hReverb; +#ifdef SPLIT_REND_WITH_HEAD_ROT + rotation_gains rot_gains_prev[MAX_HEAD_ROT_POSES]; +#else rotation_gains rot_gains_prev; +#endif int16_t nonDiegeticPan; float nonDiegeticPanGain; lfe_routing lfeRouting; @@ -163,13 +171,19 @@ typedef struct { input_base base; pan_matrix hoaDecMtx; +#ifdef SPLIT_REND_WITH_HEAD_ROT + CLDFB_REND_WRAPPER cldfbRendWrapper; +#endif CREND_WRAPPER_HANDLE crendWrapper; +#ifdef SPLIT_REND_WITH_HEAD_ROT + rotation_gains rot_gains_prev[MAX_HEAD_ROT_POSES]; +#else rotation_gains rot_gains_prev; +#endif float *bufferData; DIRAC_ANA_HANDLE hDirAC; } input_sba; - typedef struct { input_base base; @@ -198,8 +212,15 @@ struct IVAS_REND AUDIO_CONFIG outputConfig; EFAP_WRAPPER efapOutWrapper; IVAS_LSSETUP_CUSTOM_STRUCT customLsOut; +#ifdef SPLIT_REND_WITH_HEAD_ROT + SPLIT_REND_WRAPPER splitRendWrapper; + IVAS_REND_AudioBuffer splitRendEncBuffer; +#endif IVAS_REND_HeadRotData headRotData; +#ifdef SPLIT_REND_WITH_HEAD_ROT + int16_t splitRendBFI; +#endif EXTERNAL_ORIENTATION_HANDLE hExternalOrientationData; COMBINED_ORIENTATION_HANDLE hCombinedOrientationData; @@ -218,6 +239,20 @@ struct IVAS_REND static ivas_error initMasaExtRenderer( input_masa *inputMasa, const AUDIO_CONFIG outConfig ); static void freeMasaExtRenderer( MASA_EXT_REND_HANDLE *hMasaExtRendOut ); +#ifdef SPLIT_REND_WITH_HEAD_ROT +static ivas_error renderSbaToMultiBinauralCldfb( + input_sba *sbaInput, + float Cldfb_Out_Real[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + float Cldfb_Out_Imag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + const int16_t low_res_pre_rend_rot, + const int16_t num_subframes ); + +static ivas_error renderSbaToMultiBinaural( + input_sba *sbaInput, + const AUDIO_CONFIG outConfig, + float out[][L_FRAME48k] ); +#endif + /*-------------------------------------------------------------------* * Local functions *-------------------------------------------------------------------*/ @@ -289,6 +324,101 @@ static float *getSmplPtr( return buffer.data + chnlIdx * buffer.config.numSamplesPerChannel + smplIdx; } +#ifdef SPLIT_REND_WITH_HEAD_ROT +static void convertBitsBufferToInternalBitsBuff( + const IVAS_REND_BitstreamBuffer outBits, + ISAR_SPLIT_REND_BITS_HANDLE hBits ) +{ + hBits->bits_buf = outBits.bits; + hBits->bits_read = outBits.config.bitsRead; + hBits->bits_written = outBits.config.bitsWritten; + hBits->buf_len = outBits.config.bufLenInBytes; + hBits->codec = outBits.config.codec; + hBits->pose_correction = outBits.config.poseCorrection; + hBits->codec_frame_size_ms = outBits.config.codec_frame_size_ms; + + return; +} + +static void convertInternalBitsBuffToBitsBuffer( + IVAS_REND_BitstreamBuffer *hOutBits, + const ISAR_SPLIT_REND_BITS_DATA bits ) +{ + hOutBits->bits = bits.bits_buf; + hOutBits->config.bitsRead = bits.bits_read; + hOutBits->config.bitsWritten = bits.bits_written; + hOutBits->config.bufLenInBytes = bits.buf_len; + hOutBits->config.codec = bits.codec; + hOutBits->config.poseCorrection = bits.pose_correction; + hOutBits->config.codec_frame_size_ms = bits.codec_frame_size_ms; + + return; +} + +static void copyBufferToCLDFBarray( + const IVAS_REND_AudioBuffer buffer, + float re[MAX_OUTPUT_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + float im[MAX_OUTPUT_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX] ) +{ + uint32_t smplIdx, slotIdx; + uint32_t numCldfbSamples, num_bands; + uint32_t chnlIdx; + const float *readPtr; + + assert( ( buffer.config.is_cldfb == 1 ) && "for time domain input call copyBufferTo2dArray()" ); + readPtr = buffer.data; + numCldfbSamples = ( (uint32_t) buffer.config.numSamplesPerChannel ) >> 1; + num_bands = numCldfbSamples / CLDFB_NO_COL_MAX; + for ( chnlIdx = 0; chnlIdx < (uint32_t) buffer.config.numChannels; ++chnlIdx ) + { + for ( slotIdx = 0; slotIdx < CLDFB_NO_COL_MAX; ++slotIdx ) + { + for ( smplIdx = 0; smplIdx < num_bands; ++smplIdx ) + { + re[chnlIdx][slotIdx][smplIdx] = *readPtr++; + } + for ( smplIdx = 0; smplIdx < num_bands; ++smplIdx ) + { + im[chnlIdx][slotIdx][smplIdx] = *readPtr++; + } + } + } + + return; +} + +static void accumulateCLDFBArrayToBuffer( + float re[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + float im[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + IVAS_REND_AudioBuffer *buffer ) +{ + uint32_t smplIdx, slotIdx; + uint32_t numCldfbSamples, num_bands; + uint32_t chnlIdx; + float *writePtr; + + assert( ( buffer->config.is_cldfb == 1 ) && "for time domain input call copyBufferTo2dArray()" ); + writePtr = buffer->data; + numCldfbSamples = ( (uint32_t) buffer->config.numSamplesPerChannel ) >> 1; + num_bands = numCldfbSamples / CLDFB_NO_COL_MAX; + for ( chnlIdx = 0; chnlIdx < (uint32_t) buffer->config.numChannels; ++chnlIdx ) + { + for ( slotIdx = 0; slotIdx < CLDFB_NO_COL_MAX; ++slotIdx ) + { + for ( smplIdx = 0; smplIdx < num_bands; ++smplIdx ) + { + *writePtr++ += re[chnlIdx][slotIdx][smplIdx]; + } + for ( smplIdx = 0; smplIdx < num_bands; ++smplIdx ) + { + *writePtr++ += im[chnlIdx][slotIdx][smplIdx]; + } + } + } + + return; +} +#endif static void copyBufferTo2dArray( const IVAS_REND_AudioBuffer buffer, @@ -298,6 +428,9 @@ static void copyBufferTo2dArray( uint32_t chnlIdx; const float *readPtr; +#ifdef SPLIT_REND_WITH_HEAD_ROT + assert( ( buffer.config.is_cldfb == 0 ) && "for CLDFB input call copyBufferToCLDFBarray()" ); +#endif readPtr = buffer.data; for ( chnlIdx = 0; chnlIdx < (uint32_t) buffer.config.numChannels; ++chnlIdx ) @@ -313,6 +446,9 @@ static void copyBufferTo2dArray( static void accumulate2dArrayToBuffer( float array[][L_FRAME48k], +#ifdef SPLIT_REND_WITH_HEAD_ROT + const +#endif IVAS_REND_AudioBuffer *buffer ) { int16_t smplIdx, chnlIdx; @@ -407,6 +543,10 @@ static ivas_error validateOutputAudioConfig( case IVAS_AUDIO_CONFIG_HOA2: case IVAS_AUDIO_CONFIG_HOA3: case IVAS_AUDIO_CONFIG_BINAURAL: +#ifdef SPLIT_REND_WITH_HEAD_ROT + case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED: + case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM: +#endif case IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR: case IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB: case IVAS_AUDIO_CONFIG_MASA1: @@ -486,18 +626,29 @@ static ivas_error validateOutputSampleRate( /* If no binaural rendering, any sampling rate is supported */ return IVAS_ERR_OK; } - - /* Otherwise rendering to binaural, support the same set as IVAS decoder */ - switch ( sampleRate ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + else if ( ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) && sampleRate != 48000 ) { - case 8000: - case 16000: - case 32000: - case 48000: - return IVAS_ERR_OK; + return IVAS_ERROR( IVAS_ERR_INVALID_SAMPLING_RATE, "Error: Only 48kHz output sampling rate is supported for split rendering." ); } + else + { +#endif + + /* Otherwise rendering to binaural, support the same set as IVAS decoder */ + switch ( sampleRate ) + { + case 8000: + case 16000: + case 32000: + case 48000: + return IVAS_ERR_OK; + } - return IVAS_ERR_INVALID_SAMPLING_RATE; + return IVAS_ERR_INVALID_SAMPLING_RATE; +#ifdef SPLIT_REND_WITH_HEAD_ROT + } +#endif } @@ -520,6 +671,10 @@ ivas_error getAudioConfigNumChannels( break; case IVAS_AUDIO_CONFIG_STEREO: case IVAS_AUDIO_CONFIG_BINAURAL: +#ifdef SPLIT_REND_WITH_HEAD_ROT + case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED: + case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM: +#endif case IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR: case IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB: case IVAS_AUDIO_CONFIG_MASA2: @@ -973,6 +1128,9 @@ static ivas_error initHeadRotation( hIvasRend->headRotData.headPositions[i] = quaternionInit(); } +#ifdef SPLIT_REND_WITH_HEAD_ROT + hIvasRend->headRotData.sr_pose_pred_axis = DEFAULT_AXIS; +#endif if ( ( hIvasRend->headRotData.hOrientationTracker = (ivas_orient_trk_state_t *) malloc( sizeof( ivas_orient_trk_state_t ) ) ) == NULL ) { @@ -1097,6 +1255,11 @@ static rendering_context getRendCtx( ctx.pCustomLsOut = &hIvasRend->customLsOut; ctx.pEfapOutWrapper = &hIvasRend->efapOutWrapper; ctx.pHeadRotData = &hIvasRend->headRotData; +#ifdef SPLIT_REND_WITH_HEAD_ROT + ctx.hhRendererConfig = &hIvasRend->hRendererConfig; + ctx.pSplitRendBFI = &hIvasRend->splitRendBFI; + ctx.pSplitRendWrapper = &hIvasRend->splitRendWrapper; +#endif ctx.pCombinedOrientationData = &hIvasRend->hCombinedOrientationData; return ctx; @@ -1143,7 +1306,11 @@ static ivas_error initIsmMasaRendering( inputIsm->tdRendWrapper.hHrtfTD = NULL; } +#ifdef SPLIT_REND_WITH_HEAD_ROT + ivas_rend_closeCrend( &inputIsm->crendWrapper, inputIsm->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses ); +#else ivas_rend_closeCrend( &inputIsm->crendWrapper ); +#endif ivas_reverb_close( &inputIsm->hReverb ); @@ -1166,6 +1333,9 @@ static ivas_error setRendInputActiveIsm( rendering_context rendCtx; AUDIO_CONFIG outConfig; input_ism *inputIsm; +#ifdef SPLIT_REND_WITH_HEAD_ROT + int16_t i; +#endif inputIsm = (input_ism *) input; rendCtx = inputIsm->base.ctx; @@ -1192,17 +1362,46 @@ static ivas_error setRendInputActiveIsm( initRotMatrix( inputIsm->rot_mat_prev ); set_zero( inputIsm->prev_pan_gains, MAX_OUTPUT_CHANNELS ); +#ifdef SPLIT_REND_WITH_HEAD_ROT + for ( i = 0; i < (int16_t) ( sizeof( inputIsm->splitTdRendWrappers ) / sizeof( *inputIsm->splitTdRendWrappers ) ); ++i ) + { + inputIsm->splitTdRendWrappers[i] = defaultTdRendWrapper(); + } +#endif inputIsm->hOMasa = NULL; error = IVAS_ERR_OK; +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL || outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) +#else if ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) +#endif { +#ifndef SPLIT_REND_WITH_HEAD_ROT if ( ( error = ivas_rend_openCrend( &inputIsm->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, hRendCfg, NULL, *rendCtx.pOutSampleRate ) ) != IVAS_ERR_OK ) { return error; } +#else + if ( ( error = ivas_td_binaural_open_ext( &inputIsm->tdRendWrapper, inConfig, hRendCfg, NULL, *rendCtx.pOutSampleRate ) ) != IVAS_ERR_OK ) + { + return error; + } + + /* Open TD renderer wrappers */ + for ( i = 0; i < MAX_HEAD_ROT_POSES - 1; ++i ) + { + if ( ( error = ivas_td_binaural_open_ext( &inputIsm->splitTdRendWrappers[i], inConfig, hRendCfg, NULL, *inputIsm->base.ctx.pOutSampleRate ) ) != IVAS_ERR_OK ) + { + return error; + } + + /* Assert same delay as main TD renderer */ + assert( inputIsm->splitTdRendWrappers[i].binaural_latency_ns == inputIsm->tdRendWrapper.binaural_latency_ns ); + } +#endif } else if ( outConfig == IVAS_AUDIO_CONFIG_MASA1 || outConfig == IVAS_AUDIO_CONFIG_MASA2 ) { @@ -1213,6 +1412,20 @@ static ivas_error setRendInputActiveIsm( } else { +#ifndef SPLIT_REND_WITH_HEAD_ROT + if ( ( error = ivas_td_binaural_open_ext( &inputIsm->tdRendWrapper, inConfig, hRendCfg, NULL, *rendCtx.pOutSampleRate ) ) != IVAS_ERR_OK ) + { + return error; + } + + if ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) + { + if ( ( error = ivas_reverb_open( &( inputIsm->hReverb ), outConfig, NULL, inputIsm->tdRendWrapper.hBinRendererTd->HrFiltSet_p->lr_energy_and_iac, hRendCfg, *rendCtx.pOutSampleRate ) ) != IVAS_ERR_OK ) + { + return error; + } + } +#else if ( ( error = ivas_td_binaural_open_ext( &inputIsm->tdRendWrapper, inConfig, hRendCfg, NULL, *rendCtx.pOutSampleRate ) ) != IVAS_ERR_OK ) { return error; @@ -1225,6 +1438,14 @@ static ivas_error setRendInputActiveIsm( return error; } } + else if ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) + { + if ( ( error = ivas_rend_openCrend( &inputIsm->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, hRendCfg, NULL, *rendCtx.pOutSampleRate, rendCtx.pSplitRendWrapper->multiBinPoseData.num_poses ) ) != IVAS_ERR_OK ) + { + return error; + } + } +#endif } return IVAS_ERR_OK; @@ -1235,6 +1456,9 @@ static void clearInputIsm( input_ism *inputIsm ) { rendering_context rendCtx; +#ifdef SPLIT_REND_WITH_HEAD_ROT + int16_t i; +#endif rendCtx = inputIsm->base.ctx; @@ -1242,7 +1466,11 @@ static void clearInputIsm( initRendInputBase( &inputIsm->base, IVAS_AUDIO_CONFIG_INVALID, 0, rendCtx, NULL, 0 ); /* Free input's internal handles */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + ivas_rend_closeCrend( &inputIsm->crendWrapper, inputIsm->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses ); +#else ivas_rend_closeCrend( &inputIsm->crendWrapper ); +#endif ivas_reverb_close( &inputIsm->hReverb ); @@ -1252,6 +1480,13 @@ static void clearInputIsm( inputIsm->tdRendWrapper.hHrtfTD = NULL; } +#ifdef SPLIT_REND_WITH_HEAD_ROT + for ( i = 0; i < (int16_t) ( sizeof( inputIsm->splitTdRendWrappers ) / sizeof( *inputIsm->splitTdRendWrappers ) ); ++i ) + { + ivas_td_binaural_close( &inputIsm->splitTdRendWrappers[i].hBinRendererTd ); + inputIsm->splitTdRendWrappers[i].hHrtfTD = NULL; + } +#endif ivas_omasa_ana_close( &( inputIsm->hOMasa ) ); @@ -1845,6 +2080,10 @@ static ivas_error updateMcPanGains( switch ( outConfig ) { case IVAS_AUDIO_CONFIG_BINAURAL: +#ifdef SPLIT_REND_WITH_HEAD_ROT + case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED: + case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM: +#endif break; /* Do nothing */ case IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR: case IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB: @@ -1892,6 +2131,9 @@ static ivas_error initMcBinauralRendering( uint8_t reconfigureFlag ) { ivas_error error; +#ifdef SPLIT_REND_WITH_HEAD_ROT + int16_t i; +#endif int32_t binauralDelayNs; int32_t outSampleRate; int8_t useTDRend; @@ -1919,11 +2161,28 @@ static ivas_error initMcBinauralRendering( inputMc->tdRendWrapper.hHrtfTD = NULL; } +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( !reconfigureFlag || !useTDRend ) + { + for ( i = 0; i < MAX_HEAD_ROT_POSES - 1; ++i ) + { + if ( inputMc->splitTdRendWrappers[i].hBinRendererTd != NULL ) + { + ivas_td_binaural_close( &inputMc->splitTdRendWrappers[i].hBinRendererTd ); + inputMc->splitTdRendWrappers[i].hHrtfTD = NULL; + } + } + } +#endif /* if we need to use TD renderer and CREND was open, close it */ if ( useTDRend ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT + ivas_rend_closeCrend( &inputMc->crendWrapper, inputMc->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses ); +#else ivas_rend_closeCrend( &inputMc->crendWrapper ); +#endif } if ( !reconfigureFlag || ( !useTDRend && outConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB && inputMc->hReverb != NULL ) ) @@ -1948,6 +2207,23 @@ static ivas_error initMcBinauralRendering( return error; } +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + { + /* Open TD renderer wrappers */ + for ( i = 0; i < MAX_HEAD_ROT_POSES - 1; ++i ) + { + if ( ( error = ivas_td_binaural_open_ext( &inputMc->splitTdRendWrappers[i], inConfig, hRendCfg, &inputMc->customLsInput, outSampleRate ) ) != IVAS_ERR_OK ) + { + return error; + } + + /* Assert same delay as main TD renderer */ + assert( inputMc->splitTdRendWrappers[i].binaural_latency_ns == inputMc->tdRendWrapper.binaural_latency_ns ); + } + } + +#endif if ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB && inputMc->hReverb == NULL ) { if ( ( error = ivas_reverb_open( &( inputMc->hReverb ), outConfig, NULL, inputMc->tdRendWrapper.hBinRendererTd->HrFiltSet_p->lr_energy_and_iac, hRendCfg, outSampleRate ) ) != IVAS_ERR_OK ) @@ -1959,7 +2235,11 @@ static ivas_error initMcBinauralRendering( else if ( !useTDRend && inputMc->crendWrapper == NULL ) { /* open CREND */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( error = ivas_rend_openCrend( &inputMc->crendWrapper, ( inConfig == IVAS_AUDIO_CONFIG_LS_CUSTOM ) ? IVAS_AUDIO_CONFIG_7_1_4 : inConfig, outConfig, hRendCfg, NULL, outSampleRate, ( ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) || ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) ) ? inputMc->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses : 1 ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_rend_openCrend( &inputMc->crendWrapper, ( inConfig == IVAS_AUDIO_CONFIG_LS_CUSTOM ) ? IVAS_AUDIO_CONFIG_7_1_4 : inConfig, outConfig, hRendCfg, NULL, outSampleRate ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -2000,7 +2280,11 @@ static ivas_error initMcMasaRendering( inputMc->tdRendWrapper.hHrtfTD = NULL; } +#ifdef SPLIT_REND_WITH_HEAD_ROT + ivas_rend_closeCrend( &inputMc->crendWrapper, inputMc->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses ); +#else ivas_rend_closeCrend( &inputMc->crendWrapper ); +#endif ivas_reverb_close( &inputMc->hReverb ); @@ -2083,10 +2367,16 @@ static ivas_error setRendInputActiveMc( const IVAS_REND_InputId id, RENDER_CONFIG_DATA *hRendCfg ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT + int16_t i; +#endif ivas_error error; rendering_context rendCtx; AUDIO_CONFIG outConfig; input_mc *inputMc; +#ifdef SPLIT_REND_WITH_HEAD_ROT + int16_t pos_idx; +#endif inputMc = (input_mc *) input; rendCtx = inputMc->base.ctx; @@ -2115,12 +2405,28 @@ static ivas_error setRendInputActiveMc( inputMc->hReverb = NULL; inputMc->hMcMasa = NULL; +#ifdef SPLIT_REND_WITH_HEAD_ROT + for ( pos_idx = 0; pos_idx < MAX_HEAD_ROT_POSES; pos_idx++ ) + { + initRotGains( inputMc->rot_gains_prev[pos_idx] ); + } +#else initRotGains( inputMc->rot_gains_prev ); +#endif inputMc->lfeRouting = defaultLfeRouting( inConfig, inputMc->customLsInput, outConfig, *inputMc->base.ctx.pCustomLsOut ); set_zero( inputMc->lfeDelayBuffer, MAX_BIN_DELAY_SAMPLES ); inputMc->binauralDelaySmp = 0; +#ifdef SPLIT_REND_WITH_HEAD_ROT + for ( i = 0; i < (int16_t) ( sizeof( inputMc->splitTdRendWrappers ) / sizeof( *inputMc->splitTdRendWrappers ) ); ++i ) + { + inputMc->splitTdRendWrappers[i] = defaultTdRendWrapper(); + } + + if ( getAudioConfigType( outConfig ) == IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL ) +#else if ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL || outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) +#endif { if ( ( error = initMcBinauralRendering( inputMc, inConfig, outConfig, hRendCfg, FALSE ) ) != IVAS_ERR_OK ) { @@ -2148,6 +2454,9 @@ static ivas_error setRendInputActiveMc( static void clearInputMc( input_mc *inputMc ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT + int16_t i; +#endif rendering_context rendCtx; rendCtx = inputMc->base.ctx; @@ -2162,7 +2471,11 @@ static void clearInputMc( efap_free_data( &inputMc->efapInWrapper.hEfap ); } +#ifdef SPLIT_REND_WITH_HEAD_ROT + ivas_rend_closeCrend( &inputMc->crendWrapper, inputMc->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses ); +#else ivas_rend_closeCrend( &inputMc->crendWrapper ); +#endif ivas_reverb_close( &inputMc->hReverb ); @@ -2172,6 +2485,16 @@ static void clearInputMc( inputMc->tdRendWrapper.hHrtfTD = NULL; } +#ifdef SPLIT_REND_WITH_HEAD_ROT + for ( i = 0; i < (int16_t) ( sizeof( inputMc->splitTdRendWrappers ) / sizeof( *inputMc->splitTdRendWrappers ) ); ++i ) + { + if ( inputMc->splitTdRendWrappers[i].hBinRendererTd != NULL ) + { + ivas_td_binaural_close( &inputMc->splitTdRendWrappers[i].hBinRendererTd ); + inputMc->splitTdRendWrappers[i].hHrtfTD = NULL; + } + } +#endif ivas_mcmasa_ana_close( &( inputMc->hMcMasa ) ); @@ -2295,15 +2618,53 @@ static ivas_error updateSbaPanGains( case IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL: switch ( outConfig ) { - case IVAS_AUDIO_CONFIG_BINAURAL: +#ifdef SPLIT_REND_WITH_HEAD_ROT + case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED: + case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM: { - if ( ( error = ivas_rend_openCrend( &inputSba->crendWrapper, inConfig, outConfig, hRendCfg, NULL, *rendCtx.pOutSampleRate ) ) != IVAS_ERR_OK ) + if ( hRendCfg->split_rend_config.rendererSelection == ISAR_SPLIT_REND_RENDERER_SELECTION_FASTCONV ) { - return error; + assert( inConfig == IVAS_AUDIO_CONFIG_HOA3 && ( *rendCtx.pOutSampleRate == 48000 ) && "split binaural fast conv mode is currently supported with HOA3 input and 48k sampling rate only" ); + if ( ( error = ivas_rend_openCldfbRend( &inputSba->cldfbRendWrapper, inConfig, outConfig, &rendCtx.pSplitRendWrapper->multiBinPoseData, *rendCtx.pOutSampleRate ) ) != IVAS_ERR_OK ) + { + return error; + } + } + else + { + assert( ( *rendCtx.pOutSampleRate == 48000 ) && "split binaural crend mode is currently supported with 48k sampling rate only" ); + if ( ( error = ivas_rend_openMultiBinCrend( &inputSba->crendWrapper, inConfig, outConfig, &rendCtx.pSplitRendWrapper->multiBinPoseData, *rendCtx.pOutSampleRate ) ) != IVAS_ERR_OK ) + { + return error; + } } + break; } - break; +#endif + case IVAS_AUDIO_CONFIG_BINAURAL: +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( hRendCfg->split_rend_config.rendererSelection == ISAR_SPLIT_REND_RENDERER_SELECTION_FASTCONV ) + { + if ( ( error = ivas_rend_openCldfbRend( &inputSba->cldfbRendWrapper, inConfig, outConfig, &rendCtx.pSplitRendWrapper->multiBinPoseData, *rendCtx.pOutSampleRate ) ) != IVAS_ERR_OK ) + { + return error; + } + } + else +#endif + { +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( error = ivas_rend_openCrend( &inputSba->crendWrapper, inConfig, outConfig, hRendCfg, NULL, *rendCtx.pOutSampleRate, rendCtx.pSplitRendWrapper->multiBinPoseData.num_poses ) ) != IVAS_ERR_OK ) +#else + if ( ( error = ivas_rend_openCrend( &inputSba->crendWrapper, inConfig, outConfig, hRendCfg, NULL, *rendCtx.pOutSampleRate ) ) != IVAS_ERR_OK ) +#endif + + { + return error; + } + } + break; case IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR: case IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB: if ( ( error = initSbaPanGainsForMcOut( inputSba, IVAS_AUDIO_CONFIG_7_1_4, NULL ) ) != IVAS_ERR_OK ) @@ -2311,7 +2672,11 @@ static ivas_error updateSbaPanGains( return error; } +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( error = ivas_rend_openCrend( &inputSba->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, hRendCfg, NULL, *rendCtx.pOutSampleRate, rendCtx.pSplitRendWrapper->multiBinPoseData.num_poses ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_rend_openCrend( &inputSba->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, hRendCfg, NULL, *rendCtx.pOutSampleRate ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -2343,7 +2708,11 @@ static ivas_error initSbaMasaRendering( { ivas_error error; +#ifdef SPLIT_REND_WITH_HEAD_ROT + ivas_rend_closeCrend( &inputSba->crendWrapper, inputSba->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses ); +#else ivas_rend_closeCrend( &inputSba->crendWrapper ); +#endif if ( ( error = ivas_dirac_ana_open( &inputSba->hDirAC, inSampleRate ) ) != IVAS_ERR_OK ) { @@ -2364,6 +2733,9 @@ static ivas_error setRendInputActiveSba( rendering_context rendCtx; AUDIO_CONFIG outConfig; input_sba *inputSba; +#ifdef SPLIT_REND_WITH_HEAD_ROT + int16_t pos_idx; +#endif inputSba = (input_sba *) input; rendCtx = inputSba->base.ctx; @@ -2374,18 +2746,34 @@ static ivas_error setRendInputActiveSba( return IVAS_ERR_IO_CONFIG_PAIR_NOT_SUPPORTED; } +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( error = allocateInputBaseBufferData( &inputSba->bufferData, MAX_CLDFB_BUFFER_LENGTH ) ) != IVAS_ERR_OK ) +#else if ( ( error = allocateInputBaseBufferData( &inputSba->bufferData, MAX_BUFFER_LENGTH ) ) != IVAS_ERR_OK ) +#endif { return error; } +#ifdef SPLIT_REND_WITH_HEAD_ROT + initRendInputBase( &inputSba->base, inConfig, id, rendCtx, inputSba->bufferData, MAX_CLDFB_BUFFER_LENGTH ); +#else initRendInputBase( &inputSba->base, inConfig, id, rendCtx, inputSba->bufferData, MAX_BUFFER_LENGTH ); +#endif setZeroPanMatrix( inputSba->hoaDecMtx ); +#ifdef SPLIT_REND_WITH_HEAD_ROT + inputSba->crendWrapper = NULL; + for ( pos_idx = 0; pos_idx < MAX_HEAD_ROT_POSES; pos_idx++ ) + { + initRotGains( inputSba->rot_gains_prev[pos_idx] ); + } +#else inputSba->crendWrapper = NULL; inputSba->hDirAC = NULL; initRotGains( inputSba->rot_gains_prev ); +#endif if ( outConfig == IVAS_AUDIO_CONFIG_MASA1 || outConfig == IVAS_AUDIO_CONFIG_MASA2 ) { @@ -2416,7 +2804,16 @@ static void clearInputSba( initRendInputBase( &inputSba->base, IVAS_AUDIO_CONFIG_INVALID, 0, rendCtx, NULL, 0 ); /* Free input's internal handles */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + ivas_rend_closeCrend( &inputSba->crendWrapper, rendCtx.pSplitRendWrapper->multiBinPoseData.num_poses ); + + if ( inputSba->cldfbRendWrapper.hCldfbRend != NULL ) + { + ivas_rend_closeCldfbRend( &inputSba->cldfbRendWrapper ); + } +#else ivas_rend_closeCrend( &inputSba->crendWrapper ); +#endif ivas_dirac_ana_close( &( inputSba->hDirAC ) ); @@ -2512,6 +2909,9 @@ ivas_error IVAS_REND_Open( const int16_t num_subframes ) { int16_t i; +#ifdef SPLIT_REND_WITH_HEAD_ROT + int16_t j; +#endif IVAS_REND_HANDLE hIvasRend; ivas_error error; int16_t numOutChannels; @@ -2586,6 +2986,10 @@ ivas_error IVAS_REND_Open( } /* Initialize inputs */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + isar_init_split_rend_handles( &hIvasRend->splitRendWrapper ); + hIvasRend->splitRendEncBuffer.data = NULL; +#endif for ( i = 0; i < RENDERER_MAX_ISM_INPUTS; ++i ) { @@ -2594,6 +2998,13 @@ ivas_error IVAS_REND_Open( hIvasRend->inputsIsm[i].crendWrapper = NULL; hIvasRend->inputsIsm[i].hReverb = NULL; hIvasRend->inputsIsm[i].tdRendWrapper.hBinRendererTd = NULL; +#ifdef SPLIT_REND_WITH_HEAD_ROT + for ( j = 0; j < (int16_t) ( sizeof( hIvasRend->inputsIsm[i].splitTdRendWrappers ) / sizeof( *hIvasRend->inputsIsm[i].splitTdRendWrappers ) ); ++j ) + { + hIvasRend->inputsIsm[i].splitTdRendWrappers[j].hBinRendererTd = NULL; + hIvasRend->inputsIsm[i].splitTdRendWrappers[j].hHrtfTD = NULL; + } +#endif hIvasRend->inputsIsm[i].bufferData = NULL; hIvasRend->inputsIsm[i].nonDiegeticPan = nonDiegeticPan; hIvasRend->inputsIsm[i].nonDiegeticPanGain = nonDiegeticPanGain; @@ -2613,6 +3024,13 @@ ivas_error IVAS_REND_Open( hIvasRend->inputsMc[i].nonDiegeticPan = nonDiegeticPan; hIvasRend->inputsMc[i].nonDiegeticPanGain = nonDiegeticPanGain; hIvasRend->inputsMc[i].hMcMasa = NULL; +#ifdef SPLIT_REND_WITH_HEAD_ROT + for ( j = 0; j < (int16_t) ( sizeof( hIvasRend->inputsMc[i].splitTdRendWrappers ) / sizeof( *hIvasRend->inputsMc[i].splitTdRendWrappers ) ); ++j ) + { + hIvasRend->inputsMc[i].splitTdRendWrappers[j].hBinRendererTd = NULL; + hIvasRend->inputsMc[i].splitTdRendWrappers[j].hHrtfTD = NULL; + } +#endif } for ( i = 0; i < RENDERER_MAX_SBA_INPUTS; ++i ) @@ -2620,6 +3038,10 @@ ivas_error IVAS_REND_Open( initRendInputBase( &hIvasRend->inputsSba[i].base, IVAS_AUDIO_CONFIG_INVALID, 0, getRendCtx( hIvasRend ), NULL, 0 ); hIvasRend->inputsSba[i].crendWrapper = NULL; +#ifdef SPLIT_REND_WITH_HEAD_ROT + hIvasRend->inputsSba[i].cldfbRendWrapper.hCldfbRend = NULL; + hIvasRend->inputsSba[i].cldfbRendWrapper.hHrtfFastConv = NULL; +#endif hIvasRend->inputsSba[i].bufferData = NULL; hIvasRend->inputsSba[i].hDirAC = NULL; } @@ -3008,31 +3430,148 @@ static ivas_error findFreeInputSlot( } -/*-------------------------------------------------------------------* - * IVAS_REND_AddInput() +#ifdef SPLIT_REND_WITH_HEAD_ROT +static int16_t getCldfbRendFlag( + IVAS_REND_HANDLE hIvasRend, /* i : Renderer handle */ + const IVAS_REND_AudioConfigType new_configType ) +{ + int16_t i; + int16_t numMasaInputs = 0, numSbaInputs = 0, numIsmInputs = 0, numMcInputs = 0; + int16_t isCldfbRend; + + isCldfbRend = 0; + if ( hIvasRend->hRendererConfig != NULL ) + { + for ( i = 0; i < RENDERER_MAX_MASA_INPUTS; ++i ) + { + numMasaInputs += ( hIvasRend->inputsMasa[i].base.inConfig == IVAS_AUDIO_CONFIG_INVALID && new_configType != IVAS_REND_AUDIO_CONFIG_TYPE_MASA ) ? 0 : 1; + } + for ( i = 0; i < RENDERER_MAX_SBA_INPUTS; ++i ) + { + numSbaInputs += ( hIvasRend->inputsSba[i].base.inConfig == IVAS_AUDIO_CONFIG_INVALID && new_configType != IVAS_REND_AUDIO_CONFIG_TYPE_AMBISONICS ) ? 0 : 1; + } + for ( i = 0; i < RENDERER_MAX_ISM_INPUTS; ++i ) + { + numIsmInputs += ( hIvasRend->inputsIsm[i].base.inConfig == IVAS_AUDIO_CONFIG_INVALID && new_configType != IVAS_REND_AUDIO_CONFIG_TYPE_OBJECT_BASED ) ? 0 : 1; + } + for ( i = 0; i < RENDERER_MAX_MC_INPUTS; ++i ) + { + numMcInputs += ( hIvasRend->inputsMc[i].base.inConfig == IVAS_AUDIO_CONFIG_INVALID && new_configType != IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED ) ? 0 : 1; + } + + if ( numIsmInputs > 0 || numMcInputs > 0 ) + { + isCldfbRend = 0; + } + else if ( ( numMasaInputs > 0 ) || ( numSbaInputs > 0 && hIvasRend->hRendererConfig->split_rend_config.rendererSelection == ISAR_SPLIT_REND_RENDERER_SELECTION_FASTCONV ) ) + { + isCldfbRend = 1; + } + } + + return isCldfbRend; +} + +/*------------------------------------------------------------------------- + * Function ivas_pre_rend_init() * * - *-------------------------------------------------------------------*/ + *------------------------------------------------------------------------*/ -ivas_error IVAS_REND_AddInput( - IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ - const AUDIO_CONFIG inConfig, /* i : audio config for a new input */ - IVAS_REND_InputId *inputId /* o : ID of the new input */ -) +static ivas_error ivas_pre_rend_init( + SPLIT_REND_WRAPPER *pSplitRendWrapper, + IVAS_REND_AudioBuffer *pSplitRendEncBuffer, + ISAR_SPLIT_REND_CONFIG_DATA *pSplit_rend_config, + IVAS_REND_HeadRotData headRotData, + const int32_t outputSampleRate, + const AUDIO_CONFIG outConfig, + const int16_t cldfb_in_flag, + const int16_t num_subframes ) { ivas_error error; - int32_t maxNumInputsOfType; - void *inputsArray; - int32_t inputStructSize; - ivas_error ( *activateInput )( void *, AUDIO_CONFIG, IVAS_REND_InputId, RENDER_CONFIG_DATA * ); - int32_t inputIndex; + IVAS_REND_AudioBufferConfig bufConfig; - /* Validate function arguments */ - if ( hIvasRend == NULL || inputId == NULL ) + if ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + { + if ( pSplit_rend_config->poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) + { + ISAR_PRE_REND_GetMultiBinPoseData( pSplit_rend_config, &pSplitRendWrapper->multiBinPoseData, headRotData.sr_pose_pred_axis ); + } + else if ( pSplit_rend_config->poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE ) + { + isar_renderSplitUpdateNoCorrectionPoseData( pSplit_rend_config, &pSplitRendWrapper->multiBinPoseData ); + } + + if ( ( error = ISAR_PRE_REND_open( pSplitRendWrapper, pSplit_rend_config, outputSampleRate, cldfb_in_flag, outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM, num_subframes, 0 ) ) != IVAS_ERR_OK ) + { + return error; + } + + /*allocate for CLDFB in and change to TD during process if needed*/ + bufConfig.numSamplesPerChannel = MAX_CLDFB_BUFFER_LENGTH_PER_CHANNEL; + bufConfig.numChannels = BINAURAL_CHANNELS * pSplitRendWrapper->multiBinPoseData.num_poses; + bufConfig.is_cldfb = 1; + pSplitRendEncBuffer->config = bufConfig; + + if ( ( pSplitRendEncBuffer->data = malloc( bufConfig.numChannels * bufConfig.numSamplesPerChannel * sizeof( float ) ) ) == NULL ) + { + return IVAS_ERR_FAILED_ALLOC; + } + } + else + { + IVAS_REND_AudioBufferConfig bufConfig2; + + bufConfig2.numSamplesPerChannel = 0; + bufConfig2.numChannels = 0; + bufConfig2.is_cldfb = 0; + pSplitRendEncBuffer->config = bufConfig2; + pSplitRendEncBuffer->data = NULL; + } + + return IVAS_ERR_OK; +} + +#endif + + +/*-------------------------------------------------------------------* + * IVAS_REND_AddInput() + * + * + *-------------------------------------------------------------------*/ + +ivas_error IVAS_REND_AddInput( + IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + const AUDIO_CONFIG inConfig, /* i : audio config for a new input */ + IVAS_REND_InputId *inputId /* o : ID of the new input */ +) +{ + ivas_error error; + int32_t maxNumInputsOfType; + void *inputsArray; + int32_t inputStructSize; + ivas_error ( *activateInput )( void *, AUDIO_CONFIG, IVAS_REND_InputId, RENDER_CONFIG_DATA * ); + int32_t inputIndex; + + /* Validate function arguments */ + if ( hIvasRend == NULL || inputId == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) && hIvasRend->splitRendEncBuffer.data == NULL && hIvasRend->hRendererConfig != NULL ) + { + int16_t cldfb_in_flag; + cldfb_in_flag = getCldfbRendFlag( hIvasRend, getAudioConfigType( inConfig ) ); + + if ( ( error = ivas_pre_rend_init( &hIvasRend->splitRendWrapper, &hIvasRend->splitRendEncBuffer, &hIvasRend->hRendererConfig->split_rend_config, hIvasRend->headRotData, hIvasRend->sampleRateOut, hIvasRend->outputConfig, cldfb_in_flag, hIvasRend->num_subframes ) ) != IVAS_ERR_OK ) + { + return error; + } + } +#endif switch ( getAudioConfigType( inConfig ) ) { @@ -3131,7 +3670,11 @@ ivas_error IVAS_REND_ConfigureCustomInputLoudspeakerLayout( return error; } +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( getAudioConfigType( hIvasRend->outputConfig ) == IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL ) +#else if ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL || hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) +#endif { if ( ( error = initMcBinauralRendering( inputMc, inputMc->base.inConfig, hIvasRend->outputConfig, hIvasRend->hRendererConfig, FALSE ) ) != IVAS_ERR_OK ) { @@ -3441,6 +3984,27 @@ ivas_error IVAS_REND_GetDelay( { if ( hIvasRend->inputsSba[i].base.inConfig != IVAS_AUDIO_CONFIG_INVALID ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( hIvasRend->splitRendWrapper.hBinHrSplitPreRend != NULL ) + { + if ( hIvasRend->hRendererConfig->split_rend_config.rendererSelection == ISAR_SPLIT_REND_RENDERER_SELECTION_FASTCONV ) + { + latency_ns = hIvasRend->inputsSba[i].cldfbRendWrapper.binaural_latency_ns; + } + else + { + latency_ns = ( hIvasRend->inputsSba[i].crendWrapper != NULL ) ? hIvasRend->inputsSba[i].crendWrapper->binaural_latency_ns : 0; + } + max_latency_ns = max( max_latency_ns, latency_ns ); + } + else if ( hIvasRend->inputsSba[i].cldfbRendWrapper.hCldfbRend != NULL ) + { + latency_ns = hIvasRend->inputsSba[i].cldfbRendWrapper.binaural_latency_ns; + latency_ns += IVAS_FB_DEC_DELAY_NS; + max_latency_ns = max( max_latency_ns, latency_ns ); + } + else +#endif { latency_ns = ( hIvasRend->inputsSba[i].crendWrapper != NULL ) ? hIvasRend->inputsSba[i].crendWrapper->binaural_latency_ns : 0; max_latency_ns = max( max_latency_ns, latency_ns ); @@ -3448,7 +4012,6 @@ ivas_error IVAS_REND_GetDelay( } } - for ( i = 0; i < RENDERER_MAX_MASA_INPUTS; i++ ) { if ( hIvasRend->inputsMasa[i].base.inConfig != IVAS_AUDIO_CONFIG_INVALID ) @@ -3479,6 +4042,9 @@ ivas_error IVAS_REND_FeedInputAudio( ivas_error error; input_base *inputBase; int16_t numInputChannels; +#ifdef SPLIT_REND_WITH_HEAD_ROT + int16_t cldfb2tdSampleFact; +#endif /* Validate function arguments */ if ( hIvasRend == NULL || inputAudio.data == NULL ) @@ -3486,7 +4052,14 @@ ivas_error IVAS_REND_FeedInputAudio( return IVAS_ERR_UNEXPECTED_NULL_POINTER; } +#ifdef SPLIT_REND_WITH_HEAD_ROT + cldfb2tdSampleFact = ( inputAudio.config.is_cldfb ) ? 2 : 1; + + if ( inputAudio.config.numSamplesPerChannel <= 0 || ( MAX_BUFFER_LENGTH_PER_CHANNEL < inputAudio.config.numSamplesPerChannel && inputAudio.config.is_cldfb == 0 ) || + ( ( MAX_BUFFER_LENGTH_PER_CHANNEL * cldfb2tdSampleFact ) < inputAudio.config.numSamplesPerChannel && inputAudio.config.is_cldfb == 1 ) ) +#else if ( inputAudio.config.numSamplesPerChannel <= 0 || MAX_BUFFER_LENGTH_PER_CHANNEL < inputAudio.config.numSamplesPerChannel ) +#endif { return IVAS_ERROR( IVAS_ERR_INVALID_BUFFER_SIZE, "Buffer size outside of supported range" ); } @@ -3496,8 +4069,15 @@ ivas_error IVAS_REND_FeedInputAudio( return IVAS_ERR_WRONG_NUM_CHANNELS; } +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( getAudioConfigType( hIvasRend->outputConfig ) == IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL && + hIvasRend->outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && + hIvasRend->outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM && + ( inputAudio.config.numSamplesPerChannel * 1000 / cldfb2tdSampleFact ) != ( BINAURAL_RENDERING_FRAME_SIZE_MS * hIvasRend->num_subframes ) * hIvasRend->sampleRateOut ) +#else if ( getAudioConfigType( hIvasRend->outputConfig ) == IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL && inputAudio.config.numSamplesPerChannel * 1000 != ( BINAURAL_RENDERING_FRAME_SIZE_MS * hIvasRend->num_subframes ) * hIvasRend->sampleRateOut ) +#endif { return IVAS_ERROR( IVAS_ERR_INVALID_BUFFER_SIZE, "Binaural rendering requires specific frame size" ); } @@ -3526,7 +4106,11 @@ ivas_error IVAS_REND_FeedInputAudio( mvr2r( inputAudio.data, inputBase->inputBuffer.data, inputAudio.config.numSamplesPerChannel * inputAudio.config.numChannels ); +#ifdef SPLIT_REND_WITH_HEAD_ROT + inputBase->numNewSamplesPerChannel = inputAudio.config.numSamplesPerChannel / cldfb2tdSampleFact; +#else inputBase->numNewSamplesPerChannel = inputAudio.config.numSamplesPerChannel; +#endif return IVAS_ERR_OK; } @@ -3728,6 +4312,22 @@ int16_t IVAS_REND_GetRenderConfig( mvr2r( hRCin->roomAcoustics.pAcoustic_rt60, hRCout->roomAcoustics.pAcoustic_rt60, CLDFB_NO_CHANNELS_MAX ); mvr2r( hRCin->roomAcoustics.pAcoustic_dsr, hRCout->roomAcoustics.pAcoustic_dsr, CLDFB_NO_CHANNELS_MAX ); +#ifdef SPLIT_REND_WITH_HEAD_ROT + hRCout->split_rend_config.splitRendBitRate = SPLIT_REND_768k; + hRCout->split_rend_config.dof = 3; + hRCout->split_rend_config.hq_mode = 0; + hRCout->split_rend_config.codec_delay_ms = 0; +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + hRCout->split_rend_config.isar_frame_size_ms = 20; +#endif + hRCout->split_rend_config.codec_frame_size_ms = 0; /* 0 means "use default for selected codec" */ + hRCout->split_rend_config.codec = ISAR_SPLIT_REND_CODEC_DEFAULT; + hRCout->split_rend_config.poseCorrectionMode = ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB; + hRCout->split_rend_config.rendererSelection = hRCin->split_rend_config.rendererSelection; +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + hRCout->split_rend_config.lc3plus_highres = 0; +#endif +#endif hRCout->roomAcoustics.use_er = hRCin->roomAcoustics.use_er; hRCout->roomAcoustics.lowComplexity = hRCin->roomAcoustics.lowComplexity; @@ -3748,6 +4348,9 @@ int16_t IVAS_REND_FeedRenderConfig( ) { RENDER_CONFIG_HANDLE hRenderConfig; +#ifdef SPLIT_REND_WITH_HEAD_ROT + ivas_error error; +#endif if ( hIvasRend == NULL || hIvasRend->hRendererConfig == NULL ) { @@ -3778,6 +4381,35 @@ int16_t IVAS_REND_FeedRenderConfig( mvr2r( renderConfig.roomAcoustics.AbsCoeff, hRenderConfig->roomAcoustics.AbsCoeff, IVAS_ROOM_ABS_COEFF ); } +#ifdef SPLIT_REND_WITH_HEAD_ROT + hRenderConfig->split_rend_config = renderConfig.split_rend_config; + /* Overwrite any pose correction settings if 0 DOF (no pose correction) was selected */ + if ( hRenderConfig->split_rend_config.dof == 0 ) + { + hRenderConfig->split_rend_config.poseCorrectionMode = ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE; + } + + hRenderConfig->split_rend_config.codec = renderConfig.split_rend_config.codec; + + if ( ( error = isar_split_rend_validate_config( &hRenderConfig->split_rend_config, ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0 ) ) != IVAS_ERR_OK ) + { + return error; + } + + /* Must re-initialize split rendering config in case renderer config is updated after adding renderer inputs */ + /* if its not initialized yet then no need to re-initialize, initialization will happen while adding inputs*/ + if ( hIvasRend->splitRendEncBuffer.data != NULL && hIvasRend->hRendererConfig != NULL ) + { + int16_t cldfb_in_flag; + cldfb_in_flag = getCldfbRendFlag( hIvasRend, IVAS_REND_AUDIO_CONFIG_TYPE_UNKNOWN ); + ISAR_PRE_REND_close( &hIvasRend->splitRendWrapper, &hIvasRend->splitRendEncBuffer ); + + if ( ( error = ivas_pre_rend_init( &hIvasRend->splitRendWrapper, &hIvasRend->splitRendEncBuffer, &hIvasRend->hRendererConfig->split_rend_config, hIvasRend->headRotData, hIvasRend->sampleRateOut, hIvasRend->outputConfig, cldfb_in_flag, hIvasRend->num_subframes ) ) != IVAS_ERR_OK ) + { + return error; + } + } +#endif return IVAS_ERR_OK; } @@ -3793,7 +4425,10 @@ ivas_error IVAS_REND_SetHeadRotation( IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ const IVAS_QUATERNION headRot, /* i : head orientations for next rendering call */ const IVAS_VECTOR3 Pos, /* i : listener positions for next rendering call */ - const int16_t sf_idx /* i : subframe index */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + const ISAR_SPLIT_REND_ROT_AXIS rot_axis, /* i : external control for rotation axis for split rendering */ +#endif + const int16_t sf_idx /* i : subframe index */ ) { int16_t i; @@ -3843,6 +4478,9 @@ ivas_error IVAS_REND_SetHeadRotation( hIvasRend->headRotData.Pos[sf_idx] = Pos; +#ifdef SPLIT_REND_WITH_HEAD_ROT + hIvasRend->headRotData.sr_pose_pred_axis = rot_axis; +#endif return IVAS_ERR_OK; } @@ -3889,6 +4527,25 @@ ivas_error IVAS_REND_DisableHeadRotation( } +#ifdef SPLIT_REND_WITH_HEAD_ROT +/*-------------------------------------------------------------------* + * IVAS_REND_SetSplitRendBFI() + * + * + *-------------------------------------------------------------------*/ + +ivas_error +IVAS_REND_SetSplitRendBFI( + IVAS_REND_HANDLE hIvasRend, + const int16_t bfi ) +{ + hIvasRend->splitRendBFI = bfi; + + return IVAS_ERR_OK; +} +#endif + + /*-------------------------------------------------------------------* * IVAS_REND_SetOrientationTrackingMode() * @@ -4483,19 +5140,22 @@ static ivas_error renderIsmToBinaural( return IVAS_ERR_OK; } - +#ifdef SPLIT_REND_WITH_HEAD_ROT static int16_t getNumSubframesInBuffer( const IVAS_REND_AudioBuffer *buffer, const int32_t sampleRate ) { + int16_t cldfb2tdSampleFact; + + cldfb2tdSampleFact = buffer->config.is_cldfb ? 2 : 1; #ifdef DEBUGGING - assert( buffer->config.numSamplesPerChannel % ( sampleRate / FRAMES_PER_SEC / MAX_PARAM_SPATIAL_SUBFRAMES ) == 0 ); + assert( buffer->config.numSamplesPerChannel % ( sampleRate / FRAMES_PER_SEC / MAX_PARAM_SPATIAL_SUBFRAMES * cldfb2tdSampleFact ) == 0 ); #endif - return (int16_t) ( buffer->config.numSamplesPerChannel / ( sampleRate / FRAMES_PER_SEC / MAX_PARAM_SPATIAL_SUBFRAMES ) ); + return (int16_t) ( buffer->config.numSamplesPerChannel / ( sampleRate / FRAMES_PER_SEC / MAX_PARAM_SPATIAL_SUBFRAMES * cldfb2tdSampleFact ) ); } - +#endif static ivas_error renderIsmToBinauralRoom( input_ism *ismInput, @@ -4643,10 +5303,14 @@ static ivas_error renderIsmToBinauralRoom( /* render 7_1_4 with BRIRs */ - if ( ( error = ivas_rend_crendProcess( ismInput->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, - NULL, NULL, NULL, NULL, p_tmpRendBuffer, *ismInput->base.ctx.pOutSampleRate, - getNumSubframesInBuffer( &outAudio, *ismInput->base.ctx.pOutSampleRate ) ) ) != IVAS_ERR_OK ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( error = ivas_rend_crendProcessSubframe( ismInput->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, NULL, NULL, + NULL, NULL, NULL, p_tmpRendBuffer, p_tmpRendBuffer, ismInput->base.inputBuffer.config.numSamplesPerChannel, *ismInput->base.ctx.pOutSampleRate, 0 ) ) != IVAS_ERR_OK ) +#else + if ( ( error = ivas_rend_crendProcessSubframe( ismInput->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, NULL, NULL, + NULL, NULL, NULL, p_tmpRendBuffer, p_tmpRendBuffer, ismInput->base.inputBuffer.config.numSamplesPerChannel, *ismInput->base.ctx.pOutSampleRate ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -4827,6 +5491,109 @@ static ivas_error renderIsmToSba( } +#ifdef SPLIT_REND_WITH_HEAD_ROT +static ivas_error renderIsmToSplitBinaural( + input_ism *ismInput, + const IVAS_REND_AudioBuffer outAudio ) +{ + ivas_error error; + float tmpProcessing[MAX_NUM_OBJECTS][L_FRAME48k]; + int16_t pos_idx; + const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData; + const SPLIT_REND_WRAPPER *pSplitRendWrapper; + IVAS_QUATERNION originalHeadRot[MAX_PARAM_SPATIAL_SUBFRAMES]; + int16_t i; + float tmpBinaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][L_FRAME48k]; + int16_t output_frame = ismInput->base.inputBuffer.config.numSamplesPerChannel; + COMBINED_ORIENTATION_HANDLE pCombinedOrientationData; + int16_t ism_md_subframe_update_ext; + + push_wmops( "renderIsmToSplitBinaural" ); + + pSplitRendWrapper = ismInput->base.ctx.pSplitRendWrapper; + pMultiBinPoseData = &pSplitRendWrapper->multiBinPoseData; + + /* Metadata Delay to sync with audio delay converted from ms to 5ms (1000/50/4) subframe index */ + ism_md_subframe_update_ext = (int16_t) roundf( ismInput->ism_metadata_delay_ms / ( 1000 / FRAMES_PER_SEC / MAX_PARAM_SPATIAL_SUBFRAMES ) ); + + pCombinedOrientationData = *ismInput->base.ctx.pCombinedOrientationData; + + if ( pMultiBinPoseData->poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) + { + for ( i = 1; i < pCombinedOrientationData->num_subframes; ++i ) + { + pCombinedOrientationData->Quaternions[i] = pCombinedOrientationData->Quaternions[0]; + } + } + + /* Save current head positions */ + for ( i = 0; i < pCombinedOrientationData->num_subframes; ++i ) + { + originalHeadRot[i] = pCombinedOrientationData->Quaternions[i]; + } + + /* Copy input audio to a processing buffer. */ + copyBufferTo2dArray( ismInput->base.inputBuffer, tmpProcessing ); + + for ( pos_idx = 0; pos_idx < pMultiBinPoseData->num_poses; pos_idx++ ) + { + /* Update head positions */ + if ( pos_idx != 0 ) + { + for ( i = 0; i < pCombinedOrientationData->num_subframes; ++i ) + { + if ( originalHeadRot[i].w == -3.0f ) + { + pCombinedOrientationData->Quaternions[i].w = -3.0f; + pCombinedOrientationData->Quaternions[i].x = originalHeadRot[i].x + pMultiBinPoseData->relative_head_poses[pos_idx][0]; + pCombinedOrientationData->Quaternions[i].y = originalHeadRot[i].y + pMultiBinPoseData->relative_head_poses[pos_idx][1]; + pCombinedOrientationData->Quaternions[i].z = originalHeadRot[i].z + pMultiBinPoseData->relative_head_poses[pos_idx][2]; + } + else + { + pCombinedOrientationData->Quaternions[i].w = -3.0f; + Quat2EulerDegree( originalHeadRot[i], + &pCombinedOrientationData->Quaternions[i].z, + &pCombinedOrientationData->Quaternions[i].y, + &pCombinedOrientationData->Quaternions[i].x ); + pCombinedOrientationData->Quaternions[i].x += pMultiBinPoseData->relative_head_poses[pos_idx][0]; + pCombinedOrientationData->Quaternions[i].y += pMultiBinPoseData->relative_head_poses[pos_idx][1]; + pCombinedOrientationData->Quaternions[i].z += pMultiBinPoseData->relative_head_poses[pos_idx][2]; + } + } + } + + /* Render */ + if ( ( error = ivas_td_binaural_renderer_ext( ( pos_idx == 0 ) ? &ismInput->tdRendWrapper : &ismInput->splitTdRendWrappers[pos_idx - 1], ismInput->base.inConfig, NULL, ismInput->base.ctx.pCombinedOrientationData, &ismInput->currentPos, + NULL, ism_md_subframe_update_ext, *ismInput->base.ctx.pOutSampleRate, output_frame, tmpProcessing ) ) != IVAS_ERR_OK ) + { + return error; + } + + /* Copy rendered audio to tmp storage buffer. Copying directly to output would + * overwrite original audio, which is still needed for rendering next head pose. */ + mvr2r( tmpProcessing[0], tmpBinaural[2 * pos_idx], output_frame ); + mvr2r( tmpProcessing[1], tmpBinaural[2 * pos_idx + 1], output_frame ); + + /* Overwrite processing buffer with original input audio again */ + copyBufferTo2dArray( ismInput->base.inputBuffer, tmpProcessing ); + } + + /* Restore original head rotation */ + for ( i = 0; i < pCombinedOrientationData->num_subframes; ++i ) + { + pCombinedOrientationData->Quaternions[i] = originalHeadRot[i]; + } + + accumulate2dArrayToBuffer( tmpBinaural, &outAudio ); + pop_wmops(); + + /* Encoding to split rendering bitstream done at a higher level */ + return IVAS_ERR_OK; +} +#endif + + static void renderIsmToMasa( input_ism *ismInput, IVAS_REND_AudioBuffer outAudio ) @@ -4887,6 +5654,12 @@ static ivas_error renderInputIsm( case IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR: error = renderIsmToBinauralRoom( ismInput, outAudio ); break; +#ifdef SPLIT_REND_WITH_HEAD_ROT + case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED: + case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM: + error = renderIsmToSplitBinaural( ismInput, outAudio ); + break; +#endif case IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB: error = renderIsmToBinauralReverb( ismInput, outAudio ); break; @@ -4941,9 +5714,15 @@ static ivas_error renderActiveInputsIsm( static ivas_error renderLfeToBinaural( const input_mc *mcInput, +#ifdef SPLIT_REND_WITH_HEAD_ROT + const AUDIO_CONFIG outConfig, +#endif IVAS_REND_AudioBuffer outAudio ) { int16_t lfe_idx; +#ifdef SPLIT_REND_WITH_HEAD_ROT + int16_t pose_idx, num_poses; +#endif float gain; int16_t ear_idx; float tmpLfeBuffer[MAX_BUFFER_LENGTH_PER_CHANNEL]; @@ -4951,7 +5730,11 @@ static ivas_error renderLfeToBinaural( const float *lfeInput; float *writePtr; +#ifdef SPLIT_REND_WITH_HEAD_ROT + assert( ( getAudioConfigType( outConfig ) == IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL ) && "Must be binaural output" ); +#else assert( ( outAudio.config.numChannels == 2 ) && "Must be binaural output" ); +#endif push_wmops( "renderLfeToBinaural" ); @@ -4989,12 +5772,33 @@ static ivas_error renderLfeToBinaural( /* Save remaining LFE samples of current frame for next frame */ mvr2r( lfeInput + num_cpy_smpl_cur_frame, mcInput->lfeDelayBuffer, num_cpy_smpl_prev_frame ); +#ifdef SPLIT_REND_WITH_HEAD_ROT + /* Copy LFE to left and right binaural channels for all poses */ + if ( mcInput->base.ctx.pSplitRendWrapper != NULL ) + { + num_poses = mcInput->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses; + } + else + { + num_poses = 1; + } + + for ( pose_idx = 0; pose_idx < num_poses; ++pose_idx ) + { + for ( ear_idx = 0; ear_idx < BINAURAL_CHANNELS; ++ear_idx ) + { + writePtr = getSmplPtr( outAudio, pose_idx * BINAURAL_CHANNELS + ear_idx, 0 ); + v_add( writePtr, tmpLfeBuffer, writePtr, frame_size ); + } + } +#else /* SPLIT_REND_WITH_HEAD_ROT */ /* Copy LFE to left and right ears */ for ( ear_idx = 0; ear_idx < BINAURAL_CHANNELS; ++ear_idx ) { writePtr = getSmplPtr( outAudio, ear_idx, 0 ); v_add( writePtr, tmpLfeBuffer, writePtr, frame_size ); } +#endif /* SPLIT_REND_WITH_HEAD_ROT */ pop_wmops(); @@ -5058,7 +5862,11 @@ static ivas_error renderMcToBinaural( tmpRotBuffer.data = malloc( tmpRotBuffer.config.numSamplesPerChannel * tmpRotBuffer.config.numChannels * sizeof( float ) ); set_zero( tmpRotBuffer.data, tmpRotBuffer.config.numSamplesPerChannel * tmpRotBuffer.config.numChannels ); +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( error = rotateFrameMc( mcInput->base.inputBuffer, mcInput->base.inConfig, &mcInput->customLsInput, mcInput->base.ctx.pHeadRotData, mcInput->base.ctx.pCombinedOrientationData, mcInput->rot_gains_prev[0], mcInput->efapInWrapper.hEfap, tmpRotBuffer ) ) != IVAS_ERR_OK ) +#else if ( ( error = rotateFrameMc( mcInput->base.inputBuffer, mcInput->base.inConfig, &mcInput->customLsInput, mcInput->base.ctx.pHeadRotData, mcInput->base.ctx.pCombinedOrientationData, mcInput->rot_gains_prev, mcInput->efapInWrapper.hEfap, tmpRotBuffer ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -5072,8 +5880,13 @@ static ivas_error renderMcToBinaural( } /* call CREND */ - if ( ( error = ivas_rend_crendProcess( mcInput->crendWrapper, mcInput->base.inConfig, outConfig, NULL, NULL, NULL, NULL, p_tmpRendBuffer, *mcInput->base.ctx.pOutSampleRate, - getNumSubframesInBuffer( &outAudio, *mcInput->base.ctx.pOutSampleRate ) ) ) != IVAS_ERR_OK ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( error = ivas_rend_crendProcessSubframe( mcInput->crendWrapper, mcInput->base.inConfig, outConfig, NULL, NULL, + NULL, NULL, NULL, p_tmpRendBuffer, p_tmpRendBuffer, mcInput->base.inputBuffer.config.numSamplesPerChannel, *mcInput->base.ctx.pOutSampleRate, 0 ) ) != IVAS_ERR_OK ) +#else + if ( ( error = ivas_rend_crendProcessSubframe( mcInput->crendWrapper, mcInput->base.inConfig, outConfig, NULL, NULL, + NULL, NULL, NULL, p_tmpRendBuffer, p_tmpRendBuffer, mcInput->base.inputBuffer.config.numSamplesPerChannel, *mcInput->base.ctx.pOutSampleRate ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -5081,7 +5894,11 @@ static ivas_error renderMcToBinaural( accumulate2dArrayToBuffer( tmpRendBuffer, &outAudio ); +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( error = renderLfeToBinaural( mcInput, outConfig, outAudio ) ) != IVAS_ERR_OK ) +#else if ( ( error = renderLfeToBinaural( mcInput, outAudio ) ) != IVAS_ERR_OK ) +#endif { return error; @@ -5149,7 +5966,11 @@ static ivas_error renderMcToBinauralRoom( set_zero( tmpRotBuffer.data, tmpRotBuffer.config.numSamplesPerChannel * tmpRotBuffer.config.numChannels ); if ( ( error = rotateFrameMc( mcInput->base.inputBuffer, mcInput->base.inConfig, &mcInput->customLsInput, mcInput->base.ctx.pHeadRotData, mcInput->base.ctx.pCombinedOrientationData, +#ifdef SPLIT_REND_WITH_HEAD_ROT + mcInput->rot_gains_prev[0], +#else mcInput->rot_gains_prev, +#endif mcInput->efapInWrapper.hEfap, tmpRotBuffer ) ) != IVAS_ERR_OK ) { return error; @@ -5164,8 +5985,13 @@ static ivas_error renderMcToBinauralRoom( } /* call CREND */ - if ( ( error = ivas_rend_crendProcess( mcInput->crendWrapper, mcInput->base.inConfig, outConfig, NULL, NULL, NULL, NULL, p_tmpRendBuffer, *mcInput->base.ctx.pOutSampleRate, - getNumSubframesInBuffer( &outAudio, *mcInput->base.ctx.pOutSampleRate ) ) ) != IVAS_ERR_OK ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( error = ivas_rend_crendProcessSubframe( mcInput->crendWrapper, mcInput->base.inConfig, outConfig, NULL, NULL, + NULL, NULL, NULL, p_tmpRendBuffer, p_tmpRendBuffer, mcInput->base.inputBuffer.config.numSamplesPerChannel, *mcInput->base.ctx.pOutSampleRate, 0 ) ) != IVAS_ERR_OK ) +#else + if ( ( error = ivas_rend_crendProcessSubframe( mcInput->crendWrapper, mcInput->base.inConfig, outConfig, NULL, NULL, + NULL, NULL, NULL, p_tmpRendBuffer, p_tmpRendBuffer, mcInput->base.inputBuffer.config.numSamplesPerChannel, *mcInput->base.ctx.pOutSampleRate ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -5173,7 +5999,11 @@ static ivas_error renderMcToBinauralRoom( accumulate2dArrayToBuffer( tmpRendBuffer, &outAudio ); +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( error = renderLfeToBinaural( mcInput, outConfig, outAudio ) ) != IVAS_ERR_OK ) +#else if ( ( error = renderLfeToBinaural( mcInput, outAudio ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -5230,7 +6060,11 @@ static ivas_error renderMcCustomLsToBinauralRoom( set_zero( tmpRotBuffer.data, tmpRotBuffer.config.numSamplesPerChannel * tmpRotBuffer.config.numChannels ); if ( ( error = rotateFrameMc( mcInput->base.inputBuffer, mcInput->base.inConfig, &mcInput->customLsInput, mcInput->base.ctx.pHeadRotData, mcInput->base.ctx.pCombinedOrientationData, +#ifdef SPLIT_REND_WITH_HEAD_ROT + mcInput->rot_gains_prev[0], +#else mcInput->rot_gains_prev, +#endif mcInput->efapInWrapper.hEfap, tmpRotBuffer ) ) != IVAS_ERR_OK ) { return error; @@ -5257,15 +6091,24 @@ static ivas_error renderMcCustomLsToBinauralRoom( copyBufferTo2dArray( tmpMcBuffer, tmpCrendBuffer ); /* call CREND */ - if ( ( error = ivas_rend_crendProcess( mcInput->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, NULL, NULL, NULL, NULL, - p_tmpCrendBuffer, *mcInput->base.ctx.pOutSampleRate, getNumSubframesInBuffer( &outAudio, *mcInput->base.ctx.pOutSampleRate ) ) ) != IVAS_ERR_OK ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( error = ivas_rend_crendProcessSubframe( mcInput->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, NULL, NULL, + NULL, NULL, NULL, p_tmpCrendBuffer, p_tmpCrendBuffer, mcInput->base.inputBuffer.config.numSamplesPerChannel, *mcInput->base.ctx.pOutSampleRate, 0 ) ) != IVAS_ERR_OK ) +#else + if ( ( error = ivas_rend_crendProcessSubframe( mcInput->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, NULL, NULL, + NULL, NULL, NULL, p_tmpCrendBuffer, p_tmpCrendBuffer, mcInput->base.inputBuffer.config.numSamplesPerChannel, *mcInput->base.ctx.pOutSampleRate ) ) != IVAS_ERR_OK ) +#endif { return error; } accumulate2dArrayToBuffer( tmpCrendBuffer, &outAudio ); +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( error = renderLfeToBinaural( mcInput, outConfig, outAudio ) ) != IVAS_ERR_OK ) +#else if ( ( error = renderLfeToBinaural( mcInput, outAudio ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -5339,73 +6182,240 @@ static void renderMcToMasa( } -static ivas_error renderInputMc( +#ifdef SPLIT_REND_WITH_HEAD_ROT +static ivas_error renderMcToSplitBinaural( input_mc *mcInput, const AUDIO_CONFIG outConfig, IVAS_REND_AudioBuffer outAudio ) { + int16_t i, j, pos_idx; + int16_t sf; + int16_t output_frame; ivas_error error; - IVAS_REND_AudioBuffer inAudio; + const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData; + const SPLIT_REND_WRAPPER *pSplitRendWrapper; + float tmpRendBuffer[MAX_OUTPUT_CHANNELS][L_FRAME48k]; + float *p_tmpRendBuffer[MAX_OUTPUT_CHANNELS]; + float tmpSplitBinauralBuffer[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][L_FRAME48k]; + AUDIO_CONFIG inConfig; + IVAS_REND_AudioBuffer tmpRotBuffer; + COMBINED_ORIENTATION_DATA combinedOrientationDataLocal; + COMBINED_ORIENTATION_HANDLE pCombinedOrientationDataLocal; - error = IVAS_ERR_OK; + push_wmops( "renderMcToSplitBinaural" ); + inConfig = mcInput->base.inConfig; + output_frame = mcInput->base.inputBuffer.config.numSamplesPerChannel; - inAudio = mcInput->base.inputBuffer; + pSplitRendWrapper = mcInput->base.ctx.pSplitRendWrapper; + pMultiBinPoseData = &pSplitRendWrapper->multiBinPoseData; - if ( mcInput->base.numNewSamplesPerChannel != outAudio.config.numSamplesPerChannel ) + for ( i = 0; i < MAX_OUTPUT_CHANNELS; ++i ) { - return IVAS_ERROR( IVAS_ERR_INVALID_BUFFER_SIZE, "Mismatch between the number of input samples vs number of requested output samples - currently not allowed" ); + p_tmpRendBuffer[i] = tmpRendBuffer[i]; } - mcInput->base.numNewSamplesPerChannel = 0; - - /* Apply input gain to new audio */ - v_multc( inAudio.data, mcInput->base.gain, inAudio.data, inAudio.config.numSamplesPerChannel * inAudio.config.numChannels ); - - /* set combined orientation subframe info to start info */ - ivas_combined_orientation_set_to_start_index( *( mcInput->base.ctx.pCombinedOrientationData ) ); - switch ( getAudioConfigType( outConfig ) ) + /* save current head positions */ + pCombinedOrientationDataLocal = *mcInput->base.ctx.pCombinedOrientationData; + combinedOrientationDataLocal = *pCombinedOrientationDataLocal; + if ( pMultiBinPoseData->poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) { - case IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED: - renderMcToMc( mcInput, outAudio ); - break; - case IVAS_REND_AUDIO_CONFIG_TYPE_AMBISONICS: - renderMcToSba( mcInput, outAudio ); - break; - case IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL: - switch ( outConfig ) + for ( sf = 1; sf < combinedOrientationDataLocal.num_subframes; ++sf ) + { + combinedOrientationDataLocal.Quaternions[sf] = combinedOrientationDataLocal.Quaternions[0]; + for ( i = 0; i < 3; i++ ) { - case IVAS_AUDIO_CONFIG_BINAURAL: - error = renderMcToBinaural( mcInput, outConfig, outAudio ); - break; - case IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR: - case IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB: - if ( mcInput->base.inConfig == IVAS_AUDIO_CONFIG_LS_CUSTOM ) - { - error = renderMcCustomLsToBinauralRoom( mcInput, outConfig, outAudio ); - } - else - { - error = renderMcToBinauralRoom( mcInput, outConfig, outAudio ); - } - break; - default: - return IVAS_ERR_INVALID_OUTPUT_FORMAT; + for ( j = 0; j < 3; j++ ) + { + combinedOrientationDataLocal.Rmat[sf][i][j] = combinedOrientationDataLocal.Rmat[0][i][j]; + } } - break; - case IVAS_REND_AUDIO_CONFIG_TYPE_MASA: - renderMcToMasa( mcInput, outAudio ); - break; - default: - return IVAS_ERR_INVALID_OUTPUT_FORMAT; + } } - return error; -} + /* temporary buffer for rotation in source format for CREND */ + tmpRotBuffer = mcInput->base.inputBuffer; + if ( inConfig != IVAS_AUDIO_CONFIG_LS_CUSTOM && inConfig != IVAS_AUDIO_CONFIG_5_1 && inConfig != IVAS_AUDIO_CONFIG_7_1 ) + { + tmpRotBuffer.data = malloc( tmpRotBuffer.config.numSamplesPerChannel * tmpRotBuffer.config.numChannels * sizeof( float ) ); + } + for ( pos_idx = 0; pos_idx < pMultiBinPoseData->num_poses; pos_idx++ ) + { + /* Update head positions */ + IVAS_QUATERNION Quaternions_orig[MAX_PARAM_SPATIAL_SUBFRAMES], Quaternions_abs; + for ( i = 0; i < combinedOrientationDataLocal.num_subframes; i++ ) + { + Quaternions_orig[i] = combinedOrientationDataLocal.Quaternions[i]; + Quaternions_abs.w = -3.0f; + Quat2EulerDegree( combinedOrientationDataLocal.Quaternions[i], &Quaternions_abs.z, &Quaternions_abs.y, &Quaternions_abs.x ); /*order in Quat2Euler seems to be reversed ?*/ -static ivas_error renderActiveInputsMc( - IVAS_REND_HANDLE hIvasRend, - IVAS_REND_AudioBuffer outAudio ) + Quaternions_abs.x += pMultiBinPoseData->relative_head_poses[pos_idx][0]; + Quaternions_abs.y += pMultiBinPoseData->relative_head_poses[pos_idx][1]; + Quaternions_abs.z += pMultiBinPoseData->relative_head_poses[pos_idx][2]; + combinedOrientationDataLocal.Quaternions[i] = Quaternions_abs; + QuatToRotMat( combinedOrientationDataLocal.Quaternions[i], combinedOrientationDataLocal.Rmat[i] ); + } + + if ( inConfig == IVAS_AUDIO_CONFIG_LS_CUSTOM || inConfig == IVAS_AUDIO_CONFIG_5_1 || inConfig == IVAS_AUDIO_CONFIG_7_1 ) + { + /* tdrend processing overview: + * 1. copy from inputBuffer to tmpRendBuffer + * 2. td_binaural_renderer_ext: inplace processing in tmpRendBuffer + * 3. copy from tmpRendBuffer to tmpSplitBinBuffer + * 4. LFE mixing + * 5. tmpSplitBinBuffer accumulated to outBuffer */ + + /* copy input to tdrend input/output buffer */ + copyBufferTo2dArray( mcInput->base.inputBuffer, tmpRendBuffer ); + + /* perform rotation in source format to tmpRotBuffer */ + pCombinedOrientationDataLocal = &combinedOrientationDataLocal; + + /* Render */ + if ( ( error = ivas_td_binaural_renderer_ext( ( pos_idx == 0 ) ? &mcInput->tdRendWrapper : &mcInput->splitTdRendWrappers[pos_idx - 1], mcInput->base.inConfig, &mcInput->customLsInput, &pCombinedOrientationDataLocal, NULL, mcInput->hReverb, 0, /* Ism Audio Metadata Delay Sync in ms for External Renderer */ *mcInput->base.ctx.pOutSampleRate, mcInput->base.inputBuffer.config.numSamplesPerChannel, tmpRendBuffer ) ) != IVAS_ERR_OK ) + { + return error; + } + + /* Copy rendered audio to tmp storage buffer. Copying directly to output would + * overwrite original audio, which is still needed for rendering next head pose. */ + mvr2r( tmpRendBuffer[0], tmpSplitBinauralBuffer[2 * pos_idx], output_frame ); + mvr2r( tmpRendBuffer[1], tmpSplitBinauralBuffer[2 * pos_idx + 1], output_frame ); + } + else + { + /* crend processing overview: + * 1. rotateFrameMc: inputBuffer to tmpRotBuffer + * 2. crend_process: tmpRotBuffer to tmpRendBuffer + * 3. copy from tmpRendBuffer to tmpSplitBinBuffer + * 4. LFE mixing + * 5. tmpSplitBinBuffer accumulated to outBuffer */ + + + /* copy input for in-place rotation */ + set_zero( tmpRotBuffer.data, tmpRotBuffer.config.numSamplesPerChannel * tmpRotBuffer.config.numChannels ); + + /* perform rotation in source format to tmpRotBuffer */ + pCombinedOrientationDataLocal = &combinedOrientationDataLocal; + if ( ( error = rotateFrameMc( mcInput->base.inputBuffer, mcInput->base.inConfig, &mcInput->customLsInput, mcInput->base.ctx.pHeadRotData, &pCombinedOrientationDataLocal, mcInput->rot_gains_prev[pos_idx], mcInput->efapInWrapper.hEfap, tmpRotBuffer ) ) != IVAS_ERR_OK ) + { + return error; + } + + copyBufferTo2dArray( tmpRotBuffer, tmpRendBuffer ); + + /* call CREND (rotation already performed) */ + if ( ( error = ivas_rend_crendProcessSubframe( mcInput->crendWrapper, mcInput->base.inConfig, outConfig, NULL, NULL, + NULL, NULL, NULL, p_tmpRendBuffer, p_tmpRendBuffer, mcInput->base.inputBuffer.config.numSamplesPerChannel, *mcInput->base.ctx.pOutSampleRate, pos_idx ) ) != IVAS_ERR_OK ) + { + return error; + } + + /* Copy rendererd audio to tmp storage buffer, Copying directly to output would + * overwrite original audio, which is still needed for rendering next head pose. */ + mvr2r( tmpRendBuffer[0], tmpSplitBinauralBuffer[2 * pos_idx], output_frame ); + mvr2r( tmpRendBuffer[1], tmpSplitBinauralBuffer[2 * pos_idx + 1], output_frame ); + } + + /* restore original headrotation data */ + for ( i = 0; i < combinedOrientationDataLocal.num_subframes; i++ ) + { + combinedOrientationDataLocal.Quaternions[i] = Quaternions_orig[i]; + } + } + + if ( inConfig != IVAS_AUDIO_CONFIG_LS_CUSTOM && inConfig != IVAS_AUDIO_CONFIG_5_1 && inConfig != IVAS_AUDIO_CONFIG_7_1 ) + { + /* free temporary buffer for rotation in source format for CREND */ + free( tmpRotBuffer.data ); + } + + accumulate2dArrayToBuffer( tmpSplitBinauralBuffer, &outAudio ); + + if ( ( error = renderLfeToBinaural( mcInput, outConfig, outAudio ) ) != IVAS_ERR_OK ) + { + return error; + } + + pop_wmops(); + return IVAS_ERR_OK; +} +#endif + + +static ivas_error renderInputMc( + input_mc *mcInput, + const AUDIO_CONFIG outConfig, + IVAS_REND_AudioBuffer outAudio ) +{ + ivas_error error; + IVAS_REND_AudioBuffer inAudio; + + error = IVAS_ERR_OK; + + inAudio = mcInput->base.inputBuffer; + + if ( mcInput->base.numNewSamplesPerChannel != outAudio.config.numSamplesPerChannel ) + { + return IVAS_ERROR( IVAS_ERR_INVALID_BUFFER_SIZE, "Mismatch between the number of input samples vs number of requested output samples - currently not allowed" ); + } + mcInput->base.numNewSamplesPerChannel = 0; + + /* Apply input gain to new audio */ + v_multc( inAudio.data, mcInput->base.gain, inAudio.data, inAudio.config.numSamplesPerChannel * inAudio.config.numChannels ); + + /* set combined orientation subframe info to start info */ + ivas_combined_orientation_set_to_start_index( *( mcInput->base.ctx.pCombinedOrientationData ) ); + + switch ( getAudioConfigType( outConfig ) ) + { + case IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED: + renderMcToMc( mcInput, outAudio ); + break; + case IVAS_REND_AUDIO_CONFIG_TYPE_AMBISONICS: + renderMcToSba( mcInput, outAudio ); + break; + case IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL: + switch ( outConfig ) + { + case IVAS_AUDIO_CONFIG_BINAURAL: + error = renderMcToBinaural( mcInput, outConfig, outAudio ); + break; + case IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR: + case IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB: + if ( mcInput->base.inConfig == IVAS_AUDIO_CONFIG_LS_CUSTOM ) + { + error = renderMcCustomLsToBinauralRoom( mcInput, outConfig, outAudio ); + } + else + { + error = renderMcToBinauralRoom( mcInput, outConfig, outAudio ); + } + break; +#ifdef SPLIT_REND_WITH_HEAD_ROT + case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED: + case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM: + error = renderMcToSplitBinaural( mcInput, outConfig, outAudio ); + break; +#endif + default: + return IVAS_ERR_INVALID_OUTPUT_FORMAT; + } + break; + case IVAS_REND_AUDIO_CONFIG_TYPE_MASA: + renderMcToMasa( mcInput, outAudio ); + break; + default: + return IVAS_ERR_INVALID_OUTPUT_FORMAT; + } + + return error; +} + + +static ivas_error renderActiveInputsMc( + IVAS_REND_HANDLE hIvasRend, + IVAS_REND_AudioBuffer outAudio ) { int16_t i; input_mc *pCurrentInput; @@ -5468,6 +6478,166 @@ static void renderSbaToSba( return; } +#ifdef SPLIT_REND_WITH_HEAD_ROT +static ivas_error renderSbaToMultiBinaural( + input_sba *sbaInput, + const AUDIO_CONFIG outConfig, + float out[][L_FRAME48k] ) +{ + float tmpCrendBuffer[MAX_OUTPUT_CHANNELS][L_FRAME48k]; + float *p_tmpCrendBuffer[MAX_OUTPUT_CHANNELS]; + int16_t sf; + int16_t i, j, pos_idx; + COMBINED_ORIENTATION_DATA combinedOrientationDataLocal; + COMBINED_ORIENTATION_HANDLE pCombinedOrientationDataLocal; + ivas_error error; + IVAS_REND_AudioBuffer tmpRotBuffer; + const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData; + + for ( i = 0; i < MAX_OUTPUT_CHANNELS; i++ ) + { + p_tmpCrendBuffer[i] = tmpCrendBuffer[i]; + } + push_wmops( "renderSbaToMultiBinaural" ); + pMultiBinPoseData = &sbaInput->base.ctx.pSplitRendWrapper->multiBinPoseData; + + pCombinedOrientationDataLocal = *sbaInput->base.ctx.pCombinedOrientationData; + combinedOrientationDataLocal = *pCombinedOrientationDataLocal; + if ( pMultiBinPoseData->poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) + { + for ( sf = 1; sf < combinedOrientationDataLocal.num_subframes; sf++ ) + { + combinedOrientationDataLocal.Quaternions[sf] = combinedOrientationDataLocal.Quaternions[0]; + for ( i = 0; i < 3; i++ ) + { + for ( j = 0; j < 3; j++ ) + { + combinedOrientationDataLocal.Rmat[sf][i][j] = combinedOrientationDataLocal.Rmat[0][i][j]; + } + } + } + } + + tmpRotBuffer = sbaInput->base.inputBuffer; + tmpRotBuffer.data = malloc( tmpRotBuffer.config.numSamplesPerChannel * tmpRotBuffer.config.numChannels * sizeof( float ) ); + + for ( pos_idx = 0; pos_idx < pMultiBinPoseData->num_poses; pos_idx++ ) + { + IVAS_QUATERNION Quaternions_orig[MAX_PARAM_SPATIAL_SUBFRAMES], Quaternions_abs; + for ( i = 0; i < combinedOrientationDataLocal.num_subframes; i++ ) + { + Quaternions_orig[i] = combinedOrientationDataLocal.Quaternions[i]; + Quaternions_abs.w = -3.0f; + Quat2EulerDegree( combinedOrientationDataLocal.Quaternions[i], &Quaternions_abs.z, &Quaternions_abs.y, &Quaternions_abs.x ); /*order in Quat2Euler seems to be reversed ?*/ + + Quaternions_abs.x += pMultiBinPoseData->relative_head_poses[pos_idx][0]; + Quaternions_abs.y += pMultiBinPoseData->relative_head_poses[pos_idx][1]; + Quaternions_abs.z += pMultiBinPoseData->relative_head_poses[pos_idx][2]; + combinedOrientationDataLocal.Quaternions[i] = Quaternions_abs; + QuatToRotMat( combinedOrientationDataLocal.Quaternions[i], combinedOrientationDataLocal.Rmat[i] ); + } + + + /* copy input for in-place rotation */ + mvr2r( sbaInput->base.inputBuffer.data, tmpRotBuffer.data, tmpRotBuffer.config.numChannels * tmpRotBuffer.config.numSamplesPerChannel ); + + pCombinedOrientationDataLocal = &combinedOrientationDataLocal; + + if ( ( error = rotateFrameSba( sbaInput->base.inputBuffer, sbaInput->base.inConfig, sbaInput->base.ctx.pHeadRotData, &pCombinedOrientationDataLocal, sbaInput->rot_gains_prev[pos_idx], tmpRotBuffer ) ) != IVAS_ERR_OK ) + { + return error; + } + + copyBufferTo2dArray( tmpRotBuffer, tmpCrendBuffer ); + + assert( sbaInput->crendWrapper->hCrend[0]->hReverb == NULL ); + + /* call CREND */ + if ( ( error = ivas_rend_crendProcessSubframe( sbaInput->crendWrapper, sbaInput->base.inConfig, outConfig, NULL, NULL, + NULL, NULL, NULL, p_tmpCrendBuffer, p_tmpCrendBuffer, sbaInput->base.inputBuffer.config.numSamplesPerChannel, *sbaInput->base.ctx.pOutSampleRate, pos_idx ) ) != IVAS_ERR_OK ) + { + return error; + } + + for ( i = 0; i < combinedOrientationDataLocal.num_subframes; i++ ) + { + combinedOrientationDataLocal.Quaternions[i] = Quaternions_orig[i]; + } + + + /* move to output */ + for ( i = 0; i < BINAURAL_CHANNELS; i++ ) + { + mvr2r( tmpCrendBuffer[i], out[pos_idx * BINAURAL_CHANNELS + i], tmpRotBuffer.config.numSamplesPerChannel ); + } + } + + free( tmpRotBuffer.data ); + + pop_wmops(); + return IVAS_ERR_OK; +} + + +static ivas_error renderSbaToMultiBinauralCldfb( + input_sba *sbaInput, + float Cldfb_Out_Real[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + float Cldfb_Out_Imag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + const int16_t low_res_pre_rend_rot, + const int16_t num_subframes ) +{ + float Cldfb_RealBuffer[MAX_OUTPUT_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + float Cldfb_ImagBuffer[MAX_OUTPUT_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + + copyBufferToCLDFBarray( sbaInput->base.inputBuffer, Cldfb_RealBuffer, Cldfb_ImagBuffer ); + + ivas_rend_CldfbMultiBinRendProcess( sbaInput->cldfbRendWrapper.hCldfbRend, sbaInput->base.ctx.pCombinedOrientationData, &sbaInput->base.ctx.pSplitRendWrapper->multiBinPoseData, + Cldfb_RealBuffer, Cldfb_ImagBuffer, Cldfb_Out_Real, Cldfb_Out_Imag, low_res_pre_rend_rot, num_subframes ); + + return IVAS_ERR_OK; +} + + +static ivas_error renderSbaToSplitBinaural( + input_sba *sbaInput, + const AUDIO_CONFIG outConfig, + IVAS_REND_AudioBuffer outAudio ) +{ + float tmpCrendBuffer[MAX_OUTPUT_CHANNELS][L_FRAME48k]; + ivas_error error; + float Cldfb_RealBuffer_Binaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + float Cldfb_ImagBuffer_Binaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + int16_t low_res_pre_rend_rot; + + low_res_pre_rend_rot = 1; + + push_wmops( "renderSbaToSplitBinaural" ); + error = IVAS_ERR_OK; + + if ( sbaInput->base.ctx.hhRendererConfig[0]->split_rend_config.rendererSelection == ISAR_SPLIT_REND_RENDERER_SELECTION_FASTCONV ) + { + if ( ( renderSbaToMultiBinauralCldfb( sbaInput, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, low_res_pre_rend_rot, + getNumSubframesInBuffer( &outAudio, *sbaInput->base.ctx.pOutSampleRate ) ) ) != IVAS_ERR_OK ) + { + return error; + } + + accumulateCLDFBArrayToBuffer( Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, &outAudio ); + } + else + { + if ( ( renderSbaToMultiBinaural( sbaInput, outConfig, tmpCrendBuffer ) ) != IVAS_ERR_OK ) + { + return error; + } + + accumulate2dArrayToBuffer( tmpCrendBuffer, &outAudio ); + } + + pop_wmops(); + return error; +} +#endif static ivas_error renderSbaToBinaural( input_sba *sbaInput, @@ -5484,6 +6654,22 @@ static ivas_error renderSbaToBinaural( int16_t subframe_idx; push_wmops( "renderSbaToBinaural" ); +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( sbaInput->base.ctx.hhRendererConfig[0]->split_rend_config.rendererSelection == ISAR_SPLIT_REND_RENDERER_SELECTION_FASTCONV ) + { + float Cldfb_RealBuffer_Binaural[BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + float Cldfb_ImagBuffer_Binaural[BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + + if ( ( error = renderSbaToMultiBinauralCldfb( sbaInput, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, 0, + getNumSubframesInBuffer( &outAudio, *sbaInput->base.ctx.pOutSampleRate ) ) ) != IVAS_ERR_OK ) + { + return error; + } + + accumulateCLDFBArrayToBuffer( Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, &outAudio ); + } + else +#endif { for ( i = 0; i < MAX_OUTPUT_CHANNELS; i++ ) { @@ -5513,8 +6699,13 @@ static ivas_error renderSbaToBinaural( /* copy input for in-place rotation */ mvr2r( sbaInput->base.inputBuffer.data, tmpRotBuffer.data, tmpRotBuffer.config.numChannels * tmpRotBuffer.config.numSamplesPerChannel ); +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( error = rotateFrameSba( sbaInput->base.inputBuffer, sbaInput->base.inConfig, sbaInput->base.ctx.pHeadRotData, + sbaInput->base.ctx.pCombinedOrientationData, sbaInput->rot_gains_prev[0], tmpRotBuffer ) ) != IVAS_ERR_OK ) +#else if ( ( error = rotateFrameSba( sbaInput->base.inputBuffer, sbaInput->base.inConfig, sbaInput->base.ctx.pHeadRotData, sbaInput->base.ctx.pCombinedOrientationData, sbaInput->rot_gains_prev, tmpRotBuffer ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -5528,8 +6719,13 @@ static ivas_error renderSbaToBinaural( } /* call CREND */ - if ( ( error = ivas_rend_crendProcess( sbaInput->crendWrapper, sbaInput->base.inConfig, outConfig, NULL, NULL, NULL, NULL, p_tmpCrendBuffer, *sbaInput->base.ctx.pOutSampleRate, - getNumSubframesInBuffer( &outAudio, *sbaInput->base.ctx.pOutSampleRate ) ) ) != IVAS_ERR_OK ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( error = ivas_rend_crendProcessSubframe( sbaInput->crendWrapper, sbaInput->base.inConfig, outConfig, NULL, NULL, + NULL, NULL, NULL, p_tmpCrendBuffer, p_tmpCrendBuffer, sbaInput->base.inputBuffer.config.numSamplesPerChannel, *sbaInput->base.ctx.pOutSampleRate, 0 ) ) != IVAS_ERR_OK ) +#else + if ( ( error = ivas_rend_crendProcessSubframe( sbaInput->crendWrapper, sbaInput->base.inConfig, outConfig, NULL, NULL, + NULL, NULL, NULL, p_tmpCrendBuffer, p_tmpCrendBuffer, sbaInput->base.inputBuffer.config.numSamplesPerChannel, *sbaInput->base.ctx.pOutSampleRate ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -5592,7 +6788,11 @@ static ivas_error renderSbaToBinauralRoom( if ( ( error = rotateFrameSba( sbaInput->base.inputBuffer, sbaInput->base.inConfig, sbaInput->base.ctx.pHeadRotData, sbaInput->base.ctx.pCombinedOrientationData, +#ifdef SPLIT_REND_WITH_HEAD_ROT + sbaInput->rot_gains_prev[0], +#else sbaInput->rot_gains_prev, +#endif tmpRotBuffer ) ) != IVAS_ERR_OK ) { return error; @@ -5620,9 +6820,13 @@ static ivas_error renderSbaToBinauralRoom( copyBufferTo2dArray( tmpMcBuffer, tmpCrendBuffer ); /* call CREND */ - if ( ( error = ivas_rend_crendProcess( sbaInput->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, - NULL, NULL, NULL, NULL, p_tmpCrendBuffer, *sbaInput->base.ctx.pOutSampleRate, - getNumSubframesInBuffer( &outAudio, *sbaInput->base.ctx.pOutSampleRate ) ) ) != IVAS_ERR_OK ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( error = ivas_rend_crendProcessSubframe( sbaInput->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, NULL, NULL, + NULL, NULL, NULL, p_tmpCrendBuffer, p_tmpCrendBuffer, sbaInput->base.inputBuffer.config.numSamplesPerChannel, *sbaInput->base.ctx.pOutSampleRate, 0 ) ) != IVAS_ERR_OK ) +#else + if ( ( error = ivas_rend_crendProcessSubframe( sbaInput->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, NULL, NULL, + NULL, NULL, NULL, p_tmpCrendBuffer, p_tmpCrendBuffer, sbaInput->base.inputBuffer.config.numSamplesPerChannel, *sbaInput->base.ctx.pOutSampleRate ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -5663,11 +6867,20 @@ static ivas_error renderInputSba( { ivas_error error; IVAS_REND_AudioBuffer inAudio; +#ifdef SPLIT_REND_WITH_HEAD_ROT + int16_t cldfb2tdSampleFact; +#endif error = IVAS_ERR_OK; inAudio = sbaInput->base.inputBuffer; +#ifdef SPLIT_REND_WITH_HEAD_ROT + cldfb2tdSampleFact = outAudio.config.is_cldfb ? 2 : 1; + if ( ( sbaInput->base.numNewSamplesPerChannel * cldfb2tdSampleFact != outAudio.config.numSamplesPerChannel ) && + ( outConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) && ( outConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) +#else if ( sbaInput->base.numNewSamplesPerChannel != outAudio.config.numSamplesPerChannel ) +#endif { return IVAS_ERROR( IVAS_ERR_INVALID_BUFFER_SIZE, "Mismatch between the number of input samples vs number of requested output samples - currently not allowed" ); } @@ -5690,6 +6903,12 @@ static ivas_error renderInputSba( case IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL: switch ( outConfig ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT + case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED: + case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM: + error = renderSbaToSplitBinaural( sbaInput, outConfig, outAudio ); + break; +#endif case IVAS_AUDIO_CONFIG_BINAURAL: error = renderSbaToBinaural( sbaInput, outConfig, outAudio ); break; @@ -5919,6 +7138,11 @@ static ivas_error renderInputMasa( int16_t maxBin; float *tmpBuffer[MAX_OUTPUT_CHANNELS]; float tmpBuffer_buff[MAX_OUTPUT_CHANNELS][L_FRAME48k]; +#ifdef SPLIT_REND_WITH_HEAD_ROT + int16_t cldfb2tdSampleFact; + float Cldfb_RealBuffer_Binaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + float Cldfb_ImagBuffer_Binaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; +#endif if ( !masaInput->metadataHasBeenFed ) { @@ -5926,7 +7150,13 @@ static ivas_error renderInputMasa( } inAudio = masaInput->base.inputBuffer; +#ifdef SPLIT_REND_WITH_HEAD_ROT + cldfb2tdSampleFact = outAudio.config.is_cldfb ? 2 : 1; + if ( ( masaInput->base.numNewSamplesPerChannel * cldfb2tdSampleFact != outAudio.config.numSamplesPerChannel ) && + ( outConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) && ( outConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) +#else if ( masaInput->base.numNewSamplesPerChannel != outAudio.config.numSamplesPerChannel ) +#endif { return IVAS_ERROR( IVAS_ERR_INVALID_BUFFER_SIZE, "Mismatch between the number of input samples vs number of requested output samples - currently not allowed" ); } @@ -5958,25 +7188,61 @@ static ivas_error renderInputMasa( num_subframes = (int16_t) ( masaInput->base.inputBuffer.config.numSamplesPerChannel / ( *masaInput->base.ctx.pOutSampleRate / ( IVAS_NUM_FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) ); - switch ( masaInput->hMasaExtRend->renderer_type ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM || outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) { - case RENDERER_DIRAC: - copyMasaMetadataToDiracRenderer( &masaInput->masaMetadata, masaInput->hMasaExtRend->hSpatParamRendCom, maxBin ); - ivas_masa_ext_dirac_render( masaInput->hMasaExtRend, tmpBuffer, num_subframes ); - break; - case RENDERER_STEREO_PARAMETRIC: - case RENDERER_BINAURAL_PARAMETRIC: - case RENDERER_BINAURAL_PARAMETRIC_ROOM: - copyMasaMetadataToDiracRenderer( &masaInput->masaMetadata, masaInput->hMasaExtRend->hSpatParamRendCom, maxBin ); - ivas_masa_ext_rend_parambin_render( masaInput->hMasaExtRend, *masaInput->base.ctx.pCombinedOrientationData, tmpBuffer, num_subframes ); - break; - case RENDERER_DISABLE: - break; /* This happens for 1TC MASA to MONO where we just copy input transport to output */ - default: - return ( IVAS_ERROR( IVAS_ERR_IO_CONFIG_PAIR_NOT_SUPPORTED, "Wrong output config for MASA input in external renderer\n" ) ); + /* split rendering. use the combined of the first subframe in all subframes */ + int16_t sf, i, j; + COMBINED_ORIENTATION_HANDLE pCombinedOrientationData; + pCombinedOrientationData = *masaInput->base.ctx.pCombinedOrientationData; + for ( sf = 1; sf < pCombinedOrientationData->num_subframes; sf++ ) + { + pCombinedOrientationData->Quaternions[sf] = pCombinedOrientationData->Quaternions[0]; + for ( i = 0; i < 3; i++ ) + { + for ( j = 0; j < 3; j++ ) + { + pCombinedOrientationData->Rmat[sf][i][j] = pCombinedOrientationData->Rmat[0][i][j]; + } + } + } + + copyMasaMetadataToDiracRenderer( &masaInput->masaMetadata, masaInput->hMasaExtRend->hSpatParamRendCom, maxBin ); + + ivas_masa_ext_rend_parambin_render( masaInput->hMasaExtRend, *masaInput->base.ctx.pCombinedOrientationData, tmpBuffer, num_subframes, masaInput->base.ctx.pSplitRendWrapper, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural ); + + accumulateCLDFBArrayToBuffer( Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, &outAudio ); } + else + { + /* non-split path */ +#endif + switch ( masaInput->hMasaExtRend->renderer_type ) + { + case RENDERER_DIRAC: + copyMasaMetadataToDiracRenderer( &masaInput->masaMetadata, masaInput->hMasaExtRend->hSpatParamRendCom, maxBin ); + ivas_masa_ext_dirac_render( masaInput->hMasaExtRend, tmpBuffer, num_subframes ); + break; + case RENDERER_STEREO_PARAMETRIC: + case RENDERER_BINAURAL_PARAMETRIC: + case RENDERER_BINAURAL_PARAMETRIC_ROOM: + copyMasaMetadataToDiracRenderer( &masaInput->masaMetadata, masaInput->hMasaExtRend->hSpatParamRendCom, maxBin ); +#ifdef SPLIT_REND_WITH_HEAD_ROT + ivas_masa_ext_rend_parambin_render( masaInput->hMasaExtRend, *masaInput->base.ctx.pCombinedOrientationData, tmpBuffer, num_subframes, NULL, NULL, NULL ); +#else + ivas_masa_ext_rend_parambin_render( masaInput->hMasaExtRend, *masaInput->base.ctx.pCombinedOrientationData, tmpBuffer, num_subframes ); +#endif + break; + case RENDERER_DISABLE: + break; /* This happens for 1TC MASA to MONO where we just copy input transport to output */ + default: + return ( IVAS_ERROR( IVAS_ERR_IO_CONFIG_PAIR_NOT_SUPPORTED, "Wrong output config for MASA input in external renderer\n" ) ); + } - accumulate2dArrayToBuffer( tmpBuffer_buff, &outAudio ); + accumulate2dArrayToBuffer( tmpBuffer_buff, &outAudio ); +#ifdef SPLIT_REND_WITH_HEAD_ROT + } +#endif } return IVAS_ERR_OK; @@ -6186,12 +7452,21 @@ ivas_error IVAS_REND_SetIsmMetadataDelay( *-------------------------------------------------------------------*/ static ivas_error getSamplesInternal( - IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + IVAS_REND_AudioBuffer outAudio /* i/o: buffer for output audio */, + IVAS_REND_BitstreamBuffer *hBits /*i/o: buffer for input/output bitstream. Needed in split rendering mode*/ +#else IVAS_REND_AudioBuffer outAudio /* i/o: buffer for output audio */ +#endif ) { ivas_error error; int16_t numOutChannels; +#ifdef SPLIT_REND_WITH_HEAD_ROT + int16_t cldfb2tdSampleFact; + IVAS_REND_AudioBuffer outAudioOrig; +#endif /* Validate function arguments */ if ( hIvasRend == NULL || outAudio.data == NULL ) @@ -6199,7 +7474,14 @@ static ivas_error getSamplesInternal( return IVAS_ERR_UNEXPECTED_NULL_POINTER; } +#ifdef SPLIT_REND_WITH_HEAD_ROT + cldfb2tdSampleFact = ( outAudio.config.is_cldfb ) ? 2 : 1; + + if ( outAudio.config.numSamplesPerChannel <= 0 || ( MAX_BUFFER_LENGTH_PER_CHANNEL < outAudio.config.numSamplesPerChannel && outAudio.config.is_cldfb == 0 ) || + ( ( MAX_BUFFER_LENGTH_PER_CHANNEL * cldfb2tdSampleFact ) < outAudio.config.numSamplesPerChannel && outAudio.config.is_cldfb == 1 ) ) +#else if ( outAudio.config.numSamplesPerChannel <= 0 || MAX_BUFFER_LENGTH_PER_CHANNEL < outAudio.config.numSamplesPerChannel ) +#endif { return IVAS_ERR_INVALID_BUFFER_SIZE; } @@ -6209,8 +7491,15 @@ static ivas_error getSamplesInternal( return IVAS_ERR_WRONG_NUM_CHANNELS; } +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( getAudioConfigType( hIvasRend->outputConfig ) == IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL && + hIvasRend->outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && + hIvasRend->outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM && + ( outAudio.config.numSamplesPerChannel * 1000 / cldfb2tdSampleFact ) != ( hIvasRend->num_subframes * BINAURAL_RENDERING_FRAME_SIZE_MS ) * hIvasRend->sampleRateOut ) +#else if ( getAudioConfigType( hIvasRend->outputConfig ) == IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL && outAudio.config.numSamplesPerChannel * 1000 != ( hIvasRend->num_subframes * BINAURAL_RENDERING_FRAME_SIZE_MS ) * hIvasRend->sampleRateOut ) +#endif { return IVAS_ERROR( IVAS_ERR_INVALID_BUFFER_SIZE, "Binaural rendering requires specific frame size" ); } @@ -6251,7 +7540,11 @@ static ivas_error getSamplesInternal( return error; } +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( numOutChannels != outAudio.config.numChannels && hIvasRend->outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && hIvasRend->outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) +#else if ( numOutChannels != outAudio.config.numChannels ) +#endif { return IVAS_ERR_WRONG_NUM_CHANNELS; } @@ -6259,6 +7552,22 @@ static ivas_error getSamplesInternal( /* Clear original output buffer */ set_zero( outAudio.data, outAudio.config.numChannels * outAudio.config.numSamplesPerChannel ); +#ifdef SPLIT_REND_WITH_HEAD_ROT + outAudioOrig = outAudio; + /* Use internal buffer if outputting split rendering bitstream */ + if ( ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || + ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + { + int16_t num_poses_orig; + num_poses_orig = hIvasRend->splitRendWrapper.multiBinPoseData.num_poses; + outAudio = hIvasRend->splitRendEncBuffer; + ISAR_PRE_REND_GetMultiBinPoseData( &hIvasRend->hRendererConfig->split_rend_config, &hIvasRend->splitRendWrapper.multiBinPoseData, hIvasRend->headRotData.sr_pose_pred_axis ); + assert( num_poses_orig == hIvasRend->splitRendWrapper.multiBinPoseData.num_poses && "number of poses should not change dynamically" ); + + /* Clear output buffer for split rendering bitstream */ + set_zero( outAudio.data, outAudio.config.numChannels * outAudio.config.numSamplesPerChannel ); + } +#endif if ( ( error = renderActiveInputsIsm( hIvasRend, outAudio ) ) != IVAS_ERR_OK ) { @@ -6280,14 +7589,98 @@ static ivas_error getSamplesInternal( return error; } - +#ifndef SPLIT_REND_WITH_HEAD_ROT #ifndef DISABLE_LIMITER #ifdef DEBUGGING hIvasRend->numClipping += #endif limitRendererOutput( hIvasRend->hLimiter, outAudio.data, outAudio.config.numSamplesPerChannel, IVAS_LIMITER_THRESHOLD ); #endif +#endif +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + { + ISAR_SPLIT_REND_BITS_DATA bits; + int16_t cldfb_in_flag; + float Cldfb_RealBuffer_Binaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + float Cldfb_ImagBuffer_Binaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + int16_t ch; + int16_t i, ro_md_flag; + float *tmpBinaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS], tmpBinaural_buff[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][L_FRAME48k]; + + for ( ch = 0; ch < MAX_OUTPUT_CHANNELS; ch++ ) + { + tmpBinaural[ch] = tmpBinaural_buff[ch]; + } + + if ( outAudio.config.is_cldfb == 1 ) + { + cldfb_in_flag = 1; + copyBufferToCLDFBarray( outAudio, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural ); + } + else + { + cldfb_in_flag = 0; + copyBufferTo2dArray( outAudio, tmpBinaural_buff ); + } + + /* Encode split rendering bitstream */ + convertBitsBufferToInternalBitsBuff( *hBits, &bits ); + + ro_md_flag = 0; + for ( i = 0; i < RENDERER_MAX_ISM_INPUTS; ++i ) + { + if ( hIvasRend->inputsIsm[i].base.inConfig != IVAS_AUDIO_CONFIG_INVALID ) + { + ro_md_flag = 1; + break; + } + } + + if ( ( error = ISAR_PRE_REND_MultiBinToSplitBinaural( &hIvasRend->splitRendWrapper, + hIvasRend->headRotData.headPositions[0], + hIvasRend->hRendererConfig->split_rend_config.splitRendBitRate, + hIvasRend->hRendererConfig->split_rend_config.codec, +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + hIvasRend->hRendererConfig->split_rend_config.isar_frame_size_ms, +#endif + hIvasRend->hRendererConfig->split_rend_config.codec_frame_size_ms, + &bits, + Cldfb_RealBuffer_Binaural, + Cldfb_ImagBuffer_Binaural, + ( const int16_t )( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), + tmpBinaural, + 1, + cldfb_in_flag, + ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0, + ro_md_flag ) ) != IVAS_ERR_OK ) + { + return error; + } + + convertInternalBitsBuffToBitsBuffer( hBits, bits ); + + /* reset to outAudioOrig in case of PCM output */ + outAudio = outAudioOrig; + + if ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + { + accumulate2dArrayToBuffer( tmpBinaural_buff, &outAudio ); + } + } +#endif +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( outAudio.config.is_cldfb == 0 ) + { +#ifndef DISABLE_LIMITER +#ifdef DEBUGGING + hIvasRend->numClipping += +#endif + limitRendererOutput( hIvasRend->hLimiter, outAudio.data, outAudio.config.numSamplesPerChannel, IVAS_LIMITER_THRESHOLD ); +#endif + } +#endif /* update global cominbed orientation start index */ ivas_combined_orientation_update_start_index( hIvasRend->hCombinedOrientationData, outAudio.config.numSamplesPerChannel ); @@ -6308,9 +7701,73 @@ ivas_error IVAS_REND_GetSamples( ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT + return getSamplesInternal( hIvasRend, outAudio, NULL ); +#else return getSamplesInternal( hIvasRend, outAudio ); +#endif +} + + +#ifdef SPLIT_REND_WITH_HEAD_ROT +/*-------------------------------------------------------------------* + * IVAS_REND_GetSplitBinauralBitstream() + * + * + *-------------------------------------------------------------------*/ + +ivas_error +IVAS_REND_GetSplitBinauralBitstream( + IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + IVAS_REND_AudioBuffer outAudio, /* i/o: buffer for output audio */ + IVAS_REND_BitstreamBuffer *hBits /* o : buffer for output bitstream */ +) +{ + int16_t cldfb_in_flag; + + cldfb_in_flag = getCldfbRendFlag( hIvasRend, IVAS_REND_AUDIO_CONFIG_TYPE_UNKNOWN ); + hIvasRend->splitRendEncBuffer.config.is_cldfb = cldfb_in_flag; + if ( hIvasRend->hRendererConfig->split_rend_config.dof == 0 || hIvasRend->hRendererConfig->split_rend_config.poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE ) + { + hIvasRend->splitRendEncBuffer.config.numSamplesPerChannel = outAudio.config.numSamplesPerChannel; + } + else + { + hIvasRend->splitRendEncBuffer.config.numSamplesPerChannel = (int16_t) ( hIvasRend->sampleRateOut / FRAMES_PER_SEC ); + } + hIvasRend->splitRendEncBuffer.config.numSamplesPerChannel *= cldfb_in_flag ? 2 : 1; + + /* hIvasRend->splitRendEncBuffer used for BINAURAL_SPLIT_CODED output + outAudio used for BINAURAL_SPLIT_PCM output */ + return getSamplesInternal( hIvasRend, outAudio, hBits ); } +ivas_error IVAS_REND_GetSplitRendBitstreamHeader( + IVAS_REND_HANDLE hIvasRend, /* i/o: IVAS renderer handle */ + ISAR_SPLIT_REND_CODEC *pCodec, /* o: pointer to codec setting */ + ISAR_SPLIT_REND_POSE_CORRECTION_MODE *poseCorrection, /* o: pointer to pose correction mode */ + int16_t *pCodec_frame_size_ms /* o: pointer to codec frame size setting */ +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + , + int16_t *pIsar_frame_size_ms /* o: pointer to isar frame size setting */ +#endif +) +{ + if ( hIvasRend == NULL || hIvasRend->hRendererConfig == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + *pCodec = hIvasRend->hRendererConfig->split_rend_config.codec; + *pCodec_frame_size_ms = hIvasRend->hRendererConfig->split_rend_config.codec_frame_size_ms; +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + *pIsar_frame_size_ms = hIvasRend->hRendererConfig->split_rend_config.isar_frame_size_ms; +#endif + *poseCorrection = hIvasRend->hRendererConfig->split_rend_config.poseCorrectionMode; + return IVAS_ERR_OK; +} + +#endif + /*-------------------------------------------------------------------* * IVAS_REND_Close() @@ -6360,6 +7817,10 @@ void IVAS_REND_Close( ivas_limiter_close( &hIvasRend->hLimiter ); +#ifdef SPLIT_REND_WITH_HEAD_ROT + /* Split binaural rendering */ + ISAR_PRE_REND_close( &hIvasRend->splitRendWrapper, &hIvasRend->splitRendEncBuffer ); +#endif closeHeadRotation( hIvasRend ); @@ -6373,6 +7834,126 @@ void IVAS_REND_Close( } +#ifdef SPLIT_REND_WITH_HEAD_ROT +/*-------------------------------------------------------------------* + * IVAS_REND_openCldfb() + * + * + *-------------------------------------------------------------------*/ + +ivas_error +IVAS_REND_openCldfb( + IVAS_CLDFB_FILTER_BANK_HANDLE cldfbAna[IVAS_MAX_INPUT_CHANNELS], + IVAS_CLDFB_FILTER_BANK_HANDLE cldfbSyn[IVAS_MAX_OUTPUT_CHANNELS], + const int16_t num_in_chs, + const int16_t num_out_chs, + const int32_t output_Fs ) +{ + int16_t n; + ivas_error error; + + for ( n = 0; n < num_in_chs; n++ ) + { + if ( ( error = openCldfb( &( cldfbAna[n] ), CLDFB_ANALYSIS, output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) + { + return error; + } + } + for ( ; n < IVAS_MAX_INPUT_CHANNELS; n++ ) + { + cldfbAna[n] = NULL; + } + + for ( n = 0; n < num_out_chs; n++ ) + { + if ( ( error = openCldfb( &( cldfbSyn[n] ), CLDFB_SYNTHESIS, output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) + { + return error; + } + } + for ( ; n < IVAS_MAX_OUTPUT_CHANNELS; n++ ) + { + cldfbSyn[n] = NULL; + } + + return IVAS_ERR_OK; +} + +/*-------------------------------------------------------------------* + * IVAS_REND_closeCldfb() + * + * + *-------------------------------------------------------------------*/ + +void IVAS_REND_closeCldfb( + IVAS_CLDFB_FILTER_BANK_HANDLE cldfbAna[IVAS_MAX_INPUT_CHANNELS], + IVAS_CLDFB_FILTER_BANK_HANDLE cldfbSyn[IVAS_MAX_OUTPUT_CHANNELS] ) +{ + int16_t n; + + for ( n = 0; n < IVAS_MAX_INPUT_CHANNELS; n++ ) + { + if ( cldfbAna[n] != NULL ) + { + deleteCldfb( &( cldfbAna[n] ) ); + cldfbAna[n] = NULL; + } + } + + for ( n = 0; n < IVAS_MAX_OUTPUT_CHANNELS; n++ ) + { + if ( cldfbSyn[n] != NULL ) + { + deleteCldfb( &( cldfbSyn[n] ) ); + cldfbSyn[n] = NULL; + } + } + + return; +} + + +/*-------------------------------------------------------------------* + * IVAS_REND_cldfbSynthesis_wrapper() + * + * + *-------------------------------------------------------------------*/ + +void IVAS_REND_cldfbAnalysis_ts_wrapper( + const float *timeIn, /* i : time buffer */ + float realBuffer[IVAS_CLDFB_NO_CHANNELS_MAX], /* o : real value buffer */ + float imagBuffer[IVAS_CLDFB_NO_CHANNELS_MAX], /* o : imag value buffer */ + const int16_t samplesToProcess, /* i : samples to process */ + IVAS_CLDFB_FILTER_BANK_HANDLE h_cldfb /* i : filterbank state */ +) +{ + cldfbAnalysis_ts( timeIn, realBuffer, imagBuffer, samplesToProcess, h_cldfb ); + + return; +} + + +/*-------------------------------------------------------------------* + * IVAS_REND_cldfbSynthesis_wrapper() + * + * + *-------------------------------------------------------------------*/ + +void IVAS_REND_cldfbSynthesis_wrapper( + float **realBuffer, /* i : real values */ + float **imagBuffer, /* i : imag values */ + float *timeOut, /* o : output time domain samples */ + const int16_t samplesToProcess, /* i : number of processed samples */ + IVAS_CLDFB_FILTER_BANK_HANDLE h_cldfb /* i : filter bank state */ +) +{ + cldfbSynthesis( realBuffer, imagBuffer, timeOut, samplesToProcess, h_cldfb ); + + return; +} +#endif + + #ifdef DEBUGGING /*-------------------------------------------------------------------* * IVAS_REND_GetNoCLipping() @@ -6380,7 +7961,8 @@ void IVAS_REND_Close( * *-------------------------------------------------------------------*/ -int32_t IVAS_REND_GetNoCLipping( +int32_t +IVAS_REND_GetNoCLipping( IVAS_REND_CONST_HANDLE hIvasRend ) { return hIvasRend->numClipping; @@ -6771,6 +8353,9 @@ static ivas_error ivas_masa_ext_rend_parambin_init( float binCenterFreq, tmpFloat; ivas_error error; float frequency_axis[CLDFB_NO_CHANNELS_MAX]; +#ifdef SPLIT_REND_WITH_HEAD_ROT + int16_t pos_idx; +#endif error = IVAS_ERR_OK; @@ -6781,103 +8366,125 @@ static ivas_error ivas_masa_ext_rend_parambin_init( nBins = inputMasa->hMasaExtRend->hSpatParamRendCom->num_freq_bands; renderer_type = inputMasa->hMasaExtRend->renderer_type; +#ifdef SPLIT_REND_WITH_HEAD_ROT + for ( pos_idx = 0; pos_idx < inputMasa->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses; pos_idx++ ) + { + hDiracDecBin = inputMasa->hMasaExtRend->hDiracDecBin[pos_idx]; +#else hDiracDecBin = inputMasa->hMasaExtRend->hDiracDecBin; +#endif - /* Init assumes that no reconfiguration is required in external renderer. Instead, free and rebuild whole rendering. */ - if ( ( hDiracDecBin = (DIRAC_DEC_BIN_HANDLE) malloc( sizeof( DIRAC_DEC_BIN_DATA ) ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC binaural handle " ); - } + /* Init assumes that no reconfiguration is required in external renderer. Instead, free and rebuild whole rendering. */ + if ( ( hDiracDecBin = (DIRAC_DEC_BIN_HANDLE) malloc( sizeof( DIRAC_DEC_BIN_DATA ) ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC binaural handle " ); + } - hDiracDecBin->hTdDecorr = NULL; - hDiracDecBin->hReverb = NULL; - hDiracDecBin->h_freq_domain_decorr_ap_params = NULL; - hDiracDecBin->h_freq_domain_decorr_ap_state = NULL; - hDiracDecBin->hDiffuseDist = NULL; /* Not used in external renderer */ - hDiracDecBin->useTdDecorr = 0; /* Always use frequency domain decorrelator in external renderer */ + hDiracDecBin->hTdDecorr = NULL; + hDiracDecBin->hReverb = NULL; + hDiracDecBin->h_freq_domain_decorr_ap_params = NULL; + hDiracDecBin->h_freq_domain_decorr_ap_state = NULL; + hDiracDecBin->hDiffuseDist = NULL; /* Not used in external renderer */ + hDiracDecBin->useTdDecorr = 0; /* Always use frequency domain decorrelator in external renderer */ - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - for ( k = 0; k < BINAURAL_CHANNELS + MAX_NUM_OBJECTS; k++ ) + for ( j = 0; j < BINAURAL_CHANNELS; j++ ) { - set_zero( hDiracDecBin->processMtxRe[j][k], nBins ); - set_zero( hDiracDecBin->processMtxIm[j][k], nBins ); + for ( k = 0; k < BINAURAL_CHANNELS + MAX_NUM_OBJECTS; k++ ) + { + set_zero( hDiracDecBin->processMtxRe[j][k], nBins ); + set_zero( hDiracDecBin->processMtxIm[j][k], nBins ); + } + + for ( k = 0; k < BINAURAL_CHANNELS; k++ ) + { + set_zero( hDiracDecBin->processMtxDecRe[j][k], nBins ); + set_zero( hDiracDecBin->processMtxDecIm[j][k], nBins ); + } + set_zero( hDiracDecBin->ChEnePrev[j], nBins ); + set_zero( hDiracDecBin->ChEneOutPrev[j], nBins ); } + set_zero( hDiracDecBin->ChCrossRePrev, nBins ); + set_zero( hDiracDecBin->ChCrossImPrev, nBins ); + set_zero( hDiracDecBin->ChCrossReOutPrev, nBins ); + set_zero( hDiracDecBin->ChCrossImOutPrev, nBins ); + hDiracDecBin->renderStereoOutputInsteadOfBinaural = 0; - for ( k = 0; k < BINAURAL_CHANNELS; k++ ) + for ( bin = 0; bin < nBins; bin++ ) { - set_zero( hDiracDecBin->processMtxDecRe[j][k], nBins ); - set_zero( hDiracDecBin->processMtxDecIm[j][k], nBins ); + binCenterFreq = ( (float) bin + 0.5f ) / (float) nBins * ( (float) output_Fs / 2.0f ); + /* These formulas and values are from Christian Borss's publication for binaural diffuse field coherence */ + tmpFloat = max( 0.0f, 1.0f - binCenterFreq / 2700.0f ); + hDiracDecBin->diffuseFieldCoherence[bin] = tmpFloat * sinf( binCenterFreq * EVS_PI / 550.0f ) / ( binCenterFreq * EVS_PI / 550.0f ); } - set_zero( hDiracDecBin->ChEnePrev[j], nBins ); - set_zero( hDiracDecBin->ChEneOutPrev[j], nBins ); - } - set_zero( hDiracDecBin->ChCrossRePrev, nBins ); - set_zero( hDiracDecBin->ChCrossImPrev, nBins ); - set_zero( hDiracDecBin->ChCrossReOutPrev, nBins ); - set_zero( hDiracDecBin->ChCrossImOutPrev, nBins ); - hDiracDecBin->renderStereoOutputInsteadOfBinaural = 0; - - for ( bin = 0; bin < nBins; bin++ ) - { - binCenterFreq = ( (float) bin + 0.5f ) / (float) nBins * ( (float) output_Fs / 2.0f ); - /* These formulas and values are from Christian Borss's publication for binaural diffuse field coherence */ - tmpFloat = max( 0.0f, 1.0f - binCenterFreq / 2700.0f ); - hDiracDecBin->diffuseFieldCoherence[bin] = tmpFloat * sinf( binCenterFreq * EVS_PI / 550.0f ) / ( binCenterFreq * EVS_PI / 550.0f ); - } - /* No SPAR in external renderer so set directive diffuse field coherence tables to zero */ - set_zero( hDiracDecBin->diffuseFieldCoherenceX, BINAURAL_COHERENCE_DIFFERENCE_BINS ); - set_zero( hDiracDecBin->diffuseFieldCoherenceY, BINAURAL_COHERENCE_DIFFERENCE_BINS ); - set_zero( hDiracDecBin->diffuseFieldCoherenceZ, BINAURAL_COHERENCE_DIFFERENCE_BINS ); + /* No SPAR in external renderer so set directive diffuse field coherence tables to zero */ + set_zero( hDiracDecBin->diffuseFieldCoherenceX, BINAURAL_COHERENCE_DIFFERENCE_BINS ); + set_zero( hDiracDecBin->diffuseFieldCoherenceY, BINAURAL_COHERENCE_DIFFERENCE_BINS ); + set_zero( hDiracDecBin->diffuseFieldCoherenceZ, BINAURAL_COHERENCE_DIFFERENCE_BINS ); - if ( renderer_type == RENDERER_BINAURAL_PARAMETRIC ) /* Indication of binaural rendering without room effect */ - { - set_f( hDiracDecBin->earlyPartEneCorrection, 1.0f, CLDFB_NO_CHANNELS_MAX ); - hDiracDecBin->hReverb = NULL; - } - else if ( renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) /* Indication of binaural rendering with room effect */ - { - mvr2r( hHrtfParambin->parametricEarlyPartEneCorrection, hDiracDecBin->earlyPartEneCorrection, nBins ); + if ( renderer_type == RENDERER_BINAURAL_PARAMETRIC ) /* Indication of binaural rendering without room effect */ + { + set_f( hDiracDecBin->earlyPartEneCorrection, 1.0f, CLDFB_NO_CHANNELS_MAX ); + hDiracDecBin->hReverb = NULL; + } + else if ( renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) /* Indication of binaural rendering with room effect */ + { + mvr2r( hHrtfParambin->parametricEarlyPartEneCorrection, hDiracDecBin->earlyPartEneCorrection, nBins ); +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( hDiracDecBin->hReverb == NULL && pos_idx == 0 ) /* open reverb only for the main direction */ +#else if ( hDiracDecBin->hReverb == NULL ) +#endif + { + /* Todo Philips: Room acoustics should be passed here once the underlying part works. In this case, it probably should come from render context or somewhere else suitable. */ + if ( ( error = ivas_binaural_reverb_open_parambin( &hDiracDecBin->hReverb, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, NULL, output_Fs, hHrtfParambin ) ) != IVAS_ERR_OK ) + { + return error; + } + } + } + else if ( renderer_type == RENDERER_STEREO_PARAMETRIC ) + { + set_f( hDiracDecBin->earlyPartEneCorrection, 1.0f, CLDFB_NO_CHANNELS_MAX ); + hDiracDecBin->hReverb = NULL; + hDiracDecBin->renderStereoOutputInsteadOfBinaural = 1; + } + else /* Not valid renderer type for this renderer */ + { + assert( false ); + } + +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( pos_idx == 0 ) /* open decorrelator only for the main direction */ { - /* Todo Philips: Room acoustics should be passed here once the underlying part works. In this case, it probably should come from render context or somewhere else suitable. */ - if ( ( error = ivas_binaural_reverb_open_parambin( &hDiracDecBin->hReverb, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, NULL, output_Fs, hHrtfParambin ) ) != IVAS_ERR_OK ) +#endif + /* Always open frequency domain decorrelator */ + ivas_dirac_dec_get_frequency_axis( frequency_axis, output_Fs, nBins ); + if ( ( error = ivas_dirac_dec_decorr_open( &( hDiracDecBin->h_freq_domain_decorr_ap_params ), + &( hDiracDecBin->h_freq_domain_decorr_ap_state ), + nBins, + BINAURAL_CHANNELS, + BINAURAL_CHANNELS, + DIRAC_SYNTHESIS_PSD_LS, + frequency_axis, + BINAURAL_CHANNELS, + output_Fs ) ) != IVAS_ERR_OK ) { return error; } +#ifdef SPLIT_REND_WITH_HEAD_ROT } - } - else if ( renderer_type == RENDERER_STEREO_PARAMETRIC ) - { - set_f( hDiracDecBin->earlyPartEneCorrection, 1.0f, CLDFB_NO_CHANNELS_MAX ); - hDiracDecBin->hReverb = NULL; - hDiracDecBin->renderStereoOutputInsteadOfBinaural = 1; - } - else /* Not valid renderer type for this renderer */ - { - assert( false ); - } +#endif + /* External renderer uses constant regularization factor */ + hDiracDecBin->reqularizationFactor = 0.4f; - /* Always open frequency domain decorrelator */ - ivas_dirac_dec_get_frequency_axis( frequency_axis, output_Fs, nBins ); - if ( ( error = ivas_dirac_dec_decorr_open( &( hDiracDecBin->h_freq_domain_decorr_ap_params ), - &( hDiracDecBin->h_freq_domain_decorr_ap_state ), - nBins, - BINAURAL_CHANNELS, - BINAURAL_CHANNELS, - DIRAC_SYNTHESIS_PSD_LS, - frequency_axis, - BINAURAL_CHANNELS, - output_Fs ) ) != IVAS_ERR_OK ) - { - return error; +#ifdef SPLIT_REND_WITH_HEAD_ROT + inputMasa->hMasaExtRend->hDiracDecBin[pos_idx] = hDiracDecBin; } - /* External renderer uses constant regularization factor */ - hDiracDecBin->reqularizationFactor = 0.4f; - +#else inputMasa->hMasaExtRend->hDiracDecBin = hDiracDecBin; +#endif return error; } @@ -6903,7 +8510,14 @@ static ivas_error initMasaExtRenderer( hMasaExtRend->renderer_type = RENDERER_DISABLE; hMasaExtRend->hDirACRend = NULL; hMasaExtRend->hSpatParamRendCom = NULL; +#ifdef SPLIT_REND_WITH_HEAD_ROT + for ( i = 0; i < MAX_HEAD_ROT_POSES; i++ ) + { + hMasaExtRend->hDiracDecBin[i] = NULL; + } +#else hMasaExtRend->hDiracDecBin = NULL; +#endif hMasaExtRend->hReverb = NULL; hMasaExtRend->hHrtfParambin = NULL; hMasaExtRend->hVBAPdata = NULL; @@ -6950,6 +8564,10 @@ static ivas_error initMasaExtRenderer( break; case IVAS_AUDIO_CONFIG_BINAURAL: +#ifdef SPLIT_REND_WITH_HEAD_ROT + case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM: + case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED: +#endif hMasaExtRend->renderer_type = RENDERER_BINAURAL_PARAMETRIC; break; @@ -7063,10 +8681,21 @@ static void freeMasaExtRenderer( ivas_spat_hSpatParamRendCom_close( &hMasaExtRend->hSpatParamRendCom ); } +#ifdef SPLIT_REND_WITH_HEAD_ROT + for ( i = 0; i < MAX_HEAD_ROT_POSES; i++ ) + { + if ( hMasaExtRend->hDiracDecBin[i] != NULL ) + { + ivas_dirac_dec_close_binaural_data( &hMasaExtRend->hDiracDecBin[i] ); + } + } + +#else if ( hMasaExtRend->hDiracDecBin != NULL ) { ivas_dirac_dec_close_binaural_data( &hMasaExtRend->hDiracDecBin ); } +#endif if ( hMasaExtRend->hReverb != NULL ) { diff --git a/lib_rend/lib_rend.h b/lib_rend/lib_rend.h index 9fd8e08fe5868960e1ec1c2031e2ba0640bf0ac9..c09c74b80f9860a2979095f76408767a9b70db4a 100644 --- a/lib_rend/lib_rend.h +++ b/lib_rend/lib_rend.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other @@ -35,6 +35,7 @@ #include "common_api_types.h" #include +#include "ivas_stat_rend.h" /*---------------------------------------------------------------------* * Renderer constants @@ -46,25 +47,32 @@ #define RENDERER_MAX_MASA_INPUTS 1 #define RENDERER_MAX_INPUT_LFE_CHANNELS 4 - /*---------------------------------------------------------------------* * Renderer structures *---------------------------------------------------------------------*/ typedef float IVAS_REND_LfePanMtx[RENDERER_MAX_INPUT_LFE_CHANNELS][IVAS_MAX_OUTPUT_CHANNELS]; +#ifdef SPLIT_REND_WITH_HEAD_ROT typedef struct { - int16_t numSamplesPerChannel; - int16_t numChannels; -} IVAS_REND_AudioBufferConfig; - + int32_t bufLenInBytes; + int32_t bitsWritten; + int32_t bitsRead; + ISAR_SPLIT_REND_CODEC codec; + ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrection; + int16_t codec_frame_size_ms; +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + int16_t isar_frame_size_ms; + int16_t lc3plus_highres; +#endif +} IVAS_REND_BitstreamBufferConfig; typedef struct { - IVAS_REND_AudioBufferConfig config; - float *data; -} IVAS_REND_AudioBuffer; - + IVAS_REND_BitstreamBufferConfig config; + uint8_t *bits; +} IVAS_REND_BitstreamBuffer; +#endif typedef struct { @@ -216,11 +224,44 @@ int16_t IVAS_REND_FeedRenderConfig( const IVAS_RENDER_CONFIG_DATA renderConfig /* i : Render configuration struct */ ); +#ifdef SPLIT_REND_WITH_HEAD_ROT +ivas_error IVAS_REND_FeedSplitBinauralBitstream( + IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + const IVAS_REND_InputId inputId, /* i : ID of the input */ + IVAS_REND_BitstreamBuffer *hBits /* i : buffer for input bitstream */ +); + +ivas_error IVAS_REND_GetSplitBinauralSamples( + IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + IVAS_REND_AudioBuffer outAudio, /* i/o: buffer for output audio */ + bool* needNewFrame +); + +ivas_error IVAS_REND_GetSplitBinauralBitstream( + IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + IVAS_REND_AudioBuffer outAudio, /* i/o: buffer for output audio */ + IVAS_REND_BitstreamBuffer *hBits /* o : buffer for output bitstream */ +); + +ivas_error IVAS_REND_GetSplitRendBitstreamHeader( + IVAS_REND_HANDLE hIvasRend, /* i/o: IVAS renderer handle */ + ISAR_SPLIT_REND_CODEC *pCodec, /* o: pointer to codec setting */ + ISAR_SPLIT_REND_POSE_CORRECTION_MODE *poseCorrection, /* o: pointer to pose correction mode */ + int16_t *pCodec_frame_size_ms /* o: pointer to codec frame size setting */ +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + , + int16_t *pIsar_frame_size_ms /* o: pointer to isar frame size setting */ +#endif +); +#endif ivas_error IVAS_REND_SetHeadRotation( IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ const IVAS_QUATERNION headRot, /* i : head orientations for next rendering call */ const IVAS_VECTOR3 Pos, /* i : listener positions for next rendering call */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + const ISAR_SPLIT_REND_ROT_AXIS rot_axis, /* i : external control for rotation axis for split rendering*/ +#endif const int16_t sf_idx /* i : subframe index */ ); @@ -255,6 +296,11 @@ ivas_error IVAS_REND_SetReferenceVector( const IVAS_VECTOR3 refPos /* i : Reference position */ ); +#ifdef SPLIT_REND_WITH_HEAD_ROT +ivas_error IVAS_REND_SetSplitRendBFI( + IVAS_REND_HANDLE hIvasRend, + const int16_t bfi); +#endif ivas_error IVAS_REND_SetExternalOrientation( IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ @@ -315,6 +361,38 @@ void IVAS_REND_Close( ); +#ifdef SPLIT_REND_WITH_HEAD_ROT +/* Split binaural rendering functions */ + +ivas_error IVAS_REND_openCldfb( + IVAS_CLDFB_FILTER_BANK_HANDLE cldfbAna[IVAS_MAX_INPUT_CHANNELS], + IVAS_CLDFB_FILTER_BANK_HANDLE cldfbSyn[IVAS_MAX_OUTPUT_CHANNELS], + const int16_t num_in_chs, + const int16_t num_out_chs, + const int32_t output_Fs +); + +void IVAS_REND_closeCldfb( + IVAS_CLDFB_FILTER_BANK_HANDLE cldfbAna[IVAS_MAX_INPUT_CHANNELS], + IVAS_CLDFB_FILTER_BANK_HANDLE cldfbSyn[IVAS_MAX_OUTPUT_CHANNELS] +); + +void IVAS_REND_cldfbAnalysis_ts_wrapper( + const float *timeIn, /* i : time buffer */ + float realBuffer[IVAS_CLDFB_NO_CHANNELS_MAX], /* o : real value buffer */ + float imagBuffer[IVAS_CLDFB_NO_CHANNELS_MAX], /* o : imag value buffer */ + const int16_t samplesToProcess, /* i : samples to process */ + IVAS_CLDFB_FILTER_BANK_HANDLE h_cldfb /* i : filterbank state */ +); + +void IVAS_REND_cldfbSynthesis_wrapper( + float **realBuffer, /* i : real values */ + float **imagBuffer, /* i : imag values */ + float *timeOut, /* o : output time domain samples */ + const int16_t samplesToProcess, /* i : number of processed samples */ + IVAS_CLDFB_FILTER_BANK_HANDLE h_cldfb /* i : filter bank state */ +); +#endif #ifdef DEBUGGING int32_t IVAS_REND_GetNoCLipping( diff --git a/lib_util/audio_file_reader.c b/lib_util/audio_file_reader.c index 4f6bd0c34d13fd62439775d31933f9d67a4197f4..ca5e6e4963b676da58526fbb30a3cf07d9f34f77 100644 --- a/lib_util/audio_file_reader.c +++ b/lib_util/audio_file_reader.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/audio_file_reader.h b/lib_util/audio_file_reader.h index 0fd4da5ac76c25285d3b49d67166ce651a96eeb8..09a5af25d2528ce279e28ab036c7b49254ff6928 100644 --- a/lib_util/audio_file_reader.h +++ b/lib_util/audio_file_reader.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/audio_file_writer.c b/lib_util/audio_file_writer.c index 0ed64d02c59f8a5b3a19c74c9e4986895ad6c5f1..fb7a64c425b6f648667a969290b6086c11158887 100644 --- a/lib_util/audio_file_writer.c +++ b/lib_util/audio_file_writer.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/audio_file_writer.h b/lib_util/audio_file_writer.h index b5157ffde43f74a15803ec132814992a4fb8ce8f..2622992cecbbb4875a6aa5d7440492bc0d9ccb86 100644 --- a/lib_util/audio_file_writer.h +++ b/lib_util/audio_file_writer.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/bitstream_reader.c b/lib_util/bitstream_reader.c index 2e88746c035759f530bb75f7940ae84990ff4de3..45c82ed4c889158c02e451c1fe0c76dd2b562670 100644 --- a/lib_util/bitstream_reader.c +++ b/lib_util/bitstream_reader.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/bitstream_reader.h b/lib_util/bitstream_reader.h index 374c19d436d9db0f48a599a3acc78ab5e23489ae..8c88bd773ca3eed7d419ac74bf6560163af4fe72 100644 --- a/lib_util/bitstream_reader.h +++ b/lib_util/bitstream_reader.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/bitstream_writer.c b/lib_util/bitstream_writer.c index 7862ff1977c840601d39065c173eecf32674d290..8c4b64cd4816649cb6833ccd6bda13270eb0e179 100644 --- a/lib_util/bitstream_writer.c +++ b/lib_util/bitstream_writer.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/bitstream_writer.h b/lib_util/bitstream_writer.h index a855f347d272e09d8996e4540154c580ba29cefb..f3efd4ddf2ec85beea05af186ffa68cbed225b2f 100644 --- a/lib_util/bitstream_writer.h +++ b/lib_util/bitstream_writer.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/cmdl_tools.c b/lib_util/cmdl_tools.c index b0b7e906cca95b1bb64e66a62677ec1ef1eb21e9..bec772ce42f96eb8373d44aebc6cba944cdb288e 100644 --- a/lib_util/cmdl_tools.c +++ b/lib_util/cmdl_tools.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/cmdl_tools.h b/lib_util/cmdl_tools.h index b160473002930dd2c980d9bfbdcfb8e1bad3722a..327acb93d0b1d528874de8ef018a36686379b778 100644 --- a/lib_util/cmdl_tools.h +++ b/lib_util/cmdl_tools.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/cmdln_parser.c b/lib_util/cmdln_parser.c index 6ac2b0ec2d0ebf5e58c7637c5c00e3e813dd4444..432db36a52900a161c87c63ede257de1c78501a8 100644 --- a/lib_util/cmdln_parser.c +++ b/lib_util/cmdln_parser.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other @@ -150,7 +150,26 @@ static int8_t optionMatchesString( const char *optionName = stringToOptionName( str ); +#ifdef FIX_923_EXTERNAL_REND_COMMAND_LINE + char optionName_to_upper[FILENAME_MAX]; + strncpy( optionName_to_upper, optionName, sizeof( optionName_to_upper ) - 1 ); + optionName_to_upper[sizeof( optionName_to_upper ) - 1] = '\0'; + to_upper( optionName_to_upper ); + + char match_to_upper[FILENAME_MAX]; + strncpy( match_to_upper, opt.props.match, sizeof( match_to_upper ) - 1 ); + optionName_to_upper[sizeof( match_to_upper ) - 1] = '\0'; + to_upper( match_to_upper ); + + char matchShort_to_upper[FILENAME_MAX]; + strncpy( matchShort_to_upper, opt.props.matchShort, sizeof( matchShort_to_upper ) - 1 ); + optionName_to_upper[sizeof( matchShort_to_upper ) - 1] = '\0'; + to_upper( matchShort_to_upper ); + + if ( strncmp( optionName_to_upper, match_to_upper, MAX_OPTION_LENGTH ) == 0 || strncmp( optionName_to_upper, matchShort_to_upper, MAX_OPTION_LENGTH ) == 0 ) +#else if ( strncmp( optionName, opt.props.match, MAX_OPTION_LENGTH ) == 0 || strncmp( optionName, opt.props.matchShort, MAX_OPTION_LENGTH ) == 0 ) +#endif { return 1; } diff --git a/lib_util/cmdln_parser.h b/lib_util/cmdln_parser.h index b8c8370eb4e7efbfa3c6da5a1c2c661510bb1a89..2627d556624dc0de59ca01a5f342d684d066d277 100644 --- a/lib_util/cmdln_parser.h +++ b/lib_util/cmdln_parser.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/evs_rtp_payload.c b/lib_util/evs_rtp_payload.c index d67aebd4c0f4312f523e17cb74d1549fe5148bb6..a0c514bad3ac1495178debf42f7b6736ec770bd3 100644 --- a/lib_util/evs_rtp_payload.c +++ b/lib_util/evs_rtp_payload.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/evs_rtp_payload.h b/lib_util/evs_rtp_payload.h index dac5fb0e35cfee6fca7fc2402b75bf6ae94c0f42..357d985578ba9616980b33e62b75c62ee6ad5604 100644 --- a/lib_util/evs_rtp_payload.h +++ b/lib_util/evs_rtp_payload.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/g192.c b/lib_util/g192.c index 04ba16c369a2d556562544186b70cc23ddab3b27..d6c6ec4755dc8f3b4f07ba3990389888547a31ee 100644 --- a/lib_util/g192.c +++ b/lib_util/g192.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/g192.h b/lib_util/g192.h index 9e5e56d223c4a350b9e7f6d1775c6c3364101ef0..8014f523687f9c50404d39dbe3e1242b00f813c7 100644 --- a/lib_util/g192.h +++ b/lib_util/g192.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index 650768457954cce72d36277ef0e4f1e228d9e47b..23d6694f3b581dc035aeb36a9cfc6352c7f0f267 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/hrtf_file_reader.h b/lib_util/hrtf_file_reader.h index a731416570963abdfddd88e2234f8a17df278d6f..104cc5c7a8a93f778a0e3e78438a4660576e77c4 100644 --- a/lib_util/hrtf_file_reader.h +++ b/lib_util/hrtf_file_reader.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/ism_file_reader.c b/lib_util/ism_file_reader.c index b298b25bc88def43051bcff8f7394fcd6e18889c..088a4134f95145390a45fd695678ccf866bd7499 100644 --- a/lib_util/ism_file_reader.c +++ b/lib_util/ism_file_reader.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/ism_file_reader.h b/lib_util/ism_file_reader.h index 8ddb67704e4db1c30bddb2e3dd207a226b6de90e..c785cc294bde7cbd4c37e9bfb76856f9b172f5c8 100644 --- a/lib_util/ism_file_reader.h +++ b/lib_util/ism_file_reader.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/ism_file_writer.c b/lib_util/ism_file_writer.c index ca845323e72b69afa5c0cd9c1bb1b7228c136676..fff4cc4ff014e8eaac96950d115440bf8ee975d8 100644 --- a/lib_util/ism_file_writer.c +++ b/lib_util/ism_file_writer.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/ism_file_writer.h b/lib_util/ism_file_writer.h index d9f731e87e56b8f0b333d725d813047320d82a39..fc63ae48318e6f879e54ce05e1e95fb9f94abf64 100644 --- a/lib_util/ism_file_writer.h +++ b/lib_util/ism_file_writer.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/jbm_file_reader.c b/lib_util/jbm_file_reader.c index 1be5c223658691c85b01d403c1ea79f330e82658..b657ab78929f906eb29dd6c3435af8a7f91c73ca 100644 --- a/lib_util/jbm_file_reader.c +++ b/lib_util/jbm_file_reader.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/jbm_file_reader.h b/lib_util/jbm_file_reader.h index 64d2d17e45efdf246ab05ec56de690c5fd252b70..e824e1eee9f00bbb821664a0515a69f1ce987d38 100644 --- a/lib_util/jbm_file_reader.h +++ b/lib_util/jbm_file_reader.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/jbm_file_writer.c b/lib_util/jbm_file_writer.c index 584a22bc7f97df3c3084e1a4045356f6547e80bf..76a5a67d2566db5d87ecefb0bb7d21bbeb9afcaf 100644 --- a/lib_util/jbm_file_writer.c +++ b/lib_util/jbm_file_writer.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/jbm_file_writer.h b/lib_util/jbm_file_writer.h index c82c38e0f9bcbfd9b039a5c31a4b863900e21139..aca768a1a0e75c88dd01910bf00854cabc0dc2f2 100644 --- a/lib_util/jbm_file_writer.h +++ b/lib_util/jbm_file_writer.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/ls_custom_file_reader.c b/lib_util/ls_custom_file_reader.c index 9b39fab486bd99ab3259fc5dd6770351792e1e6e..01d1f0307ad721fc38ffa53ff338563ab5c792ad 100644 --- a/lib_util/ls_custom_file_reader.c +++ b/lib_util/ls_custom_file_reader.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/ls_custom_file_reader.h b/lib_util/ls_custom_file_reader.h index df7fe6bde7a929cb7dff5ae4a4e17d34ab0b58eb..46b20a4ff013827acf56198b2b6f917952f21201 100644 --- a/lib_util/ls_custom_file_reader.h +++ b/lib_util/ls_custom_file_reader.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/masa_file_reader.c b/lib_util/masa_file_reader.c index 5fda0fcc3c146b9fa9c99b467b2983e348c99675..b4a088d2c5a3827334d9aa1fb7e544da4bc43e07 100644 --- a/lib_util/masa_file_reader.c +++ b/lib_util/masa_file_reader.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/masa_file_reader.h b/lib_util/masa_file_reader.h index 5f3f2fec2a9ce19d539ddad48bc29ba53e3c7b0d..7510598c3bf16a9690be159e7da3fd1187fc6d1d 100644 --- a/lib_util/masa_file_reader.h +++ b/lib_util/masa_file_reader.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/masa_file_writer.c b/lib_util/masa_file_writer.c index 171eb4a2e6b88b89def390e944f8321048a3c3b8..0939d0829ce7a4a2bc7a8b1718eea70694c37bf5 100644 --- a/lib_util/masa_file_writer.c +++ b/lib_util/masa_file_writer.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/masa_file_writer.h b/lib_util/masa_file_writer.h index 0619ff02e75223df155abd429e9c39967227ceeb..2d476e28f037e45af8a957b77015c1582bff2ef0 100644 --- a/lib_util/masa_file_writer.h +++ b/lib_util/masa_file_writer.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/mime_io.c b/lib_util/mime_io.c index b5c257bb49558d5c59d02977a566974ff30b5fb2..9bdd20e45343aac7bf6828575850638678267184 100644 --- a/lib_util/mime_io.c +++ b/lib_util/mime_io.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/mime_io.h b/lib_util/mime_io.h index 91b9160529600b46447baf60dca5485c71a3ec1a..dbd21c9c79d2fd67d834b4e3364b0f714546bc36 100644 --- a/lib_util/mime_io.h +++ b/lib_util/mime_io.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/render_config_reader.c b/lib_util/render_config_reader.c index 9ea77d5faf46ba65d6a11833f68f62b36a35ada3..7fb3f1a7aea552ab56ae5d2218c4a1cc6c783f18 100644 --- a/lib_util/render_config_reader.c +++ b/lib_util/render_config_reader.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other @@ -1064,7 +1064,11 @@ static void strip_spaces( while ( pStr[read_idx] ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( !isspace( (int32_t) pStr[read_idx] ) && !iscntrl( (int32_t) pStr[read_idx] ) ) +#else if ( !isspace( pStr[read_idx] ) && !iscntrl( pStr[read_idx] ) ) +#endif { pStr[write_idx++] = pStr[read_idx]; } @@ -1841,6 +1845,10 @@ ivas_error RenderConfigReader_read( uint32_t fgHasMethod, fgHasNBands, fgHasFreqs, fgHasDefaultGrid, fgHasStartFreq, fgHasFreqHop; uint32_t aeHasFgIdx, aeHasPredelay, aeHasRt60, aeHasDsr; uint32_t aeHasERsize, aeHasERabs; +#ifdef SPLIT_REND_WITH_HEAD_ROT + bool dofProvided = false; + bool poseCorrProvided = false; +#endif uint32_t nDP; uint32_t accDPIdx; @@ -2436,6 +2444,142 @@ ivas_error RenderConfigReader_read( free( pValue ); acIdx++; } +#ifdef SPLIT_REND_WITH_HEAD_ROT + else if ( strcmp( chapter, "SPLITREND" ) == 0 && strlen( pParams ) != 0 ) + { + params_idx = 0; + pValue = (char *) calloc( strlen( pParams ), sizeof( char ) ); + while ( sscanf( pParams + params_idx, "%64[^=]=%[^;];", item, pValue ) == 2 ) + { + params_idx += (int32_t) ( strlen( item ) + strlen( pValue ) + 2 ); +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG + fprintf( stderr, " PARAM: %s -> %s\n", item, pValue ); +#endif + if ( strcmp( item, "CODECDELAY" ) == 0 ) + { + if ( !sscanf( pValue, "%hd", &hRenderConfig->split_rend_config.codec_delay_ms ) ) + { + errorHandler( item, ERROR_VALUE_INVALID ); + } + } + else if ( strcmp( item, "HQMODE" ) == 0 ) + { + if ( !sscanf( pValue, "%hd", &hRenderConfig->split_rend_config.hq_mode ) ) + { + errorHandler( item, ERROR_VALUE_INVALID ); + } + } + else if ( strcmp( item, "BITRATE" ) == 0 ) + { + if ( !sscanf( pValue, "%d", &hRenderConfig->split_rend_config.splitRendBitRate ) ) + { + errorHandler( item, ERROR_VALUE_INVALID ); + } + } + else if ( strcmp( item, "DOF" ) == 0 ) + { + dofProvided = true; + if ( !sscanf( pValue, "%hd", &hRenderConfig->split_rend_config.dof ) ) + { + errorHandler( item, ERROR_VALUE_INVALID ); + } + /* 0 DOF implies no pose correction */ + if ( hRenderConfig->split_rend_config.dof == 0 && !poseCorrProvided ) + { + hRenderConfig->split_rend_config.poseCorrectionMode = ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE; + } + } + else if ( strcmp( item, "CODEC" ) == 0 ) + { + if ( strcmp( pValue, "LCLD" ) == 0 ) + { + hRenderConfig->split_rend_config.codec = ISAR_SPLIT_REND_CODEC_LCLD; + } + else if ( strcmp( pValue, "LC3PLUS" ) == 0 ) + { + hRenderConfig->split_rend_config.codec = ISAR_SPLIT_REND_CODEC_LC3PLUS; + } + else + { + errorHandler( pValue, ERROR_VALUE_INVALID ); + } + } + else if ( strcmp( item, "FRAMESIZE" ) == 0 ) + { + if ( !sscanf( pValue, "%hd", &hRenderConfig->split_rend_config.codec_frame_size_ms ) ) + { + errorHandler( item, ERROR_VALUE_INVALID ); + } + if ( hRenderConfig->split_rend_config.codec_frame_size_ms != 5 && + hRenderConfig->split_rend_config.codec_frame_size_ms != 10 && + hRenderConfig->split_rend_config.codec_frame_size_ms != 20 ) + { + errorHandler( item, ERROR_VALUE_INVALID ); + } + } + else if ( strcmp( item, "POSECORRECTION" ) == 0 ) + { + poseCorrProvided = true; + if ( strcmp( pValue, "CLDFB" ) == 0 ) + { + hRenderConfig->split_rend_config.poseCorrectionMode = ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB; + } + else if ( strcmp( pValue, "NONE" ) == 0 ) + { + hRenderConfig->split_rend_config.poseCorrectionMode = ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE; + /* no pose correction implies 0 DOF */ + if ( !dofProvided ) + { + hRenderConfig->split_rend_config.dof = 0; + } + } + else + { + errorHandler( pValue, ERROR_VALUE_INVALID ); + } + } + else if ( strcmp( item, "RENDERER" ) == 0 ) + { + if ( strcmp( pValue, "CREND" ) == 0 ) + { + hRenderConfig->split_rend_config.rendererSelection = ISAR_SPLIT_REND_RENDERER_SELECTION_CREND; + } + else if ( strcmp( pValue, "FASTCONV" ) == 0 ) + { + hRenderConfig->split_rend_config.rendererSelection = ISAR_SPLIT_REND_RENDERER_SELECTION_FASTCONV; + } + else if ( strcmp( pValue, "PARAMBIN" ) == 0 ) + { + hRenderConfig->split_rend_config.rendererSelection = ISAR_SPLIT_REND_RENDERER_SELECTION_PARAMBIN; + } + else if ( strcmp( pValue, "TDREND" ) == 0 ) + { + hRenderConfig->split_rend_config.rendererSelection = ISAR_SPLIT_REND_RENDERER_SELECTION_TDREND; + } + else + { + errorHandler( pValue, ERROR_VALUE_INVALID ); + } + } +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + else if ( strcmp( item, "LC3PLUS_HIGHRES" ) == 0 ) + { + if ( !sscanf( pValue, "%hd", &hRenderConfig->split_rend_config.lc3plus_highres ) ) + { + errorHandler( item, ERROR_VALUE_INVALID ); + } + } +#endif +#ifdef DEBUGGING + else + { + fprintf( stderr, "Unsupported configuration property %s\n", item ); + } +#endif + } + free( pValue ); + } +#endif else if ( strcmp( chapter, "DIRECTIVITYSETTING" ) == 0 && strlen( pParams ) != 0 ) { diff --git a/lib_util/render_config_reader.h b/lib_util/render_config_reader.h index 2e929643282ebc55dfdaff5c25f5c50cf0a26356..5edf73ded33d2cc91653c86276a86a92bc496432 100644 --- a/lib_util/render_config_reader.h +++ b/lib_util/render_config_reader.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/rotation_file_reader.c b/lib_util/rotation_file_reader.c index 19721f49bad23f5bf75ed460e4a82aff3f1bf40a..b948a51524b2c6bf4412eb974e51ec8ec529f8f0 100644 --- a/lib_util/rotation_file_reader.c +++ b/lib_util/rotation_file_reader.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/rotation_file_reader.h b/lib_util/rotation_file_reader.h index 1ae772fceb19d61eb28392282f0494222b705ffc..8d6206bd6331744bb16e22a24ba0205c0a4ac4ca 100644 --- a/lib_util/rotation_file_reader.h +++ b/lib_util/rotation_file_reader.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/rtpdump.c b/lib_util/rtpdump.c index 262f114a13ef015d83562bb35d5d978ed0bc794a..e3eb4c1f4acb3329e0183bd97f820b318cb81400 100644 --- a/lib_util/rtpdump.c +++ b/lib_util/rtpdump.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/rtpdump.h b/lib_util/rtpdump.h index 46300c0e9a1e85fbd704ea54df6da123e40df741..5b8b31e8de3b7a6eda80cd7e6d8e808c6e9446b5 100644 --- a/lib_util/rtpdump.h +++ b/lib_util/rtpdump.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/split_rend_bfi_file_reader.c b/lib_util/split_rend_bfi_file_reader.c new file mode 100644 index 0000000000000000000000000000000000000000..3fc63331783c21e734e2d1a68cea680fd346e85c --- /dev/null +++ b/lib_util/split_rend_bfi_file_reader.c @@ -0,0 +1,162 @@ +/****************************************************************************************************** + + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#include +#include "options.h" +#include "split_rend_bfi_file_reader.h" +#ifdef SPLIT_REND_WITH_HEAD_ROT +#include +#include "prot.h" + +struct SplitRendBFIFileReader +{ + FILE *bfiFile; + int32_t frameCounter; + char *file_path; + bool fileRewind; + bool txtfile; +}; + + +/*-----------------------------------------------------------------------* + * SplitRendBFIFileReader_open() + * + * Allocate and initialize Split Renderer Frameloss file reader + *-----------------------------------------------------------------------*/ + +ivas_error SplitRendBFIFileReader_open( + char *bfiFilePath, /* i : frame loss file name */ + SplitRendBFIFileReader **SplitRendBFIReader /* o : SplitRendBFIFileReader handle */ +) +{ + SplitRendBFIFileReader *self; + FILE *bfiFile; + bool txtfile; + + /* Open bfi file */ + if ( strlen( bfiFilePath ) < 1 ) + { + return IVAS_ERR_FAILED_FILE_OPEN; + } + + bfiFile = fopen( bfiFilePath, "r" ); + + if ( !bfiFile ) + { + return IVAS_ERR_FAILED_FILE_OPEN; + } + + txtfile = ( strcmp( bfiFilePath + strlen( bfiFilePath ) - 4, ".txt" ) ? false : true ); + + self = calloc( sizeof( SplitRendBFIFileReader ), 1 ); + self->bfiFile = bfiFile; + self->frameCounter = 0; + self->file_path = calloc( sizeof( char ), strlen( bfiFilePath ) + 1 ); + strcpy( self->file_path, bfiFilePath ); + self->fileRewind = false; + self->txtfile = txtfile; + + *SplitRendBFIReader = self; + + return IVAS_ERR_OK; +} + + +/*-----------------------------------------------------------------------* + * SplitRendBFIFileReading() + * + * Read values from the bfi file + *-----------------------------------------------------------------------*/ + +ivas_error SplitRendBFIFileReading( + SplitRendBFIFileReader *SplitRendBFIReader, /* i/o: SplitRendBFIFileReader handle */ + int16_t *bfi ) +{ + if ( SplitRendBFIReader->txtfile ? 1 != fscanf( SplitRendBFIReader->bfiFile, "%hd", bfi ) : 1 != fread( bfi, sizeof( *bfi ), 1, SplitRendBFIReader->bfiFile ) ) + { + if ( feof( SplitRendBFIReader->bfiFile ) ) + { + rewind( SplitRendBFIReader->bfiFile ); + SplitRendBFIReader->fileRewind = true; + return SplitRendBFIFileReading( SplitRendBFIReader, bfi ); + } + return IVAS_ERR_FAILED_FILE_PARSE; + } + + ( SplitRendBFIReader->frameCounter )++; + + return IVAS_ERR_OK; +} + + +/*-----------------------------------------------------------------------* + * SplitRendBFIationFileReader_close() + * + * Deallocates memory for the Head-Tracking reader + *-----------------------------------------------------------------------*/ + +void SplitRendBFIFileReader_close( + SplitRendBFIFileReader **SplitRendBFIReader /* i/o: SplitRendBFIFileReader handle */ +) +{ + if ( SplitRendBFIReader == NULL || *SplitRendBFIReader == NULL ) + { + return; + } + + fclose( ( *SplitRendBFIReader )->bfiFile ); + free( ( *SplitRendBFIReader )->file_path ); + free( *SplitRendBFIReader ); + *SplitRendBFIReader = NULL; + + return; +} + + +/*-----------------------------------------------------------------------* + * SplitRendBFIFileReader_getFilePath() + * + * + *-----------------------------------------------------------------------*/ + +const char *SplitRendBFIFileReader_getFilePath( + SplitRendBFIFileReader *SplitRendBFIReader /* i/o: SplitRendBFIFileReader handle */ +) +{ + if ( SplitRendBFIReader == NULL ) + { + return NULL; + } + + return SplitRendBFIReader->file_path; +} +#endif /* SPLIT_REND_WITH_HEAD_ROT */ diff --git a/lib_util/split_rend_bfi_file_reader.h b/lib_util/split_rend_bfi_file_reader.h new file mode 100644 index 0000000000000000000000000000000000000000..679c424a1563cc4fd8de76651ef439565a03269c --- /dev/null +++ b/lib_util/split_rend_bfi_file_reader.h @@ -0,0 +1,60 @@ +/****************************************************************************************************** + + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#ifndef IVAS_SR_BFI_FILE_READER_H +#define IVAS_SR_BFI_FILE_READER_H + +#include "common_api_types.h" +#ifdef SPLIT_REND_WITH_HEAD_ROT + +typedef struct SplitRendBFIFileReader SplitRendBFIFileReader; + +ivas_error SplitRendBFIFileReader_open( + char *trajFilePath, /* i : head rotation trajectory file name */ + SplitRendBFIFileReader **SplitRendBFIReader /* o : SplitRendBFIFileReader handle */ +); + +ivas_error SplitRendBFIFileReading( + SplitRendBFIFileReader *SplitRendBFIReader, /* i/o: SplitRendBFIFileReader handle */ + int16_t *bfi ); + +void SplitRendBFIFileReader_close( + SplitRendBFIFileReader **SplitRendBFIReader /* i/o: SplitRendBFIFileReader handle */ +); + +const char *SplitRendBFIFileReader_getFilePath( + SplitRendBFIFileReader *SplitRendBFIReader /* i/o: SplitRendBFIFileReader handle */ +); + + +#endif /* SPLIT_REND_WITH_HEAD_ROT */ +#endif /* IVAS_SR_BFI_FILE_READER_H */ diff --git a/lib_util/split_render_file_read_write.c b/lib_util/split_render_file_read_write.c new file mode 100644 index 0000000000000000000000000000000000000000..e52f9fe86ddb867237859198ff127699a7036fe7 --- /dev/null +++ b/lib_util/split_render_file_read_write.c @@ -0,0 +1,431 @@ +/****************************************************************************************************** + + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#include +#include "options.h" +#include "split_render_file_read_write.h" +#ifdef SPLIT_REND_WITH_HEAD_ROT +#include +#include "prot.h" + + +/*------------------------------------------------------------------------------------------* + * PreProc Macros + *------------------------------------------------------------------------------------------*/ + +#define SPLIT_RENDERER_FRAME_HEADER_LEN ( 12 ) + +/*------------------------------------------------------------------------------------------* + * Type definitions + *------------------------------------------------------------------------------------------*/ + +struct SplitFileReadWrite +{ + FILE *file; + uint32_t delay_ns; +}; + + +/*-----------------------------------------------------------------------------------------* + * Function split_rend_reader_open() + * + * open in read mode + *-----------------------------------------------------------------------------------------*/ + +ivas_error split_rend_reader_open( + SplitFileReadWrite **hhSplitRendFileReadWrite, + char *filename, + ISAR_SPLIT_REND_CODEC *codec, + ISAR_SPLIT_REND_POSE_CORRECTION_MODE *poseCorrection, + int16_t *codec_frame_size_ms +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + , + int16_t *isar_frame_size_ms, + int32_t *sampling_rate, + int16_t *lc3plus_highres +#endif +) +{ + SplitFileReadWrite *hSplitRendFileReadWrite; + size_t header_len, h; + char header[SPLIT_RENDERER_FRAME_HEADER_LEN] = "MAIN_SPLITH"; + char header_read[SPLIT_RENDERER_FRAME_HEADER_LEN]; + + if ( ( hSplitRendFileReadWrite = (SplitFileReadWrite *) malloc( sizeof( SplitFileReadWrite ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for split rendering writer\n" ) ); + } + + hSplitRendFileReadWrite->file = fopen( filename, "rb" ); + if ( hSplitRendFileReadWrite->file == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_FILE_READ, "\nCould not open split rend metadata file %s\n", filename ) ); + } + + header_len = strlen( header ); + + /*read frame header*/ + for ( h = 0; h < header_len; h++ ) + { + if ( fread( &header_read[h], sizeof( char ), 1, hSplitRendFileReadWrite->file ) != 1 ) + { + return IVAS_ERR_FAILED_FILE_READ; + } + } + + if ( strncmp( header_read, header, header_len ) ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_FILE_READ, "\nError split rend bitstream main header mismatch\n" ) ); + } + + fread( &hSplitRendFileReadWrite->delay_ns, sizeof( uint32_t ), 1, hSplitRendFileReadWrite->file ); + + /* read codec signalling */ + if ( fread( codec, sizeof( *codec ), 1, hSplitRendFileReadWrite->file ) != 1 ) + { + return IVAS_ERR_FAILED_FILE_READ; + } + + /* read pose correction signalling */ + if ( fread( poseCorrection, sizeof( *poseCorrection ), 1, hSplitRendFileReadWrite->file ) != 1 ) + { + return IVAS_ERR_FAILED_FILE_READ; + } + /* read transport codec frame size signalling */ + if ( fread( codec_frame_size_ms, sizeof( *codec_frame_size_ms ), 1, hSplitRendFileReadWrite->file ) != 1 ) + { + return IVAS_ERR_FAILED_FILE_READ; + } +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + /* read isar bitstream frame size signalling */ + if ( fread( isar_frame_size_ms, sizeof( *isar_frame_size_ms ), 1, hSplitRendFileReadWrite->file ) != 1 ) + { + return IVAS_ERR_FAILED_FILE_READ; + } + /* read sampling rate signalling */ + if ( fread( sampling_rate, sizeof( *sampling_rate ), 1, hSplitRendFileReadWrite->file ) != 1 ) + { + return IVAS_ERR_FAILED_FILE_READ; + } + /* read LC3plus highres signalling */ + if ( fread( lc3plus_highres, sizeof( *lc3plus_highres ), 1, hSplitRendFileReadWrite->file ) != 1 ) + { + return IVAS_ERR_FAILED_FILE_READ; + } +#endif + + *hhSplitRendFileReadWrite = hSplitRendFileReadWrite; + + return IVAS_ERR_OK; +} + + +/*-----------------------------------------------------------------------------------------* + * Function split_rend_writer_open() + * + * open in write mode + *-----------------------------------------------------------------------------------------*/ + +ivas_error split_rend_writer_open( + SplitFileReadWrite **hhSplitRendFileReadWrite, + char *filename, + const int16_t delayNumSamples, + const int32_t delayTimeScale, + ISAR_SPLIT_REND_CODEC codec, + ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrection, + int16_t codec_frame_size_ms +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + , + const int16_t isar_frame_size_ms, + const int32_t sampling_rate, + const int16_t lc3plus_highres +#endif +) +{ + SplitFileReadWrite *hSplitRendFileReadWrite; + size_t header_len, h; + char header[SPLIT_RENDERER_FRAME_HEADER_LEN] = "MAIN_SPLITH"; + + if ( filename == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + if ( ( hSplitRendFileReadWrite = (SplitFileReadWrite *) malloc( sizeof( SplitFileReadWrite ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for split rendering writer\n" ) ); + } + + hSplitRendFileReadWrite->file = fopen( filename, "wb" ); + if ( hSplitRendFileReadWrite->file == NULL ) + { + return IVAS_ERR_FAILED_FILE_OPEN; + } + + header_len = strlen( header ); + + /* write frame header */ + for ( h = 0; h < header_len; h++ ) + { + if ( fwrite( &header[h], sizeof( char ), 1, hSplitRendFileReadWrite->file ) != 1 ) + { + return IVAS_ERR_END_OF_FILE; + } + } + hSplitRendFileReadWrite->delay_ns = (int32_t) ( (float) delayNumSamples * 1000000000.0f / (float) delayTimeScale ); + fwrite( &hSplitRendFileReadWrite->delay_ns, sizeof( int32_t ), 1, hSplitRendFileReadWrite->file ); + + /* Write codec signalling */ + if ( fwrite( &codec, sizeof( codec ), 1, hSplitRendFileReadWrite->file ) != 1 ) + { + return IVAS_ERR_FAILED_FILE_WRITE; + } + + /* Write pose correction signalling */ + if ( fwrite( &poseCorrection, sizeof( poseCorrection ), 1, hSplitRendFileReadWrite->file ) != 1 ) + { + return IVAS_ERR_FAILED_FILE_WRITE; + } + /* Write transport codec frame size signalling */ + if ( fwrite( &codec_frame_size_ms, sizeof( codec_frame_size_ms ), 1, hSplitRendFileReadWrite->file ) != 1 ) + { + return IVAS_ERR_FAILED_FILE_WRITE; + } +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + /* Write isar bit stream frame size signalling */ + if ( fwrite( &isar_frame_size_ms, sizeof( isar_frame_size_ms ), 1, hSplitRendFileReadWrite->file ) != 1 ) + { + return IVAS_ERR_FAILED_FILE_WRITE; + } + /* Write sampling rate signalling */ + if ( fwrite( &sampling_rate, sizeof( sampling_rate ), 1, hSplitRendFileReadWrite->file ) != 1 ) + { + return IVAS_ERR_FAILED_FILE_WRITE; + } + /* Write LC3plus highres signalling */ + if ( fwrite( &lc3plus_highres, sizeof( lc3plus_highres ), 1, hSplitRendFileReadWrite->file ) != 1 ) + { + return IVAS_ERR_FAILED_FILE_WRITE; + } +#endif + + *hhSplitRendFileReadWrite = hSplitRendFileReadWrite; + + return IVAS_ERR_OK; +} + + +/*-----------------------------------------------------------------------------------------* + * Function split_rend_reader_writer_close() + * + * + *-----------------------------------------------------------------------------------------*/ + +void split_rend_reader_writer_close( + SplitFileReadWrite **hhSplitRendFileReadWrite ) +{ + if ( ( *hhSplitRendFileReadWrite ) != NULL ) + { + if ( ( *hhSplitRendFileReadWrite )->file != NULL ) + { + fclose( ( *hhSplitRendFileReadWrite )->file ); + ( *hhSplitRendFileReadWrite )->file = NULL; + } + + free( *hhSplitRendFileReadWrite ); + *hhSplitRendFileReadWrite = NULL; + } + + return; +} + + +/*-----------------------------------------------------------------------------------------* + * Function split_rend_write_bitstream_to_file() + * + * + *-----------------------------------------------------------------------------------------*/ + +ivas_error split_rend_write_bitstream_to_file( + SplitFileReadWrite *hSplitRendFileReadWrite, + uint8_t *bits, + int32_t *bits_read, + int32_t *bits_written ) +{ + char header[SPLIT_RENDERER_FRAME_HEADER_LEN] = "SPLIT_FRAME"; + size_t header_len, i, num_bytes; + uint8_t version = 0; + + if ( hSplitRendFileReadWrite == NULL ) + { + return IVAS_ERR_FAILED_FILE_READ; + } + + if ( hSplitRendFileReadWrite->file == NULL ) + { + return IVAS_ERR_FAILED_FILE_WRITE; + } + + header_len = strlen( header ); + + /* write frame header */ + for ( i = 0; i < header_len; i++ ) + { + if ( fwrite( &header[i], sizeof( char ), 1, hSplitRendFileReadWrite->file ) != 1 ) + { + return IVAS_ERR_FAILED_FILE_WRITE; + } + } + + /* Write versioning signalling */ + if ( fwrite( &version, 1, 1, hSplitRendFileReadWrite->file ) != 1 ) + { + return IVAS_ERR_FAILED_FILE_WRITE; + } + + /* write num bytes */ + if ( fwrite( bits_written, sizeof( int32_t ), 1, hSplitRendFileReadWrite->file ) != 1 ) + { + return IVAS_ERR_FAILED_FILE_WRITE; + } + + num_bytes = ( *bits_written + 7 ) >> 3; + if ( fwrite( bits, sizeof( uint8_t ), num_bytes, hSplitRendFileReadWrite->file ) != num_bytes ) + { + return IVAS_ERR_FAILED_FILE_WRITE; + } + + *bits_read = 0; + *bits_written = 0; + + return IVAS_ERR_OK; +} + + +/*-----------------------------------------------------------------------------------------* + * Function split_rend_read_bits_from_file() + * + * + *-----------------------------------------------------------------------------------------*/ + +ivas_error split_rend_read_bits_from_file( + SplitFileReadWrite *hSplitRendFileReadWrite, + uint8_t *bits, + int32_t *bits_read, + int32_t *bits_written ) +{ + char header[SPLIT_RENDERER_FRAME_HEADER_LEN] = "SPLIT_FRAME"; + char header_read[SPLIT_RENDERER_FRAME_HEADER_LEN]; + int32_t header_len, i, num_bytes, bit_len = 0; + uint8_t version; + + if ( hSplitRendFileReadWrite == NULL ) + { + return IVAS_ERR_FAILED_FILE_READ; + } + + if ( hSplitRendFileReadWrite->file == NULL ) + { + return IVAS_ERR_FAILED_FILE_READ; + } + + header_len = (int32_t) strlen( header ); + + /* read frame header */ + for ( i = 0; i < header_len; i++ ) + { + if ( fread( &header_read[i], sizeof( char ), 1, hSplitRendFileReadWrite->file ) != 1 ) + { + return IVAS_ERR_END_OF_FILE; + } + } + + if ( strncmp( header_read, header, header_len ) ) + { + fprintf( stderr, "Error bitstream frame header mismatch\n" ); + return IVAS_ERR_FAILED_FILE_READ; + } + + /* read versioning signalling */ + if ( fread( &version, 1, 1, hSplitRendFileReadWrite->file ) != 1 ) + { + return IVAS_ERR_FAILED_FILE_WRITE; + } + if ( version != 0 ) + { + fprintf( stderr, "Error bitstream version mismatch\n" ); + return IVAS_ERR_FAILED_FILE_READ; + } + + /* write num bytes */ + if ( fread( &bit_len, sizeof( int32_t ), 1, hSplitRendFileReadWrite->file ) != 1 ) + { + return IVAS_ERR_FAILED_FILE_READ; + } + num_bytes = ( bit_len + 7 ) >> 3; + + if ( fread( bits, sizeof( uint8_t ), num_bytes, hSplitRendFileReadWrite->file ) != (uint32_t) num_bytes ) + { + return IVAS_ERR_FAILED_FILE_READ; + } + for ( i = 0; i < ISAR_SPLIT_REND_ADDITIONAL_BYTES_TO_READ; i++ ) + { + bits[num_bytes + i] = 0; + } + + *bits_read = 0; + *bits_written = bit_len; + + return IVAS_ERR_OK; +} + + +/*-----------------------------------------------------------------------------------------* + * Function split_rend_read_pre_rend_delay_ns() + * + * + *-----------------------------------------------------------------------------------------*/ + +ivas_error split_rend_read_pre_rend_delay_ns( + SplitFileReadWrite *hSplitRendFileReadWrite, + uint32_t *delay_ns ) +{ + if ( hSplitRendFileReadWrite == NULL ) + { + return IVAS_ERR_FAILED_FILE_READ; + } + + *delay_ns = hSplitRendFileReadWrite->delay_ns; + + return IVAS_ERR_OK; +} +#endif /* SPLIT_REND_WITH_HEAD_ROT */ diff --git a/lib_util/split_render_file_read_write.h b/lib_util/split_render_file_read_write.h new file mode 100644 index 0000000000000000000000000000000000000000..bdda7e59893446ef9501f87464f1463474c119a9 --- /dev/null +++ b/lib_util/split_render_file_read_write.h @@ -0,0 +1,99 @@ +/****************************************************************************************************** + + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#ifndef SPLIT_RENDER_FILE_READ_WRITE_H +#define SPLIT_RENDER_FILE_READ_WRITE_H + +#include "common_api_types.h" +#ifdef SPLIT_REND_WITH_HEAD_ROT + +typedef struct SplitFileReadWrite SplitFileReadWrite; + +/* Allocates and initializes a a split renderer reader instance */ +ivas_error split_rend_reader_open( + SplitFileReadWrite **hhSplitRendFileReadWrite, + char *filename, + ISAR_SPLIT_REND_CODEC *codec, + ISAR_SPLIT_REND_POSE_CORRECTION_MODE *poseCorrection, + int16_t *codec_frame_size_ms +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + , + int16_t *isar_frame_size_ms, + int32_t *sampling_rate, + int16_t *lc3plus_highres +#endif +); + + +/* Allocates and initializes a a split renderer writer instance */ +ivas_error split_rend_writer_open( + SplitFileReadWrite **hhSplitRendFileReadWrite, + char *filename, + const int16_t delayNumSamples, + const int32_t delayTimeScale, + ISAR_SPLIT_REND_CODEC codec, + ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrection, + int16_t codec_frame_size_ms +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + , + const int16_t isar_frame_size_ms, + const int32_t sampling_rate, + const int16_t lc3plus_highres +#endif +); + + +/* Closes the split renderer reader/writer and deallocates memory */ +void split_rend_reader_writer_close( + SplitFileReadWrite **hhSplitRendFileReadWrite ); + +/*write split rend coded bitstream to file */ +ivas_error split_rend_write_bitstream_to_file( + SplitFileReadWrite *hSplitRendFileReadWrite, + uint8_t *bits, + int32_t *bits_read, + int32_t *bits_written ); + +/* read split rend coded bits from file */ +ivas_error split_rend_read_bits_from_file( + SplitFileReadWrite *hSplitRendFileReadWrite, + uint8_t *bits, + int32_t *bits_read, + int32_t *bits_written ); + +/* read split pre rend delay */ +ivas_error split_rend_read_pre_rend_delay_ns( + SplitFileReadWrite *hSplitRendFileReadWrite, + uint32_t *delay_ns ); + +#endif /* SPLIT_REND_WITH_HEAD_ROT */ +#endif /* SPLIT_RENDER_FILE_READ_WRITE_H */ diff --git a/lib_util/tinywavein_c.h b/lib_util/tinywavein_c.h index cddcb6450184d85979aae605f9656ec962aa98a1..b86d97c9640f1e91427a4b6cf8731df62a1596bb 100644 --- a/lib_util/tinywavein_c.h +++ b/lib_util/tinywavein_c.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/tinywaveout_c.h b/lib_util/tinywaveout_c.h index db60146a02ae467d7b637ecb2adaca525e065079..693beccf9557dfaf7d6a507cb614064f76049f03 100644 --- a/lib_util/tinywaveout_c.h +++ b/lib_util/tinywaveout_c.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/tsm_scale_file_reader.c b/lib_util/tsm_scale_file_reader.c new file mode 100644 index 0000000000000000000000000000000000000000..3b9a2895add15be06ed757f719e45ae9463f18bf --- /dev/null +++ b/lib_util/tsm_scale_file_reader.c @@ -0,0 +1,148 @@ +/****************************************************************************************************** + + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#include "tsm_scale_file_reader.h" +#include "cmdl_tools.h" +#include +#include +#include + +struct TsmScaleFileReader +{ + FILE *file; + char *file_path; + bool fileRewind; +}; + + +/*---------------------------------------------------------------------* + * TsmScaleFileReader_open() + * + * Allocates memory for an TsmScaleFileReader and opens the file at given path for reading. + *---------------------------------------------------------------------*/ + +/*! r: JbmFileReader handle */ +TsmScaleFileReader *TsmScaleFileReader_open( + const char *filePath /* i : path to CA config file */ +) +{ + TsmScaleFileReader *self; + FILE *file; + + if ( !filePath ) + { + return NULL; + } + + file = fopen( filePath, "rb" ); + + if ( !file ) + { + return NULL; + } + + self = calloc( sizeof( TsmScaleFileReader ), 1 ); + self->file = file; + self->file_path = calloc( sizeof( char ), strlen( filePath ) + 1 ); + strcpy( self->file_path, filePath ); + + return self; +} + + +/*---------------------------------------------------------------------* + * TsmScaleFileReader_readScale() + * + * Read TSM scale entry + *---------------------------------------------------------------------*/ + +ivas_error TsmScaleFileReader_readScale( + TsmScaleFileReader *self, /* i/o: TsmScaleFileReader handle */ + int16_t *scale /* o : scale */ +) +{ + int tmp; + if ( 1 != fscanf( self->file, "%d", &tmp ) ) + { + if ( feof( self->file ) ) + { + rewind( self->file ); + self->fileRewind = true; + return TsmScaleFileReader_readScale( self, scale ); + } + return IVAS_ERR_FAILED_FILE_PARSE; + } + *scale = (int16_t) tmp; + return IVAS_ERR_OK; +} + + +/*---------------------------------------------------------------------* + * JbmFileReader_close() + * + * De-allocates all underlying memory of an JbmFileReader. + *---------------------------------------------------------------------*/ + +void TsmScaleFileReader_close( + TsmScaleFileReader **selfPtr /* i/o: pointer to JbmFileReader handle */ +) +{ + if ( selfPtr == NULL || *selfPtr == NULL ) + { + return; + } + + fclose( ( *selfPtr )->file ); + free( ( *selfPtr )->file_path ); + free( *selfPtr ); + *selfPtr = NULL; + + return; +} + + +/*---------------------------------------------------------------------* + * JbmFileReader_getFilePath() + * + *---------------------------------------------------------------------*/ + +const char *TsmScaleFileReader_getFilePath( + TsmScaleFileReader *self /* i/o: JbmFileReader handle */ +) +{ + if ( self == NULL ) + { + return NULL; + } + + return self->file_path; +} diff --git a/lib_util/tsm_scale_file_reader.h b/lib_util/tsm_scale_file_reader.h new file mode 100644 index 0000000000000000000000000000000000000000..7c5cb051d62741e6ea28a8278fe3678532144664 --- /dev/null +++ b/lib_util/tsm_scale_file_reader.h @@ -0,0 +1,64 @@ +/****************************************************************************************************** + + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#ifndef IVAS_TSM_SCALE_FILE_READER_H +#define IVAS_TSM_SCALE_FILE_READER_H + +#include "common_api_types.h" + +/* clang-format off */ + +typedef struct TsmScaleFileReader TsmScaleFileReader; + + +/*! r: TsmScaleFileReader handle */ +TsmScaleFileReader *TsmScaleFileReader_open( + const char *filePath /* i : path to TSM scale file */ +); + +ivas_error TsmScaleFileReader_readScale( + TsmScaleFileReader* self, /* i/o: TsmScaleFileReader handle */ + int16_t *scale /* o : next scale */ +); + +void TsmScaleFileReader_close( + TsmScaleFileReader **selfPtr /* i/o: pointer to TsmScaleFileReader handle */ +); + +/*! r: path to the currently opened file or NULL if `self` is NULL */ +const char *TsmScaleFileReader_getFilePath( + TsmScaleFileReader* self /* i/o: TsmScaleFileReader handle */ +); + +/* clang-format on */ + +#endif /* IVAS_TSM_SCALE_FILE_READER_H */ diff --git a/lib_util/vector3_pair_file_reader.c b/lib_util/vector3_pair_file_reader.c index 9e03358b91c901e9c6f2875bb8f714cce00a86db..a6aee3eefb31c7276e2b7e0e1775e34e72da767e 100644 --- a/lib_util/vector3_pair_file_reader.c +++ b/lib_util/vector3_pair_file_reader.c @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/lib_util/vector3_pair_file_reader.h b/lib_util/vector3_pair_file_reader.h index e4691939220cfaded272c9481c715f73cd018d65..6515d32d58f68c5088204f7fa1aae667ad3140cb 100644 --- a/lib_util/vector3_pair_file_reader.h +++ b/lib_util/vector3_pair_file_reader.h @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other diff --git a/readme.txt b/readme.txt index e39174163960b44daf988c902afd177883de5bc7..9b1ab852d136d9976a04d7d1bdb1b54cbd30d6ff 100644 --- a/readme.txt +++ b/readme.txt @@ -1,6 +1,6 @@ /****************************************************************************************************** - (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other