diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c306a2537b7cf5e3a4a46716fa3711d4d9173457..aeb270a3625fe8a0cdbed5c497c66ce6e19c51ba 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -244,6 +244,7 @@ stages: extends: .test-job-linux before_script: - if [ ! -d "$TESTV_DIR" ]; then mkdir -p $TESTV_DIR; fi + - python3 scripts/prepare_combined_format_inputs.py - cp -r scripts/testv/* $TESTV_DIR/ # --------------------------------------------------------------- @@ -397,7 +398,7 @@ build-codec-windows-msbuild: - *print-common-info-windows - *activate-WX-windows - py .\scripts\strip_split_rendering.py - - MSBuild.exe .\Workspace_msvc\Workspace_msvc.sln /property:Configuration=Debug + - MSBuild.exe -maxcpucount .\Workspace_msvc\Workspace_msvc.sln /property:Configuration=Debug # --------------------------------------------------------------- # Test jobs for merge requests @@ -408,7 +409,7 @@ codec-smoke-test: extends: - .test-job-linux-needs-testv-dir - .rules-merge-request - timeout: "17 minutes" + timeout: "20 minutes" tags: - ivas-linux-fast stage: test @@ -440,7 +441,7 @@ codec-smoke-test: # code selftest testvectors with memory-sanitizer binaries codec-msan: extends: - - .test-job-linux + - .test-job-linux-needs-testv-dir - .rules-merge-request stage: test needs: ["build-codec-sanitizers-linux"] @@ -448,22 +449,26 @@ codec-msan: - *print-common-info - make clean - make -j CLANG=1 - - python3 scripts/self_test.py -z console --create | tee test_output.txt - - run_errors=$(cat test_output.txt | grep -ic "run errors") || true - - if [ $run_errors != 0 ] ; then echo "Run errors in self_test.py with Clang memory-sanitizer"; exit 1; fi + - testcase_timeout=180 + - exit_code=0 + - python3 -m pytest tests/codec_be_on_mr_nonselection/test_param_file.py -v --update_ref 1 -m create_ref --html=report.html --self-contained-html --junit-xml=report-junit.xml --testcase_timeout=$testcase_timeout --ref_encoder_path ./IVAS_cod --ref_decoder_path ./IVAS_dec || exit_code=$? + - if [ $exit_code != 0 ] ; then echo "Run errors found by Clang memory-sanitizer"; exit 1; fi artifacts: name: "mr-$CI_MERGE_REQUEST_IID--sha-$CI_COMMIT_SHORT_SHA--stage-$CI_JOB_STAGE--results" expire_in: 1 week when: always paths: - - scripts/ref/logs/ - - test_output.txt + - report-junit.xml + - report.html expose_as: "msan selftest results" + reports: + junit: + - report-junit.xml # code selftest testvectors with address-sanitizer binaries codec-asan: extends: - - .test-job-linux + - .test-job-linux-needs-testv-dir - .rules-merge-request stage: test needs: ["build-codec-sanitizers-linux"] @@ -471,22 +476,26 @@ codec-asan: - *print-common-info - make clean - make -j CLANG=2 - - python3 scripts/self_test.py -z console --create | tee test_output.txt - - run_errors=$(cat test_output.txt | grep -ic "run errors") || true - - if [ $run_errors != 0 ] ; then echo "Run errors in self_test.py with Clang address-sanitizer"; exit 1; fi + - testcase_timeout=180 + - exit_code=0 + - python3 -m pytest tests/codec_be_on_mr_nonselection/test_param_file.py -v --update_ref 1 -m create_ref --html=report.html --self-contained-html --junit-xml=report-junit.xml --testcase_timeout=$testcase_timeout --ref_encoder_path ./IVAS_cod --ref_decoder_path ./IVAS_dec || exit_code=$? + - if [ $exit_code != 0 ] ; then echo "Run errors found by Clang address-sanitizer"; exit 1; fi artifacts: name: "mr-$CI_MERGE_REQUEST_IID--sha-$CI_COMMIT_SHORT_SHA--stage-$CI_JOB_STAGE--results" expire_in: 1 week when: always paths: - - scripts/ref/logs/ - - test_output.txt + - report-junit.xml + - report.html expose_as: "asan selftest results" + reports: + junit: + - report-junit.xml # code selftest testvectors with address-sanitizer binaries codec-usan: extends: - - .test-job-linux + - .test-job-linux-needs-testv-dir - .rules-merge-request stage: test needs: ["build-codec-sanitizers-linux"] @@ -494,17 +503,21 @@ codec-usan: - *print-common-info - make clean - make -j CLANG=3 - - UBSAN_OPTIONS=suppressions=scripts/ubsan.supp,report_error_type=1 python3 scripts/self_test.py -z console --create - - grep_exit_code=0 - - grep UndefinedBehaviorSanitizer scripts/ref/logs/* || grep_exit_code=$? - - if [ $grep_exit_code != 1 ] ; then echo "Run errors in self_test.py with Clang undefined-behavior-sanitizer"; exit 1; fi + - testcase_timeout=180 + - exit_code=0 + - UBSAN_OPTIONS=suppressions=scripts/ubsan.supp,report_error_type=1 python3 -m pytest tests/codec_be_on_mr_nonselection/test_param_file.py -v --update_ref 1 -m create_ref --html=report.html --self-contained-html --junit-xml=report-junit.xml --testcase_timeout=$testcase_timeout --ref_encoder_path ./IVAS_cod --ref_decoder_path ./IVAS_dec || exit_code=$? + - if [ $exit_code != 0 ] ; then echo "Run errors found by Clang undefined-behavior-sanitizer"; exit 1; fi artifacts: name: "mr-$CI_MERGE_REQUEST_IID--sha-$CI_COMMIT_SHORT_SHA--stage-$CI_JOB_STAGE--results" expire_in: 1 week when: always paths: - - scripts/ref/logs/ + - report-junit.xml + - report.html expose_as: "usan selftest results" + reports: + junit: + - report-junit.xml # test renderer executable renderer-smoke-test: @@ -515,7 +528,8 @@ renderer-smoke-test: stage: test script: - make -j IVAS_rend - - python3 -m pytest -q -n auto -rA --junit-xml=report-junit.xml tests/renderer/test_renderer.py + - testcase_timeout=60 + - python3 -m pytest -q -n auto -rA --junit-xml=report-junit.xml tests/renderer/test_renderer.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 @@ -537,7 +551,8 @@ renderer-asan: script: - cmake -B cmake-build -G "Unix Makefiles" -DCLANG=asan -DCOPY_EXECUTABLES_FROM_BUILD_DIR=true - cmake --build cmake-build -- -j - - python3 -m pytest -q -n auto -rA --junit-xml=report-junit.xml tests/renderer/test_renderer.py + - testcase_timeout=180 + - python3 -m pytest -q -n auto -rA --junit-xml=report-junit.xml tests/renderer/test_renderer.py --testcase_timeout=$testcase_timeout artifacts: name: "mr-$CI_MERGE_REQUEST_IID--sha-$CI_COMMIT_SHORT_SHA--job-$CI_JOB_NAME--results" @@ -560,7 +575,8 @@ renderer-msan: script: - cmake -B cmake-build -G "Unix Makefiles" -DCLANG=msan -DCOPY_EXECUTABLES_FROM_BUILD_DIR=true - cmake --build cmake-build -- -j - - python3 -m pytest -q -n auto -rA --junit-xml=report-junit.xml tests/renderer/test_renderer.py + - testcase_timeout=180 + - python3 -m pytest -q -n auto -rA --junit-xml=report-junit.xml tests/renderer/test_renderer.py --testcase_timeout=$testcase_timeout artifacts: name: "mr-$CI_MERGE_REQUEST_IID--sha-$CI_COMMIT_SHORT_SHA--job-$CI_JOB_NAME--results" @@ -583,7 +599,8 @@ renderer-usan: script: - cmake -B cmake-build -G "Unix Makefiles" -DCLANG=usan -DCOPY_EXECUTABLES_FROM_BUILD_DIR=true - cmake --build cmake-build -- -j - - UBSAN_OPTIONS=suppressions=scripts/ubsan.supp,report_error_type=1,log_path=usan_log_catchall python3 -m pytest -q -n auto -rA --junit-xml=report-junit.xml tests/renderer/test_renderer.py + - testcase_timeout=180 + - UBSAN_OPTIONS=suppressions=scripts/ubsan.supp,report_error_type=1,log_path=usan_log_catchall python3 -m pytest -q -n auto -rA --junit-xml=report-junit.xml tests/renderer/test_renderer.py --testcase_timeout=$testcase_timeout - grep_exit_code=0 - touch usan_log_empty # Creates an empty file, this is to avoid "grep: usan_log_*: No such file or directory" in case no USAN failures are reported from pytest - grep UndefinedBehaviorSanitizer usan_log_* || grep_exit_code=$? @@ -603,7 +620,7 @@ renderer-usan: # compare renderer bitexactness between target and source branch renderer-pytest-on-merge-request: extends: - - .test-job-linux + - .test-job-linux-needs-testv-dir - .rules-merge-request needs: ["build-codec-linux-make"] # TODO: set reasonable timeout, will most likely take less @@ -625,13 +642,14 @@ renderer-pytest-on-merge-request: - if [ $ref_using_main == 0 ]; then git checkout $source_branch_commit_sha; fi - exit_code=0 - - python3 -m pytest -q --log-level ERROR -n auto -rA --html=report.html --self-contained-html --junit-xml=report-junit.xml tests/renderer/test_renderer.py --create_ref || exit_code=$? + - 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/renderer/test_renderer.py --create_ref --testcase_timeout=$testcase_timeout || exit_code=$? ### Run test using branch scripts and input - if [ $ref_using_main == 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/renderer/test_renderer_.py --create_cut || exit_code=$? + - python3 -m pytest -q --log-level ERROR -n auto -rA --html=report.html --self-contained-html --junit-xml=report-junit.xml tests/renderer/test_renderer_.py --create_cut --testcase_timeout=$testcase_timeout || exit_code=$? - zero_errors=$(cat report-junit.xml | grep -c 'errors="0"') || true - *merge-request-comparison-check @@ -661,7 +679,8 @@ split-rendering-smoke-test: script: - *enable-split-rendering - make -j INCLUDE_SPLIT=1 - - python3 -m pytest -q -n auto -rA --junit-xml=report-junit.xml tests/split_rendering/test_split_rendering.py + - 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 @@ -676,7 +695,7 @@ split-rendering-smoke-test: # compare split-rendering bitexactness between target and source branch split-rendering-pytest-on-merge-request: extends: - - .test-job-linux + - .test-job-linux-needs-testv-dir - .rules-merge-request needs: ["build-codec-linux-make"] # TODO: set reasonable timeout, will most likely take less @@ -711,7 +730,8 @@ split-rendering-pytest-on-merge-request: - if [ $ref_using_main == 0 ]; then git restore lib_com/options.h; fi # Revert changes back before checking out another branch to avoid conflicts - if [ $ref_using_main == 0 ]; then git checkout $source_branch_commit_sha; fi - exit_code=0 - - 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 || exit_code=$? + - 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 @@ -725,7 +745,7 @@ split-rendering-pytest-on-merge-request: - if [ $ref_using_main == 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 || exit_code=$? + - 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 @@ -748,7 +768,7 @@ split-rendering-pytest-on-merge-request: # compare bit exactness between target and source branch ivas-pytest-on-merge-request: extends: - - .test-job-linux + - .test-job-linux-needs-testv-dir - .rules-merge-request stage: compare needs: ["build-codec-linux-cmake", "codec-smoke-test"] @@ -780,7 +800,8 @@ ivas-pytest-on-merge-request: ### run pytest - exit_code=0 - - python3 -m pytest $TESTS_DIR_CODEC_BE_ON_MR -v --html=report.html --self-contained-html --junit-xml=report-junit.xml || exit_code=$? + - testcase_timeout=60 + - python3 -m pytest $TESTS_DIR_CODEC_BE_ON_MR -v --html=report.html --self-contained-html --junit-xml=report-junit.xml --testcase_timeout=$testcase_timeout || exit_code=$? - zero_errors=$(cat report-junit.xml | grep -c 'errors="0"') || true - *merge-request-comparison-check @@ -804,7 +825,7 @@ ivas-pytest-on-merge-request: # Check interop IVAS_cod_test -> IVAS_dec_ref ivas-interop-on-merge-request: extends: - - .test-job-linux + - .test-job-linux-needs-testv-dir - .rules-merge-request stage: test needs: ["build-codec-linux-cmake"] @@ -880,14 +901,15 @@ evs-pytest-on-merge-request: ### prepare pytest # create references - - python3 -m pytest $TESTS_DIR_CODEC_BE_ON_MR/test_param_file.py -v --update_ref 1 -m create_ref --param_file scripts/config/self_test_evs.prm + - testcase_timeout=60 + - python3 -m pytest $TESTS_DIR_CODEC_BE_ON_MR/test_param_file.py -v --update_ref 1 -m create_ref --param_file scripts/config/self_test_evs.prm --testcase_timeout=$testcase_timeout ### Run test using branch scripts and input - if [ $ref_using_main == 1 ]; then git checkout $source_branch_commit_sha; fi ### run pytest for EVS cases - exit_code=0 - - python3 -m pytest $TESTS_DIR_CODEC_BE_ON_MR/test_param_file.py -v --param_file scripts/config/self_test_evs.prm --html=report.html --self-contained-html --junit-xml=report-junit-evs.xml || exit_code=$? + - python3 -m pytest $TESTS_DIR_CODEC_BE_ON_MR/test_param_file.py -v --param_file scripts/config/self_test_evs.prm --html=report.html --self-contained-html --junit-xml=report-junit-evs.xml --testcase_timeout=$testcase_timeout || exit_code=$? - zero_errors=$(cat report-junit-evs.xml | grep -c 'errors="0"') || true - *merge-request-comparison-check @@ -989,11 +1011,11 @@ check-first-frame-is-sid: # run all modes and cut bitstream to start with an SID. Use stereo output to limit runtime, test is only about decoding - ism_md_cmd="--ism_metadata_files /usr/local/ltv/ltvISM1.csv /usr/local/ltv/ltvISM2.csv /usr/local/ltv/ltvISM3.csv /usr/local/ltv/ltvISM4.csv" - modes=$(scripts/runIvasCodec.py -l | grep dtx | grep -vE "FOA|HOA" ) - - scripts/runIvasCodec.py -z console -p scripts/config/ci_linux_sidstart_test.json -m $modes -s --bs_length 200 -U 0:20 --oc stereo $ism_md_cmd || exit_code_no_sba=$? + - scripts/runIvasCodec.py -z console -p scripts/config/ci_linux_sidstart_test.json -m $modes -s --bs_length 200 -U 0:20 --oc stereo $ism_md_cmd --timeout 10 || exit_code_no_sba=$? - modes=$(scripts/runIvasCodec.py -l | grep dtx | grep -E "HOA") - - scripts/runIvasCodec.py -z console -p scripts/config/ci_linux_sidstart_test.json -m $modes -s --bs_length 100 -U 70:80 --oc stereo || exit_code_hoa=$? + - scripts/runIvasCodec.py -z console -p scripts/config/ci_linux_sidstart_test.json -m $modes -s --bs_length 100 -U 70:80 --oc stereo --timeout 10 || exit_code_hoa=$? - modes=$(scripts/runIvasCodec.py -l | grep dtx | grep "FOA") - - scripts/runIvasCodec.py -z console -p scripts/config/ci_linux_sidstart_test.json -m $modes -s --bs_length 100 -U 75:110 --oc stereo || exit_code_foa=$? + - scripts/runIvasCodec.py -z console -p scripts/config/ci_linux_sidstart_test.json -m $modes -s --bs_length 100 -U 75:110 --oc stereo timeout 10 || exit_code_foa=$? - if [ $exit_code_no_sba -ne 0 ] || [ $exit_code_hoa -ne 0 ] || [ $exit_code_hoa -ne 0 ]; then exit 1; fi artifacts: @@ -1036,7 +1058,7 @@ be-2-evs-windows: - *print-common-info-windows - $winoutdata = $null - - MSBuild.exe .\Workspace_msvc\Workspace_msvc.sln /property:Configuration=Release | tee -variable winoutdata + - MSBuild.exe -maxcpucount .\Workspace_msvc\Workspace_msvc.sln /property:Configuration=Release | tee -variable winoutdata - $winoutdata | Out-File $BUILD_OUTPUT -Encoding Utf8 # copy over to never change the testvector dir @@ -1076,7 +1098,7 @@ be-2-evs-linux: codec-comparison-on-main-push: extends: - - .test-job-linux + - .test-job-linux-needs-testv-dir - .rules-main-push stage: compare needs: ["build-codec-linux-cmake"] @@ -1129,15 +1151,16 @@ codec-comparison-on-main-push: - mv IVAS_cod_test IVAS_cod - mv IVAS_dec_test IVAS_dec # create references - - python3 -m pytest $TESTS_DIR_CODEC_BE_ON_MR -v --update_ref 1 -m create_ref - - python3 -m pytest $TESTS_DIR_CODEC_BE_ON_MR -v --update_ref 1 -m create_ref_part2 + - testcase_timeout=60 + - python3 -m pytest $TESTS_DIR_CODEC_BE_ON_MR -v --update_ref 1 -m create_ref --testcase_timeout=$testcase_timeout + - python3 -m pytest $TESTS_DIR_CODEC_BE_ON_MR -v --update_ref 1 -m create_ref_part2 --testcase_timeout=$testcase_timeout ### re-checkout the latest commit here, if ref_using_main is set - if [ $ref_using_main -eq 1 ]; then git checkout $latest_commit;fi ### run pytest - exit_code=0 - - python3 -m pytest $TESTS_DIR_CODEC_BE_ON_MR -v --html=report.html --self-contained-html --junit-xml=report-junit.xml || exit_code=$? + - python3 -m pytest $TESTS_DIR_CODEC_BE_ON_MR -v --html=report.html --self-contained-html --junit-xml=report-junit.xml --testcase_timeout=$testcase_timeout || exit_code=$? - if [ $exit_code -eq 1 ] && [ $non_be_flag == 0 ]; then echo "pytest run had failures and non-BE flag not present"; exit $EXIT_CODE_FAIL; fi - zero_errors=$(cat report-junit.xml | grep -c 'errors="0"') || true - if [ $exit_code -eq 1 ] && [ $zero_errors == 1 ]; then echo "pytest run had failures, but no errors and non-BE flag present"; exit $EXIT_CODE_NON_BE; fi @@ -1172,7 +1195,7 @@ test-be-to-release: script: - echo "$CI_COMMIT_BRANCH" - - MSBuild.exe .\Workspace_msvc\Workspace_msvc.sln /property:Configuration=Debug /p:Platform=win32 /m | tee -variable winoutdata + - MSBuild.exe -maxcpucount .\Workspace_msvc\Workspace_msvc.sln /property:Configuration=Debug /p:Platform=win32 /m | tee -variable winoutdata # path to release candidate refs defined in config.toml @@ -1231,11 +1254,12 @@ test-long-self-test: # create references - exit_code_ref=0 - - python3 -m pytest $TESTS_DIR_CODEC_BE_ON_MR/test_param_file.py -v --update_ref 1 -m create_ref --param_file scripts/config/self_test_ltv.prm || exit_code_ref=$? + - testcase_timeout=300 + - python3 -m pytest $TESTS_DIR_CODEC_BE_ON_MR/test_param_file.py -v --update_ref 1 -m create_ref --param_file scripts/config/self_test_ltv.prm --testcase_timeout=$testcase_timeout || exit_code_ref=$? ### run pytest self-test using long test vectors - exit_code=0 - - python3 -m pytest $TESTS_DIR_CODEC_BE_ON_MR/test_param_file.py -v --param_file scripts/config/self_test_ltv.prm --html=report-ltv.html --self-contained-html --junit-xml=report-junit-ltv.xml || exit_code=$? + - python3 -m pytest $TESTS_DIR_CODEC_BE_ON_MR/test_param_file.py -v --param_file scripts/config/self_test_ltv.prm --html=report-ltv.html --self-contained-html --junit-xml=report-junit-ltv.xml --testcase_timeout=$testcase_timeout || exit_code=$? - zero_errors=$(cat report-junit-ltv.xml | grep -c 'errors="0"') || true - if [ $zero_errors != 1 ]; then echo "Run errors encountered!"; exit $EXIT_CODE_FAIL; fi diff --git a/apps/decoder.c b/apps/decoder.c index 1e41f9054f5ee4a62f69f6518267e769535dac73..91450bd5c04b05c2c1fc10f40e4450f7814387f8 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -199,6 +199,9 @@ int main( #ifdef NONBE_FIX_BINARY_BINAURAL_READING IVAS_DEC_HRTF_HANDLE *hHrtfTD = NULL; IVAS_DEC_HRTF_CREND_HANDLE *hSetOfHRTF = NULL; +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + IVAS_DEC_HRTF_STATISTICS_HANDLE *hHrtfStatistics = NULL; +#endif #endif #ifdef DEBUGGING int32_t noClipping; @@ -742,6 +745,7 @@ int main( } #endif +#ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES #ifdef FIX_638_ENERGIE_IAC_ROM_TABLES #ifdef NONBE_FIX_BINARY_BINAURAL_READING if ( ( *hHrtfTD != NULL ) && ( error = load_reverb_binary( *hHrtfTD, hrtfReader ) ) != IVAS_ERR_OK ) @@ -760,6 +764,7 @@ int main( } #endif #endif +#endif #ifndef NONBE_FIX_BINARY_BINAURAL_READING IVAS_DEC_HRTF_CREND_HANDLE hSetOfHRTF = NULL; @@ -847,6 +852,36 @@ int main( fprintf( stderr, "\nError in loading HRTF binary file %s for parametric binauralizer \n\n", arg.hrtfFileName ); goto cleanup; } +#endif + +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES +#ifdef FIX_638_ENERGIE_IAC_ROM_TABLES +#ifdef NONBE_FIX_BINARY_BINAURAL_READING + if ( ( error = IVAS_DEC_GetHrtfStatisticsHandle( hIvasDec, &hHrtfStatistics ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nIVAS_DEC_GetHrtfHandle failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; + } + if ( ( error = load_reverb_binary( *hHrtfStatistics, arg.output_Fs, hrtfReader ) ) != IVAS_ERR_OK ) + { + if ( error != IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA ) + { + fprintf( stderr, "\nError in loading HRTF binary file %s \n\n", arg.hrtfFileName ); + goto cleanup; + } + else + { + destroy_hrtf_statistics( hHrtfStatistics ); + } + } +#else + if ( ( hHrtfTD != NULL ) && ( error = load_reverb_binary( hHrtfTD, hrtfReader ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError in loading HRTF binary file %s \n\n", arg.hrtfFileName ); + goto cleanup; + } +#endif +#endif #endif } @@ -939,6 +974,11 @@ cleanup: #endif IVAS_DEC_GetHrtfCRendHandle( hIvasDec, &hSetOfHRTF ); destroy_SetOfHRTF( hSetOfHRTF ); + +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + IVAS_DEC_GetHrtfStatisticsHandle( hIvasDec, &hHrtfStatistics ); + destroy_hrtf_statistics( hHrtfStatistics ); +#endif } IVAS_DEC_Close( &hIvasDec ); @@ -1589,7 +1629,6 @@ static bool parseCmdlIVAS_dec( * Mandatory input arguments *-----------------------------------------------------------------*/ -#ifdef FIX_956_DECODER_COMMAND_LINE_FIX if ( i < argc - 4 ) { for ( i = 1; i < argc; i++ ) @@ -1607,9 +1646,6 @@ static bool parseCmdlIVAS_dec( return false; } else if ( i < argc - 3 ) -#else - if ( i < argc - 3 ) -#endif { arg->outputConfig = cmdline2config( argv[i] ); if ( arg->outputConfig == IVAS_AUDIO_CONFIG_LS_CUSTOM ) diff --git a/apps/renderer.c b/apps/renderer.c index e230082ca8ffb5fbaca1d4363146b735cf38aca0..cd80a05c5c549f6a52c94d7a23d5f01f8586df54 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -748,6 +748,9 @@ int main( IVAS_DEC_HRTF_FASTCONV_HANDLE *hHrtfFastConv = NULL; IVAS_DEC_HRTF_PARAMBIN_HANDLE *hHrtfParambin = NULL; IVAS_DEC_HRTF_HANDLE *hHrtfTD = NULL; +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + IVAS_DEC_HRTF_STATISTICS_HANDLE *hHrtfStatistics = NULL; +#endif #endif IsmPositionProvider *positionProvider; LfeRoutingConfig *lfeRoutingConfigs[RENDERER_MAX_MC_INPUTS]; @@ -1053,6 +1056,7 @@ int main( } } +#ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES #ifdef FIX_638_ENERGIE_IAC_ROM_TABLES if ( ( hHrtfTD != NULL ) && ( error = load_reverb_binary( *hHrtfTD, hrtfFileReader ) ) != IVAS_ERR_OK ) { @@ -1062,6 +1066,7 @@ int main( goto cleanup; } } +#endif #endif if ( ( error = IVAS_REND_GetHrtfCRendHandle( hIvasRend, &hSetOfHRTF ) ) != IVAS_ERR_OK ) @@ -1120,6 +1125,28 @@ int main( destroy_parambin_hrtf( hHrtfParambin ); } } + +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES +#ifdef FIX_638_ENERGIE_IAC_ROM_TABLES + if ( ( error = IVAS_REND_GetHrtfStatisticsHandle( hIvasRend, &hHrtfStatistics ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nIVAS_REND_GetHrtfStatisticsHandle failed\n\n" ); + goto cleanup; + } + if ( ( error = load_reverb_binary( *hHrtfStatistics, args.sampleRate, hrtfFileReader ) ) != IVAS_ERR_OK ) + { + if ( error != IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA ) + { + fprintf( stderr, "\nError in loading HRTF binary file %s \n\n", args.customHrtfFilePath ); + goto cleanup; + } + else + { + destroy_hrtf_statistics( hHrtfStatistics ); + } + } +#endif +#endif } hrtfFileReader_close( &hrtfFileReader ); @@ -2241,6 +2268,9 @@ cleanup: #ifdef NONBE_FIX_BINARY_BINAURAL_READING destroy_td_hrtf( hHrtfTD ); destroy_SetOfHRTF( hSetOfHRTF ); +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + destroy_hrtf_statistics( hHrtfStatistics ); +#endif #endif IVAS_REND_Close( &hIvasRend ); IsmPositionProvider_close( positionProvider ); diff --git a/ci/run_scheduled_sanitizer_test.py b/ci/run_scheduled_sanitizer_test.py index 5007914b957d3e7a22cacb992ee370ea57c7a91d..b3fc88acc4695679540385ed2e1d92984b0b4c55 100755 --- a/ci/run_scheduled_sanitizer_test.py +++ b/ci/run_scheduled_sanitizer_test.py @@ -55,6 +55,7 @@ N_FRAMES_DLY_PROFILE = 7500 GENPATT_CMD = f"gen-patt -tailstat -fer -g192 -gamma 0 -rate 0.15 -tol 0.001 -reset -n {N_FRAMES_DLY_PROFILE} {EP_FILE}" MC_MODES = ["5_1", "5_1_2", "5_1_4", "7_1", "7_1_4"] AMBISONICS_MODES = ["HOA3", "HOA2", "FOA", "PlanarHOA3", "PlanarHOA2", "PlanarFOA"] +TIMEOUT = 60 * 15 # timeout of 15 minutes per en/decoding to safeguard against endless loops CONSOLE_OUT_FILE = "output_san.txt" @@ -148,6 +149,8 @@ def run_check(in_format: str, out_formats: list, tests: list, run_fec: bool = Tr *md_file_command, "--usan_supp_file", USAN_SUPP_FILE, + "--timeout", + str(TIMEOUT), ] print( diff --git a/ci/smoke_test.sh b/ci/smoke_test.sh index a2f3ffb82b711d65af31d91f14843c78b88d7a80..d36ce41d637e9beb6873d58063389c69022239f6 100755 --- a/ci/smoke_test.sh +++ b/ci/smoke_test.sh @@ -56,6 +56,7 @@ dly_profile=./scripts/dly_error_profiles/dly_error_profile_10.dat ism_md_cmd="--ism_metadata_files /usr/local/ltv/ltvISM1.csv /usr/local/ltv/ltvISM2.csv /usr/local/ltv/ltvISM3.csv /usr/local/ltv/ltvISM4.csv" duration_arg="-U 1:2" verbosity_cmd="-z console" +timeout_cmd="--timeout 20" ep_file="ci/complexity_measurements/ep_10pct_fer.g192" if [ $BUILD -eq 1 ];then @@ -84,21 +85,21 @@ echo "\n======================= 0. preparing combined format test inputs ======= ism_modes=$(./scripts/runIvasCodec.py -l | grep ^ISM) non_ism_modes=$(./scripts/runIvasCodec.py -l | grep -v ^ISM) echo "\n======================= 1. non-ism modes no FEC =======================\n\n" -./scripts/runIvasCodec.py $verbosity_cmd -m $non_ism_modes -p $cfg $duration_arg | tee smoke_test_output.txt +./scripts/runIvasCodec.py $verbosity_cmd -m $non_ism_modes -p $cfg $duration_arg $timeout_cmd | tee smoke_test_output.txt echo "\n======================= 2. ism modes no FEC =======================\n\n" -./scripts/runIvasCodec.py $verbosity_cmd -m $ism_modes -p $cfg $duration_arg $ism_md_cmd | tee smoke_test_output.txt +./scripts/runIvasCodec.py $verbosity_cmd -m $ism_modes -p $cfg $duration_arg $ism_md_cmd $timeout_cmd | tee smoke_test_output.txt # run the decoding again, but with 15% frame loss echo "\n======================= 3. all modes with FEC =======================\n\n" -./scripts/runIvasCodec.py $verbosity_cmd -p $cfg $duration_arg -f="$ep_file" --decoder_only | tee smoke_test_output_plc.txt +./scripts/runIvasCodec.py $verbosity_cmd -p $cfg $duration_arg -f="$ep_file" --decoder_only $timeout_cmd | tee smoke_test_output_plc.txt # run JBM modes - EXT is excluded as not supported yet # OMASA disabled for now modes_with_no_ext_out=$(./scripts/runIvasCodec.py -l | grep -v ^MASA | grep -v ^ISM | grep -v OMASA) modes_with_ext_out=$(./scripts/runIvasCodec.py -l | grep 'MASA\|ISM' | grep -v ^ISM+ | grep -v OMASA) echo "\n======================= 4. JBM, modes with no EXT =======================\n\n" -./scripts/runIvasCodec.py $verbosity_cmd -m $modes_with_no_ext_out -p $cfg $duration_arg --decoder_only --jbm_file $dly_profile | tee smoke_test_output_jbm_noEXT.txt +./scripts/runIvasCodec.py $verbosity_cmd -m $modes_with_no_ext_out -p $cfg $duration_arg --decoder_only --jbm_file $dly_profile $timeout_cmd | tee smoke_test_output_jbm_noEXT.txt echo "\n======================= 5. JBM, modes with EXT =======================\n\n" -./scripts/runIvasCodec.py $verbosity_cmd -m $modes_with_ext_out -p $cfg $duration_arg --decoder_only --jbm_file $dly_profile --oc BINAURAL BINAURAL_ROOM_IR mono stereo FOA HOA3 5_1 7_1_4 | tee -a smoke_test_output_jbm_noEXT.txt +./scripts/runIvasCodec.py $verbosity_cmd -m $modes_with_ext_out -p $cfg $duration_arg --decoder_only --jbm_file $dly_profile --oc BINAURAL BINAURAL_ROOM_IR mono stereo FOA HOA3 5_1 7_1_4 $timeout_cmd | tee -a smoke_test_output_jbm_noEXT.txt # run all modes with binaural output using external files modes_with_bin_out="FOA HOA2 HOA3 PlanarFOA PlanarHOA2 PlanarHOA3 MASA MC ISM1 ISM2 ISM3 ISM4" @@ -107,14 +108,14 @@ bin_out_modes="BINAURAL BINAURAL_ROOM_IR" echo "\n======================= 6. binaural out with HRTF files - WB =======================\n\n" wb_modes=$(./scripts/runIvasCodec.py -l -C $modes_with_bin_out | grep _wb_) hrtf_wb="../scripts/binauralRenderer_interface/binaural_renderers_hrtf_data/ivas_binaural_16kHz.bin" -./scripts/runIvasCodec.py $verbosity_cmd -p $cfg -m $wb_modes $duration_arg -D="-hrtf ${hrtf_wb}" --decoder_only --oc $bin_out_modes | tee -a smoke_test_output_hrtf.txt +./scripts/runIvasCodec.py $verbosity_cmd -p $cfg -m $wb_modes $duration_arg -D="-hrtf ${hrtf_wb}" --decoder_only --oc $bin_out_modes $timeout_cmd | tee -a smoke_test_output_hrtf.txt echo "\n======================= 7. binaural out with HRTF files - SWB =======================\n\n" swb_modes=$(./scripts/runIvasCodec.py -l -C $modes_with_bin_out | grep _swb_) hrtf_swb="../scripts/binauralRenderer_interface/binaural_renderers_hrtf_data/ivas_binaural_32kHz.bin" -./scripts/runIvasCodec.py $verbosity_cmd -p $cfg -m $swb_modes $duration_arg -D="-hrtf ${hrtf_swb}" --decoder_only --oc $bin_out_modes | tee -a smoke_test_output_hrtf.txt +./scripts/runIvasCodec.py $verbosity_cmd -p $cfg -m $swb_modes $duration_arg -D="-hrtf ${hrtf_swb}" --decoder_only --oc $bin_out_modes $timeout_cmd | tee -a smoke_test_output_hrtf.txt echo "\n======================= 8. binaural out with HRTF files - FB =======================\n\n" fb_modes=$(./scripts/runIvasCodec.py -l -C $modes_with_bin_out | grep _fb_) hrtf_fb="../scripts/binauralRenderer_interface/binaural_renderers_hrtf_data/ivas_binaural_48kHz.bin" -./scripts/runIvasCodec.py $verbosity_cmd -p $cfg -m $fb_modes $duration_arg -D="-hrtf ${hrtf_fb}" --decoder_only --oc $bin_out_modes | tee -a smoke_test_output_hrtf.txt +./scripts/runIvasCodec.py $verbosity_cmd -p $cfg -m $fb_modes $duration_arg -D="-hrtf ${hrtf_fb}" --decoder_only --oc $bin_out_modes $timeout_cmd | tee -a smoke_test_output_hrtf.txt diff --git a/lib_com/common_api_types.h b/lib_com/common_api_types.h index 132e829ed3712b3cb2105beaaac5e8483e84604a..dcedfd5a71977a8198b2a2100db3e162672d836f 100644 --- a/lib_com/common_api_types.h +++ b/lib_com/common_api_types.h @@ -163,6 +163,9 @@ typedef struct TDREND_HRFILT_FiltSet_struct *IVAS_DEC_HRTF_HANDLE; typedef struct ivas_hrtfs_crend_structure *IVAS_DEC_HRTF_CREND_HANDLE; typedef struct ivas_hrtfs_fastconv_struct *IVAS_DEC_HRTF_FASTCONV_HANDLE; typedef struct ivas_hrtfs_parambin_struct *IVAS_DEC_HRTF_PARAMBIN_HANDLE; +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES +typedef struct ivas_hrtfs_statistics_struct *IVAS_DEC_HRTF_STATISTICS_HANDLE; +#endif typedef struct cldfb_filter_bank_struct *IVAS_CLDFB_FILTER_BANK_HANDLE; typedef struct ivas_LS_setup_custom *IVAS_LSSETUP_CUSTOM_HANDLE; diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index af3fbb8932bb904455e26504b079a7415eaed9d7..38e9518e61e9a26a889aaf4f65b991ad01f847ea 100755 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -328,9 +328,7 @@ typedef enum #define ISM_Q_STEP 2.5f #define ISM_Q_STEP_BORDER 5.0f -#ifdef NONBE_FIX_944_FEC_OMASA_1SEP_OBJ_MASA #define ISM_FEC_MAX 10 -#endif #define ISM_RADIUS_NBITS 6 #define ISM_RADIUS_MIN 0.0f diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 2eacf811b0d1d9556d79479d47f5ad84ec60d2d7..b27a002513cf656605b7148f1397b68b4b7c8bc3 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -5469,7 +5469,11 @@ void ivas_mono_dmx_renderer_close( MONO_DOWNMIX_RENDERER_HANDLE *hMonoDmxRenderer /* i/ i/o: Mono downmix structure */ ); +#ifdef NONBE_FIX_967_ISM_MONO_DMX +void ivas_ism_mono_dmx( +#else void ivas_mono_downmix_render_passive( +#endif Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ float *output_f[], /* i/o: synthesized core-coder transport channels/mono output */ const int16_t output_frame /* i : output frame length */ diff --git a/lib_com/options.h b/lib_com/options.h index 5aa3ec18d8999a901e5cf0e81920c308361dd033..a47754e10376fdd01b036d31e8728430d9d0d6c4 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -150,17 +150,16 @@ /*#define FIX_I4_OL_PITCH*/ /* fix open-loop pitch used for EVS core switching */ /*#define SPLIT_REND_WITH_HEAD_ROT */ /* Dlb,FhG: Split Rendering contributions 21 and 35 */ -#define FIX_954_OTR_REF_VEC /* FhG: Fix forward vector direction for OTR REF VEC mode */ -#define FIX_638_ENERGIE_IAC_ROM_TABLES /* Orange : Missing left/right and coherence late reverb tables in binary format*/ -#define FIX_WARNING_RENDER_CONFIG /* Orange: fix warning on windows build */ +#define FIX_638_ENERGIE_IAC_ROM_TABLES /* Orange: Missing left/right and coherence late reverb tables in binary format*/ #define FIX_WARNING_SPLIT_RENDER /* Orange: fix warning on windows build vscode */ #define FIX_INV_DIFFUSE_WEIGHT /* Orange : Fix error in energy compensation in late binaural reverb*/ #define FIX_20_MS_FRAME_LEN_TABLES_CONVERTER /* Orange : generate_tables_converter tools can generate rom for 5 and 20 ms frame length */ -#define FIX_958_667_DISABLE_INITIAL_PLC_SUPPRESSION /* Ericsson: Fix related to issue 667 in IVAS BASOP. Handling of initial lost frame in IVAS causes non-BE on EVS BASOP 26.444 */ -#define FIX_957_REMOVE_PANNING_DEAD_CODE /* VA: Remove obsolete non-diegetic panning related code. */ -#define FIX_956_DECODER_COMMAND_LINE_FIX /* VA: Output correct error message when the decoder command-line has too many mandatory arguments. */ #define FIX_955_FASTCONV_REND_IN_ISM /* VA: put FastConv rendering call under DEBUGGING */ +#define FIX_969_USAN_IGF_ARITH /* FhG: issue 969: fix USAN error in igf_sce_dec; same issue as #962 */ +#define FIX_959_MASA_LINEAR_REND /* VA: issue 959: remove unused calling of ivas_sba_linear_renderer() in MASA rendering */ +#define FIX_963_USAN_ERROR /* Eri: Issue 963: USAN error in Stereo CNG, division by zero */ +#define FIX_971_LOG2_IDX_GAIN_0 /* VA: prevent -Inf due to log2(ratio==0) */ /* #################### End BE switches ################################## */ @@ -170,14 +169,19 @@ #define NONBE_FIX_BINARY_BINAURAL_READING /* Orange: Add support for reading binaural binary file */ #define NONBE_FIX_AVG_IAC_CLDFB_REVERB /* Orange: Add computation avg energy and iac tables for rom and binaural binary file */ -#define NONBE_FIX_856_TCX_LTP_SYNTH_FILTER /* FhG: issue 856: correct filtering length for tcx-ltp synth filtering*/ -#define NONBE_FIX_944_FEC_OMASA_1SEP_OBJ_MASA /* Nokia: issue 944: fix FEC error in OMASA */ +#define NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES /* Philips: Use pre-computed HRTF average L/R energies and IAC in all renderers */ #define NONBE_FIX_935_EARLY_REFLECTIONS_WRONG_ORDER /* Qualcomm: issue 953: fix order or ER channels in LC mode*/ -#define NONBE_FIX_949_MC_5MS_FRAMING /* Dlb: issue 949: fix for issue 949, distorted output in MC mode with 5ms framing*/ +#define NONBE_FIX_935_SBA_REVERB /* FhG: issue 935: fix MSAN error for SBA related to BINAURAL_ROOM_REVERB */ #define NONBE_FIX_952_MC_PARAMUPMIX_5MS /* Dlb : issue 952 : Differences between 5ms and 20ms rendering for ParamUpmix*/ +#define NONBE_FIX_967_ISM_MONO_DMX /* FhG: issue 967: accumulating energies in ISM mono DMX */ #define NONBE_FIX_968_ISM_BRIR_WITH_HEADROTATION_5MS_FIX /* FhG : issue #968: differences between 5ms and 20ms rendering for discrete ISM with BRIR and head rotation*/ #define NONBE_FIX_977_OSBA_GAIN_MISMATCH /* Dlb : issue 977 : Output gain mismatch for different bit rates in OSBA */ +#define BE_FIX_567_DOUBLE_STEREO_DMX /* NTT: Fix formal issues */ +#define NONBE_FIX_567_DOUBLE_STEREO_DMX /* Orange: Double-precision replaced by single-precision */ +#define NONBE_FIX_947_STEREO_DMX_EVS_POC /* Orange: Fix clicks on POC */ +#define NONBE_FIX_947_STEREO_DMX_EVS_PHA /* Orange: Fix issues on PHA */ + /* ##################### End NON-BE switches ########################### */ /* ################## End DEVELOPMENT switches ######################### */ diff --git a/lib_com/prot.h b/lib_com/prot.h index 527d80318794ee6493b2b7451f8e80b2f46669f4..5b31e16f31ccb87b97ad5436483598615f0bf6c8 100644 --- a/lib_com/prot.h +++ b/lib_com/prot.h @@ -132,6 +132,13 @@ float inv_sqrt( const float x /* i : input value */ ); +#ifdef NONBE_FIX_567_DOUBLE_STEREO_DMX +/*! r: inverse square root of input value (float) */ +float inv_sqrtf( + const float x /* i : input value */ +); +#endif + /*! r: output random value */ int16_t own_random( int16_t *seed /* i/o: random seed */ diff --git a/lib_com/tcx_ltp.c b/lib_com/tcx_ltp.c index 502328348df6501804da45227e4e2949f9259f6a..1711ad24b35e3219360d3ef0cce3e602aeb5d3ce 100755 --- a/lib_com/tcx_ltp.c +++ b/lib_com/tcx_ltp.c @@ -740,11 +740,7 @@ static void tcx_ltp_synth_filter_11_unequal_pitch( gain = prev_gain; gain_step = -prev_gain / length; -#ifdef NONBE_FIX_856_TCX_LTP_SYNTH_FILTER for ( j = 0; j < length; j++ ) -#else - for ( j = 0; j < length + L; j++ ) -#endif { s = 0; s2 = 0; @@ -765,14 +761,9 @@ static void tcx_ltp_synth_filter_11_unequal_pitch( gain += gain_step; } -#ifdef NONBE_FIX_856_TCX_LTP_SYNTH_FILTER mvr2r( out - L, temp_buf, length + L ); mvr2r( in + length, temp_buf + length + L, L ); temp_ptr = &temp_buf[0] + L; -#else - mvr2r( out - MAX_TCX_LTP_FILTER_LEN, temp_buf, MAX_TRANSITION_LEN + 2 * MAX_TCX_LTP_FILTER_LEN ); - temp_ptr = &temp_buf[0] + MAX_TCX_LTP_FILTER_LEN; -#endif m0 = temp_ptr; m1 = temp_ptr - 1; diff --git a/lib_com/tools.c b/lib_com/tools.c index ecd2fdbfa4335d846d5eba766498779445adb374..47416257fe412da08ea9d0e0e7a531395d09071f 100644 --- a/lib_com/tools.c +++ b/lib_com/tools.c @@ -768,6 +768,21 @@ float inv_sqrt( return (float) ( 1.0 / sqrt( x ) ); } +#ifdef NONBE_FIX_567_DOUBLE_STEREO_DMX +/*---------------------------------------------------------------------* + * inv_sqrtf() + * + * Find the inverse square root of the input value (float) + *---------------------------------------------------------------------*/ + +/*! r: inverse square root of input value (float) */ +float inv_sqrtf( + const float x /* i : input value */ +) +{ + return ( 1.0f / sqrtf( x ) ); +} +#endif /*-------------------------------------------------------------------* * conv() diff --git a/lib_dec/igf_scf_dec.c b/lib_dec/igf_scf_dec.c old mode 100644 new mode 100755 index f152f637a0d83b6e78684766f44a215874793eb0..a8162c64431a70712496a65fc0ff6b5abf36968a --- a/lib_dec/igf_scf_dec.c +++ b/lib_dec/igf_scf_dec.c @@ -211,7 +211,12 @@ static void decode_sfe_vector( | c b | e --> t */ +#ifdef FIX_969_USAN_IGF_ARITH + int16_t pred; + uint16_t pred_tmp; +#else uint16_t pred; +#endif int16_t f, ctx, ctx_f, ctx_t; for ( f = 0; f < length; f++ ) @@ -221,7 +226,12 @@ static void decode_sfe_vector( if ( f == 0 ) { /* decode one of the IGF_SYMBOLS_IN_TABLE == 27 alphabet symbols using the new raw AC function */ +#ifdef FIX_969_USAN_IGF_ARITH + ari_decode_14bits_s27_ext( st, &pred_tmp, &hPrivateData->acState, hPrivateData->cf_se00 ); + pred = (int16_t) pred_tmp; +#else ari_decode_14bits_s27_ext( st, &pred, &hPrivateData->acState, hPrivateData->cf_se00 ); +#endif x[f] = pred << 2; x[f] += arith_decode_bits( &hPrivateData->acState, st, 2 ); /* LSBs as 2 bit raw */ } diff --git a/lib_dec/ivas_binRenderer_internal.c b/lib_dec/ivas_binRenderer_internal.c index ce06e369306bc19989c5dfba83b876bb8d6000ca..2494704395c0a63c082a0a3a75d734713230d131 100644 --- a/lib_dec/ivas_binRenderer_internal.c +++ b/lib_dec/ivas_binRenderer_internal.c @@ -1231,7 +1231,11 @@ ivas_error ivas_binRenderer_open( /* Allocate memories needed for reverb module */ if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV && st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) { +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + if ( ( error = ivas_binaural_reverb_init( &( hBinRenderer->hReverb ), st_ivas->hHrtfStatistics, hBinRenderer->conv_band, hBinRenderer->timeSlots, &( st_ivas->hRenderConfig->roomAcoustics ), st_ivas->hDecoderConfig->output_Fs, st_ivas->hHrtfFastConv->fastconvReverberationTimes, st_ivas->hHrtfFastConv->fastconvReverberationEneCorrections ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_binaural_reverb_open_fastconv( &( hBinRenderer->hReverb ), hBinRenderer->conv_band, hBinRenderer->timeSlots, &( st_ivas->hRenderConfig->roomAcoustics ), st_ivas->hIntSetup.output_config, st_ivas->hDecoderConfig->output_Fs, st_ivas->hHrtfFastConv ) ) != IVAS_ERR_OK ) +#endif { return error; } diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index d24e043648b8b6e8d374c0f8c86e3fbddc36fdef..24ba618a3c67c988195c0ed5bae192ef2f406f65 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -1066,6 +1066,13 @@ ivas_error ivas_init_decoder_front( { return error; } + +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + if ( ( error = ivas_HRTF_statistics_binary_open( &st_ivas->hHrtfStatistics ) ) != IVAS_ERR_OK ) + { + return error; + } +#endif } /*-------------------------------------------------------------------* @@ -1219,6 +1226,20 @@ ivas_error ivas_init_decoder( } } +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + /*--------------------------------------------------------------------* + * Allocate and initialize HRTF Statistics handle + *--------------------------------------------------------------------*/ + + if ( st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) + { + if ( ( error = ivas_HRTF_statistics_init( &st_ivas->hHrtfStatistics, output_Fs ) ) != IVAS_ERR_OK ) + { + return error; + } + } +#endif + #ifdef SPLIT_REND_WITH_HEAD_ROT /*-----------------------------------------------------------------* * Initialize binuaral split rendering @@ -1972,7 +1993,11 @@ ivas_error ivas_init_decoder( if ( st_ivas->hIntSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) { +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + if ( ( error = ivas_reverb_open( &st_ivas->hReverb, st_ivas->hHrtfStatistics, st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_reverb_open( &st_ivas->hReverb, st_ivas->hDecoderConfig->output_config, NULL, st_ivas->hBinRendererTd->HrFiltSet_p->lr_energy_and_iac, st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -2011,11 +2036,21 @@ ivas_error ivas_init_decoder( } #ifdef SPLIT_REND_WITH_HEAD_ROT +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + 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->hHrtfStatistics, st_ivas->hDecoderConfig->output_Fs, 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, st_ivas->hSplitBinRend.splitrend.multiBinPoseData.num_poses ) ) != IVAS_ERR_OK ) +#endif +#else +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + 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->hHrtfStatistics, st_ivas->hDecoderConfig->output_Fs ) ) != 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 #endif { return error; @@ -2462,6 +2497,9 @@ void ivas_initialize_handles_dec( st_ivas->hSetOfHRTF = NULL; st_ivas->hHrtfFastConv = NULL; st_ivas->hHrtfParambin = NULL; +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + st_ivas->hHrtfStatistics = NULL; +#endif st_ivas->hoa_dec_mtx = NULL; st_ivas->hMasaIsmData = NULL; st_ivas->hSbaIsmData = NULL; @@ -2709,6 +2747,11 @@ void ivas_destroy_dec( /* Parametric binauralizer HRTF filters */ ivas_HRTF_parambin_binary_close( &st_ivas->hHrtfParambin ); +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + /* HRTF statistics */ + ivas_HRTF_statistics_close( &st_ivas->hHrtfStatistics ); +#endif + /* Config. Renderer */ ivas_render_config_close( &( st_ivas->hRenderConfig ) ); diff --git a/lib_dec/ivas_ism_dec.c b/lib_dec/ivas_ism_dec.c index 52349b9e69a431700970c46c550b8cfd7c5a58d7..b2bcf783dab14f96d7f6d0dbfb789aee93ee7410 100644 --- a/lib_dec/ivas_ism_dec.c +++ b/lib_dec/ivas_ism_dec.c @@ -201,7 +201,11 @@ static ivas_error ivas_ism_bitrate_switching_dec( } if ( st_ivas->hIntSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) { +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + if ( ( error = ivas_reverb_open( &st_ivas->hReverb, st_ivas->hHrtfStatistics, st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_reverb_open( &st_ivas->hReverb, st_ivas->hDecoderConfig->output_config, NULL, st_ivas->hBinRendererTd->HrFiltSet_p->lr_energy_and_iac, st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -230,9 +234,17 @@ static ivas_error ivas_ism_bitrate_switching_dec( /* Open Crend Binaural renderer */ #ifdef SPLIT_REND_WITH_HEAD_ROT +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + 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->hHrtfStatistics, st_ivas->hDecoderConfig->output_Fs, 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, st_ivas->hSplitBinRend.splitrend.multiBinPoseData.num_poses ) ) != IVAS_ERR_OK ) +#endif +#else +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + 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->hHrtfStatistics, st_ivas->hDecoderConfig->output_Fs ) ) != 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 #endif { return error; diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index b0199a301e7b65ba24afa794b63b9d065cdb4dcb..dc394dda02babf81328e08467c59823141d749fc 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -196,7 +196,11 @@ ivas_error ivas_jbm_dec_tc( if ( st_ivas->renderer_type == RENDERER_MONO_DOWNMIX ) { +#ifdef NONBE_FIX_967_ISM_MONO_DMX + ivas_ism_mono_dmx( st_ivas, p_output, output_frame ); +#else ivas_mono_downmix_render_passive( st_ivas, p_output, output_frame ); +#endif } else if ( st_ivas->ism_mode == ISM_MODE_PARAM && ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) ) { @@ -388,7 +392,11 @@ ivas_error ivas_jbm_dec_tc( if ( st_ivas->renderer_type == RENDERER_MONO_DOWNMIX ) { +#ifdef NONBE_FIX_967_ISM_MONO_DMX + ivas_ism_mono_dmx( st_ivas, p_output, output_frame ); +#else ivas_mono_downmix_render_passive( st_ivas, p_output, output_frame ); +#endif } else if ( output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) { @@ -512,7 +520,11 @@ ivas_error ivas_jbm_dec_tc( } else if ( st_ivas->renderer_type == RENDERER_MONO_DOWNMIX && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { +#ifdef NONBE_FIX_967_ISM_MONO_DMX + ivas_ism_mono_dmx( st_ivas, p_output, output_frame ); +#else ivas_mono_downmix_render_passive( st_ivas, p_output, output_frame ); +#endif /* add W */ for ( n = 0; n < nchan_out; n++ ) @@ -1030,13 +1042,6 @@ ivas_error ivas_jbm_dec_render( { ivas_dirac_dec_binaural_render( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, st_ivas->nchan_transport, p_output ); } -#ifndef FIX_957_REMOVE_PANNING_DEAD_CODE - else if ( st_ivas->renderer_type == RENDERER_NON_DIEGETIC_DOWNMIX ) - { - *nSamplesRendered = min( st_ivas->hTcBuffer->n_samples_available, nSamplesAskedLocal ); - ivas_apply_non_diegetic_panning( p_output, st_ivas->hDecoderConfig->non_diegetic_pan_gain, *nSamplesRendered ); - } -#endif else if ( st_ivas->renderer_type == RENDERER_PARAM_ISM || st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) { ivas_param_ism_dec_render( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output ); @@ -1133,6 +1138,7 @@ ivas_error ivas_jbm_dec_render( } else if ( st_ivas->ivas_format == MASA_FORMAT ) { +#ifndef FIX_959_MASA_LINEAR_REND if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_DEC ) { *nSamplesRendered = min( st_ivas->hTcBuffer->n_samples_available, nSamplesAskedLocal ); @@ -1147,6 +1153,9 @@ ivas_error ivas_jbm_dec_render( } } else if ( st_ivas->renderer_type == RENDERER_DIRAC ) +#else + if ( st_ivas->renderer_type == RENDERER_DIRAC ) +#endif { ivas_dirac_dec_render( st_ivas, nchan_remapped, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output ); } @@ -1274,12 +1283,10 @@ ivas_error ivas_jbm_dec_render( } else if ( st_ivas->ivas_format == MC_FORMAT ) { -#ifdef NONBE_FIX_949_MC_5MS_FRAMING for ( n = 0; n < st_ivas->hTcBuffer->nchan_buffer_full; n++ ) { p_tc[n] = &st_ivas->hTcBuffer->tc[n][st_ivas->hTcBuffer->n_samples_rendered]; } -#endif if ( st_ivas->mc_mode == MC_MODE_MCT ) { int16_t crendInPlaceRotation = FALSE; diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index 4be9304f4b735cdda34532e79647d45f4da519ea..db147b9e7f20ed1a8ac32d041f43b0e1d9398a21 100644 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -1273,9 +1273,17 @@ static ivas_error ivas_mc_dec_reconfig( 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 +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + 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->hHrtfStatistics, st_ivas->hDecoderConfig->output_Fs, 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, st_ivas->hSplitBinRend.splitrend.multiBinPoseData.num_poses ) ) != IVAS_ERR_OK ) +#endif +#else +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + 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->hHrtfStatistics, st_ivas->hDecoderConfig->output_Fs ) ) != 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 #endif { return error; diff --git a/lib_dec/ivas_mono_dmx_renderer.c b/lib_dec/ivas_mono_dmx_renderer.c index 0936209639d9388e7910919011740336be89bf28..1da119f0003496c9106c4e1d0668468e7a30b3c6 100644 --- a/lib_dec/ivas_mono_dmx_renderer.c +++ b/lib_dec/ivas_mono_dmx_renderer.c @@ -46,9 +46,11 @@ * Local constants *------------------------------------------------------------------------*/ -#define DOWNMIX_ALPHA 0.95f /* Smoothing coefficient */ -#define DOWNMIX_MAX_GAIN 4.0f /* Maximum allowed gain */ -#define MONO_DOWNMIX_RENDERER_MAX_INPUT_CHANS 4 +#define DOWNMIX_ALPHA 0.95f /* Smoothing coefficient */ +#define DOWNMIX_MAX_GAIN 4.0f /* Maximum allowed gain */ +#ifndef NONBE_FIX_967_ISM_MONO_DMX +#define MONO_DOWNMIX_RENDERER_MAX_INPUT_CHANS 4 // FhG esr: this seems to be obsolete; not related to issue 967 +#endif /*------------------------------------------------------------------------- @@ -99,12 +101,16 @@ void ivas_mono_dmx_renderer_close( /*------------------------------------------------------------------------- - * ivas_mono_downmix_render_passive() + * ivas_ism_mono_dmx() * * Downmix process *------------------------------------------------------------------------*/ +#ifdef NONBE_FIX_967_ISM_MONO_DMX +void ivas_ism_mono_dmx( +#else void ivas_mono_downmix_render_passive( +#endif Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ float *output_f[], /* i/o: synthesized core-coder transport channels/mono output */ const int16_t output_frame /* i : output frame length */ @@ -112,6 +118,9 @@ void ivas_mono_downmix_render_passive( { int16_t i, j, numInputChannels; float proto_signal[L_FRAME48k], eq; +#ifdef NONBE_FIX_967_ISM_MONO_DMX + float inputEnergy_local, protoEnergy_local; +#endif MONO_DOWNMIX_RENDERER_HANDLE hDownmix; numInputChannels = st_ivas->nSCE; @@ -134,6 +143,10 @@ void ivas_mono_downmix_render_passive( hDownmix = st_ivas->hMonoDmxRenderer; set_zero( proto_signal, output_frame ); +#ifdef NONBE_FIX_967_ISM_MONO_DMX + inputEnergy_local = 0; + protoEnergy_local = 0; +#endif /* Compute the Proto Signal */ for ( i = 0; i < numInputChannels; i++ ) @@ -141,6 +154,18 @@ void ivas_mono_downmix_render_passive( v_add( output_f[i], proto_signal, proto_signal, output_frame ); } +#ifdef NONBE_FIX_967_ISM_MONO_DMX + /* compute the input energy, proto energy */ + for ( i = 0; i < output_frame; i++ ) + { + protoEnergy_local += proto_signal[i] * proto_signal[i]; + + for ( j = 0; j < numInputChannels; j++ ) + { + inputEnergy_local += ( output_f[j][i] * output_f[j][i] ); + } + } +#else /* compute the input energy, proto energy after smoothing */ hDownmix->inputEnergy *= DOWNMIX_ALPHA; hDownmix->protoEnergy *= DOWNMIX_ALPHA; @@ -153,6 +178,13 @@ void ivas_mono_downmix_render_passive( hDownmix->inputEnergy += ( output_f[j][i] * output_f[j][i] ); } } +#endif +#ifdef NONBE_FIX_967_ISM_MONO_DMX + hDownmix->inputEnergy *= DOWNMIX_ALPHA; + hDownmix->protoEnergy *= DOWNMIX_ALPHA; + hDownmix->inputEnergy += ( 1.0f - DOWNMIX_ALPHA ) * inputEnergy_local; + hDownmix->protoEnergy += ( 1.0f - DOWNMIX_ALPHA ) * protoEnergy_local; +#endif /* compute the eq factor */ eq = min( DOWNMIX_MAX_GAIN, sqrtf( hDownmix->inputEnergy / ( EPSILON + hDownmix->protoEnergy ) ) ); diff --git a/lib_dec/ivas_output_config.c b/lib_dec/ivas_output_config.c index 34bfbb57fabc5a4ca651c8e11967e2245017e79d..f050edde6a23c7305cb199b3eec9b798d03999de 100644 --- a/lib_dec/ivas_output_config.c +++ b/lib_dec/ivas_output_config.c @@ -160,7 +160,11 @@ void ivas_renderer_select( { *internal_config = IVAS_AUDIO_CONFIG_HOA3; +#ifdef NONBE_FIX_935_SBA_REVERB + if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL +#else if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB +#endif #ifdef SPLIT_REND_WITH_HEAD_ROT || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM #endif @@ -371,7 +375,11 @@ void ivas_renderer_select( { *internal_config = IVAS_AUDIO_CONFIG_HOA3; } +#ifdef FIX_959_MASA_LINEAR_REND + *renderer_type = RENDERER_SBA_LINEAR_DEC; +#else st_ivas->renderer_type = RENDERER_SBA_LINEAR_DEC; +#endif } else if ( ( ivas_format == MASA_FORMAT && output_config == IVAS_AUDIO_CONFIG_MONO && st_ivas->nchan_transport == 1 ) || ( ivas_format == SBA_FORMAT && ( output_config == IVAS_AUDIO_CONFIG_STEREO || output_config == IVAS_AUDIO_CONFIG_MONO ) ) ) diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 6ddcb3777867f7fc1a17270712d482b6910a3e6a..82e95467fd661f74f788cc27f36545761d22989f 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -194,7 +194,11 @@ ivas_error ivas_sba_dec_reconfigure( } else { +#ifdef NONBE_FIX_935_SBA_REVERB + if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL +#else if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB +#endif #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 diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index a7e105b36c8d5bb9182521e95612fb5cec0b527c..9769c6e5694f6b1e3ad740d8d83f4488d7498076 100644 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -249,7 +249,13 @@ ivas_error ivas_spar_dec_open( nchan_to_allocate = 2 * BINAURAL_CHANNELS; } - if ( st_ivas->ivas_format == SBA_ISM_FORMAT && ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + if ( st_ivas->ivas_format == SBA_ISM_FORMAT && +#ifdef NONBE_FIX_935_SBA_REVERB + st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL && +#else + ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) && +#endif + st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { /* get correct granularity in case of binaural rendering of the discrete objects with the td obj renderer */ granularity = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ); diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 81427d9cfa4ca9ccd5bec73e6a148b7cbe60be4b..92fd8f2f914a9b75c2104f5ea72bb571d840b3f1 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -1110,6 +1110,9 @@ typedef struct Decoder_Struct HRTFS_CREND_HANDLE hSetOfHRTF; /* Set of HRTFs handle (CRend) */ HRTFS_FASTCONV_HANDLE hHrtfFastConv; /* FASTCONV HRTF tables for binaural rendering */ HRTFS_PARAMBIN_HANDLE hHrtfParambin; /* HRTF tables for parametric binauralizer */ +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + HRTFS_STATISTICS_HANDLE hHrtfStatistics; /* HRTF statistics handle */ +#endif LSSETUP_CUSTOM_HANDLE hLsSetupCustom; /* Custom LS configuration handle */ float *hoa_dec_mtx; /* Pointer to decoder matrix for SBA */ HEAD_TRACK_DATA_HANDLE hHeadTrackData; /* Head tracking data structure */ diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 5ed7a54eae39d84096efb9577303b1ccc5eaf6d1..405a7bf997d44bf04817922043c766ceff3ca287 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -216,9 +216,7 @@ ivas_error IVAS_DEC_Open( st_ivas->transport_config = IVAS_AUDIO_CONFIG_INVALID; st_ivas->intern_config = IVAS_AUDIO_CONFIG_INVALID; st_ivas->writeFECoffset = 0; -#ifdef FIX_958_667_DISABLE_INITIAL_PLC_SUPPRESSION hIvasDec->hasDecodedFirstGoodFrame = true; /* Functionality to suppress output for initial lost frames is disabled in EVS operation */ -#endif return IVAS_ERR_OK; } @@ -1995,6 +1993,29 @@ ivas_error IVAS_DEC_GetHrtfParamBinHandle( return IVAS_ERR_OK; } +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES +/*---------------------------------------------------------------------* + * IVAS_DEC_GetHrtfStatisticsHandle( ) + * + * + *---------------------------------------------------------------------*/ + +ivas_error IVAS_DEC_GetHrtfStatisticsHandle( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + IVAS_DEC_HRTF_STATISTICS_HANDLE **hHrtfStatistics /* o : HRTF statistics handle */ +) +{ + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || hIvasDec->st_ivas->hHrtfStatistics == NULL ) + { + return IVAS_ERR_WRONG_PARAMS; + } + + *hHrtfStatistics = &hIvasDec->st_ivas->hHrtfStatistics; + + return IVAS_ERR_OK; +} +#endif + /*---------------------------------------------------------------------* * copyRendererConfigStruct( ) * diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index 0187d1782b789d0058f403db07cd837abaf3eb45..882ac57f22764a49e0ada1bc37ef8ba3dd15bf4f 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -441,6 +441,12 @@ ivas_error IVAS_DEC_GetHrtfParamBinHandle( #endif ); +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES +ivas_error IVAS_DEC_GetHrtfStatisticsHandle( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + IVAS_DEC_HRTF_STATISTICS_HANDLE **hHrtfStatistics /* o : HRTF statistics handle */ +); +#endif /*! r: error code*/ ivas_error IVAS_DEC_GetRenderConfig( diff --git a/lib_enc/ivas_ism_metadata_enc.c b/lib_enc/ivas_ism_metadata_enc.c index 3b23359850014686a8a3e88b60ebbf4813384903..3e452b1ebca6129fce3b31f24d9e2f2c093c6dff 100644 --- a/lib_enc/ivas_ism_metadata_enc.c +++ b/lib_enc/ivas_ism_metadata_enc.c @@ -55,9 +55,6 @@ #define ISM_MAX_ELEVATION_DIFF_IDX ( ISM_ELEVATION_NBITS - 1 /*zero*/ - 1 /*sign*/ ) #define ISM_MAX_RADIUS_DIFF_IDX ( ISM_RADIUS_NBITS - 1 /*zero*/ - 1 /*sign*/ ) -#ifndef NONBE_FIX_944_FEC_OMASA_1SEP_OBJ_MASA -#define ISM_FEC_MAX 10 -#endif #define ISM_MD_FEC_DIFF 10 #define ISM_MD_INC_DIFF_CNT_MAX 6 #define ISM_MD_FEC_CNT_MAX 25 diff --git a/lib_enc/ivas_omasa_enc.c b/lib_enc/ivas_omasa_enc.c index b5382f906050379c9cac535a5d85324fdcfe2ea6..7e17c87c2664683ebe17831059e9c372b10a327d 100644 --- a/lib_enc/ivas_omasa_enc.c +++ b/lib_enc/ivas_omasa_enc.c @@ -45,13 +45,11 @@ #include "wmc_auto.h" -#ifdef NONBE_FIX_944_FEC_OMASA_1SEP_OBJ_MASA /*------------------------------------------------------------------------- * Local constants *------------------------------------------------------------------------*/ #define OMASA_FEC_MAX 5 -#endif /*------------------------------------------------------------------------- * Local function prototypes @@ -141,9 +139,7 @@ ivas_error ivas_omasa_enc_open( set_zero( hOMasa->broadband_energy_prev, MAX_NUM_OBJECTS + MASA_MAX_TRANSPORT_CHANNELS ); hOMasa->prev_selected_object = 0; hOMasa->changing_object = 0; -#ifdef NONBE_FIX_944_FEC_OMASA_1SEP_OBJ_MASA hOMasa->since_obj_change_cnt = 0; -#endif input_frame = (int16_t) ( st_ivas->hEncoderConfig->input_Fs / FRAMES_PER_SEC ); for ( i = 0; i < input_frame; i++ ) @@ -507,7 +503,6 @@ void ivas_omasa_enc( hOMasa->broadband_energy_prev[i] = broadband_energy[i]; } -#ifdef NONBE_FIX_944_FEC_OMASA_1SEP_OBJ_MASA /* force absolute MD coding in case of change of separated object */ if ( hOMasa->prev_selected_object != selected_object ) { @@ -523,7 +518,6 @@ void ivas_omasa_enc( hIsmMeta[0]->position_angle.angle1_diff_cnt = ISM_FEC_MAX; } } -#endif hOMasa->prev_selected_object = selected_object; /* Separate the selected object */ diff --git a/lib_enc/ivas_rom_enc.c b/lib_enc/ivas_rom_enc.c index 9d04a20689b5348063e79e226a7e41f818d98e6e..048b4ad89509ee9626f7781acea67094bd5a8d3a 100644 --- a/lib_enc/ivas_rom_enc.c +++ b/lib_enc/ivas_rom_enc.c @@ -534,7 +534,114 @@ const float ari_bit_estimate_s17_LC[RANGE_N_CONTEXT][RANGE_N_SYMBOLS] = * Stereo downmix to EVS ROM tables *----------------------------------------------------------------------------------*/ - +#ifdef NONBE_FIX_947_STEREO_DMX_EVS_POC + +const float Stereo_dmx_s_wnd_coef_16k[L_FRAME16k >> 1] = { + 0.00009518625f, 0.00038070876f, 0.00085645882f, 0.00152225529f, 0.00237784467f, 0.00342290120f, 0.00465702698f, 0.00607975212f, 0.00769053493f, 0.00948876211f, + 0.01147374899f, 0.01364473980f, 0.01600090794f, 0.01854135633f, 0.02126511768f, 0.02417115495f, 0.02725836167f, 0.03052556242f, 0.03397151320f, 0.03759490201f, + 0.04139434925f, 0.04536840829f, 0.04951556605f, 0.05383424350f, 0.05832279634f, 0.06297951556f, 0.06780262815f, 0.07279029773f, 0.07794062527f, 0.08325164980f, + 0.08872134919f, 0.09434764087f, 0.10012838266f, 0.10606137357f, 0.11214435465f, 0.11837500982f, 0.12475096680f, 0.13126979798f, 0.13792902134f, 0.14472610141f, + 0.15165845025f, 0.15872342839f, 0.16591834588f, 0.17324046329f, 0.18068699277f, 0.18825509907f, 0.19594190069f, 0.20374447091f, 0.21165983894f, 0.21968499105f, + 0.22781687170f, 0.23605238471f, 0.24438839446f, 0.25282172706f, 0.26134917154f, 0.26996748113f, 0.27867337446f, 0.28746353680f, 0.29633462133f, 0.30528325043f, + 0.31430601697f, 0.32339948556f, 0.33256019391f, 0.34178465414f, 0.35106935407f, 0.36041075859f, 0.36980531103f, 0.37924943444f, 0.38873953302f, 0.39827199347f, + 0.40784318636f, 0.41744946748f, 0.42708717932f, 0.43675265234f, 0.44644220647f, 0.45615215247f, 0.46587879332f, 0.47561842564f, 0.48536734113f, 0.49512182793f, + 0.50487817207f, 0.51463265887f, 0.52438157436f, 0.53412120668f, 0.54384784753f, 0.55355779353f, 0.56324734766f, 0.57291282068f, 0.58255053252f, 0.59215681364f, + 0.60172800653f, 0.61126046698f, 0.62075056556f, 0.63019468897f, 0.63958924141f, 0.64893064593f, 0.65821534586f, 0.66743980609f, 0.67660051444f, 0.68569398303f, + 0.69471674957f, 0.70366537867f, 0.71253646320f, 0.72132662554f, 0.73003251887f, 0.73865082846f, 0.74717827294f, 0.75561160554f, 0.76394761529f, 0.77218312830f, + 0.78031500895f, 0.78834016106f, 0.79625552909f, 0.80405809931f, 0.81174490093f, 0.81931300723f, 0.82675953671f, 0.83408165412f, 0.84127657161f, 0.84834154975f, + 0.85527389859f, 0.86207097866f, 0.86873020202f, 0.87524903320f, 0.88162499018f, 0.88785564535f, 0.89393862643f, 0.89987161734f, 0.90565235913f, 0.91127865081f, + 0.91674835020f, 0.92205937473f, 0.92720970227f, 0.93219737185f, 0.93702048444f, 0.94167720366f, 0.94616575650f, 0.95048443395f, 0.95463159171f, 0.95860565075f, + 0.96240509799f, 0.96602848680f, 0.96947443758f, 0.97274163833f, 0.97582884505f, 0.97873488232f, 0.98145864367f, 0.98399909206f, 0.98635526020f, 0.98852625101f, + 0.99051123789f, 0.99230946507f, 0.99392024788f, 0.99534297302f, 0.99657709880f, 0.99762215533f, 0.99847774471f, 0.99914354118f, 0.99961929124f, 0.99990481375f, +}; + +const float Stereo_dmx_s_wnd_coef_32k[L_FRAME32k >> 1] = { + 0.00002394563f, 0.00009578022f, 0.00021549689f, 0.00038308417f, 0.00059852602f, 0.00086180179f, 0.00117288627f, 0.00153174967f, 0.00193835760f, 0.00239267114f, + 0.00289464674f, 0.00344423635f, 0.00404138732f, 0.00468604244f, 0.00537813998f, 0.00611761365f, 0.00690439261f, 0.00773840150f, 0.00861956044f, 0.00954778504f, + 0.01052298638f, 0.01154507106f, 0.01261394118f, 0.01372949435f, 0.01489162374f, 0.01610021802f, 0.01735516144f, 0.01865633380f, 0.02000361046f, 0.02139686238f, + 0.02283595610f, 0.02432075380f, 0.02585111325f, 0.02742688787f, 0.02904792673f, 0.03071407456f, 0.03242517178f, 0.03418105448f, 0.03598155450f, 0.03782649936f, + 0.03971571237f, 0.04164901255f, 0.04362621475f, 0.04564712957f, 0.04771156345f, 0.04981931865f, 0.05197019329f, 0.05416398135f, 0.05640047270f, 0.05867945313f, + 0.06100070434f, 0.06336400401f, 0.06576912578f, 0.06821583926f, 0.07070391012f, 0.07323310003f, 0.07580316675f, 0.07841386411f, 0.08106494204f, 0.08375614663f, + 0.08648722009f, 0.08925790085f, 0.09206792352f, 0.09491701895f, 0.09780491424f, 0.10073133278f, 0.10369599428f, 0.10669861478f, 0.10973890666f, 0.11281657874f, + 0.11593133621f, 0.11908288075f, 0.12227091048f, 0.12549512005f, 0.12875520064f, 0.13205083999f, 0.13538172244f, 0.13874752893f, 0.14214793710f, 0.14558262123f, + 0.14905125235f, 0.15255349823f, 0.15608902340f, 0.15965748923f, 0.16325855391f, 0.16689187254f, 0.17055709710f, 0.17425387653f, 0.17798185674f, 0.18174068066f, + 0.18552998825f, 0.18934941657f, 0.19319859978f, 0.19707716920f, 0.20098475333f, 0.20492097790f, 0.20888546587f, 0.21287783752f, 0.21689771045f, 0.22094469963f, + 0.22501841743f, 0.22911847365f, 0.23324447559f, 0.23739602804f, 0.24157273335f, 0.24577419148f, 0.25000000000f, 0.25424975414f, 0.25852304686f, 0.26281946885f, + 0.26713860858f, 0.27148005237f, 0.27584338436f, 0.28022818664f, 0.28463403922f, 0.28906052009f, 0.29350720527f, 0.29797366885f, 0.30245948302f, 0.30696421811f, + 0.31148744266f, 0.31602872341f, 0.32058762540f, 0.32516371195f, 0.32975654476f, 0.33436568391f, 0.33899068794f, 0.34363111384f, 0.34828651715f, 0.35295645195f, + 0.35764047095f, 0.36233812551f, 0.36704896567f, 0.37177254021f, 0.37650839670f, 0.38125608152f, 0.38601513994f, 0.39078511611f, 0.39556555316f, 0.40035599320f, + 0.40515597739f, 0.40996504598f, 0.41478273835f, 0.41960859304f, 0.42444214782f, 0.42928293972f, 0.43413050508f, 0.43898437958f, 0.44384409832f, 0.44870919580f, + 0.45357920605f, 0.45845366260f, 0.46333209856f, 0.46821404667f, 0.47309903931f, 0.47798660859f, 0.48287628638f, 0.48776760431f, 0.49266009390f, 0.49755328651f, + 0.50244671349f, 0.50733990610f, 0.51223239569f, 0.51712371362f, 0.52201339141f, 0.52690096069f, 0.53178595333f, 0.53666790144f, 0.54154633740f, 0.54642079395f, + 0.55129080420f, 0.55615590168f, 0.56101562042f, 0.56586949492f, 0.57071706028f, 0.57555785218f, 0.58039140696f, 0.58521726165f, 0.59003495402f, 0.59484402261f, + 0.59964400680f, 0.60443444684f, 0.60921488389f, 0.61398486006f, 0.61874391848f, 0.62349160330f, 0.62822745979f, 0.63295103433f, 0.63766187449f, 0.64235952905f, + 0.64704354805f, 0.65171348285f, 0.65636888616f, 0.66100931206f, 0.66563431609f, 0.67024345524f, 0.67483628805f, 0.67941237460f, 0.68397127659f, 0.68851255734f, + 0.69303578189f, 0.69754051698f, 0.70202633115f, 0.70649279473f, 0.71093947991f, 0.71536596078f, 0.71977181336f, 0.72415661564f, 0.72851994763f, 0.73286139142f, + 0.73718053115f, 0.74147695314f, 0.74575024586f, 0.75000000000f, 0.75422580852f, 0.75842726665f, 0.76260397196f, 0.76675552441f, 0.77088152635f, 0.77498158257f, + 0.77905530037f, 0.78310228955f, 0.78712216248f, 0.79111453413f, 0.79507902210f, 0.79901524667f, 0.80292283080f, 0.80680140022f, 0.81065058343f, 0.81447001175f, + 0.81825931934f, 0.82201814326f, 0.82574612347f, 0.82944290290f, 0.83310812746f, 0.83674144609f, 0.84034251077f, 0.84391097660f, 0.84744650177f, 0.85094874765f, + 0.85441737877f, 0.85785206290f, 0.86125247107f, 0.86461827756f, 0.86794916001f, 0.87124479936f, 0.87450487995f, 0.87772908952f, 0.88091711925f, 0.88406866379f, + 0.88718342126f, 0.89026109334f, 0.89330138522f, 0.89630400572f, 0.89926866722f, 0.90219508576f, 0.90508298105f, 0.90793207648f, 0.91074209915f, 0.91351277991f, + 0.91624385337f, 0.91893505796f, 0.92158613589f, 0.92419683325f, 0.92676689997f, 0.92929608988f, 0.93178416074f, 0.93423087422f, 0.93663599599f, 0.93899929566f, + 0.94132054687f, 0.94359952730f, 0.94583601865f, 0.94802980671f, 0.95018068135f, 0.95228843655f, 0.95435287043f, 0.95637378525f, 0.95835098745f, 0.96028428763f, + 0.96217350064f, 0.96401844550f, 0.96581894552f, 0.96757482822f, 0.96928592544f, 0.97095207327f, 0.97257311213f, 0.97414888675f, 0.97567924620f, 0.97716404390f, + 0.97860313762f, 0.97999638954f, 0.98134366620f, 0.98264483856f, 0.98389978198f, 0.98510837626f, 0.98627050565f, 0.98738605882f, 0.98845492894f, 0.98947701362f, + 0.99045221496f, 0.99138043956f, 0.99226159850f, 0.99309560739f, 0.99388238635f, 0.99462186002f, 0.99531395756f, 0.99595861268f, 0.99655576365f, 0.99710535326f, + 0.99760732886f, 0.99806164240f, 0.99846825033f, 0.99882711373f, 0.99913819821f, 0.99940147398f, 0.99961691583f, 0.99978450311f, 0.99990421978f, 0.99997605437f, +}; + +const float Stereo_dmx_s_wnd_coef_48k[L_FRAME48k >> 1] = { + 0.00001066469f, 0.00004265829f, 0.00009597944f, 0.00017062587f, 0.00026659439f, 0.00038388092f, 0.00052248043f, 0.00068238703f, 0.00086359389f, 0.00106609329f, + 0.00128987657f, 0.00153493420f, 0.00180125573f, 0.00208882979f, 0.00239764411f, 0.00272768552f, 0.00307893994f, 0.00345139239f, 0.00384502699f, 0.00425982692f, + 0.00469577451f, 0.00515285116f, 0.00563103736f, 0.00613031272f, 0.00665065594f, 0.00719204483f, 0.00775445628f, 0.00833786630f, 0.00894225002f, 0.00956758164f, + 0.01021383449f, 0.01088098101f, 0.01156899272f, 0.01227784029f, 0.01300749347f, 0.01375792114f, 0.01452909129f, 0.01532097101f, 0.01613352653f, 0.01696672319f, + 0.01782052544f, 0.01869489686f, 0.01958980015f, 0.02050519713f, 0.02144104876f, 0.02239731512f, 0.02337395540f, 0.02437092795f, 0.02538819024f, 0.02642569887f, + 0.02748340959f, 0.02856127727f, 0.02965925593f, 0.03077729874f, 0.03191535800f, 0.03307338516f, 0.03425133082f, 0.03544914473f, 0.03666677580f, 0.03790417209f, + 0.03916128080f, 0.04043804831f, 0.04173442015f, 0.04305034103f, 0.04438575481f, 0.04574060451f, 0.04711483235f, 0.04850837971f, 0.04992118712f, 0.05135319434f, + 0.05280434026f, 0.05427456299f, 0.05576379980f, 0.05727198717f, 0.05879906076f, 0.06034495543f, 0.06190960523f, 0.06349294342f, 0.06509490245f, 0.06671541398f, + 0.06835440889f, 0.07001181725f, 0.07168756837f, 0.07338159076f, 0.07509381216f, 0.07682415952f, 0.07857255903f, 0.08033893610f, 0.08212321539f, 0.08392532077f, + 0.08574517538f, 0.08758270157f, 0.08943782098f, 0.09131045444f, 0.09320052209f, 0.09510794329f, 0.09703263668f, 0.09897452015f, 0.10093351086f, 0.10290952525f, + 0.10490247902f, 0.10691228715f, 0.10893886391f, 0.11098212284f, 0.11304197679f, 0.11511833788f, 0.11721111754f, 0.11932022649f, 0.12144557476f, 0.12358707169f, + 0.12574462591f, 0.12791814541f, 0.13010753744f, 0.13231270863f, 0.13453356489f, 0.13677001149f, 0.13902195302f, 0.14128929343f, 0.14357193598f, 0.14586978330f, + 0.14818273738f, 0.15051069953f, 0.15285357046f, 0.15521125022f, 0.15758363824f, 0.15997063331f, 0.16237213360f, 0.16478803667f, 0.16721823946f, 0.16966263830f, + 0.17212112893f, 0.17459360645f, 0.17707996539f, 0.17958009971f, 0.18209390273f, 0.18462126722f, 0.18716208538f, 0.18971624880f, 0.19228364855f, 0.19486417508f, + 0.19745771833f, 0.20006416764f, 0.20268341185f, 0.20531533920f, 0.20795983744f, 0.21061679373f, 0.21328609476f, 0.21596762663f, 0.21866127498f, 0.22136692487f, + 0.22408446091f, 0.22681376715f, 0.22955472717f, 0.23230722405f, 0.23507114037f, 0.23784635822f, 0.24063275922f, 0.24343022449f, 0.24623863471f, 0.24905787007f, + 0.25188781030f, 0.25472833469f, 0.25757932206f, 0.26044065079f, 0.26331219882f, 0.26619384366f, 0.26908546237f, 0.27198693160f, 0.27489812759f, 0.27781892614f, + 0.28074920265f, 0.28368883213f, 0.28663768917f, 0.28959564798f, 0.29256258237f, 0.29553836579f, 0.29852287128f, 0.30151597152f, 0.30451753885f, 0.30752744522f, + 0.31054556222f, 0.31357176111f, 0.31660591279f, 0.31964788784f, 0.32269755648f, 0.32575478862f, 0.32881945384f, 0.33189142141f, 0.33497056027f, 0.33805673909f, + 0.34114982620f, 0.34424968966f, 0.34735619724f, 0.35046921640f, 0.35358861436f, 0.35671425805f, 0.35984601412f, 0.36298374899f, 0.36612732880f, 0.36927661945f, + 0.37243148660f, 0.37559179565f, 0.37875741181f, 0.38192820002f, 0.38510402503f, 0.38828475135f, 0.39147024330f, 0.39466036500f, 0.39785498036f, 0.40105395309f, + 0.40425714674f, 0.40746442465f, 0.41067565002f, 0.41389068585f, 0.41710939500f, 0.42033164016f, 0.42355728386f, 0.42678618852f, 0.43001821639f, 0.43325322959f, + 0.43649109013f, 0.43973165987f, 0.44297480059f, 0.44622037393f, 0.44946824144f, 0.45271826458f, 0.45597030469f, 0.45922422305f, 0.46247988086f, 0.46573713923f, + 0.46899585921f, 0.47225590178f, 0.47551712789f, 0.47877939840f, 0.48204257416f, 0.48530651596f, 0.48857108456f, 0.49183614071f, 0.49510154512f, 0.49836715849f, + 0.50163284151f, 0.50489845488f, 0.50816385929f, 0.51142891544f, 0.51469348404f, 0.51795742584f, 0.52122060160f, 0.52448287211f, 0.52774409822f, 0.53100414079f, + 0.53426286077f, 0.53752011914f, 0.54077577695f, 0.54402969531f, 0.54728173542f, 0.55053175856f, 0.55377962607f, 0.55702519941f, 0.56026834013f, 0.56350890987f, + 0.56674677041f, 0.56998178361f, 0.57321381148f, 0.57644271614f, 0.57966835984f, 0.58289060500f, 0.58610931415f, 0.58932434998f, 0.59253557535f, 0.59574285326f, + 0.59894604691f, 0.60214501964f, 0.60533963500f, 0.60852975670f, 0.61171524865f, 0.61489597497f, 0.61807179998f, 0.62124258819f, 0.62440820435f, 0.62756851340f, + 0.63072338055f, 0.63387267120f, 0.63701625101f, 0.64015398588f, 0.64328574195f, 0.64641138564f, 0.64953078360f, 0.65264380276f, 0.65575031034f, 0.65885017380f, + 0.66194326091f, 0.66502943973f, 0.66810857859f, 0.67118054616f, 0.67424521138f, 0.67730244352f, 0.68035211216f, 0.68339408721f, 0.68642823889f, 0.68945443778f, + 0.69247255478f, 0.69548246115f, 0.69848402848f, 0.70147712872f, 0.70446163421f, 0.70743741763f, 0.71040435202f, 0.71336231083f, 0.71631116787f, 0.71925079735f, + 0.72218107386f, 0.72510187241f, 0.72801306840f, 0.73091453763f, 0.73380615634f, 0.73668780118f, 0.73955934921f, 0.74242067794f, 0.74527166531f, 0.74811218970f, + 0.75094212993f, 0.75376136529f, 0.75656977551f, 0.75936724078f, 0.76215364178f, 0.76492885963f, 0.76769277595f, 0.77044527283f, 0.77318623285f, 0.77591553909f, + 0.77863307513f, 0.78133872502f, 0.78403237337f, 0.78671390524f, 0.78938320627f, 0.79204016256f, 0.79468466080f, 0.79731658815f, 0.79993583236f, 0.80254228167f, + 0.80513582492f, 0.80771635145f, 0.81028375120f, 0.81283791462f, 0.81537873278f, 0.81790609727f, 0.82041990029f, 0.82292003461f, 0.82540639355f, 0.82787887107f, + 0.83033736170f, 0.83278176054f, 0.83521196333f, 0.83762786640f, 0.84002936669f, 0.84241636176f, 0.84478874978f, 0.84714642954f, 0.84948930047f, 0.85181726262f, + 0.85413021670f, 0.85642806402f, 0.85871070657f, 0.86097804698f, 0.86322998851f, 0.86546643511f, 0.86768729137f, 0.86989246256f, 0.87208185459f, 0.87425537409f, + 0.87641292831f, 0.87855442524f, 0.88067977351f, 0.88278888246f, 0.88488166212f, 0.88695802321f, 0.88901787716f, 0.89106113609f, 0.89308771285f, 0.89509752098f, + 0.89709047475f, 0.89906648914f, 0.90102547985f, 0.90296736332f, 0.90489205671f, 0.90679947791f, 0.90868954556f, 0.91056217902f, 0.91241729843f, 0.91425482462f, + 0.91607467923f, 0.91787678461f, 0.91966106390f, 0.92142744097f, 0.92317584048f, 0.92490618784f, 0.92661840924f, 0.92831243163f, 0.92998818275f, 0.93164559111f, + 0.93328458602f, 0.93490509755f, 0.93650705658f, 0.93809039477f, 0.93965504457f, 0.94120093924f, 0.94272801283f, 0.94423620020f, 0.94572543701f, 0.94719565974f, + 0.94864680566f, 0.95007881288f, 0.95149162029f, 0.95288516765f, 0.95425939549f, 0.95561424519f, 0.95694965897f, 0.95826557985f, 0.95956195169f, 0.96083871920f, + 0.96209582791f, 0.96333322420f, 0.96455085527f, 0.96574866918f, 0.96692661484f, 0.96808464200f, 0.96922270126f, 0.97034074407f, 0.97143872273f, 0.97251659041f, + 0.97357430113f, 0.97461180976f, 0.97562907205f, 0.97662604460f, 0.97760268488f, 0.97855895124f, 0.97949480287f, 0.98041019985f, 0.98130510314f, 0.98217947456f, + 0.98303327681f, 0.98386647347f, 0.98467902899f, 0.98547090871f, 0.98624207886f, 0.98699250653f, 0.98772215971f, 0.98843100728f, 0.98911901899f, 0.98978616551f, + 0.99043241836f, 0.99105774998f, 0.99166213370f, 0.99224554372f, 0.99280795517f, 0.99334934406f, 0.99386968728f, 0.99436896264f, 0.99484714884f, 0.99530422549f, + 0.99574017308f, 0.99615497301f, 0.99654860761f, 0.99692106006f, 0.99727231448f, 0.99760235589f, 0.99791117021f, 0.99819874427f, 0.99846506580f, 0.99871012343f, + 0.99893390671f, 0.99913640611f, 0.99931761297f, 0.99947751957f, 0.99961611908f, 0.99973340561f, 0.99982937413f, 0.99990402056f, 0.99995734171f, 0.99998933531f, +}; + +#else const float Stereo_dmx_s_wnd_coef_16k[L_FRAME16k >> 4] = { 0.00154133327f, 0.0138150426f, 0.0380602330f, 0.0736799166f, 0.119797014f, 0.175276011f, 0.238750681f, 0.308658302f, 0.383277327f, 0.460770488f, 0.539229512f, 0.616722703f, 0.691341758f, 0.761249363f, 0.824724138f, 0.880203009f, 0.926320136f, 0.961939812f, 0.986184955f, 0.998458624f, @@ -555,6 +662,7 @@ const float Stereo_dmx_s_wnd_coef_48k[L_FRAME48k >> 4] = { 0.761249363f, 0.783203125f, 0.804380774f, 0.824724138f, 0.844177306f, 0.862687230f, 0.880203009f, 0.896676719f, 0.912063122f, 0.926320136f, 0.939408541f, 0.951292694f, 0.961939812f, 0.971320748f, 0.979409873f, 0.986184955f, 0.991627395f, 0.995722473f, 0.998458624f, 0.999828696f }; +#endif const float Stereo_dmx_wnd_coef_32k[L_FRAME32k] = { 0.00245436677f, 0.00736304140f, 0.0122715384f, 0.0171797406f, 0.0220875274f, 0.0269947834f, 0.0319013894f, 0.0368072242f, 0.0417121723f, 0.0466161147f, diff --git a/lib_enc/ivas_rom_enc.h b/lib_enc/ivas_rom_enc.h index 60d4ddcf79ebbccb097965b8e413d5ac317dba22..9c1cef2c8bb2f5e763a1e1bf31948f04fd17877b 100644 --- a/lib_enc/ivas_rom_enc.h +++ b/lib_enc/ivas_rom_enc.h @@ -120,9 +120,15 @@ extern const uint16_t ECSQ_tab_vals[ECSQ_PARAM_COUNT - 1][1 + ECSQ_TAB_VALS_SIZE * Stereo downmix to EVS ROM tables *----------------------------------------------------------------------------------*/ +#ifdef NONBE_FIX_947_STEREO_DMX_EVS_POC +extern const float Stereo_dmx_s_wnd_coef_16k[L_FRAME16k >> 1]; +extern const float Stereo_dmx_s_wnd_coef_32k[L_FRAME32k >> 1]; +extern const float Stereo_dmx_s_wnd_coef_48k[L_FRAME48k >> 1]; +#else extern const float Stereo_dmx_s_wnd_coef_16k[L_FRAME16k >> 4]; extern const float Stereo_dmx_s_wnd_coef_32k[L_FRAME32k >> 4]; extern const float Stereo_dmx_s_wnd_coef_48k[L_FRAME48k >> 4]; +#endif extern const float Stereo_dmx_wnd_coef_32k[L_FRAME32k]; extern const float Stereo_dmx_wnd_coef_48k[L_FRAME48k]; diff --git a/lib_enc/ivas_stat_enc.h b/lib_enc/ivas_stat_enc.h index 181fe5316b305bd1444035e0fba6ba4581c86da8..f9c0ab58c97df5b39c867daaaeb50d6fe84d6af0 100644 --- a/lib_enc/ivas_stat_enc.h +++ b/lib_enc/ivas_stat_enc.h @@ -788,9 +788,7 @@ typedef struct ivas_omasa_enc_state_structure float broadband_energy_prev[MAX_NUM_OBJECTS + MASA_MAX_TRANSPORT_CHANNELS]; int16_t prev_selected_object; uint8_t changing_object; -#ifdef NONBE_FIX_944_FEC_OMASA_1SEP_OBJ_MASA int16_t since_obj_change_cnt; -#endif float fade_out_gain[L_FRAME48k]; float fade_in_gain[L_FRAME48k]; @@ -1076,7 +1074,9 @@ typedef struct stereo_dmx_evs_phase_only_correlation_structure typedef struct stereo_dmx_evs_correlation_filter_structure { +#ifndef NONBE_FIX_947_STEREO_DMX_EVS_PHA int16_t init_frmCntr; +#endif float isd_rate_s; float iccr_s; float ipd_ff[STEREO_DMX_EVS_NB_SUBBAND_MAX]; @@ -1097,17 +1097,44 @@ typedef struct stereo_dmx_evs_correlation_filter_structure STEREO_DMX_EVS_PHA curr_pha; STEREO_DMX_EVS_PHA prev_pha; int16_t pha_hys_cnt; +#ifdef NONBE_FIX_947_STEREO_DMX_EVS_PHA + STEREO_DMX_EVS_PHA proc_pha; + bool force_poc; + + int16_t pha_ipd_chan2rephase; + int16_t pha_ipd_previouschan2rephase; + int16_t pha_ipd_chan_cnt; + int16_t pha_ipd_chan_thresh; + float pha_ipd_ild_thresh; + int16_t pha_ipd_chanswitch; + int16_t pha_ipd_chanswitch_allowed; + float pha_ipd_sf_Threshold; +#endif int16_t prc_thres; STEREO_DMX_EVS_PRC curr_prc; STEREO_DMX_EVS_PRC prev_prc; int16_t prc_hys_cnt; float fad_g_prc[L_FRAME48k]; +#ifndef NONBE_FIX_947_STEREO_DMX_EVS_PHA int16_t fad_len_prc; +#endif float trns_aux_energy[CPE_CHANNELS]; float crst_fctr; +#ifdef NONBE_FIX_947_STEREO_DMX_EVS_PHA + int16_t n_fad_g; + int16_t n_fad_cnt; + float dmx_pha_ener; + float dmx_poc_ener; + float dmx_pha_ener_sgc; + float dmx_poc_ener_sgc; + float dmx_pha_gain_sgc; + float dmx_poc_gain_sgc; + float low_egy_thres_sgc; +#endif + } STEREO_DMX_EVS_PHA_DATA, *STEREO_DMX_EVS_PHA_HANDLE; typedef struct stereo_dmx_evs_enc_data_structure diff --git a/lib_enc/ivas_stereo_dft_enc_itd.c b/lib_enc/ivas_stereo_dft_enc_itd.c index d3336f4eb604e5fba2dd1ede2fe9de49ec870dfc..13b72ea7b956becbf02edecb58d7dccfcfffdcbc 100755 --- a/lib_enc/ivas_stereo_dft_enc_itd.c +++ b/lib_enc/ivas_stereo_dft_enc_itd.c @@ -908,7 +908,18 @@ void stereo_dft_enc_compute_itd( { hStereoDft->expectedNumUpdates += 1 + min( hCPE->hFrontVad[0]->rem_dtx_ho, hCPE->hFrontVad[1]->rem_dtx_ho ); } +#ifdef FIX_963_USAN_ERROR + if ( hStereoDft->expectedNumUpdates + hStereoDft->currentNumUpdates == 0 ) + { + cng_xcorr_filt = max( CORR_FILT, sfm_L ); + } + else + { + cng_xcorr_filt = max( min( CORR_FILT, 10.0f * CORR_FILT / ( hStereoDft->expectedNumUpdates + hStereoDft->currentNumUpdates ) ), sfm_L ); + } +#else cng_xcorr_filt = max( min( CORR_FILT, 10.0f * CORR_FILT / ( hStereoDft->expectedNumUpdates + hStereoDft->currentNumUpdates ) ), sfm_L ); +#endif hStereoDft->currentNumUpdates++; for ( i = 1; i < NFFT / 2; i++ ) { @@ -943,7 +954,18 @@ void stereo_dft_enc_compute_itd( if ( vad_flag_dtx[0] == 0 ) { /* expectedNumUpdates updated after call to dtx() in SID frames */ +#ifdef FIX_963_USAN_ERROR + if ( hStereoDft->expectedNumUpdates + hStereoDft->currentNumUpdates == 0 ) + { + cng_xcorr_filt = max( CORR_FILT, sfm_L ); + } + else + { + cng_xcorr_filt = max( min( CORR_FILT, 10.0f * CORR_FILT / ( hStereoDft->expectedNumUpdates + hStereoDft->currentNumUpdates ) ), sfm_L ); + } +#else cng_xcorr_filt = max( min( CORR_FILT, 10.0f * CORR_FILT / ( hStereoDft->expectedNumUpdates + hStereoDft->currentNumUpdates ) ), sfm_L ); +#endif hStereoDft->currentNumUpdates++; hStereoDft->sfm = cng_xcorr_filt; } diff --git a/lib_enc/ivas_stereo_dmx_evs.c b/lib_enc/ivas_stereo_dmx_evs.c index 2ffc13d75d779e73ccc37561d3a4444c33e39672..813d10e1cf4e101a871232129b840920274f59aa 100644 --- a/lib_enc/ivas_stereo_dmx_evs.c +++ b/lib_enc/ivas_stereo_dmx_evs.c @@ -58,7 +58,11 @@ #define STEREO_DMX_EVS_POC_FORGETTING 0.78f #define STEREO_DMX_EVS_TARGET_POC_FORGETTING 0.79f #define STEREO_DMX_EVS_POC_W_FORGETTING 0.875f -#define STEREO_DMX_EVS_SHIFT_LIMIT 5.625f /* ms */ +#ifdef BE_FIX_567_DOUBLE_STEREO_DMX +#define STEREO_DMX_EVS_SHIFT_LIMIT STEREO_DFT_ZP_NS_ENC +#else +#define STEREO_DMX_EVS_SHIFT_LIMIT 5.625f /* ms */ +#endif #define STEREO_DMX_EVS_DMX_EGY_FORGETTING 0.25f #define STEREO_DMX_EVS_CORR_FORGETTING 0.78f @@ -88,7 +92,14 @@ #define STEREO_DMX_EVS_SWTCH_PRC_THRES_48 29 #define STEREO_DMX_EVS_SWTCH_PRC_HYS_THRES 1 -#define STEREO_DMX_EVS_FADE_LEN_PRC 20.0f +#ifdef NONBE_FIX_947_STEREO_DMX_EVS_PHA +#define STEREO_DMX_EVS_IFF_AMIN 0.857696f +#define STEREO_DMX_EVS_IFF_AMAX 0.944061f +#define STEREO_DMX_EVS_IFF_FREQ 3000.0f +#define STEREO_DMX_EVS_PHA_WND_C 1.8f +#else +#define STEREO_DMX_EVS_FADE_LEN_PRC 20.0f +#endif #define STEREO_DMX_EVS_NB_SBFRM 5 #define STEREO_DMX_EVS_TRNS_DTC_INST 75.0f @@ -98,6 +109,21 @@ #define STEREO_DMX_EVS_TRNS_EGY_FORGETTING 0.75f +#ifdef NONBE_FIX_947_STEREO_DMX_EVS_PHA +#define STEREO_DMX_EVS_FAD_R 3 +#define STEREO_DMX_EVS_SGC_EGY_FORGETTING 0.9f +#define STEREO_DMX_EVS_SGC_GR_S 1.00461543f +#define STEREO_DMX_EVS_SGC_GL 0.9885f +#define STEREO_DMX_EVS_SGC_GH 1.0116f +#define STEREO_DMX_EVS_SGC_LEGY_THRES_16 2.5E8 +#define STEREO_DMX_EVS_SGC_LEGY_THRES_32 3.E8 +#define STEREO_DMX_EVS_SGC_LEGY_THRES_48 5.E8 +#define STEREO_DMX_EVS_SGC_GMAX 1.4142f +#define STEREO_DMX_EVS_SGC_GMIN 0.7071f +#endif + +#define STEREO_DMX_EVS_IPD_ILD_THRES 3.16f // 5dB +#define STEREO_DMX_EVS_IPD_SF_THRES 0.05f /*-----------------------------------------------------------------------* * Local function prototypes @@ -111,6 +137,9 @@ static void adapt_gain( const float src[], float dst[], const float gain, const static void create_M_signal( const float srcL[], const float srcR[], float dmx[], const float w_curr, const int16_t input_frame, const float wnd[], float *w_prev, float *dmx_energy, float *src_energy ); static float find_poc_peak( STEREO_DMX_EVS_POC_HANDLE hPOC, float itd[], const int16_t input_frame, const float ratio ); static void calc_energy( const float src1[], const float src2[], float energy[], const int16_t input_frame, const float ratio ); +#ifdef NONBE_FIX_947_STEREO_DMX_EVS_PHA +static float spectral_flatness( const float sig[], const int16_t sig_length ); +#endif /*-------------------------------------------------------------------* * estimate_itd_wnd_fft() @@ -202,7 +231,11 @@ static void calc_poc( int16_t cos_step, cos_max; float eps_cos, eps_sin, EPS; +#ifdef NONBE_FIX_947_STEREO_DMX_EVS_PHA + int16_t isd_cnt_h, isd_cnt_l, ild_cnt, n, freq_8k, freq_ipd_max, nsbd, input_frame_pha, pha_ipd_ild_chan2rephase; +#else int16_t isd_cnt_h, isd_cnt_l, ild_cnt, n, freq_8k, freq_ipd_max, nsbd, input_frame_pha; +#endif float Nr, Ni, Dr, Di, tPr, tPi, Pn, energy, isd_rate; float eneL, eneR, IPDr, IPDi, tIPDr, tIPDi, ICCr; float *Pr, *Pi, *ipd_ff, *p_curr_taps; @@ -381,12 +414,13 @@ static void calc_poc( } specPOr[n0] = sign( specLr[n0] * specRr[n0] ) * wnd[i * step + bias] * gamma; - +#ifndef NONBE_FIX_947_STEREO_DMX_EVS_PHA hPHA->init_frmCntr--; if ( hPHA->init_frmCntr < 0 ) { hPHA->init_frmCntr = 0; } +#endif freq_8k = L_FRAME16k / 2; freq_ipd_max = (int16_t) ( freq_8k * 5000.0f / ( 8000.0f * STEREO_DMX_EVS_SUBBAND_SIZE ) ); @@ -495,7 +529,11 @@ static void calc_poc( tPi += IPDi; /* ICCr */ +#ifdef NONBE_FIX_567_DOUBLE_STEREO_DMX + Pn = inv_sqrtf( ( IPDr * IPDr + IPDi * IPDi ) + EPSILON ); +#else Pn = (float) inv_sqrt( ( IPDr * IPDr + IPDi * IPDi ) + EPSILON ); +#endif IPDr *= Pn; IPDi *= Pn; @@ -508,16 +546,37 @@ static void calc_poc( eneL += ( specLr[i] * specLr[i] + specLi[i] * specLi[i] ); eneR += ( specRr[i] * specRr[i] + specRi[i] * specRi[i] ); } - +#ifdef NONBE_FIX_567_DOUBLE_STEREO_DMX + Pn = inv_sqrtf( ( tPr * tPr + tPi * tPi ) + EPSILON ); +#else Pn = (float) inv_sqrt( ( tPr * tPr + tPi * tPi ) + EPSILON ); +#endif + tPr *= Pn; tPi *= Pn; +#ifdef NONBE_FIX_947_STEREO_DMX_EVS_PHA + + Pr[n] = ipd_ff[n] * Pr[n] + ( 1.0f - ipd_ff[n] ) * tPr; + Pi[n] = ipd_ff[n] * Pi[n] + ( 1.0f - ipd_ff[n] ) * tPi; +#ifdef NONBE_FIX_567_DOUBLE_STEREO_DMX + Pn = inv_sqrtf( ( Pr[n] * Pr[n] + Pi[n] * Pi[n] ) + EPSILON ); +#else + Pn = (float) inv_sqrt( ( Pr[n] * Pr[n] + Pi[n] * Pi[n] ) + EPSILON ); +#endif + Pr[n] *= Pn; + Pi[n] *= Pn; + +#else if ( hPHA->init_frmCntr == 0 ) { Pr[n] = ipd_ff[n] * Pr[n] + ( 1.0f - ipd_ff[n] ) * tPr; Pi[n] = ipd_ff[n] * Pi[n] + ( 1.0f - ipd_ff[n] ) * tPi; +#ifdef NONBE_FIX_567_DOUBLE_STEREO_DMX + Pn = inv_sqrtf( ( Pr[n] * Pr[n] + Pi[n] * Pi[n] ) + EPSILON ); +#else Pn = (float) inv_sqrt( ( Pr[n] * Pr[n] + Pi[n] * Pi[n] ) + EPSILON ); +#endif Pr[n] *= Pn; Pi[n] *= Pn; } @@ -526,13 +585,264 @@ static void calc_poc( Pr[n] = tPr; Pi[n] = tPi; } - +#endif Pr[n] = ( Pr[n] > 1.0f ) ? 1.0f : Pr[n]; Pr[n] = ( Pr[n] < -1.0f ) ? -1.0f : Pr[n]; } + +#ifdef NONBE_FIX_947_STEREO_DMX_EVS_PHA + /* Computes Spectral flatness on one channel */ + tmp1 = spectral_flatness( &tEl[1], nsbd - 1 ); + if ( tmp1 < hPHA->pha_ipd_sf_Threshold ) + { + hPHA->pha_ipd_chanswitch_allowed = 0; + } + else + { + hPHA->pha_ipd_chanswitch_allowed = 1; + } +#endif + +#ifdef NONBE_FIX_567_DOUBLE_STEREO_DMX + ICCr = sqrtf( ( Nr * Nr + Ni * Ni ) / ( eneL * eneR + EPSILON ) ); +#else ICCr = (float) sqrt( ( Nr * Nr + Ni * Ni ) / ( eneL * eneR + EPSILON ) ); +#endif hPHA->iccr_s = STEREO_DMX_EVS_ICCR_FORGETTING * hPHA->iccr_s + ( 1.0f - STEREO_DMX_EVS_ICCR_FORGETTING ) * ICCr; +#ifdef NONBE_FIX_947_STEREO_DMX_EVS_PHA + if ( hPHA->curr_pha == STEREO_DMX_EVS_PHA_IPD ) + { + hPHA->force_poc = FALSE; + hPHA->proc_pha = STEREO_DMX_EVS_PHA_IPD; + } + else + { + if ( ( hPHA->iccr_s < STEREO_DMX_EVS_ICCR_HYST_L ) || ( ( hPHA->iccr_s < STEREO_DMX_EVS_ICCR_HYST_H ) && ( hPHA->proc_pha == STEREO_DMX_EVS_PHA_IPD2 ) && !hPHA->force_poc ) ) + { + hPHA->force_poc = FALSE; + hPHA->proc_pha = STEREO_DMX_EVS_PHA_IPD2; + } + else + { + hPHA->force_poc = TRUE; + } + } + + if ( hPHA->proc_pha == STEREO_DMX_EVS_PHA_IPD ) + { + rfft_pha_buf[0] = 1.; + rfft_pha_buf[1] = 1.; + + ild_cnt = 0; + for ( i = 1; i < nsbd; i++ ) + { + rfft_pha_buf[i * 2] = Pr[i]; + rfft_pha_buf[i * 2 + 1] = Pi[i]; + if ( ( tEr[i] > STEREO_DMX_EVS_LR_EGY * tEl[i] ) || ( tEl[i] > STEREO_DMX_EVS_LR_EGY * tEr[i] ) ) + { + ild_cnt++; + tEr[i] = 1; + } + else + { + tEr[i] = -1; + } + } + if ( ild_cnt > nsbd * STEREO_DMX_EVS_ILD_PRC ) + { + for ( i = 1; i < nsbd; i++ ) + { + if ( tEr[i] > 0 ) + { + rfft_pha_buf[i * 2] = 1.; + rfft_pha_buf[i * 2 + 1] = 0.; + } + } + } + + rfft( rfft_pha_buf, hPHA->rfft_ipd_coef, input_frame_pha, +1 ); + + /* Choose best channel to phase align */ + /* Channel selection based on ILD */ + if ( hPHA->trns_aux_energy[0] > hPHA->trns_aux_energy[1] * hPHA->pha_ipd_ild_thresh ) + { + pha_ipd_ild_chan2rephase = 0; + } + else if ( hPHA->trns_aux_energy[1] > hPHA->trns_aux_energy[0] * hPHA->pha_ipd_ild_thresh ) + { + pha_ipd_ild_chan2rephase = 1; + } + else + { + pha_ipd_ild_chan2rephase = -1; + } + + /* Channel selection based on spikyness of R2L/L2R impulse responses */ + tmp1 = spectral_flatness( rfft_pha_buf, hPHA->pha_len ); + rfft_pha_buf[input_frame_pha - hPHA->pha_len] = rfft_pha_buf[0]; + tmp2 = spectral_flatness( &rfft_pha_buf[input_frame_pha - hPHA->pha_len], hPHA->pha_len ); + + /* Combined ILD/SF channel selection with tempo */ + if ( ( ( tmp1 > tmp2 ) && ( pha_ipd_ild_chan2rephase == -1 ) ) || ( pha_ipd_ild_chan2rephase == 0 ) ) /* L => R */ + { + if ( hPHA->pha_ipd_previouschan2rephase == 0 ) + { + hPHA->pha_ipd_chan_cnt++; + if ( hPHA->pha_ipd_chan_cnt >= hPHA->pha_ipd_chan_thresh ) + { + /* Avoid channel switch in case of too harmonic signals */ + if ( hPHA->pha_ipd_chanswitch_allowed ) + { + if ( hPHA->pha_ipd_chan2rephase != 0 ) + { + hPHA->pha_ipd_chanswitch = 1; + } + else + { + hPHA->pha_ipd_chanswitch = 0; + } + hPHA->pha_ipd_chan2rephase = 0; + } + } + } + else + { + hPHA->pha_ipd_previouschan2rephase = 0; + hPHA->pha_ipd_chan_cnt = 1; + hPHA->pha_ipd_chanswitch = 0; + } + } + else /* R => L */ + { + if ( hPHA->pha_ipd_previouschan2rephase == 1 ) + { + hPHA->pha_ipd_chan_cnt++; + if ( hPHA->pha_ipd_chan_cnt >= hPHA->pha_ipd_chan_thresh ) + { + /* Avoid channel switch in case of too harmonic signals */ + if ( hPHA->pha_ipd_chanswitch_allowed ) + { + if ( hPHA->pha_ipd_chan2rephase != 1 ) + { + hPHA->pha_ipd_chanswitch = 1; + } + else + { + hPHA->pha_ipd_chanswitch = 0; + } + hPHA->pha_ipd_chan2rephase = 1; + } + hPHA->pha_ipd_chan_cnt = hPHA->pha_ipd_chan_thresh; + } + } + else + { + hPHA->pha_ipd_previouschan2rephase = 1; + hPHA->pha_ipd_chan_cnt = 1; + hPHA->pha_ipd_chanswitch = 0; + } + } + + if ( !hPHA->pha_ipd_chanswitch ) + { + if ( hPHA->pha_ipd_chan2rephase == 0 ) + { + hPHA->p_curr_taps[1] = NULL; + hPHA->p_curr_taps[0] = hPHA->curr_taps[0]; + p_curr_taps = hPHA->p_curr_taps[0]; + p_curr_taps[0] = rfft_pha_buf[0]; + for ( i = 1, j = input_frame_pha - 1; i < hPHA->pha_len; i++, j-- ) + { + p_curr_taps[i] = rfft_pha_buf[j]; + } + } + else + { + hPHA->p_curr_taps[0] = NULL; + hPHA->p_curr_taps[1] = hPHA->curr_taps[1]; + mvr2r( rfft_pha_buf, hPHA->p_curr_taps[1], hPHA->pha_len ); + } + } + } + + if ( hPHA->pha_ipd_chanswitch ) + { + for ( n = 0; n < CPE_CHANNELS; n++ ) + { + hPHA->p_curr_taps[n] = NULL; + } + } + else if ( hPHA->proc_pha == STEREO_DMX_EVS_PHA_IPD2 ) + { + /* IPDn */ + + set_f( &( Pr[freq_ipd_max] ), 1.0f, ( nsbd - freq_ipd_max ) ); + set_f( &( Pi[freq_ipd_max] ), 0.0f, ( nsbd - freq_ipd_max ) ); + + for ( n = 0; n < CPE_CHANNELS; n++ ) + { + hPHA->p_curr_taps[n] = hPHA->curr_taps[n]; + } + + rfft_pha_buf[0] = 1.; + rfft_pha_buf[1] = 1.; + + ild_cnt = 0; + isd_rate = (float) isd_cnt_l / freq_8k; + for ( i = 1; i < nsbd; i++ ) + { +#ifdef NONBE_FIX_567_DOUBLE_STEREO_DMX + rfft_pha_buf[i * 2] = sqrtf( ( 1.0f + Pr[i] ) / 2.0f ); + rfft_pha_buf[i * 2 + 1] = sqrtf( ( 1.0f - Pr[i] ) / 2.0f ) * sign( Pi[i] ); + if ( isd_rate > STEREO_DMX_EVS_ISD_DIST_THRES_IPD ) + { + rfft_pha_buf[i * 2 + 1] = sqrtf( ( 1.0f - rfft_pha_buf[i * 2] ) / 2.0f ) * sign( rfft_pha_buf[i * 2 + 1] ); + rfft_pha_buf[i * 2] = sqrtf( ( 1.0f + rfft_pha_buf[i * 2] ) / 2.0f ); + } +#else + rfft_pha_buf[i * 2] = (float) sqrt( ( 1.0f + Pr[i] ) / 2.0f ); + rfft_pha_buf[i * 2 + 1] = (float) sqrt( ( 1.0f - Pr[i] ) / 2.0f ) * sign( Pi[i] ); + if ( isd_rate > STEREO_DMX_EVS_ISD_DIST_THRES_IPD ) + { + rfft_pha_buf[i * 2 + 1] = (float) sqrt( ( 1.0f - rfft_pha_buf[i * 2] ) / 2.0f ) * sign( rfft_pha_buf[i * 2 + 1] ); + rfft_pha_buf[i * 2] = (float) sqrt( ( 1.0f + rfft_pha_buf[i * 2] ) / 2.0f ); + } +#endif + if ( ( tEr[i] > STEREO_DMX_EVS_LR_EGY * tEl[i] ) || ( tEl[i] > STEREO_DMX_EVS_LR_EGY * tEr[i] ) ) + { + ild_cnt++; + tEr[i] = 1; + } + else + { + tEr[i] = -1; + } + } + if ( ild_cnt > nsbd * STEREO_DMX_EVS_ILD_PRC ) + { + for ( i = 1; i < nsbd; i++ ) + { + if ( tEr[i] > 0 ) + { + rfft_pha_buf[i * 2] = 1.; + rfft_pha_buf[i * 2 + 1] = 0.; + } + } + } + + rfft( rfft_pha_buf, hPHA->rfft_ipd_coef, input_frame_pha, +1 ); + mvr2r( rfft_pha_buf, hPHA->p_curr_taps[1], hPHA->pha_len ); + + /* PHA L2R */ + p_curr_taps = hPHA->p_curr_taps[0]; + p_curr_taps[0] = rfft_pha_buf[0]; + for ( i = 1; i < hPHA->pha_len; i++ ) + { + p_curr_taps[i] = rfft_pha_buf[input_frame_pha - i]; + } + } +#else if ( hPHA->curr_pha == STEREO_DMX_EVS_PHA_IPD ) { hPHA->p_curr_taps[0] = NULL; @@ -592,6 +902,15 @@ static void calc_poc( isd_rate = (float) isd_cnt_l / freq_8k; for ( i = 1; i < nsbd; i++ ) { +#ifdef NONBE_FIX_567_DOUBLE_STEREO_DMX + rfft_pha_buf[i * 2] = sqrtf( ( 1.0f + Pr[i] ) / 2.0f ); + rfft_pha_buf[i * 2 + 1] = sqrtf( ( 1.0f - Pr[i] ) / 2.0f ) * sign( Pi[i] ); + if ( isd_rate > STEREO_DMX_EVS_ISD_DIST_THRES_IPD ) + { + rfft_pha_buf[i * 2 + 1] = sqrtf( ( 1.0f - rfft_pha_buf[i * 2] ) / 2.0f ) * sign( rfft_pha_buf[i * 2 + 1] ); + rfft_pha_buf[i * 2] = sqrtf( ( 1.0f + rfft_pha_buf[i * 2] ) / 2.0f ); + } +#else rfft_pha_buf[i * 2] = (float) sqrt( ( 1.0f + Pr[i] ) / 2.0f ); rfft_pha_buf[i * 2 + 1] = (float) sqrt( ( 1.0f - Pr[i] ) / 2.0f ) * sign( Pi[i] ); if ( isd_rate > STEREO_DMX_EVS_ISD_DIST_THRES_IPD ) @@ -599,7 +918,7 @@ static void calc_poc( rfft_pha_buf[i * 2 + 1] = (float) sqrt( ( 1.0f - rfft_pha_buf[i * 2] ) / 2.0f ) * sign( rfft_pha_buf[i * 2 + 1] ); rfft_pha_buf[i * 2] = (float) sqrt( ( 1.0f + rfft_pha_buf[i * 2] ) / 2.0f ); } - +#endif if ( ( tEr[i] > STEREO_DMX_EVS_LR_EGY * tEl[i] ) || ( tEl[i] > STEREO_DMX_EVS_LR_EGY * tEr[i] ) ) { ild_cnt++; @@ -641,6 +960,7 @@ static void calc_poc( } } } +#endif for ( n = 0; n < CPE_CHANNELS; n++ ) { @@ -656,7 +976,11 @@ static void calc_poc( { energy += hPHA->p_curr_taps[n][i] * hPHA->p_curr_taps[n][i]; } +#ifdef NONBE_FIX_567_DOUBLE_STEREO_DMX + energy = inv_sqrtf( energy + EPSILON ); +#else energy = (float) inv_sqrt( energy + EPSILON ); +#endif for ( i = 0; i < hPHA->pha_len; i++ ) { hPHA->p_curr_taps[n][i] *= energy; @@ -949,10 +1273,12 @@ static void weighted_ave( const float wnd[] /* i : window coef */ ) { +#ifdef NONBE_FIX_947_STEREO_DMX_EVS_POC + int16_t i, len; float gain_tmp = 0.f, gain_sub; - len = input_frame >> 4; + len = input_frame >> 1; gain_sub = gain - old_gain; for ( i = 0; i < len; i++ ) @@ -965,9 +1291,58 @@ static void weighted_ave( dst[i] = src1[i] * gain + src2[i] * ( 1.0f - gain_tmp ); } +#else + int16_t i, len; + float gain_tmp = 0.f, gain_sub; + + len = input_frame >> 4; + gain_sub = gain - old_gain; + + for ( i = 0; i < len; i++ ) + { + gain_tmp = old_gain + gain_sub * wnd[i]; + dst[i] = src1[i] * gain_tmp + src2[i] * ( 1.0f - gain_tmp ); + } + for ( ; i < input_frame; i++ ) + { + dst[i] = src1[i] * gain + src2[i] * ( 1.0f - gain_tmp ); + } +#endif return; } +#ifdef NONBE_FIX_947_STEREO_DMX_EVS_PHA +/*-------------------------------------------------------------------* + * spectral_flatness() + * + * computes spectral flatness SF + * SF(x) = exp(mean_i(ln(x_i))) / mean_i(x_i) + *-------------------------------------------------------------------*/ + +static float spectral_flatness( + const float sig[], /* i : input signal */ + const int16_t sigLength /* i : input signal length */ +) +{ + float geoMean = 0.0f; + float ariMean = 0.0f; + float eps = 1e-10f; + int16_t i; + + /* Initialization */ + for ( i = 0; i < sigLength; i++ ) + { + ariMean += fabsf( sig[i] ) + eps; + geoMean += logf( fabsf( sig[i] ) + eps ); + } + ariMean /= sigLength; + geoMean /= sigLength; + geoMean = expf( geoMean ); + + return geoMean / ariMean; +} + +#endif /*-------------------------------------------------------------------* * calc_energy() @@ -1015,6 +1390,25 @@ static void calc_energy( } +#ifdef NONBE_FIX_947_STEREO_DMX_EVS_PHA +/*-------------------------------------------------------------------* + * calc_energy_sgc() + * + * calculate energy for switch gain control + *-------------------------------------------------------------------*/ +static void calc_energy_sgc( + const float src[], /* i : input signal */ + float *energy, /* o : calculated energy */ + const int16_t input_frame, /* i : input frame length */ + const float ratio /* i : adapting ratio */ +) +{ + *energy = ratio * *energy + ( 1.0f - ratio ) * sum2_f( src, input_frame ); + return; +} +#endif + + /*-------------------------------------------------------------------* * adapt_gain() * @@ -1030,10 +1424,12 @@ static void adapt_gain( const float wnd[] /* i : window coef */ ) { +#ifdef NONBE_FIX_947_STEREO_DMX_EVS_POC + int16_t i, len; float gain_tmp, gain_sub; - len = input_frame >> 4; + len = input_frame >> 1; gain_sub = gain - old_gain; for ( i = 0; i < len; i++ ) @@ -1045,7 +1441,23 @@ static void adapt_gain( { dst[i] = src[i] * gain; } +#else + int16_t i, len; + float gain_tmp, gain_sub; + + len = input_frame >> 4; + gain_sub = gain - old_gain; + for ( i = 0; i < len; i++ ) + { + gain_tmp = old_gain + gain_sub * wnd[i]; + dst[i] = src[i] * gain_tmp; + } + for ( ; i < input_frame; i++ ) + { + dst[i] = src[i] * gain; + } +#endif return; } @@ -1106,6 +1518,48 @@ static void create_M_signal( } +#ifdef NONBE_FIX_947_STEREO_DMX_EVS_PHA + +/*-------------------------------------------------------------------* + * apply_gain_sgc() + * + * Apply gain for switching + *-------------------------------------------------------------------*/ + +static void apply_gain_sgc( + float data[], /* i/o : input signal */ + float *gain, /* i : gain */ + float ratio, /* i : ratio */ + const int16_t input_frame /* i : input frame length */ +) +{ + int16_t n; + float lr; + + if ( *gain > STEREO_DMX_EVS_SGC_GH ) + { + lr = 1.0f / ratio; + } + else if ( *gain < STEREO_DMX_EVS_SGC_GL ) + { + lr = ratio; + } + else + { + return; + } + + for ( n = 0; n < input_frame; n++ ) + { + data[n] *= *gain; + } + + *gain *= lr; +} + +#endif + + /*-------------------------------------------------------------------* * stereo_dmx_evs_enc() * @@ -1120,6 +1574,293 @@ void stereo_dmx_evs_enc( const bool is_binaural /* i : indication that input is binaural audio */ ) { +#ifdef NONBE_FIX_947_STEREO_DMX_EVS_PHA + + float dmx_weight, corr; + int16_t k, m, n, pha_len, fad_len, input_subframe, input_frame, n_fad_r, n_fad_g, m_fad_g, n_fad_cnt; + float data_f[CPE_CHANNELS][L_FRAME48k]; + float mem_prev[STEREO_DMX_EVS_FAD_LEN_MAX], data_mem[STEREO_DMX_EVS_DATA_LEN_MAX]; + float dmx_poc_data[L_FRAME48k], dmx_pha_data[L_FRAME48k], subframe_energy[STEREO_DMX_EVS_NB_SBFRM]; + float *p_data_mem, *p_prev_taps, *p_curr_taps, *p_data, *p_sub_frame; + float ftmp, *fad_g, *p_dmx_data, *p_dmx_data_fo; + bool is_transient; + STEREO_DMX_EVS_PRC prev_prc; + STEREO_DMX_EVS_PHA_HANDLE hPHA; + + if ( is_binaural ) + { + /* use of is_binaural flag is to be considered */ + } + + input_frame = (int16_t) ( input_Fs / FRAMES_PER_SEC ); + hPHA = hStereoDmxEVS->hPHA; + + for ( n = 0; n < input_frame; n++ ) + { + data_f[0][n] = (float) data[2 * n]; + data_f[1][n] = (float) data[2 * n + 1]; + } + if ( n_samples < input_frame ) + { + set_f( data_f[0] + n_samples, 0.0f, input_frame - n_samples ); + set_f( data_f[1] + n_samples, 0.0f, input_frame - n_samples ); + } + + input_subframe = n_samples / STEREO_DMX_EVS_NB_SBFRM; + is_transient = false; + for ( k = 0; k < CPE_CHANNELS; k++ ) + { + for ( m = 0; m < STEREO_DMX_EVS_NB_SBFRM; m++ ) + { + p_sub_frame = &( data_f[k][m * input_subframe] ); + subframe_energy[m] = sum2_f( p_sub_frame, input_subframe ); + if ( subframe_energy[m] > hPHA->crst_fctr * ( hPHA->trns_aux_energy[k] + EPSILON ) ) + { + is_transient = true; + } + + hPHA->trns_aux_energy[k] = STEREO_DMX_EVS_TRNS_EGY_FORGETTING * hPHA->trns_aux_energy[k] + ( 1.0f - STEREO_DMX_EVS_TRNS_EGY_FORGETTING ) * subframe_energy[m]; + } + + for ( m = 1; m < STEREO_DMX_EVS_NB_SBFRM; m++ ) + { + if ( subframe_energy[m] / ( subframe_energy[m - 1] + EPSILON ) > STEREO_DMX_EVS_TRNS_DTC_INST ) + { + is_transient = true; + } + } + } + + estimate_itd( &corr, hStereoDmxEVS->hPOC, hPHA, data_f[0], data_f[1], &hStereoDmxEVS->itd, input_frame ); + + /* poc */ + + if ( hStereoDmxEVS->itd ) + { + dmx_weight = ( ( hStereoDmxEVS->itd > 0 ) ? ( -1 ) : 1 ) * 0.5f * corr + 0.5f; + } + else + { + dmx_weight = 0.5f; + } + + create_M_signal( data_f[0], data_f[1], dmx_poc_data, dmx_weight, input_frame, hStereoDmxEVS->s_wnd, + hStereoDmxEVS->dmx_weight, hStereoDmxEVS->pre_dmx_energy, hStereoDmxEVS->aux_dmx_energy ); + + /* pha */ + + pha_len = hPHA->pha_len; + fad_len = hPHA->fad_len; + fad_g = hPHA->fad_g; + + set_zero( dmx_pha_data, n_samples ); + set_zero( mem_prev, fad_len ); + + for ( k = 0; k < CPE_CHANNELS; k++ ) + { + p_data = data_f[k]; + mvr2r( hPHA->data_mem[k], data_mem, pha_len ); + mvr2r( &( p_data[n_samples - pha_len] ), hPHA->data_mem[k], pha_len ); + p_data_mem = &( data_mem[pha_len] ); + mvr2r( p_data, p_data_mem, n_samples ); + + p_prev_taps = hPHA->p_prev_taps[k]; + if ( p_prev_taps ) + { + for ( n = 0; n < fad_len; n++ ) + { + for ( ftmp = 0, m = 0; m < pha_len; m++ ) + { + ftmp += p_data_mem[n - m] * p_prev_taps[m]; + } + mem_prev[n] += ftmp * INV_SQRT_2; + } + } + else + { + for ( n = 0; n < fad_len; n++ ) + { + mem_prev[n] += p_data[n] * INV_SQRT_2; + } + } + + p_curr_taps = hPHA->p_curr_taps[k]; + if ( p_curr_taps ) + { + for ( n = 0; n < n_samples; n++ ) + { + for ( ftmp = 0, m = 0; m < pha_len; m++ ) + { + ftmp += p_data_mem[n - m] * p_curr_taps[m]; + } + dmx_pha_data[n] += ftmp * INV_SQRT_2; + } + } + else + { + for ( n = 0; n < n_samples; n++ ) + { + dmx_pha_data[n] += p_data[n] * INV_SQRT_2; + } + } + } + + for ( n = 0, m = ( fad_len - 1 ); n < fad_len; n++, m-- ) + { + dmx_pha_data[n] *= fad_g[n]; + dmx_pha_data[n] += ( mem_prev[n] ) * fad_g[m]; + } + + /* prc switch */ + + prev_prc = hPHA->curr_prc; + if ( abs( (int16_t) hStereoDmxEVS->itd ) > hPHA->prc_thres ) + { + if ( hPHA->curr_prc != STEREO_DMX_EVS_PRC_POC ) + { + if ( hPHA->prev_prc == STEREO_DMX_EVS_PRC_POC ) + { + hPHA->prc_hys_cnt += 1; + } + else + { + hPHA->prc_hys_cnt = 0; + } + + if ( hPHA->prc_hys_cnt >= STEREO_DMX_EVS_SWTCH_PRC_HYS_THRES ) + { + hPHA->curr_prc = STEREO_DMX_EVS_PRC_POC; + } + } + hPHA->prev_prc = STEREO_DMX_EVS_PRC_POC; + } + else + { + if ( hPHA->curr_prc != STEREO_DMX_EVS_PRC_PHA ) + { + if ( hPHA->prev_prc == STEREO_DMX_EVS_PRC_PHA ) + { + hPHA->prc_hys_cnt += 1; + } + else + { + hPHA->prc_hys_cnt = 0; + } + + if ( hPHA->prc_hys_cnt >= STEREO_DMX_EVS_SWTCH_PRC_HYS_THRES ) + { + hPHA->curr_prc = STEREO_DMX_EVS_PRC_PHA; + } + } + hPHA->prev_prc = STEREO_DMX_EVS_PRC_PHA; + } + + if ( is_transient || ( hStereoDmxEVS->aux_dmx_energy[0] > STEREO_DMX_EVS_ILDS_EGY * hStereoDmxEVS->aux_dmx_energy[1] ) || ( hStereoDmxEVS->aux_dmx_energy[1] > STEREO_DMX_EVS_ILDS_EGY * hStereoDmxEVS->aux_dmx_energy[0] ) || ( hPHA->force_poc ) ) + { + hPHA->curr_prc = STEREO_DMX_EVS_PRC_POC; + hPHA->prc_hys_cnt = 0; + } + + calc_energy_sgc( dmx_poc_data, &( hPHA->dmx_poc_ener ), n_samples, STEREO_DMX_EVS_SGC_EGY_FORGETTING ); + calc_energy_sgc( dmx_pha_data, &( hPHA->dmx_pha_ener ), n_samples, STEREO_DMX_EVS_SGC_EGY_FORGETTING ); + + if ( ( prev_prc != hPHA->curr_prc ) && !is_transient && !( ( hPHA->dmx_pha_ener < hPHA->low_egy_thres_sgc ) && ( hPHA->dmx_poc_ener < hPHA->low_egy_thres_sgc ) ) ) + { + if ( hPHA->curr_prc == STEREO_DMX_EVS_PRC_POC ) + { + apply_gain_sgc( dmx_pha_data, &( hPHA->dmx_pha_gain_sgc ), STEREO_DMX_EVS_SGC_GR_S, n_samples ); + calc_energy_sgc( dmx_pha_data, &( hPHA->dmx_pha_ener_sgc ), n_samples, STEREO_DMX_EVS_SGC_EGY_FORGETTING ); + + hPHA->dmx_poc_gain_sgc = sqrtf( hPHA->dmx_pha_ener_sgc / ( hPHA->dmx_poc_ener + EPSILON ) ); + hPHA->dmx_poc_gain_sgc = min( hPHA->dmx_poc_gain_sgc, STEREO_DMX_EVS_SGC_GMAX ); + hPHA->dmx_poc_gain_sgc = max( hPHA->dmx_poc_gain_sgc, STEREO_DMX_EVS_SGC_GMIN ); + + apply_gain_sgc( dmx_poc_data, &( hPHA->dmx_poc_gain_sgc ), STEREO_DMX_EVS_SGC_GR_S, n_samples ); + calc_energy_sgc( dmx_poc_data, &( hPHA->dmx_poc_ener_sgc ), n_samples, STEREO_DMX_EVS_SGC_EGY_FORGETTING ); + } + else + { + apply_gain_sgc( dmx_poc_data, &( hPHA->dmx_poc_gain_sgc ), STEREO_DMX_EVS_SGC_GR_S, n_samples ); + calc_energy_sgc( dmx_poc_data, &( hPHA->dmx_poc_ener_sgc ), n_samples, STEREO_DMX_EVS_SGC_EGY_FORGETTING ); + + hPHA->dmx_pha_gain_sgc = sqrtf( hPHA->dmx_poc_ener_sgc / ( hPHA->dmx_pha_ener + EPSILON ) ); + hPHA->dmx_pha_gain_sgc = min( hPHA->dmx_pha_gain_sgc, STEREO_DMX_EVS_SGC_GMAX ); + hPHA->dmx_pha_gain_sgc = max( hPHA->dmx_pha_gain_sgc, STEREO_DMX_EVS_SGC_GMIN ); + + apply_gain_sgc( dmx_pha_data, &( hPHA->dmx_pha_gain_sgc ), STEREO_DMX_EVS_SGC_GR_S, n_samples ); + calc_energy_sgc( dmx_pha_data, &( hPHA->dmx_pha_ener_sgc ), n_samples, STEREO_DMX_EVS_SGC_EGY_FORGETTING ); + } + } + else + { + apply_gain_sgc( dmx_poc_data, &( hPHA->dmx_poc_gain_sgc ), STEREO_DMX_EVS_SGC_GR_S, n_samples ); + calc_energy_sgc( dmx_poc_data, &( hPHA->dmx_poc_ener_sgc ), n_samples, STEREO_DMX_EVS_SGC_EGY_FORGETTING ); + + apply_gain_sgc( dmx_pha_data, &( hPHA->dmx_pha_gain_sgc ), STEREO_DMX_EVS_SGC_GR_S, n_samples ); + calc_energy_sgc( dmx_pha_data, &( hPHA->dmx_pha_ener_sgc ), n_samples, STEREO_DMX_EVS_SGC_EGY_FORGETTING ); + } + + if ( hPHA->curr_prc == STEREO_DMX_EVS_PRC_POC ) + { + p_dmx_data = dmx_poc_data; + p_dmx_data_fo = dmx_pha_data; + } + else + { + p_dmx_data = dmx_pha_data; + p_dmx_data_fo = dmx_poc_data; + } + + n_fad_r = is_transient ? 1 : STEREO_DMX_EVS_FAD_R; + + if ( prev_prc != hPHA->curr_prc ) + { + if ( hPHA->n_fad_g == input_frame ) + { + hPHA->n_fad_g = 0; + hPHA->n_fad_cnt = 0; + } + else + { + hPHA->n_fad_g = input_frame - hPHA->n_fad_g - 1; + hPHA->n_fad_cnt = is_transient ? 0 : n_fad_r - hPHA->n_fad_cnt; + } + } + else if ( is_transient ) + { + hPHA->n_fad_cnt = 0; + } + + fad_len = min( n_samples, ( ( input_frame * n_fad_r ) - ( hPHA->n_fad_g * n_fad_r + hPHA->n_fad_cnt ) ) ); + + if ( fad_len != 0 ) + { + fad_g = hPHA->fad_g_prc; + n_fad_g = hPHA->n_fad_g; + n_fad_cnt = hPHA->n_fad_cnt; + m_fad_g = input_frame - n_fad_g - 1; + + for ( n = 0; n < fad_len; n++ ) + { + p_dmx_data[n] *= fad_g[n_fad_g]; + p_dmx_data[n] += fad_g[m_fad_g] * p_dmx_data_fo[n]; + + if ( ++n_fad_cnt == n_fad_r ) + { + n_fad_cnt = 0; + n_fad_g++; + m_fad_g--; + } + } + + hPHA->n_fad_g = n_fad_g; + hPHA->n_fad_cnt = n_fad_cnt; + } + + mvr2s( p_dmx_data, data, n_samples ); + +#else + int16_t n; float dmx_weight, corr; float data_f[CPE_CHANNELS][L_FRAME48k]; @@ -1358,6 +2099,7 @@ void stereo_dmx_evs_enc( mvr2s( p_dmx_data, data, n_samples ); +#endif return; } @@ -1378,7 +2120,11 @@ ivas_error stereo_dmx_evs_init_encoder( int16_t n, input_frame; int16_t m, len, pha_len, fad_len, fad_len2, trans_len, itrh, rfft_ipd_coef_step, n0, input_frame_pha; +#ifdef NONBE_FIX_947_STEREO_DMX_EVS_PHA + float *win, *fad_g, fad_r, tmp_r, a_step, *ipd_ff; +#else float *win, *fad_g, fad_r, tmp_r, a_min, a_max, a_step, *ipd_ff; +#endif const float *p_ipd_w; input_frame = (int16_t) ( input_Fs / FRAMES_PER_SEC ); @@ -1423,7 +2169,12 @@ ivas_error stereo_dmx_evs_init_encoder( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for STEREO_DMX_EVS_POC_DATA\n" ) ); } +#ifdef BE_FIX_567_DOUBLE_STEREO_DMX + hStereoDmxEVS->hPOC->shift_limit = NS2SA( input_Fs, STEREO_DMX_EVS_SHIFT_LIMIT ); +#else hStereoDmxEVS->hPOC->shift_limit = (int16_t) ( STEREO_DMX_EVS_SHIFT_LIMIT * input_Fs / 1000 ); +#endif + for ( n = 0; n < CPE_CHANNELS; n++ ) { hStereoDmxEVS->hPOC->peakQ[n] = 0.0f; @@ -1491,6 +2242,9 @@ ivas_error stereo_dmx_evs_init_encoder( hStereoDmxEVS->hPHA->fad_len = STEREO_DMX_EVS_FAD_LEN_16; hStereoDmxEVS->hPHA->prc_thres = STEREO_DMX_EVS_SWTCH_PRC_THRES_16; hStereoDmxEVS->hPHA->crst_fctr = STEREO_DMX_EVS_CRST_FCTR_16; +#ifdef NONBE_FIX_947_STEREO_DMX_EVS_PHA + hStereoDmxEVS->hPHA->low_egy_thres_sgc = STEREO_DMX_EVS_SGC_LEGY_THRES_16; +#endif } else if ( input_Fs == 32000 ) { @@ -1498,6 +2252,9 @@ ivas_error stereo_dmx_evs_init_encoder( hStereoDmxEVS->hPHA->fad_len = STEREO_DMX_EVS_FAD_LEN_32; hStereoDmxEVS->hPHA->prc_thres = STEREO_DMX_EVS_SWTCH_PRC_THRES_32; hStereoDmxEVS->hPHA->crst_fctr = STEREO_DMX_EVS_CRST_FCTR_32; +#ifdef NONBE_FIX_947_STEREO_DMX_EVS_PHA + hStereoDmxEVS->hPHA->low_egy_thres_sgc = STEREO_DMX_EVS_SGC_LEGY_THRES_32; +#endif } else if ( input_Fs == 48000 ) { @@ -1505,6 +2262,9 @@ ivas_error stereo_dmx_evs_init_encoder( hStereoDmxEVS->hPHA->fad_len = STEREO_DMX_EVS_FAD_LEN_48; hStereoDmxEVS->hPHA->prc_thres = STEREO_DMX_EVS_SWTCH_PRC_THRES_48; hStereoDmxEVS->hPHA->crst_fctr = STEREO_DMX_EVS_CRST_FCTR_48; +#ifdef NONBE_FIX_947_STEREO_DMX_EVS_PHA + hStereoDmxEVS->hPHA->low_egy_thres_sgc = STEREO_DMX_EVS_SGC_LEGY_THRES_48; +#endif } else { @@ -1512,7 +2272,9 @@ ivas_error stereo_dmx_evs_init_encoder( } hStereoDmxEVS->hPHA->pha_len = len / 2; +#ifndef NONBE_FIX_947_STEREO_DMX_EVS_PHA hStereoDmxEVS->hPHA->init_frmCntr = (int16_t) ( FRAMES_PER_SEC * 0.2f ); +#endif hStereoDmxEVS->hPHA->isd_rate_s = 0.0f; hStereoDmxEVS->hPHA->iccr_s = 0.0f; @@ -1520,13 +2282,21 @@ ivas_error stereo_dmx_evs_init_encoder( fad_len = hStereoDmxEVS->hPHA->fad_len; trans_len = (int16_t) ( (float) pha_len / 20.0f ); +#ifdef NONBE_FIX_947_STEREO_DMX_EVS_PHA + set_f( hStereoDmxEVS->hPHA->win, STEREO_DMX_EVS_PHA_WND_C, pha_len - trans_len ); +#else set_f( hStereoDmxEVS->hPHA->win, 1.8f, pha_len - trans_len ); +#endif hStereoDmxEVS->hPHA->win[0] = 1.0f; tmp_r = 1.0f / ( ( trans_len * 2 ) + 1 ); win = &( hStereoDmxEVS->hPHA->win[pha_len - trans_len] ); for ( n = 0; n < trans_len; n++ ) { +#ifdef NONBE_FIX_947_STEREO_DMX_EVS_PHA + win[n] = ( 0.5f * ( 1.0f + cosf( ( PI2 * ( n + 1 ) ) * tmp_r ) ) ) * STEREO_DMX_EVS_PHA_WND_C; +#else win[n] = ( 0.5f * ( 1.0f + cosf( ( PI2 * ( n + 1 ) ) * tmp_r ) ) ) * 1.8f; +#endif } fad_g = hStereoDmxEVS->hPHA->fad_g; @@ -1542,6 +2312,39 @@ ivas_error stereo_dmx_evs_init_encoder( hStereoDmxEVS->hPHA->prev_pha = STEREO_DMX_EVS_PHA_IPD; hStereoDmxEVS->hPHA->pha_hys_cnt = 0; +#ifdef NONBE_FIX_947_STEREO_DMX_EVS_PHA + + hStereoDmxEVS->hPHA->pha_ipd_chan_cnt = 0; + hStereoDmxEVS->hPHA->pha_ipd_chan_thresh = 10; + hStereoDmxEVS->hPHA->pha_ipd_ild_thresh = STEREO_DMX_EVS_IPD_ILD_THRES; + hStereoDmxEVS->hPHA->pha_ipd_chan2rephase = 1; + hStereoDmxEVS->hPHA->pha_ipd_previouschan2rephase = 1; + hStereoDmxEVS->hPHA->pha_ipd_chanswitch = 0; + hStereoDmxEVS->hPHA->pha_ipd_chanswitch_allowed = 0; + hStereoDmxEVS->hPHA->pha_ipd_sf_Threshold = STEREO_DMX_EVS_IPD_SF_THRES; + + hStereoDmxEVS->hPHA->proc_pha = STEREO_DMX_EVS_PHA_IPD; + hStereoDmxEVS->hPHA->force_poc = FALSE; + + /* Compute the forgetting factor */ + itrh = (int16_t) ( ( STEREO_DMX_EVS_IFF_FREQ * input_frame ) / ( input_Fs * STEREO_DMX_EVS_SUBBAND_SIZE ) ); + n0 = L_FRAME16k / ( 2 * STEREO_DMX_EVS_SUBBAND_SIZE ); + a_step = ( STEREO_DMX_EVS_IFF_AMIN - STEREO_DMX_EVS_IFF_AMAX ) / ( n0 + 1 - itrh ); + ipd_ff = hStereoDmxEVS->hPHA->ipd_ff; + for ( n = 0; n < itrh; n++ ) + { + ipd_ff[n] = STEREO_DMX_EVS_IFF_AMAX; + } + for ( ; n < ( n0 + 1 ); n++ ) /* 8kHz */ + { + ipd_ff[n] = STEREO_DMX_EVS_IFF_AMAX + ( n - itrh ) * a_step; + } + for ( ; n < STEREO_DMX_EVS_NB_SUBBAND_MAX; n++ ) + { + ipd_ff[n] = STEREO_DMX_EVS_IFF_AMIN; + } +#else + /* Compute the forgetting factor */ a_min = 0.8576958985908941f; a_max = 0.9440608762859234f; @@ -1561,6 +2364,8 @@ ivas_error stereo_dmx_evs_init_encoder( { ipd_ff[n] = a_min; } + +#endif set_f( hStereoDmxEVS->hPHA->Pr, 1.0, STEREO_DMX_EVS_NB_SUBBAND_MAX ); set_zero( hStereoDmxEVS->hPHA->Pi, STEREO_DMX_EVS_NB_SUBBAND_MAX ); @@ -1600,8 +2405,10 @@ ivas_error stereo_dmx_evs_init_encoder( hStereoDmxEVS->hPHA->prev_prc = STEREO_DMX_EVS_PRC_POC; hStereoDmxEVS->hPHA->prc_hys_cnt = 0; +#ifndef NONBE_FIX_947_STEREO_DMX_EVS_PHA hStereoDmxEVS->hPHA->fad_len_prc = (int16_t) ( STEREO_DMX_EVS_FADE_LEN_PRC * (float) input_Fs / 1000.0f ); - fad_len = hStereoDmxEVS->hPHA->fad_len_prc; +#endif + fad_len = input_frame; fad_g = hStereoDmxEVS->hPHA->fad_g_prc; fad_r = 1.0f / (float) ( fad_len + 1 ); fad_len2 = fad_len / 2; @@ -1616,6 +2423,21 @@ ivas_error stereo_dmx_evs_init_encoder( hStereoDmxEVS->hPHA->trns_aux_energy[n] = 0.0f; } +#ifdef NONBE_FIX_947_STEREO_DMX_EVS_PHA + + hStereoDmxEVS->hPHA->n_fad_g = input_frame; + hStereoDmxEVS->hPHA->n_fad_cnt = 0; + + hStereoDmxEVS->hPHA->dmx_pha_ener_sgc = 0.0f; + hStereoDmxEVS->hPHA->dmx_poc_ener_sgc = 0.0f; + hStereoDmxEVS->hPHA->dmx_pha_gain_sgc = 1.0f; + hStereoDmxEVS->hPHA->dmx_poc_gain_sgc = 1.0f; + + hStereoDmxEVS->hPHA->dmx_pha_ener = 0.0f; + hStereoDmxEVS->hPHA->dmx_poc_ener = 0.0f; + +#endif + *hStereoDmxEVS_out = hStereoDmxEVS; return IVAS_ERR_OK; diff --git a/lib_enc/swb_tbe_enc.c b/lib_enc/swb_tbe_enc.c index 135e856a990dee3f7efa2aae09c465498791ed4a..9fab9da4387e73525ba716365cd318da73135165 100644 --- a/lib_enc/swb_tbe_enc.c +++ b/lib_enc/swb_tbe_enc.c @@ -2738,6 +2738,12 @@ void fb_tbe_enc( hBWE_TD->prev_fb_energy = sum2_f( input_fhb + L_FRAME48k / 2, L_FRAME48k / 2 ); fb_exc_energy = sum2_f( fb_exc, L_FRAME16k ) + EPSILON; ratio = (float) sqrt( temp2 / fb_exc_energy ); +#ifdef FIX_971_LOG2_IDX_GAIN_0 + if ( ratio < 1.0f ) + { + ratio = 1.0f; + } +#endif idxGain = (int16_t) ( log2_f( (float) ratio ) + 0.5f ); idxGain = max( 0, min( 15, idxGain ) ); ratio = (float) ( 1 << idxGain ); diff --git a/lib_rend/ivas_crend.c b/lib_rend/ivas_crend.c index 26462c3a246f6009bf216c6142faabcb7dd4fe36..fedb722b4e248ce10e4c9348e53e6a088c8bf44f 100644 --- a/lib_rend/ivas_crend.c +++ b/lib_rend/ivas_crend.c @@ -1369,7 +1369,11 @@ ivas_error ivas_rend_openMultiBinCrend( ivas_error error; #ifdef SPLIT_REND_WITH_HEAD_ROT +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + if ( ( error = ivas_rend_openCrend( pCrend, inConfig, outConfig, NULL /*hRendCfg*/, NULL, NULL /* hHrtfStatistics */, output_Fs, pMultiBinPoseData->num_poses ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_rend_openCrend( pCrend, inConfig, outConfig, NULL /*hRendCfg*/, NULL, output_Fs, pMultiBinPoseData->num_poses ) ) != IVAS_ERR_OK ) +#endif #else if ( ( error = ivas_rend_openCrend( pCrend, inConfig, outConfig, NULL /*hRendCfg*/, NULL, output_Fs ) ) != IVAS_ERR_OK ) #endif @@ -1394,6 +1398,9 @@ ivas_error ivas_rend_openCrend( const AUDIO_CONFIG outConfig, RENDER_CONFIG_DATA *hRendCfg, HRTFS_CREND_HANDLE hSetOfHRTF, +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + HRTFS_STATISTICS_HANDLE hHrtfStatistics, +#endif #ifdef SPLIT_REND_WITH_HEAD_ROT const int32_t output_Fs, const int16_t num_poses @@ -1568,7 +1575,11 @@ ivas_error ivas_rend_openCrend( if ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) { +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + if ( ( error = ivas_reverb_open( &( hCrend->hReverb ), hHrtfStatistics, hRendCfg, output_Fs ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_reverb_open( &( hCrend->hReverb ), inConfig, ( *pCrend )->hHrtfCrend, NULL, hRendCfg, output_Fs ) ) != IVAS_ERR_OK ) +#endif { return error; } diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index 936d68b4047e4e9910bb873d5b7a420d234af6a8..6909945ff6a3775173462320b6f3331e89d177f9 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -239,8 +239,12 @@ ivas_error ivas_dirac_dec_init_binaural_data( if ( hDiracDecBin->hReverb == NULL ) #endif { - /* 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 ) +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + if ( ( error = ivas_binaural_reverb_init( &hDiracDecBin->hReverb, st_ivas->hHrtfStatistics, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, &( st_ivas->hRenderConfig->roomAcoustics ), output_Fs, st_ivas->hHrtfParambin->parametricReverberationTimes, st_ivas->hHrtfParambin->parametricReverberationEneCorrections ) ) != IVAS_ERR_OK ) +#else + /* 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 ) +#endif { return error; } diff --git a/lib_rend/ivas_hrtf.c b/lib_rend/ivas_hrtf.c index f03b9a9a8690ffe316fd0a1fc350e034fb390c08..1f943595be2ffc1f3db2bec15951ff9e0a0bfbcc 100644 --- a/lib_rend/ivas_hrtf.c +++ b/lib_rend/ivas_hrtf.c @@ -37,6 +37,9 @@ #include "ivas_error.h" #include "wmc_auto.h" #include "ivas_prot.h" +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES +#include "ivas_rom_binaural_crend_head.h" +#endif /*-----------------------------------------------------------------------* * ivas_HRTF_binary_open() @@ -214,3 +217,98 @@ void ivas_HRTF_parambin_binary_close( return; } + +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES +/*-----------------------------------------------------------------------* + * ivas_HRTF_statistics_binary_open() + * + * Allocate HRTF binary handle for statistics handler + *-----------------------------------------------------------------------*/ + +ivas_error ivas_HRTF_statistics_binary_open( + HRTFS_STATISTICS **hHrtfStatistics ) +{ + *hHrtfStatistics = (HRTFS_STATISTICS *) malloc( sizeof( HRTFS_STATISTICS ) ); + if ( *hHrtfStatistics == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for statistics HRTF tables!" ); + } + + return IVAS_ERR_OK; +} + + +/*-----------------------------------------------------------------------* + * ivas_HRTF_statistics_close() + * + * Close HRTF binary handle for statistics handler + *-----------------------------------------------------------------------*/ + +void ivas_HRTF_statistics_close( + HRTFS_STATISTICS **hHrtfStatistics ) +{ + if ( hHrtfStatistics == NULL || *hHrtfStatistics == NULL ) + { + return; + } + + free( *hHrtfStatistics ); + *hHrtfStatistics = NULL; + + return; +} + +/*-----------------------------------------------------------------------* + * ivas_HRTF_statistics_init() + * + * Allocates HRTF statistics handle and initializes from ROM + *-----------------------------------------------------------------------*/ + +ivas_error ivas_HRTF_statistics_init( + HRTFS_STATISTICS_HANDLE *hHrtfStatistics, + int32_t sampleRate ) +{ + HRTFS_STATISTICS *HrtfStatistics; + + if ( hHrtfStatistics != NULL && *hHrtfStatistics != NULL ) + { + /* Tables already loaded from file */ + return IVAS_ERR_OK; + } + + /* Initialise tables from ROM */ + if ( ( HrtfStatistics = (HRTFS_STATISTICS *) malloc( sizeof( HRTFS_STATISTICS ) ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for statistics HRTF tables!" ); + } + + HrtfStatistics->average_energy_l = NULL; + HrtfStatistics->average_energy_r = NULL; + HrtfStatistics->inter_aural_coherence = NULL; + + switch ( sampleRate ) + { + case 48000: + HrtfStatistics->average_energy_l = defaultHRIR_left_avg_power_48kHz; + HrtfStatistics->average_energy_r = defaultHRIR_right_avg_power_48kHz; + HrtfStatistics->inter_aural_coherence = defaultHRIR_coherence_48kHz; + break; + case 32000: + HrtfStatistics->average_energy_l = defaultHRIR_left_avg_power_32kHz; + HrtfStatistics->average_energy_r = defaultHRIR_right_avg_power_32kHz; + HrtfStatistics->inter_aural_coherence = defaultHRIR_coherence_32kHz; + break; + case 16000: + HrtfStatistics->average_energy_l = defaultHRIR_left_avg_power_16kHz; + HrtfStatistics->average_energy_r = defaultHRIR_right_avg_power_16kHz; + HrtfStatistics->inter_aural_coherence = defaultHRIR_coherence_16kHz; + break; + } + HrtfStatistics->fromROM = TRUE; + + *hHrtfStatistics = HrtfStatistics; + + + return IVAS_ERR_OK; +} +#endif diff --git a/lib_rend/ivas_objectRenderer_mix.c b/lib_rend/ivas_objectRenderer_mix.c index 2a72b1d3023238fe7f9a06d86e88517102de1410..72d1921d6283738051f71c7740907cbc5188e461 100644 --- a/lib_rend/ivas_objectRenderer_mix.c +++ b/lib_rend/ivas_objectRenderer_mix.c @@ -404,6 +404,8 @@ static ivas_error DefaultBSplineModel( model = &( HrFiltSet_p->ModelParams ); modelITD = &( HrFiltSet_p->ModelParamsITD ); +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES +#else switch ( output_Fs ) { case 48000: @@ -422,6 +424,7 @@ static ivas_error DefaultBSplineModel( HrFiltSet_p->lr_energy_and_iac[2] = defaultHRIR_coherence_16kHz; break; } +#endif /* Set ROM flag for correct deallocation */ model->modelROM = TRUE; diff --git a/lib_rend/ivas_orient_trk.c b/lib_rend/ivas_orient_trk.c index f4332a3b6839670d545ab323904be06faea711ec..0f2c694875fe111effc2388ddb7d3768c0baa2dd 100644 --- a/lib_rend/ivas_orient_trk.c +++ b/lib_rend/ivas_orient_trk.c @@ -545,11 +545,7 @@ ivas_error ivas_orient_trk_SetReferenceVector( case IVAS_HEAD_ORIENT_TRK_REF: case IVAS_HEAD_ORIENT_TRK_AVG: case IVAS_HEAD_ORIENT_TRK_REF_VEC: -#ifdef FIX_954_OTR_REF_VEC acousticFrontVector = VectorSubtract( refPos, listenerPos ); -#else - acousticFrontVector = VectorSubtract( listenerPos, refPos ); -#endif break; case IVAS_HEAD_ORIENT_TRK_REF_VEC_LEV: /* ignore the height difference between listener position and reference position */ @@ -558,11 +554,7 @@ ivas_error ivas_orient_trk_SetReferenceVector( listenerPosLevel.y = listenerPos.y; refPosLevel.x = refPos.x; refPosLevel.y = refPos.y; -#ifdef FIX_954_OTR_REF_VEC acousticFrontVector = VectorSubtract( refPosLevel, listenerPosLevel ); -#else - acousticFrontVector = VectorSubtract( listenerPosLevel, refPosLevel ); -#endif break; default: return IVAS_ERR_WRONG_PARAMS; @@ -576,11 +568,7 @@ ivas_error ivas_orient_trk_SetReferenceVector( return IVAS_ERR_WRONG_PARAMS; } -#ifdef FIX_954_OTR_REF_VEC ivasForwardVector.x = 1.0f; -#else - ivasForwardVector.x = -1.0f; -#endif ivasForwardVector.y = 0.0f; ivasForwardVector.z = 0.0f; VectorRotationToQuaternion( ivasForwardVector, acousticFrontVector, &pOTR->refRot ); diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index 53d48eaa4956a432f4bcb625bc7e3945e6c118ff..7dcea4363bf99123322a4f688fda0f4068ed2363 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -616,6 +616,21 @@ void ivas_HRTF_CRend_binary_close( HRTFS_CREND **hSetOfHRTF /* i/o: Set of HRTF handle */ ); +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES +ivas_error ivas_HRTF_statistics_init( + HRTFS_STATISTICS_HANDLE *hHrtfStatistics, /* i/o: HRTF statistics structure */ + int32_t sampleRate /* i : Sample rate */ +); + +void ivas_HRTF_statistics_close( + HRTFS_STATISTICS **hHrtfStatistics /* i/o: HRTF statistics structure */ +); + +ivas_error ivas_HRTF_statistics_binary_open( + HRTFS_STATISTICS **hHrtfStatistics /* i/o: HRTF statistics structure */ +); + +#endif /*----------------------------------------------------------------------------------* * TD object renderer @@ -888,6 +903,9 @@ ivas_error ivas_rend_openCrend( const AUDIO_CONFIG outConfig, RENDER_CONFIG_DATA *hRendCfg, HRTFS_CREND_HANDLE hSetOfHRTF, +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + HRTFS_STATISTICS_HANDLE hHrtfStatistics, +#endif #ifdef SPLIT_REND_WITH_HEAD_ROT const int32_t output_Fs, const int16_t num_poses @@ -942,16 +960,34 @@ ivas_error ivas_rend_crendProcessSubframe( * Reverberator *----------------------------------------------------------------------------------*/ +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES +ivas_error ivas_binaural_reverb_init( +#else ivas_error ivas_binaural_reverb_open_fastconv( +#endif REVERB_STRUCT_HANDLE *hReverbPr, /* i/o: binaural reverb handle */ +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + const HRTFS_STATISTICS_HANDLE hHrtfStatistics, /* i : HRTF statistics handle */ +#else +#endif const int16_t numBins, /* i : number of CLDFB bins */ const int16_t numCldfbSlotsPerFrame, /* i : number of CLDFB slots per frame */ +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + const IVAS_ROOM_ACOUSTICS_CONFIG_DATA *roomAcoustics, /* i/o: room acoustics parameters */ +#else IVAS_ROOM_ACOUSTICS_CONFIG_DATA *roomAcoustics, /* i/o: room acoustics parameters */ const AUDIO_CONFIG internal_config, /* i : internal audio config for FastConv */ +#endif const int32_t sampling_rate, /* i : sampling rate */ +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + const float *defaultTimes, /* i : default reverberation times */ + const float *defaultEne /* i : default reverberation energies */ +#else const HRTFS_FASTCONV_HANDLE hHrtfFastConv /* i : FastConv HRTF handle */ +#endif ); +#ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES ivas_error ivas_binaural_reverb_open_parambin( REVERB_STRUCT_HANDLE *hReverbPr, /* i/o: binaural reverb handle */ const int16_t numBins, /* i : number of CLDFB bins */ @@ -960,6 +996,7 @@ ivas_error ivas_binaural_reverb_open_parambin( const int32_t sampling_rate, /* i : sampling rate */ const HRTFS_PARAMBIN_HANDLE hHrtfParambin /* i : Parametric binauralizer HRTF handle */ ); +#endif void ivas_binaural_reverb_close( REVERB_STRUCT_HANDLE *hReverb /* i/o: binaural reverb handle */ @@ -977,9 +1014,13 @@ void ivas_binaural_reverb_processSubframe( ivas_error ivas_reverb_open( REVERB_HANDLE *hReverb, /* i/o: Reverberator handle */ +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + const HRTFS_STATISTICS_HANDLE hHrtfStatistics, /* i : HRTF statistics handle */ +#else const AUDIO_CONFIG input_audio_config, /* i : reverb. input audio configuration */ const HRTFS_HANDLE hHrtf, /* i : HRTF handle */ const float *lr_energy_and_iac[], /* i : precomuputed lr energies and iac */ +#endif RENDER_CONFIG_DATA *pConfig, /* i : Reverb configuration */ const int32_t output_Fs /* i : output sampling rate */ ); @@ -1136,6 +1177,14 @@ void ivas_reverb_calc_color_levels( float *pTarget_color_R ); +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES +ivas_error ivas_reverb_prepare_cldfb_params( + const IVAS_ROOM_ACOUSTICS_CONFIG_DATA *pInput_params, + const HRTFS_STATISTICS_HANDLE hHrtfStatistics, + const int32_t output_Fs, + float *pOutput_t60, + float *pOutput_ene ); +#else ivas_error ivas_reverb_prepare_cldfb_params( IVAS_ROOM_ACOUSTICS_CONFIG_DATA *pInput_params, const HRTFS_FASTCONV_HANDLE hHrtfFastConv, @@ -1144,6 +1193,7 @@ ivas_error ivas_reverb_prepare_cldfb_params( const int32_t output_Fs, float *pOutput_t60, float *pOutput_ene ); +#endif void ivas_reverb_interpolate_acoustic_data( const int16_t input_table_size, @@ -1156,6 +1206,7 @@ void ivas_reverb_interpolate_acoustic_data( float *pOutput_dsr ); +#ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES void ivas_reverb_get_hrtf_set_properties( float **ppHrtf_set_L_re, float **ppHrtf_set_L_im, @@ -1169,7 +1220,7 @@ void ivas_reverb_get_hrtf_set_properties( float *pOut_avg_pwr_R, float *pOut_i_a_coherence ); - +#endif /*---------------------------------------------------------------------------------* * Shoebox Prototypes diff --git a/lib_rend/ivas_reverb.c b/lib_rend/ivas_reverb.c index 537ecde2c294e90f1f6f071000ad4f6fc24cb1c1..d85506bdbbad95c1f1842228a707cff63a97a556 100644 --- a/lib_rend/ivas_reverb.c +++ b/lib_rend/ivas_reverb.c @@ -939,15 +939,26 @@ static void set_fft_and_datablock_sizes( static void set_reverb_acoustic_data( ivas_reverb_params_t *pParams, +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES +#else const AUDIO_CONFIG input_audio_config, const HRTFS_HANDLE hHrtf, +#endif IVAS_ROOM_ACOUSTICS_CONFIG_DATA *pRoomAcoustics, +#ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES const int16_t subframe_len, +#endif const int16_t nr_fc_input, const int16_t nr_fc_fft_filter ) { +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + int16_t bin_idx; +#else int16_t nr_out_ch, hrtf_idx, offset, iter_idx, bin_idx; +#endif float ln_1e6_inverted, delay_diff, exp_argument; +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES +#else float *pHrtf_set_l_re[MAX_INTERN_CHANNELS]; float *pHrtf_set_l_im[MAX_INTERN_CHANNELS]; float *pHrtf_set_r_re[MAX_INTERN_CHANNELS]; @@ -990,6 +1001,7 @@ static void set_reverb_acoustic_data( pParams->pHrtf_inter_aural_coherence_const = (const float *) pParams->pHrtf_inter_aural_coherence; } +#endif /* interpolate input table data for T60 and DSR to the FFT filter grid */ ivas_reverb_interpolate_acoustic_data( nr_fc_input, pRoomAcoustics->pFc_input, pRoomAcoustics->pAcoustic_rt60, pRoomAcoustics->pAcoustic_dsr, nr_fc_fft_filter, pParams->pFc, pParams->pRt60, pParams->pDsr ); @@ -1083,12 +1095,16 @@ static ivas_error setup_FDN_branches( *------------------------------------------------------------------------*/ ivas_error ivas_reverb_open( - REVERB_HANDLE *hReverb, /* i/o: Reverberator handle */ + REVERB_HANDLE *hReverb, /* i/o: Reverberator handle */ +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + const HRTFS_STATISTICS_HANDLE hHrtfStatistics, /* i : HRTF statistics handle */ +#else const AUDIO_CONFIG input_audio_config, /* i : reverb. input audio configuration */ const HRTFS_HANDLE hHrtf, /* i : HRTF handle */ const float *lr_energy_and_iac[], /* i : precomuputed lr energies and iac */ - RENDER_CONFIG_HANDLE hRenderConfig, /* i : Renderer configuration handle */ - const int32_t output_Fs /* i : output sampling rate */ +#endif + RENDER_CONFIG_HANDLE hRenderConfig, /* i : Renderer configuration handle */ + const int32_t output_Fs /* i : output sampling rate */ ) { ivas_error error; @@ -1160,6 +1176,12 @@ ivas_error ivas_reverb_open( params.pFc[bin_idx] = freq_step * bin_idx; } +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + set_reverb_acoustic_data( ¶ms, &hRenderConfig->roomAcoustics, nr_fc_input, nr_fc_fft_filter ); + params.pHrtf_avg_pwr_response_l_const = hHrtfStatistics->average_energy_l; + params.pHrtf_avg_pwr_response_r_const = hHrtfStatistics->average_energy_r; + params.pHrtf_inter_aural_coherence_const = hHrtfStatistics->inter_aural_coherence; +#else if ( hHrtf == NULL && lr_energy_and_iac != NULL ) { params.pHrtf_avg_pwr_response_l_const = lr_energy_and_iac[0]; @@ -1168,6 +1190,7 @@ ivas_error ivas_reverb_open( } /* set up reverb acoustic data on the basis of HRTF data and renderer config */ set_reverb_acoustic_data( ¶ms, input_audio_config, hHrtf, &hRenderConfig->roomAcoustics, subframe_len, nr_fc_input, nr_fc_fft_filter ); +#endif /* set reverb acoustic configuration based on renderer config */ #ifdef DEBUGGING @@ -1880,7 +1903,56 @@ static ivas_error ivas_binaural_reverb_open( return IVAS_ERR_OK; } +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES +/*------------------------------------------------------------------------- + * ivas_binaural_reverb_init() + * + * Allocate and initialize binaural room reverberator handle + * for CLDFB renderers + *------------------------------------------------------------------------*/ +ivas_error ivas_binaural_reverb_init( + REVERB_STRUCT_HANDLE *hReverbPr, /* i/o: binaural reverb handle */ + const HRTFS_STATISTICS_HANDLE hHrtfStatistics, /* i : HRTF statistics handle */ + const int16_t numBins, /* i : number of CLDFB bins */ + const int16_t numCldfbSlotsPerFrame, /* i : number of CLDFB slots per frame */ + const IVAS_ROOM_ACOUSTICS_CONFIG_DATA *roomAcoustics, /* i/o: room acoustics parameters */ + const int32_t sampling_rate, /* i : sampling rate */ + const float *defaultTimes, /* i : default reverberation times */ + const float *defaultEne /* i : default reverberation energies */ +) +{ + ivas_error error; + const float *revTimes; + const float *revEne; + float t60[CLDFB_NO_CHANNELS_MAX]; + float ene[CLDFB_NO_CHANNELS_MAX]; + int16_t preDelay; + error = IVAS_ERR_OK; + + if ( ( roomAcoustics != NULL ) && roomAcoustics->override ) + { + revTimes = t60; + revEne = ene; + + if ( ( error = ivas_reverb_prepare_cldfb_params( roomAcoustics, hHrtfStatistics, sampling_rate, t60, ene ) ) != IVAS_ERR_OK ) + { + return error; + } + preDelay = (int16_t) roundf( 48000.0f * roomAcoustics->acousticPreDelay / CLDFB_NO_CHANNELS_MAX ); + } + else + { + revTimes = defaultTimes; + revEne = defaultEne; + preDelay = 10; + } + + error = ivas_binaural_reverb_open( hReverbPr, numBins, numCldfbSlotsPerFrame, sampling_rate, revTimes, revEne, preDelay ); + + return error; +} +#else /*------------------------------------------------------------------------- * ivas_binaural_reverb_open_fastconv() * @@ -1975,7 +2047,7 @@ ivas_error ivas_binaural_reverb_open_parambin( return error; } - +#endif /*------------------------------------------------------------------------- * ivas_binaural_reverb_close() diff --git a/lib_rend/ivas_reverb_filter_design.c b/lib_rend/ivas_reverb_filter_design.c index 14ab7c52d4abd66e7d0680c415f09cff56c6b01d..e90efe1307200c28b6fed8abe64822b309137c29 100644 --- a/lib_rend/ivas_reverb_filter_design.c +++ b/lib_rend/ivas_reverb_filter_design.c @@ -654,7 +654,7 @@ void ivas_reverb_interpolate_acoustic_data( return; } - +#ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES /*-------------------------------------------------------------------* * ivas_reverb_get_hrtf_set_properties() * @@ -841,3 +841,4 @@ void ivas_reverb_get_hrtf_set_properties( return; } +#endif diff --git a/lib_rend/ivas_reverb_utils.c b/lib_rend/ivas_reverb_utils.c index 23d7592ce6a219c6ec2d153b512fa3e46cf9b11a..f62bf4eab4d6943f3f50cb2083b452504955daa9 100644 --- a/lib_rend/ivas_reverb_utils.c +++ b/lib_rend/ivas_reverb_utils.c @@ -67,8 +67,11 @@ typedef struct cldfb_convolver_state float filter_states_im[BINAURAL_CONVBANDS][CLDFB_CONVOLVER_NTAPS_MAX]; } cldfb_convolver_state; +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES +static void ivas_reverb_set_energies( const float *avg_pwr_l, const float *avg_pwr_r, const int32_t sampling_rate, float *avg_pwr_l_out, float *avg_pwr_r_out ); +#else static ivas_error ivas_reverb_get_fastconv_hrtf_set_energies( const HRTFS_FASTCONV_HANDLE hHrtfFastConv, const AUDIO_CONFIG input_audio_config, const int16_t use_brir, const int32_t sampling_rate, float *avg_pwr_left, float *avg_pwr_right ); - +#endif /*-----------------------------------------------------------------------------------------* * Function ivas_reverb_prepare_cldfb_params() @@ -77,10 +80,15 @@ static ivas_error ivas_reverb_get_fastconv_hrtf_set_energies( const HRTFS_FASTCO *-----------------------------------------------------------------------------------------*/ ivas_error ivas_reverb_prepare_cldfb_params( +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + const IVAS_ROOM_ACOUSTICS_CONFIG_DATA *pInput_params, + const HRTFS_STATISTICS_HANDLE hHrtfStatistics, +#else IVAS_ROOM_ACOUSTICS_CONFIG_DATA *pInput_params, const HRTFS_FASTCONV_HANDLE hHrtfFastConv, const AUDIO_CONFIG input_audio_config, const int16_t use_brir, +#endif const int32_t output_Fs, float *pOutput_t60, float *pOutput_ene ) @@ -92,7 +100,9 @@ ivas_error ivas_reverb_prepare_cldfb_params( float delay_diff, ln_1e6_inverted, exp_argument; const float dist = DEFAULT_SRC_DIST; const float dmx_gain_2 = 4.0f * EVS_PI * dist * dist / 0.001f; +#ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES ivas_error error; +#endif for ( idx = 0; idx < CLDFB_NO_CHANNELS_MAX; idx++ ) { @@ -113,10 +123,14 @@ ivas_error ivas_reverb_prepare_cldfb_params( pOutput_ene[idx] *= expf( exp_argument ); } +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + ivas_reverb_set_energies( hHrtfStatistics->average_energy_l, hHrtfStatistics->average_energy_r, output_Fs, avg_pwr_left, avg_pwr_right ); +#else if ( ( error = ivas_reverb_get_fastconv_hrtf_set_energies( hHrtfFastConv, input_audio_config, use_brir, output_Fs, avg_pwr_left, avg_pwr_right ) ) != IVAS_ERR_OK ) { return error; } +#endif for ( idx = 0; idx < CLDFB_NO_CHANNELS_MAX; idx++ ) { @@ -126,7 +140,7 @@ ivas_error ivas_reverb_prepare_cldfb_params( return IVAS_ERR_OK; } - +#ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES /*-----------------------------------------------------------------------------------------* * Function ivas_cldfb_convolver() * @@ -470,8 +484,20 @@ static ivas_error ivas_reverb_get_cldfb_hrtf_set_properties( return IVAS_ERR_OK; } +#endif +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES +/*-----------------------------------------------------------------------------------------* + * Function ivas_reverb_set_energies() + * + * Function gets the precalculated left/right energies and computes average + * left/right energies to CLDFB bin center frequencies. + *-----------------------------------------------------------------------------------------*/ +static void ivas_reverb_set_energies( + const float *avg_pwr_l, + const float *avg_pwr_r, +#else /*-----------------------------------------------------------------------------------------* * Function ivas_reverb_get_fastconv_hrtf_set_energies() * @@ -484,34 +510,50 @@ static ivas_error ivas_reverb_get_fastconv_hrtf_set_energies( const HRTFS_FASTCONV_HANDLE hHrtfFastConv, const AUDIO_CONFIG input_audio_config, const int16_t use_brir, +#endif const int32_t sampling_rate, float *avg_pwr_left, float *avg_pwr_right ) { int16_t freq_idx; const int16_t cldfb_freq_halfstep = MAX_SAMPLING_RATE / ( 4 * CLDFB_NO_CHANNELS_MAX ); +#ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES float avg_pwr_left_fft[FFT_SPECTRUM_SIZE]; float avg_pwr_right_fft[FFT_SPECTRUM_SIZE]; +#endif float input_fc[FFT_SPECTRUM_SIZE]; float output_fc[CLDFB_NO_CHANNELS_MAX]; +#ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES ivas_error error; +#endif +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + const int16_t avg_pwr_len = sampling_rate == 16000 ? LR_IAC_LENGTH_NR_FC_16KHZ : LR_IAC_LENGTH_NR_FC; + for ( freq_idx = 0; freq_idx < avg_pwr_len; freq_idx++ ) + { + input_fc[freq_idx] = freq_idx * ( 0.5f * sampling_rate / (float) ( avg_pwr_len - 1 ) ); + } +#else for ( freq_idx = 0; freq_idx < FFT_SPECTRUM_SIZE; freq_idx++ ) { input_fc[freq_idx] = freq_idx * ( 0.5f * sampling_rate / (float) ( FFT_SPECTRUM_SIZE - 1 ) ); } +#endif for ( freq_idx = 0; freq_idx < CLDFB_NO_CHANNELS_MAX; freq_idx++ ) { output_fc[freq_idx] = (float) ( ( 2 * freq_idx + 1 ) * cldfb_freq_halfstep ); } +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + ivas_reverb_interpolate_acoustic_data( avg_pwr_len, input_fc, avg_pwr_l, avg_pwr_r, CLDFB_NO_CHANNELS_MAX, output_fc, avg_pwr_left, avg_pwr_right ); +#else if ( ( error = ivas_reverb_get_cldfb_hrtf_set_properties( input_audio_config, hHrtfFastConv, use_brir, sampling_rate, avg_pwr_left_fft, avg_pwr_right_fft ) ) != IVAS_ERR_OK ) { return error; } ivas_reverb_interpolate_acoustic_data( FFT_SPECTRUM_SIZE, input_fc, avg_pwr_left_fft, avg_pwr_right_fft, CLDFB_NO_CHANNELS_MAX, output_fc, avg_pwr_left, avg_pwr_right ); - return IVAS_ERR_OK; +#endif } diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index 108476754c8d47216cb56d05cc3ddea7a54a86ba..aa37b22ae75be5207ab4f6a70f8274a64dd31cc5 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -1063,8 +1063,11 @@ typedef struct TDREND_HRFILT_FiltSet_struct ModelParamsITD_t ModelParamsITD; TDREND_HRFILT_Method_t FilterMethod; /* HR filtering method */ float latency_s; +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES +#else const float *lr_energy_and_iac[3]; /* left/right energy and interaural coherence for late reverb */ float *lr_energy_and_iac_dyn[3]; +#endif } TDREND_HRFILT_FiltSet_t; @@ -1344,6 +1347,15 @@ typedef struct ivas_hrtfs_parambin_struct } HRTFS_PARAMBIN, *HRTFS_PARAMBIN_HANDLE; +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES +typedef struct ivas_hrtfs_statistics_struct +{ + float *average_energy_l; + float *average_energy_r; + float *inter_aural_coherence; + int16_t fromROM; /* Flag that indicates that the pointers point to tables in ROM (controls init/dealloc).*/ +} HRTFS_STATISTICS, *HRTFS_STATISTICS_HANDLE; +#endif #ifdef SPLIT_REND_WITH_HEAD_ROT /*----------------------------------------------------------------------------------* diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 0cf92c5a33512a20b497bab6d4104e16095161fd..b1961a514320fefe64426cb9007187f91e840267 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -234,6 +234,9 @@ typedef struct hrtf_handles IVAS_DEC_HRTF_FASTCONV_HANDLE hHrtfFastConv; IVAS_DEC_HRTF_PARAMBIN_HANDLE hHrtfParambin; IVAS_DEC_HRTF_HANDLE hHrtfTD; +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + IVAS_DEC_HRTF_STATISTICS_HANDLE hHrtfStatistics; +#endif } hrtf_handles; #endif @@ -291,7 +294,11 @@ struct IVAS_REND *-------------------------------------------------------------------*/ #ifdef NONBE_FIX_BINARY_BINAURAL_READING +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES +static ivas_error initMasaExtRenderer( input_masa *inputMasa, const AUDIO_CONFIG outConfig, const RENDER_CONFIG_DATA *hRendCfg, hrtf_handles *hHrtfs ); +#else static ivas_error initMasaExtRenderer( input_masa *inputMasa, const AUDIO_CONFIG outConfig, hrtf_handles *hHrtfs ); +#endif #else static ivas_error initMasaExtRenderer( input_masa *inputMasa, const AUDIO_CONFIG outConfig ); #endif @@ -1438,7 +1445,11 @@ static ivas_error setRendInputActiveIsm( { #ifndef SPLIT_REND_WITH_HEAD_ROT #ifdef NONBE_FIX_BINARY_BINAURAL_READING +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + if ( ( error = ivas_rend_openCrend( &inputIsm->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, hRendCfg, hrtfs->hSetOfHRTF, hrtfs->hHrtfStatistics, *rendCtx.pOutSampleRate ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_rend_openCrend( &inputIsm->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, hRendCfg, hrtfs->hSetOfHRTF, *rendCtx.pOutSampleRate ) ) != IVAS_ERR_OK ) +#endif #else if ( ( error = ivas_rend_openCrend( &inputIsm->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, hRendCfg, NULL, *rendCtx.pOutSampleRate ) ) != IVAS_ERR_OK ) #endif @@ -1481,7 +1492,11 @@ static ivas_error setRendInputActiveIsm( if ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) { +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + if ( ( error = ivas_reverb_open( &( inputIsm->hReverb ), hrtfs->hHrtfStatistics, hRendCfg, *rendCtx.pOutSampleRate ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_reverb_open( &( inputIsm->hReverb ), outConfig, NULL, inputIsm->tdRendWrapper.hBinRendererTd->HrFiltSet_p->lr_energy_and_iac, hRendCfg, *rendCtx.pOutSampleRate ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -1494,7 +1509,11 @@ static ivas_error setRendInputActiveIsm( if ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) { +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + if ( ( error = ivas_reverb_open( &( inputIsm->hReverb ), hrtfs->hHrtfStatistics, hRendCfg, *rendCtx.pOutSampleRate ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_reverb_open( &( inputIsm->hReverb ), outConfig, NULL, inputIsm->tdRendWrapper.hBinRendererTd->HrFiltSet_p->lr_energy_and_iac, hRendCfg, *rendCtx.pOutSampleRate ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -1502,7 +1521,11 @@ static ivas_error setRendInputActiveIsm( else if ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) { #ifdef NONBE_FIX_BINARY_BINAURAL_READING +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + if ( ( error = ivas_rend_openCrend( &inputIsm->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, hRendCfg, hrtfs->hSetOfHRTF, hrtfs->hHrtfStatistics, *rendCtx.pOutSampleRate, rendCtx.pSplitRendWrapper->multiBinPoseData.num_poses ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_rend_openCrend( &inputIsm->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, hRendCfg, hrtfs->hSetOfHRTF, *rendCtx.pOutSampleRate, rendCtx.pSplitRendWrapper->multiBinPoseData.num_poses ) ) != IVAS_ERR_OK ) +#endif #else 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 ) #endif @@ -2199,6 +2222,9 @@ static ivas_error initMcBinauralRendering( RENDER_CONFIG_DATA *hRendCfg, #ifdef NONBE_FIX_BINARY_BINAURAL_READING IVAS_DEC_HRTF_CREND_HANDLE hMixconv, +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + HRTFS_STATISTICS_HANDLE hHrtfStatistics, +#endif #endif uint8_t reconfigureFlag ) { @@ -2302,7 +2328,11 @@ static ivas_error initMcBinauralRendering( #endif if ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB && inputMc->hReverb == NULL ) { +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + if ( ( error = ivas_reverb_open( &( inputMc->hReverb ), hHrtfStatistics, hRendCfg, outSampleRate ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_reverb_open( &( inputMc->hReverb ), outConfig, NULL, inputMc->tdRendWrapper.hBinRendererTd->HrFiltSet_p->lr_energy_and_iac, hRendCfg, outSampleRate ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -2313,17 +2343,24 @@ static ivas_error initMcBinauralRendering( /* open CREND */ #ifdef SPLIT_REND_WITH_HEAD_ROT #ifdef NONBE_FIX_BINARY_BINAURAL_READING +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + if ( ( error = ivas_rend_openCrend( &inputMc->crendWrapper, ( inConfig == IVAS_AUDIO_CONFIG_LS_CUSTOM ) ? IVAS_AUDIO_CONFIG_7_1_4 : inConfig, outConfig, hRendCfg, hMixconv, hHrtfStatistics, + 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, hMixconv, 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 ) - +#endif #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, ( ( 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 ) - #endif #else #ifdef NONBE_FIX_BINARY_BINAURAL_READING +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + if ( ( error = ivas_rend_openCrend( &inputMc->crendWrapper, ( inConfig == IVAS_AUDIO_CONFIG_LS_CUSTOM ) ? IVAS_AUDIO_CONFIG_7_1_4 : inConfig, outConfig, hRendCfg, hMixconv, hHrtfStatistics, outSampleRate ) ) != 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, hMixconv, outSampleRate ) ) != IVAS_ERR_OK ) +#endif #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 @@ -2540,7 +2577,11 @@ static ivas_error setRendInputActiveMc( #endif { #ifdef NONBE_FIX_BINARY_BINAURAL_READING +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + if ( ( error = initMcBinauralRendering( inputMc, inConfig, outConfig, hRendCfg, hrtfs->hSetOfHRTF, hrtfs->hHrtfStatistics, FALSE ) ) != IVAS_ERR_OK ) +#else if ( ( error = initMcBinauralRendering( inputMc, inConfig, outConfig, hRendCfg, hrtfs->hSetOfHRTF, FALSE ) ) != IVAS_ERR_OK ) +#endif #else if ( ( error = initMcBinauralRendering( inputMc, inConfig, outConfig, hRendCfg, FALSE ) ) != IVAS_ERR_OK ) #endif @@ -2746,6 +2787,10 @@ static ivas_error updateSbaPanGains( #ifdef NONBE_FIX_BINARY_BINAURAL_READING RENDER_CONFIG_DATA *hRendCfg, IVAS_DEC_HRTF_CREND_HANDLE hMixconv +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + , + IVAS_DEC_HRTF_STATISTICS_HANDLE hHrtfStatistics +#endif #else RENDER_CONFIG_DATA *hRendCfg #endif @@ -2810,10 +2855,18 @@ static ivas_error updateSbaPanGains( { #ifdef NONBE_FIX_BINARY_BINAURAL_READING #ifdef SPLIT_REND_WITH_HEAD_ROT +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + if ( ( error = ivas_rend_openCrend( &inputSba->crendWrapper, inConfig, outConfig, hRendCfg, hMixconv, hHrtfStatistics, *rendCtx.pOutSampleRate, rendCtx.pSplitRendWrapper->multiBinPoseData.num_poses ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_rend_openCrend( &inputSba->crendWrapper, inConfig, outConfig, hRendCfg, hMixconv, *rendCtx.pOutSampleRate, rendCtx.pSplitRendWrapper->multiBinPoseData.num_poses ) ) != IVAS_ERR_OK ) +#endif +#else +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + if ( ( error = ivas_rend_openCrend( &inputSba->crendWrapper, inConfig, outConfig, hRendCfg, hMixconv, hHrtfStatistics, *rendCtx.pOutSampleRate ) ) != IVAS_ERR_OK ) #else if ( ( error = ivas_rend_openCrend( &inputSba->crendWrapper, inConfig, outConfig, hRendCfg, hMixconv, *rendCtx.pOutSampleRate ) ) != IVAS_ERR_OK ) #endif +#endif #else #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 ) @@ -2835,10 +2888,18 @@ static ivas_error updateSbaPanGains( #ifdef NONBE_FIX_BINARY_BINAURAL_READING #ifdef SPLIT_REND_WITH_HEAD_ROT +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + if ( ( error = ivas_rend_openCrend( &inputSba->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, hRendCfg, hMixconv, hHrtfStatistics, *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, hMixconv, *rendCtx.pOutSampleRate, rendCtx.pSplitRendWrapper->multiBinPoseData.num_poses ) ) != IVAS_ERR_OK ) +#endif +#else +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + if ( ( error = ivas_rend_openCrend( &inputSba->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, hRendCfg, hMixconv, hHrtfStatistics, *rendCtx.pOutSampleRate ) ) != IVAS_ERR_OK ) #else if ( ( error = ivas_rend_openCrend( &inputSba->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, hRendCfg, hMixconv, *rendCtx.pOutSampleRate ) ) != IVAS_ERR_OK ) #endif +#endif #else #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 ) @@ -3011,7 +3072,11 @@ static ivas_error setRendInputActiveSba( } #ifdef NONBE_FIX_BINARY_BINAURAL_READING +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + if ( ( error = updateSbaPanGains( inputSba, outConfig, hRendCfg, hrtfs->hSetOfHRTF, hrtfs->hHrtfStatistics ) ) != IVAS_ERR_OK ) +#else if ( ( error = updateSbaPanGains( inputSba, outConfig, hRendCfg, hrtfs->hSetOfHRTF ) ) != IVAS_ERR_OK ) +#endif #else if ( ( error = updateSbaPanGains( inputSba, outConfig, hRendCfg ) ) != IVAS_ERR_OK ) #endif @@ -3094,8 +3159,11 @@ static ivas_error setRendInputActiveMasa( #else RENDER_CONFIG_DATA *hRendCfg #endif - +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES +) +#else ) /* Todo: This is not used at all within MASA. Support might be better to do after refactoring. */ +#endif { ivas_error error; rendering_context rendCtx; @@ -3106,7 +3174,9 @@ static ivas_error setRendInputActiveMasa( inputMasa = (input_masa *) input; rendCtx = inputMasa->base.ctx; outConfig = *rendCtx.pOutConfig; +#ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES (void) hRendCfg; /* Suppress warning */ +#endif if ( !isIoConfigPairSupported( inConfig, outConfig ) ) { @@ -3135,7 +3205,11 @@ static ivas_error setRendInputActiveMasa( else { #ifdef NONBE_FIX_BINARY_BINAURAL_READING +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + if ( ( error = initMasaExtRenderer( inputMasa, outConfig, hRendCfg, hrtfs ) ) != IVAS_ERR_OK ) +#else if ( ( error = initMasaExtRenderer( inputMasa, outConfig, hrtfs ) ) != IVAS_ERR_OK ) +#endif #else if ( ( error = initMasaExtRenderer( inputMasa, outConfig ) ) != IVAS_ERR_OK ) #endif @@ -3408,6 +3482,9 @@ ivas_error IVAS_REND_Open( hIvasRend->hHrtfs.hHrtfParambin = NULL; hIvasRend->hHrtfs.hHrtfTD = NULL; hIvasRend->hHrtfs.hSetOfHRTF = NULL; +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + hIvasRend->hHrtfs.hHrtfStatistics = NULL; +#endif if ( asHrtfBinary ) { if ( ( error = ivas_HRTF_binary_open( &( hIvasRend->hHrtfs.hHrtfTD ) ) ) != IVAS_ERR_OK ) @@ -3426,7 +3503,19 @@ ivas_error IVAS_REND_Open( { return error; } +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + if ( ( error = ivas_HRTF_statistics_binary_open( &( hIvasRend->hHrtfs.hHrtfStatistics ) ) ) != IVAS_ERR_OK ) + { + return error; + } +#endif + } +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + if ( ( error = ivas_HRTF_statistics_init( &( hIvasRend->hHrtfs.hHrtfStatistics ), hIvasRend->sampleRateOut ) ) != IVAS_ERR_OK ) + { + return error; } +#endif #endif return IVAS_ERR_OK; @@ -3574,7 +3663,11 @@ ivas_error IVAS_REND_ConfigureCustomOutputLoudspeakerLayout( } #ifdef NONBE_FIX_BINARY_BINAURAL_READING +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + if ( ( error = updateSbaPanGains( inputSba, hIvasRend->outputConfig, hIvasRend->hRendererConfig, NULL, NULL ) ) != IVAS_ERR_OK ) +#else if ( ( error = updateSbaPanGains( inputSba, hIvasRend->outputConfig, hIvasRend->hRendererConfig, NULL ) ) != IVAS_ERR_OK ) +#endif #else if ( ( error = updateSbaPanGains( inputSba, hIvasRend->outputConfig, hIvasRend->hRendererConfig ) ) != IVAS_ERR_OK ) #endif @@ -4054,6 +4147,9 @@ ivas_error IVAS_REND_ConfigureCustomInputLoudspeakerLayout( hIvasRend->hRendererConfig, #ifdef NONBE_FIX_BINARY_BINAURAL_READING hIvasRend->hHrtfs.hSetOfHRTF, +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + hIvasRend->hHrtfs.hHrtfStatistics, +#endif #endif FALSE ) ) != IVAS_ERR_OK ) { @@ -4900,6 +4996,9 @@ ivas_error IVAS_REND_SetHeadRotation( hIvasRend->hRendererConfig, #ifdef NONBE_FIX_BINARY_BINAURAL_READING hIvasRend->hHrtfs.hSetOfHRTF, +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + hIvasRend->hHrtfs.hHrtfStatistics, +#endif #endif TRUE ) ) != IVAS_ERR_OK ) { @@ -4967,6 +5066,9 @@ ivas_error IVAS_REND_DisableHeadRotation( hIvasRend->hRendererConfig, #ifdef NONBE_FIX_BINARY_BINAURAL_READING hIvasRend->hHrtfs.hSetOfHRTF, +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + hIvasRend->hHrtfs.hHrtfStatistics, +#endif #endif TRUE ) ) != IVAS_ERR_OK ) { @@ -8643,6 +8745,9 @@ void IVAS_REND_Close( ivas_HRTF_CRend_binary_close( &( hIvasRend->hHrtfs.hSetOfHRTF ) ); ivas_HRTF_fastconv_binary_close( &( hIvasRend->hHrtfs.hHrtfFastConv ) ); ivas_HRTF_parambin_binary_close( &( hIvasRend->hHrtfs.hHrtfParambin ) ); +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + ivas_HRTF_statistics_close( &( hIvasRend->hHrtfs.hHrtfStatistics ) ); +#endif #endif free( hIvasRend ); @@ -8887,6 +8992,28 @@ ivas_error IVAS_REND_GetHrtfParamBinHandle( } #endif +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES +/*---------------------------------------------------------------------* + * IVAS_REND_GetHrtfStatisticsHandle( ) + * + * + *---------------------------------------------------------------------*/ + +ivas_error IVAS_REND_GetHrtfStatisticsHandle( + IVAS_REND_HANDLE hIvasRend, /* i/o: IVAS decoder handle */ + IVAS_DEC_HRTF_STATISTICS_HANDLE **hHrtfStatistics /* o : HRTF statistics handle */ +) +{ + if ( hIvasRend == NULL || hIvasRend->hHrtfs.hHrtfStatistics == NULL ) + { + return IVAS_ERR_WRONG_PARAMS; + } + + *hHrtfStatistics = &hIvasRend->hHrtfs.hHrtfStatistics; + + return IVAS_ERR_OK; +} +#endif static ivas_error ivas_masa_ext_rend_dirac_rend_init( input_masa *inputMasa ) @@ -9249,7 +9376,13 @@ static ivas_error ivas_masa_ext_rend_dirac_rend_init( } static ivas_error ivas_masa_ext_rend_parambin_init( +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + input_masa *inputMasa, /* i/o: MASA external renderer structure */ + const RENDER_CONFIG_DATA *hRendCfg, /* i : Renderer configuration data handle */ + HRTFS_STATISTICS_HANDLE hHrtfStatistics /* i : HRTF statistics */ +#else input_masa *inputMasa /* i/o: MASA external renderer structure */ +#endif ) { DIRAC_DEC_BIN_HANDLE hDiracDecBin; @@ -9349,8 +9482,12 @@ static ivas_error ivas_masa_ext_rend_parambin_init( 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 ) +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + if ( ( error = ivas_binaural_reverb_init( &hDiracDecBin->hReverb, hHrtfStatistics, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, &( hRendCfg->roomAcoustics ), output_Fs, hHrtfParambin->parametricReverberationTimes, hHrtfParambin->parametricReverberationEneCorrections ) ) != IVAS_ERR_OK ) +#else + /* 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 { return error; } @@ -9405,6 +9542,9 @@ static ivas_error initMasaExtRenderer( input_masa *inputMasa, #ifdef NONBE_FIX_BINARY_BINAURAL_READING const AUDIO_CONFIG outConfig, +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + const RENDER_CONFIG_DATA *hRendCfg, +#endif hrtf_handles *hrtfs #else const AUDIO_CONFIG outConfig @@ -9542,7 +9682,11 @@ static ivas_error initMasaExtRenderer( } } +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + if ( ( error = ivas_masa_ext_rend_parambin_init( inputMasa, hRendCfg, hrtfs->hHrtfStatistics ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_masa_ext_rend_parambin_init( inputMasa ) ) != IVAS_ERR_OK ) +#endif { return error; } diff --git a/lib_rend/lib_rend.h b/lib_rend/lib_rend.h index 5e30b70dab79eeed8771785e5392dd9e6eaf38af..1a4a6abc08f26645a998badb7ae49375b807d48b 100644 --- a/lib_rend/lib_rend.h +++ b/lib_rend/lib_rend.h @@ -203,25 +203,32 @@ ivas_error IVAS_REND_GetDelay( #ifdef NONBE_FIX_BINARY_BINAURAL_READING /*! r: error code */ ivas_error IVAS_REND_GetHrtfHandle( - IVAS_REND_HANDLE hIvasRend, /* i/o: IVAS decoder handle */ + IVAS_REND_HANDLE hIvasRend, /* i/o: IVAS render handle */ IVAS_DEC_HRTF_HANDLE **hHrtfTD /* o : HRTF handle */ ); /*! r: error code */ ivas_error IVAS_REND_GetHrtfCRendHandle( - IVAS_REND_HANDLE hIvasRend, /* i/o: IVAS decoder handle */ + IVAS_REND_HANDLE hIvasRend, /* i/o: IVAS renderer handle */ IVAS_DEC_HRTF_CREND_HANDLE **hSetOfHRTF /* o : Set of HRTF handle */ ); ivas_error IVAS_REND_GetHrtfFastConvHandle( - IVAS_REND_HANDLE hIvasRend, /* i/o: IVAS decoder handle */ + IVAS_REND_HANDLE hIvasRend, /* i/o: IVAS renderer handle */ IVAS_DEC_HRTF_FASTCONV_HANDLE **hHrtfFastConv /* o : FASTCONV HRTF handle */ ); ivas_error IVAS_REND_GetHrtfParamBinHandle( - IVAS_REND_HANDLE hIvasRend, /* i/o: IVAS decoder handle */ + IVAS_REND_HANDLE hIvasRend, /* i/o: IVAS renderer handle */ IVAS_DEC_HRTF_PARAMBIN_HANDLE **hHrtfParambin /* o : Parametric binauralizer HRTF handle */ ); + +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES +ivas_error IVAS_REND_GetHrtfStatisticsHandle( + IVAS_REND_HANDLE hIvasRend, /* i/o: IVAS renderer handle */ + IVAS_DEC_HRTF_STATISTICS_HANDLE **hHrtfStatistics /* o : HRTF statistics handle */ +); +#endif #endif /* Functions to be called during rendering */ diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index d0aff3ad2deaf8ce76c01395fa8252cce7b2b432..362498dd45b3ea565f58e1b8c8cbb942122ce03f 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -463,6 +463,7 @@ static ivas_error LoadBSplineBinary( #ifdef FIX_638_ENERGIE_IAC_ROM_TABLES +#ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES /*-------------------------------------------------------------------* * set_default_reverb_iac_energy() * @@ -556,6 +557,7 @@ static ivas_error set_default_reverb_iac_energy( return IVAS_ERR_OK; } +#endif #ifdef FIX_638_ENERGIE_IAC_ROM_TABLES @@ -566,11 +568,18 @@ static ivas_error set_default_reverb_iac_energy( --------------------------------------------------------------------*/ static ivas_error load_reverb_from_binary( +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + IVAS_DEC_HRTF_STATISTICS_HANDLE hHrtfStatistics, /* i/o: HRTF statistics handle */ + int32_t sampleRate, /* i : sample rate */ +#else IVAS_DEC_HRTF_HANDLE HrFiltSet_p, /* i/o: HR filter model parameter structure */ - FILE *f_hrtf /* i : HR filter data file handle */ +#endif + FILE *f_hrtf /* i : HR filter data file handle */ ) { +#ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES int16_t i; +#endif bool is_reverb; ivas_error header_check_result; ivas_hrtfs_file_header_t hrtfs_file_header; @@ -581,13 +590,21 @@ static ivas_error load_reverb_from_binary( #ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB int16_t lr_iac_len; +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + if ( hHrtfStatistics == NULL ) +#else if ( HrFiltSet_p == NULL ) +#endif { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } lr_iac_len = LR_IAC_LENGTH_NR_FC; +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + if ( sampleRate == 16000 ) +#else if ( HrFiltSet_p->SampleRate == 16000 ) +#endif { lr_iac_len = LR_IAC_LENGTH_NR_FC_16KHZ; } @@ -645,6 +662,21 @@ static ivas_error load_reverb_from_binary( if ( is_reverb ) { +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + hHrtfStatistics->average_energy_l = (float *) malloc( lr_iac_len * sizeof( float ) ); + hHrtfStatistics->average_energy_r = (float *) malloc( lr_iac_len * sizeof( float ) ); + hHrtfStatistics->inter_aural_coherence = (float *) malloc( lr_iac_len * sizeof( float ) ); + + if ( hHrtfStatistics->average_energy_l == NULL || hHrtfStatistics->average_energy_r == NULL || hHrtfStatistics->inter_aural_coherence == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); + } + fread( hHrtfStatistics->average_energy_l, sizeof( const float ), lr_iac_len, f_hrtf ); + fread( hHrtfStatistics->average_energy_r, sizeof( const float ), lr_iac_len, f_hrtf ); + fread( hHrtfStatistics->inter_aural_coherence, sizeof( const float ), lr_iac_len, f_hrtf ); + + hHrtfStatistics->fromROM = FALSE; +#else /* left/right energy and interaural coherence for late reverb */ for ( i = 0; i < 3; i++ ) { @@ -670,14 +702,17 @@ static ivas_error load_reverb_from_binary( HrFiltSet_p->lr_energy_and_iac[i] = (const float *) HrFiltSet_p->lr_energy_and_iac_dyn[i]; #endif } +#endif } else { +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES +#else if ( ( header_check_result = set_default_reverb_iac_energy( HrFiltSet_p ) ) != IVAS_ERR_OK ) { return header_check_result; } - +#endif #ifdef NONBE_FIX_BINARY_BINAURAL_READING return IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA; #else @@ -696,13 +731,22 @@ static ivas_error load_reverb_from_binary( *---------------------------------------------------------------------*/ ivas_error load_reverb_binary( - IVAS_DEC_HRTF_HANDLE hHrtf, /* i/o: HRTF handle */ +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + IVAS_DEC_HRTF_STATISTICS_HANDLE hHrtfStatistics, /* i/o: HRTF statistics handle */ + int32_t sampleRate, /* i : sample rate */ +#else + IVAS_DEC_HRTF_HANDLE hHrtf, /* i/o: HRTF handle */ +#endif const hrtfFileReader *hrtfReader /* i/o: pointer to hrtfFileReader handle */ ) { fseek( hrtfReader->file, 0, SEEK_SET ); +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + return load_reverb_from_binary( hHrtfStatistics, sampleRate, hrtfReader->file ); +#else return load_reverb_from_binary( hHrtf, hrtfReader->file ); +#endif } #endif @@ -986,10 +1030,12 @@ void destroy_td_hrtf( free( ( *hHrtf )->ModelEval.hrfModL ); free( ( *hHrtf )->ModelEval.hrfModR ); +#ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES for ( i = 0; i < 3; i++ ) { free( ( *hHrtf )->lr_energy_and_iac_dyn[i] ); } +#endif } ivas_HRTF_binary_close( hHrtf ); @@ -2236,3 +2282,24 @@ ivas_error destroy_SetOfHRTF( return IVAS_ERR_OK; } #endif +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES +/*---------------------------------------------------------------------* + * destroy_hrtf_statistics() + * + * Destroy the HRTF statistics set. + *---------------------------------------------------------------------*/ + +ivas_error destroy_hrtf_statistics( + IVAS_DEC_HRTF_STATISTICS_HANDLE *hHrtfStatistics /* i/o: HRTF statistics handle */ +) +{ + if ( hHrtfStatistics != NULL && ( *hHrtfStatistics )->fromROM == FALSE ) + { + free( ( *hHrtfStatistics )->average_energy_l ); + free( ( *hHrtfStatistics )->average_energy_r ); + free( ( *hHrtfStatistics )->inter_aural_coherence ); + } + ivas_HRTF_statistics_close( hHrtfStatistics ); + return IVAS_ERR_OK; +} +#endif diff --git a/lib_util/hrtf_file_reader.h b/lib_util/hrtf_file_reader.h index 3299d2d6a13b5e08072ffcff134f765e21025f78..a86bddd87657b18c6d9f5d1a03d45905b3634322 100644 --- a/lib_util/hrtf_file_reader.h +++ b/lib_util/hrtf_file_reader.h @@ -101,7 +101,12 @@ ivas_error load_HRTF_binary( *---------------------------------------------------------------------*/ ivas_error load_reverb_binary( - IVAS_DEC_HRTF_HANDLE hHrtf, /* i/o: HRTF handle */ +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + IVAS_DEC_HRTF_STATISTICS_HANDLE hHrtfStatistics, /* i/o: HRTF statistics handle */ + int32_t sampleRate, /* i : sample rate */ +#else + IVAS_DEC_HRTF_HANDLE hHrtf, /* i/o: HRTF handle */ +#endif const hrtfFileReader *hrtfReader /* i/o: pointer to hrtfFileReader handle */ ); #endif @@ -190,6 +195,18 @@ void destroy_td_hrtf( IVAS_DEC_HRTF_HANDLE *hHRTF /* i/o: HRTF handle */ ); +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES +/*---------------------------------------------------------------------* + * destroy_hrtf_statistics() + * + * free memory allocated for HRTF statistics binary data + *---------------------------------------------------------------------*/ + +ivas_error destroy_hrtf_statistics( + IVAS_DEC_HRTF_STATISTICS_HANDLE *hHrtfStatistics /* i/o: HRTF statistics handle */ +); +#endif + #else /*---------------------------------------------------------------------* * dealloc_HRTF_binary() diff --git a/lib_util/render_config_reader.c b/lib_util/render_config_reader.c index 369de3b310619a9de75d88e2e9fc65305627d90f..e5101cfe92a7eaa4ca970241bd7c78365d01f4ce 100644 --- a/lib_util/render_config_reader.c +++ b/lib_util/render_config_reader.c @@ -435,11 +435,7 @@ static ivas_error read_bin_bits( *pTarget = 0; for ( n = 0; n < nBits; n++ ) { -#ifdef FIX_WARNING_RENDER_CONFIG nByte = (uint32_t) ( ( this->readOffset + n ) >> 3 ); -#else - nByte = ( this->readOffset + n ) >> 3; -#endif bit = this->pBitstream[nByte] >> ( 7 - ( ( this->readOffset + n ) % 8 ) ) & 1; *pTarget = ( *pTarget << 1 ) + bit; } diff --git a/scripts/batch_comp_audio.py b/scripts/batch_comp_audio.py index 97e9f8f54840f22f71fddb44ebd0bddd8fa486ce..ef47968cb83d33693d9d3e3d87c2deda505536ed 100755 --- a/scripts/batch_comp_audio.py +++ b/scripts/batch_comp_audio.py @@ -33,40 +33,52 @@ import argparse import concurrent.futures import os +import pathlib import re import shutil import subprocess import sys import threading from itertools import repeat +from pyaudio3dtools.audiofile import readfile +from pyaudio3dtools.audioarray import compare FILES_EQUAL = "File A = File B" -SNR_EXPR = r"SNR\s+=(.+)dB\s*\(File B Gain = (.+)\)" +SNR_EXPR = r"SNR\s+=(.+)dB\s*\(.+= (.+)\)" SEG_SNR_EXPR = r"Seg. SNR\s+=(.+)dB" DIFF_EXPR = r"Max Diff\s+=\s+(\d+)" +DIFF_STR = { + "CompAudio": "{label} Max. diff (PCM) for file {f}: {diff}", + "mld": "{label} MLD diff for file {f}: {diff}", +} def main(args): - - if shutil.which("CompAudio") is None: - print("CompAudio not in PATH - abort.") + tool = args.tool + if shutil.which(tool) is None: + print(f"{tool} not in PATH - abort.") sys.exit(-1) num_files_diff = 0 with OutFileManager(args.out_file) as out_file: if args.diffs_only: - print("Only printing differing files!", file=out_file) + print("Only printing differing files!") fol1, fol2 = os.path.normpath(args.folder1), os.path.normpath(args.folder2) common_files = get_common_files(fol1, fol2) diff_files = get_diff_files(fol1, fol2) num_files_diff = len(diff_files) - print(f"Comparing {len(common_files)} files...", file=out_file) + print(f"Comparing {len(common_files)} files...") outputs = dict() - if args.num_threads > 1: + if args.num_threads == 1: + # if only one thread is passed, do everything in the main thread + # to allow for meaningful debugging if needed + for f in common_files: + compare_files(f, fol1, fol2, outputs, tool) + else: with concurrent.futures.ThreadPoolExecutor( max_workers=args.num_threads ) as exc: @@ -76,20 +88,26 @@ def main(args): repeat(fol1), repeat(fol2), repeat(outputs), + repeat(tool), ) - else: - # if only one thread is passed, do everything in the main thread - # to allow for meaningful debugging if needed - for f in common_files: - compare_files(f, fol1, fol2, outputs) if args.sort: out = dict(sorted(outputs.items(), key=lambda item: item[1])) else: out = outputs - for f, output_tuple in out.items(): - diff, snr, gain, seg_snr = output_tuple + # write csv header + if out_file is not None: + if tool == "CompAudio": + out_file.write("filename,diff\n") + elif tool == "mld": + out_file.write("filename,mld\n") + + for f, tool_output in out.items(): + if tool == "CompAudio": + diff, snr, gain, seg_snr = tool_output + elif tool == "mld": + diff = tool_output if diff > 0: num_files_diff = num_files_diff + 1 @@ -99,38 +117,47 @@ def main(args): label = "[OKAY]" else: label = "[FAIL]" - result = f"{label} Max. diff (PCM) for file {f}: {diff}" + result = DIFF_STR[tool].format(label=label, f=f, diff=diff) - if args.verbose and diff != 0.0: + if tool == "CompAudio" and args.verbose and diff != 0.0: result += f", SNR = {snr:4.2f} dB (File 2 Gain = {gain:4.3f})" result += f", Seg. SNR = {seg_snr:4.2f} dB" - print(result, file=out_file) + print(result) + + if out_file is not None: + out_file.write(f"{f},{diff}\n") if num_files_diff > 0: - print(f"{num_files_diff} files differ/don't exist", file=out_file) + print(f"{num_files_diff} files differ/don't exist") else: - print(f"All files are bitexact", file=out_file) + print(f"All files are bitexact") -def compare_files(f, fol1, fol2, outputs_dict): +def compare_files(f, fol1, fol2, outputs_dict, tool): """ - Compare file f in both folders fol1 and fol2 using CompAudio and + Compare file f in both folders fol1 and fol2 using the given tool and store the parsed difference in outputs_dict. """ f1 = os.path.join(fol1, f) f2 = os.path.join(fol2, f) - cmd = f"CompAudio {f1} {f2}" - try: - output = subprocess.check_output(cmd.split(" ")) - except subprocess.CalledProcessError: - print("CompAudio returned a non-zero exit status. Check your files.") - sys.exit(-1) - output_tuple = _parse_comp_audio(output) + if tool == "CompAudio": + cmd = f"{tool} {f1} {f2}" + try: + output = subprocess.check_output(cmd.split(" ")) + except subprocess.CalledProcessError: + print(f"{tool} returned a non-zero exit status. Check your files.") + sys.exit(-1) + tool_output = _parse_comp_audio(output) + elif tool == "mld": + s1, fs1 = readfile(f1, outdtype="int16") + s2, fs2 = readfile(f2, outdtype="int16") + cmp_result = compare(s1, s2, fs1, per_frame=False, get_mld=True) + tool_output = cmp_result["MLD"] with threading.Lock(): - outputs_dict.update({f: output_tuple}) + outputs_dict.update({f: tool_output}) def get_common_files(fol1, fol2): @@ -220,7 +247,6 @@ class OutFileManager: if __name__ == "__main__": - parser = argparse.ArgumentParser( description="Compare .wav files in two folders using CompAudio" ) @@ -251,10 +277,16 @@ if __name__ == "__main__": "--out_file", type=str, default=None, - help="If given, write output diffs to this file", + help="If given, write output diffs to this file as comma-separated values (csv)", + ) + parser.add_argument( + "-t", "--num_threads", type=int, default=None, help="Number of threads to use" ) parser.add_argument( - "-t", "--num_threads", type=int, default=1, help="Number of threads to use" + "--tool", + choices=["mld", "CompAudio"], + default="CompAudio", + help="Compare tool to run", ) args = parser.parse_args() diff --git a/scripts/config/self_test.prm b/scripts/config/self_test.prm index 203c8dfc4dfaac52fef159905799fa6c11f029fd..f4fb4e5a3898562f6ac7dd4f678350f8e72dbc22 100644 --- a/scripts/config/self_test.prm +++ b/scripts/config/self_test.prm @@ -295,7 +295,7 @@ eid-xor -fer -vbr -bs g192 -ep g192 bit ../scripts/dly_error_profiles/ep_5pct.g1 eid-xor -fer -vbr -bs g192 -ep g192 bit ../scripts/dly_error_profiles/ep_5pct.g192 bit_error ../IVAS_dec BINAURAL 48 bit_error testv/stv48n.wav_1ISM_13200_48-48_DTX_FER5_BINAURAL.tst -// 1 ISM with metadata at 16.4 kbps, 48 kHz in, 48 kHz out, BINAURAL ROOM out +// 1 ISM with metadata at 16.4 kbps, 48 kHz in, 48 kHz out, BINAURAL ROOM IR out ../IVAS_cod -ism 1 testv/stvISM1.csv 16400 48 testv/stv1ISM48s.wav bit ../IVAS_dec BINAURAL_ROOM_IR 48 bit testv/stv1ISM48s.wav_16400_48-48_binaural_room.tst @@ -303,7 +303,7 @@ eid-xor -fer -vbr -bs g192 -ep g192 bit ../scripts/dly_error_profiles/ep_5pct.g1 ../IVAS_cod -dtx -ism 1 testv/stvISM1.csv 32000 32 testv/stv32n.wav bit ../IVAS_dec MONO 32 bit testv/stv32n.wav_1ISM_32000_32-32_DTX_MONO.tst -// 1 ISM with metadata at 48 kbps, 48 kHz in, 48 kHz out, BINAURAL ROOM out, head rotation, random FER at 5% +// 1 ISM with metadata at 48 kbps, 48 kHz in, 48 kHz out, BINAURAL ROOM IR out, head rotation, random FER at 5% ../IVAS_cod -ism 1 testv/stvISM1.csv 48000 48 testv/stv1ISM48s.wav bit eid-xor -fer -vbr -bs g192 -ep g192 bit ../scripts/dly_error_profiles/ep_5pct.g192 bit_error ../IVAS_dec -t testv/headrot_case00_3000_q.csv BINAURAL_ROOM_IR 48 bit_error testv/stv1ISM48s.wav_64000_48-48_binaural_room_HR.tst @@ -313,7 +313,7 @@ eid-xor -fer -vbr -bs g192 -ep g192 bit ../scripts/dly_error_profiles/ep_5pct.g1 eid-xor -fer -vbr -bs g192 -ep g192 bit ../scripts/dly_error_profiles/ep_5pct.g192 bit_error ../IVAS_dec -t testv/headrot_case00_3000_q.csv BINAURAL 48 bit_error testv/stv1ISM48s.wav_64000_48-48_FER5_binaural_HR.tst -// 1 ISM with metadata at 48 kbps, 48 kHz in, 48 kHz out, BINAURAL ROOM out, head rotation, external orientation, random FER at 5% +// 1 ISM with metadata at 48 kbps, 48 kHz in, 48 kHz out, BINAURAL ROOM IR out, head rotation, external orientation, random FER at 5% ../IVAS_cod -ism 1 testv/stvISM1.csv 48000 48 testv/stv1ISM48s.wav bit eid-xor -fer -vbr -bs g192 -ep g192 bit ../scripts/dly_error_profiles/ep_5pct.g192 bit_error ../IVAS_dec -t testv/headrot_case00_3000_q.csv -exof testv/headrot_case00_3000_q_combinedRotationTest.csv BINAURAL_ROOM_IR 48 bit_error testv/stv1ISM48s.wav_64000_48-48_FER5_binaural_room_HR_EXOF.tst @@ -358,7 +358,7 @@ eid-xor -fer -vbr -bs g192 -ep g192 bit ../scripts/dly_error_profiles/ep_5pct.g1 eid-xor -fer -vbr -bs g192 -ep g192 bit ../scripts/dly_error_profiles/ep_5pct.g192 bit_error ../IVAS_dec EXT 48 bit_error testv/stv2ISM48s.wav_48000_48-48_EXT_FER5.tst -// 2 ISM with metadata at 64 kbps, 48 kHz in, 48 kHz out, BINAURAL ROOM out +// 2 ISM with metadata at 64 kbps, 48 kHz in, 48 kHz out, BINAURAL ROOM IR out ../IVAS_cod -ism 2 testv/stvISM3.csv testv/stvISM4.csv 64000 48 testv/stv2ISM48s.wav bit ../IVAS_dec BINAURAL_ROOM_IR 48 bit testv/stv2ISM48s.wav_64000_48-48_binaural_room.tst @@ -402,7 +402,7 @@ eid-xor -fer -vbr -bs g192 -ep g192 bit ../scripts/dly_error_profiles/ep_5pct.g1 // 3 ISM with metadata at 48 kbps, 48 kHz in, 48 kHz out, EXT out ../IVAS_cod -ism 3 testv/stvISM1.csv testv/stvISM2.csv testv/stvISM3.csv 48000 48 testv/stv3ISM48s.wav bit -../IVAS_dec MONO 48 bit testv/stv3ISM48s.48000_48-48_MONO.tst +../IVAS_dec EXT 48 bit testv/stv3ISM48s.48000_48-48_MONO.tst // 3 ISM with metadata at 64 kbps, 48 kHz in, 48 kHz out, EXT out ../IVAS_cod -ism 3 testv/stvISM1.csv testv/stvISM2.csv testv/stvISM3.csv 64000 48 testv/stv3ISM48s.wav bit @@ -451,17 +451,17 @@ eid-xor -fer -vbr -bs g192 -ep g192 bit ../scripts/dly_error_profiles/ep_5pct.g1 ../IVAS_cod -ism 4 testv/stvISM1.csv testv/stvISM2.csv testv/stvISM3.csv testv/stvISM4.csv 32000 48 testv/stv4ISM48s.wav bit ../IVAS_dec -t testv/headrot_case03_3000_q.csv -exof testv/headrot_case00_3000_q_combinedRotationTest.csv BINAURAL 48 bit testv/stv4ISM48s.wav_32000_48-48_binaural_file_TDHR_EXOF.tst -// 4 ISM with metadata at 32 kbps, 48 kHz in, 48 kHz out, BINAURAL ROOM out, random FER at 5% +// 4 ISM with metadata at 32 kbps, 48 kHz in, 48 kHz out, BINAURAL ROOM IR out, random FER at 5% ../IVAS_cod -ism 4 testv/stvISM1.csv testv/stvISM2.csv testv/stvISM3.csv testv/stvISM4.csv 32000 48 testv/stv4ISM48s.wav bit eid-xor -fer -vbr -bs g192 -ep g192 bit ../scripts/dly_error_profiles/ep_5pct.g192 bit_error ../IVAS_dec BINAURAL_ROOM_IR 48 bit_error testv/stv4ISM48s.wav_32000_48-48_binaural_room_FER5.tst -// 4 ISM with metadata at 48 kbps, 48 kHz in, 48 kHz out, DTX on, BINAURAL ROOM out, random FER at 5% +// 4 ISM with metadata at 48 kbps, 48 kHz in, 48 kHz out, DTX on, BINAURAL ROOM IR out, random FER at 5% ../IVAS_cod -dtx -ism 4 testv/stvISM1.csv testv/stvISM2.csv testv/stvISM3.csv testv/stvISM4.csv 48000 48 testv/stv4ISM48n.wav bit eid-xor -fer -vbr -bs g192 -ep g192 bit ../scripts/dly_error_profiles/ep_5pct.g192 bit_error ../IVAS_dec BINAURAL_ROOM_IR 48 bit_error testv/stv4ISM48n.wav_48000_48-48_DTX_TD_binaural_room_FER5.tst -// 4 ISM with metadata at 64 kbps, 48 kHz in, 48 kHz out, BINAURAL ROOM out +// 4 ISM with metadata at 64 kbps, 48 kHz in, 48 kHz out, BINAURAL ROOM IR out ../IVAS_cod -ism 4 testv/stvISM1.csv testv/stvISM2.csv testv/stvISM3.csv testv/stvISM4.csv 64000 48 testv/stv4ISM48s.wav bit ../IVAS_dec BINAURAL_ROOM_IR 48 bit testv/stv4ISM48s.wav_64000_48-48_binaural_room.tst @@ -624,43 +624,43 @@ eid-xor -fer -vbr -bs g192 -ep g192 bit ../scripts/dly_error_profiles/ep_5pct.g1 ../IVAS_cod -sba 3 48000 32 testv/stv3OA32c.wav bit ../IVAS_dec STEREO 32 bit testv/stv3OA32c.wav_SBA_48000_32-32_stereo.tst -// SBA at 48 kbps, 32kHz in, 32kHz out, BINAURAL ROOM out +// SBA at 48 kbps, 32kHz in, 32kHz out, BINAURAL ROOM IR out ../IVAS_cod -sba 3 48000 32 testv/stv3OA32c.wav bit ../IVAS_dec BINAURAL_ROOM_IR 32 bit testv/stv3OA32c.wav_SBA_48000_32-32_BinauralRoom.tst -// SBA at 48 kbps, 32kHz in, 32kHz out, BINAURAL ROOM out +// SBA at 48 kbps, 32kHz in, 32kHz out, BINAURAL ROOM IR out ../IVAS_cod -sba 3 48000 32 testv/stv3OA32c.wav bit ../IVAS_dec BINAURAL_ROOM_IR 32 bit testv/stv3OA32c.wav_SBA_48000_32-32_BinauralRoom_Subframe.tst -// SBA at 48 kbps, 32kHz in, 32kHz out, BINAURAL ROOM out, Headrotation +// SBA at 48 kbps, 32kHz in, 32kHz out, BINAURAL ROOM IR out, Headrotation ../IVAS_cod -sba 3 48000 32 testv/stv3OA32c.wav bit ../IVAS_dec -t testv/headrot.csv BINAURAL_ROOM_IR 32 bit testv/stv3OA32c.wav_SBA_48000_32-32_BinauralRoom_Headrot.tst -// SBA at 48 kbps, 32kHz in, 32kHz out, BINAURAL ROOM out, Headrotation, external orientation +// SBA at 48 kbps, 32kHz in, 32kHz out, BINAURAL ROOM IR out, Headrotation, external orientation ../IVAS_cod -sba 3 48000 32 testv/stv3OA32c.wav bit ../IVAS_dec -t testv/headrot.csv -exof testv/headrot_case00_3000_q_combinedRotationTest.csv BINAURAL_ROOM_IR 32 bit testv/stv3OA32c.wav_SBA_48000_32-32_BinauralRoom_Headrot_EXOF.tst -// SBA at 48 kbps, 32kHz in, 32kHz out, BINAURAL ROOM out, Headrotation, Orientation tracking +// SBA at 48 kbps, 32kHz in, 32kHz out, BINAURAL ROOM IR out, Headrotation, Orientation tracking ../IVAS_cod -sba 3 48000 32 testv/stv3OA32c.wav bit ../IVAS_dec -t testv/headrot.csv -otr avg BINAURAL_ROOM_IR 32 bit testv/stv3OA32c.pcm_SBA_48000_32-32_BinauralRoom_Headrot_OtrAvg.tst -// SBA at 48 kbps, 32kHz in, 32kHz out, BINAURAL ROOM out, Headrotation, Orientation tracking, external orientation +// SBA at 48 kbps, 32kHz in, 32kHz out, BINAURAL ROOM IR out, Headrotation, Orientation tracking, external orientation ../IVAS_cod -sba 3 48000 32 testv/stv3OA32c.wav bit ../IVAS_dec -t testv/headrot.csv -exof testv/headrot_case00_3000_q_combinedRotationTest.csv -otr avg BINAURAL_ROOM_IR 32 bit testv/stv3OA32c.pcm_SBA_48000_32-32_BinauralRoom_Headrot_EXOF_OtrAvg.tst -// SBA at 48 kbps, 32kHz in, 32kHz out, BINAURAL ROOM out, Headrotation, reference vector tracking +// SBA at 48 kbps, 32kHz in, 32kHz out, BINAURAL ROOM IR out, Headrotation, reference vector tracking ../IVAS_cod -sba 3 48000 32 testv/stv3OA32c.wav bit ../IVAS_dec -t ../scripts/trajectories/full-circle-4s.csv -rvf ../scripts/trajectories/full-circle-4s-Vector3.csv -otr ref_vec BINAURAL_ROOM_IR 32 bit testv/stv3OA32c.pcm_SBA_48000_32-32_BinauralRoom_Headrot_OtrRefPos.tst -// SBA at 48 kbps, 32kHz in, 32kHz out, BINAURAL ROOM out, Headrotation, reference vector tracking, external orientation +// SBA at 48 kbps, 32kHz in, 32kHz out, BINAURAL ROOM IR out, Headrotation, reference vector tracking, external orientation ../IVAS_cod -sba 3 48000 32 testv/stv3OA32c.wav bit ../IVAS_dec -t ../scripts/trajectories/full-circle-4s.csv -exof testv/headrot_case00_3000_q_combinedRotationTest.csv -rvf ../scripts/trajectories/full-circle-4s-Vector3.csv -otr ref_vec BINAURAL_ROOM_IR 32 bit testv/stv3OA32c.pcm_SBA_48000_32-32_BinauralRoom_Headrot_EXOF_OtrRefPos.tst -// SBA at 48 kbps, 32kHz in, 32kHz out, BINAURAL ROOM out, Headrotation, reference vector tracking in level mode +// SBA at 48 kbps, 32kHz in, 32kHz out, BINAURAL ROOM IR out, Headrotation, reference vector tracking in level mode ../IVAS_cod -sba 3 48000 32 testv/stv3OA32c.wav bit ../IVAS_dec -t ../scripts/trajectories/full-circle-with-up-and-down-4s.csv -rvf ../scripts/trajectories/full-circle-with-up-and-down-4s-Vector3.csv -otr ref_vec_lev BINAURAL_ROOM_IR 32 bit testv/stv3OA32c.pcm_SBA_48000_32-32_BinauralRoom_Headrot_OtrRefPosLev.tst -// SBA at 48 kbps, 32kHz in, 32kHz out, BINAURAL ROOM out, Headrotation, reference vector tracking in level mode, external orientation +// SBA at 48 kbps, 32kHz in, 32kHz out, BINAURAL ROOM IR out, Headrotation, reference vector tracking in level mode, external orientation ../IVAS_cod -sba 3 48000 32 testv/stv3OA32c.wav bit ../IVAS_dec -t ../scripts/trajectories/full-circle-with-up-and-down-4s.csv -exof testv/headrot_case00_3000_q_combinedRotationTest.csv -rvf ../scripts/trajectories/full-circle-with-up-and-down-4s-Vector3.csv -otr ref_vec_lev BINAURAL_ROOM_IR 32 bit testv/stv3OA32c.pcm_SBA_48000_32-32_BinauralRoom_Headrot_EXOF_OtrRefPosLev.tst @@ -731,19 +731,19 @@ eid-xor -fer -vbr -bs g192 -ep g192 bit ../scripts/dly_error_profiles/ep_5pct.g1 ../IVAS_cod -sba 1 96000 48 testv/stvFOA48c.wav bit ../IVAS_dec FOA 48 bit testv/stvFOA48c.wav_SBA_96000_48-48_FOA.tst -// SBA at 128 kbps, 32kHz in, 32kHz out, BINAURAL ROOM out, Headrotation +// SBA at 128 kbps, 32kHz in, 32kHz out, BINAURAL ROOM IR out, Headrotation ../IVAS_cod -sba 3 128000 32 testv/stv3OA32c.wav bit ../IVAS_dec -t testv/headrot_case00_3000_q.csv BINAURAL_ROOM_IR 32 bit testv/stv3OA32c.wav_SBA_128000_32-32_Binaural_room_Headrot.tst -// SBA at 128 kbps, 32kHz in, 32kHz out, BINAURAL ROOM out, Headrotation, external orientation +// SBA at 128 kbps, 32kHz in, 32kHz out, BINAURAL ROOM IR out, Headrotation, external orientation ../IVAS_cod -sba 3 128000 32 testv/stv3OA32c.wav bit ../IVAS_dec -t testv/headrot_case00_3000_q.csv -exof testv/headrot_case00_3000_q_combinedRotationTest.csv BINAURAL_ROOM_IR 32 bit testv/stv3OA32c.wav_SBA_128000_32-32_Binaural_room_Headrot_EXOF.tst -// SBA at 128 kbps, 32kHz in, 32kHz out, BINAURAL ROOM out, Headrotation, Orientation tracking +// SBA at 128 kbps, 32kHz in, 32kHz out, BINAURAL ROOM IR out, Headrotation, Orientation tracking ../IVAS_cod -sba 3 128000 32 testv/stv3OA32c.wav bit ../IVAS_dec -t testv/headrot.csv -otr avg BINAURAL_ROOM_IR 32 bit testv/stv3OA32c.pcm_SBA_128000_32-32_Binaural_room_Headrot_OtrAvg.tst -// SBA at 128 kbps, 32kHz in, 32kHz out, BINAURAL ROOM out, Headrotation, Orientation tracking, external orientation +// SBA at 128 kbps, 32kHz in, 32kHz out, BINAURAL ROOM IR out, Headrotation, Orientation tracking, external orientation ../IVAS_cod -sba 3 128000 32 testv/stv3OA32c.wav bit ../IVAS_dec -t testv/headrot.csv -exof testv/headrot_case00_3000_q_combinedRotationTest.csv -otr avg BINAURAL_ROOM_IR 32 bit testv/stv3OA32c.pcm_SBA_128000_32-32_Binaural_room_Headrot_EXOF_OtrAvg.tst @@ -781,7 +781,7 @@ eid-xor -fer -vbr -bs g192 -ep g192 bit ../scripts/dly_error_profiles/ep_5pct.g1 ../IVAS_cod -sba 1 256000 32 testv/stvFOA32c.wav bit ../IVAS_dec BINAURAL_ROOM_IR 32 bit testv/stvFOA32c.wav_SBA_256000_32-32_BINAURAL_ROOM.tst -// SBA at 256 kbps, 32kHz in, 32kHz out, BINAURAL ROOM out, Headrotation, external orientation +// SBA at 256 kbps, 32kHz in, 32kHz out, BINAURAL ROOM IR out, Headrotation, external orientation ../IVAS_cod -sba 1 256000 32 testv/stvFOA32c.wav bit ../IVAS_dec -t testv/headrot.csv -exof testv/headrot_case00_3000_q_combinedRotationTest.csv BINAURAL_ROOM_IR 32 bit testv/stvFOA32c.wav_SBA_256000_32-32_BinauralRoom_Headrot_EXOF.tst @@ -850,6 +850,38 @@ eid-xor -fer -vbr -bs g192 -ep g192 bit ../scripts/dly_error_profiles/ep_5pct.g1 ../IVAS_cod -sba 1 -max_band fb ../scripts/switchPaths/sw_13k2_512k.bin 48 testv/stvFOA48c.wav bit ../IVAS_dec FOA 48 bit testv/stvFOA48c.wav_sw_48-48_FOA.tst +// SBA at 48 kbps, 32kHz in, 32kHz out, BINAURAL_ROOM_REVERB out, Headrotation +../IVAS_cod -sba 3 48000 32 testv/stv3OA32c.wav bit +../IVAS_dec -t testv/headrot.csv BINAURAL_ROOM_REVERB 32 bit testv/stv3OA32c.pcm_SBA_48000_32-32_BinauralRoomReverb_Headrot.tst + +// Planar SBA at 48 kbps, 32kHz in, 32kHz out, BINAURAL_ROOM_REVERB out, Config renderer, Headrotation +../IVAS_cod -sba -2 48000 32 testv/stv2OA32c.wav bit +../IVAS_dec -t testv/headrot.csv -render_config testv/rend_config_renderer.cfg BINAURAL_ROOM_REVERB 32 bit testv/stv2OA32c.pcm_planarSBA_48000_32-32_BinauralRoomReverb_Config_renderer_Headrot.tst + +// SBA at 48 kbps, 32kHz in, 48kHz out, BINAURAL_ROOM_REVERB out (Model from file), Headrotation +../IVAS_cod -sba 1 48000 32 testv/stvFOA32c.wav bit +../IVAS_dec -hrtf ../scripts/binauralRenderer_interface/binaural_renderers_hrtf_data/ivas_binaural_48kHz.bin -t testv/headrot.csv BINAURAL_ROOM_REVERB 48 bit testv/stvFOA32c.pcm_SBA_48000_32-48_BinauralRoomReverb_Headrot_BinauralFile.tst + +// Planar SBA at 48 kbps, 32kHz in, 32kHz out, BINAURAL_ROOM_REVERB out (Model from file), Config renderer, Headrotation +../IVAS_cod -sba -3 48000 32 testv/stv3OA32c.wav bit +../IVAS_dec -hrtf ../scripts/binauralRenderer_interface/binaural_renderers_hrtf_data/ivas_binaural_32kHz.bin -t testv/headrot.csv -render_config testv/rend_config_renderer.cfg BINAURAL_ROOM_REVERB 32 bit testv/stv3OA32c.pcm_planarSBA_48000_32-32_BinauralRoomReverb_Config_renderer_Headrot_BinauralFile.tst + +// SBA at 128 kbps, 32kHZ in, 32kHz out, BINAURAL_ROOM_REVERB out Headrotation +../IVAS_cod -sba 3 128000 32 testv/stv3OA32c.wav bit +../IVAS_dec -t testv/headrot_case00_3000_q.csv BINAURAL_ROOM_REVERB 32 bit testv/stv3OA32c.pcm_SBA_12800032-32_BinauralRoomReverb_Headrot.tst + +// SBA at 128 kbps, 32kHZ in, 32kHz out, BINAURAL_ROOM_REVERB out, Config renderer, Headrotation +../IVAS_cod -sba 3 128000 32 testv/stv3OA32c.wav bit +../IVAS_dec -t testv/headrot_case00_3000_q.csv -render_config testv/rend_config_renderer.cfg BINAURAL_ROOM_REVERB 32 bit testv/stv3OA32c.pcm_SBA_12800032-32_BinauralRoomReverb_Config_renderer_Headrot.tst + +// SBA at 128 kbps, 32kHZ in, 16kHz out, BINAURAL_ROOM_REVERB out (Model from file), Headrotation +../IVAS_cod -sba 2 128000 32 testv/stv2OA32c.wav bit +../IVAS_dec -hrtf ../scripts/binauralRenderer_interface/binaural_renderers_hrtf_data/ivas_binaural_16kHz.bin -t testv/headrot_case00_3000_q.csv BINAURAL_ROOM_REVERB 16 bit testv/stv2OA32c.pcm_SBA_12800032-16_BinauralRoomReverb_Headrot_BinauralFile.tst + +// Planar SBA at 128 kbps, 48kHZ in, 32kHz out, BINAURAL_ROOM_REVERB out (Model from file), Config renderer, Headrotation +../IVAS_cod -sba -1 128000 48 testv/stvFOA48c.wav bit +../IVAS_dec -hrtf ../scripts/binauralRenderer_interface/binaural_renderers_hrtf_data/ivas_binaural_32kHz.bin -t testv/headrot_case00_3000_q.csv -render_config testv/rend_config_renderer.cfg BINAURAL_ROOM_REVERB 32 bit testv/stvFOA48c.pcm_planarSBA_12800032-32_BinauralRoomReverb_Config_renderer_Headrot_BinauralFile.tst + // MASA 1dir 1TC at 13.2 kbps, 48kHz in, 48kHz out, BINAURAL out ../IVAS_cod -masa 1 testv/stv1MASA1TC48c.met 13200 48 testv/stv1MASA1TC48c.wav bit @@ -860,19 +892,19 @@ eid-xor -fer -vbr -bs g192 -ep g192 bit ../scripts/dly_error_profiles/ep_5pct.g1 eid-xor -fer -vbr -bs g192 -ep g192 bit ../scripts/dly_error_profiles/ep_5pct.g192 bit_error ../IVAS_dec HOA3 48 bit_error testv/stv1MASA1TC48c.wav_16400_48-48_HOA3_FER5.tst -// MASA 1dir 1TC at 24.4 kbps, 48kHz in, 48kHz out, BINAURAL ROOM out +// MASA 1dir 1TC at 24.4 kbps, 48kHz in, 48kHz out, BINAURAL ROOM IR out ../IVAS_cod -masa 1 testv/stv1MASA1TC48c.met 24400 48 testv/stv1MASA1TC48c.wav bit ../IVAS_dec BINAURAL_ROOM_IR 48 bit testv/stv1MASA1TC48c.wav_24400_48-48_BinauralRoom.tst -// MASA 1dir 1TC at 24.4 kbps, 48kHz in, 48kHz out, BINAURAL ROOM out +// MASA 1dir 1TC at 24.4 kbps, 48kHz in, 48kHz out, BINAURAL ROOM IR out ../IVAS_cod -masa 1 testv/stv1MASA1TC48c.met 24400 48 testv/stv1MASA1TC48c.wav bit ../IVAS_dec BINAURAL_ROOM_IR 48 bit testv/stv1MASA1TC48c.wav_24400_48-48_BinauralRoom_Subframe.tst -// MASA 1dir 1TC at 24.4 kbps, 48kHz in, 48kHz out, BINAURAL ROOM out, Headrotation +// MASA 1dir 1TC at 24.4 kbps, 48kHz in, 48kHz out, BINAURAL ROOM IR out, Headrotation ../IVAS_cod -masa 1 testv/stv1MASA1TC48c.met 24400 48 testv/stv1MASA1TC48c.wav bit ../IVAS_dec -t testv/headrot.csv BINAURAL_ROOM_IR 48 bit testv/stv1MASA1TC48c.wav_24400_48-48_BinauralRoom_Headrot.tst -// MASA 1dir 1TC at 24.4 kbps, 48kHz in, 48kHz out, BINAURAL ROOM out, Headrotation, external orientation +// MASA 1dir 1TC at 24.4 kbps, 48kHz in, 48kHz out, BINAURAL ROOM IR out, Headrotation, external orientation ../IVAS_cod -masa 1 testv/stv1MASA1TC48c.met 24400 48 testv/stv1MASA1TC48c.wav bit ../IVAS_dec -t testv/headrot.csv -exof testv/headrot_case00_3000_q_combinedRotationTest.csv BINAURAL_ROOM_IR 48 bit testv/stv1MASA1TC48c.wav_24400_48-48_BinauralRoom_Headrot_EXOF.tst @@ -919,23 +951,23 @@ eid-xor -fer -vbr -bs g192 -ep g192 bit ../scripts/dly_error_profiles/ep_5pct.g1 ../IVAS_cod -masa 2 testv/stv1MASA2TC48c.met 24400 48 testv/stv1MASA2TC48c.wav bit ../IVAS_dec STEREO 48 bit testv/stv1MASA2TC48c.wav_24400_48-48_STEREO.tst -// MASA 1dir 2TC at 32 kbps, 48kHz in, 48kHz out, BINAURAL ROOM out +// MASA 1dir 2TC at 32 kbps, 48kHz in, 48kHz out, BINAURAL ROOM IR out ../IVAS_cod -masa 2 testv/stv1MASA2TC48c.met 32000 48 testv/stv1MASA2TC48c.wav bit ../IVAS_dec BINAURAL_ROOM_IR 48 bit testv/stv1MASA2TC48c.wav_32000_48-48_BinauralRoom.tst -// MASA 1dir 2TC at 32 kbps, 48kHz in, 48kHz out, BINAURAL ROOM out, Headrotation +// MASA 1dir 2TC at 32 kbps, 48kHz in, 48kHz out, BINAURAL ROOM IR out, Headrotation ../IVAS_cod -masa 2 testv/stv1MASA2TC48c.met 32000 48 testv/stv1MASA2TC48c.wav bit ../IVAS_dec -t testv/headrot.csv BINAURAL_ROOM_IR 48 bit testv/stv1MASA2TC48c.wav_32000_48-48_BinauralRoom_Headrot.tst -// MASA 1dir 2TC at 32 kbps, 48kHz in, 48kHz out, BINAURAL ROOM out, Headrotation, external orientation +// MASA 1dir 2TC at 32 kbps, 48kHz in, 48kHz out, BINAURAL ROOM IR out, Headrotation, external orientation ../IVAS_cod -masa 2 testv/stv1MASA2TC48c.met 32000 48 testv/stv1MASA2TC48c.wav bit ../IVAS_dec -t testv/headrot.csv -exof testv/headrot_case00_3000_q_combinedRotationTest.csv BINAURAL_ROOM_IR 48 bit testv/stv1MASA2TC48c.wav_32000_48-48_BinauralRoom_Headrot_EXOF.tst -// MASA 1dir 2TC at 32 kbps, 48kHz in, 48kHz out, BINAURAL ROOM out, Headrotation, Orientation tracking +// MASA 1dir 2TC at 32 kbps, 48kHz in, 48kHz out, BINAURAL ROOM IR out, Headrotation, Orientation tracking ../IVAS_cod -masa 2 testv/stv1MASA2TC48c.met 32000 48 testv/stv1MASA2TC48c.wav bit ../IVAS_dec -t testv/headrot.csv -otr avg BINAURAL_ROOM_IR 48 bit testv/stv_IVASMASA_1dir2TC.pcm_32000_48-48_BinauralRoom_Headrot_OtrAvg.tst -// MASA 1dir 2TC at 32 kbps, 48kHz in, 48kHz out, BINAURAL ROOM out, Headrotation, Orientation tracking, external orientation +// MASA 1dir 2TC at 32 kbps, 48kHz in, 48kHz out, BINAURAL ROOM IR out, Headrotation, Orientation tracking, external orientation ../IVAS_cod -masa 2 testv/stv1MASA2TC48c.met 32000 48 testv/stv1MASA2TC48c.wav bit ../IVAS_dec -t testv/headrot.csv -exof testv/headrot_case00_3000_q_combinedRotationTest.csv -otr avg BINAURAL_ROOM_IR 48 bit testv/stv_IVASMASA_1dir2TC.pcm_32000_48-48_BinauralRoom_Headrot_EXOF_OtrAvg.tst @@ -1096,11 +1128,11 @@ eid-xor -fer -vbr -bs g192 -ep g192 bit ../scripts/dly_error_profiles/ep_5pct.g1 ../IVAS_cod -mc 5_1 64000 48 testv/stv51MC48c.wav bit ../IVAS_dec -t testv/headrot.csv -exof testv/headrot_case00_3000_q_combinedRotationTest.csv BINAURAL 48 bit testv/stv51MC48c.wav_MC51_64000_48-48_Binaural_Headrot_EXOF.tst -// Multi-channel 5_1 at 64 kbps, 48kHz in, 48kHz out, BINAURAL ROOM out, Headrotation +// Multi-channel 5_1 at 64 kbps, 48kHz in, 48kHz out, BINAURAL ROOM IR out, Headrotation ../IVAS_cod -mc 5_1 64000 48 testv/stv51MC48c.wav bit ../IVAS_dec -t testv/headrot_case00_3000_q.csv BINAURAL_ROOM_IR 48 bit testv/stv51MC48c.wav_MC51_64000_48-48_Binaural_room_Headrot.tst -// Multi-channel 5_1 at 64 kbps, 48kHz in, 48kHz out, BINAURAL ROOM out, Headrotation, external orientation +// Multi-channel 5_1 at 64 kbps, 48kHz in, 48kHz out, BINAURAL ROOM IR out, Headrotation, external orientation ../IVAS_cod -mc 5_1 64000 48 testv/stv51MC48c.wav bit ../IVAS_dec -t testv/headrot_case00_3000_q.csv -exof testv/headrot_case00_3000_q_combinedRotationTest.csv BINAURAL_ROOM_IR 48 bit testv/stv51MC48c.wav_MC51_64000_48-48_Binaural_room_Headrot_EXOF.tst @@ -1126,7 +1158,7 @@ eid-xor -fer -vbr -bs g192 -ep g192 bit ../scripts/dly_error_profiles/ep_5pct.g1 eid-xor -fer -vbr -bs g192 -ep g192 bit ../scripts/dly_error_profiles/ep_5pct.g192 bit_error ../IVAS_dec STEREO 48 bit_error testv/stv51MC48c.wav_MC51_256000_48-48_stereo_FER5.tst -// Multi-channel 5_1 at 192 kbps, 48kHz in, 48kHz out, BINAURAL ROOM out +// Multi-channel 5_1 at 192 kbps, 48kHz in, 48kHz out, BINAURAL ROOM IR out ../IVAS_cod -mc 5_1 192000 48 testv/stv51MC48c.wav bit ../IVAS_dec BINAURAL_ROOM_IR 48 bit testv/stv51MC48c.wav_MC51_192000_48-48_BinauralRoom.tst @@ -1134,19 +1166,19 @@ eid-xor -fer -vbr -bs g192 -ep g192 bit ../scripts/dly_error_profiles/ep_5pct.g1 ../IVAS_cod -mc 5_1 256000 48 testv/stv51MC48c.wav bit ../IVAS_dec MONO 48 bit testv/stv51MC48c.wav_MC51_256000_48-48_mono.tst -// Multi-channel 5_1 at 256 kbps, 48kHz in, 48kHz out, BINAURAL ROOM out, head rotation +// Multi-channel 5_1 at 256 kbps, 48kHz in, 48kHz out, BINAURAL ROOM IR out, head rotation ../IVAS_cod -mc 5_1 256000 48 testv/stv51MC48c.wav bit ../IVAS_dec -t testv/headrot_case00_3000_q.csv BINAURAL_ROOM_IR 48 bit testv/stv51MC48c.wav_MC51_256000_48-48_BinauralRoom_Headrot.tst -// Multi-channel 5_1 at 256 kbps, 48kHz in, 48kHz out, BINAURAL ROOM out, head rotation, external orientation +// Multi-channel 5_1 at 256 kbps, 48kHz in, 48kHz out, BINAURAL ROOM IR out, head rotation, external orientation ../IVAS_cod -mc 5_1 256000 48 testv/stv51MC48c.wav bit ../IVAS_dec -t testv/headrot_case00_3000_q.csv -exof testv/headrot_case00_3000_q_combinedRotationTest.csv BINAURAL_ROOM_IR 48 bit testv/stv51MC48c.wav_MC51_256000_48-48_BinauralRoom_Headrot_EXOF.tst -// Multi-channel 5_1 at 256 kbps, 48kHz in, 48kHz out, BINAURAL ROOM out, head rotation, Orientation tracking +// Multi-channel 5_1 at 256 kbps, 48kHz in, 48kHz out, BINAURAL ROOM IR out, head rotation, Orientation tracking ../IVAS_cod -mc 5_1 256000 48 testv/stv51MC48c.wav bit ../IVAS_dec -t testv/headrot.csv -otr avg BINAURAL_ROOM_IR 48 bit testv/stv51MC48c.pcm_MC51_256000_48-48_BinauralRoom_Headrot_OtrAvg.tst -// Multi-channel 5_1 at 256 kbps, 48kHz in, 48kHz out, BINAURAL ROOM out, head rotation, Orientation tracking, external orientation +// Multi-channel 5_1 at 256 kbps, 48kHz in, 48kHz out, BINAURAL ROOM IR out, head rotation, Orientation tracking, external orientation ../IVAS_cod -mc 5_1 256000 48 testv/stv51MC48c.wav bit ../IVAS_dec -t testv/headrot.csv -exof testv/headrot_case00_3000_q_combinedRotationTest.csv -otr avg BINAURAL_ROOM_IR 48 bit testv/stv51MC48c.pcm_MC51_256000_48-48_BinauralRoom_EXOF_OtrAvg.tst @@ -1568,6 +1600,10 @@ eid-xor -fer -vbr -bs g192 -ep g192 bit ../scripts/dly_error_profiles/ep_5pct.g1 ../IVAS_cod -ism_sba 1 1 testv/stvISM1.csv 32000 48 testv/stvOSBA_1ISM_FOA48c.wav bit ../IVAS_dec BINAURAL 48 bit testv/stvOSBA_1ISM_FOA48c.wav_BINAURAL_32000_48-48.tst +// OSBA FOA 1ISM at 48 kbps, 16kHz in, 16kHz out, BINAURAL_ROOM_REVERB (Model from file) out +../IVAS_cod -ism_sba 1 1 testv/stvISM1.csv 32000 16 testv/stvOSBA_1ISM_FOA16c.wav bit +../IVAS_dec -hrtf ../scripts/binauralRenderer_interface/binaural_renderers_hrtf_data/ivas_binaural_16kHz.bin BINAURAL_ROOM_REVERB 16 bit testv/stvOSBA_1ISM_FOA16c.wav_BINAURAL_ROOM_REVERB_32000_16-16.tst + // OSBA FOA 2ISM at 64 kbps, 48kHz in, 48kHz out, HOA3 out ../IVAS_cod -ism_sba 2 1 testv/stvISM1.csv testv/stvISM2.csv 64000 48 testv/stvOSBA_2ISM_FOA48c.wav bit ../IVAS_dec HOA3 48 bit testv/stvOSBA_2ISM_FOA48c.wav_HOA3_64000_48-48.tst @@ -1580,9 +1616,13 @@ eid-xor -fer -vbr -bs g192 -ep g192 bit ../scripts/dly_error_profiles/ep_5pct.g1 ../IVAS_cod -ism_sba 4 1 testv/stvISM1.csv testv/stvISM2.csv testv/stvISM3.csv testv/stvISM4.csv 256000 48 testv/stvOSBA_4ISM_FOA48c.wav bit ../IVAS_dec EXT 48 bit testv/stvOSBA_4ISM_FOA48c.wav_EXT_256000_48-48.tst -// OSBA FOA 4ISM at 512 kbps, 48kHz in, 48kHz out, BINAURAL out +// OSBA FOA 4ISM at 512 kbps, 48kHz in, 48kHz out, BINAURAL (Model from file) out ../IVAS_cod -ism_sba 4 1 testv/stvISM1.csv testv/stvISM2.csv testv/stvISM3.csv testv/stvISM4.csv 512000 48 testv/stvOSBA_4ISM_FOA48c.wav bit -../IVAS_dec BINAURAL 48 bit testv/stvOSBA_4ISM_FOA48c.wav_BINAURAL_512000_48-48.tst +../IVAS_dec -hrtf ../scripts/binauralRenderer_interface/binaural_renderers_hrtf_data/ivas_binaural_48kHz.bin BINAURAL 48 bit testv/stvOSBA_4ISM_FOA48c.wav_BINAURAL_512000_48-48.tst + +// OSBA FOA 4ISM at 384 kbps, 32kHz in, 32kHz out, BINAURAL ROOM IR (Model from file) out +../IVAS_cod -ism_sba 4 1 testv/stvISM1.csv testv/stvISM2.csv testv/stvISM3.csv testv/stvISM4.csv 384000 32 testv/stvOSBA_4ISM_FOA32c.wav bit +../IVAS_dec -hrtf ../scripts/binauralRenderer_interface/binaural_renderers_hrtf_data/ivas_binaural_32kHz.bin BINAURAL_ROOM_IR 32 bit testv/stvOSBA_4ISM_FOA32c.wav_BINAURAL_384000_32-32.tst // OSBA 2OA 1ISM at 24.4 kbps, 48kHz in, 48kHz out, FOA out ../IVAS_cod -ism_sba 1 2 testv/stvISM1.csv 24400 48 testv/stvOSBA_1ISM_2OA48c.wav bit @@ -1592,6 +1632,10 @@ eid-xor -fer -vbr -bs g192 -ep g192 bit ../scripts/dly_error_profiles/ep_5pct.g1 ../IVAS_cod -ism_sba 2 2 testv/stvISM1.csv testv/stvISM2.csv 48000 48 testv/stvOSBA_2ISM_2OA48c.wav bit ../IVAS_dec MONO 48 bit testv/stvOSBA_2ISM_2OA48c.wav_MONO_48000_48-48.tst +// OSBA 2OA 2ISM at 64 kbps, 32kHz in, 16kHz out, BINAURAL ROOM REVERB out +../IVAS_cod -ism_sba 2 2 testv/stvISM1.csv testv/stvISM2.csv 48000 32 testv/stvOSBA_2ISM_2OA32c.wav bit +../IVAS_dec BINAURAL_ROOM_REVERB 16 bit testv/stvOSBA_2ISM_2OA32c.wav_MONO_64000_32-16.tst + // OSBA 2OA 3ISM at 96 kbps, 48kHz in, 48kHz out, STEREO out ../IVAS_cod -ism_sba 3 2 testv/stvISM1.csv testv/stvISM2.csv testv/stvISM3.csv 96000 48 testv/stvOSBA_3ISM_2OA48c.wav bit ../IVAS_dec STEREO 48 bit testv/stvOSBA_3ISM_2OA48c.wav_STEREO_96000_48-48.tst @@ -1612,11 +1656,15 @@ eid-xor -fer -vbr -bs g192 -ep g192 bit ../scripts/dly_error_profiles/ep_5pct.g1 ../IVAS_cod -ism_sba 3 3 testv/stvISM1.csv testv/stvISM2.csv testv/stvISM3.csv 128000 48 testv/stvOSBA_3ISM_3OA48c.wav bit ../IVAS_dec BINAURAL 48 bit testv/stvOSBA_3ISM_3OA48c.wav_BINAURAL_128000_48-48.tst +// OSBA 3OA 3ISM at 160 kbps, 16kHz in, 48kHz out, BINAURAL ROOM IR out +../IVAS_cod -ism_sba 3 3 testv/stvISM1.csv testv/stvISM2.csv testv/stvISM3.csv 160000 16 testv/stvOSBA_3ISM_3OA16c.wav bit +../IVAS_dec BINAURAL_ROOM_IR 48 bit testv/stvOSBA_3ISM_3OA416c.wav_BINAURAL_ROOM_IR_160000_16-48.tst + // OSBA 3OA 4ISM at 16.4 kbps, 48kHz in, 48kHz out, 5_1 out ../IVAS_cod -ism_sba 4 3 testv/stvISM1.csv testv/stvISM2.csv testv/stvISM3.csv testv/stvISM4.csv 16400 48 testv/stvOSBA_4ISM_3OA48c.wav bit ../IVAS_dec 5_1 48 bit testv/stvOSBA_4ISM_3OA48c.wav_5_1_16400_48-48.tst -// OSBA 3OA 4ISM bitrate switching 13.2 to 512, 48kHz in, 48kHz out, BIN out +// OSBA 3OA 4ISM bitrate switching 13.2 to 512, 48kHz in, 48kHz out, BINAURAL out ../IVAS_cod -ism_sba 4 3 testv/stvISM1.csv testv/stvISM2.csv testv/stvISM3.csv testv/stvISM4.csv ../scripts/switchPaths/sw_13k2_512k.bin 48 testv/stvOSBA_4ISM_3OA48c.wav bit ../IVAS_dec BINAURAL 48 bit testv/stvOSBA_4ISM_3OA48c.wav_BINAURAL_sw_13k2_512k_48-48.tst @@ -1646,6 +1694,10 @@ eid-xor -fer -vbr -bs g192 -ep g192 bit ../scripts/dly_error_profiles/ep_5pct.g1 eid-xor -fer -vbr -bs g192 -ep g192 bit ../scripts/dly_error_profiles/ep_10pct.g192 bit_error ../IVAS_dec STEREO 32 bit_error testv/stvOSBA_3ISM_2OA48c.wav_STEREO_sw_48-32_FER10.tst +// OSBA 3ISM 3OA at bitrate switching 13.2 to 512 kbps, 48kHz in, 32kHz out, BINAURAL ROOM REVERB out +../IVAS_cod -ism_sba 3 3 testv/stvISM1.csv testv/stvISM2.csv testv/stvISM3.csv ../scripts/switchPaths/sw_13k2_512k.bin 48 testv/stvOSBA_3ISM_3OA48c.wav bit +../IVAS_dec BINAURAL_ROOM_REVERB 32 bit testv/stvOSBA_3ISM_2OA48c.wav_BINAURAL_ROOM_REVERB_sw_48-32.tst + // OSBA planar FOA 1ISM at 256 kbps, 48 kHz in, 48 kHz out, BINAURAL out ../IVAS_cod -ism_sba 1 -1 testv/stvISM1.csv 256000 48 testv/stvOSBA_1ISM_FOA48c.wav bit ../IVAS_dec BINAURAL 48 bit testv/stvOSBA_1ISM_pFOA48c.wav_BINAURAL_256000_48-48.tst @@ -1654,6 +1706,10 @@ eid-xor -fer -vbr -bs g192 -ep g192 bit ../scripts/dly_error_profiles/ep_10pct.g ../IVAS_cod -ism_sba 2 -1 testv/stvISM1.csv testv/stvISM2.csv 512000 48 testv/stvOSBA_2ISM_FOA48c.wav bit ../IVAS_dec BINAURAL 48 bit testv/stvOSBA_2ISM_pFOA48c.wav_BINAURAL_512000_48-48.tst -// OSBA planar 3OA 4ISM at 512 kbps, 48 kHz in, 48 kHz out, BINAURAL out +// OSBA planar 3OA 4ISM at 512 kbps, 48 kHz in, 48 kHz out, BINAURAL ROOM IR out ../IVAS_cod -ism_sba 4 -3 testv/stvISM1.csv testv/stvISM2.csv testv/stvISM3.csv testv/stvISM4.csv 512000 48 testv/stvOSBA_4ISM_3OA48c.wav bit -../IVAS_dec BINAURAL 48 bit testv/stvOSBA_4ISM_p3OA48c.wav_BINAURAL_512000_48-48.tst +../IVAS_dec BINAURAL_ROOM_IR 48 bit testv/stvOSBA_4ISM_p3OA48c.wav_BINAURAL_ROOM_IR_512000_48-48.tst + +// OSBA planar 2OA 4ISM at 512 kbps, 48 kHz in, 48 kHz out, BINAURAL ROOM REVERB (Model from file) out +../IVAS_cod -ism_sba 4 -2 testv/stvISM1.csv testv/stvISM2.csv testv/stvISM3.csv testv/stvISM4.csv 512000 48 testv/stvOSBA_4ISM_2OA48c.wav bit +../IVAS_dec -hrtf ../scripts/binauralRenderer_interface/binaural_renderers_hrtf_data/ivas_binaural_48kHz.bin BINAURAL_ROOM_REVERB 48 bit testv/stvOSBA_4ISM_p3OA48c.wav_BINAURAL_ROOM_REVERB_512000_48-48.tst diff --git a/scripts/config/self_test_ltv.prm b/scripts/config/self_test_ltv.prm index 0aa3f764dc250b5bbe62c9ec69836189018a1f7c..971a577ed8db797e1615b9220d7091f330432447 100644 --- a/scripts/config/self_test_ltv.prm +++ b/scripts/config/self_test_ltv.prm @@ -401,7 +401,7 @@ eid-xor -fer -vbr -bs g192 -ep g192 bit ../scripts/dly_error_profiles/ep_5pct.g1 // 3 ISM with metadata at 48 kbps, 48 kHz in, 48 kHz out, EXT out ../IVAS_cod -ism 3 testv/ltvISM1.csv testv/ltvISM2.csv testv/ltvISM3.csv 48000 48 testv/ltv48_3ISM.wav bit -../IVAS_dec MONO 48 bit testv/ltv48_3ISM.48000_48-48_MONO.tst +../IVAS_dec EXT 48 bit testv/ltv48_3ISM.48000_48-48_MONO.tst // 3 ISM with metadata at 64 kbps, 48 kHz in, 48 kHz out, EXT out ../IVAS_cod -ism 3 testv/ltvISM1.csv testv/ltvISM2.csv testv/ltvISM3.csv 64000 48 testv/ltv48_3ISM.wav bit diff --git a/scripts/parse_mld_xml.py b/scripts/parse_mld_xml.py index 34371deabc2e586bb1525a6b7259bbe329c2c51b..e3b6dd57ae87232b7be468a9b1d37147d0318413 100644 --- a/scripts/parse_mld_xml.py +++ b/scripts/parse_mld_xml.py @@ -25,11 +25,13 @@ if __name__ == '__main__': with open(csv_file,'w') as outfile: for testcase in testcases: - fulltestname = testcase.get('file') + "::" + testcase.get('name') - system_out = testcase.find(".//system-out") - mld_val = None - if system_out is not None: - for line in system_out.text.split('\n'): - if line.startswith('MLD:'): - mld_val = float(line.split()[1]) - outfile.write(fulltestname + ';' + str(mld_val)+'\n') + if testcase.find('.//skipped') == None: + if testcase.get('file') == None: + fulltestname = testcase.get('classname').replace('.','/') + ".py::" + testcase.get('name') + else: + fulltestname = testcase.get('file') + "::" + testcase.get('name') + if testcase.find('.//property') == None: + mld_val = None + else: + mld_val = testcase.find('.//property').get('value') # Currently MLD is the only set property. If more are added updates are needed here. + outfile.write(fulltestname + ';' + str(mld_val)+'\n') diff --git a/scripts/prepare_combined_format_inputs.py b/scripts/prepare_combined_format_inputs.py index f51da80db9c5a2c098eaa48fc1afea7c95b3ad60..fe80c426820d477f385d6e0c3d8c06b87649f632 100755 --- a/scripts/prepare_combined_format_inputs.py +++ b/scripts/prepare_combined_format_inputs.py @@ -38,13 +38,11 @@ import numpy as np from pyaudio3dtools import audiofile, audioarray +FS = [48, 32, 16] # scripts/testv/ path input_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'testv') -if 'TESTV_DIR' in os.environ: - output_dir = os.environ['TESTV_DIR'] -else: - output_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'testv') +output_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'testv') print(f'Writing new files into {output_dir}') @@ -52,24 +50,24 @@ print(f'Writing new files into {output_dir}') force_overwrite = False # overwrite existing files # define MASA test item files -masa_alts = ({'masa_meta_file': 'stv2MASA2TC48c.met', - 'masa_audio_file': 'stv2MASA2TC48c.wav', +masa_alts = ({'masa_meta_file': 'stv2MASA2TC{}c.met', + 'masa_audio_file': 'stv2MASA2TC{}c.wav', 'masa_tag': '2MASA2TC'}, - {'masa_meta_file': 'stv2MASA1TC48c.met', - 'masa_audio_file': 'stv2MASA1TC48c.wav', + {'masa_meta_file': 'stv2MASA1TC{}c.met', + 'masa_audio_file': 'stv2MASA1TC{}c.wav', 'masa_tag': '2MASA1TC'}, - {'masa_meta_file': 'stv1MASA2TC48c.met', - 'masa_audio_file': 'stv1MASA2TC48c.wav', + {'masa_meta_file': 'stv1MASA2TC{}c.met', + 'masa_audio_file': 'stv1MASA2TC{}c.wav', 'masa_tag': '1MASA2TC'}, - {'masa_meta_file': 'stv1MASA1TC48c.met', - 'masa_audio_file': 'stv1MASA1TC48c.wav', + {'masa_meta_file': 'stv1MASA1TC{}c.met', + 'masa_audio_file': 'stv1MASA1TC{}c.wav', 'masa_tag': '1MASA1TC'}) -sba_alts = ({'sba_audio_file': 'stvFOA48c.wav', +sba_alts = ({'sba_audio_file': 'stvFOA{}c.wav', 'sba_tag': 'FOA'}, - {'sba_audio_file': 'stv2OA48c.wav', + {'sba_audio_file': 'stv2OA{}c.wav', 'sba_tag': '2OA'}, - {'sba_audio_file': 'stv3OA48c.wav', + {'sba_audio_file': 'stv3OA{}c.wav', 'sba_tag': '3OA'}) # files containing 1-4 ISMs as channels @@ -78,53 +76,62 @@ ism_files = ('stv1ISM48s.wav', 'stv2ISM48s.wav', 'stv3ISM48s.wav', 'stv4ISM48s.w ism_meta_files = ('stvISM1.csv', 'stvISM2.csv', 'stvISM3.csv', 'stvISM4.csv') wrote_files = [] -for enum_idx, (ism_audio_file, ism_meta_file) in enumerate(zip(ism_files, ism_meta_files)): - n_isms = enum_idx + 1 - ism_audio, ism_fs = audiofile.readfile(filename=os.path.join(input_dir, ism_audio_file)) - - for masa_item in masa_alts: - masa_tag = masa_item['masa_tag'] - - omasa_file_body = f'stvOMASA_{n_isms}ISM_{masa_tag}48c' - omasa_file = os.path.join(output_dir, f'{omasa_file_body}.wav') - - if not os.path.exists(omasa_file) or force_overwrite: - audiofile.combinefiles(in_filenames=[os.path.join(input_dir, ism_audio_file), - os.path.join(input_dir, masa_item['masa_audio_file'])], - out_file=omasa_file) - wrote_files.append(omasa_file) - - # copy ISM metadata files under names matching the combined file - for ism_idx in range(n_isms): - ism_file_name = os.path.join(output_dir, f'{omasa_file_body}_ISM{ism_idx+1}{os.path.splitext(ism_meta_file)[1]}') - if not os.path.exists(ism_file_name) or force_overwrite: - shutil.copyfile(os.path.join(input_dir, ism_meta_file), ism_file_name) - wrote_files.append(ism_file_name) - - # copy MASA metadata file under a matching name - masa_meta_name = os.path.join(output_dir, f'{omasa_file_body}{os.path.splitext(masa_item["masa_meta_file"])[1]}') - - if not os.path.exists(masa_meta_name) or force_overwrite: - shutil.copyfile(os.path.join(input_dir, masa_item['masa_meta_file']), masa_meta_name) - wrote_files.append(masa_meta_name) - for sba_item in sba_alts: - sba_tag = sba_item['sba_tag'] - - osba_file_body = f'stvOSBA_{n_isms}ISM_{sba_tag}48c' - osba_file = os.path.join(output_dir, f'{osba_file_body}.wav') - - if not os.path.exists(osba_file) or force_overwrite: - audiofile.combinefiles(in_filenames=[os.path.join(input_dir, ism_audio_file), - os.path.join(input_dir, sba_item['sba_audio_file'])], - out_file=osba_file) - wrote_files.append(osba_file) - - # copy ISM metadata files under names matching the combined file - for ism_idx in range(n_isms): - ism_file_name = os.path.join(output_dir, f'{osba_file_body}_ISM{ism_idx+1}{os.path.splitext(ism_meta_file)[1]}') - if not os.path.exists(ism_file_name) or force_overwrite: - shutil.copyfile(os.path.join(input_dir, ism_meta_file), ism_file_name) - wrote_files.append(ism_file_name) +for fs in FS: + for enum_idx, (ism_audio_file, ism_meta_file) in enumerate(zip(ism_files, ism_meta_files)): + n_isms = enum_idx + 1 + ism_audio, ism_fs = audiofile.readfile(filename=os.path.join(input_dir, ism_audio_file)) + + # no stv MASA files in other sampling rates available currently + if fs == 48: + for masa_item in masa_alts: + masa_tag = masa_item['masa_tag'] + masa_audio_file = masa_item['masa_audio_file'].format(fs) + meta_file = masa_item['masa_meta_file'].format(fs) + + omasa_file_body = f'stvOMASA_{n_isms}ISM_{masa_tag}{fs}c' + omasa_file = os.path.join(output_dir, f'{omasa_file_body}.wav') + + if not os.path.exists(omasa_file) or force_overwrite: + audiofile.combinefiles(in_filenames=[os.path.join(input_dir, ism_audio_file), + os.path.join(input_dir, masa_audio_file)], + out_file=omasa_file, + in_fs=fs * 1000) + wrote_files.append(omasa_file) + + # copy ISM metadata files under names matching the combined file + for ism_idx in range(n_isms): + ism_file_name = os.path.join(output_dir, f'{omasa_file_body}_ISM{ism_idx+1}{os.path.splitext(ism_meta_file)[1]}') + if not os.path.exists(ism_file_name) or force_overwrite: + shutil.copyfile(os.path.join(input_dir, ism_meta_file), ism_file_name) + wrote_files.append(ism_file_name) + + # copy MASA metadata file under a matching name + masa_meta_name = os.path.join(output_dir, f'{omasa_file_body}{os.path.splitext(meta_file)[1]}') + + if not os.path.exists(masa_meta_name) or force_overwrite: + shutil.copyfile(os.path.join(input_dir, meta_file), masa_meta_name) + wrote_files.append(masa_meta_name) + + for sba_item in sba_alts: + sba_tag = sba_item['sba_tag'] + sba_audio_file = sba_item['sba_audio_file'].format(fs) + + osba_file_body = f'stvOSBA_{n_isms}ISM_{sba_tag}{fs}c' + osba_file = os.path.join(output_dir, f'{osba_file_body}.wav') + + if not os.path.exists(osba_file) or force_overwrite: + audiofile.combinefiles(in_filenames=[os.path.join(input_dir, ism_audio_file), + os.path.join(input_dir, sba_audio_file)], + out_file=osba_file, + in_fs=fs * 1000) + wrote_files.append(osba_file) + + # copy ISM metadata files under names matching the combined file + for ism_idx in range(n_isms): + ism_file_name = os.path.join(output_dir, f'{osba_file_body}_ISM{ism_idx+1}{os.path.splitext(ism_meta_file)[1]}') + if not os.path.exists(ism_file_name) or force_overwrite: + shutil.copyfile(os.path.join(input_dir, ism_meta_file), ism_file_name) + wrote_files.append(ism_file_name) # info print. helps setting up .gitignore diff --git a/scripts/pyivastest/IvasModeRunner.py b/scripts/pyivastest/IvasModeRunner.py index c67f252e1d073198a2360920e344162a8b6cc8af..57ef3ba31d06b81cd22d11dbec5c37f021fb1b87 100644 --- a/scripts/pyivastest/IvasModeRunner.py +++ b/scripts/pyivastest/IvasModeRunner.py @@ -50,6 +50,8 @@ import pyaudio3dtools.audiofile as af import pyaudio3dtools.audioarray as ar BW_TO_SR = {"nb": 8, "wb": 16, "swb": 32, "fb": 48} +RET_CODE_TIMEOUT_EXP = 9999 + class Error(Exception): pass @@ -85,6 +87,7 @@ class IvasModeRunner(IvasModeCollector.IvasModeCollector): console_logger_level="", logger_name="IvasBaseClass", log_level=logging.DEBUG, + timeout=None, ): super().__init__( @@ -97,6 +100,7 @@ class IvasModeRunner(IvasModeCollector.IvasModeCollector): logger_name=logger_name, log_level=log_level, ) + self.timeout = timeout self.lock = threading.Lock() self.dec_queue = None self.enc_queue = None @@ -317,13 +321,22 @@ class IvasModeRunner(IvasModeCollector.IvasModeCollector): + [enc_file_name, dec_file_name] ) - cur_dec_result = subprocess.run(dec_cmd, capture_output=True, text=True, env=self.run_env) dec_log.write(" ".join(dec_cmd)) - dec_log.write(cur_dec_result.stderr) - dec_log.write(cur_dec_result.stdout) - if cur_dec_result.returncode != 0: + try: + cur_dec_result = subprocess.run(dec_cmd, capture_output=True, text=True, env=self.run_env, timeout=self.timeout) + returncode = cur_dec_result.returncode + dec_log.write(cur_dec_result.stderr) + dec_log.write(cur_dec_result.stdout) + except subprocess.TimeoutExpired: + returncode = RET_CODE_TIMEOUT_EXP + + if returncode != 0: + fail_string = "Decoding {} to {} failed!" + if returncode == RET_CODE_TIMEOUT_EXP: + fail_string = fail_string[:-1] + f" due to timeout after {self.timeout} seconds!" + self.logger.error( - "Decoding {} to {} failed!".format(enc_file_name, dec_file_name) + fail_string.format(enc_file_name, dec_file_name) ) self.lock.acquire() if self.stats: @@ -331,9 +344,7 @@ class IvasModeRunner(IvasModeCollector.IvasModeCollector): self.show_progress() self.results.append( [ - "Decoding failed to {} for {}".format( - output_config, enc_file_name - ), + fail_string.format(output_config, enc_file_name), config["ivas_format"], enc_dec_cmd["table_name"], dec_log_name, @@ -706,10 +717,13 @@ class IvasModeRunner(IvasModeCollector.IvasModeCollector): enc_log = open(enc_log_name, "w") enc_log.write(" ".join(enc_cmd)) - enc_result = subprocess.run(enc_cmd, capture_output=True, text=True, env=self.run_env) - error = enc_result.returncode - enc_log.write(enc_result.stderr) - enc_log.write(enc_result.stdout) + try: + enc_result = subprocess.run(enc_cmd, capture_output=True, text=True, env=self.run_env, timeout=self.timeout) + error = enc_result.returncode + enc_log.write(enc_result.stderr) + enc_log.write(enc_result.stdout) + except subprocess.TimeoutExpired: + error = RET_CODE_TIMEOUT_EXP if error == 0 and "bitstream_processing" in enc_dec_cmd: bs_in_file = enc_file_name @@ -797,13 +811,17 @@ class IvasModeRunner(IvasModeCollector.IvasModeCollector): self.lock.release() if error != 0: + fail_string = "Encoding failed for {}" + if error == RET_CODE_TIMEOUT_EXP: + fail_string = fail_string + f" due to timeout after {self.timeout} seconds" + self.lock.acquire() if self.stats: self.stats["num_enc_errors"] += 1 self.show_progress() self.results.append( [ - "Encoding failed for {}".format(enc_file_name), + fail_string.format(enc_file_name), mode, enc_dec_cmd["table_name"], enc_log_name, @@ -811,7 +829,7 @@ class IvasModeRunner(IvasModeCollector.IvasModeCollector): ) self.failed_modes["enc"].append(mode) self.lock.release() - self.logger.error("Encoding failed for {}".format(enc_file_name)) + self.logger.error(fail_string.format(enc_file_name)) else: self.logger.info("Encoding successful for {}".format(enc_file_name)) diff --git a/scripts/pyivastest/IvasScriptsCommon.py b/scripts/pyivastest/IvasScriptsCommon.py index 0d1558c8ecd6b1227f12776a665592c2777b75bd..a6158b99089849919eee95f5933bf5557c475fcc 100644 --- a/scripts/pyivastest/IvasScriptsCommon.py +++ b/scripts/pyivastest/IvasScriptsCommon.py @@ -141,6 +141,11 @@ class IvasScriptArgParser(argparse.ArgumentParser): default=multiprocessing.cpu_count(), type=int, ) + self.add_argument( + "--timeout", + help="Timeout duration for an individual encoder/decoder run", + default=None, + ) if not minimal: self.add_argument( "-C", @@ -339,6 +344,15 @@ class IvasScriptArgParser(argparse.ArgumentParser): args["error"] = 1 args["exit"] = 1 + if args["timeout"] is not None: + try: + timeout = float(args["timeout"]) + args["timeout"] = timeout + except ValueError: + print(f"Given timeout value {args['timeout']} is not a valid number.") + args["error"] = 1 + args["exit"] = 1 + if not self.minimal: format_dict = self.get_format_dict(args["format_file"]) if format_dict == -1: @@ -690,6 +704,9 @@ def runner_setup(runner, args): if args["filter_regex"]: runner.filter = args["filter_regex"] + if args["timeout"] is not None: + runner.timeout = args["timeout"] + def analyzer_setup(analyzer, args): bs_proc_chain = {} diff --git a/scripts/pyivastest/IvasSvnBuilder.py b/scripts/pyivastest/IvasSvnBuilder.py index a935ae4e8f345bd8a60bbd409390d0efe9aade36..99b5ac57b6dec3ffa9cd878dc1a314f523df0f7a 100644 --- a/scripts/pyivastest/IvasSvnBuilder.py +++ b/scripts/pyivastest/IvasSvnBuilder.py @@ -775,6 +775,7 @@ class IvasBuilderAndRunner(IvasBaseClass): formats_dict={}, formats_fname="", max_workers=1, + timeout=None, ): """ @@ -840,6 +841,7 @@ class IvasBuilderAndRunner(IvasBaseClass): enable_logging=True, logger_name="{}.{}runner".format(self.logger.name, cfg_name), log_level=self.logger.level, + timeout=timeout, ) if format_select_list: newRunner.set_format_select_list(format_select_list) diff --git a/scripts/runIvasCodec.py b/scripts/runIvasCodec.py index 7cf1d64a6b130b52ad00a317c78dc2bea7a94bc0..f8486ac5f358ae57c6498a00707d7c8ac3018a36 100755 --- a/scripts/runIvasCodec.py +++ b/scripts/runIvasCodec.py @@ -133,6 +133,7 @@ class RunIvasCodec(IvasScriptsCommon.IvasScript): sample_rate_dec_out=self.args["srout"], enable_logging=True, logger_name="{}.runner".format(self.logger.name), + timeout=self.args["timeout"], ) IvasScriptsCommon.runner_setup(runner, self.args) diff --git a/scripts/testv/stv2OA16c.wav b/scripts/testv/stv2OA16c.wav new file mode 100644 index 0000000000000000000000000000000000000000..ecc49cdc47923be78cf77f1e2c608e9def7b9024 --- /dev/null +++ b/scripts/testv/stv2OA16c.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:98b13db94ef2f84fb0e626b5cd13e21478dfd95bf2da9ce5e461042d796ccf16 +size 5760294 diff --git a/scripts/testv/stv3OA16c.wav b/scripts/testv/stv3OA16c.wav new file mode 100644 index 0000000000000000000000000000000000000000..ac052cedba09816c52404434e6ba2b9227341aaa --- /dev/null +++ b/scripts/testv/stv3OA16c.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:039573071859b85429c20fc331f8319293d637e488689526dcee47b564cc4ee4 +size 10240420 diff --git a/tests/cmp_pcm.py b/tests/cmp_pcm.py index 817ac9c5026c249e8155353a9654bb2c659666cf..9db7ccd39e3750cc10cf21eb3134e4f226cd495d 100755 --- a/tests/cmp_pcm.py +++ b/tests/cmp_pcm.py @@ -12,7 +12,7 @@ import pyivastest import numpy as np -def cmp_pcm(file1, file2, out_config, fs, get_mld = False) -> (int, str): +def cmp_pcm(file1, file2, out_config, fs, get_mld = False, mld_lim = 0) -> (int, str): """ Compare 2 PCM files for bitexactness """ @@ -54,8 +54,12 @@ def cmp_pcm(file1, file2, out_config, fs, get_mld = False) -> (int, str): print(first_msg) if get_mld: mld_msg = f"MLD: {cmp_result['MLD']}" - print(mld_msg) - return 1, "FAIL: Files have different content" + print(mld_msg) + if cmp_result['MLD'] <= mld_lim: + return 0, f"MLD: {cmp_result['MLD']} <= {mld_lim}" + else: + return 1, f"MLD: {cmp_result['MLD']} > {mld_lim}" + return 1, "Non-BE" if __name__ == "__main__": @@ -71,6 +75,7 @@ if __name__ == "__main__": ) parser.add_argument("-s", "--sampling_rate", type=int, default=48000, dest="fs") parser.add_argument("--get_mld", action="store_true") + parser.add_argument("--mld_lim", type=float, default=0, dest="mld_lim") args = parser.parse_args() result, msg = cmp_pcm(**vars(args)) diff --git a/tests/codec_be_on_mr_nonselection/test_masa_enc_dec.py b/tests/codec_be_on_mr_nonselection/test_masa_enc_dec.py index 0614651653e14d33efe61fa28071ff9aec87b8d1..3c49f9f21c6357d749664186439c2bce806984f0 100644 --- a/tests/codec_be_on_mr_nonselection/test_masa_enc_dec.py +++ b/tests/codec_be_on_mr_nonselection/test_masa_enc_dec.py @@ -93,6 +93,7 @@ def check_and_makedir(dir_path): masa_metadata_audio_ndir_ntransportch_dtx_list, ) def test_masa_enc_dec( + record_property, dut_encoder_frontend: EncoderFrontend, dut_decoder_frontend: DecoderFrontend, ref_encoder_frontend: EncoderFrontend, @@ -106,6 +107,7 @@ def test_masa_enc_dec( test_vector_path, output_mode, get_mld, + get_mld_lim, ): # Input parameters in_fs = 48 @@ -201,8 +203,13 @@ def test_masa_enc_dec( # Compare audio outputs pcmcmp_res, reason = cmp_pcm( - dec_output_dut, dec_output_ref, output_mode, int(out_fs * 1000), get_mld=get_mld + dec_output_dut, dec_output_ref, output_mode, int(out_fs * 1000), get_mld=get_mld, mld_lim=get_mld_lim ) + if get_mld: + mld = 0 + if "MLD" in reason: + mld = float(reason.split(':')[1].split()[0]) + record_property("MLD",mld) # Fail if compare fails compare result if metacmp_res == False and pcmcmp_res != 0: @@ -219,11 +226,19 @@ def test_masa_enc_dec( filecmp_res = cmp(dec_output_ref, dec_output_dut) if filecmp_res == False: cmp_result, reason = cmp_pcm( - dec_output_dut, dec_output_ref, output_mode, int(out_fs * 1000), get_mld=get_mld + dec_output_dut, dec_output_ref, output_mode, int(out_fs * 1000), get_mld=get_mld, mld_lim=get_mld_lim ) + if get_mld: + mld = 0 + if "MLD" in reason: + mld = float(reason.split(':')[1].split()[0]) + record_property("MLD",mld) # Report compare result - assert cmp_result == 0, reason + if cmp_result != 0: + pytest.fail(reason) else: + if get_mld: + record_property("MLD","0") print("Comparison bit exact") # remove_output( diff --git a/tests/codec_be_on_mr_nonselection/test_param_file.py b/tests/codec_be_on_mr_nonselection/test_param_file.py index 1dfda043d7d99730759751aa8aa495b84f637910..c5fe72ee505f51c23917f7cd801ebcd1cf84a311 100644 --- a/tests/codec_be_on_mr_nonselection/test_param_file.py +++ b/tests/codec_be_on_mr_nonselection/test_param_file.py @@ -125,6 +125,7 @@ def convert_test_string_to_tag(test_string): @pytest.mark.create_ref @pytest.mark.parametrize("test_tag", list(param_file_test_dict.keys())) def test_param_file_tests( + record_property, dut_encoder_frontend: EncoderFrontend, dut_decoder_frontend: DecoderFrontend, ref_encoder_frontend: EncoderFrontend, @@ -137,6 +138,7 @@ def test_param_file_tests( keep_files, test_tag, get_mld, + get_mld_lim, ): enc_opts, dec_opts, sim_opts, eid_opts = param_file_test_dict[test_tag] @@ -325,10 +327,16 @@ def test_param_file_tests( ref_output_file = f"{reference_path}/param_file/dec/{output_file}" fs = int(sampling_rate) * 1000 output_differs, reason = cmp_pcm( - dut_output_file, ref_output_file, output_config, fs, get_mld=get_mld + dut_output_file, ref_output_file, output_config, fs, get_mld=get_mld, mld_lim=get_mld_lim ) md_out_files = get_expected_md_files(ref_output_file, enc_split, output_config) + if get_mld: + mld = 0 + if "MLD" in reason: + mld = float(reason.split(':')[1].split()[0]) + record_property("MLD",mld) + metadata_differs = False for md_file in md_out_files: dut_metadata_file = Path(f"{dut_base_path}/param_file/dec/{md_file}") @@ -347,13 +355,13 @@ def test_param_file_tests( if output_differs or metadata_differs: msg = "Difference between ref and dut in " if output_differs and metadata_differs: - msg += "output and metadata" + msg += f"output ({reason}) and metadata" elif output_differs: - msg += "output only" + msg += f"output only ({reason})" elif metadata_differs: msg += "metadata only" - assert False, msg + pytest.fail(msg) # remove DUT output files when test result is OK (to save disk space) if not keep_files: diff --git a/tests/codec_be_on_mr_nonselection/test_sba_bs_dec_plc.py b/tests/codec_be_on_mr_nonselection/test_sba_bs_dec_plc.py index 422f87d9c7cebb502957120e6a909808288a8c08..484ada6c8aba66fadc3c868ff13e004888a0f494 100644 --- a/tests/codec_be_on_mr_nonselection/test_sba_bs_dec_plc.py +++ b/tests/codec_be_on_mr_nonselection/test_sba_bs_dec_plc.py @@ -75,6 +75,7 @@ def check_and_makedir(dir_path): @pytest.mark.parametrize("fs", sampling_rate_list) @pytest.mark.parametrize("gain_flag", gain_list) def test_sba_plc_system( + record_property, dut_decoder_frontend: DecoderFrontend, test_vector_path, reference_path, @@ -89,6 +90,7 @@ def test_sba_plc_system( fs, gain_flag, get_mld, + get_mld_lim, ): SID = 0 if dtx == '1' and ivas_br not in ['13200','16400','24400','32000', '64000']: @@ -105,6 +107,7 @@ def test_sba_plc_system( # dec sba_dec_plc( + record_property, dut_decoder_frontend, test_vector_path, reference_path, @@ -120,12 +123,14 @@ def test_sba_plc_system( gain_flag, keep_files, get_mld=get_mld, + get_mld_lim=get_mld_lim, ) ######################################################### # -------------------- test function -------------------- def sba_dec_plc( + record_property, decoder_frontend, test_vector_path, reference_path, @@ -141,6 +146,7 @@ def sba_dec_plc( gain_flag, keep_files, get_mld=False, + get_mld_lim=0, ): # ------------ run cmd ------------ @@ -191,10 +197,16 @@ def sba_dec_plc( # -------------- compare cmd -------------- fs = int(sampling_rate) * 1000 - cmp_result, reason = cmp_pcm(dut_out_raw, ref_out_raw, output_config, fs, get_mld=get_mld) + cmp_result, reason = cmp_pcm(dut_out_raw, ref_out_raw, output_config, fs, get_mld=get_mld, mld_lim=get_mld_lim) + if get_mld: + mld = 0 + if "MLD" in reason: + mld = float(reason.split(':')[1].split()[0]) + record_property("MLD",mld) # report compare result - assert cmp_result == 0, reason + if cmp_result != 0: + pytest.fail(reason) # remove DUT output files when test result is OK (to save disk space) if not keep_files: diff --git a/tests/codec_be_on_mr_nonselection/test_sba_bs_enc.py b/tests/codec_be_on_mr_nonselection/test_sba_bs_enc.py index 3e84e6b2839d488a17afcd1a42e8ce015685ce1b..650bddb17d2cefc2ae4a68758cd6b193b409d59e 100644 --- a/tests/codec_be_on_mr_nonselection/test_sba_bs_enc.py +++ b/tests/codec_be_on_mr_nonselection/test_sba_bs_enc.py @@ -89,6 +89,7 @@ def check_and_makedir(dir_path): @pytest.mark.parametrize("tag", tag_list) @pytest.mark.parametrize("fs", sample_rate_list) def test_pca_enc( + record_property, dut_encoder_frontend: EncoderFrontend, dut_decoder_frontend: DecoderFrontend, test_vector_path, @@ -101,6 +102,7 @@ def test_pca_enc( tag, fs, get_mld, + get_mld_lim, ): pca = True tag = tag + fs + "c" @@ -134,6 +136,7 @@ def test_pca_enc( # dec sba_dec( + record_property, dut_decoder_frontend, ref_decoder_frontend, reference_path, @@ -149,6 +152,7 @@ def test_pca_enc( gain_flag, keep_files, get_mld=get_mld, + get_mld_lim=get_mld_lim, pca=pca, ) @@ -161,6 +165,7 @@ def test_pca_enc( @pytest.mark.parametrize("gain_flag", gain_list) @pytest.mark.parametrize("SID", SID_list) def test_sba_enc_system( + record_property, dut_encoder_frontend: EncoderFrontend, dut_decoder_frontend: DecoderFrontend, test_vector_path, @@ -178,6 +183,7 @@ def test_sba_enc_system( gain_flag, SID, get_mld, + get_mld_lim, ): if dtx == "1" and ivas_br not in ["13200", "16400", "24400", "32000", "64000"]: @@ -227,6 +233,7 @@ def test_sba_enc_system( # dec sba_dec( + record_property, dut_decoder_frontend, ref_decoder_frontend, reference_path, @@ -241,7 +248,8 @@ def test_sba_enc_system( update_ref, gain_flag, keep_files, - get_mld=get_mld + get_mld=get_mld, + get_mld_lim=get_mld_lim ) @@ -249,6 +257,7 @@ def test_sba_enc_system( @pytest.mark.parametrize("ivas_br", ivas_br_HOA2) @pytest.mark.parametrize("tag", tag_list_HOA2) def test_spar_hoa2_enc_system( + record_property, dut_encoder_frontend: EncoderFrontend, dut_decoder_frontend: DecoderFrontend, test_vector_path, @@ -261,6 +270,7 @@ def test_spar_hoa2_enc_system( ivas_br, tag, get_mld, + get_mld_lim, ): fs = "48" dtx = "0" @@ -292,6 +302,7 @@ def test_spar_hoa2_enc_system( # dec sba_dec( + record_property, dut_decoder_frontend, ref_decoder_frontend, reference_path, @@ -307,6 +318,7 @@ def test_spar_hoa2_enc_system( gain_flag, keep_files, get_mld=get_mld, + get_mld_lim=get_mld_lim, ) @@ -314,6 +326,7 @@ def test_spar_hoa2_enc_system( @pytest.mark.parametrize("ivas_br", ivas_br_HOA3) @pytest.mark.parametrize("tag", tag_list_HOA3) def test_spar_hoa3_enc_system( + record_property, dut_encoder_frontend: EncoderFrontend, dut_decoder_frontend: DecoderFrontend, test_vector_path, @@ -326,6 +339,7 @@ def test_spar_hoa3_enc_system( ivas_br, tag, get_mld, + get_mld_lim, ): fs = "48" dtx = "0" @@ -357,6 +371,7 @@ def test_spar_hoa3_enc_system( # dec sba_dec( + record_property, dut_decoder_frontend, ref_decoder_frontend, reference_path, @@ -371,7 +386,8 @@ def test_spar_hoa3_enc_system( update_ref, gain_flag, keep_files, - get_mld=get_mld + get_mld=get_mld, + get_mld_lim=get_mld_lim, ) @@ -381,6 +397,7 @@ def test_spar_hoa3_enc_system( @pytest.mark.parametrize("tag", tag_list_bw_force) @pytest.mark.parametrize("sample_rate_bw_idx", sample_rate_bw_idx_list) def test_sba_enc_BWforce_system( + record_property, dut_encoder_frontend: EncoderFrontend, dut_decoder_frontend: DecoderFrontend, test_vector_path, @@ -395,6 +412,7 @@ def test_sba_enc_BWforce_system( tag, sample_rate_bw_idx, get_mld, + get_mld_lim, ): if dtx == "1" and ivas_br not in ["32000", "64000"]: # skip high bitrates for DTX until DTX issue is resolved @@ -432,6 +450,7 @@ def test_sba_enc_BWforce_system( # dec sba_dec( + record_property, dut_decoder_frontend, ref_decoder_frontend, reference_path, @@ -447,6 +466,7 @@ def test_sba_enc_BWforce_system( gain_flag, keep_files, get_mld=get_mld, + get_mld_lim=get_mld_lim, ) @@ -594,6 +614,7 @@ def sba_enc( def sba_dec( + record_property, decoder_frontend, ref_decoder_frontend, reference_path, @@ -609,6 +630,7 @@ def sba_dec( gain_flag, keep_files, get_mld=False, + get_mld_lim=0, pca=False, ): # -------- run cmd ------------ @@ -663,10 +685,16 @@ def sba_dec( ) fs = int(sampling_rate) * 1000 - cmp_result, reason = cmp_pcm(dut_out_raw, ref_out_raw, output_config, fs, get_mld=get_mld) + cmp_result, reason = cmp_pcm(dut_out_raw, ref_out_raw, output_config, fs, get_mld=get_mld, mld_lim=get_mld_lim ) + if get_mld: + mld = 0 + if "MLD" in reason: + mld = float(reason.split(':')[1].split()[0]) + record_property("MLD",mld) # report compare result - assert cmp_result == 0, reason + if cmp_result != 0: + pytest.fail(reason) # remove DUT output files when test result is OK (to save disk space) if not keep_files: diff --git a/tests/conftest.py b/tests/conftest.py index 5f7ed04a829219a8e5b1b968c93c8354268c85b7..3b2d5944db1e4cc1f465f86039e2c937d03eb185 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -158,6 +158,12 @@ def pytest_addoption(parser): help="Run the MLD tool instead of just comparing for bitexactness", ) + parser.addoption( + "--mld-lim", + action="store", + help="MLD limit for comparison (default: 0)", + default="0", + ) @pytest.fixture(scope="session", autouse=True) def update_ref(request): @@ -177,6 +183,12 @@ def get_mld(request): """ return request.config.option.mld +@pytest.fixture(scope="session", autouse=True) +def get_mld_lim(request): + """ + Return MLD limit for MLD comparison + """ + return float(request.config.getoption("--mld-lim")) @pytest.fixture(scope="session") def keep_files(request) -> bool: @@ -274,7 +286,7 @@ class EncoderFrontend: cmd_str = textwrap.indent(" ".join(command), prefix="\t") log_dbg_msg(f"{self._type} encoder command:\n{cmd_str}") - try: + try: result = run(command, capture_output=True, check=True, timeout=self.timeout) except TimeoutExpired: pytest.fail(f"{self._type} encoder run timed out after {self.timeout}s.") @@ -292,6 +304,8 @@ class EncoderFrontend: pytest.fail( f"{self._type} encoder terminated with a non-0 return code: {self.returncode}" ) + if self.stderr and "UndefinedBehaviorSanitizer" in self.stderr: + pytest.fail("Undefined Behaviour runtime error encountered") def _check_run(self): if self.returncode is not None: @@ -429,10 +443,10 @@ class DecoderFrontend: eid_path = "./scripts/tools/Darwin/eid-xor" else: raise ValueError(f'Wrong system "{system}"!') - + if not os.path.isfile(eid_path): raise FileNotFoundError(f"eid-xor binary {eid_path} not found!\n") - + eid_command = [eid_path] eid_command.extend(["-fer", "-vbr", "-bs", "g192", "-ep", "g192"]) eid_output_suffix = "." + next(tempfile._get_candidate_names()) + ".fer" @@ -441,7 +455,7 @@ class DecoderFrontend: str(plc_file), str(input_bitstream_path) + eid_output_suffix ] - + try: result = run(eid_command, check=True) except Exception as e: @@ -450,7 +464,7 @@ class DecoderFrontend: pytest.fail(f"eid-xor operation failed!") input_bitstream_path += eid_output_suffix - + if add_option_list is not None: command.extend(add_option_list) @@ -485,6 +499,8 @@ class DecoderFrontend: pytest.fail( f"{self._type} decoder terminated with a non-0 return code: {self.returncode}" ) + if self.stderr and "UndefinedBehaviorSanitizer" in self.stderr: + pytest.fail("Undefined Behaviour runtime error encountered") def _check_run(self): if self.returncode is not None: diff --git a/tests/hrtf_binary_loading/__init__.py b/tests/hrtf_binary_loading/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..462a690696adb655cb405d953ae30d04137ea868 --- /dev/null +++ b/tests/hrtf_binary_loading/__init__.py @@ -0,0 +1,31 @@ +#!/usr/bin/env python3 + +""" + (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. 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. +""" diff --git a/tests/hrtf_binary_loading/bitstream/.gitignore b/tests/hrtf_binary_loading/bitstream/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..f935021a8f8a7bd22f9d6703cafa5134bb6a57f8 --- /dev/null +++ b/tests/hrtf_binary_loading/bitstream/.gitignore @@ -0,0 +1 @@ +!.gitignore diff --git a/tests/hrtf_binary_loading/conftest.py b/tests/hrtf_binary_loading/conftest.py new file mode 100644 index 0000000000000000000000000000000000000000..4668d742db526a2758319beea8269f2d63412de9 --- /dev/null +++ b/tests/hrtf_binary_loading/conftest.py @@ -0,0 +1,44 @@ +#!/usr/bin/env python3 + +""" + (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. 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. +""" + + +def pytest_addoption(parser): + parser.addoption( + "--create_ref", + action="store_true", + default=False, + ) + parser.addoption( + "--create_cut", + action="store_true", + default=False, + ) diff --git a/tests/hrtf_binary_loading/constants.py b/tests/hrtf_binary_loading/constants.py new file mode 100644 index 0000000000000000000000000000000000000000..223fa864f62f14365a2f30d0cf43a3d0956ccc05 --- /dev/null +++ b/tests/hrtf_binary_loading/constants.py @@ -0,0 +1,236 @@ +#!/usr/bin/env python3 + +""" + (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. 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. +""" + +import re +from pathlib import Path + +from tests.renderer.constants import ( + OUTPUT_FORMATS_BINAURAL, + SCRIPTS_DIR, + TESTV_DIR, +) + +TESTS_DIR = Path(__file__).parent + +BITSTREAM_DIR = TESTS_DIR.joinpath("bitstream") +DEC_ROM_DIR = TESTS_DIR.joinpath("dec_out_rom") +HRTF_BINARY_DIR = SCRIPTS_DIR.joinpath( + "binauralRenderer_interface", "binaural_renderers_hrtf_data" +) +DEC_BINARY_DIR = TESTS_DIR.joinpath("dec_out_bin") + +ENCODER_CMD = [str(TESTS_DIR.parent.parent.joinpath("IVAS_cod"))] + +DECODER_CMD = [str(TESTS_DIR.parent.parent.joinpath("IVAS_dec"))] + +RENDERER_CMD = [str(TESTS_DIR.parent.parent.joinpath("IVAS_rend"))] + +HRTF_BINARY_FILE = "ivas_binaural_{}kHz.bin" +SAMPLE_RATE = ["16", "32", "48"] + +INPUT_FORMATS_MC = ["5_1", "5_1_2", "5_1_4", "7_1", "7_1_4"] # "MONO", "STEREO", +INPUT_FORMATS_SBA = ["1", "2", "3"] +INPUT_FORMATS_ISM = ["1", "2", "3", "4"] +INPUT_FORMATS_MASA = {"tc": ["1", "2"], "dir": ["1", "2"]} +INPUT_FORMATS_MASA_RENDERER = ["MASA1", "MASA2"] + + +FORMAT_TO_FILE_MC_WOEXT = { + "5_1": "stv51MC{}c", + "7_1": "stv71MC{}c", + "5_1_2": "stv512MC{}c", + "5_1_4": "stv514MC{}c", + "7_1_4": "stv714MC{}c", +} +FORMAT_TO_FILE_SBA_WOEXT = { + "1": "stvFOA{}c", + "2": "stv2OA{}c", + "3": "stv3OA{}c", +} +FORMAT_TO_FILE_ISM_WOEXT = "stv{}ISM{}s" +FORMAT_TO_FILE_MASA_WOEXT = "stv{}MASA{}TC{}c" + +BITRATE_ISM = { + "1": 96000, + "2": 160000, + "3": 384000, + "4": 512000, +} + +FORMAT_TO_METADATA_FILES = {"MASA": "stv{}MASA{}TC{}c.met", "ISM": "stvISM{}.csv"} + +FORMAT_TO_METADATA_FILES_RENDERER = { + "ISM1": [str(TESTV_DIR.joinpath("stvISM1.csv"))], + "ISM2": [ + str(TESTV_DIR.joinpath("stvISM1.csv")), + str(TESTV_DIR.joinpath("stvISM2.csv")), + ], + "ISM3": [ + str(TESTV_DIR.joinpath("stvISM1.csv")), + str(TESTV_DIR.joinpath("stvISM2.csv")), + str(TESTV_DIR.joinpath("stvISM3.csv")), + ], + "ISM4": [ + str(TESTV_DIR.joinpath("stvISM1.csv")), + str(TESTV_DIR.joinpath("stvISM2.csv")), + str(TESTV_DIR.joinpath("stvISM3.csv")), + str(TESTV_DIR.joinpath("stvISM4.csv")), + ], + "NDP_ISM4": [ + str(TESTV_DIR.joinpath("stvISM1.csv")), + str(TESTV_DIR.joinpath("stvISM2_non-diegetic-pan.csv")), + str(TESTV_DIR.joinpath("stvISM3.csv")), + str(TESTV_DIR.joinpath("stvISM4.csv")), + ], + "MASA1": [str(TESTV_DIR.joinpath("stv1MASA1TC48c.met"))], + "MASA2": [str(TESTV_DIR.joinpath("stv2MASA2TC48c.met"))], +} + + +HR_TRAJECTORIES_TO_TEST = ["headrot_case00_3000_q", "headrot"] + +HR_TRAJECTORIES_TO_TEST_RENDERER = ["full_circle_in_15s"] + + +with open( + str(TESTS_DIR.parent.parent.joinpath("lib_com")) + "/ivas_cnst.h", "r" +) as ivas_cnst_file: + ivas_cnst = ivas_cnst_file.read() + + # Declare renderer_types + rtid = ivas_cnst.find("RENDERER_TYPE;") + rte_c = ivas_cnst[ivas_cnst[:rtid].rfind("{") : ivas_cnst[:rtid].rfind("}")] + enumid = 0 + for rtid1 in [m.start() for m in re.finditer("RENDERER_", rte_c)]: + rtid2 = rte_c[rtid1:].find(",") + if rtid2 == -1: + rtid2 = rte_c[rtid1:].find(" ") + globals()[rte_c[rtid1 : rtid1 + rtid2]] = enumid + enumid += 1 + + # Declare binaural_input_audio_config + biacid = ivas_cnst.find("BINAURAL_INPUT_AUDIO_CONFIG;") + biace_c = ivas_cnst[ivas_cnst[:biacid].rfind("{") : ivas_cnst[:biacid].rfind("}")] + enumid = 0 + for biacid1 in [ + m.start() for m in re.finditer("BINAURAL_INPUT_AUDIO_CONFIG_", biace_c) + ]: + biacid2 = biace_c[biacid1:].find(",") + if biacid2 == -1: + biacid2 = biace_c[biacid1:].find(" ") + globals()[biace_c[biacid1 : biacid1 + biacid2]] = enumid + enumid += 1 + +HRTF_READER_RENDERER_BINAURAL_INVALID = 0 +HRTF_READER_RENDERER_BINAURAL_FASTCONV = 1 +HRTF_READER_RENDERER_BINAURAL_FASTCONV_ROOM = 2 +HRTF_READER_RENDERER_BINAURAL_PARAMETRIC = 3 +HRTF_READER_RENDERER_BINAURAL_PARAMETRIC_ROOM = 4 +HRTF_READER_RENDERER_BINAURAL_OBJECTS_TD = 5 +HRTF_READER_RENDERER_BINAURAL_MIXER_CONV = 6 +HRTF_READER_RENDERER_BINAURAL_MIXER_CONV_ROOM = 7 +HRTF_READER_RENDERER_BINAURAL_REVERB_ALL = 8 + +BINAURAL_INPUT_AUDIO_CONFIG_INVALID = 0 +BINAURAL_INPUT_AUDIO_CONFIG_COMBINED = 1 +BINAURAL_INPUT_AUDIO_CONFIG_HOA3 = 2 +BINAURAL_INPUT_AUDIO_CONFIG_HOA2 = 3 +BINAURAL_INPUT_AUDIO_CONFIG_FOA = 4 +BINAURAL_INPUT_AUDIO_CONFIG_UNDEFINED = 5 + +REQ_HRTF_CONFIG = [ + { + "renderer_type": HRTF_READER_RENDERER_BINAURAL_FASTCONV, + "input_configuration": BINAURAL_INPUT_AUDIO_CONFIG_COMBINED, + "sampling_frequency": 48000, + }, + { + "renderer_type": HRTF_READER_RENDERER_BINAURAL_FASTCONV, + "input_configuration": BINAURAL_INPUT_AUDIO_CONFIG_HOA3, + "sampling_frequency": 48000, + }, + { + "renderer_type": HRTF_READER_RENDERER_BINAURAL_FASTCONV, + "input_configuration": BINAURAL_INPUT_AUDIO_CONFIG_HOA2, + "sampling_frequency": 48000, + }, + { + "renderer_type": HRTF_READER_RENDERER_BINAURAL_FASTCONV, + "input_configuration": BINAURAL_INPUT_AUDIO_CONFIG_FOA, + "sampling_frequency": 48000, + }, + { + "renderer_type": HRTF_READER_RENDERER_BINAURAL_FASTCONV_ROOM, + "input_configuration": BINAURAL_INPUT_AUDIO_CONFIG_COMBINED, + "sampling_frequency": 48000, + }, + { + "renderer_type": HRTF_READER_RENDERER_BINAURAL_PARAMETRIC_ROOM, + "input_configuration": BINAURAL_INPUT_AUDIO_CONFIG_UNDEFINED, + "sampling_frequency": 48000, + }, + { + "renderer_type": HRTF_READER_RENDERER_BINAURAL_OBJECTS_TD, + "input_configuration": BINAURAL_INPUT_AUDIO_CONFIG_UNDEFINED, + "sampling_frequency": -1, + }, + { + "renderer_type": HRTF_READER_RENDERER_BINAURAL_MIXER_CONV, + "input_configuration": BINAURAL_INPUT_AUDIO_CONFIG_COMBINED, + "sampling_frequency": -1, + }, + { + "renderer_type": HRTF_READER_RENDERER_BINAURAL_MIXER_CONV, + "input_configuration": BINAURAL_INPUT_AUDIO_CONFIG_HOA3, + "sampling_frequency": -1, + }, + { + "renderer_type": HRTF_READER_RENDERER_BINAURAL_MIXER_CONV, + "input_configuration": BINAURAL_INPUT_AUDIO_CONFIG_HOA2, + "sampling_frequency": -1, + }, + { + "renderer_type": HRTF_READER_RENDERER_BINAURAL_MIXER_CONV, + "input_configuration": BINAURAL_INPUT_AUDIO_CONFIG_FOA, + "sampling_frequency": -1, + }, + { + "renderer_type": HRTF_READER_RENDERER_BINAURAL_MIXER_CONV_ROOM, + "input_configuration": BINAURAL_INPUT_AUDIO_CONFIG_COMBINED, + "sampling_frequency": -1, + }, + { + "renderer_type": HRTF_READER_RENDERER_BINAURAL_REVERB_ALL, + "input_configuration": BINAURAL_INPUT_AUDIO_CONFIG_UNDEFINED, + "sampling_frequency": -1, + }, +] diff --git a/tests/hrtf_binary_loading/dec_out_bin/.gitignore b/tests/hrtf_binary_loading/dec_out_bin/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..f935021a8f8a7bd22f9d6703cafa5134bb6a57f8 --- /dev/null +++ b/tests/hrtf_binary_loading/dec_out_bin/.gitignore @@ -0,0 +1 @@ +!.gitignore diff --git a/tests/hrtf_binary_loading/dec_out_rom/.gitignore b/tests/hrtf_binary_loading/dec_out_rom/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..f935021a8f8a7bd22f9d6703cafa5134bb6a57f8 --- /dev/null +++ b/tests/hrtf_binary_loading/dec_out_rom/.gitignore @@ -0,0 +1 @@ +!.gitignore diff --git a/tests/hrtf_binary_loading/test_codec_ROM_vs_file.py b/tests/hrtf_binary_loading/test_codec_ROM_vs_file.py new file mode 100644 index 0000000000000000000000000000000000000000..fbfd5fc637896e1f9bb0ea541419b6b58c5cb486 --- /dev/null +++ b/tests/hrtf_binary_loading/test_codec_ROM_vs_file.py @@ -0,0 +1,344 @@ +#!/usr/bin/env python3 + +""" + (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. 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. +""" +import pytest + +from tests.hrtf_binary_loading.utils import * + +""" Binary file """ + + +@pytest.mark.parametrize("out_fs", SAMPLE_RATE) +def test_binary_file(test_info, out_fs): + check_binary_file(out_fs) + + +""" Multichannel """ + + +@pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL[:-1]) +@pytest.mark.parametrize("out_fs", SAMPLE_RATE) +@pytest.mark.parametrize("in_fmt", INPUT_FORMATS_MC) +def test_multichannel_binaural_static(test_info, in_fmt, out_fmt, out_fs): + # if in_fmt in ["MONO", "STEREO"]: + # pytest.skip("MONO or STEREO to Binaural rendering unsupported") + + # -mc InputConf : Multi-channel format + # where InputConf specifies the channel configuration (5_1, 7_1, 5_1_2, 5_1_4, 7_1_4) + + bitrate = 512000 + in_fs = 48 + option_list = ["-mc", in_fmt] + in_file = FORMAT_TO_FILE_MC_WOEXT[in_fmt].format(in_fs) + + compare_rom_vs_binary( + test_info, + option_list, + bitrate, + in_file, + in_fs, + out_fmt, + out_fs, + ) + + +@pytest.mark.parametrize("trj_file", [HR_TRAJECTORIES_TO_TEST[0]]) +@pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL[:-1]) +@pytest.mark.parametrize("out_fs", SAMPLE_RATE) +@pytest.mark.parametrize("in_fmt", INPUT_FORMATS_MC) +def test_multichannel_binaural_headrotation( + test_info, in_fmt, out_fmt, out_fs, trj_file +): + # if in_fmt in ["MONO", "STEREO"]: + # pytest.skip("MONO or STEREO to Binaural rendering unsupported") + + # -mc InputConf : Multi-channel format + # where InputConf specifies the channel configuration (5_1, 7_1, 5_1_2, 5_1_4, 7_1_4) + + bitrate = 512000 + in_fs = 48 + option_list = ["-mc", in_fmt] + in_file = FORMAT_TO_FILE_MC_WOEXT[in_fmt].format(in_fs) + + compare_rom_vs_binary( + test_info, + option_list, + bitrate, + in_file, + in_fs, + out_fmt, + out_fs, + trj_file=str(TESTV_DIR.joinpath(f"{trj_file}.csv")), + ) + + +""" Ambisonics """ + + +@pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL[:-1]) +@pytest.mark.parametrize("fs", SAMPLE_RATE[1:]) +@pytest.mark.parametrize("in_fmt", INPUT_FORMATS_SBA) +def test_sba_binaural_static(test_info, in_fmt, fs, out_fmt): + # -sba +/-Order : Scene Based Audio input format (Ambisonics ACN/SN3D) + # where Order specifies the Ambisionics order (1-3) + + bitrate = 256000 + option_list = ["-sba", in_fmt] + in_file = FORMAT_TO_FILE_SBA_WOEXT[in_fmt].format(fs) + + compare_rom_vs_binary( + test_info, + option_list, + bitrate, + in_file, + fs, + out_fmt, + fs, + ) + + +@pytest.mark.parametrize("trj_file", [HR_TRAJECTORIES_TO_TEST[0]]) +@pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL[:-1]) +@pytest.mark.parametrize("fs", SAMPLE_RATE[1:]) +@pytest.mark.parametrize("in_fmt", INPUT_FORMATS_SBA) +def test_sba_binaural_headrotation(test_info, in_fmt, fs, out_fmt, trj_file): + # -sba +/-Order : Scene Based Audio input format (Ambisonics ACN/SN3D) + # where Order specifies the Ambisionics order (1-3) + + bitrate = 256000 + option_list = ["-sba", in_fmt] + in_file = FORMAT_TO_FILE_SBA_WOEXT[in_fmt].format(fs) + + compare_rom_vs_binary( + test_info, + option_list, + bitrate, + in_file, + fs, + out_fmt, + fs, + trj_file=str(TESTV_DIR.joinpath(f"{trj_file}.csv")), + ) + + +""" MASA """ + + +@pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL[:-1]) +@pytest.mark.parametrize("fs", SAMPLE_RATE[-1:]) +@pytest.mark.parametrize("in_dir", INPUT_FORMATS_MASA["dir"]) +@pytest.mark.parametrize("in_tc", INPUT_FORMATS_MASA["tc"]) +def test_masa_binaural_static(test_info, in_tc, in_dir, fs, out_fmt): + # -masa Ch File : MASA format + # where Ch specifies the number of MASA input/transport channels (1 or 2) + # and File specifies input file containing parametric MASA metadata + + bitrate = 256000 + metadata_file = str( + TESTV_DIR.joinpath(FORMAT_TO_METADATA_FILES["MASA"].format(in_dir, in_tc, fs)) + ) + option_list = ["-masa", in_tc, metadata_file] + in_file = FORMAT_TO_FILE_MASA_WOEXT.format(in_dir, in_tc, fs) + + compare_rom_vs_binary( + test_info, + option_list, + bitrate, + in_file, + fs, + out_fmt, + fs, + ) + + +@pytest.mark.parametrize("trj_file", [HR_TRAJECTORIES_TO_TEST[1]]) +@pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL[:-1]) +@pytest.mark.parametrize("fs", SAMPLE_RATE[-1:]) +@pytest.mark.parametrize("in_dir", INPUT_FORMATS_MASA["dir"]) +@pytest.mark.parametrize("in_tc", INPUT_FORMATS_MASA["tc"]) +def test_masa_binaural_headrotation(test_info, in_tc, in_dir, fs, out_fmt, trj_file): + # -masa Ch File : MASA format + # where Ch specifies the number of MASA input/transport channels (1 or 2) + # and File specifies input file containing parametric MASA metadata + + bitrate = 256000 + metadata_file = str( + TESTV_DIR.joinpath(FORMAT_TO_METADATA_FILES["MASA"].format(in_dir, in_tc, fs)) + ) + option_list = ["-masa", in_tc, metadata_file] + in_file = FORMAT_TO_FILE_MASA_WOEXT.format(in_dir, in_tc, fs) + + compare_rom_vs_binary( + test_info, + option_list, + bitrate, + in_file, + fs, + out_fmt, + fs, + trj_file=str(TESTV_DIR.joinpath(f"{trj_file}.csv")), + ) + + +""" ISM """ + + +@pytest.mark.parametrize("out_fmt", [OUTPUT_FORMATS_BINAURAL[0]]) +@pytest.mark.parametrize("out_fs", SAMPLE_RATE) +@pytest.mark.parametrize("in_fmt", INPUT_FORMATS_ISM) +def test_ism_binaural_static(test_info, in_fmt, out_fs, out_fmt): + # -ism [+]Ch Files : ISM format + # where Ch specifies the number of ISMs (1-4) + # and Files specify input files containing metadata, one file per object + + in_fs = 48 + bitrate = BITRATE_ISM[in_fmt] + option_list = ["-ism", in_fmt] + metadata_file_list = [] + for n in range(int(in_fmt)): + test = str( + TESTV_DIR.joinpath(FORMAT_TO_METADATA_FILES["ISM"].format(n + 1, in_fs)) + ) + metadata_file_list.append(test) + option_list.extend(metadata_file_list) + in_file = FORMAT_TO_FILE_ISM_WOEXT.format(in_fmt, in_fs) + + compare_rom_vs_binary( + test_info, + option_list, + bitrate, + in_file, + in_fs, + out_fmt, + out_fs, + ) + + +@pytest.mark.parametrize("trj_file", [HR_TRAJECTORIES_TO_TEST[0]]) +@pytest.mark.parametrize("out_fmt", [OUTPUT_FORMATS_BINAURAL[0]]) +@pytest.mark.parametrize("out_fs", SAMPLE_RATE) +@pytest.mark.parametrize("in_fmt", INPUT_FORMATS_ISM) +def test_ism_binaural_headrotation(test_info, in_fmt, out_fs, out_fmt, trj_file): + # -ism [+]Ch Files : ISM format + # where Ch specifies the number of ISMs (1-4) + # and Files specify input files containing metadata, one file per object + + in_fs = 48 + bitrate = BITRATE_ISM[in_fmt] + option_list = ["-ism", in_fmt] + metadata_file_list = [] + for n in range(int(in_fmt)): + test = str( + TESTV_DIR.joinpath(FORMAT_TO_METADATA_FILES["ISM"].format(n + 1, in_fs)) + ) + metadata_file_list.append(test) + option_list.extend(metadata_file_list) + in_file = FORMAT_TO_FILE_ISM_WOEXT.format(in_fmt, in_fs) + + compare_rom_vs_binary( + test_info, + option_list, + bitrate, + in_file, + in_fs, + out_fmt, + out_fs, + trj_file=str(TESTV_DIR.joinpath(f"{trj_file}.csv")), + ) + + +""" ISM - Room Reverb """ + + +@pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL[-1:]) +@pytest.mark.parametrize("out_fs", SAMPLE_RATE) +@pytest.mark.parametrize("in_fmt", INPUT_FORMATS_ISM) +def test_ism_binaural_roomreverb_static(test_info, in_fmt, out_fs, out_fmt): + # -ism [+]Ch Files : ISM format + # where Ch specifies the number of ISMs (1-4) + # and Files specify input files containing metadata, one file per object + + in_fs = 48 + bitrate = BITRATE_ISM[in_fmt] + option_list = ["-ism", in_fmt] + metadata_file_list = [] + for n in range(int(in_fmt)): + test = str( + TESTV_DIR.joinpath(FORMAT_TO_METADATA_FILES["ISM"].format(n + 1, in_fs)) + ) + metadata_file_list.append(test) + option_list.extend(metadata_file_list) + in_file = FORMAT_TO_FILE_ISM_WOEXT.format(in_fmt, in_fs) + + compare_rom_vs_binary( + test_info, + option_list, + bitrate, + in_file, + in_fs, + out_fmt, + out_fs, + ) + + +@pytest.mark.parametrize("trj_file", [HR_TRAJECTORIES_TO_TEST[0]]) +@pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL[-1:]) +@pytest.mark.parametrize("out_fs", SAMPLE_RATE) +@pytest.mark.parametrize("in_fmt", INPUT_FORMATS_ISM) +def test_ism_binaural_roomreverb_headrotation( + test_info, in_fmt, out_fs, out_fmt, trj_file +): + # -ism [+]Ch Files : ISM format + # where Ch specifies the number of ISMs (1-4) + # and Files specify input files containing metadata, one file per object + + in_fs = 48 + bitrate = BITRATE_ISM[in_fmt] + option_list = ["-ism", in_fmt] + metadata_file_list = [] + for n in range(int(in_fmt)): + test = str( + TESTV_DIR.joinpath(FORMAT_TO_METADATA_FILES["ISM"].format(n + 1, in_fs)) + ) + metadata_file_list.append(test) + option_list.extend(metadata_file_list) + in_file = FORMAT_TO_FILE_ISM_WOEXT.format(in_fmt, in_fs) + + compare_rom_vs_binary( + test_info, + option_list, + bitrate, + in_file, + in_fs, + out_fmt, + out_fs, + trj_file=str(TESTV_DIR.joinpath(f"{trj_file}.csv")), + ) diff --git a/tests/hrtf_binary_loading/test_renderer_ROM_vs_file.py b/tests/hrtf_binary_loading/test_renderer_ROM_vs_file.py new file mode 100644 index 0000000000000000000000000000000000000000..1fd7bbbe3e4c6f58c4fc5e303e179f0a6b9c6d99 --- /dev/null +++ b/tests/hrtf_binary_loading/test_renderer_ROM_vs_file.py @@ -0,0 +1,219 @@ +#!/usr/bin/env python3 + +""" + (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. 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. +""" + +import pytest + +from tests.hrtf_binary_loading.utils import * + +from tests.renderer.constants import ( + INPUT_FORMATS_AMBI, + INPUT_FORMATS_ISM, + INPUT_FORMATS_MC, + CUSTOM_LS_TO_TEST, + CUSTOM_LAYOUT_DIR, + FRAMING_TO_TEST, + HR_TRAJECTORY_DIR, +) + +""" Ambisonics """ + + +@pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL) +@pytest.mark.parametrize("in_fmt", INPUT_FORMATS_AMBI) +@pytest.mark.parametrize("frame_size", FRAMING_TO_TEST) +def test_ambisonics_binaural_static_with_binary_hrir( + test_info, in_fmt, out_fmt, frame_size +): + compare_renderer_vs_renderer_with_binary_hrir( + test_info, in_fmt, out_fmt, frame_size=frame_size + ) + + +@pytest.mark.parametrize("trj_file", HR_TRAJECTORIES_TO_TEST_RENDERER) +@pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL) +@pytest.mark.parametrize("in_fmt", INPUT_FORMATS_AMBI) +@pytest.mark.parametrize("frame_size", FRAMING_TO_TEST) +def test_ambisonics_binaural_headrotation_with_binary_hrir( + test_info, in_fmt, out_fmt, trj_file, frame_size +): + compare_renderer_vs_renderer_with_binary_hrir( + test_info, + in_fmt, + out_fmt, + trj_file=HR_TRAJECTORY_DIR.joinpath(f"{trj_file}.csv"), + frame_size=frame_size, + ) + + +""" Multichannel """ + + +@pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL) +@pytest.mark.parametrize("in_fmt", INPUT_FORMATS_MC) +@pytest.mark.parametrize("frame_size", FRAMING_TO_TEST) +def test_multichannel_binaural_static_with_binary_hrir( + test_info, in_fmt, out_fmt, frame_size +): + if in_fmt in ["MONO", "STEREO"]: + pytest.skip("MONO or STEREO to Binaural rendering unsupported") + + compare_renderer_vs_renderer_with_binary_hrir( + test_info, in_fmt, out_fmt, frame_size=frame_size + ) + + +@pytest.mark.parametrize("trj_file", HR_TRAJECTORIES_TO_TEST_RENDERER) +@pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL) +@pytest.mark.parametrize("in_fmt", INPUT_FORMATS_MC) +@pytest.mark.parametrize("frame_size", FRAMING_TO_TEST) +def test_multichannel_binaural_headrotation_with_binary_hrir( + test_info, in_fmt, out_fmt, trj_file, frame_size +): + if in_fmt in ["MONO", "STEREO"]: + pytest.skip("MONO or STEREO to Binaural rendering unsupported") + + compare_renderer_vs_renderer_with_binary_hrir( + test_info, + in_fmt, + out_fmt, + trj_file=HR_TRAJECTORY_DIR.joinpath(f"{trj_file}.csv"), + frame_size=frame_size, + ) + + +""" ISM """ + + +@pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL) +@pytest.mark.parametrize("in_fmt", INPUT_FORMATS_ISM) +@pytest.mark.parametrize("frame_size", FRAMING_TO_TEST) +def test_ism_binaural_static_with_binary_hrir(test_info, in_fmt, out_fmt, frame_size): + try: + in_meta_files = FORMAT_TO_METADATA_FILES_RENDERER[in_fmt] + except: + in_meta_files = None + + compare_renderer_vs_renderer_with_binary_hrir( + test_info, in_fmt, out_fmt, in_meta_files=in_meta_files, frame_size=frame_size + ) + + +@pytest.mark.parametrize("trj_file", HR_TRAJECTORIES_TO_TEST_RENDERER) +@pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL) +@pytest.mark.parametrize("in_fmt", INPUT_FORMATS_ISM) +@pytest.mark.parametrize("frame_size", FRAMING_TO_TEST) +def test_ism_binaural_headrotation_with_binary_hrir( + test_info, in_fmt, out_fmt, trj_file, frame_size +): + try: + in_meta_files = FORMAT_TO_METADATA_FILES_RENDERER[in_fmt] + except: + in_meta_files = None + + compare_renderer_vs_renderer_with_binary_hrir( + test_info, + in_fmt, + out_fmt, + trj_file=HR_TRAJECTORY_DIR.joinpath(f"{trj_file}.csv"), + in_meta_files=in_meta_files, + frame_size=frame_size, + ) + + +""" MASA """ + + +@pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL) +@pytest.mark.parametrize("in_fmt", INPUT_FORMATS_MASA_RENDERER) +@pytest.mark.parametrize("frame_size", FRAMING_TO_TEST) +def test_masa_binaural_static_with_binary_hrir(test_info, in_fmt, out_fmt, frame_size): + if out_fmt in ["BINAURAL_ROOM_IR", "BINAURAL_ROOM_REVERB"]: + pytest.skip("Skipping binaural room outputs for MASA as unimplemented.") + + compare_renderer_vs_renderer_with_binary_hrir( + test_info, + in_fmt, + out_fmt, + in_meta_files=FORMAT_TO_METADATA_FILES_RENDERER[in_fmt], + ) + + +@pytest.mark.parametrize("trj_file", HR_TRAJECTORIES_TO_TEST_RENDERER) +@pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL) +@pytest.mark.parametrize("in_fmt", INPUT_FORMATS_MASA_RENDERER) +@pytest.mark.parametrize("frame_size", FRAMING_TO_TEST) +def test_masa_binaural_headrotation_with_binary_hrir( + test_info, in_fmt, out_fmt, trj_file, frame_size +): + if out_fmt in ["BINAURAL_ROOM_IR", "BINAURAL_ROOM_REVERB"]: + pytest.skip("Skipping binaural room outputs for MASA as unimplemented.") + + compare_renderer_vs_renderer_with_binary_hrir( + test_info, + in_fmt, + out_fmt, + trj_file=HR_TRAJECTORY_DIR.joinpath(f"{trj_file}.csv"), + in_meta_files=FORMAT_TO_METADATA_FILES_RENDERER[in_fmt], + ) + + +""" Custom loudspeaker layouts """ + + +@pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL) +@pytest.mark.parametrize("in_layout", CUSTOM_LS_TO_TEST) +@pytest.mark.parametrize("frame_size", FRAMING_TO_TEST) +def test_custom_ls_input_binaural_with_binary_hrir( + test_info, in_layout, out_fmt, frame_size +): + compare_renderer_vs_renderer_with_binary_hrir( + test_info, + CUSTOM_LAYOUT_DIR.joinpath(f"{in_layout}.txt"), + out_fmt, + frame_size=frame_size, + ) + + +@pytest.mark.parametrize("trj_file", HR_TRAJECTORIES_TO_TEST_RENDERER) +@pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL) +@pytest.mark.parametrize("in_layout", CUSTOM_LS_TO_TEST) +@pytest.mark.parametrize("frame_size", FRAMING_TO_TEST) +def test_custom_ls_input_binaural_headrotation_with_binary_hrir( + test_info, in_layout, out_fmt, trj_file, frame_size +): + compare_renderer_vs_renderer_with_binary_hrir( + test_info, + CUSTOM_LAYOUT_DIR.joinpath(f"{in_layout}.txt"), + out_fmt, + trj_file=HR_TRAJECTORY_DIR.joinpath(f"{trj_file}.csv"), + frame_size=frame_size, + ) diff --git a/tests/hrtf_binary_loading/utils.py b/tests/hrtf_binary_loading/utils.py new file mode 100644 index 0000000000000000000000000000000000000000..66d177541f986d76179fa4009e5e912138396b3d --- /dev/null +++ b/tests/hrtf_binary_loading/utils.py @@ -0,0 +1,391 @@ +#!/usr/bin/env python3 + +""" + (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. 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. +""" + +import os +import sys +import uuid +from typing import Dict, Optional + +import pytest + +from tests.renderer.compare_audio import compare_audio_arrays +from tests.renderer.utils import check_BE, run_cmd, test_info, run_renderer + +from .constants import * + +sys.path.append(SCRIPTS_DIR) +import pyaudio3dtools + + +def run_encoder( + bitrate: int, + sampling_rate: int, + input_file: str, + output_file: str, + sba_order: Optional[str] = None, + dtx_mode: Optional[bool] = False, + max_band: Optional[str] = None, + bypass_mode: Optional[int] = None, + quiet_mode: Optional[bool] = True, + add_option_list: Optional[list] = None, +): + cmd = ENCODER_CMD[:] + + # add optional parameters + + if sba_order is not None: + cmd.extend(["-sba", sba_order]) + + if dtx_mode: + cmd.extend(["-dtx"]) + + if max_band is not None: + cmd.extend(["-max_band", max_band]) + + if bypass_mode is not None: + cmd.extend(["-bypass", str(bypass_mode)]) + + if quiet_mode: + cmd.extend(["-q"]) + + if add_option_list is not None: + cmd.extend(add_option_list) + + # add mandatory parameters + + cmd += [ + str(bitrate), + str(sampling_rate), + str(input_file), + str(output_file), + ] + + run_cmd(cmd) + + +def run_decoder( + output_config: str, + output_sampling_rate: int, + input_bitstream_path: Path, + output_path: Path, + quiet_mode: Optional[bool] = True, + plc_file: Optional[Path] = None, + add_option_list: Optional[list] = None, +): + cmd = DECODER_CMD[:] + + # add optional parameters + + if quiet_mode: + cmd.extend(["-q"]) + + if plc_file is not None: + cmd.extend(["-fec", str(plc_file)]) + + if add_option_list is not None: + cmd.extend(add_option_list) + + # add mandatory parameters + + # output_config is mandatory for IVAS; EVS does not have this parameter, indicated by "" + if output_config != "": + cmd += [output_config] + + cmd += [ + str(output_sampling_rate), + str(input_bitstream_path), + str(output_path), + ] + + run_cmd(cmd) + + +def get_option_list_str(option_list): + option_list_str = option_list.copy() + for i in range(len(option_list_str)): + if option_list_str[i][0] == "-": + option_list_str[i] = option_list_str[i][1:] + if os.path.isfile(option_list_str[i]): + option_list_str[i] = Path(option_list_str[i]).stem + + return option_list_str + + +def check_binary_file(out_fs): + with open( + str(HRTF_BINARY_DIR.joinpath(HRTF_BINARY_FILE.format(out_fs))), "rb" + ) as file: + binary_data = file.read() + + # [Declaration of the binary file] + # File Identifier (8 bytes) + # Size of file in bytes (4 bytes) + # Number of HRTF (2 bytes) + # Max length of HRTF data (4 bytes) + + binary_file_size = os.path.getsize( + str(HRTF_BINARY_DIR.joinpath(HRTF_BINARY_FILE.format(out_fs))) + ) + if binary_file_size < 18: + pytest.fail("HRTF binary file not compliant (size of file header)") + + file_header = binary_data[:18] + + file_identifier = file_header[:8].decode() + if file_identifier != "IVASHRTF": + pytest.fail("Header of HRTF binary file not compliant (identifier)") + + file_size = int.from_bytes(file_header[8:12], byteorder="little") + if file_size != binary_file_size: + pytest.fail("Header of HRTF binary file not compliant (file size)") + + nb_hrtf = int.from_bytes(file_header[12:14], byteorder="little") + max_data_size = int.from_bytes(file_header[14:18], byteorder="little") + + read_bid = 18 + + hrtf_cnt = 0 + raw_data_size_max = 0 + hrtf_config_file = [] + while read_bid < file_size: + if read_bid + 16 > file_size: + pytest.fail("Reading of HRTF header failed") + + # HRTF Header */ + # Renderer type (4 bytes) : See "RENDERER_TYPE" */ + # Input configuration (4 bytes) : See "BINAURAL_INPUT_AUDIO_CONFIG" */ + # Sampling Frequency (4 bytes) */ + # Raw data size (4 bytes) */ + + hrtf_header = binary_data[read_bid : read_bid + 16] + + renderer_type = int.from_bytes(hrtf_header[:4], byteorder="little") + input_configuration = int.from_bytes(hrtf_header[4:8], byteorder="little") + sampling_frequency = int.from_bytes(hrtf_header[8:12], byteorder="little") + raw_data_size = int.from_bytes(hrtf_header[12:16], byteorder="little") + + if ( + (renderer_type != HRTF_READER_RENDERER_BINAURAL_MIXER_CONV) + and (renderer_type != HRTF_READER_RENDERER_BINAURAL_MIXER_CONV_ROOM) + and (renderer_type != HRTF_READER_RENDERER_BINAURAL_FASTCONV) + and (renderer_type != HRTF_READER_RENDERER_BINAURAL_FASTCONV_ROOM) + and (renderer_type != HRTF_READER_RENDERER_BINAURAL_PARAMETRIC) + and (renderer_type != HRTF_READER_RENDERER_BINAURAL_PARAMETRIC_ROOM) + and (renderer_type != HRTF_READER_RENDERER_BINAURAL_OBJECTS_TD) + and (renderer_type != HRTF_READER_RENDERER_BINAURAL_REVERB_ALL) + ): + pytest.fail("Header of HRTF binary file not compliant (renderer type)") + + if ( + (input_configuration != BINAURAL_INPUT_AUDIO_CONFIG_COMBINED) + and (input_configuration != BINAURAL_INPUT_AUDIO_CONFIG_HOA3) + and (input_configuration != BINAURAL_INPUT_AUDIO_CONFIG_HOA2) + and (input_configuration != BINAURAL_INPUT_AUDIO_CONFIG_FOA) + and (input_configuration != BINAURAL_INPUT_AUDIO_CONFIG_UNDEFINED) + ): + pytest.fail( + "Header of HRTF binary file not compliant (input configuration)" + ) + + if ( + (sampling_frequency != 16000) + and (sampling_frequency != 32000) + and (sampling_frequency != 48000) + ): + pytest.fail( + "Header of HRTF binary file not compliant (sampling frequency)" + ) + + if raw_data_size_max < raw_data_size: + raw_data_size_max = raw_data_size + + hrtf_config_file.append( + { + "renderer_type": renderer_type, + "input_configuration": input_configuration, + "sampling_frequency": sampling_frequency, + } + ) + + # hrtf_raw_data => Tested in compare_rom_vs_binary + read_bid += 16 + raw_data_size + + hrtf_cnt += 1 + + if read_bid != file_size: + pytest.fail("Inconsistent size of binary file") + + if hrtf_cnt != nb_hrtf: + pytest.fail("Inconsistent number of HRTF in binary file") + + if raw_data_size_max != max_data_size: + pytest.fail("Inconsistent max data size") + + for hrtf_config in REQ_HRTF_CONFIG: + config = next( + ( + cfg + for cfg in hrtf_config_file + if (cfg["renderer_type"] == hrtf_config["renderer_type"]) + and ( + cfg["input_configuration"] == hrtf_config["input_configuration"] + ) + ), + None, + ) + if config == None: + pytest.fail( + f"Configuration (renderer_type : {hrtf_config['renderer_type']} - input_configuration : {hrtf_config['input_configuration']}) not found in binary file!" + ) + if ( + (hrtf_config["sampling_frequency"] == -1) + and (config["sampling_frequency"] != int(out_fs) * 1000) + ) or ( + (hrtf_config["sampling_frequency"] != -1) + and (config["sampling_frequency"] != hrtf_config["sampling_frequency"]) + ): + pytest.fail( + f"Bad sampling frequency for configuration (renderer_type : {hrtf_config['renderer_type']} - input_configuration : {hrtf_config['input_configuration']}) : {config['sampling_frequency']} instead of {int(out_fs)*1000}!" + ) + + +def compare_rom_vs_binary( + test_info, + option_list_enc, + bitrate, + in_file, + in_fs, + out_fmt, + out_fs, + keep_file: Optional[bool] = False, + trj_file: Optional[str] = None, +): + option_str = "_".join(get_option_list_str(option_list_enc)) + file_ext = f"_{option_str or ''}_{bitrate or ''}_{in_fs or ''}-{out_fs or ''}_{out_fmt or ''}-{uuid.uuid1()} " + + # check_binary_file(out_fs) + + input_path = TESTV_DIR.joinpath(in_file).with_suffix(".wav") + bitstream_path = BITSTREAM_DIR.joinpath(in_file + file_ext) + run_encoder( + bitrate, in_fs, input_path, bitstream_path, add_option_list=option_list_enc + ) + + if trj_file is not None: + option_list_dec = ["-t", trj_file] + file_ext += "_headrot" + else: + option_list_dec = None + out_rom_path = DEC_ROM_DIR.joinpath(in_file + file_ext).with_suffix(".wav") + run_decoder( + out_fmt, out_fs, bitstream_path, out_rom_path, add_option_list=option_list_dec + ) + out_rom, out_rom_fs = pyaudio3dtools.audiofile.readfile(out_rom_path) + + hrtf_file = HRTF_BINARY_FILE.format(out_fs) + if trj_file is not None: + option_list_dec.extend(["-hrtf", str(HRTF_BINARY_DIR.joinpath(hrtf_file))]) + else: + option_list_dec = ["-hrtf", str(HRTF_BINARY_DIR.joinpath(hrtf_file))] + out_bin_path = DEC_BINARY_DIR.joinpath(in_file + file_ext).with_suffix(".wav") + run_decoder( + out_fmt, out_fs, bitstream_path, out_bin_path, add_option_list=option_list_dec + ) + out_bin, out_bin_fs = pyaudio3dtools.audiofile.readfile(out_rom_path) + + check_BE(test_info, out_rom, out_rom_fs, out_bin, out_bin_fs) + if keep_file == False: + os.remove(bitstream_path) + os.remove(out_rom_path) + os.remove(out_bin_path) + + +def compare_renderer_vs_renderer_with_binary_hrir( + test_info, + in_fmt, + out_fmt, + metadata_input: Optional[str] = None, + in_meta_files: Optional[list] = None, + trj_file: Optional[str] = None, + non_diegetic_pan: Optional[str] = None, + name_extension: Optional[str] = uuid.uuid1(), + refrot_file: Optional[str] = None, + refvec_file: Optional[str] = None, + refveclev_file: Optional[str] = None, + config_file: Optional[str] = None, + frame_size: Optional[str] = "20ms", + hrir_name="ivas_binaural_48kHz.bin", + keep_file=False, +): + hrtf_file_dir = SCRIPTS_DIR.joinpath( + "binauralRenderer_interface/binaural_renderers_hrtf_data" + ) + hrtf_file_path = hrtf_file_dir.joinpath(hrir_name) + ref_out = run_renderer( + test_info, + in_fmt, + out_fmt, + metadata_input, + in_meta_files, + trj_file, + non_diegetic_pan, + name_extension, + refrot_file, + refvec_file, + refveclev_file, + config_file, + frame_size=frame_size, + ) + cut_out = run_renderer( + test_info, + in_fmt, + out_fmt, + metadata_input, + in_meta_files, + trj_file, + non_diegetic_pan, + name_extension, + refrot_file, + refvec_file, + refveclev_file, + config_file, + hrtf_file=hrtf_file_path, + frame_size=frame_size, + ) + + ref, ref_fs = pyaudio3dtools.audiofile.readfile(ref_out) + cut, cut_fs = pyaudio3dtools.audiofile.readfile(cut_out) + + check_BE(test_info, ref, ref_fs, cut, cut_fs) + if keep_file == False: + os.remove(ref_out) + os.remove(cut_out) diff --git a/tests/renderer/test_renderer.py b/tests/renderer/test_renderer.py index 1ddba2269586d99d02d0ec82567d23f4b0321b6b..9750cc11f4ee5b547c1e36912596a7b6bd8f340f 100644 --- a/tests/renderer/test_renderer.py +++ b/tests/renderer/test_renderer.py @@ -42,313 +42,396 @@ from .utils import * ############################################################################## """ Ambisonics """ - +@pytest.mark.create_ref @pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS) @pytest.mark.parametrize("in_fmt", INPUT_FORMATS_AMBI) @pytest.mark.parametrize("frame_size", FRAMING_TO_TEST) -def test_ambisonics(test_info, in_fmt, out_fmt, frame_size): +def test_ambisonics(record_property, test_info, in_fmt, out_fmt, frame_size, get_mld, get_mld_lim): run_renderer( + record_property, test_info, in_fmt, out_fmt, frame_size=frame_size, + get_mld=get_mld, + mld_lim=get_mld_lim, ) +@pytest.mark.create_ref @pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL) @pytest.mark.parametrize("in_fmt", INPUT_FORMATS_AMBI) @pytest.mark.parametrize("frame_size", FRAMING_TO_TEST) -def test_ambisonics_binaural_static(test_info, in_fmt, out_fmt, frame_size): +def test_ambisonics_binaural_static(record_property, test_info, in_fmt, out_fmt, frame_size, get_mld, get_mld_lim): run_renderer( + record_property, test_info, in_fmt, out_fmt, frame_size=frame_size, + get_mld=get_mld, + mld_lim=get_mld_lim, ) +@pytest.mark.create_ref @pytest.mark.parametrize("trj_file", HR_TRAJECTORIES_TO_TEST) @pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL) @pytest.mark.parametrize("in_fmt", INPUT_FORMATS_AMBI) @pytest.mark.parametrize("frame_size", FRAMING_TO_TEST) def test_ambisonics_binaural_headrotation( - test_info, in_fmt, out_fmt, trj_file, frame_size + record_property, test_info, in_fmt, out_fmt, trj_file, frame_size, get_mld, get_mld_lim ): run_renderer( + record_property, test_info, in_fmt, out_fmt, trj_file=HR_TRAJECTORY_DIR.joinpath(f"{trj_file}.csv"), frame_size=frame_size, + get_mld=get_mld, + mld_lim=get_mld_lim, ) """ Multichannel """ +@pytest.mark.create_ref @pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS) @pytest.mark.parametrize("in_fmt", INPUT_FORMATS_MC) @pytest.mark.parametrize("frame_size", FRAMING_TO_TEST) -def test_multichannel(test_info, in_fmt, out_fmt, frame_size): +def test_multichannel(record_property, test_info, in_fmt, out_fmt, frame_size, get_mld, get_mld_lim): run_renderer( + record_property, test_info, in_fmt, out_fmt, frame_size=frame_size, + get_mld=get_mld, + mld_lim=get_mld_lim, ) +@pytest.mark.create_ref @pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL) @pytest.mark.parametrize("in_fmt", INPUT_FORMATS_MC) @pytest.mark.parametrize("frame_size", FRAMING_TO_TEST) -def test_multichannel_binaural_static(test_info, in_fmt, out_fmt, frame_size): +def test_multichannel_binaural_static(record_property, test_info, in_fmt, out_fmt, frame_size, get_mld, get_mld_lim): if in_fmt in ["MONO", "STEREO"]: pytest.skip("MONO or STEREO to Binaural rendering unsupported") run_renderer( + record_property, test_info, in_fmt, out_fmt, frame_size=frame_size, + get_mld=get_mld, + mld_lim=get_mld_lim, ) +@pytest.mark.create_ref @pytest.mark.parametrize("trj_file", HR_TRAJECTORIES_TO_TEST) @pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL) @pytest.mark.parametrize("in_fmt", INPUT_FORMATS_MC) @pytest.mark.parametrize("frame_size", FRAMING_TO_TEST) def test_multichannel_binaural_headrotation( - test_info, in_fmt, out_fmt, trj_file, frame_size + record_property, test_info, in_fmt, out_fmt, trj_file, frame_size, get_mld, get_mld_lim ): if in_fmt in ["MONO", "STEREO"]: pytest.skip("MONO or STEREO to Binaural rendering unsupported") run_renderer( + record_property, test_info, in_fmt, out_fmt, trj_file=HR_TRAJECTORY_DIR.joinpath(f"{trj_file}.csv"), frame_size=frame_size, + get_mld=get_mld, + mld_lim=get_mld_lim, ) """ ISM """ +@pytest.mark.create_ref @pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS) @pytest.mark.parametrize("in_fmt", INPUT_FORMATS_ISM) @pytest.mark.parametrize("frame_size", FRAMING_TO_TEST) -def test_ism(test_info, in_fmt, out_fmt, frame_size): +def test_ism(record_property, test_info, in_fmt, out_fmt, frame_size, get_mld, get_mld_lim): run_renderer( + record_property, test_info, in_fmt, out_fmt, in_meta_files=FORMAT_TO_METADATA_FILES[in_fmt], frame_size=frame_size, + get_mld=get_mld, + mld_lim=get_mld_lim, ) +@pytest.mark.create_ref @pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL) @pytest.mark.parametrize("in_fmt", INPUT_FORMATS_ISM) @pytest.mark.parametrize("frame_size", FRAMING_TO_TEST) -def test_ism_binaural_static(test_info, in_fmt, out_fmt, frame_size): +def test_ism_binaural_static(record_property, test_info, in_fmt, out_fmt, frame_size, get_mld, get_mld_lim): try: in_meta_files = FORMAT_TO_METADATA_FILES[in_fmt] except KeyError: in_meta_files = None run_renderer( + record_property, test_info, in_fmt, out_fmt, in_meta_files=in_meta_files, frame_size=frame_size, + get_mld=get_mld, + mld_lim=get_mld_lim, ) +@pytest.mark.create_ref @pytest.mark.parametrize("trj_file", HR_TRAJECTORIES_TO_TEST) @pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL) @pytest.mark.parametrize("in_fmt", INPUT_FORMATS_ISM) @pytest.mark.parametrize("frame_size", FRAMING_TO_TEST) -def test_ism_binaural_headrotation(test_info, in_fmt, out_fmt, trj_file, frame_size): +def test_ism_binaural_headrotation(record_property, test_info, in_fmt, out_fmt, trj_file, frame_size, get_mld, get_mld_lim): try: in_meta_files = FORMAT_TO_METADATA_FILES[in_fmt] except KeyError: in_meta_files = None run_renderer( + record_property, test_info, in_fmt, out_fmt, trj_file=HR_TRAJECTORY_DIR.joinpath(f"{trj_file}.csv"), in_meta_files=in_meta_files, frame_size=frame_size, + get_mld=get_mld, + mld_lim=get_mld_lim, ) """ MASA """ +@pytest.mark.create_ref @pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS) @pytest.mark.parametrize("in_fmt", INPUT_FORMATS_MASA) @pytest.mark.parametrize("frame_size", FRAMING_TO_TEST) -def test_masa(test_info, in_fmt, out_fmt, frame_size): +def test_masa(record_property, test_info, in_fmt, out_fmt, frame_size, get_mld, get_mld_lim): run_renderer( + record_property, test_info, in_fmt, out_fmt, in_meta_files=FORMAT_TO_METADATA_FILES[in_fmt], frame_size=frame_size, + get_mld=get_mld, + mld_lim=get_mld_lim, ) +@pytest.mark.create_ref @pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL) @pytest.mark.parametrize("in_fmt", INPUT_FORMATS_MASA) @pytest.mark.parametrize("frame_size", FRAMING_TO_TEST) -def test_masa_binaural_static(test_info, in_fmt, out_fmt, frame_size): +def test_masa_binaural_static(record_property, test_info, in_fmt, out_fmt, frame_size, get_mld, get_mld_lim): if out_fmt in ["BINAURAL_ROOM_IR", "BINAURAL_ROOM_REVERB"]: pytest.skip("Skipping binaural room outputs for MASA as unimplemented.") run_renderer( + record_property, test_info, in_fmt, out_fmt, in_meta_files=FORMAT_TO_METADATA_FILES[in_fmt], frame_size=frame_size, + get_mld=get_mld, + mld_lim=get_mld_lim, ) +@pytest.mark.create_ref @pytest.mark.parametrize("trj_file", HR_TRAJECTORIES_TO_TEST) @pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL) @pytest.mark.parametrize("in_fmt", INPUT_FORMATS_MASA) @pytest.mark.parametrize("frame_size", FRAMING_TO_TEST) -def test_masa_binaural_headrotation(test_info, in_fmt, out_fmt, trj_file, frame_size): +def test_masa_binaural_headrotation(record_property, test_info, in_fmt, out_fmt, trj_file, frame_size, get_mld, get_mld_lim): if out_fmt in ["BINAURAL_ROOM_IR", "BINAURAL_ROOM_REVERB"]: pytest.skip("Skipping binaural room outputs for MASA as unimplemented.") run_renderer( + record_property, test_info, in_fmt, out_fmt, trj_file=HR_TRAJECTORY_DIR.joinpath(f"{trj_file}.csv"), in_meta_files=FORMAT_TO_METADATA_FILES[in_fmt], frame_size=frame_size, + get_mld=get_mld, + mld_lim=get_mld_lim, ) +@pytest.mark.create_ref @pytest.mark.parametrize("in_fmt", METADATA_SCENES_TO_TEST_MASA_PREREND) -def test_masa_prerend(test_info, in_fmt): +def test_masa_prerend(record_property, test_info, in_fmt, get_mld, get_mld_lim): run_renderer( + record_property, test_info, "META", "MASA2", metadata_input=TEST_VECTOR_DIR.joinpath(f"{in_fmt}.txt"), + get_mld=get_mld, + mld_lim=get_mld_lim, ) """ Custom loudspeaker layouts """ +@pytest.mark.create_ref @pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS) @pytest.mark.parametrize("in_layout", CUSTOM_LS_TO_TEST) @pytest.mark.parametrize("frame_size", FRAMING_TO_TEST) -def test_custom_ls_input(test_info, in_layout, out_fmt, frame_size): +def test_custom_ls_input(record_property, test_info, in_layout, out_fmt, frame_size, get_mld, get_mld_lim): run_renderer( + record_property, test_info, CUSTOM_LAYOUT_DIR.joinpath(f"{in_layout}.txt"), out_fmt, frame_size=frame_size, + get_mld=get_mld, + mld_lim=get_mld_lim, ) +@pytest.mark.create_ref @pytest.mark.parametrize("out_fmt", CUSTOM_LS_TO_TEST) @pytest.mark.parametrize("in_fmt", OUTPUT_FORMATS) -def test_custom_ls_output(test_info, in_fmt, out_fmt): +def test_custom_ls_output(record_property, test_info, in_fmt, out_fmt, get_mld, get_mld_lim): run_renderer( + record_property, test_info, in_fmt, CUSTOM_LAYOUT_DIR.joinpath(f"{out_fmt}.txt"), + get_mld=get_mld, + mld_lim=get_mld_lim, ) +@pytest.mark.create_ref @pytest.mark.parametrize("out_fmt", CUSTOM_LS_TO_TEST) @pytest.mark.parametrize("in_fmt", CUSTOM_LS_TO_TEST) -def test_custom_ls_input_output(test_info, in_fmt, out_fmt): +def test_custom_ls_input_output(record_property, test_info, in_fmt, out_fmt, get_mld, get_mld_lim): run_renderer( + record_property, test_info, CUSTOM_LAYOUT_DIR.joinpath(f"{in_fmt}.txt"), CUSTOM_LAYOUT_DIR.joinpath(f"{out_fmt}.txt"), + get_mld=get_mld, + mld_lim=get_mld_lim, ) +@pytest.mark.create_ref @pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL) @pytest.mark.parametrize("in_layout", CUSTOM_LS_TO_TEST) @pytest.mark.parametrize("frame_size", FRAMING_TO_TEST) -def test_custom_ls_input_binaural(test_info, in_layout, out_fmt, frame_size): +def test_custom_ls_input_binaural(record_property, test_info, in_layout, out_fmt, frame_size, get_mld, get_mld_lim): run_renderer( + record_property, test_info, CUSTOM_LAYOUT_DIR.joinpath(f"{in_layout}.txt"), out_fmt, frame_size=frame_size, + get_mld=get_mld, + mld_lim=get_mld_lim, ) +@pytest.mark.create_ref @pytest.mark.parametrize("trj_file", HR_TRAJECTORIES_TO_TEST) @pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL) @pytest.mark.parametrize("in_layout", CUSTOM_LS_TO_TEST) @pytest.mark.parametrize("frame_size", FRAMING_TO_TEST) def test_custom_ls_input_binaural_headrotation( - test_info, in_layout, out_fmt, trj_file, frame_size + record_property, test_info, in_layout, out_fmt, trj_file, frame_size, get_mld, get_mld_lim ): run_renderer( + record_property, test_info, CUSTOM_LAYOUT_DIR.joinpath(f"{in_layout}.txt"), out_fmt, trj_file=HR_TRAJECTORY_DIR.joinpath(f"{trj_file}.csv"), frame_size=frame_size, + get_mld=get_mld, + mld_lim=get_mld_lim, ) """ Metadata / scene description input """ +@pytest.mark.create_ref @pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS) @pytest.mark.parametrize("in_fmt", METADATA_SCENES_TO_TEST) @pytest.mark.parametrize("frame_size", FRAMING_TO_TEST) -def test_metadata(test_info, in_fmt, out_fmt, frame_size): +def test_metadata(record_property, test_info, in_fmt, out_fmt, frame_size, get_mld, get_mld_lim): run_renderer( + record_property, test_info, "META", out_fmt, metadata_input=TEST_VECTOR_DIR.joinpath(f"{in_fmt}.txt"), frame_size=frame_size, + get_mld=get_mld, + mld_lim=get_mld_lim, ) """ non diegetic pan """ +@pytest.mark.create_ref @pytest.mark.parametrize("out_fmt", ["STEREO"]) @pytest.mark.parametrize("in_fmt", ["MONO"]) @pytest.mark.parametrize("non_diegetic_pan", ["0", "-30", "45", "90", "-90"]) -def test_non_diegetic_pan_static(test_info, in_fmt, out_fmt, non_diegetic_pan): +def test_non_diegetic_pan_static(record_property, test_info, in_fmt, out_fmt, non_diegetic_pan, get_mld, get_mld_lim): run_renderer( + record_property, test_info, in_fmt, out_fmt, non_diegetic_pan=non_diegetic_pan, + get_mld=get_mld, + mld_lim=get_mld_lim, ) +@pytest.mark.create_ref @pytest.mark.parametrize("out_fmt", ["STEREO"]) @pytest.mark.parametrize("in_fmt", ["ISM1"]) @pytest.mark.parametrize("non_diegetic_pan", ["0", "-30", "45", "90", "-90"]) -def test_non_diegetic_pan_ism_static(test_info, in_fmt, out_fmt, non_diegetic_pan): +def test_non_diegetic_pan_ism_static(record_property, test_info, in_fmt, out_fmt, non_diegetic_pan, get_mld, get_mld_lim): run_renderer( + record_property, test_info, in_fmt, out_fmt, non_diegetic_pan=non_diegetic_pan, + get_mld=get_mld, + mld_lim=get_mld_lim, ) @@ -366,12 +449,13 @@ def test_non_diegetic_pan_ism_static(test_info, in_fmt, out_fmt, non_diegetic_pa @pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL) @pytest.mark.parametrize("in_fmt", INPUT_FORMATS_AMBI) def test_ambisonics_binaural_headrotation_refrotzero( - test_info, in_fmt, out_fmt, trj_file + record_property, test_info, in_fmt, out_fmt, trj_file, get_mld, get_mld_lim ): if test_info.config.option.create_ref or test_info.config.option.create_cut: pytest.skip("OTR tests only run for smoke test") compare_renderer_args( + record_property, test_info, in_fmt, out_fmt, @@ -393,11 +477,12 @@ def test_ambisonics_binaural_headrotation_refrotzero( # Note that reference rotation is supplied per 4 subframes; head rotation per subframe. @pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL) @pytest.mark.parametrize("in_fmt", INPUT_FORMATS_AMBI) -def test_ambisonics_binaural_headrotation_refrotequal(test_info, in_fmt, out_fmt): +def test_ambisonics_binaural_headrotation_refrotequal(record_property, test_info, in_fmt, out_fmt, get_mld, get_mld_lim): if test_info.config.option.create_ref or test_info.config.option.create_cut: pytest.skip("OTR tests only run for smoke test") compare_renderer_args( + record_property, test_info, in_fmt, out_fmt, @@ -425,12 +510,13 @@ def test_ambisonics_binaural_headrotation_refrotequal(test_info, in_fmt, out_fmt @pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL) @pytest.mark.parametrize("in_fmt", INPUT_FORMATS_AMBI) def test_ambisonics_binaural_headrotation_refveczero( - test_info, in_fmt, out_fmt, trj_file + record_property, test_info, in_fmt, out_fmt, trj_file, get_mld, get_mld_lim ): if test_info.config.option.create_ref or test_info.config.option.create_cut: pytest.skip("OTR tests only run for smoke test") compare_renderer_args( + record_property, test_info, in_fmt, out_fmt, @@ -453,7 +539,7 @@ def test_ambisonics_binaural_headrotation_refveczero( # looking-direction of the head rotation and therefore compensates it (OTR=REF_VEC) @pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL) @pytest.mark.parametrize("in_fmt", INPUT_FORMATS_AMBI) -def test_ambisonics_binaural_headrotation_refvecequal(test_info, in_fmt, out_fmt): +def test_ambisonics_binaural_headrotation_refvecequal(record_property, test_info, in_fmt, out_fmt, get_mld, get_mld_lim): if test_info.config.option.create_ref or test_info.config.option.create_cut: pytest.skip("OTR tests only run for smoke test") @@ -462,6 +548,7 @@ def test_ambisonics_binaural_headrotation_refvecequal(test_info, in_fmt, out_fmt pytest.xfail("WIP : minor differences to be resolved") else: compare_renderer_args( + record_property, test_info, in_fmt, out_fmt, @@ -487,7 +574,7 @@ def test_ambisonics_binaural_headrotation_refvecequal(test_info, in_fmt, out_fmt # in a way that produces the same acoustic output as the ref head rot trajectory (OTR=REF_VEC) @pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL) @pytest.mark.parametrize("in_fmt", INPUT_FORMATS_AMBI) -def test_ambisonics_binaural_headrotation_refvec_rotating(test_info, in_fmt, out_fmt): +def test_ambisonics_binaural_headrotation_refvec_rotating(record_property, test_info, in_fmt, out_fmt, get_mld, get_mld_lim): if test_info.config.option.create_ref or test_info.config.option.create_cut: pytest.skip("OTR tests only run for smoke test") @@ -496,6 +583,7 @@ def test_ambisonics_binaural_headrotation_refvec_rotating(test_info, in_fmt, out pytest.xfail("WIP : minor differences to be resolved") else: compare_renderer_args( + record_property, test_info, in_fmt, out_fmt, @@ -525,12 +613,13 @@ def test_ambisonics_binaural_headrotation_refvec_rotating(test_info, in_fmt, out @pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL) @pytest.mark.parametrize("in_fmt", INPUT_FORMATS_AMBI) def test_ambisonics_binaural_headrotation_refvec_rotating_fixed_pos_offset( - test_info, in_fmt, out_fmt + record_property, test_info, in_fmt, out_fmt, get_mld, get_mld_lim ): if test_info.config.option.create_ref or test_info.config.option.create_cut: pytest.skip("OTR tests only run for smoke test") compare_renderer_args( + record_property, test_info, in_fmt, out_fmt, @@ -559,12 +648,13 @@ def test_ambisonics_binaural_headrotation_refvec_rotating_fixed_pos_offset( @pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL) @pytest.mark.parametrize("in_fmt", INPUT_FORMATS_AMBI) def test_ambisonics_binaural_headrotation_refveclev_vs_refvec( - test_info, in_fmt, out_fmt + record_property, test_info, in_fmt, out_fmt, get_mld, get_mld_lim ): if test_info.config.option.create_ref or test_info.config.option.create_cut: pytest.skip("OTR tests only run for smoke test") compare_renderer_args( + record_property, test_info, in_fmt, out_fmt, @@ -590,7 +680,7 @@ def test_ambisonics_binaural_headrotation_refveclev_vs_refvec( # in a way that produces the same acoustic output as the ref head rot trajectory (OTR=REF_VEC) @pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL) @pytest.mark.parametrize("in_fmt", INPUT_FORMATS_MC) -def test_multichannel_binaural_headrotation_refvec_rotating(test_info, in_fmt, out_fmt): +def test_multichannel_binaural_headrotation_refvec_rotating(record_property, test_info, in_fmt, out_fmt, get_mld, get_mld_lim): if test_info.config.option.create_ref or test_info.config.option.create_cut: pytest.skip("OTR tests only run for smoke test") @@ -598,6 +688,7 @@ def test_multichannel_binaural_headrotation_refvec_rotating(test_info, in_fmt, o pytest.skip("MONO or STEREO to Binaural rendering unsupported") compare_renderer_args( + record_property, test_info, in_fmt, out_fmt, @@ -624,7 +715,7 @@ def test_multichannel_binaural_headrotation_refvec_rotating(test_info, in_fmt, o # in a way that produces the same acoustic output as the ref head rot trajectory (OTR=REF_VEC) @pytest.mark.parametrize("out_fmt", OUTPUT_FORMATS_BINAURAL) @pytest.mark.parametrize("in_fmt", INPUT_FORMATS_ISM) -def test_ism_binaural_headrotation_refvec_rotating(test_info, in_fmt, out_fmt): +def test_ism_binaural_headrotation_refvec_rotating(record_property, test_info, in_fmt, out_fmt, get_mld, get_mld_lim): if test_info.config.option.create_ref or test_info.config.option.create_cut: pytest.skip("OTR tests only run for smoke test") @@ -634,6 +725,7 @@ def test_ism_binaural_headrotation_refvec_rotating(test_info, in_fmt, out_fmt): in_meta_files = None compare_renderer_args( + record_property, test_info, in_fmt, out_fmt, diff --git a/tests/renderer/utils.py b/tests/renderer/utils.py index 5f724e16de66c2d1b251000208e1a80ec6b9acdf..a70546ddecb90dfa2f4a6538970db5757d286855 100644 --- a/tests/renderer/utils.py +++ b/tests/renderer/utils.py @@ -94,6 +94,7 @@ def check_BE( def run_renderer( + record_property, test_info, in_fmt: str, out_fmt: str, @@ -108,6 +109,9 @@ def run_renderer( config_file: Optional[str] = None, binary_suffix: str = "", frame_size: Optional[str] = "20ms", + hrtf_file: Optional[str] = None, + get_mld = False, + mld_lim = 0, ) -> str: # prepare arguments and filepaths if trj_file is not None: @@ -145,6 +149,11 @@ def run_renderer( else: out_name = out_fmt + if hrtf_file is not None: + hrtf_file_name = f"_{hrtf_file.stem}" + else: + hrtf_file_name = "" + if test_info.config.option.create_ref: output_path_base = OUTPUT_PATH_REF else: @@ -166,7 +175,7 @@ def run_renderer( in_file = FORMAT_TO_FILE[in_fmt] in_name = in_fmt - out_file_stem = f"{in_name}_to_{out_name}{trj_name}{non_diegetic_pan}{refrot_name}{refvec_name}{refveclev_name}{config_name}{framing_name}{name_extension}.wav" + out_file_stem = f"{in_name}_to_{out_name}{trj_name}{non_diegetic_pan}{refrot_name}{refvec_name}{refveclev_name}{config_name}{framing_name}{hrtf_file_name}{name_extension}.wav" out_file = str(output_path_base.joinpath(out_file_stem)) @@ -220,16 +229,25 @@ def run_renderer( # CUT creation mode will run a comparison with REF out_file_ref = str(OUTPUT_PATH_REF.joinpath(out_file_stem)) - try: - ref, ref_fs = readfile(out_file_ref) - except FileNotFoundError: - pytest.fail( - f"Reference vector not found! Ensure they were created with the --create_ref argument.\n{out_file_ref}" - ) - - cut, cut_fs = readfile(out_file) - - check_BE(test_info, ref, ref_fs, cut, cut_fs) + if get_mld: + output_differs, reason = cmp_pcm(out_file, out_file_ref, out_fmt, ref_fs, get_mld=get_mld, mld_lim=get_mld_lim) + mld = 0 + if "MLD" in reason: + mld = float(reason.split(':')[1].split()[0]) + record_property("MLD",mld) + if output_differs: + pytest.fail(f"Output differs: ({reason})") + else: + try: + ref, ref_fs = readfile(out_file_ref) + except FileNotFoundError: + pytest.fail( + f"Reference vector not found! Ensure they were created with the --create_ref argument.\n{out_file_ref}" + ) + + cut, cut_fs = readfile(out_file) + + check_BE(test_info, ref, ref_fs, cut, cut_fs) # compare metadata files in case of MASA prerendering if "MASA" in str(out_fmt): @@ -242,9 +260,10 @@ def run_renderer( def compare_renderer_args( - test_info, in_fmt, out_fmt, ref_kwargs: Dict, cut_kwargs: Dict + record_property, test_info, in_fmt, out_fmt, ref_kwargs: Dict, cut_kwargs: Dict ): out_file_ref = run_renderer( + record_property, test_info, in_fmt, out_fmt, @@ -252,6 +271,7 @@ def compare_renderer_args( ) ref, ref_fs = readfile(out_file_ref) out_file_cut = run_renderer( + record_property, test_info, in_fmt, out_fmt, diff --git a/tests/test_26444.py b/tests/test_26444.py index fcbf2cfc7f167b18139fb0ff46945892e538ea72..ccf8d23fad876f40306052e04be14b1744fd46a4 100644 --- a/tests/test_26444.py +++ b/tests/test_26444.py @@ -88,7 +88,7 @@ def test_evs_26444(test_tag): result1 = filecmp.cmp(cmd1[0], cmd1[1]) result2 = True if not (result1 and result2): - assert False, "Output differs" + pytest.fail("Output differs") \ No newline at end of file diff --git a/tests/test_param_file_ltv.py b/tests/test_param_file_ltv.py index 055cd2415471b1aa5dd7e8c723783fb8b93cd127..d74a32aa76d8f5ec721e430270e7192ac2ecc388 100644 --- a/tests/test_param_file_ltv.py +++ b/tests/test_param_file_ltv.py @@ -126,6 +126,7 @@ def convert_test_string_to_tag(test_string): @pytest.mark.create_ref @pytest.mark.parametrize("test_tag", list(param_file_test_dict.keys())) def test_param_file_tests( + record_property, dut_encoder_frontend: EncoderFrontend, dut_decoder_frontend: DecoderFrontend, ref_encoder_frontend: EncoderFrontend, @@ -138,6 +139,7 @@ def test_param_file_tests( keep_files, test_tag, get_mld, + get_mld_lim, ): enc_opts, dec_opts, sim_opts, eid_opts = param_file_test_dict[test_tag] @@ -326,10 +328,16 @@ def test_param_file_tests( ref_output_file = f"{reference_path}/param_file/dec/{output_file}" fs = int(sampling_rate) * 1000 output_differs, reason = cmp_pcm( - dut_output_file, ref_output_file, output_config, fs, get_mld=get_mld + dut_output_file, ref_output_file, output_config, fs, get_mld=get_mld, mld_lim=get_mld_lim ) md_out_files = get_expected_md_files(ref_output_file, enc_split, output_config) + if get_mld: + mld = 0 + if "MLD" in reason: + mld = float(reason.split(':')[1].split()[0]) + record_property("MLD",mld) + metadata_differs = False for md_file in md_out_files: dut_metadata_file = Path(f"{dut_base_path}/param_file/dec/{md_file}") @@ -348,13 +356,12 @@ def test_param_file_tests( if output_differs or metadata_differs: msg = "Difference between ref and dut in " if output_differs and metadata_differs: - msg += "output and metadata" + msg += f"output ({reason}) and metadata" elif output_differs: - msg += "output only" + msg += f"output only ({reason})" elif metadata_differs: msg += "metadata only" - - assert False, msg + pytest.fail(msg) # remove DUT output files when test result is OK (to save disk space) if not keep_files: