From 5ba20af7a38fad978274542de69369350676b769 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Tue, 3 Sep 2024 09:40:30 +0200 Subject: [PATCH 01/29] enable OBJ_EDITING_INTERFACE and fix EVS non-bitexactness --- apps/decoder.c | 1 - lib_com/options.h | 2 +- lib_dec/ivas_jbm_dec.c | 4 ++-- lib_dec/lib_dec.c | 10 +++++----- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 9a0a7ebd64..fc003928e9 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -1112,7 +1112,6 @@ static bool parseCmdlIVAS_dec( #ifdef OBJ_EDITING_EXAMPLE arg->objEditEnabled = false; #endif -# /*-----------------------------------------------------------------* diff --git a/lib_com/options.h b/lib_com/options.h index 02e3d0df8e..d1e85d2805 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -154,7 +154,7 @@ /* ################## Start DEVELOPMENT switches ######################### */ -/*#define OBJ_EDITING_INTERFACE*/ /* Interface for object editing */ +#define OBJ_EDITING_INTERFACE /* Interface for object editing */ #ifdef OBJ_EDITING_INTERFACE #define OBJ_EDITING_API /* object editing changes related to the API */ #define OBJ_EDITING_EXAMPLE /* obj editing example code in decoder.c */ diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 6eea0419a2..29b2cd1403 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -792,7 +792,7 @@ void ivas_jbm_dec_feed_tc_to_renderer( float *p_data_f[MAX_CLDFB_DIGEST_CHANNELS]; int16_t n, n_render_timeslots; - push_wmops( "ivas_jbm_dec_feed_tc_to_rendererer" ); + push_wmops( "ivas_jbm_dec_feed_tc_to_renderer" ); for ( n = 0; n < MAX_CLDFB_DIGEST_CHANNELS; n++ ) { p_data_f[n] = &data_f[n][0]; @@ -3012,7 +3012,7 @@ void ivas_jbm_dec_prepare_renderer( { int16_t n, n_render_timeslots; - push_wmops( "ivas_jbm_dec_feed_tc_to_rendererer" ); + push_wmops( "ivas_jbm_dec_prepare_renderer" ); n_render_timeslots = st_ivas->hTcBuffer->n_samples_available / st_ivas->hTcBuffer->n_samples_granularity; diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 61ba65f590..69f344d4f5 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -895,7 +895,6 @@ ivas_error IVAS_DEC_FeedFrame_Serial( bfi = 2; } } - if ( ( error = read_indices( hIvasDec->st_ivas, serial, num_bits, &hIvasDec->prev_ft_speech, &hIvasDec->CNG, bfi ) ) != IVAS_ERR_OK ) { return error; @@ -919,8 +918,8 @@ ivas_error IVAS_DEC_FeedFrame_Serial( #ifdef OBJ_EDITING_API /* decode TCs, do TSM and feed to renderer */ - /* setup */ - if ( hIvasDec->hasBeenFedFirstGoodFrame ) + if ( ( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm && hIvasDec->hasBeenFedFirstGoodFrame ) || + ( !hIvasDec->st_ivas->hDecoderConfig->Opt_tsm && ( !hIvasDec->isInitialized || hIvasDec->hasBeenFedFrame ) ) ) { uint16_t l_ts, nTimeScalerOutSamples; uint8_t nTransportChannels, nOutChannels; @@ -989,6 +988,7 @@ ivas_error IVAS_DEC_FeedFrame_Serial( return IVAS_ERR_UNKNOWN; } } + hIvasDec->hasBeenFedFrame = false; } hIvasDec->hasBeenPreparedRendering = false; @@ -1388,7 +1388,7 @@ ivas_error IVAS_DEC_SetEditableParameters( /*---------------------------------------------------------------------* * IVAS_DEC_PrepareRenderer( ) * - * Main function to decode to PCM data + * prepare IVAS JBM renderer *---------------------------------------------------------------------*/ ivas_error IVAS_DEC_PrepareRenderer( IVAS_DEC_HANDLE hIvasDec ) @@ -1605,7 +1605,7 @@ ivas_error IVAS_DEC_GetSamples( #ifdef DEBUGGING else { - assert( 0 & "wrong PCM type for the flush buffer!" ); + assert( 0 && "wrong PCM type for the flush buffer!" ); } #endif nSamplesRendered += hIvasDec->nSamplesFlushed; -- GitLab From 3ac21be59624e84dc9c01657847f839c2a3aa724 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Tue, 10 Sep 2024 08:26:13 +0200 Subject: [PATCH 02/29] Added SBA LTV to test-long-self-test and ltv sanitizer tests --- .gitlab-ci.yml | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a57b67497a..8bc0f5c163 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -228,12 +228,12 @@ stages: - if [ $CLANG_NUM -eq 1 ]; then sanitizer_type="MemorySanitizer"; elif [ $CLANG_NUM -eq 2 ]; then sanitizer_type="AddressSanitizer"; elif [ $CLANG_NUM -eq 3 ]; then sanitizer_type="UndefinedBehaviorSanitizer"; else echo "Wrong CLANG_NUM $CLANG_NUM given!"; exit 1; fi # run encoder and decoder with 20ms renderer framesize first, use reference creation mode - - python3 -m pytest tests/codec_be_on_mr_nonselection/test_param_file.py --param_file $SELF_TEST_PRM_FILE -v --update_ref 1 --html=report-20ms.html --self-contained-html --junit-xml=report-junit-20ms.xml --testcase_timeout=$testcase_timeout --ref_encoder_path ./IVAS_cod --ref_decoder_path ./IVAS_dec || exit_code20=$? + - python3 -m pytest tests/codec_be_on_mr_nonselection $USE_LTV --param_file $SELF_TEST_PRM_FILE -v --update_ref 1 --html=report-20ms.html --self-contained-html --junit-xml=report-junit-20ms.xml --testcase_timeout=$testcase_timeout --ref_encoder_path ./IVAS_cod --ref_decoder_path ./IVAS_dec || exit_code20=$? # for 10ms and 5ms renderer framesize, we only need to run the decoder part as renderer framesize is a decoder-only option # set tolerance very high do ignore any BE differences due to the different renderer framesizes, those can appear due to the limiter being active # we are only interested in runtime errors from the sanitizers and ignore the diffs - - python3 -m pytest tests/codec_be_on_mr_nonselection/test_param_file.py --param_file $SELF_TEST_PRM_FILE -v --html=report-5ms.html --self-contained-html --junit-xml=report-junit-5ms.xml --dut_fr 5 --decoder_only --abs_tol 100000 || exit_code5=$? - - python3 -m pytest tests/codec_be_on_mr_nonselection/test_param_file.py --param_file $SELF_TEST_PRM_FILE -v --html=report-10ms.html --self-contained-html --junit-xml=report-junit-10ms.xml --dut_fr 10 --decoder_only --abs_tol 100000 || exit_code10=$? + - python3 -m pytest tests/codec_be_on_mr_nonselection $USE_LTV --param_file $SELF_TEST_PRM_FILE -v --html=report-5ms.html --self-contained-html --junit-xml=report-junit-5ms.xml --dut_fr 5 --decoder_only --abs_tol 100000 || exit_code5=$? + - python3 -m pytest tests/codec_be_on_mr_nonselection $USE_LTV --param_file $SELF_TEST_PRM_FILE -v --html=report-10ms.html --self-contained-html --junit-xml=report-junit-10ms.xml --dut_fr 10 --decoder_only --abs_tol 100000 || exit_code10=$? - if [ $exit_code20 -ne 0 ] || [ $exit_code10 -ne 0 ] || [ $exit_code5 -ne 0 ]; then exit 1; fi @@ -570,6 +570,7 @@ codec-msan: - CLANG_NUM=1 - SELFTEST_SANITY_TIMEOUT=$TESTCASE_TIMEOUT_STV_SANITIZERS - SELF_TEST_PRM_FILE="scripts/config/self_test.prm" + - $USE_LTV="" <<: *sanitizer-selftest-anchor # code selftest testvectors with address-sanitizer binaries @@ -580,6 +581,7 @@ codec-asan: - CLANG_NUM=2 - SELFTEST_SANITY_TIMEOUT=$TESTCASE_TIMEOUT_STV_SANITIZERS - SELF_TEST_PRM_FILE="scripts/config/self_test.prm" + - $USE_LTV="" <<: *sanitizer-selftest-anchor # code selftest testvectors with undefined-behaviour-sanitizer binaries @@ -592,6 +594,7 @@ codec-usan: - CLANG_NUM=3 - SELFTEST_SANITY_TIMEOUT=$TESTCASE_TIMEOUT_STV_SANITIZERS - SELF_TEST_PRM_FILE="scripts/config/self_test.prm" + - $USE_LTV="" <<: *sanitizer-selftest-anchor # compare bit-exactness between 5ms and 20 on the branch @@ -1612,11 +1615,11 @@ test-long-self-test: # create references - exit_code_ref=0 - testcase_timeout=300 - - python3 -m pytest $TESTS_DIR_CODEC_BE_ON_MR/test_param_file.py -v --update_ref 1 --param_file scripts/config/self_test_ltv.prm --testcase_timeout=$testcase_timeout || exit_code_ref=$? + - python3 -m pytest $TESTS_DIR_CODEC_BE_ON_MR --use_ltv -v --update_ref 1 --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 --testcase_timeout=$testcase_timeout || exit_code=$? + - python3 -m pytest $TESTS_DIR_CODEC_BE_ON_MR --use_ltv -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 @@ -1654,6 +1657,7 @@ ltv-msan: - CLANG_NUM=1 - SELFTEST_SANITY_TIMEOUT=$TESTCASE_TIMEOUT_LTV_SANITIZERS - SELF_TEST_PRM_FILE="scripts/config/self_test_ltv.prm" + - $USE_LTV="--use_ltv" <<: *sanitizer-selftest-anchor # code selftest long testvectors with address-sanitizer binaries @@ -1671,6 +1675,7 @@ ltv-asan: - CLANG_NUM=2 - SELFTEST_SANITY_TIMEOUT=$TESTCASE_TIMEOUT_LTV_SANITIZERS - SELF_TEST_PRM_FILE="scripts/config/self_test_ltv.prm" + - $USE_LTV="--use_ltv" <<: *sanitizer-selftest-anchor # code selftest long testvectors with undefined-behaviour-sanitizer binaries @@ -1688,6 +1693,7 @@ ltv-usan: - CLANG_NUM=3 - SELFTEST_SANITY_TIMEOUT=$TESTCASE_TIMEOUT_LTV_SANITIZERS - SELF_TEST_PRM_FILE="scripts/config/self_test_ltv.prm" + - $USE_LTV="--use_ltv" <<: *sanitizer-selftest-anchor .sanitizer-test-template: -- GitLab From c45b166288031c50108c1b2074360336b7f3dcf2 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Tue, 10 Sep 2024 12:08:42 +0200 Subject: [PATCH 03/29] run be-2-evs-linux in an MR --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8879290e16..df17abe8fb 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1231,7 +1231,7 @@ be-2-evs-windows: be-2-evs-linux: extends: - .test-job-linux - - .rules-main-push + - .rules-merge-request tags: - be-2-evs-temp stage: test -- GitLab From 4e69215d0e20dca5ed2f0faafe634483d1bc8b1b Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Tue, 10 Sep 2024 12:49:58 +0200 Subject: [PATCH 04/29] simplify condition to run decoding in IVAS_DEC_FeedFrame_Serial --- lib_dec/lib_dec.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 69f344d4f5..9bb50ed941 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -918,8 +918,7 @@ ivas_error IVAS_DEC_FeedFrame_Serial( #ifdef OBJ_EDITING_API /* decode TCs, do TSM and feed to renderer */ - if ( ( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm && hIvasDec->hasBeenFedFirstGoodFrame ) || - ( !hIvasDec->st_ivas->hDecoderConfig->Opt_tsm && ( !hIvasDec->isInitialized || hIvasDec->hasBeenFedFrame ) ) ) + if ( ( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm && hIvasDec->hasBeenFedFirstGoodFrame ) || !hIvasDec->st_ivas->hDecoderConfig->Opt_tsm ) { uint16_t l_ts, nTimeScalerOutSamples; uint8_t nTransportChannels, nOutChannels; -- GitLab From d22bcb1522d826497bba553020a6fcfe5f44d1e3 Mon Sep 17 00:00:00 2001 From: norvell Date: Tue, 10 Sep 2024 11:22:50 +0000 Subject: [PATCH 05/29] Correct syntax error for $USE_LTV="--use_ltv" --- .gitlab-ci.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8bc0f5c163..6e5c88431c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -570,7 +570,7 @@ codec-msan: - CLANG_NUM=1 - SELFTEST_SANITY_TIMEOUT=$TESTCASE_TIMEOUT_STV_SANITIZERS - SELF_TEST_PRM_FILE="scripts/config/self_test.prm" - - $USE_LTV="" + - USE_LTV="" <<: *sanitizer-selftest-anchor # code selftest testvectors with address-sanitizer binaries @@ -581,7 +581,7 @@ codec-asan: - CLANG_NUM=2 - SELFTEST_SANITY_TIMEOUT=$TESTCASE_TIMEOUT_STV_SANITIZERS - SELF_TEST_PRM_FILE="scripts/config/self_test.prm" - - $USE_LTV="" + - USE_LTV="" <<: *sanitizer-selftest-anchor # code selftest testvectors with undefined-behaviour-sanitizer binaries @@ -594,7 +594,7 @@ codec-usan: - CLANG_NUM=3 - SELFTEST_SANITY_TIMEOUT=$TESTCASE_TIMEOUT_STV_SANITIZERS - SELF_TEST_PRM_FILE="scripts/config/self_test.prm" - - $USE_LTV="" + - USE_LTV="" <<: *sanitizer-selftest-anchor # compare bit-exactness between 5ms and 20 on the branch @@ -1657,7 +1657,7 @@ ltv-msan: - CLANG_NUM=1 - SELFTEST_SANITY_TIMEOUT=$TESTCASE_TIMEOUT_LTV_SANITIZERS - SELF_TEST_PRM_FILE="scripts/config/self_test_ltv.prm" - - $USE_LTV="--use_ltv" + - USE_LTV="--use_ltv" <<: *sanitizer-selftest-anchor # code selftest long testvectors with address-sanitizer binaries @@ -1675,7 +1675,7 @@ ltv-asan: - CLANG_NUM=2 - SELFTEST_SANITY_TIMEOUT=$TESTCASE_TIMEOUT_LTV_SANITIZERS - SELF_TEST_PRM_FILE="scripts/config/self_test_ltv.prm" - - $USE_LTV="--use_ltv" + - USE_LTV="--use_ltv" <<: *sanitizer-selftest-anchor # code selftest long testvectors with undefined-behaviour-sanitizer binaries @@ -1693,7 +1693,7 @@ ltv-usan: - CLANG_NUM=3 - SELFTEST_SANITY_TIMEOUT=$TESTCASE_TIMEOUT_LTV_SANITIZERS - SELF_TEST_PRM_FILE="scripts/config/self_test_ltv.prm" - - $USE_LTV="--use_ltv" + - USE_LTV="--use_ltv" <<: *sanitizer-selftest-anchor .sanitizer-test-template: -- GitLab From a374784fbcd158fa39ebf8c8a2bbfc741bdcbba2 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 11 Sep 2024 17:10:35 +0200 Subject: [PATCH 06/29] [cleanup] accept FIX_CREND_SIMPLIFY_CODE --- apps/decoder.c | 1 - lib_com/options.h | 1 - lib_rend/ivas_crend.c | 25 ------------------------- 3 files changed, 27 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 9a0a7ebd64..fc003928e9 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -1112,7 +1112,6 @@ static bool parseCmdlIVAS_dec( #ifdef OBJ_EDITING_EXAMPLE arg->objEditEnabled = false; #endif -# /*-----------------------------------------------------------------* diff --git a/lib_com/options.h b/lib_com/options.h index ebce0e4062..3753113199 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -167,7 +167,6 @@ /*#define FIX_I4_OL_PITCH*/ /* fix open-loop pitch used for EVS core switching */ -#define FIX_CREND_SIMPLIFY_CODE /* Ora : simplify line code in crend */ #define TMP_FIX_1119_SPLIT_RENDERING_VOIP /* FhG: Add error check for unsupported config: split rendering with VoIP mode */ #define FIX_POINT_HRTF_FILE_FORMAT /* All: fix point hrtf binary file format */ diff --git a/lib_rend/ivas_crend.c b/lib_rend/ivas_crend.c index 232e478be6..87215cd2bf 100644 --- a/lib_rend/ivas_crend.c +++ b/lib_rend/ivas_crend.c @@ -1566,15 +1566,9 @@ static ivas_error ivas_rend_crendConvolver( int32_t offset, offset_in, offset_diffuse; int16_t nchan_in, nchan_out; const float *pIn; -#ifdef FIX_CREND_SIMPLIFY_CODE const float *pFreq_filt_re, *pFreq_filt_im; float *pFreq_buf_re = NULL, *pFreq_buf_im = NULL; float *pFreq_buf2_re = NULL, *pFreq_buf2_im = NULL; -#else - float *pFreq_buf_re, *pFreq_buf_im; - float *pFreq_buf2_re, *pFreq_buf2_im; - const float *pFreq_filt_re, *pFreq_filt_im; -#endif float pOut[L_FRAME48k * 2]; float tmp_out_re[L_FRAME48k], tmp_out_im[L_FRAME48k]; CREND_HANDLE hCrend; @@ -1621,7 +1615,6 @@ static ivas_error ivas_rend_crendConvolver( } } -#ifdef FIX_CREND_SIMPLIFY_CODE if ( pCrend->hHrtfCrend->num_iterations_diffuse[0] > 0 ) { if ( pCrend->hHrtfCrend->same_inv_diffuse_weight ) @@ -1637,7 +1630,6 @@ static ivas_error ivas_rend_crendConvolver( pFreq_buf2_im = &hCrend->freq_buffer_im_diffuse[1][offset_diffuse]; } } -#endif i = 0; for ( idx_in = 0; idx_in < nchan_in; idx_in++ ) @@ -1649,10 +1641,6 @@ static ivas_error ivas_rend_crendConvolver( { if ( pCrend->hHrtfCrend->same_inv_diffuse_weight ) { -#ifndef FIX_CREND_SIMPLIFY_CODE - pFreq_buf_re = &hCrend->freq_buffer_re_diffuse[0][offset_diffuse]; - pFreq_buf_im = &hCrend->freq_buffer_im_diffuse[0][offset_diffuse]; -#endif pFreq_filt_re = &hCrend->freq_buffer_re[i][offset]; pFreq_filt_im = &hCrend->freq_buffer_im[i][offset]; @@ -1664,12 +1652,6 @@ static ivas_error ivas_rend_crendConvolver( } else { -#ifndef FIX_CREND_SIMPLIFY_CODE - pFreq_buf_re = &hCrend->freq_buffer_re_diffuse[0][offset_diffuse]; - pFreq_buf_im = &hCrend->freq_buffer_im_diffuse[0][offset_diffuse]; - pFreq_buf2_re = &hCrend->freq_buffer_re_diffuse[1][offset_diffuse]; - pFreq_buf2_im = &hCrend->freq_buffer_im_diffuse[1][offset_diffuse]; -#endif pFreq_filt_re = &hCrend->freq_buffer_re[i][offset]; pFreq_filt_im = &hCrend->freq_buffer_im[i][offset]; @@ -1683,14 +1665,7 @@ static ivas_error ivas_rend_crendConvolver( } } -#ifdef FIX_CREND_SIMPLIFY_CODE ivas_mdft( pIn, &hCrend->freq_buffer_re[i][offset], &hCrend->freq_buffer_im[i][offset], subframe_length, subframe_length ); -#else - pFreq_buf_re = &hCrend->freq_buffer_re[i][offset]; - pFreq_buf_im = &hCrend->freq_buffer_im[i][offset]; - - ivas_mdft( pIn, pFreq_buf_re, pFreq_buf_im, subframe_length, subframe_length ); -#endif i++; } } -- GitLab From e113a15ba4b586007dd2c9e4947bbdbf1419ca00 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 11 Sep 2024 17:13:23 +0200 Subject: [PATCH 07/29] [cleanup] accept FIX_POINT_HRTF_FILE_FORMAT --- lib_com/options.h | 3 - lib_util/hrtf_file_reader.c | 2693 ++++++----------- lib_util/hrtf_file_reader.h | 3 - .../generate_tables_from_rom_to_bin.c | 337 --- .../generate_crend_ivas_tables_from_sofa.c | 512 ---- 5 files changed, 871 insertions(+), 2677 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 3753113199..053b3cc518 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -169,14 +169,11 @@ #define TMP_FIX_1119_SPLIT_RENDERING_VOIP /* FhG: Add error check for unsupported config: split rendering with VoIP mode */ -#define FIX_POINT_HRTF_FILE_FORMAT /* All: fix point hrtf binary file format */ -#ifdef FIX_POINT_HRTF_FILE_FORMAT #define FIX_POINT_ROM_CONST /* Ora: issue #1150 HRTF ROM tables should be defined as 'const'*/ #define FIX_1123_CREND_16BIT_FMT /* Ora: update CREND binary file format to 16 bit */ #define FIX_1123_CREND_FLTFX_BE /* Ora: make CREND FLT ROM tables BE to FX file */ #define FIX_1123_FASTCONV_16BIT_FMT /* FhG: issue 1123: update FastConv binary file format and scripts to 16 bit */ #define FIX_RETURN /* VA: fix location of function returns */ -#endif #define FIX_1135_EXT_RENDERER_HANDLES /* VA: issue 1135: Memory usage reduction in external renderer: Allocate only handles that are really needed. */ #define FIX_1158_FASTCONV_REVERB_HRTF /* Philips: issue 1158: Rendering with FastConv to BINAURAL_ROOM_REVERB uses BRIR convolution instead of HRTF */ #define FIX_1166_TDREND_DIV0 /* FhG,Eri: issue 1166: potential divide by zero in TD Renderer */ diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index d893c1d7de..fad9380837 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -32,9 +32,7 @@ #include "hrtf_file_reader.h" #include -#ifdef FIX_POINT_HRTF_FILE_FORMAT #include -#endif #include #include "ivas_prot_rend.h" #include "ivas_prot.h" @@ -58,13 +56,6 @@ typedef struct ivas_hrtfs_file_header_t } ivas_hrtfs_file_header_t; -#ifndef FIX_POINT_HRTF_FILE_FORMAT -/*---------------------------------------------------------------------* - * Local function declarations - *---------------------------------------------------------------------*/ - -static void HRTF_energy_sections_precalc( ModelParams_t *model ); -#endif /*---------------------------------------------------------------------* * hrtfFileReader_open() @@ -195,11 +186,7 @@ static ivas_error check_hrtf_binary_header( /* Check the renderer type */ if ( ( hrtf_header->rend_type != HRTF_READER_RENDERER_BINAURAL_MIXER_CONV ) && ( hrtf_header->rend_type != HRTF_READER_RENDERER_BINAURAL_MIXER_CONV_ROOM ) && ( hrtf_header->rend_type != HRTF_READER_RENDERER_BINAURAL_FASTCONV ) && ( hrtf_header->rend_type != HRTF_READER_RENDERER_BINAURAL_FASTCONV_ROOM ) && -#ifdef FIX_POINT_HRTF_FILE_FORMAT ( hrtf_header->rend_type != HRTF_READER_RENDERER_BINAURAL_PARAMETRIC ) && -#else - ( hrtf_header->rend_type != HRTF_READER_RENDERER_BINAURAL_PARAMETRIC ) && ( hrtf_header->rend_type != HRTF_READER_RENDERER_BINAURAL_PARAMETRIC_ROOM ) && -#endif ( hrtf_header->rend_type != HRTF_READER_RENDERER_BINAURAL_OBJECTS_TD ) && ( hrtf_header->rend_type != HRTF_READER_RENDERER_BINAURAL_REVERB_ALL ) ) { return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Header of HRTF binary file not compliant (renderer type)" ); @@ -251,7 +238,6 @@ static ivas_error read_hrtf_binary_header( return IVAS_ERR_END_OF_FILE; } -#ifdef FIX_POINT_HRTF_FILE_FORMAT /*-------------------------------------------------------------------* * LoadBSplineBinaryITD() @@ -407,71 +393,6 @@ static ivas_error LoadBSplineBinaryITD( return IVAS_ERR_OK; } -#else -/*-------------------------------------------------------------------* - * LoadBSplineBinaryITD() - * - * Loads the B Spline HR filter model ITD data from file. - --------------------------------------------------------------------*/ - -static void LoadBSplineBinaryITD( - ModelParamsITD_t *modelITD, /* i/o: ITD model parameter structure */ - FILE *f_hrtf /* i : HR filter data file handle */ -) -{ - int16_t tmp; - fread( &modelITD->elevDim3, sizeof( int16_t ), 1, f_hrtf ); - modelITD->elevKSeq_dyn = (float *) malloc( ( modelITD->elevDim3 - 2 ) * sizeof( float ) ); - fread( modelITD->elevKSeq_dyn, sizeof( float ), modelITD->elevDim3 - 2, f_hrtf ); - - fread( &modelITD->azimDim3, sizeof( int16_t ), 1, f_hrtf ); - modelITD->azimKSeq_dyn = (float *) malloc( ( ( modelITD->azimDim3 + 1 ) / 2 - 2 ) * sizeof( float ) ); /* basis functions are flipped around 180 deg, number of basis functions above/below is (N+1)/2 */ - fread( modelITD->azimKSeq_dyn, sizeof( float ), ( modelITD->azimDim3 + 1 ) / 2 - 2, f_hrtf ); - - fread( &tmp, sizeof( int16_t ), 1, f_hrtf ); - modelITD->W_dyn = (float *) malloc( tmp * sizeof( float ) ); - fread( modelITD->W_dyn, sizeof( float ), tmp, f_hrtf ); - - /* azimuth */ - modelITD->azimBsLen_dyn = (int16_t *) malloc( HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( int16_t ) ); - fread( modelITD->azimBsLen_dyn, sizeof( int16_t ), HRTF_MODEL_BSPLINE_NUM_COEFFS, f_hrtf ); - modelITD->azimBsStart_dyn = (int16_t *) malloc( HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( int16_t ) ); - fread( modelITD->azimBsStart_dyn, sizeof( int16_t ), HRTF_MODEL_BSPLINE_NUM_COEFFS, f_hrtf ); - - fread( &tmp, sizeof( int16_t ), 1, f_hrtf ); - - modelITD->azimBsShape_dyn = (float *) malloc( tmp * sizeof( float ) ); - fread( modelITD->azimBsShape_dyn, sizeof( float ), tmp, f_hrtf ); - - fread( &modelITD->azimSegSamples, sizeof( int16_t ), 1, f_hrtf ); - - /* elevation */ - modelITD->elevBsLen_dyn = (int16_t *) malloc( HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( int16_t ) ); - fread( modelITD->elevBsLen_dyn, sizeof( int16_t ), HRTF_MODEL_BSPLINE_NUM_COEFFS, f_hrtf ); - modelITD->elevBsStart_dyn = (int16_t *) malloc( HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( int16_t ) ); - fread( modelITD->elevBsStart_dyn, sizeof( int16_t ), HRTF_MODEL_BSPLINE_NUM_COEFFS, f_hrtf ); - - fread( &tmp, sizeof( int16_t ), 1, f_hrtf ); - - modelITD->elevBsShape_dyn = (float *) malloc( tmp * sizeof( float ) ); - fread( modelITD->elevBsShape_dyn, sizeof( float ), tmp, f_hrtf ); - - fread( &modelITD->elevSegSamples, sizeof( int16_t ), 1, f_hrtf ); - - modelITD->elevKSeq = (const float *) modelITD->elevKSeq_dyn; - modelITD->azimKSeq = (const float *) modelITD->azimKSeq_dyn; - modelITD->W = (const float *) modelITD->W_dyn; - modelITD->azimBsShape = (const float *) modelITD->azimBsShape_dyn; - modelITD->elevBsShape = (const float *) modelITD->elevBsShape_dyn; - modelITD->azimBsLen = (const int16_t *) modelITD->azimBsLen_dyn; - modelITD->azimBsStart = (const int16_t *) modelITD->azimBsStart_dyn; - modelITD->elevBsLen = (const int16_t *) modelITD->elevBsLen_dyn; - modelITD->elevBsStart = (const int16_t *) modelITD->elevBsStart_dyn; - - return; -} -#endif -#ifdef FIX_POINT_HRTF_FILE_FORMAT /*-------------------------------------------------------------------* * LoadBSplineBinary() @@ -759,144 +680,6 @@ static ivas_error LoadBSplineBinary( return IVAS_ERR_OK; } -#else -/*-------------------------------------------------------------------* - * LoadBSplineBinary() - * - * Loads the B Spline HR filter model data from file. - --------------------------------------------------------------------*/ - -static ivas_error LoadBSplineBinary( - IVAS_DEC_HRTF_HANDLE HrFiltSet_p, /* i/o: HR filter model parameter structure */ - FILE *f_hrtf /* i : HR filter data file handle */ -) -{ - ModelParams_t *model; - int16_t i, tmp; - - fread( &HrFiltSet_p->latency_s, sizeof( float ), 1, f_hrtf ); - - model = &( HrFiltSet_p->ModelParams ); - - /* Set ROM flag for correct deallocation */ - model->modelROM = FALSE; - - fread( &model->UseItdModel, sizeof( int16_t ), 1, f_hrtf ); /* Indicates if ITD model is active */ - fread( &tmp, sizeof( int16_t ), 1, f_hrtf ); - - switch ( tmp ) - { - case 16: - HrFiltSet_p->SampleRate = 16000; - if ( HrFiltSet_p->ModelParams.UseItdModel ) - { - HrFiltSet_p->ModelParamsITD.resamp_factor = RESAMPLE_FACTOR_16_48; - } - break; - case 32: - HrFiltSet_p->SampleRate = 32000; - if ( HrFiltSet_p->ModelParams.UseItdModel ) - { - HrFiltSet_p->ModelParamsITD.resamp_factor = RESAMPLE_FACTOR_32_48; - } - break; - case 48: - HrFiltSet_p->SampleRate = 48000; - if ( HrFiltSet_p->ModelParams.UseItdModel ) - { - HrFiltSet_p->ModelParamsITD.resamp_factor = 1.0f; - } - break; - default: - return IVAS_ERROR( IVAS_ERR_INVALID_HRTF, "Error: HR filter file had an unsupported sampling rate (%d kHz)", tmp ); - } - - fread( &model->K, sizeof( int16_t ), 1, f_hrtf ); - fread( &model->elevDim3, sizeof( int16_t ), 1, f_hrtf ); - model->elevKSeq_dyn = (float *) malloc( ( model->elevDim3 - 2 ) * sizeof( float ) ); - fread( model->elevKSeq_dyn, sizeof( float ), model->elevDim3 - 2, f_hrtf ); - model->azimDim3_dyn = (int16_t *) malloc( model->elevDim3 * sizeof( int16_t ) ); - model->azim_start_idx_dyn = (int16_t *) malloc( model->elevDim3 * sizeof( int16_t ) ); - model->azimKSeq = (float **) malloc( model->elevDim3 * sizeof( float * ) ); - for ( i = 0; i < model->elevDim3; i++ ) - { - fread( &model->azimDim3_dyn[i], sizeof( int16_t ), 1, f_hrtf ); - fread( &model->azim_start_idx_dyn[i], sizeof( int16_t ), 1, f_hrtf ); - model->azimKSeq[i] = (float *) malloc( ( model->azimDim3_dyn[i] + 1 ) * sizeof( float ) ); - fread( model->azimKSeq[i], sizeof( float ), ( model->azimDim3_dyn[i] + 1 ), f_hrtf ); - } - fread( &model->AlphaN, sizeof( int16_t ), 1, f_hrtf ); - - model->AlphaL_dyn = (float *) malloc( model->AlphaN * model->K * sizeof( float ) ); - fread( model->AlphaL_dyn, sizeof( float ), model->AlphaN * model->K, f_hrtf ); - - model->AlphaR_dyn = (float *) malloc( model->AlphaN * model->K * sizeof( float ) ); - fread( model->AlphaR_dyn, sizeof( float ), model->AlphaN * model->K, f_hrtf ); - - /* azimuth */ - fread( &model->num_unique_azim_splines, sizeof( int16_t ), 1, f_hrtf ); - model->azimBsShape = (const float **) malloc( model->num_unique_azim_splines * sizeof( float * ) ); - model->azimBsShape_dyn = (float **) malloc( model->num_unique_azim_splines * sizeof( float * ) ); - model->azimSegSamples_dyn = (int16_t *) malloc( model->num_unique_azim_splines * sizeof( int16_t ) ); - for ( i = 0; i < model->num_unique_azim_splines; i++ ) - { - fread( &tmp, sizeof( int16_t ), 1, f_hrtf ); - model->azimBsShape_dyn[i] = (float *) malloc( tmp * sizeof( float ) ); - fread( model->azimBsShape_dyn[i], sizeof( float ), tmp, f_hrtf ); - fread( &model->azimSegSamples_dyn[i], sizeof( int16_t ), 1, f_hrtf ); - } - - model->azimShapeIdx_dyn = (int16_t *) malloc( model->elevDim3 * sizeof( int16_t ) ); - fread( model->azimShapeIdx_dyn, sizeof( int16_t ), model->elevDim3, f_hrtf ); - model->azimShapeSampFactor_dyn = (int16_t *) malloc( model->elevDim3 * sizeof( int16_t ) ); - fread( model->azimShapeSampFactor_dyn, sizeof( int16_t ), model->elevDim3, f_hrtf ); - - /* elevation */ - model->elevBsLen_dyn = (int16_t *) malloc( HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( int16_t ) ); - fread( model->elevBsLen_dyn, sizeof( int16_t ), HRTF_MODEL_BSPLINE_NUM_COEFFS, f_hrtf ); - model->elevBsStart_dyn = (int16_t *) malloc( HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( int16_t ) ); - fread( model->elevBsStart_dyn, sizeof( int16_t ), HRTF_MODEL_BSPLINE_NUM_COEFFS, f_hrtf ); - fread( &tmp, sizeof( int16_t ), 1, f_hrtf ); - model->elevBsShape_dyn = (float *) malloc( tmp * sizeof( float ) ); - fread( model->elevBsShape_dyn, sizeof( float ), tmp, f_hrtf ); - - fread( &model->elevSegSamples, sizeof( int16_t ), 1, f_hrtf ); - - /* Set const pointers */ - model->AlphaL = (const float *) model->AlphaL_dyn; - model->AlphaR = (const float *) model->AlphaR_dyn; - model->EL = (const float *) model->EL_dyn; - model->ER = (const float *) model->ER_dyn; - model->elevBsLen = (const int16_t *) model->elevBsLen_dyn; - model->elevBsStart = (const int16_t *) model->elevBsStart_dyn; - model->elevBsShape = (const float *) model->elevBsShape_dyn; - model->elevKSeq = (const float *) model->elevKSeq_dyn; - model->azimDim3 = (const int16_t *) model->azimDim3_dyn; - model->azim_start_idx = (const int16_t *) model->azim_start_idx_dyn; - model->azimSegSamples = (const int16_t *) model->azimSegSamples_dyn; - model->azimShapeIdx = (const int16_t *) model->azimShapeIdx_dyn; - model->azimShapeSampFactor = (const int16_t *) model->azimShapeSampFactor_dyn; - - for ( i = 0; i < model->num_unique_azim_splines; i++ ) - { - model->azimBsShape[i] = (const float *) model->azimBsShape_dyn[i]; - } - - HRTF_model_precalc( model ); - HRTF_energy_sections_precalc( model ); - HrFiltSet_p->FiltLength = HrFiltSet_p->ModelParams.K; - - HrFiltSet_p->ModelEval.hrfModL = (float *) malloc( model->K * sizeof( float ) ); - HrFiltSet_p->ModelEval.hrfModR = (float *) malloc( model->K * sizeof( float ) ); - - if ( HrFiltSet_p->ModelParams.UseItdModel ) - { - LoadBSplineBinaryITD( &HrFiltSet_p->ModelParamsITD, f_hrtf ); - } - - return IVAS_ERR_OK; -} -#endif /*-------------------------------------------------------------------* @@ -919,14 +702,12 @@ static ivas_error load_reverb_from_binary( int32_t hrtf_data_size_max; char *hrtf_data; int16_t lr_iac_len; -#ifdef FIX_POINT_HRTF_FILE_FORMAT int16_t ind; Word16 factorQ; Word16 tmp16; float factorQ_f; #ifndef FIX_POINT_ROM_CONST float average_energy; -#endif #endif if ( hHrtfStatistics == NULL || f_hrtf == NULL ) @@ -1014,7 +795,6 @@ static ivas_error load_reverb_from_binary( return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); } #endif -#ifdef FIX_POINT_HRTF_FILE_FORMAT fread( &factorQ, sizeof( Word16 ), 1, f_hrtf ); factorQ_f = powf( 2.f, -1.f * factorQ ); for ( ind = 0; ind < lr_iac_len; ind++ ) @@ -1047,11 +827,6 @@ static ivas_error load_reverb_from_binary( memcpy( (float *) &hHrtfStatistics->inter_aural_coherence[ind], &average_energy, sizeof( float ) ); #endif } -#else - 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 ); -#endif hHrtfStatistics->fromROM = FALSE; } @@ -1226,64 +1001,6 @@ ivas_error load_HRTF_binary( return TDREND_MIX_LoadHRTF( hrtfReader->file, hHrtf ); } -#ifndef FIX_POINT_HRTF_FILE_FORMAT -/*---------------------------------------------------------------------* - * HRTF_energy_sections_precalc() - * - * Calculate energies of each section and store in model->EL/model->ER - *---------------------------------------------------------------------*/ -static void HRTF_energy_sections_precalc( - ModelParams_t *model /* i/o: HRTF model parameters */ -) -{ - int16_t i, k, j; - float *pEL; - float *pER; - const float *pAlphaL; - const float *pAlphaR; - float tmp; - int16_t AlphaN; - - if ( !model->modelROM ) - { - AlphaN = model->AlphaN; - - /* Precalculated energies for each section and each row of the alpha matrices */ - model->EL_dyn = (float *) malloc( HRTF_MODEL_N_SECTIONS * AlphaN * sizeof( float ) ); - model->ER_dyn = (float *) malloc( HRTF_MODEL_N_SECTIONS * AlphaN * sizeof( float ) ); - pEL = model->EL_dyn; - pER = model->ER_dyn; - for ( i = 0; i < HRTF_MODEL_N_SECTIONS; i++ ) - { - for ( j = 0; j < AlphaN; j++ ) /* rows of Alpha matrices */ - { - *pEL = 0.0f; - *pER = 0.0f; - - pAlphaL = &model->AlphaL[model->iSecFirst[i] * AlphaN + j]; - pAlphaR = &model->AlphaR[model->iSecFirst[i] * AlphaN + j]; - - for ( k = model->iSecFirst[i]; k < model->iSecLast[i]; k++ ) /* k within the sections */ - { - /* Energy calculation */ - tmp = *pAlphaL; - *pEL += tmp * tmp; - tmp = *pAlphaR; - *pER += tmp * tmp; - pAlphaL += AlphaN; - pAlphaR += AlphaN; - } - pEL++; - pER++; - } - } - model->EL = (const float *) model->EL_dyn; - model->ER = (const float *) model->ER_dyn; - } - - return; -} -#endif /*---------------------------------------------------------------------* * destroy_td_hrtf() @@ -1354,7 +1071,6 @@ void destroy_td_hrtf( return; } -#ifndef FIX_POINT_HRTF_FILE_FORMAT /*---------------------------------------------------------------------* * create_HRTF_from_rawdata() @@ -1369,15 +1085,12 @@ static ivas_error create_HRTF_from_rawdata( { int16_t i, j, k; int16_t max_num_iterations_diffuse; -#ifdef FIX_POINT_HRTF_FILE_FORMAT uint32_t max_total_num_fsamp_per_iteration, max_total_num_fsamp_per_iteration_diff; -#else - uint16_t max_total_num_fsamp_per_iteration, max_total_num_fsamp_per_iteration_diff; -#endif - uint32_t mem_size; + uint32_t mem_size, l; char *hrtf_data_rptr; float *pOut_to_bin_wptr; ivas_error error; + Word16 factorQ; if ( *hHRTF == NULL ) { @@ -1396,12 +1109,21 @@ static ivas_error create_HRTF_from_rawdata( return IVAS_ERR_INTERNAL; } + if ( hrtf_data == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + ( *hHRTF )->init_from_rom = 0; hrtf_data_rptr = hrtf_data; + /* latency_s Q factor*/ + factorQ = *( (Word16 *) ( hrtf_data_rptr ) ); + hrtf_data_rptr += sizeof( Word16 ); + /* latency_s */ - ( *hHRTF )->latency_s = *( (float *) ( hrtf_data_rptr ) ); - hrtf_data_rptr += sizeof( float ); + ( *hHRTF )->latency_s = ( *( (Word32 *) ( hrtf_data_rptr ) ) ) * powf( 2.f, -1.f * factorQ ); + hrtf_data_rptr += sizeof( Word32 ); /* max_num_ir */ ( *hHRTF )->max_num_ir = *( (uint16_t *) ( hrtf_data_rptr ) ); @@ -1434,12 +1156,22 @@ static ivas_error create_HRTF_from_rawdata( for ( j = 0; j < BINAURAL_CHANNELS; j++ ) { mem_size = ( *hHRTF )->max_num_iterations * sizeof( uint16_t ); +#ifdef FIX_POINT_ROM_CONST + ( *hHRTF )->pIndex_frequency_max_dyn[i][j] = (uint16_t *) malloc( mem_size ); + if ( ( *hHRTF )->pIndex_frequency_max_dyn[i][j] == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for pIndex_frequency_max" ); + } + memcpy( ( *hHRTF )->pIndex_frequency_max_dyn[i][j], hrtf_data_rptr, mem_size ); + ( *hHRTF )->pIndex_frequency_max[i][j] = ( *hHRTF )->pIndex_frequency_max_dyn[i][j]; +#else ( *hHRTF )->pIndex_frequency_max[i][j] = (uint16_t *) malloc( mem_size ); if ( ( *hHRTF )->pIndex_frequency_max[i][j] == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for pIndex_frequency_max" ); } - memcpy( ( *hHRTF )->pIndex_frequency_max[i][j], hrtf_data_rptr, mem_size ); + memcpy( (uint16_t *) ( *hHRTF )->pIndex_frequency_max[i][j], hrtf_data_rptr, mem_size ); +#endif hrtf_data_rptr += mem_size; } } @@ -1461,12 +1193,22 @@ static ivas_error create_HRTF_from_rawdata( for ( j = 0; j < BINAURAL_CHANNELS; j++ ) { mem_size = ( *hHRTF )->num_iterations_diffuse[j] * sizeof( uint16_t ); +#ifdef FIX_POINT_ROM_CONST + ( *hHRTF )->pIndex_frequency_max_diffuse_dyn[j] = (uint16_t *) malloc( mem_size ); + if ( ( *hHRTF )->pIndex_frequency_max_diffuse_dyn[j] == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for pIndex_frequency_max_diffuse" ); + } + memcpy( ( *hHRTF )->pIndex_frequency_max_diffuse_dyn[j], hrtf_data_rptr, mem_size ); + ( *hHRTF )->pIndex_frequency_max_diffuse[j] = ( *hHRTF )->pIndex_frequency_max_diffuse_dyn[j]; +#else ( *hHRTF )->pIndex_frequency_max_diffuse[j] = (uint16_t *) malloc( mem_size ); - if ( ( *hHRTF )->pIndex_frequency_max_diffuse[j] == NULL ) + if ( (uint16_t *) ( *hHRTF )->pIndex_frequency_max_diffuse[j] == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for pIndex_frequency_max_diffuse" ); } - memcpy( ( *hHRTF )->pIndex_frequency_max_diffuse[j], hrtf_data_rptr, mem_size ); + memcpy( (uint16_t *) ( *hHRTF )->pIndex_frequency_max_diffuse[j], hrtf_data_rptr, mem_size ); +#endif hrtf_data_rptr += mem_size; } } @@ -1475,26 +1217,28 @@ static ivas_error create_HRTF_from_rawdata( ( *hHRTF )->index_frequency_max_diffuse = *( (uint16_t *) ( hrtf_data_rptr ) ); hrtf_data_rptr += sizeof( uint16_t ); + /* inv_diffuse_weight Q factor*/ + factorQ = *( (Word16 *) ( hrtf_data_rptr ) ); + hrtf_data_rptr += sizeof( Word16 ); + /* inv_diffuse_weight */ for ( i = 0; i < ( *hHRTF )->max_num_ir; i++ ) { - ( *hHRTF )->inv_diffuse_weight[0][i] = *( (float *) ( hrtf_data_rptr ) ); - hrtf_data_rptr += sizeof( float ); + ( *hHRTF )->inv_diffuse_weight[0][i] = ( *( (Word16 *) ( hrtf_data_rptr ) ) ) * powf( 2.f, -1.f * factorQ ); + hrtf_data_rptr += sizeof( Word16 ); } + for ( i = 0; i < ( *hHRTF )->max_num_ir; i++ ) { - ( *hHRTF )->inv_diffuse_weight[1][i] = *( (float *) ( hrtf_data_rptr ) ); - hrtf_data_rptr += sizeof( float ); + ( *hHRTF )->inv_diffuse_weight[1][i] = ( *( (Word16 *) ( hrtf_data_rptr ) ) ) * powf( 2.f, -1.f * factorQ ); + hrtf_data_rptr += sizeof( Word16 ); } /* max_total_num_fsamp_per_iteration */ -#ifdef FIX_POINT_HRTF_FILE_FORMAT max_total_num_fsamp_per_iteration = *( (uint32_t *) ( hrtf_data_rptr ) ); hrtf_data_rptr += sizeof( uint32_t ); -#else - max_total_num_fsamp_per_iteration = *( (uint16_t *) ( hrtf_data_rptr ) ); - hrtf_data_rptr += sizeof( uint16_t ); -#endif + factorQ = *( (Word16 *) ( hrtf_data_rptr ) ); + hrtf_data_rptr += sizeof( Word16 ); /* coeff_re (the size depends on pIndex_frequency_max) */ for ( i = 0; i < ( *hHRTF )->max_num_ir; i++ ) @@ -1502,18 +1246,39 @@ static ivas_error create_HRTF_from_rawdata( for ( j = 0; j < BINAURAL_CHANNELS; j++ ) { mem_size = max_total_num_fsamp_per_iteration * sizeof( float ); +#ifdef FIX_POINT_ROM_CONST + ( *hHRTF )->pOut_to_bin_re_dyn[i][j] = (float *) malloc( mem_size ); + if ( ( *hHRTF )->pOut_to_bin_re_dyn[i][j] == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for Out_to_bin_re" ); + } + memset( ( *hHRTF )->pOut_to_bin_re_dyn[i][j], 0x00, mem_size ); + ( *hHRTF )->pOut_to_bin_re[i][j] = ( *hHRTF )->pOut_to_bin_re_dyn[i][j]; + pOut_to_bin_wptr = ( *hHRTF )->pOut_to_bin_re_dyn[i][j]; +#else ( *hHRTF )->pOut_to_bin_re[i][j] = (float *) malloc( mem_size ); if ( ( *hHRTF )->pOut_to_bin_re[i][j] == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for Out_to_bin_re" ); } - memset( ( *hHRTF )->pOut_to_bin_re[i][j], 0x00, mem_size ); + memset( (float *) ( *hHRTF )->pOut_to_bin_re[i][j], 0x00, mem_size ); + + pOut_to_bin_wptr = (float *) ( *hHRTF )->pOut_to_bin_re[i][j]; +#endif - pOut_to_bin_wptr = ( *hHRTF )->pOut_to_bin_re[i][j]; for ( k = 0; k < ( *hHRTF )->num_iterations[i][j]; k++ ) { - mem_size = ( *hHRTF )->pIndex_frequency_max[i][j][k] * sizeof( float ); - memcpy( pOut_to_bin_wptr, hrtf_data_rptr, mem_size ); +#ifdef FIX_1123_CREND_16BIT_FMT + mem_size = ( *hHRTF )->pIndex_frequency_max[i][j][k] * sizeof( int16_t ); + Word16 *ptW = (Word16 *) hrtf_data_rptr; +#else + mem_size = ( *hHRTF )->pIndex_frequency_max[i][j][k] * sizeof( int32_t ); + Word32 *ptW = (Word32 *) hrtf_data_rptr; +#endif + for ( l = 0; l < ( *hHRTF )->pIndex_frequency_max[i][j][k]; l++ ) + { + pOut_to_bin_wptr[l] = ptW[l] * powf( 2.f, -1.f * factorQ ); + } hrtf_data_rptr += mem_size; pOut_to_bin_wptr += ( *hHRTF )->pIndex_frequency_max[i][j][k]; } @@ -1526,18 +1291,39 @@ static ivas_error create_HRTF_from_rawdata( for ( j = 0; j < BINAURAL_CHANNELS; j++ ) { mem_size = max_total_num_fsamp_per_iteration * sizeof( float ); +#ifdef FIX_POINT_ROM_CONST + ( *hHRTF )->pOut_to_bin_im_dyn[i][j] = (float *) malloc( mem_size ); + if ( ( *hHRTF )->pOut_to_bin_im_dyn[i][j] == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for Out_to_bin_im" ); + } + memset( ( *hHRTF )->pOut_to_bin_im_dyn[i][j], 0x00, mem_size ); + ( *hHRTF )->pOut_to_bin_im[i][j] = ( *hHRTF )->pOut_to_bin_im_dyn[i][j]; + + pOut_to_bin_wptr = ( *hHRTF )->pOut_to_bin_im_dyn[i][j]; +#else ( *hHRTF )->pOut_to_bin_im[i][j] = (float *) malloc( mem_size ); if ( ( *hHRTF )->pOut_to_bin_im[i][j] == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for Out_to_bin_im" ); } - memset( ( *hHRTF )->pOut_to_bin_im[i][j], 0x00, mem_size ); + memset( (float *) ( *hHRTF )->pOut_to_bin_im[i][j], 0x00, mem_size ); - pOut_to_bin_wptr = ( *hHRTF )->pOut_to_bin_im[i][j]; + pOut_to_bin_wptr = (float *) ( *hHRTF )->pOut_to_bin_im[i][j]; +#endif for ( k = 0; k < ( *hHRTF )->num_iterations[i][j]; k++ ) { - mem_size = ( *hHRTF )->pIndex_frequency_max[i][j][k] * sizeof( float ); - memcpy( pOut_to_bin_wptr, hrtf_data_rptr, mem_size ); +#ifdef FIX_1123_CREND_16BIT_FMT + mem_size = ( *hHRTF )->pIndex_frequency_max[i][j][k] * sizeof( int16_t ); + Word16 *ptW = (Word16 *) hrtf_data_rptr; +#else + mem_size = ( *hHRTF )->pIndex_frequency_max[i][j][k] * sizeof( int32_t ); + Word32 *ptW = (Word32 *) hrtf_data_rptr; +#endif + for ( l = 0; l < ( *hHRTF )->pIndex_frequency_max[i][j][k]; l++ ) + { + pOut_to_bin_wptr[l] = ptW[l] * powf( 2.f, -1.f * factorQ ); + } hrtf_data_rptr += mem_size; pOut_to_bin_wptr += ( *hHRTF )->pIndex_frequency_max[i][j][k]; } @@ -1545,32 +1331,51 @@ static ivas_error create_HRTF_from_rawdata( } /* max_total_num_fsamp_per_iteration_diff */ -#ifdef FIX_POINT_HRTF_FILE_FORMAT max_total_num_fsamp_per_iteration_diff = *( (uint32_t *) ( hrtf_data_rptr ) ); hrtf_data_rptr += sizeof( uint32_t ); -#else - max_total_num_fsamp_per_iteration_diff = *( (uint16_t *) ( hrtf_data_rptr ) ); - hrtf_data_rptr += sizeof( uint16_t ); -#endif if ( max_total_num_fsamp_per_iteration_diff != 0 ) { + /* factorQ = *( (Word16 *) ( hrtf_data_rptr ) ); */ + /* hrtf_data_rptr += sizeof( Word16 ); */ /* coeff_diffuse_re : The size depends on pIndex_frequency_max_diffuse */ for ( j = 0; j < BINAURAL_CHANNELS; j++ ) { mem_size = max_total_num_fsamp_per_iteration_diff * sizeof( float ); +#ifdef FIX_POINT_ROM_CONST + ( *hHRTF )->pOut_to_bin_diffuse_re_dyn[j] = (float *) malloc( mem_size ); + if ( ( *hHRTF )->pOut_to_bin_diffuse_re_dyn[j] == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for pOut_to_bin_diffuse_re" ); + } + memset( ( *hHRTF )->pOut_to_bin_diffuse_re_dyn[j], 0x00, mem_size ); + ( *hHRTF )->pOut_to_bin_diffuse_re[j] = ( *hHRTF )->pOut_to_bin_diffuse_re_dyn[j]; + + pOut_to_bin_wptr = ( *hHRTF )->pOut_to_bin_diffuse_re_dyn[j]; +#else ( *hHRTF )->pOut_to_bin_diffuse_re[j] = (float *) malloc( mem_size ); if ( ( *hHRTF )->pOut_to_bin_diffuse_re[j] == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for pOut_to_bin_diffuse_re" ); } - memset( ( *hHRTF )->pOut_to_bin_diffuse_re[j], 0x00, mem_size ); + memset( (uint16_t *) ( *hHRTF )->pOut_to_bin_diffuse_re[j], 0x00, mem_size ); + + pOut_to_bin_wptr = (float *) ( *hHRTF )->pOut_to_bin_diffuse_re[j]; +#endif - pOut_to_bin_wptr = ( *hHRTF )->pOut_to_bin_diffuse_re[j]; for ( k = 0; k < ( *hHRTF )->num_iterations_diffuse[j]; k++ ) { - mem_size = ( *hHRTF )->pIndex_frequency_max_diffuse[j][k] * sizeof( float ); - memcpy( pOut_to_bin_wptr, hrtf_data_rptr, mem_size ); +#ifdef FIX_1123_CREND_16BIT_FMT + mem_size = ( *hHRTF )->pIndex_frequency_max_diffuse[j][k] * sizeof( int16_t ); + Word16 *ptW = (Word16 *) hrtf_data_rptr; +#else + mem_size = ( *hHRTF )->pIndex_frequency_max_diffuse[j][k] * sizeof( int32_t ); + Word32 *ptW = (Word32 *) hrtf_data_rptr; +#endif + for ( l = 0; l < ( *hHRTF )->pIndex_frequency_max_diffuse[j][k]; l++ ) + { + pOut_to_bin_wptr[l] = ptW[l] * powf( 2.f, -1.f * factorQ ); + } hrtf_data_rptr += mem_size; pOut_to_bin_wptr += ( *hHRTF )->pIndex_frequency_max_diffuse[j][k]; } @@ -1580,18 +1385,39 @@ static ivas_error create_HRTF_from_rawdata( for ( j = 0; j < BINAURAL_CHANNELS; j++ ) { mem_size = max_total_num_fsamp_per_iteration_diff * sizeof( float ); +#ifdef FIX_POINT_ROM_CONST + ( *hHRTF )->pOut_to_bin_diffuse_im_dyn[j] = (float *) malloc( mem_size ); + if ( ( *hHRTF )->pOut_to_bin_diffuse_im_dyn[j] == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for pOut_to_bin_diffuse_im" ); + } + memset( ( *hHRTF )->pOut_to_bin_diffuse_im_dyn[j], 0x00, mem_size ); + ( *hHRTF )->pOut_to_bin_diffuse_im[j] = ( *hHRTF )->pOut_to_bin_diffuse_im_dyn[j]; + + pOut_to_bin_wptr = ( *hHRTF )->pOut_to_bin_diffuse_im_dyn[j]; +#else ( *hHRTF )->pOut_to_bin_diffuse_im[j] = (float *) malloc( mem_size ); if ( ( *hHRTF )->pOut_to_bin_diffuse_im[j] == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for pOut_to_bin_diffuse_im" ); } - memset( ( *hHRTF )->pOut_to_bin_diffuse_im[j], 0x00, mem_size ); + memset( (uint16_t *) ( *hHRTF )->pOut_to_bin_diffuse_im[j], 0x00, mem_size ); - pOut_to_bin_wptr = ( *hHRTF )->pOut_to_bin_diffuse_im[j]; + pOut_to_bin_wptr = (float *) ( *hHRTF )->pOut_to_bin_diffuse_im[j]; +#endif for ( k = 0; k < ( *hHRTF )->num_iterations_diffuse[j]; k++ ) { - mem_size = ( *hHRTF )->pIndex_frequency_max_diffuse[j][k] * sizeof( float ); - memcpy( pOut_to_bin_wptr, hrtf_data_rptr, mem_size ); +#ifdef FIX_1123_CREND_16BIT_FMT + mem_size = ( *hHRTF )->pIndex_frequency_max_diffuse[j][k] * sizeof( int16_t ); + Word16 *ptW = (Word16 *) hrtf_data_rptr; +#else + mem_size = ( *hHRTF )->pIndex_frequency_max_diffuse[j][k] * sizeof( int32_t ); + Word32 *ptW = (Word32 *) hrtf_data_rptr; +#endif + for ( l = 0; l < ( *hHRTF )->pIndex_frequency_max_diffuse[j][k]; l++ ) + { + pOut_to_bin_wptr[l] = ptW[l] * powf( 2.f, -1.f * factorQ ); + } hrtf_data_rptr += mem_size; pOut_to_bin_wptr += ( *hHRTF )->pIndex_frequency_max_diffuse[j][k]; } @@ -1601,51 +1427,42 @@ static ivas_error create_HRTF_from_rawdata( return IVAS_ERR_OK; } -#else /*---------------------------------------------------------------------* - * create_HRTF_from_rawdata() + * create_fastconv_HRTF_from_rawdata() * - * Create HRTF from the raw data (to the HRTF CRend handle) + * Create HRTF from the raw data (to the HRTF FastConv handle) *---------------------------------------------------------------------*/ -static ivas_error create_HRTF_from_rawdata( - HRTFS_HANDLE *hHRTF, /* i/o: HRTF CRend handle */ - char *hrtf_data /* i : pointer to binary file */ +static ivas_error create_fastconv_HRTF_from_rawdata( + HRTFS_FASTCONV_HANDLE *hHRTF, /* i/o: HRTF FastConv handle */ + char *hrtf_data, /* i : pointer to binary file */ + HRTF_READER_RENDERER_TYPE rend_type, /* i : Renderer type */ + BINAURAL_INPUT_AUDIO_CONFIG input_cfg /* i : Input binaural config */ ) { int16_t i, j, k; - int16_t max_num_iterations_diffuse; - uint32_t max_total_num_fsamp_per_iteration, max_total_num_fsamp_per_iteration_diff; - uint32_t mem_size, l; char *hrtf_data_rptr; - float *pOut_to_bin_wptr; ivas_error error; Word16 factorQ; - - if ( *hHRTF == NULL ) - { - if ( ( ( *hHRTF ) = (HRTFS_HANDLE) malloc( sizeof( HRTFS_DATA ) ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HRTF binary data\n" ); - } - - if ( ( error = ivas_hrtf_init( *hHRTF ) ) != IVAS_ERR_OK ) - { - return error; - } - } - else - { - return IVAS_ERR_INTERNAL; - } +#ifdef FIX_1123_FASTCONV_16BIT_FMT + float scaleFactor; + int16_t *ptW16; + float latency_s; + uint16_t ntaps; + uint16_t nbchan; +#else + int32_t *ptW32; +#endif if ( hrtf_data == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } - ( *hHRTF )->init_from_rom = 0; + ( *hHRTF )->allocate_init_flag = 0; + +#ifdef FIX_1123_FASTCONV_16BIT_FMT hrtf_data_rptr = hrtf_data; /* latency_s Q factor*/ @@ -1653,1320 +1470,77 @@ static ivas_error create_HRTF_from_rawdata( hrtf_data_rptr += sizeof( Word16 ); /* latency_s */ - ( *hHRTF )->latency_s = ( *( (Word32 *) ( hrtf_data_rptr ) ) ) * powf( 2.f, -1.f * factorQ ); + latency_s = ( *( (Word32 *) ( hrtf_data_rptr ) ) ) * powf( 2.f, -1.f * factorQ ); hrtf_data_rptr += sizeof( Word32 ); - /* max_num_ir */ - ( *hHRTF )->max_num_ir = *( (uint16_t *) ( hrtf_data_rptr ) ); - hrtf_data_rptr += sizeof( uint16_t ); - - /* BINAURAL_CHANNELS */ - if ( BINAURAL_CHANNELS != *( (int16_t *) ( hrtf_data_rptr ) ) ) + if ( BINAURAL_CONVBANDS != *( (uint16_t *) ( hrtf_data_rptr ) ) ) { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file format not compliant (BINAURAL_CHANNELS)" ); + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (BINAURAL_CONVBANDS)" ); } hrtf_data_rptr += sizeof( uint16_t ); - /* max_num_iterations */ - ( *hHRTF )->max_num_iterations = *( (int16_t *) ( hrtf_data_rptr ) ); - hrtf_data_rptr += sizeof( int16_t ); + nbchan = *( (uint16_t *) ( hrtf_data_rptr ) ); + hrtf_data_rptr += sizeof( uint16_t ); - /* num_iterations */ - for ( i = 0; i < ( *hHRTF )->max_num_ir; i++ ) + ntaps = *( (uint16_t *) ( hrtf_data_rptr ) ); + hrtf_data_rptr += sizeof( uint16_t ); + + if ( rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_COMBINED ) { - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) + if ( HRTF_LS_CHANNELS != nbchan ) { - ( *hHRTF )->num_iterations[i][j] = *( (uint16_t *) ( hrtf_data_rptr ) ); - hrtf_data_rptr += sizeof( uint16_t ); + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (HRTF_LS_CHANNELS)" ); } + ( *hHRTF )->ntaps_hrir = ntaps; + ( *hHRTF )->FASTCONV_HRIR_latency_s = latency_s; } - - /* pIndex_frequency_max */ - for ( i = 0; i < ( *hHRTF )->max_num_ir; i++ ) + else if ( rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_HOA3 ) { - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) + if ( HOA3_CHANNELS != nbchan ) { - mem_size = ( *hHRTF )->max_num_iterations * sizeof( uint16_t ); -#ifdef FIX_POINT_ROM_CONST - ( *hHRTF )->pIndex_frequency_max_dyn[i][j] = (uint16_t *) malloc( mem_size ); - if ( ( *hHRTF )->pIndex_frequency_max_dyn[i][j] == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for pIndex_frequency_max" ); - } - memcpy( ( *hHRTF )->pIndex_frequency_max_dyn[i][j], hrtf_data_rptr, mem_size ); - ( *hHRTF )->pIndex_frequency_max[i][j] = ( *hHRTF )->pIndex_frequency_max_dyn[i][j]; -#else - ( *hHRTF )->pIndex_frequency_max[i][j] = (uint16_t *) malloc( mem_size ); - if ( ( *hHRTF )->pIndex_frequency_max[i][j] == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for pIndex_frequency_max" ); - } - memcpy( (uint16_t *) ( *hHRTF )->pIndex_frequency_max[i][j], hrtf_data_rptr, mem_size ); -#endif - hrtf_data_rptr += mem_size; + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (HOA3_CHANNELS)" ); } + ( *hHRTF )->ntaps_hrir_hoa3 = ntaps; + ( *hHRTF )->FASTCONV_HOA3_latency_s = latency_s; } - - /* max_num_iterations_diffuse */ - max_num_iterations_diffuse = *( (int16_t *) ( hrtf_data_rptr ) ); - hrtf_data_rptr += sizeof( int16_t ); - - if ( max_num_iterations_diffuse != 0 ) + else if ( rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_HOA2 ) { - /* num_iterations_diffuse */ - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) + if ( HOA2_CHANNELS != nbchan ) { - ( *hHRTF )->num_iterations_diffuse[j] = *( (uint16_t *) ( hrtf_data_rptr ) ); - hrtf_data_rptr += sizeof( uint16_t ); + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (HOA2_CHANNELS)" ); } - - /* pIndex_frequency_max_diffuse (the size depends on num_iterations_diffuse) */ - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) + ( *hHRTF )->ntaps_hrir_hoa2 = ntaps; + ( *hHRTF )->FASTCONV_HOA2_latency_s = latency_s; + } + else if ( rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_FOA ) + { + if ( FOA_CHANNELS != nbchan ) { - mem_size = ( *hHRTF )->num_iterations_diffuse[j] * sizeof( uint16_t ); -#ifdef FIX_POINT_ROM_CONST - ( *hHRTF )->pIndex_frequency_max_diffuse_dyn[j] = (uint16_t *) malloc( mem_size ); - if ( ( *hHRTF )->pIndex_frequency_max_diffuse_dyn[j] == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for pIndex_frequency_max_diffuse" ); - } - memcpy( ( *hHRTF )->pIndex_frequency_max_diffuse_dyn[j], hrtf_data_rptr, mem_size ); - ( *hHRTF )->pIndex_frequency_max_diffuse[j] = ( *hHRTF )->pIndex_frequency_max_diffuse_dyn[j]; -#else - ( *hHRTF )->pIndex_frequency_max_diffuse[j] = (uint16_t *) malloc( mem_size ); - if ( (uint16_t *) ( *hHRTF )->pIndex_frequency_max_diffuse[j] == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for pIndex_frequency_max_diffuse" ); - } - memcpy( (uint16_t *) ( *hHRTF )->pIndex_frequency_max_diffuse[j], hrtf_data_rptr, mem_size ); -#endif - hrtf_data_rptr += mem_size; + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (FOA_CHANNELS)" ); } + ( *hHRTF )->ntaps_hrir_foa = ntaps; + ( *hHRTF )->FASTCONV_FOA_latency_s = latency_s; } - - /* index_frequency_max_diffuse */ - ( *hHRTF )->index_frequency_max_diffuse = *( (uint16_t *) ( hrtf_data_rptr ) ); - hrtf_data_rptr += sizeof( uint16_t ); - - /* inv_diffuse_weight Q factor*/ - factorQ = *( (Word16 *) ( hrtf_data_rptr ) ); - hrtf_data_rptr += sizeof( Word16 ); - - /* inv_diffuse_weight */ - for ( i = 0; i < ( *hHRTF )->max_num_ir; i++ ) - { - ( *hHRTF )->inv_diffuse_weight[0][i] = ( *( (Word16 *) ( hrtf_data_rptr ) ) ) * powf( 2.f, -1.f * factorQ ); - hrtf_data_rptr += sizeof( Word16 ); - } - - for ( i = 0; i < ( *hHRTF )->max_num_ir; i++ ) - { - ( *hHRTF )->inv_diffuse_weight[1][i] = ( *( (Word16 *) ( hrtf_data_rptr ) ) ) * powf( 2.f, -1.f * factorQ ); - hrtf_data_rptr += sizeof( Word16 ); - } - - /* max_total_num_fsamp_per_iteration */ - max_total_num_fsamp_per_iteration = *( (uint32_t *) ( hrtf_data_rptr ) ); - hrtf_data_rptr += sizeof( uint32_t ); - factorQ = *( (Word16 *) ( hrtf_data_rptr ) ); - hrtf_data_rptr += sizeof( Word16 ); - - /* coeff_re (the size depends on pIndex_frequency_max) */ - for ( i = 0; i < ( *hHRTF )->max_num_ir; i++ ) - { - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - mem_size = max_total_num_fsamp_per_iteration * sizeof( float ); -#ifdef FIX_POINT_ROM_CONST - ( *hHRTF )->pOut_to_bin_re_dyn[i][j] = (float *) malloc( mem_size ); - if ( ( *hHRTF )->pOut_to_bin_re_dyn[i][j] == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for Out_to_bin_re" ); - } - memset( ( *hHRTF )->pOut_to_bin_re_dyn[i][j], 0x00, mem_size ); - ( *hHRTF )->pOut_to_bin_re[i][j] = ( *hHRTF )->pOut_to_bin_re_dyn[i][j]; - pOut_to_bin_wptr = ( *hHRTF )->pOut_to_bin_re_dyn[i][j]; -#else - ( *hHRTF )->pOut_to_bin_re[i][j] = (float *) malloc( mem_size ); - if ( ( *hHRTF )->pOut_to_bin_re[i][j] == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for Out_to_bin_re" ); - } - memset( (float *) ( *hHRTF )->pOut_to_bin_re[i][j], 0x00, mem_size ); - - pOut_to_bin_wptr = (float *) ( *hHRTF )->pOut_to_bin_re[i][j]; -#endif - - for ( k = 0; k < ( *hHRTF )->num_iterations[i][j]; k++ ) - { -#ifdef FIX_1123_CREND_16BIT_FMT - mem_size = ( *hHRTF )->pIndex_frequency_max[i][j][k] * sizeof( int16_t ); - Word16 *ptW = (Word16 *) hrtf_data_rptr; -#else - mem_size = ( *hHRTF )->pIndex_frequency_max[i][j][k] * sizeof( int32_t ); - Word32 *ptW = (Word32 *) hrtf_data_rptr; -#endif - for ( l = 0; l < ( *hHRTF )->pIndex_frequency_max[i][j][k]; l++ ) - { - pOut_to_bin_wptr[l] = ptW[l] * powf( 2.f, -1.f * factorQ ); - } - hrtf_data_rptr += mem_size; - pOut_to_bin_wptr += ( *hHRTF )->pIndex_frequency_max[i][j][k]; - } - } - } - - /* coeff_im (the size depends on pIndex_frequency_max) */ - for ( i = 0; i < ( *hHRTF )->max_num_ir; i++ ) - { - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - mem_size = max_total_num_fsamp_per_iteration * sizeof( float ); -#ifdef FIX_POINT_ROM_CONST - ( *hHRTF )->pOut_to_bin_im_dyn[i][j] = (float *) malloc( mem_size ); - if ( ( *hHRTF )->pOut_to_bin_im_dyn[i][j] == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for Out_to_bin_im" ); - } - memset( ( *hHRTF )->pOut_to_bin_im_dyn[i][j], 0x00, mem_size ); - ( *hHRTF )->pOut_to_bin_im[i][j] = ( *hHRTF )->pOut_to_bin_im_dyn[i][j]; - - pOut_to_bin_wptr = ( *hHRTF )->pOut_to_bin_im_dyn[i][j]; -#else - ( *hHRTF )->pOut_to_bin_im[i][j] = (float *) malloc( mem_size ); - if ( ( *hHRTF )->pOut_to_bin_im[i][j] == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for Out_to_bin_im" ); - } - memset( (float *) ( *hHRTF )->pOut_to_bin_im[i][j], 0x00, mem_size ); - - pOut_to_bin_wptr = (float *) ( *hHRTF )->pOut_to_bin_im[i][j]; -#endif - for ( k = 0; k < ( *hHRTF )->num_iterations[i][j]; k++ ) - { -#ifdef FIX_1123_CREND_16BIT_FMT - mem_size = ( *hHRTF )->pIndex_frequency_max[i][j][k] * sizeof( int16_t ); - Word16 *ptW = (Word16 *) hrtf_data_rptr; -#else - mem_size = ( *hHRTF )->pIndex_frequency_max[i][j][k] * sizeof( int32_t ); - Word32 *ptW = (Word32 *) hrtf_data_rptr; -#endif - for ( l = 0; l < ( *hHRTF )->pIndex_frequency_max[i][j][k]; l++ ) - { - pOut_to_bin_wptr[l] = ptW[l] * powf( 2.f, -1.f * factorQ ); - } - hrtf_data_rptr += mem_size; - pOut_to_bin_wptr += ( *hHRTF )->pIndex_frequency_max[i][j][k]; - } - } - } - - /* max_total_num_fsamp_per_iteration_diff */ - max_total_num_fsamp_per_iteration_diff = *( (uint32_t *) ( hrtf_data_rptr ) ); - hrtf_data_rptr += sizeof( uint32_t ); - - if ( max_total_num_fsamp_per_iteration_diff != 0 ) - { - /* factorQ = *( (Word16 *) ( hrtf_data_rptr ) ); */ - /* hrtf_data_rptr += sizeof( Word16 ); */ - /* coeff_diffuse_re : The size depends on pIndex_frequency_max_diffuse */ - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - mem_size = max_total_num_fsamp_per_iteration_diff * sizeof( float ); -#ifdef FIX_POINT_ROM_CONST - ( *hHRTF )->pOut_to_bin_diffuse_re_dyn[j] = (float *) malloc( mem_size ); - if ( ( *hHRTF )->pOut_to_bin_diffuse_re_dyn[j] == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for pOut_to_bin_diffuse_re" ); - } - memset( ( *hHRTF )->pOut_to_bin_diffuse_re_dyn[j], 0x00, mem_size ); - ( *hHRTF )->pOut_to_bin_diffuse_re[j] = ( *hHRTF )->pOut_to_bin_diffuse_re_dyn[j]; - - pOut_to_bin_wptr = ( *hHRTF )->pOut_to_bin_diffuse_re_dyn[j]; -#else - ( *hHRTF )->pOut_to_bin_diffuse_re[j] = (float *) malloc( mem_size ); - if ( ( *hHRTF )->pOut_to_bin_diffuse_re[j] == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for pOut_to_bin_diffuse_re" ); - } - memset( (uint16_t *) ( *hHRTF )->pOut_to_bin_diffuse_re[j], 0x00, mem_size ); - - pOut_to_bin_wptr = (float *) ( *hHRTF )->pOut_to_bin_diffuse_re[j]; -#endif - - for ( k = 0; k < ( *hHRTF )->num_iterations_diffuse[j]; k++ ) - { -#ifdef FIX_1123_CREND_16BIT_FMT - mem_size = ( *hHRTF )->pIndex_frequency_max_diffuse[j][k] * sizeof( int16_t ); - Word16 *ptW = (Word16 *) hrtf_data_rptr; -#else - mem_size = ( *hHRTF )->pIndex_frequency_max_diffuse[j][k] * sizeof( int32_t ); - Word32 *ptW = (Word32 *) hrtf_data_rptr; -#endif - for ( l = 0; l < ( *hHRTF )->pIndex_frequency_max_diffuse[j][k]; l++ ) - { - pOut_to_bin_wptr[l] = ptW[l] * powf( 2.f, -1.f * factorQ ); - } - hrtf_data_rptr += mem_size; - pOut_to_bin_wptr += ( *hHRTF )->pIndex_frequency_max_diffuse[j][k]; - } - } - - /* coeff_diffuse_im : The size depends on pIndex_frequency_max_diffuse */ - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - mem_size = max_total_num_fsamp_per_iteration_diff * sizeof( float ); -#ifdef FIX_POINT_ROM_CONST - ( *hHRTF )->pOut_to_bin_diffuse_im_dyn[j] = (float *) malloc( mem_size ); - if ( ( *hHRTF )->pOut_to_bin_diffuse_im_dyn[j] == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for pOut_to_bin_diffuse_im" ); - } - memset( ( *hHRTF )->pOut_to_bin_diffuse_im_dyn[j], 0x00, mem_size ); - ( *hHRTF )->pOut_to_bin_diffuse_im[j] = ( *hHRTF )->pOut_to_bin_diffuse_im_dyn[j]; - - pOut_to_bin_wptr = ( *hHRTF )->pOut_to_bin_diffuse_im_dyn[j]; -#else - ( *hHRTF )->pOut_to_bin_diffuse_im[j] = (float *) malloc( mem_size ); - if ( ( *hHRTF )->pOut_to_bin_diffuse_im[j] == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for pOut_to_bin_diffuse_im" ); - } - memset( (uint16_t *) ( *hHRTF )->pOut_to_bin_diffuse_im[j], 0x00, mem_size ); - - pOut_to_bin_wptr = (float *) ( *hHRTF )->pOut_to_bin_diffuse_im[j]; -#endif - for ( k = 0; k < ( *hHRTF )->num_iterations_diffuse[j]; k++ ) - { -#ifdef FIX_1123_CREND_16BIT_FMT - mem_size = ( *hHRTF )->pIndex_frequency_max_diffuse[j][k] * sizeof( int16_t ); - Word16 *ptW = (Word16 *) hrtf_data_rptr; -#else - mem_size = ( *hHRTF )->pIndex_frequency_max_diffuse[j][k] * sizeof( int32_t ); - Word32 *ptW = (Word32 *) hrtf_data_rptr; -#endif - for ( l = 0; l < ( *hHRTF )->pIndex_frequency_max_diffuse[j][k]; l++ ) - { - pOut_to_bin_wptr[l] = ptW[l] * powf( 2.f, -1.f * factorQ ); - } - hrtf_data_rptr += mem_size; - pOut_to_bin_wptr += ( *hHRTF )->pIndex_frequency_max_diffuse[j][k]; - } - } - } - - return IVAS_ERR_OK; -} - - -/*---------------------------------------------------------------------* - * create_fastconv_HRTF_from_rawdata() - * - * Create HRTF from the raw data (to the HRTF FastConv handle) - *---------------------------------------------------------------------*/ - -static ivas_error create_fastconv_HRTF_from_rawdata( - HRTFS_FASTCONV_HANDLE *hHRTF, /* i/o: HRTF FastConv handle */ - char *hrtf_data, /* i : pointer to binary file */ - HRTF_READER_RENDERER_TYPE rend_type, /* i : Renderer type */ - BINAURAL_INPUT_AUDIO_CONFIG input_cfg /* i : Input binaural config */ -) -{ - int16_t i, j, k; - char *hrtf_data_rptr; - ivas_error error; - Word16 factorQ; -#ifdef FIX_1123_FASTCONV_16BIT_FMT - float scaleFactor; - int16_t *ptW16; - float latency_s; - uint16_t ntaps; - uint16_t nbchan; -#else - int32_t *ptW32; -#endif - - if ( hrtf_data == NULL ) - { - return IVAS_ERR_UNEXPECTED_NULL_POINTER; - } - - ( *hHRTF )->allocate_init_flag = 0; - -#ifdef FIX_1123_FASTCONV_16BIT_FMT - hrtf_data_rptr = hrtf_data; - - /* latency_s Q factor*/ - factorQ = *( (Word16 *) ( hrtf_data_rptr ) ); - hrtf_data_rptr += sizeof( Word16 ); - - /* latency_s */ - latency_s = ( *( (Word32 *) ( hrtf_data_rptr ) ) ) * powf( 2.f, -1.f * factorQ ); - hrtf_data_rptr += sizeof( Word32 ); - - if ( BINAURAL_CONVBANDS != *( (uint16_t *) ( hrtf_data_rptr ) ) ) - { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (BINAURAL_CONVBANDS)" ); - } - hrtf_data_rptr += sizeof( uint16_t ); - - nbchan = *( (uint16_t *) ( hrtf_data_rptr ) ); - hrtf_data_rptr += sizeof( uint16_t ); - - ntaps = *( (uint16_t *) ( hrtf_data_rptr ) ); - hrtf_data_rptr += sizeof( uint16_t ); - - if ( rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_COMBINED ) - { - if ( HRTF_LS_CHANNELS != nbchan ) - { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (HRTF_LS_CHANNELS)" ); - } - ( *hHRTF )->ntaps_hrir = ntaps; - ( *hHRTF )->FASTCONV_HRIR_latency_s = latency_s; - } - else if ( rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_HOA3 ) - { - if ( HOA3_CHANNELS != nbchan ) - { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (HOA3_CHANNELS)" ); - } - ( *hHRTF )->ntaps_hrir_hoa3 = ntaps; - ( *hHRTF )->FASTCONV_HOA3_latency_s = latency_s; - } - else if ( rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_HOA2 ) - { - if ( HOA2_CHANNELS != nbchan ) - { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (HOA2_CHANNELS)" ); - } - ( *hHRTF )->ntaps_hrir_hoa2 = ntaps; - ( *hHRTF )->FASTCONV_HOA2_latency_s = latency_s; - } - else if ( rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_FOA ) - { - if ( FOA_CHANNELS != nbchan ) - { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (FOA_CHANNELS)" ); - } - ( *hHRTF )->ntaps_hrir_foa = ntaps; - ( *hHRTF )->FASTCONV_FOA_latency_s = latency_s; - } - else if ( rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV_ROOM && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_COMBINED ) - { - if ( HRTF_LS_CHANNELS != nbchan ) - { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (HRTF_LS_CHANNELS)" ); - } - ( *hHRTF )->ntaps_brir = ntaps; - ( *hHRTF )->FASTCONV_BRIR_latency_s = latency_s; - } - else - { - return IVAS_ERROR( IVAS_ERR_BITSTREAM_READER_INVALID_FORMAT, "Can not read hrtf binary file : wrong render type and input config couple " ); - } -#else - if ( BINAURAL_NTAPS != *( (uint16_t *) ( hrtf_data_rptr ) ) ) - { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (BINAURAL_NTAPS)" ); - } -#endif - - if ( rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV ) - { - if ( ( error = ivas_allocate_binaural_hrtf( *hHRTF, 0, input_cfg, RENDERER_BINAURAL_FASTCONV, ( *hHRTF )->allocate_init_flag ) ) != IVAS_ERR_OK ) - { - return error; - } - } - else if ( rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV_ROOM ) - { - if ( ( error = ivas_allocate_binaural_hrtf( *hHRTF, 0, input_cfg, RENDERER_BINAURAL_FASTCONV_ROOM, ( *hHRTF )->allocate_init_flag ) ) != IVAS_ERR_OK ) - { - return error; - } - } - else - { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "renderer type not compliant" ); - } -#ifndef FIX_1123_FASTCONV_16BIT_FMT - hrtf_data_rptr = hrtf_data; -#endif - /* HRIR */ - if ( rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_COMBINED ) - { -#ifndef FIX_1123_FASTCONV_16BIT_FMT - /* latency_s Q factor*/ - factorQ = *( (Word16 *) ( hrtf_data_rptr ) ); - hrtf_data_rptr += sizeof( Word16 ); - - /* latency_s */ - ( *hHRTF )->FASTCONV_HRIR_latency_s = ( *( (Word32 *) ( hrtf_data_rptr ) ) ) * powf( 2.f, -1.f * factorQ ); - hrtf_data_rptr += sizeof( Word32 ); - - if ( BINAURAL_CONVBANDS != *( (uint16_t *) ( hrtf_data_rptr ) ) ) - { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (BINAURAL_CONVBANDS)" ); - } - hrtf_data_rptr += sizeof( uint16_t ); - - if ( HRTF_LS_CHANNELS != *( (uint16_t *) ( hrtf_data_rptr ) ) ) - { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (HRTF_LS_CHANNELS)" ); - } - hrtf_data_rptr += sizeof( uint16_t ); - - if ( BINAURAL_NTAPS != *( (uint16_t *) ( hrtf_data_rptr ) ) ) - { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (BINAURAL_NTAPS)" ); - } - hrtf_data_rptr += sizeof( uint16_t ); -#endif - - /* HRIR Q factor*/ - factorQ = *( (Word16 *) ( hrtf_data_rptr ) ); - hrtf_data_rptr += sizeof( Word16 ); -#ifdef FIX_1123_FASTCONV_16BIT_FMT - scaleFactor = powf( 2.f, -1.f * factorQ ); -#endif - - for ( i = 0; i < BINAURAL_CONVBANDS; i++ ) - { - for ( j = 0; j < HRTF_LS_CHANNELS; j++ ) - { -#ifdef FIX_1123_FASTCONV_16BIT_FMT - ptW16 = (Word16 *) hrtf_data_rptr; - for ( k = 0; k < ( *hHRTF )->ntaps_hrir; k++ ) -#else - ptW32 = (Word32 *) hrtf_data_rptr; - for ( k = 0; k < BINAURAL_NTAPS; k++ ) -#endif - { -#ifdef FIX_1123_FASTCONV_16BIT_FMT - ( *hHRTF )->leftHRIRReal[i][j][k] = ptW16[k] * scaleFactor; -#else - ( *hHRTF )->leftHRIRReal[i][j][k] = (float) ptW32[k] * powf( 2.f, -1.f * (float) factorQ ); -#endif - } -#ifdef FIX_1123_FASTCONV_16BIT_FMT - hrtf_data_rptr += ( *hHRTF )->ntaps_hrir * sizeof( Word16 ); -#else - hrtf_data_rptr += BINAURAL_NTAPS * sizeof( int32_t ); -#endif - } - } - for ( i = 0; i < BINAURAL_CONVBANDS; i++ ) - { - for ( j = 0; j < HRTF_LS_CHANNELS; j++ ) - { -#ifdef FIX_1123_FASTCONV_16BIT_FMT - ptW16 = (Word16 *) hrtf_data_rptr; - for ( k = 0; k < ( *hHRTF )->ntaps_hrir; k++ ) -#else - ptW32 = (Word32 *) hrtf_data_rptr; - for ( k = 0; k < BINAURAL_NTAPS; k++ ) -#endif - { -#ifdef FIX_1123_FASTCONV_16BIT_FMT - ( *hHRTF )->leftHRIRImag[i][j][k] = ptW16[k] * scaleFactor; -#else - ( *hHRTF )->leftHRIRImag[i][j][k] = (float) ptW32[k] * powf( 2.f, -1.f * (float) factorQ ); -#endif - } -#ifdef FIX_1123_FASTCONV_16BIT_FMT - hrtf_data_rptr += ( *hHRTF )->ntaps_hrir * sizeof( Word16 ); -#else - hrtf_data_rptr += BINAURAL_NTAPS * sizeof( int32_t ); -#endif - } - } - for ( i = 0; i < BINAURAL_CONVBANDS; i++ ) - { - for ( j = 0; j < HRTF_LS_CHANNELS; j++ ) - { -#ifdef FIX_1123_FASTCONV_16BIT_FMT - ptW16 = (Word16 *) hrtf_data_rptr; - for ( k = 0; k < ( *hHRTF )->ntaps_hrir; k++ ) -#else - ptW32 = (Word32 *) hrtf_data_rptr; - for ( k = 0; k < BINAURAL_NTAPS; k++ ) -#endif - { -#ifdef FIX_1123_FASTCONV_16BIT_FMT - ( *hHRTF )->rightHRIRReal[i][j][k] = ptW16[k] * scaleFactor; -#else - ( *hHRTF )->rightHRIRReal[i][j][k] = (float) ptW32[k] * powf( 2.f, -1.f * (float) factorQ ); -#endif - } -#ifdef FIX_1123_FASTCONV_16BIT_FMT - hrtf_data_rptr += ( *hHRTF )->ntaps_hrir * sizeof( Word16 ); -#else - hrtf_data_rptr += BINAURAL_NTAPS * sizeof( int32_t ); -#endif - } - } - for ( i = 0; i < BINAURAL_CONVBANDS; i++ ) - { - for ( j = 0; j < HRTF_LS_CHANNELS; j++ ) - { -#ifdef FIX_1123_FASTCONV_16BIT_FMT - ptW16 = (Word16 *) hrtf_data_rptr; - for ( k = 0; k < ( *hHRTF )->ntaps_hrir; k++ ) -#else - ptW32 = (Word32 *) hrtf_data_rptr; - for ( k = 0; k < BINAURAL_NTAPS; k++ ) -#endif - { -#ifdef FIX_1123_FASTCONV_16BIT_FMT - ( *hHRTF )->rightHRIRImag[i][j][k] = ptW16[k] * scaleFactor; -#else - ( *hHRTF )->rightHRIRImag[i][j][k] = (float) ptW32[k] * powf( 2.f, -1.f * (float) factorQ ); -#endif - } -#ifdef FIX_1123_FASTCONV_16BIT_FMT - hrtf_data_rptr += ( *hHRTF )->ntaps_hrir * sizeof( Word16 ); -#else - hrtf_data_rptr += BINAURAL_NTAPS * sizeof( int32_t ); -#endif - } - } - } - else if ( rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_HOA3 ) - { -#ifndef FIX_1123_FASTCONV_16BIT_FMT - /* latency_s Q factor*/ - factorQ = *( (Word16 *) ( hrtf_data_rptr ) ); - hrtf_data_rptr += sizeof( Word16 ); - - /* latency_s */ - ( *hHRTF )->FASTCONV_HOA3_latency_s = ( *( (Word32 *) ( hrtf_data_rptr ) ) ) * powf( 2.f, -1.f * factorQ ); - hrtf_data_rptr += sizeof( Word32 ); - - if ( BINAURAL_CONVBANDS != *( (uint16_t *) ( hrtf_data_rptr ) ) ) - { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (BINAURAL_CONVBANDS)" ); - } - hrtf_data_rptr += sizeof( uint16_t ); - - if ( HOA3_CHANNELS != *( (uint16_t *) ( hrtf_data_rptr ) ) ) - { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (HOA3_CHANNELS)" ); - } - hrtf_data_rptr += sizeof( uint16_t ); - - if ( BINAURAL_NTAPS_SBA != *( (uint16_t *) ( hrtf_data_rptr ) ) ) - { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (BINAURAL_NTAPS_SBA)" ); - } - hrtf_data_rptr += sizeof( uint16_t ); -#endif - - /* HRIR Q factor*/ - factorQ = *( (Word16 *) ( hrtf_data_rptr ) ); - hrtf_data_rptr += sizeof( Word16 ); -#ifdef FIX_1123_FASTCONV_16BIT_FMT - scaleFactor = powf( 2.f, -1.f * factorQ ); -#endif - - for ( i = 0; i < BINAURAL_CONVBANDS; i++ ) - { - for ( j = 0; j < HOA3_CHANNELS; j++ ) - { -#ifdef FIX_1123_FASTCONV_16BIT_FMT - ptW16 = (Word16 *) hrtf_data_rptr; - for ( k = 0; k < ( *hHRTF )->ntaps_hrir_hoa3; k++ ) -#else - ptW32 = (Word32 *) hrtf_data_rptr; - for ( k = 0; k < BINAURAL_NTAPS_SBA; k++ ) -#endif - { -#ifdef FIX_1123_FASTCONV_16BIT_FMT - ( *hHRTF )->leftHRIRReal_HOA3[i][j][k] = ptW16[k] * scaleFactor; -#else - ( *hHRTF )->leftHRIRReal_HOA3[i][j][k] = (float) ptW32[k] * powf( 2.f, -1.f * (float) factorQ ); -#endif - } -#ifdef FIX_1123_FASTCONV_16BIT_FMT - hrtf_data_rptr += ( *hHRTF )->ntaps_hrir_hoa3 * sizeof( Word16 ); -#else - hrtf_data_rptr += BINAURAL_NTAPS_SBA * sizeof( int32_t ); -#endif - } - } - for ( i = 0; i < BINAURAL_CONVBANDS; i++ ) - { - for ( j = 0; j < HOA3_CHANNELS; j++ ) - { -#ifdef FIX_1123_FASTCONV_16BIT_FMT - ptW16 = (Word16 *) hrtf_data_rptr; - for ( k = 0; k < ( *hHRTF )->ntaps_hrir_hoa3; k++ ) -#else - ptW32 = (Word32 *) hrtf_data_rptr; - for ( k = 0; k < BINAURAL_NTAPS_SBA; k++ ) -#endif - { -#ifdef FIX_1123_FASTCONV_16BIT_FMT - ( *hHRTF )->leftHRIRImag_HOA3[i][j][k] = ptW16[k] * scaleFactor; -#else - ( *hHRTF )->leftHRIRImag_HOA3[i][j][k] = (float) ptW32[k] * powf( 2.f, -1.f * (float) factorQ ); -#endif - } -#ifdef FIX_1123_FASTCONV_16BIT_FMT - hrtf_data_rptr += ( *hHRTF )->ntaps_hrir_hoa3 * sizeof( Word16 ); -#else - hrtf_data_rptr += BINAURAL_NTAPS_SBA * sizeof( int32_t ); -#endif - } - } - for ( i = 0; i < BINAURAL_CONVBANDS; i++ ) - { - for ( j = 0; j < HOA3_CHANNELS; j++ ) - { -#ifdef FIX_1123_FASTCONV_16BIT_FMT - ptW16 = (Word16 *) hrtf_data_rptr; - for ( k = 0; k < ( *hHRTF )->ntaps_hrir_hoa3; k++ ) -#else - ptW32 = (Word32 *) hrtf_data_rptr; - for ( k = 0; k < BINAURAL_NTAPS_SBA; k++ ) -#endif - { -#ifdef FIX_1123_FASTCONV_16BIT_FMT - ( *hHRTF )->rightHRIRReal_HOA3[i][j][k] = ptW16[k] * scaleFactor; -#else - ( *hHRTF )->rightHRIRReal_HOA3[i][j][k] = (float) ptW32[k] * powf( 2.f, -1.f * (float) factorQ ); -#endif - } -#ifdef FIX_1123_FASTCONV_16BIT_FMT - hrtf_data_rptr += ( *hHRTF )->ntaps_hrir_hoa3 * sizeof( Word16 ); -#else - hrtf_data_rptr += BINAURAL_NTAPS_SBA * sizeof( int32_t ); -#endif - } - } - for ( i = 0; i < BINAURAL_CONVBANDS; i++ ) - { - for ( j = 0; j < HOA3_CHANNELS; j++ ) - { -#ifdef FIX_1123_FASTCONV_16BIT_FMT - ptW16 = (Word16 *) hrtf_data_rptr; - for ( k = 0; k < ( *hHRTF )->ntaps_hrir_hoa3; k++ ) -#else - ptW32 = (Word32 *) hrtf_data_rptr; - for ( k = 0; k < BINAURAL_NTAPS_SBA; k++ ) -#endif - { -#ifdef FIX_1123_FASTCONV_16BIT_FMT - ( *hHRTF )->rightHRIRImag_HOA3[i][j][k] = ptW16[k] * scaleFactor; -#else - ( *hHRTF )->rightHRIRImag_HOA3[i][j][k] = (float) ptW32[k] * powf( 2.f, -1.f * (float) factorQ ); -#endif - } -#ifdef FIX_1123_FASTCONV_16BIT_FMT - hrtf_data_rptr += ( *hHRTF )->ntaps_hrir_hoa3 * sizeof( Word16 ); -#else - hrtf_data_rptr += BINAURAL_NTAPS_SBA * sizeof( int32_t ); -#endif - } - } - } - else if ( rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_HOA2 ) - { -#ifndef FIX_1123_FASTCONV_16BIT_FMT - /* latency_s Q factor*/ - factorQ = *( (Word16 *) ( hrtf_data_rptr ) ); - hrtf_data_rptr += sizeof( Word16 ); - - /* latency_s */ - ( *hHRTF )->FASTCONV_HOA2_latency_s = ( *( (Word32 *) ( hrtf_data_rptr ) ) ) * powf( 2.f, -1.f * factorQ ); - hrtf_data_rptr += sizeof( Word32 ); - - if ( BINAURAL_CONVBANDS != *( (uint16_t *) ( hrtf_data_rptr ) ) ) - { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (BINAURAL_CONVBANDS)" ); - } - hrtf_data_rptr += sizeof( uint16_t ); - - if ( HOA2_CHANNELS != *( (uint16_t *) ( hrtf_data_rptr ) ) ) - { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (HOA2_CHANNELS)" ); - } - hrtf_data_rptr += sizeof( uint16_t ); - if ( BINAURAL_NTAPS_SBA != *( (uint16_t *) ( hrtf_data_rptr ) ) ) - { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (BINAURAL_NTAPS_SBA)" ); - } - hrtf_data_rptr += sizeof( uint16_t ); -#endif - - /* HRIR Q factor*/ - factorQ = *( (Word16 *) ( hrtf_data_rptr ) ); - hrtf_data_rptr += sizeof( Word16 ); -#ifdef FIX_1123_FASTCONV_16BIT_FMT - scaleFactor = powf( 2.f, -1.f * factorQ ); -#endif - - for ( i = 0; i < BINAURAL_CONVBANDS; i++ ) - { - for ( j = 0; j < HOA2_CHANNELS; j++ ) - { -#ifdef FIX_1123_FASTCONV_16BIT_FMT - ptW16 = (Word16 *) hrtf_data_rptr; - for ( k = 0; k < ( *hHRTF )->ntaps_hrir_hoa2; k++ ) -#else - ptW32 = (Word32 *) hrtf_data_rptr; - for ( k = 0; k < BINAURAL_NTAPS_SBA; k++ ) -#endif - { -#ifdef FIX_1123_FASTCONV_16BIT_FMT - ( *hHRTF )->leftHRIRReal_HOA2[i][j][k] = ptW16[k] * scaleFactor; -#else - ( *hHRTF )->leftHRIRReal_HOA2[i][j][k] = (float) ptW32[k] * powf( 2.f, -1.f * (float) factorQ ); -#endif - } -#ifdef FIX_1123_FASTCONV_16BIT_FMT - hrtf_data_rptr += ( *hHRTF )->ntaps_hrir_hoa2 * sizeof( Word16 ); -#else - hrtf_data_rptr += BINAURAL_NTAPS_SBA * sizeof( int32_t ); -#endif - } - } - for ( i = 0; i < BINAURAL_CONVBANDS; i++ ) - { - for ( j = 0; j < HOA2_CHANNELS; j++ ) - { -#ifdef FIX_1123_FASTCONV_16BIT_FMT - ptW16 = (Word16 *) hrtf_data_rptr; - for ( k = 0; k < ( *hHRTF )->ntaps_hrir_hoa2; k++ ) -#else - ptW32 = (Word32 *) hrtf_data_rptr; - for ( k = 0; k < BINAURAL_NTAPS_SBA; k++ ) -#endif - { -#ifdef FIX_1123_FASTCONV_16BIT_FMT - ( *hHRTF )->leftHRIRImag_HOA2[i][j][k] = ptW16[k] * scaleFactor; -#else - ( *hHRTF )->leftHRIRImag_HOA2[i][j][k] = (float) ptW32[k] * powf( 2.f, -1.f * (float) factorQ ); -#endif - } -#ifdef FIX_1123_FASTCONV_16BIT_FMT - hrtf_data_rptr += ( *hHRTF )->ntaps_hrir_hoa2 * sizeof( Word16 ); -#else - hrtf_data_rptr += BINAURAL_NTAPS_SBA * sizeof( int32_t ); -#endif - } - } - for ( i = 0; i < BINAURAL_CONVBANDS; i++ ) - { - for ( j = 0; j < HOA2_CHANNELS; j++ ) - { -#ifdef FIX_1123_FASTCONV_16BIT_FMT - ptW16 = (Word16 *) hrtf_data_rptr; - for ( k = 0; k < ( *hHRTF )->ntaps_hrir_hoa2; k++ ) -#else - ptW32 = (Word32 *) hrtf_data_rptr; - for ( k = 0; k < BINAURAL_NTAPS_SBA; k++ ) -#endif - { -#ifdef FIX_1123_FASTCONV_16BIT_FMT - ( *hHRTF )->rightHRIRReal_HOA2[i][j][k] = ptW16[k] * scaleFactor; -#else - ( *hHRTF )->rightHRIRReal_HOA2[i][j][k] = (float) ptW32[k] * powf( 2.f, -1.f * (float) factorQ ); -#endif - } -#ifdef FIX_1123_FASTCONV_16BIT_FMT - hrtf_data_rptr += ( *hHRTF )->ntaps_hrir_hoa2 * sizeof( Word16 ); -#else - hrtf_data_rptr += BINAURAL_NTAPS_SBA * sizeof( int32_t ); -#endif - } - } - for ( i = 0; i < BINAURAL_CONVBANDS; i++ ) - { - for ( j = 0; j < HOA2_CHANNELS; j++ ) - { -#ifdef FIX_1123_FASTCONV_16BIT_FMT - ptW16 = (Word16 *) hrtf_data_rptr; - for ( k = 0; k < ( *hHRTF )->ntaps_hrir_hoa2; k++ ) -#else - ptW32 = (Word32 *) hrtf_data_rptr; - for ( k = 0; k < BINAURAL_NTAPS_SBA; k++ ) -#endif - { -#ifdef FIX_1123_FASTCONV_16BIT_FMT - ( *hHRTF )->rightHRIRImag_HOA2[i][j][k] = ptW16[k] * scaleFactor; -#else - ( *hHRTF )->rightHRIRImag_HOA2[i][j][k] = (float) ptW32[k] * powf( 2.f, -1.f * (float) factorQ ); -#endif - } -#ifdef FIX_1123_FASTCONV_16BIT_FMT - hrtf_data_rptr += ( *hHRTF )->ntaps_hrir_hoa2 * sizeof( Word16 ); -#else - hrtf_data_rptr += BINAURAL_NTAPS_SBA * sizeof( int32_t ); -#endif - } - } - } - else if ( rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_FOA ) - { -#ifndef FIX_1123_FASTCONV_16BIT_FMT - /* latency_s Q factor*/ - factorQ = *( (Word16 *) ( hrtf_data_rptr ) ); - hrtf_data_rptr += sizeof( Word16 ); - - /* latency_s */ - ( *hHRTF )->FASTCONV_FOA_latency_s = ( *( (Word32 *) ( hrtf_data_rptr ) ) ) * powf( 2.f, -1.f * factorQ ); - hrtf_data_rptr += sizeof( Word32 ); - - - if ( BINAURAL_CONVBANDS != *( (uint16_t *) ( hrtf_data_rptr ) ) ) - { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (BINAURAL_CONVBANDS)" ); - } - hrtf_data_rptr += sizeof( uint16_t ); - - if ( FOA_CHANNELS != *( (uint16_t *) ( hrtf_data_rptr ) ) ) - { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (FOA_CHANNELS)" ); - } - hrtf_data_rptr += sizeof( uint16_t ); - - if ( BINAURAL_NTAPS_SBA != *( (uint16_t *) ( hrtf_data_rptr ) ) ) - { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (BINAURAL_NTAPS_SBA)" ); - } - hrtf_data_rptr += sizeof( uint16_t ); -#endif - - /* HRIR Q factor*/ - factorQ = *( (Word16 *) ( hrtf_data_rptr ) ); - hrtf_data_rptr += sizeof( Word16 ); -#ifdef FIX_1123_FASTCONV_16BIT_FMT - scaleFactor = powf( 2.f, -1.f * factorQ ); -#endif - - for ( i = 0; i < BINAURAL_CONVBANDS; i++ ) - { - for ( j = 0; j < FOA_CHANNELS; j++ ) - { -#ifdef FIX_1123_FASTCONV_16BIT_FMT - ptW16 = (Word16 *) hrtf_data_rptr; - for ( k = 0; k < ( *hHRTF )->ntaps_hrir_foa; k++ ) -#else - ptW32 = (Word32 *) hrtf_data_rptr; - for ( k = 0; k < BINAURAL_NTAPS_SBA; k++ ) -#endif - { -#ifdef FIX_1123_FASTCONV_16BIT_FMT - ( *hHRTF )->leftHRIRReal_FOA[i][j][k] = ptW16[k] * scaleFactor; -#else - ( *hHRTF )->leftHRIRReal_FOA[i][j][k] = (float) ptW32[k] * powf( 2.f, -1.f * (float) factorQ ); -#endif - } -#ifdef FIX_1123_FASTCONV_16BIT_FMT - hrtf_data_rptr += ( *hHRTF )->ntaps_hrir_foa * sizeof( Word16 ); -#else - hrtf_data_rptr += BINAURAL_NTAPS_SBA * sizeof( int32_t ); -#endif - } - } - for ( i = 0; i < BINAURAL_CONVBANDS; i++ ) - { - for ( j = 0; j < FOA_CHANNELS; j++ ) - { -#ifdef FIX_1123_FASTCONV_16BIT_FMT - ptW16 = (Word16 *) hrtf_data_rptr; - for ( k = 0; k < ( *hHRTF )->ntaps_hrir_foa; k++ ) -#else - ptW32 = (Word32 *) hrtf_data_rptr; - for ( k = 0; k < BINAURAL_NTAPS_SBA; k++ ) -#endif - { -#ifdef FIX_1123_FASTCONV_16BIT_FMT - ( *hHRTF )->leftHRIRImag_FOA[i][j][k] = ptW16[k] * scaleFactor; -#else - ( *hHRTF )->leftHRIRImag_FOA[i][j][k] = (float) ptW32[k] * powf( 2.f, -1.f * (float) factorQ ); -#endif - } -#ifdef FIX_1123_FASTCONV_16BIT_FMT - hrtf_data_rptr += ( *hHRTF )->ntaps_hrir_foa * sizeof( Word16 ); -#else - hrtf_data_rptr += BINAURAL_NTAPS_SBA * sizeof( int32_t ); -#endif - } - } - for ( i = 0; i < BINAURAL_CONVBANDS; i++ ) - { - for ( j = 0; j < FOA_CHANNELS; j++ ) - { -#ifdef FIX_1123_FASTCONV_16BIT_FMT - ptW16 = (Word16 *) hrtf_data_rptr; - for ( k = 0; k < ( *hHRTF )->ntaps_hrir_foa; k++ ) -#else - ptW32 = (Word32 *) hrtf_data_rptr; - for ( k = 0; k < BINAURAL_NTAPS_SBA; k++ ) -#endif - { -#ifdef FIX_1123_FASTCONV_16BIT_FMT - ( *hHRTF )->rightHRIRReal_FOA[i][j][k] = ptW16[k] * scaleFactor; -#else - ( *hHRTF )->rightHRIRReal_FOA[i][j][k] = (float) ptW32[k] * powf( 2.f, -1.f * (float) factorQ ); -#endif - } -#ifdef FIX_1123_FASTCONV_16BIT_FMT - hrtf_data_rptr += ( *hHRTF )->ntaps_hrir_foa * sizeof( Word16 ); -#else - hrtf_data_rptr += BINAURAL_NTAPS_SBA * sizeof( int32_t ); -#endif - } - } - for ( i = 0; i < BINAURAL_CONVBANDS; i++ ) - { - for ( j = 0; j < FOA_CHANNELS; j++ ) - { -#ifdef FIX_1123_FASTCONV_16BIT_FMT - ptW16 = (Word16 *) hrtf_data_rptr; - for ( k = 0; k < ( *hHRTF )->ntaps_hrir_foa; k++ ) -#else - ptW32 = (Word32 *) hrtf_data_rptr; - for ( k = 0; k < BINAURAL_NTAPS_SBA; k++ ) -#endif - { -#ifdef FIX_1123_FASTCONV_16BIT_FMT - ( *hHRTF )->rightHRIRImag_FOA[i][j][k] = ptW16[k] * scaleFactor; -#else - ( *hHRTF )->rightHRIRImag_FOA[i][j][k] = (float) ptW32[k] * powf( 2.f, -1.f * (float) factorQ ); -#endif - } -#ifdef FIX_1123_FASTCONV_16BIT_FMT - hrtf_data_rptr += ( *hHRTF )->ntaps_hrir_foa * sizeof( Word16 ); -#else - hrtf_data_rptr += BINAURAL_NTAPS_SBA * sizeof( int32_t ); -#endif - } - } - } - /* BRIR */ - else if ( rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV_ROOM && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_COMBINED ) - { -#ifndef FIX_1123_FASTCONV_16BIT_FMT - /* latency_s Q factor*/ - factorQ = *( (Word16 *) ( hrtf_data_rptr ) ); - hrtf_data_rptr += sizeof( Word16 ); - - /* latency_s */ - ( *hHRTF )->FASTCONV_BRIR_latency_s = ( *( (Word32 *) ( hrtf_data_rptr ) ) ) * powf( 2.f, -1.f * factorQ ); - hrtf_data_rptr += sizeof( Word32 ); - - if ( BINAURAL_CONVBANDS != *( (uint16_t *) ( hrtf_data_rptr ) ) ) - { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (BINAURAL_CONVBANDS)" ); - } - hrtf_data_rptr += sizeof( uint16_t ); - - if ( HRTF_LS_CHANNELS != *( (uint16_t *) ( hrtf_data_rptr ) ) ) - { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (HRTF_LS_CHANNELS)" ); - } - hrtf_data_rptr += sizeof( uint16_t ); - - if ( BINAURAL_NTAPS_MAX != *( (uint16_t *) ( hrtf_data_rptr ) ) ) - { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (BINAURAL_NTAPS)" ); - } - hrtf_data_rptr += sizeof( uint16_t ); -#endif - - /* BRIR Q factor*/ - factorQ = *( (Word16 *) ( hrtf_data_rptr ) ); - hrtf_data_rptr += sizeof( Word16 ); -#ifdef FIX_1123_FASTCONV_16BIT_FMT - scaleFactor = powf( 2.f, -1.f * factorQ ); -#endif - - for ( i = 0; i < BINAURAL_CONVBANDS; i++ ) - { - for ( j = 0; j < HRTF_LS_CHANNELS; j++ ) - { -#ifdef FIX_1123_FASTCONV_16BIT_FMT - ptW16 = (Word16 *) hrtf_data_rptr; - for ( k = 0; k < ( *hHRTF )->ntaps_brir; k++ ) -#else - ptW32 = (Word32 *) hrtf_data_rptr; - for ( k = 0; k < BINAURAL_NTAPS_MAX; k++ ) -#endif - { -#ifdef FIX_1123_FASTCONV_16BIT_FMT - ( *hHRTF )->leftBRIRReal[i][j][k] = ptW16[k] * scaleFactor; -#else - ( *hHRTF )->leftBRIRReal[i][j][k] = (float) ptW32[k] * powf( 2.f, -1.f * (float) factorQ ); -#endif - } -#ifdef FIX_1123_FASTCONV_16BIT_FMT - hrtf_data_rptr += ( *hHRTF )->ntaps_brir * sizeof( Word16 ); -#else - hrtf_data_rptr += BINAURAL_NTAPS_MAX * sizeof( int32_t ); -#endif - } - } - for ( i = 0; i < BINAURAL_CONVBANDS; i++ ) - { - for ( j = 0; j < HRTF_LS_CHANNELS; j++ ) - { -#ifdef FIX_1123_FASTCONV_16BIT_FMT - ptW16 = (Word16 *) hrtf_data_rptr; - for ( k = 0; k < ( *hHRTF )->ntaps_brir; k++ ) -#else - ptW32 = (Word32 *) hrtf_data_rptr; - for ( k = 0; k < BINAURAL_NTAPS_MAX; k++ ) -#endif - { -#ifdef FIX_1123_FASTCONV_16BIT_FMT - ( *hHRTF )->leftBRIRImag[i][j][k] = ptW16[k] * scaleFactor; -#else - ( *hHRTF )->leftBRIRImag[i][j][k] = (float) ptW32[k] * powf( 2.f, -1.f * (float) factorQ ); -#endif - } -#ifdef FIX_1123_FASTCONV_16BIT_FMT - hrtf_data_rptr += ( *hHRTF )->ntaps_brir * sizeof( Word16 ); -#else - hrtf_data_rptr += BINAURAL_NTAPS_MAX * sizeof( int32_t ); -#endif - } - } - for ( i = 0; i < BINAURAL_CONVBANDS; i++ ) - { - for ( j = 0; j < HRTF_LS_CHANNELS; j++ ) - { -#ifdef FIX_1123_FASTCONV_16BIT_FMT - ptW16 = (Word16 *) hrtf_data_rptr; - for ( k = 0; k < ( *hHRTF )->ntaps_brir; k++ ) -#else - ptW32 = (Word32 *) hrtf_data_rptr; - for ( k = 0; k < BINAURAL_NTAPS_MAX; k++ ) -#endif - { -#ifdef FIX_1123_FASTCONV_16BIT_FMT - ( *hHRTF )->rightBRIRReal[i][j][k] = ptW16[k] * scaleFactor; -#else - ( *hHRTF )->rightBRIRReal[i][j][k] = (float) ptW32[k] * powf( 2.f, -1.f * (float) factorQ ); -#endif - } -#ifdef FIX_1123_FASTCONV_16BIT_FMT - hrtf_data_rptr += ( *hHRTF )->ntaps_brir * sizeof( Word16 ); -#else - hrtf_data_rptr += BINAURAL_NTAPS_MAX * sizeof( int32_t ); -#endif - } - } - for ( i = 0; i < BINAURAL_CONVBANDS; i++ ) - { - for ( j = 0; j < HRTF_LS_CHANNELS; j++ ) - { -#ifdef FIX_1123_FASTCONV_16BIT_FMT - ptW16 = (Word16 *) hrtf_data_rptr; - for ( k = 0; k < ( *hHRTF )->ntaps_brir; k++ ) -#else - ptW32 = (Word32 *) hrtf_data_rptr; - for ( k = 0; k < BINAURAL_NTAPS_MAX; k++ ) -#endif - { -#ifdef FIX_1123_FASTCONV_16BIT_FMT - ( *hHRTF )->rightBRIRImag[i][j][k] = ptW16[k] * scaleFactor; -#else - ( *hHRTF )->rightBRIRImag[i][j][k] = (float) ptW32[k] * powf( 2.f, -1.f * (float) factorQ ); -#endif - } -#ifdef FIX_1123_FASTCONV_16BIT_FMT - hrtf_data_rptr += ( *hHRTF )->ntaps_brir * sizeof( Word16 ); -#else - hrtf_data_rptr += BINAURAL_NTAPS_MAX * sizeof( int32_t ); -#endif - } - } - - /* Reverb Parameters */ - if ( CLDFB_NO_CHANNELS_MAX != *( (uint16_t *) ( hrtf_data_rptr ) ) ) - { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (CLDFB_NO_CHANNELS_MAX)" ); - } - hrtf_data_rptr += sizeof( uint16_t ); - - /* fastconvReverberationTimes Q factor*/ - factorQ = *( (Word16 *) ( hrtf_data_rptr ) ); - hrtf_data_rptr += sizeof( Word16 ); -#ifdef FIX_1123_FASTCONV_16BIT_FMT - scaleFactor = powf( 2.f, -1.f * factorQ ); -#endif - - ptW16 = (int16_t *) hrtf_data_rptr; - for ( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) - { -#ifdef FIX_1123_FASTCONV_16BIT_FMT - ( *hHRTF )->fastconvReverberationTimes[j] = ptW16[j] * powf( 2.f, -1.f * factorQ ); -#else - ( *hHRTF )->fastconvReverberationTimes[j] = (float) ptW16[j] * scaleFactor; -#endif - } - hrtf_data_rptr += CLDFB_NO_CHANNELS_MAX * sizeof( int16_t ); - - /* fastconvReverberationEneCorrections Q factor */ - factorQ = *( (Word16 *) ( hrtf_data_rptr ) ); - hrtf_data_rptr += sizeof( Word16 ); -#ifdef FIX_1123_FASTCONV_16BIT_FMT - scaleFactor = powf( 2.f, -1.f * factorQ ); -#endif - - ptW16 = (int16_t *) hrtf_data_rptr; - for ( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) - { -#ifdef FIX_1123_FASTCONV_16BIT_FMT - ( *hHRTF )->fastconvReverberationEneCorrections[j] = ptW16[j] * powf( 2.f, -1.f * factorQ ); -#else - ( *hHRTF )->fastconvReverberationEneCorrections[j] = (float) ptW16[j] * scaleFactor; -#endif - } - hrtf_data_rptr += CLDFB_NO_CHANNELS_MAX * sizeof( int16_t ); - } - - return IVAS_ERR_OK; -} - - -/*---------------------------------------------------------------------* - * create_parambin_HRTF_from_rawdata() - * - * - *---------------------------------------------------------------------*/ - -static ivas_error create_parambin_HRTF_from_rawdata( - HRTFS_PARAMBIN_HANDLE *hHRTF, /* i/o: Parametric binauralizer HRTF handle */ - char *hrtf_data /* i : pointer to binary file */ -) -{ - int16_t i, j, k; - char *hrtf_data_rptr; - uint32_t data_size_tmp; - Word16 factorQ; - int16_t *ptW16; - float scaler; - - if ( hrtf_data == NULL ) - { - return IVAS_ERR_UNEXPECTED_NULL_POINTER; - } - - hrtf_data_rptr = hrtf_data; - - /* HRTF_SH_CHANNELS */ - if ( HRTF_SH_CHANNELS != *( (uint16_t *) ( hrtf_data_rptr ) ) ) - { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (HRTF_SH_CHANNELS)" ); - } - hrtf_data_rptr += sizeof( uint16_t ); - - /* HRTF_NUM_BINS */ - if ( HRTF_NUM_BINS != *( (uint16_t *) ( hrtf_data_rptr ) ) ) - { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (HRTF_NUM_BINS)" ); - } - hrtf_data_rptr += sizeof( uint16_t ); - - /* HRTF */ - /* Q factor*/ - factorQ = *( (Word16 *) ( hrtf_data_rptr ) ); - hrtf_data_rptr += sizeof( Word16 ); - scaler = powf( 2.f, -1.f * factorQ ); - - data_size_tmp = HRTF_NUM_BINS * sizeof( int16_t ); - for ( i = 0; i < BINAURAL_CHANNELS; i++ ) - { - for ( j = 0; j < HRTF_SH_CHANNELS; j++ ) - { - ptW16 = (int16_t *) hrtf_data_rptr; - for ( k = 0; k < HRTF_NUM_BINS; k++ ) - { - ( *hHRTF )->hrtfShCoeffsRe[i][j][k] = ptW16[k] * scaler; - } - hrtf_data_rptr += data_size_tmp; - } - } - for ( i = 0; i < BINAURAL_CHANNELS; i++ ) + else if ( rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV_ROOM && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_COMBINED ) { - for ( j = 0; j < HRTF_SH_CHANNELS; j++ ) + if ( HRTF_LS_CHANNELS != nbchan ) { - ptW16 = (int16_t *) hrtf_data_rptr; - for ( k = 0; k < HRTF_NUM_BINS; k++ ) - { - ( *hHRTF )->hrtfShCoeffsIm[i][j][k] = ptW16[k] * scaler; - } - hrtf_data_rptr += data_size_tmp; + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (HRTF_LS_CHANNELS)" ); } + ( *hHRTF )->ntaps_brir = ntaps; + ( *hHRTF )->FASTCONV_BRIR_latency_s = latency_s; } - - /* Reverb Parameters */ - if ( CLDFB_NO_CHANNELS_MAX != *( (uint16_t *) ( hrtf_data_rptr ) ) ) - { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (CLDFB_NO_CHANNELS_MAX)" ); - } - hrtf_data_rptr += sizeof( uint16_t ); - - /* Q factor*/ - factorQ = *( (Word16 *) ( hrtf_data_rptr ) ); - hrtf_data_rptr += sizeof( Word16 ); - scaler = powf( 2.f, -1.f * factorQ ); - - ptW16 = (int16_t *) hrtf_data_rptr; - for ( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) - { - ( *hHRTF )->parametricReverberationTimes[j] = ptW16[j] * scaler; - } - hrtf_data_rptr += CLDFB_NO_CHANNELS_MAX * sizeof( int16_t ); - - /* Q factor*/ - factorQ = *( (Word16 *) ( hrtf_data_rptr ) ); - hrtf_data_rptr += sizeof( Word16 ); - scaler = powf( 2.f, -1.f * factorQ ); - - ptW16 = (int16_t *) hrtf_data_rptr; - for ( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) + else { - ( *hHRTF )->parametricReverberationEneCorrections[j] = ptW16[j] * scaler; + return IVAS_ERROR( IVAS_ERR_BITSTREAM_READER_INVALID_FORMAT, "Can not read hrtf binary file : wrong render type and input config couple " ); } - hrtf_data_rptr += CLDFB_NO_CHANNELS_MAX * sizeof( int16_t ); - - /* Q factor*/ - factorQ = *( (Word16 *) ( hrtf_data_rptr ) ); - hrtf_data_rptr += sizeof( Word16 ); - scaler = powf( 2.f, -1.f * factorQ ); - - ptW16 = (int16_t *) hrtf_data_rptr; - for ( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) +#else + if ( BINAURAL_NTAPS != *( (uint16_t *) ( hrtf_data_rptr ) ) ) { - ( *hHRTF )->parametricEarlyPartEneCorrection[j] = ptW16[j] * scaler; + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (BINAURAL_NTAPS)" ); } - hrtf_data_rptr += CLDFB_NO_CHANNELS_MAX * sizeof( int16_t ); - - return IVAS_ERR_OK; -} - #endif -#ifndef FIX_POINT_HRTF_FILE_FORMAT - -static ivas_error create_fastconv_HRTF_from_rawdata( - HRTFS_FASTCONV_HANDLE *hHRTF, /* i/o: HRTF FastConv handle */ - char *hrtf_data, /* i : pointer to binary file */ - HRTF_READER_RENDERER_TYPE rend_type, /* i : Renderer type */ - BINAURAL_INPUT_AUDIO_CONFIG input_cfg /* i : Input binaural config */ -) -{ - int16_t i, j; - char *hrtf_data_rptr; - ivas_error error; - - ( *hHRTF )->allocate_init_flag = 0; - if ( rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV ) { if ( ( error = ivas_allocate_binaural_hrtf( *hHRTF, 0, input_cfg, RENDERER_BINAURAL_FASTCONV, ( *hHRTF )->allocate_init_flag ) ) != IVAS_ERR_OK ) @@ -2985,14 +1559,20 @@ static ivas_error create_fastconv_HRTF_from_rawdata( { return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "renderer type not compliant" ); } - +#ifndef FIX_1123_FASTCONV_16BIT_FMT hrtf_data_rptr = hrtf_data; - +#endif /* HRIR */ if ( rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_COMBINED ) { - ( *hHRTF )->FASTCONV_HRIR_latency_s = *( (float *) ( hrtf_data_rptr ) ); - hrtf_data_rptr += sizeof( float ); +#ifndef FIX_1123_FASTCONV_16BIT_FMT + /* latency_s Q factor*/ + factorQ = *( (Word16 *) ( hrtf_data_rptr ) ); + hrtf_data_rptr += sizeof( Word16 ); + + /* latency_s */ + ( *hHRTF )->FASTCONV_HRIR_latency_s = ( *( (Word32 *) ( hrtf_data_rptr ) ) ) * powf( 2.f, -1.f * factorQ ); + hrtf_data_rptr += sizeof( Word32 ); if ( BINAURAL_CONVBANDS != *( (uint16_t *) ( hrtf_data_rptr ) ) ) { @@ -3011,46 +1591,126 @@ static ivas_error create_fastconv_HRTF_from_rawdata( return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (BINAURAL_NTAPS)" ); } hrtf_data_rptr += sizeof( uint16_t ); +#endif + /* HRIR Q factor*/ + factorQ = *( (Word16 *) ( hrtf_data_rptr ) ); + hrtf_data_rptr += sizeof( Word16 ); +#ifdef FIX_1123_FASTCONV_16BIT_FMT + scaleFactor = powf( 2.f, -1.f * factorQ ); +#endif for ( i = 0; i < BINAURAL_CONVBANDS; i++ ) { for ( j = 0; j < HRTF_LS_CHANNELS; j++ ) { - memcpy( ( *hHRTF )->leftHRIRReal[i][j], hrtf_data_rptr, BINAURAL_NTAPS * sizeof( float ) ); - hrtf_data_rptr += BINAURAL_NTAPS * sizeof( float ); +#ifdef FIX_1123_FASTCONV_16BIT_FMT + ptW16 = (Word16 *) hrtf_data_rptr; + for ( k = 0; k < ( *hHRTF )->ntaps_hrir; k++ ) +#else + ptW32 = (Word32 *) hrtf_data_rptr; + for ( k = 0; k < BINAURAL_NTAPS; k++ ) +#endif + { +#ifdef FIX_1123_FASTCONV_16BIT_FMT + ( *hHRTF )->leftHRIRReal[i][j][k] = ptW16[k] * scaleFactor; +#else + ( *hHRTF )->leftHRIRReal[i][j][k] = (float) ptW32[k] * powf( 2.f, -1.f * (float) factorQ ); +#endif + } +#ifdef FIX_1123_FASTCONV_16BIT_FMT + hrtf_data_rptr += ( *hHRTF )->ntaps_hrir * sizeof( Word16 ); +#else + hrtf_data_rptr += BINAURAL_NTAPS * sizeof( int32_t ); +#endif } } for ( i = 0; i < BINAURAL_CONVBANDS; i++ ) { for ( j = 0; j < HRTF_LS_CHANNELS; j++ ) { - memcpy( ( *hHRTF )->leftHRIRImag[i][j], hrtf_data_rptr, BINAURAL_NTAPS * sizeof( float ) ); - hrtf_data_rptr += BINAURAL_NTAPS * sizeof( float ); +#ifdef FIX_1123_FASTCONV_16BIT_FMT + ptW16 = (Word16 *) hrtf_data_rptr; + for ( k = 0; k < ( *hHRTF )->ntaps_hrir; k++ ) +#else + ptW32 = (Word32 *) hrtf_data_rptr; + for ( k = 0; k < BINAURAL_NTAPS; k++ ) +#endif + { +#ifdef FIX_1123_FASTCONV_16BIT_FMT + ( *hHRTF )->leftHRIRImag[i][j][k] = ptW16[k] * scaleFactor; +#else + ( *hHRTF )->leftHRIRImag[i][j][k] = (float) ptW32[k] * powf( 2.f, -1.f * (float) factorQ ); +#endif + } +#ifdef FIX_1123_FASTCONV_16BIT_FMT + hrtf_data_rptr += ( *hHRTF )->ntaps_hrir * sizeof( Word16 ); +#else + hrtf_data_rptr += BINAURAL_NTAPS * sizeof( int32_t ); +#endif } } for ( i = 0; i < BINAURAL_CONVBANDS; i++ ) { for ( j = 0; j < HRTF_LS_CHANNELS; j++ ) { - memcpy( ( *hHRTF )->rightHRIRReal[i][j], hrtf_data_rptr, BINAURAL_NTAPS * sizeof( float ) ); - hrtf_data_rptr += BINAURAL_NTAPS * sizeof( float ); +#ifdef FIX_1123_FASTCONV_16BIT_FMT + ptW16 = (Word16 *) hrtf_data_rptr; + for ( k = 0; k < ( *hHRTF )->ntaps_hrir; k++ ) +#else + ptW32 = (Word32 *) hrtf_data_rptr; + for ( k = 0; k < BINAURAL_NTAPS; k++ ) +#endif + { +#ifdef FIX_1123_FASTCONV_16BIT_FMT + ( *hHRTF )->rightHRIRReal[i][j][k] = ptW16[k] * scaleFactor; +#else + ( *hHRTF )->rightHRIRReal[i][j][k] = (float) ptW32[k] * powf( 2.f, -1.f * (float) factorQ ); +#endif + } +#ifdef FIX_1123_FASTCONV_16BIT_FMT + hrtf_data_rptr += ( *hHRTF )->ntaps_hrir * sizeof( Word16 ); +#else + hrtf_data_rptr += BINAURAL_NTAPS * sizeof( int32_t ); +#endif } } for ( i = 0; i < BINAURAL_CONVBANDS; i++ ) { for ( j = 0; j < HRTF_LS_CHANNELS; j++ ) { - memcpy( ( *hHRTF )->rightHRIRImag[i][j], hrtf_data_rptr, BINAURAL_NTAPS * sizeof( float ) ); - hrtf_data_rptr += BINAURAL_NTAPS * sizeof( float ); +#ifdef FIX_1123_FASTCONV_16BIT_FMT + ptW16 = (Word16 *) hrtf_data_rptr; + for ( k = 0; k < ( *hHRTF )->ntaps_hrir; k++ ) +#else + ptW32 = (Word32 *) hrtf_data_rptr; + for ( k = 0; k < BINAURAL_NTAPS; k++ ) +#endif + { +#ifdef FIX_1123_FASTCONV_16BIT_FMT + ( *hHRTF )->rightHRIRImag[i][j][k] = ptW16[k] * scaleFactor; +#else + ( *hHRTF )->rightHRIRImag[i][j][k] = (float) ptW32[k] * powf( 2.f, -1.f * (float) factorQ ); +#endif + } +#ifdef FIX_1123_FASTCONV_16BIT_FMT + hrtf_data_rptr += ( *hHRTF )->ntaps_hrir * sizeof( Word16 ); +#else + hrtf_data_rptr += BINAURAL_NTAPS * sizeof( int32_t ); +#endif } } } else if ( rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_HOA3 ) { - /* HRIR_HOA3 */ - ( *hHRTF )->FASTCONV_HOA3_latency_s = *( (float *) ( hrtf_data_rptr ) ); - hrtf_data_rptr += sizeof( float ); +#ifndef FIX_1123_FASTCONV_16BIT_FMT + /* latency_s Q factor*/ + factorQ = *( (Word16 *) ( hrtf_data_rptr ) ); + hrtf_data_rptr += sizeof( Word16 ); + + /* latency_s */ + ( *hHRTF )->FASTCONV_HOA3_latency_s = ( *( (Word32 *) ( hrtf_data_rptr ) ) ) * powf( 2.f, -1.f * factorQ ); + hrtf_data_rptr += sizeof( Word32 ); if ( BINAURAL_CONVBANDS != *( (uint16_t *) ( hrtf_data_rptr ) ) ) { @@ -3069,46 +1729,264 @@ static ivas_error create_fastconv_HRTF_from_rawdata( return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (BINAURAL_NTAPS_SBA)" ); } hrtf_data_rptr += sizeof( uint16_t ); +#endif + /* HRIR Q factor*/ + factorQ = *( (Word16 *) ( hrtf_data_rptr ) ); + hrtf_data_rptr += sizeof( Word16 ); +#ifdef FIX_1123_FASTCONV_16BIT_FMT + scaleFactor = powf( 2.f, -1.f * factorQ ); +#endif for ( i = 0; i < BINAURAL_CONVBANDS; i++ ) { for ( j = 0; j < HOA3_CHANNELS; j++ ) { - memcpy( ( *hHRTF )->leftHRIRReal_HOA3[i][j], hrtf_data_rptr, BINAURAL_NTAPS_SBA * sizeof( float ) ); - hrtf_data_rptr += BINAURAL_NTAPS_SBA * sizeof( float ); +#ifdef FIX_1123_FASTCONV_16BIT_FMT + ptW16 = (Word16 *) hrtf_data_rptr; + for ( k = 0; k < ( *hHRTF )->ntaps_hrir_hoa3; k++ ) +#else + ptW32 = (Word32 *) hrtf_data_rptr; + for ( k = 0; k < BINAURAL_NTAPS_SBA; k++ ) +#endif + { +#ifdef FIX_1123_FASTCONV_16BIT_FMT + ( *hHRTF )->leftHRIRReal_HOA3[i][j][k] = ptW16[k] * scaleFactor; +#else + ( *hHRTF )->leftHRIRReal_HOA3[i][j][k] = (float) ptW32[k] * powf( 2.f, -1.f * (float) factorQ ); +#endif + } +#ifdef FIX_1123_FASTCONV_16BIT_FMT + hrtf_data_rptr += ( *hHRTF )->ntaps_hrir_hoa3 * sizeof( Word16 ); +#else + hrtf_data_rptr += BINAURAL_NTAPS_SBA * sizeof( int32_t ); +#endif + } + } + for ( i = 0; i < BINAURAL_CONVBANDS; i++ ) + { + for ( j = 0; j < HOA3_CHANNELS; j++ ) + { +#ifdef FIX_1123_FASTCONV_16BIT_FMT + ptW16 = (Word16 *) hrtf_data_rptr; + for ( k = 0; k < ( *hHRTF )->ntaps_hrir_hoa3; k++ ) +#else + ptW32 = (Word32 *) hrtf_data_rptr; + for ( k = 0; k < BINAURAL_NTAPS_SBA; k++ ) +#endif + { +#ifdef FIX_1123_FASTCONV_16BIT_FMT + ( *hHRTF )->leftHRIRImag_HOA3[i][j][k] = ptW16[k] * scaleFactor; +#else + ( *hHRTF )->leftHRIRImag_HOA3[i][j][k] = (float) ptW32[k] * powf( 2.f, -1.f * (float) factorQ ); +#endif + } +#ifdef FIX_1123_FASTCONV_16BIT_FMT + hrtf_data_rptr += ( *hHRTF )->ntaps_hrir_hoa3 * sizeof( Word16 ); +#else + hrtf_data_rptr += BINAURAL_NTAPS_SBA * sizeof( int32_t ); +#endif + } + } + for ( i = 0; i < BINAURAL_CONVBANDS; i++ ) + { + for ( j = 0; j < HOA3_CHANNELS; j++ ) + { +#ifdef FIX_1123_FASTCONV_16BIT_FMT + ptW16 = (Word16 *) hrtf_data_rptr; + for ( k = 0; k < ( *hHRTF )->ntaps_hrir_hoa3; k++ ) +#else + ptW32 = (Word32 *) hrtf_data_rptr; + for ( k = 0; k < BINAURAL_NTAPS_SBA; k++ ) +#endif + { +#ifdef FIX_1123_FASTCONV_16BIT_FMT + ( *hHRTF )->rightHRIRReal_HOA3[i][j][k] = ptW16[k] * scaleFactor; +#else + ( *hHRTF )->rightHRIRReal_HOA3[i][j][k] = (float) ptW32[k] * powf( 2.f, -1.f * (float) factorQ ); +#endif + } +#ifdef FIX_1123_FASTCONV_16BIT_FMT + hrtf_data_rptr += ( *hHRTF )->ntaps_hrir_hoa3 * sizeof( Word16 ); +#else + hrtf_data_rptr += BINAURAL_NTAPS_SBA * sizeof( int32_t ); +#endif } } for ( i = 0; i < BINAURAL_CONVBANDS; i++ ) { for ( j = 0; j < HOA3_CHANNELS; j++ ) { - memcpy( ( *hHRTF )->leftHRIRImag_HOA3[i][j], hrtf_data_rptr, BINAURAL_NTAPS_SBA * sizeof( float ) ); - hrtf_data_rptr += BINAURAL_NTAPS_SBA * sizeof( float ); +#ifdef FIX_1123_FASTCONV_16BIT_FMT + ptW16 = (Word16 *) hrtf_data_rptr; + for ( k = 0; k < ( *hHRTF )->ntaps_hrir_hoa3; k++ ) +#else + ptW32 = (Word32 *) hrtf_data_rptr; + for ( k = 0; k < BINAURAL_NTAPS_SBA; k++ ) +#endif + { +#ifdef FIX_1123_FASTCONV_16BIT_FMT + ( *hHRTF )->rightHRIRImag_HOA3[i][j][k] = ptW16[k] * scaleFactor; +#else + ( *hHRTF )->rightHRIRImag_HOA3[i][j][k] = (float) ptW32[k] * powf( 2.f, -1.f * (float) factorQ ); +#endif + } +#ifdef FIX_1123_FASTCONV_16BIT_FMT + hrtf_data_rptr += ( *hHRTF )->ntaps_hrir_hoa3 * sizeof( Word16 ); +#else + hrtf_data_rptr += BINAURAL_NTAPS_SBA * sizeof( int32_t ); +#endif + } + } + } + else if ( rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_HOA2 ) + { +#ifndef FIX_1123_FASTCONV_16BIT_FMT + /* latency_s Q factor*/ + factorQ = *( (Word16 *) ( hrtf_data_rptr ) ); + hrtf_data_rptr += sizeof( Word16 ); + + /* latency_s */ + ( *hHRTF )->FASTCONV_HOA2_latency_s = ( *( (Word32 *) ( hrtf_data_rptr ) ) ) * powf( 2.f, -1.f * factorQ ); + hrtf_data_rptr += sizeof( Word32 ); + + if ( BINAURAL_CONVBANDS != *( (uint16_t *) ( hrtf_data_rptr ) ) ) + { + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (BINAURAL_CONVBANDS)" ); + } + hrtf_data_rptr += sizeof( uint16_t ); + + if ( HOA2_CHANNELS != *( (uint16_t *) ( hrtf_data_rptr ) ) ) + { + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (HOA2_CHANNELS)" ); + } + hrtf_data_rptr += sizeof( uint16_t ); + if ( BINAURAL_NTAPS_SBA != *( (uint16_t *) ( hrtf_data_rptr ) ) ) + { + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (BINAURAL_NTAPS_SBA)" ); + } + hrtf_data_rptr += sizeof( uint16_t ); +#endif + + /* HRIR Q factor*/ + factorQ = *( (Word16 *) ( hrtf_data_rptr ) ); + hrtf_data_rptr += sizeof( Word16 ); +#ifdef FIX_1123_FASTCONV_16BIT_FMT + scaleFactor = powf( 2.f, -1.f * factorQ ); +#endif + + for ( i = 0; i < BINAURAL_CONVBANDS; i++ ) + { + for ( j = 0; j < HOA2_CHANNELS; j++ ) + { +#ifdef FIX_1123_FASTCONV_16BIT_FMT + ptW16 = (Word16 *) hrtf_data_rptr; + for ( k = 0; k < ( *hHRTF )->ntaps_hrir_hoa2; k++ ) +#else + ptW32 = (Word32 *) hrtf_data_rptr; + for ( k = 0; k < BINAURAL_NTAPS_SBA; k++ ) +#endif + { +#ifdef FIX_1123_FASTCONV_16BIT_FMT + ( *hHRTF )->leftHRIRReal_HOA2[i][j][k] = ptW16[k] * scaleFactor; +#else + ( *hHRTF )->leftHRIRReal_HOA2[i][j][k] = (float) ptW32[k] * powf( 2.f, -1.f * (float) factorQ ); +#endif + } +#ifdef FIX_1123_FASTCONV_16BIT_FMT + hrtf_data_rptr += ( *hHRTF )->ntaps_hrir_hoa2 * sizeof( Word16 ); +#else + hrtf_data_rptr += BINAURAL_NTAPS_SBA * sizeof( int32_t ); +#endif + } + } + for ( i = 0; i < BINAURAL_CONVBANDS; i++ ) + { + for ( j = 0; j < HOA2_CHANNELS; j++ ) + { +#ifdef FIX_1123_FASTCONV_16BIT_FMT + ptW16 = (Word16 *) hrtf_data_rptr; + for ( k = 0; k < ( *hHRTF )->ntaps_hrir_hoa2; k++ ) +#else + ptW32 = (Word32 *) hrtf_data_rptr; + for ( k = 0; k < BINAURAL_NTAPS_SBA; k++ ) +#endif + { +#ifdef FIX_1123_FASTCONV_16BIT_FMT + ( *hHRTF )->leftHRIRImag_HOA2[i][j][k] = ptW16[k] * scaleFactor; +#else + ( *hHRTF )->leftHRIRImag_HOA2[i][j][k] = (float) ptW32[k] * powf( 2.f, -1.f * (float) factorQ ); +#endif + } +#ifdef FIX_1123_FASTCONV_16BIT_FMT + hrtf_data_rptr += ( *hHRTF )->ntaps_hrir_hoa2 * sizeof( Word16 ); +#else + hrtf_data_rptr += BINAURAL_NTAPS_SBA * sizeof( int32_t ); +#endif } } for ( i = 0; i < BINAURAL_CONVBANDS; i++ ) { - for ( j = 0; j < HOA3_CHANNELS; j++ ) + for ( j = 0; j < HOA2_CHANNELS; j++ ) { - memcpy( ( *hHRTF )->rightHRIRReal_HOA3[i][j], hrtf_data_rptr, BINAURAL_NTAPS_SBA * sizeof( float ) ); - hrtf_data_rptr += BINAURAL_NTAPS_SBA * sizeof( float ); +#ifdef FIX_1123_FASTCONV_16BIT_FMT + ptW16 = (Word16 *) hrtf_data_rptr; + for ( k = 0; k < ( *hHRTF )->ntaps_hrir_hoa2; k++ ) +#else + ptW32 = (Word32 *) hrtf_data_rptr; + for ( k = 0; k < BINAURAL_NTAPS_SBA; k++ ) +#endif + { +#ifdef FIX_1123_FASTCONV_16BIT_FMT + ( *hHRTF )->rightHRIRReal_HOA2[i][j][k] = ptW16[k] * scaleFactor; +#else + ( *hHRTF )->rightHRIRReal_HOA2[i][j][k] = (float) ptW32[k] * powf( 2.f, -1.f * (float) factorQ ); +#endif + } +#ifdef FIX_1123_FASTCONV_16BIT_FMT + hrtf_data_rptr += ( *hHRTF )->ntaps_hrir_hoa2 * sizeof( Word16 ); +#else + hrtf_data_rptr += BINAURAL_NTAPS_SBA * sizeof( int32_t ); +#endif } } for ( i = 0; i < BINAURAL_CONVBANDS; i++ ) { - for ( j = 0; j < HOA3_CHANNELS; j++ ) + for ( j = 0; j < HOA2_CHANNELS; j++ ) { - memcpy( ( *hHRTF )->rightHRIRImag_HOA3[i][j], hrtf_data_rptr, BINAURAL_NTAPS_SBA * sizeof( float ) ); - hrtf_data_rptr += BINAURAL_NTAPS_SBA * sizeof( float ); +#ifdef FIX_1123_FASTCONV_16BIT_FMT + ptW16 = (Word16 *) hrtf_data_rptr; + for ( k = 0; k < ( *hHRTF )->ntaps_hrir_hoa2; k++ ) +#else + ptW32 = (Word32 *) hrtf_data_rptr; + for ( k = 0; k < BINAURAL_NTAPS_SBA; k++ ) +#endif + { +#ifdef FIX_1123_FASTCONV_16BIT_FMT + ( *hHRTF )->rightHRIRImag_HOA2[i][j][k] = ptW16[k] * scaleFactor; +#else + ( *hHRTF )->rightHRIRImag_HOA2[i][j][k] = (float) ptW32[k] * powf( 2.f, -1.f * (float) factorQ ); +#endif + } +#ifdef FIX_1123_FASTCONV_16BIT_FMT + hrtf_data_rptr += ( *hHRTF )->ntaps_hrir_hoa2 * sizeof( Word16 ); +#else + hrtf_data_rptr += BINAURAL_NTAPS_SBA * sizeof( int32_t ); +#endif } } } - else if ( rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_HOA2 ) + else if ( rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_FOA ) { - /* HRIR_HOA2 */ - ( *hHRTF )->FASTCONV_HOA2_latency_s = *( (float *) ( hrtf_data_rptr ) ); - hrtf_data_rptr += sizeof( float ); +#ifndef FIX_1123_FASTCONV_16BIT_FMT + /* latency_s Q factor*/ + factorQ = *( (Word16 *) ( hrtf_data_rptr ) ); + hrtf_data_rptr += sizeof( Word16 ); + + /* latency_s */ + ( *hHRTF )->FASTCONV_FOA_latency_s = ( *( (Word32 *) ( hrtf_data_rptr ) ) ) * powf( 2.f, -1.f * factorQ ); + hrtf_data_rptr += sizeof( Word32 ); + if ( BINAURAL_CONVBANDS != *( (uint16_t *) ( hrtf_data_rptr ) ) ) { @@ -3116,9 +1994,9 @@ static ivas_error create_fastconv_HRTF_from_rawdata( } hrtf_data_rptr += sizeof( uint16_t ); - if ( HOA2_CHANNELS != *( (uint16_t *) ( hrtf_data_rptr ) ) ) + if ( FOA_CHANNELS != *( (uint16_t *) ( hrtf_data_rptr ) ) ) { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (HOA2_CHANNELS)" ); + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (FOA_CHANNELS)" ); } hrtf_data_rptr += sizeof( uint16_t ); @@ -3127,46 +2005,127 @@ static ivas_error create_fastconv_HRTF_from_rawdata( return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (BINAURAL_NTAPS_SBA)" ); } hrtf_data_rptr += sizeof( uint16_t ); +#endif + /* HRIR Q factor*/ + factorQ = *( (Word16 *) ( hrtf_data_rptr ) ); + hrtf_data_rptr += sizeof( Word16 ); +#ifdef FIX_1123_FASTCONV_16BIT_FMT + scaleFactor = powf( 2.f, -1.f * factorQ ); +#endif for ( i = 0; i < BINAURAL_CONVBANDS; i++ ) { - for ( j = 0; j < HOA2_CHANNELS; j++ ) + for ( j = 0; j < FOA_CHANNELS; j++ ) { - memcpy( ( *hHRTF )->leftHRIRReal_HOA2[i][j], hrtf_data_rptr, BINAURAL_NTAPS_SBA * sizeof( float ) ); - hrtf_data_rptr += BINAURAL_NTAPS_SBA * sizeof( float ); +#ifdef FIX_1123_FASTCONV_16BIT_FMT + ptW16 = (Word16 *) hrtf_data_rptr; + for ( k = 0; k < ( *hHRTF )->ntaps_hrir_foa; k++ ) +#else + ptW32 = (Word32 *) hrtf_data_rptr; + for ( k = 0; k < BINAURAL_NTAPS_SBA; k++ ) +#endif + { +#ifdef FIX_1123_FASTCONV_16BIT_FMT + ( *hHRTF )->leftHRIRReal_FOA[i][j][k] = ptW16[k] * scaleFactor; +#else + ( *hHRTF )->leftHRIRReal_FOA[i][j][k] = (float) ptW32[k] * powf( 2.f, -1.f * (float) factorQ ); +#endif + } +#ifdef FIX_1123_FASTCONV_16BIT_FMT + hrtf_data_rptr += ( *hHRTF )->ntaps_hrir_foa * sizeof( Word16 ); +#else + hrtf_data_rptr += BINAURAL_NTAPS_SBA * sizeof( int32_t ); +#endif } } for ( i = 0; i < BINAURAL_CONVBANDS; i++ ) { - for ( j = 0; j < HOA2_CHANNELS; j++ ) + for ( j = 0; j < FOA_CHANNELS; j++ ) { - memcpy( ( *hHRTF )->leftHRIRImag_HOA2[i][j], hrtf_data_rptr, BINAURAL_NTAPS_SBA * sizeof( float ) ); - hrtf_data_rptr += BINAURAL_NTAPS_SBA * sizeof( float ); +#ifdef FIX_1123_FASTCONV_16BIT_FMT + ptW16 = (Word16 *) hrtf_data_rptr; + for ( k = 0; k < ( *hHRTF )->ntaps_hrir_foa; k++ ) +#else + ptW32 = (Word32 *) hrtf_data_rptr; + for ( k = 0; k < BINAURAL_NTAPS_SBA; k++ ) +#endif + { +#ifdef FIX_1123_FASTCONV_16BIT_FMT + ( *hHRTF )->leftHRIRImag_FOA[i][j][k] = ptW16[k] * scaleFactor; +#else + ( *hHRTF )->leftHRIRImag_FOA[i][j][k] = (float) ptW32[k] * powf( 2.f, -1.f * (float) factorQ ); +#endif + } +#ifdef FIX_1123_FASTCONV_16BIT_FMT + hrtf_data_rptr += ( *hHRTF )->ntaps_hrir_foa * sizeof( Word16 ); +#else + hrtf_data_rptr += BINAURAL_NTAPS_SBA * sizeof( int32_t ); +#endif } } for ( i = 0; i < BINAURAL_CONVBANDS; i++ ) { - for ( j = 0; j < HOA2_CHANNELS; j++ ) + for ( j = 0; j < FOA_CHANNELS; j++ ) { - memcpy( ( *hHRTF )->rightHRIRReal_HOA2[i][j], hrtf_data_rptr, BINAURAL_NTAPS_SBA * sizeof( float ) ); - hrtf_data_rptr += BINAURAL_NTAPS_SBA * sizeof( float ); +#ifdef FIX_1123_FASTCONV_16BIT_FMT + ptW16 = (Word16 *) hrtf_data_rptr; + for ( k = 0; k < ( *hHRTF )->ntaps_hrir_foa; k++ ) +#else + ptW32 = (Word32 *) hrtf_data_rptr; + for ( k = 0; k < BINAURAL_NTAPS_SBA; k++ ) +#endif + { +#ifdef FIX_1123_FASTCONV_16BIT_FMT + ( *hHRTF )->rightHRIRReal_FOA[i][j][k] = ptW16[k] * scaleFactor; +#else + ( *hHRTF )->rightHRIRReal_FOA[i][j][k] = (float) ptW32[k] * powf( 2.f, -1.f * (float) factorQ ); +#endif + } +#ifdef FIX_1123_FASTCONV_16BIT_FMT + hrtf_data_rptr += ( *hHRTF )->ntaps_hrir_foa * sizeof( Word16 ); +#else + hrtf_data_rptr += BINAURAL_NTAPS_SBA * sizeof( int32_t ); +#endif } } for ( i = 0; i < BINAURAL_CONVBANDS; i++ ) { - for ( j = 0; j < HOA2_CHANNELS; j++ ) + for ( j = 0; j < FOA_CHANNELS; j++ ) { - memcpy( ( *hHRTF )->rightHRIRImag_HOA2[i][j], hrtf_data_rptr, BINAURAL_NTAPS_SBA * sizeof( float ) ); - hrtf_data_rptr += BINAURAL_NTAPS_SBA * sizeof( float ); +#ifdef FIX_1123_FASTCONV_16BIT_FMT + ptW16 = (Word16 *) hrtf_data_rptr; + for ( k = 0; k < ( *hHRTF )->ntaps_hrir_foa; k++ ) +#else + ptW32 = (Word32 *) hrtf_data_rptr; + for ( k = 0; k < BINAURAL_NTAPS_SBA; k++ ) +#endif + { +#ifdef FIX_1123_FASTCONV_16BIT_FMT + ( *hHRTF )->rightHRIRImag_FOA[i][j][k] = ptW16[k] * scaleFactor; +#else + ( *hHRTF )->rightHRIRImag_FOA[i][j][k] = (float) ptW32[k] * powf( 2.f, -1.f * (float) factorQ ); +#endif + } +#ifdef FIX_1123_FASTCONV_16BIT_FMT + hrtf_data_rptr += ( *hHRTF )->ntaps_hrir_foa * sizeof( Word16 ); +#else + hrtf_data_rptr += BINAURAL_NTAPS_SBA * sizeof( int32_t ); +#endif } } } - else if ( rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_FOA ) + /* BRIR */ + else if ( rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV_ROOM && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_COMBINED ) { - /* HRIR_FOA */ - ( *hHRTF )->FASTCONV_FOA_latency_s = *( (float *) ( hrtf_data_rptr ) ); - hrtf_data_rptr += sizeof( float ); +#ifndef FIX_1123_FASTCONV_16BIT_FMT + /* latency_s Q factor*/ + factorQ = *( (Word16 *) ( hrtf_data_rptr ) ); + hrtf_data_rptr += sizeof( Word16 ); + + /* latency_s */ + ( *hHRTF )->FASTCONV_BRIR_latency_s = ( *( (Word32 *) ( hrtf_data_rptr ) ) ) * powf( 2.f, -1.f * factorQ ); + hrtf_data_rptr += sizeof( Word32 ); if ( BINAURAL_CONVBANDS != *( (uint16_t *) ( hrtf_data_rptr ) ) ) { @@ -3174,128 +2133,293 @@ static ivas_error create_fastconv_HRTF_from_rawdata( } hrtf_data_rptr += sizeof( uint16_t ); - if ( FOA_CHANNELS != *( (uint16_t *) ( hrtf_data_rptr ) ) ) + if ( HRTF_LS_CHANNELS != *( (uint16_t *) ( hrtf_data_rptr ) ) ) { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (FOA_CHANNELS)" ); + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (HRTF_LS_CHANNELS)" ); } hrtf_data_rptr += sizeof( uint16_t ); - if ( BINAURAL_NTAPS_SBA != *( (uint16_t *) ( hrtf_data_rptr ) ) ) + if ( BINAURAL_NTAPS_MAX != *( (uint16_t *) ( hrtf_data_rptr ) ) ) { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (BINAURAL_NTAPS_SBA)" ); + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (BINAURAL_NTAPS)" ); } hrtf_data_rptr += sizeof( uint16_t ); +#endif + /* BRIR Q factor*/ + factorQ = *( (Word16 *) ( hrtf_data_rptr ) ); + hrtf_data_rptr += sizeof( Word16 ); +#ifdef FIX_1123_FASTCONV_16BIT_FMT + scaleFactor = powf( 2.f, -1.f * factorQ ); +#endif for ( i = 0; i < BINAURAL_CONVBANDS; i++ ) { - for ( j = 0; j < FOA_CHANNELS; j++ ) + for ( j = 0; j < HRTF_LS_CHANNELS; j++ ) { - memcpy( ( *hHRTF )->leftHRIRReal_FOA[i][j], hrtf_data_rptr, BINAURAL_NTAPS_SBA * sizeof( float ) ); - hrtf_data_rptr += BINAURAL_NTAPS_SBA * sizeof( float ); +#ifdef FIX_1123_FASTCONV_16BIT_FMT + ptW16 = (Word16 *) hrtf_data_rptr; + for ( k = 0; k < ( *hHRTF )->ntaps_brir; k++ ) +#else + ptW32 = (Word32 *) hrtf_data_rptr; + for ( k = 0; k < BINAURAL_NTAPS_MAX; k++ ) +#endif + { +#ifdef FIX_1123_FASTCONV_16BIT_FMT + ( *hHRTF )->leftBRIRReal[i][j][k] = ptW16[k] * scaleFactor; +#else + ( *hHRTF )->leftBRIRReal[i][j][k] = (float) ptW32[k] * powf( 2.f, -1.f * (float) factorQ ); +#endif + } +#ifdef FIX_1123_FASTCONV_16BIT_FMT + hrtf_data_rptr += ( *hHRTF )->ntaps_brir * sizeof( Word16 ); +#else + hrtf_data_rptr += BINAURAL_NTAPS_MAX * sizeof( int32_t ); +#endif } } for ( i = 0; i < BINAURAL_CONVBANDS; i++ ) { - for ( j = 0; j < FOA_CHANNELS; j++ ) + for ( j = 0; j < HRTF_LS_CHANNELS; j++ ) { - memcpy( ( *hHRTF )->leftHRIRImag_FOA[i][j], hrtf_data_rptr, BINAURAL_NTAPS_SBA * sizeof( float ) ); - hrtf_data_rptr += BINAURAL_NTAPS_SBA * sizeof( float ); +#ifdef FIX_1123_FASTCONV_16BIT_FMT + ptW16 = (Word16 *) hrtf_data_rptr; + for ( k = 0; k < ( *hHRTF )->ntaps_brir; k++ ) +#else + ptW32 = (Word32 *) hrtf_data_rptr; + for ( k = 0; k < BINAURAL_NTAPS_MAX; k++ ) +#endif + { +#ifdef FIX_1123_FASTCONV_16BIT_FMT + ( *hHRTF )->leftBRIRImag[i][j][k] = ptW16[k] * scaleFactor; +#else + ( *hHRTF )->leftBRIRImag[i][j][k] = (float) ptW32[k] * powf( 2.f, -1.f * (float) factorQ ); +#endif + } +#ifdef FIX_1123_FASTCONV_16BIT_FMT + hrtf_data_rptr += ( *hHRTF )->ntaps_brir * sizeof( Word16 ); +#else + hrtf_data_rptr += BINAURAL_NTAPS_MAX * sizeof( int32_t ); +#endif } } for ( i = 0; i < BINAURAL_CONVBANDS; i++ ) { - for ( j = 0; j < FOA_CHANNELS; j++ ) + for ( j = 0; j < HRTF_LS_CHANNELS; j++ ) { - memcpy( ( *hHRTF )->rightHRIRReal_FOA[i][j], hrtf_data_rptr, BINAURAL_NTAPS_SBA * sizeof( float ) ); - hrtf_data_rptr += BINAURAL_NTAPS_SBA * sizeof( float ); +#ifdef FIX_1123_FASTCONV_16BIT_FMT + ptW16 = (Word16 *) hrtf_data_rptr; + for ( k = 0; k < ( *hHRTF )->ntaps_brir; k++ ) +#else + ptW32 = (Word32 *) hrtf_data_rptr; + for ( k = 0; k < BINAURAL_NTAPS_MAX; k++ ) +#endif + { +#ifdef FIX_1123_FASTCONV_16BIT_FMT + ( *hHRTF )->rightBRIRReal[i][j][k] = ptW16[k] * scaleFactor; +#else + ( *hHRTF )->rightBRIRReal[i][j][k] = (float) ptW32[k] * powf( 2.f, -1.f * (float) factorQ ); +#endif + } +#ifdef FIX_1123_FASTCONV_16BIT_FMT + hrtf_data_rptr += ( *hHRTF )->ntaps_brir * sizeof( Word16 ); +#else + hrtf_data_rptr += BINAURAL_NTAPS_MAX * sizeof( int32_t ); +#endif } } for ( i = 0; i < BINAURAL_CONVBANDS; i++ ) { - for ( j = 0; j < FOA_CHANNELS; j++ ) + for ( j = 0; j < HRTF_LS_CHANNELS; j++ ) { - memcpy( ( *hHRTF )->rightHRIRImag_FOA[i][j], hrtf_data_rptr, BINAURAL_NTAPS_SBA * sizeof( float ) ); - hrtf_data_rptr += BINAURAL_NTAPS_SBA * sizeof( float ); +#ifdef FIX_1123_FASTCONV_16BIT_FMT + ptW16 = (Word16 *) hrtf_data_rptr; + for ( k = 0; k < ( *hHRTF )->ntaps_brir; k++ ) +#else + ptW32 = (Word32 *) hrtf_data_rptr; + for ( k = 0; k < BINAURAL_NTAPS_MAX; k++ ) +#endif + { +#ifdef FIX_1123_FASTCONV_16BIT_FMT + ( *hHRTF )->rightBRIRImag[i][j][k] = ptW16[k] * scaleFactor; +#else + ( *hHRTF )->rightBRIRImag[i][j][k] = (float) ptW32[k] * powf( 2.f, -1.f * (float) factorQ ); +#endif + } +#ifdef FIX_1123_FASTCONV_16BIT_FMT + hrtf_data_rptr += ( *hHRTF )->ntaps_brir * sizeof( Word16 ); +#else + hrtf_data_rptr += BINAURAL_NTAPS_MAX * sizeof( int32_t ); +#endif } } - } - /* BRIR */ - else if ( rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV_ROOM && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_COMBINED ) - { - ( *hHRTF )->FASTCONV_BRIR_latency_s = *( (float *) ( hrtf_data_rptr ) ); - hrtf_data_rptr += sizeof( float ); - if ( BINAURAL_CONVBANDS != *( (uint16_t *) ( hrtf_data_rptr ) ) ) + /* Reverb Parameters */ + if ( CLDFB_NO_CHANNELS_MAX != *( (uint16_t *) ( hrtf_data_rptr ) ) ) { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (BINAURAL_CONVBANDS)" ); + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (CLDFB_NO_CHANNELS_MAX)" ); } hrtf_data_rptr += sizeof( uint16_t ); - if ( HRTF_LS_CHANNELS != *( (uint16_t *) ( hrtf_data_rptr ) ) ) - { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (HRTF_LS_CHANNELS)" ); - } - hrtf_data_rptr += sizeof( uint16_t ); + /* fastconvReverberationTimes Q factor*/ + factorQ = *( (Word16 *) ( hrtf_data_rptr ) ); + hrtf_data_rptr += sizeof( Word16 ); +#ifdef FIX_1123_FASTCONV_16BIT_FMT + scaleFactor = powf( 2.f, -1.f * factorQ ); +#endif - if ( BINAURAL_NTAPS_MAX != *( (uint16_t *) ( hrtf_data_rptr ) ) ) + ptW16 = (int16_t *) hrtf_data_rptr; + for ( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (BINAURAL_NTAPS)" ); +#ifdef FIX_1123_FASTCONV_16BIT_FMT + ( *hHRTF )->fastconvReverberationTimes[j] = ptW16[j] * powf( 2.f, -1.f * factorQ ); +#else + ( *hHRTF )->fastconvReverberationTimes[j] = (float) ptW16[j] * scaleFactor; +#endif } - hrtf_data_rptr += sizeof( uint16_t ); + hrtf_data_rptr += CLDFB_NO_CHANNELS_MAX * sizeof( int16_t ); + /* fastconvReverberationEneCorrections Q factor */ + factorQ = *( (Word16 *) ( hrtf_data_rptr ) ); + hrtf_data_rptr += sizeof( Word16 ); +#ifdef FIX_1123_FASTCONV_16BIT_FMT + scaleFactor = powf( 2.f, -1.f * factorQ ); +#endif - for ( i = 0; i < BINAURAL_CONVBANDS; i++ ) - { - for ( j = 0; j < HRTF_LS_CHANNELS; j++ ) - { - memcpy( ( *hHRTF )->leftBRIRReal[i][j], hrtf_data_rptr, BINAURAL_NTAPS_MAX * sizeof( float ) ); - hrtf_data_rptr += BINAURAL_NTAPS_MAX * sizeof( float ); - } - } - for ( i = 0; i < BINAURAL_CONVBANDS; i++ ) + ptW16 = (int16_t *) hrtf_data_rptr; + for ( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) { - for ( j = 0; j < HRTF_LS_CHANNELS; j++ ) - { - memcpy( ( *hHRTF )->leftBRIRImag[i][j], hrtf_data_rptr, BINAURAL_NTAPS_MAX * sizeof( float ) ); - hrtf_data_rptr += BINAURAL_NTAPS_MAX * sizeof( float ); - } +#ifdef FIX_1123_FASTCONV_16BIT_FMT + ( *hHRTF )->fastconvReverberationEneCorrections[j] = ptW16[j] * powf( 2.f, -1.f * factorQ ); +#else + ( *hHRTF )->fastconvReverberationEneCorrections[j] = (float) ptW16[j] * scaleFactor; +#endif } - for ( i = 0; i < BINAURAL_CONVBANDS; i++ ) + hrtf_data_rptr += CLDFB_NO_CHANNELS_MAX * sizeof( int16_t ); + } + + return IVAS_ERR_OK; +} + + +/*---------------------------------------------------------------------* + * create_parambin_HRTF_from_rawdata() + * + * + *---------------------------------------------------------------------*/ + +static ivas_error create_parambin_HRTF_from_rawdata( + HRTFS_PARAMBIN_HANDLE *hHRTF, /* i/o: Parametric binauralizer HRTF handle */ + char *hrtf_data /* i : pointer to binary file */ +) +{ + int16_t i, j, k; + char *hrtf_data_rptr; + uint32_t data_size_tmp; + Word16 factorQ; + int16_t *ptW16; + float scaler; + + if ( hrtf_data == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + hrtf_data_rptr = hrtf_data; + + /* HRTF_SH_CHANNELS */ + if ( HRTF_SH_CHANNELS != *( (uint16_t *) ( hrtf_data_rptr ) ) ) + { + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (HRTF_SH_CHANNELS)" ); + } + hrtf_data_rptr += sizeof( uint16_t ); + + /* HRTF_NUM_BINS */ + if ( HRTF_NUM_BINS != *( (uint16_t *) ( hrtf_data_rptr ) ) ) + { + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (HRTF_NUM_BINS)" ); + } + hrtf_data_rptr += sizeof( uint16_t ); + + /* HRTF */ + /* Q factor*/ + factorQ = *( (Word16 *) ( hrtf_data_rptr ) ); + hrtf_data_rptr += sizeof( Word16 ); + scaler = powf( 2.f, -1.f * factorQ ); + + data_size_tmp = HRTF_NUM_BINS * sizeof( int16_t ); + for ( i = 0; i < BINAURAL_CHANNELS; i++ ) + { + for ( j = 0; j < HRTF_SH_CHANNELS; j++ ) { - for ( j = 0; j < HRTF_LS_CHANNELS; j++ ) + ptW16 = (int16_t *) hrtf_data_rptr; + for ( k = 0; k < HRTF_NUM_BINS; k++ ) { - memcpy( ( *hHRTF )->rightBRIRReal[i][j], hrtf_data_rptr, BINAURAL_NTAPS_MAX * sizeof( float ) ); - hrtf_data_rptr += BINAURAL_NTAPS_MAX * sizeof( float ); + ( *hHRTF )->hrtfShCoeffsRe[i][j][k] = ptW16[k] * scaler; } + hrtf_data_rptr += data_size_tmp; } - for ( i = 0; i < BINAURAL_CONVBANDS; i++ ) + } + for ( i = 0; i < BINAURAL_CHANNELS; i++ ) + { + for ( j = 0; j < HRTF_SH_CHANNELS; j++ ) { - for ( j = 0; j < HRTF_LS_CHANNELS; j++ ) + ptW16 = (int16_t *) hrtf_data_rptr; + for ( k = 0; k < HRTF_NUM_BINS; k++ ) { - memcpy( ( *hHRTF )->rightBRIRImag[i][j], hrtf_data_rptr, BINAURAL_NTAPS_MAX * sizeof( float ) ); - hrtf_data_rptr += BINAURAL_NTAPS_MAX * sizeof( float ); + ( *hHRTF )->hrtfShCoeffsIm[i][j][k] = ptW16[k] * scaler; } + hrtf_data_rptr += data_size_tmp; } + } - /* Reverb Parameters */ - if ( CLDFB_NO_CHANNELS_MAX != *( (uint16_t *) ( hrtf_data_rptr ) ) ) - { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (CLDFB_NO_CHANNELS_MAX)" ); - } - hrtf_data_rptr += sizeof( uint16_t ); + /* Reverb Parameters */ + if ( CLDFB_NO_CHANNELS_MAX != *( (uint16_t *) ( hrtf_data_rptr ) ) ) + { + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (CLDFB_NO_CHANNELS_MAX)" ); + } + hrtf_data_rptr += sizeof( uint16_t ); + + /* Q factor*/ + factorQ = *( (Word16 *) ( hrtf_data_rptr ) ); + hrtf_data_rptr += sizeof( Word16 ); + scaler = powf( 2.f, -1.f * factorQ ); + + ptW16 = (int16_t *) hrtf_data_rptr; + for ( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) + { + ( *hHRTF )->parametricReverberationTimes[j] = ptW16[j] * scaler; + } + hrtf_data_rptr += CLDFB_NO_CHANNELS_MAX * sizeof( int16_t ); + + /* Q factor*/ + factorQ = *( (Word16 *) ( hrtf_data_rptr ) ); + hrtf_data_rptr += sizeof( Word16 ); + scaler = powf( 2.f, -1.f * factorQ ); + + ptW16 = (int16_t *) hrtf_data_rptr; + for ( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) + { + ( *hHRTF )->parametricReverberationEneCorrections[j] = ptW16[j] * scaler; + } + hrtf_data_rptr += CLDFB_NO_CHANNELS_MAX * sizeof( int16_t ); - memcpy( ( *hHRTF )->fastconvReverberationTimes, hrtf_data_rptr, CLDFB_NO_CHANNELS_MAX * sizeof( float ) ); - hrtf_data_rptr += CLDFB_NO_CHANNELS_MAX * sizeof( float ); + /* Q factor*/ + factorQ = *( (Word16 *) ( hrtf_data_rptr ) ); + hrtf_data_rptr += sizeof( Word16 ); + scaler = powf( 2.f, -1.f * factorQ ); - memcpy( ( *hHRTF )->fastconvReverberationEneCorrections, hrtf_data_rptr, CLDFB_NO_CHANNELS_MAX * sizeof( float ) ); - hrtf_data_rptr += CLDFB_NO_CHANNELS_MAX * sizeof( float ); + ptW16 = (int16_t *) hrtf_data_rptr; + for ( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) + { + ( *hHRTF )->parametricEarlyPartEneCorrection[j] = ptW16[j] * scaler; } + hrtf_data_rptr += CLDFB_NO_CHANNELS_MAX * sizeof( int16_t ); return IVAS_ERR_OK; } -#endif + /*---------------------------------------------------------------------* * load_fastconv_HRTF_from_binary() @@ -3385,77 +2509,6 @@ ivas_error load_fastconv_HRTF_from_binary( } } -#ifndef FIX_POINT_HRTF_FILE_FORMAT - -/*---------------------------------------------------------------------* - * create_parambin_HRTF_from_rawdata() - * - * - *---------------------------------------------------------------------*/ - -static ivas_error create_parambin_HRTF_from_rawdata( - HRTFS_PARAMBIN_HANDLE *hHRTF, /* i/o: Parametric binauralizer HRTF handle */ - char *hrtf_data /* i : pointer to binary file */ -) -{ - int16_t i, j; - char *hrtf_data_rptr; - uint32_t data_size_tmp; - - hrtf_data_rptr = hrtf_data; - - /* HRTF_SH_CHANNELS */ - if ( HRTF_SH_CHANNELS != *( (uint16_t *) ( hrtf_data_rptr ) ) ) - { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (HRTF_SH_CHANNELS)" ); - } - hrtf_data_rptr += sizeof( uint16_t ); - - /* HRTF_NUM_BINS */ - if ( HRTF_NUM_BINS != *( (uint16_t *) ( hrtf_data_rptr ) ) ) - { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (HRTF_NUM_BINS)" ); - } - hrtf_data_rptr += sizeof( uint16_t ); - - /* HRTF */ - data_size_tmp = HRTF_NUM_BINS * sizeof( float ); - for ( i = 0; i < BINAURAL_CHANNELS; i++ ) - { - for ( j = 0; j < HRTF_SH_CHANNELS; j++ ) - { - memcpy( ( *hHRTF )->hrtfShCoeffsRe[i][j], hrtf_data_rptr, data_size_tmp ); - hrtf_data_rptr += data_size_tmp; - } - } - for ( i = 0; i < BINAURAL_CHANNELS; i++ ) - { - for ( j = 0; j < HRTF_SH_CHANNELS; j++ ) - { - memcpy( ( *hHRTF )->hrtfShCoeffsIm[i][j], hrtf_data_rptr, data_size_tmp ); - hrtf_data_rptr += data_size_tmp; - } - } - - /* Reverb Parameters */ - if ( CLDFB_NO_CHANNELS_MAX != *( (uint16_t *) ( hrtf_data_rptr ) ) ) - { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (CLDFB_NO_CHANNELS_MAX)" ); - } - hrtf_data_rptr += sizeof( uint16_t ); - - memcpy( ( *hHRTF )->parametricReverberationTimes, hrtf_data_rptr, CLDFB_NO_CHANNELS_MAX * sizeof( float ) ); - hrtf_data_rptr += CLDFB_NO_CHANNELS_MAX * sizeof( float ); - - memcpy( ( *hHRTF )->parametricReverberationEneCorrections, hrtf_data_rptr, CLDFB_NO_CHANNELS_MAX * sizeof( float ) ); - hrtf_data_rptr += CLDFB_NO_CHANNELS_MAX * sizeof( float ); - - memcpy( ( *hHRTF )->parametricEarlyPartEneCorrection, hrtf_data_rptr, CLDFB_NO_CHANNELS_MAX * sizeof( float ) ); - hrtf_data_rptr += CLDFB_NO_CHANNELS_MAX * sizeof( float ); - - return IVAS_ERR_OK; -} -#endif /*---------------------------------------------------------------------* * load_parambin_HRTF_from_binary() @@ -3514,11 +2567,7 @@ ivas_error load_parambin_HRTF_from_binary( free( hrtf_data ); return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "HRTF binary file not compliant (number of HRTF)" ); } -#ifdef FIX_POINT_HRTF_FILE_FORMAT if ( hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_PARAMETRIC ) /* Parametric binauralizer data is represented as single entity */ -#else - if ( hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_PARAMETRIC_ROOM ) /* Parametric binauralizer data is represented as single entity */ -#endif { if ( fread( hrtf_data, 1, hrtf_header.data_size, f_hrtf ) != hrtf_header.data_size ) { diff --git a/lib_util/hrtf_file_reader.h b/lib_util/hrtf_file_reader.h index 81af54479c..dbb38c3d88 100644 --- a/lib_util/hrtf_file_reader.h +++ b/lib_util/hrtf_file_reader.h @@ -43,9 +43,6 @@ typedef enum HRTF_READER_RENDERER_BINAURAL_FASTCONV, HRTF_READER_RENDERER_BINAURAL_FASTCONV_ROOM, HRTF_READER_RENDERER_BINAURAL_PARAMETRIC, -#ifndef FIX_POINT_HRTF_FILE_FORMAT - HRTF_READER_RENDERER_BINAURAL_PARAMETRIC_ROOM, -#endif HRTF_READER_RENDERER_BINAURAL_OBJECTS_TD, HRTF_READER_RENDERER_BINAURAL_MIXER_CONV, HRTF_READER_RENDERER_BINAURAL_MIXER_CONV_ROOM, diff --git a/scripts/binauralRenderer_interface/Table_Format_Converter/generate_tables_from_rom_to_bin.c b/scripts/binauralRenderer_interface/Table_Format_Converter/generate_tables_from_rom_to_bin.c index ba17e8545a..e16d826749 100644 --- a/scripts/binauralRenderer_interface/Table_Format_Converter/generate_tables_from_rom_to_bin.c +++ b/scripts/binauralRenderer_interface/Table_Format_Converter/generate_tables_from_rom_to_bin.c @@ -40,9 +40,7 @@ #include "ivas_stat_dec.h" #include "hrtf_file_reader.h" #include "ivas_rom_rend.h" -#ifdef FIX_POINT_HRTF_FILE_FORMAT #include -#endif #define FILE_HEADER @@ -98,13 +96,8 @@ typedef struct _crend_hrtf_tables_dimensions int16_t max_num_ir; int16_t max_num_iterations; int16_t max_num_iterations_diffuse; -#ifdef FIX_POINT_HRTF_FILE_FORMAT uint32_t max_total_num_fsamp_per_iteration; uint32_t max_total_num_fsamp_per_iteration_diff; -#else - uint16_t max_total_num_fsamp_per_iteration; - uint16_t max_total_num_fsamp_per_iteration_diff; -#endif } crend_hrtf_tables_dimensions; @@ -1213,18 +1206,6 @@ char *create_hrtf_parametric( int32_t *hrtf_size ) uint32_t hrtf_data_size; FILE *input_param_bin_file = NULL; -#ifndef FIX_POINT_HRTF_FILE_FORMAT - int16_t i, j; - uint32_t data_size_tmp; - uint8_t file_read_ok; - - float hrtfShCoeffsReFile[BINAURAL_CHANNELS][HRTF_SH_CHANNELS][HRTF_NUM_BINS]; - float hrtfShCoeffsImFile[BINAURAL_CHANNELS][HRTF_SH_CHANNELS][HRTF_NUM_BINS]; - - float parametricReverberationTimesFile[CLDFB_NO_CHANNELS_MAX]; - float parametricReverberationEneCorrectionsFile[CLDFB_NO_CHANNELS_MAX]; - float parametricEarlyPartEneCorrectionFile[CLDFB_NO_CHANNELS_MAX]; -#endif full_in_param_bin_path = (char *) malloc( sizeof( char ) * ( strlen( input_param_bin_path ) + strlen( input_param_bin_file_name ) + 2 ) ); if ( full_in_param_bin_path == NULL ) @@ -1241,7 +1222,6 @@ char *create_hrtf_parametric( int32_t *hrtf_size ) hrtf_data_size = 0; -#ifdef FIX_POINT_HRTF_FILE_FORMAT input_param_bin_file = fopen( full_in_param_bin_path, "rb" ); @@ -1298,200 +1278,6 @@ char *create_hrtf_parametric( int32_t *hrtf_size ) full_in_param_bin_path = NULL; } -#else - /* Binary file - block description : - - HRTFs - HRTF_SH_CHANNELS => uint16_t - HRTF_NUM_BINS => uint16_t - hrtfShCoeffsRe => float[BINAURAL_CHANNELS][HRTF_SH_CHANNELS][HRTF_NUM_BINS]; - hrtfShCoeffsIm => float[BINAURAL_CHANNELS][HRTF_SH_CHANNELS][HRTF_NUM_BINS]; - - BRIR-based reverb - CLDFB_NO_CHANNELS_MAX => uint16_t - parametricReverberationTimes => float[CLDFB_NO_CHANNELS_MAX]; - parametricReverberationEneCorrections => float[CLDFB_NO_CHANNELS_MAX]; - parametricEarlyPartEneCorrection => float[CLDFB_NO_CHANNELS_MAX]; -*/ - - // Compute total size of data to write - // CLDFB SH domain HRTF-data - hrtf_data_size += sizeof( uint16_t ); // HRTF_SH_CHANNELS - hrtf_data_size += sizeof( uint16_t ); // HRTF_NUM_BINS - hrtf_data_size += 2 * ( BINAURAL_CHANNELS * HRTF_SH_CHANNELS * HRTF_NUM_BINS * sizeof( float ) ); // HRTF - - // Always write also BRIR reverb data - hrtf_data_size += sizeof( uint16_t ); // CLDFB_NO_CHANNELS_MAX - hrtf_data_size += CLDFB_NO_CHANNELS_MAX * sizeof( float ); // parametricReverberationTimes - hrtf_data_size += CLDFB_NO_CHANNELS_MAX * sizeof( float ); // parametricReverberationEneCorrections - hrtf_data_size += CLDFB_NO_CHANNELS_MAX * sizeof( float ); // parametricEarlyPartEneCorrection - - file_read_ok = 0; - input_param_bin_file = fopen( full_in_param_bin_path, "rb" ); - if ( input_param_bin_file != NULL ) - { - uint16_t hrtf_sh_channels, hrtf_num_bins, cldfb_no_channels_max; - - fseek( input_param_bin_file, 0, SEEK_END ); - data_size_tmp = ftell( input_param_bin_file ); - fseek( input_param_bin_file, 0, SEEK_SET ); - - if ( data_size_tmp != hrtf_data_size ) - { - fprintf( stderr, "Inconsistent binary data file size (expected: %d, found %d). Using built-in default values.\n\n", hrtf_data_size, data_size_tmp ); - } - else - { - fread( &hrtf_sh_channels, sizeof( uint16_t ), 1, input_param_bin_file ); - fread( &hrtf_num_bins, sizeof( uint16_t ), 1, input_param_bin_file ); - if ( hrtf_sh_channels != HRTF_SH_CHANNELS ) - { - fprintf( stderr, "Warning: Inconsistent HRTF_SH_CHANNELS (expected: %d, found: %d).\n\n", HRTF_SH_CHANNELS, hrtf_sh_channels ); - } - if ( hrtf_num_bins != HRTF_NUM_BINS ) - { - fprintf( stderr, "Warning: Inconsistent HRTF_NUM_BINS (expected: %d, found: %d).\n\n", HRTF_NUM_BINS, hrtf_num_bins ); - } - - for ( size_t bin_chnl = 0; bin_chnl < BINAURAL_CHANNELS; bin_chnl++ ) - { - for ( size_t hrtf_chnl = 0; hrtf_chnl < HRTF_SH_CHANNELS; hrtf_chnl++ ) - { - fread( hrtfShCoeffsReFile[bin_chnl][hrtf_chnl], sizeof( float ), HRTF_NUM_BINS, input_param_bin_file ); - } - } - for ( size_t bin_chnl = 0; bin_chnl < BINAURAL_CHANNELS; bin_chnl++ ) - { - for ( size_t hrtf_chnl = 0; hrtf_chnl < HRTF_SH_CHANNELS; hrtf_chnl++ ) - { - fread( hrtfShCoeffsImFile[bin_chnl][hrtf_chnl], sizeof( float ), HRTF_NUM_BINS, input_param_bin_file ); - } - } - - /* reverb */ - fread( &cldfb_no_channels_max, sizeof( uint16_t ), 1, input_param_bin_file ); - if ( cldfb_no_channels_max != CLDFB_NO_CHANNELS_MAX ) - { - fprintf( stderr, "Warning: Inconsistent CLDFB_NO_CHANNELS_MAX (expected: %d, found: %d).\n\n", CLDFB_NO_CHANNELS_MAX, cldfb_no_channels_max ); - } - - fread( parametricReverberationTimesFile, sizeof( float ), CLDFB_NO_CHANNELS_MAX, input_param_bin_file ); - fread( parametricReverberationEneCorrectionsFile, sizeof( float ), CLDFB_NO_CHANNELS_MAX, input_param_bin_file ); - fread( parametricEarlyPartEneCorrectionFile, sizeof( float ), CLDFB_NO_CHANNELS_MAX, input_param_bin_file ); - - file_read_ok = 1; - } - } - else - { - fprintf( stderr, "Opening of parambin file %s failed. Using built-in default values.\n\n", full_in_param_bin_path ); - } - - // Allocate memory - *hrtf_size = sizeof( ivas_hrtfs_header_t ) + hrtf_data_size; - hrtf = (char *) malloc( *hrtf_size ); - if ( hrtf == NULL ) - { - fprintf( stderr, "Memory allocation for the block failed!\n\n" ); - *hrtf_size = -1; - return NULL; - } - - // Write - - // Header [Declaration of the HRTF] - // Renderer type (4 bytes) : See "RENDERER_TYPE" - // Decoder output format (4 bytes) : See "BINAURAL_INPUT_AUDIO_CONFIG" - // Sampling Frequency (4 bytes) - // Raw data size (4 bytes) - - memset( hrtf, 0x00, *hrtf_size ); - hrtf_wptr = hrtf; - - // Renderer type - we use only parametric room type here to cover both cases -#ifdef FIX_POINT_HRTF_FILE_FORMAT - *( (int32_t *) ( hrtf_wptr ) ) = HRTF_READER_RENDERER_BINAURAL_PARAMETRIC; -#else - *( (int32_t *) ( hrtf_wptr ) ) = HRTF_READER_RENDERER_BINAURAL_PARAMETRIC_ROOM; -#endif - hrtf_wptr += sizeof( int32_t ); - - // Decoder output format - not relevant parametric binaural renderer - *( (int32_t *) ( hrtf_wptr ) ) = BINAURAL_INPUT_AUDIO_CONFIG_UNDEFINED; - hrtf_wptr += sizeof( int32_t ); - - // Sampling Frequency - *( (int32_t *) ( hrtf_wptr ) ) = 48000; - hrtf_wptr += sizeof( int32_t ); - - // Raw data size - memcpy( hrtf_wptr, &( hrtf_data_size ), sizeof( uint32_t ) ); - hrtf_wptr += sizeof( uint32_t ); - - // Write the HRTF raw data - *( (uint16_t *) ( hrtf_wptr ) ) = HRTF_SH_CHANNELS; - hrtf_wptr += sizeof( uint16_t ); - - *( (uint16_t *) ( hrtf_wptr ) ) = HRTF_NUM_BINS; - hrtf_wptr += sizeof( uint16_t ); - - // HRTF - data_size_tmp = HRTF_NUM_BINS * sizeof( float ); - for ( i = 0; i < BINAURAL_CHANNELS; i++ ) - { - for ( j = 0; j < HRTF_SH_CHANNELS; j++ ) - { - if ( file_read_ok ) - { - memcpy( hrtf_wptr, &hrtfShCoeffsReFile[i][j], data_size_tmp ); - } - else - { - memcpy( hrtf_wptr, &hrtfShCoeffsRe[i][j], data_size_tmp ); - } - hrtf_wptr += data_size_tmp; - } - } - for ( i = 0; i < BINAURAL_CHANNELS; i++ ) - { - for ( j = 0; j < HRTF_SH_CHANNELS; j++ ) - { - if ( file_read_ok ) - { - memcpy( hrtf_wptr, &hrtfShCoeffsImFile[i][j], data_size_tmp ); - } - else - { - memcpy( hrtf_wptr, &hrtfShCoeffsIm[i][j], data_size_tmp ); - } - hrtf_wptr += data_size_tmp; - } - } - - // Reverb Parameters - *( (uint16_t *) ( hrtf_wptr ) ) = CLDFB_NO_CHANNELS_MAX; - hrtf_wptr += sizeof( uint16_t ); - - data_size_tmp = CLDFB_NO_CHANNELS_MAX * sizeof( float ); - if ( file_read_ok ) - { - memcpy( hrtf_wptr, &( parametricReverberationTimesFile ), data_size_tmp ); // parametricReverberationTimes - hrtf_wptr += data_size_tmp; - memcpy( hrtf_wptr, &( parametricReverberationEneCorrectionsFile ), data_size_tmp ); // parametricReverberationEneCorrections - hrtf_wptr += data_size_tmp; - memcpy( hrtf_wptr, &( parametricEarlyPartEneCorrectionFile ), data_size_tmp ); // parametricEarlyPartEneCorrection - hrtf_wptr += data_size_tmp; - } - else - { - memcpy( hrtf_wptr, &( parametricReverberationTimes ), data_size_tmp ); // parametricReverberationTimes - hrtf_wptr += data_size_tmp; - memcpy( hrtf_wptr, &( parametricReverberationEneCorrections ), data_size_tmp ); // parametricReverberationEneCorrections - hrtf_wptr += data_size_tmp; - memcpy( hrtf_wptr, &( parametricEarlyPartEneCorrection ), data_size_tmp ); // parametricEarlyPartEneCorrection - hrtf_wptr += data_size_tmp; - } -#endif return hrtf; } @@ -1911,7 +1697,6 @@ int16_t get_crend_hrtf_tables( HRTF_READER_RENDERER_TYPE rend_type, BINAURAL_INP return result; } -#ifdef FIX_POINT_HRTF_FILE_FORMAT /*---------------------------------------------------------------------* * compute_crend_hrtf_data_size_fx() * @@ -1986,78 +1771,6 @@ int32_t compute_crend_hrtf_data_size( crend_hrtf_tables_pointers *hrtf_table_ptr return hrtf_data_size; } -#else -/*---------------------------------------------------------------------* - * compute_crend_hrtf_data_size() - * - *---------------------------------------------------------------------*/ -int32_t compute_crend_hrtf_data_size( crend_hrtf_tables_pointers *hrtf_table_ptrs, crend_hrtf_tables_dimensions *hrtf_table_dims ) -{ - int32_t hrtf_data_size = 0; - int32_t iChan, iIR, iIndex, iIter; - - if ( ( hrtf_table_ptrs == NULL ) || ( hrtf_table_dims == NULL ) ) - { - return 0; - } - - hrtf_data_size += sizeof( float ); // latency_s - hrtf_data_size += sizeof( uint16_t ); // max_num_ir - hrtf_data_size += sizeof( uint16_t ); // BINAURAL_CHANNELS - hrtf_data_size += sizeof( int16_t ); // max_num_iterations - hrtf_data_size += hrtf_table_dims->max_num_ir * BINAURAL_CHANNELS * sizeof( uint16_t ); // num_iterations - hrtf_data_size += hrtf_table_dims->max_num_ir * BINAURAL_CHANNELS * hrtf_table_dims->max_num_iterations * sizeof( uint16_t ); // pIndex_frequency_max - - hrtf_data_size += sizeof( int16_t ); // max_num_iterations_diffuse - if ( hrtf_table_dims->max_num_iterations_diffuse != 0 ) - { - hrtf_data_size += BINAURAL_CHANNELS * sizeof( uint16_t ); // num_iterations_diffuse - // pIndex_frequency_max_diffuse : The size depends on num_iterations_diffuse - for ( iChan = 0; iChan < BINAURAL_CHANNELS; iChan++ ) - { - hrtf_data_size += hrtf_table_ptrs->num_iterations_diffuse[iChan] * sizeof( uint16_t ); - } - } - - hrtf_data_size += sizeof( uint16_t ); // index_frequency_max_diffuse - hrtf_data_size += hrtf_table_dims->max_num_ir * BINAURAL_CHANNELS * sizeof( float ); // inv_diffuse_weight -#ifdef FIX_POINT_HRTF_FILE_FORMAT - hrtf_data_size += sizeof( uint32_t ); // max_total_num_fsamp_per_iteration -#else - hrtf_data_size += sizeof( uint16_t ); // max_total_num_fsamp_per_iteration -#endif - // coeff_re & coeff_im : The size depends on pIndex_frequency_max - for ( iIR = 0, iIndex = 0; iIR < hrtf_table_dims->max_num_ir; iIR++ ) - { - for ( iChan = 0; iChan < BINAURAL_CHANNELS; iChan++ ) - { - for ( iIter = 0; iIter < hrtf_table_ptrs->num_iterations[iIR * BINAURAL_CHANNELS + iChan]; iIter++ ) - { - hrtf_data_size += 2 * hrtf_table_ptrs->pIndex_frequency_max[iIndex++] * sizeof( float ); // 2* : re & im - } - } - } - -#ifdef FIX_POINT_HRTF_FILE_FORMAT - hrtf_data_size += sizeof( uint32_t ); // max_total_num_fsamp_per_iteration_diff -#else - hrtf_data_size += sizeof( uint16_t ); // max_total_num_fsamp_per_iteration_diff -#endif - if ( hrtf_table_dims->max_total_num_fsamp_per_iteration_diff != 0 ) - { - // coeff_diffuse_re & coeff_diffuse_im : The size depends on pIndex_frequency_max - for ( iChan = 0, iIndex = 0; iChan < BINAURAL_CHANNELS; iChan++ ) - { - for ( iIter = 0; iIter < hrtf_table_ptrs->num_iterations_diffuse[iChan]; iIter++ ) - { - hrtf_data_size += 2 * hrtf_table_ptrs->pIndex_frequency_max_diffuse[iIndex++] * sizeof( float ); // 2* : re & im - } - } - } - - return hrtf_data_size; -} -#endif /*---------------------------------------------------------------------* * check_bin_file() @@ -2190,11 +1903,7 @@ int16_t check_hrtf_data( HRTF_READER_RENDERER_TYPE rend_type, BINAURAL_INPUT_AUD if ( rend_type == HRTF_READER_RENDERER_BINAURAL_OBJECTS_TD || rend_type == HRTF_READER_RENDERER_BINAURAL_REVERB_ALL || rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV || rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV_ROOM || -#ifdef FIX_POINT_HRTF_FILE_FORMAT rend_type == HRTF_READER_RENDERER_BINAURAL_PARAMETRIC ) -#else - rend_type == HRTF_READER_RENDERER_BINAURAL_PARAMETRIC || rend_type == HRTF_READER_RENDERER_BINAURAL_PARAMETRIC_ROOM ) -#endif { return 0; } @@ -2230,20 +1939,12 @@ int16_t check_hrtf_data( HRTF_READER_RENDERER_TYPE rend_type, BINAURAL_INPUT_AUD hrtf_data_in_rptr = hrtf_data_in; // latency_s -#ifdef FIX_POINT_HRTF_FILE_FORMAT if ( ( *( tabs_ptrs.latency_s ) - ( *( (int32_t *) ( hrtf_data_in_rptr ) ) ) * powf( 2.f, -31.f ) ) > 1e-9f ) -#else - if ( ( *( tabs_ptrs.latency_s ) - *( (float *) ( hrtf_data_in_rptr ) ) ) > 1e-9f ) -#endif { fprintf( stderr, "check_hrtf_data of binary file failed: bad latency_s!\n\n" ); return -1; } -#ifdef FIX_POINT_HRTF_FILE_FORMAT hrtf_data_in_rptr += sizeof( int32_t ); -#else - hrtf_data_in_rptr += sizeof( float ); -#endif // max_num_ir if ( tabs_dims.max_num_ir != *( (uint16_t *) ( hrtf_data_in_rptr ) ) ) @@ -2328,11 +2029,7 @@ int16_t check_hrtf_data( HRTF_READER_RENDERER_TYPE rend_type, BINAURAL_INPUT_AUD hrtf_data_in_rptr += sizeof( uint16_t ); // inv_diffuse_weight -#ifdef FIX_POINT_HRTF_FILE_FORMAT ctrl_size = tabs_dims.max_num_ir * BINAURAL_CHANNELS * sizeof( int16_t ); -#else - ctrl_size = tabs_dims.max_num_ir * BINAURAL_CHANNELS * sizeof( float ); -#endif if ( memcmp( tabs_ptrs.inv_diffuse_weight, hrtf_data_in_rptr, ctrl_size ) != 0 ) { fprintf( stderr, "check_hrtf_data of binary file failed: bad inv_diffuse_weight!\n\n" ); @@ -2349,21 +2046,12 @@ int16_t check_hrtf_data( HRTF_READER_RENDERER_TYPE rend_type, BINAURAL_INPUT_AUD hrtf_data_in_rptr += ctrl_size; // max_total_num_fsamp_per_iteration -#ifdef FIX_POINT_HRTF_FILE_FORMAT if ( tabs_dims.max_total_num_fsamp_per_iteration != *( (uint32_t *) ( hrtf_data_in_rptr ) ) ) { fprintf( stderr, "check_hrtf_data of binary file failed: bad max_total_num_fsamp_per_iteration!\n\n" ); return -1; } hrtf_data_in_rptr += sizeof( uint32_t ); -#else - if ( tabs_dims.max_total_num_fsamp_per_iteration != *( (uint16_t *) ( hrtf_data_in_rptr ) ) ) - { - fprintf( stderr, "check_hrtf_data of binary file failed: bad max_total_num_fsamp_per_iteration!\n\n" ); - return -1; - } - hrtf_data_in_rptr += sizeof( uint16_t ); -#endif // coeff_re : The size depends on pIndex_frequency_max for ( iIR = 0, iIndex = 0; iIR < tabs_dims.max_num_ir; iIR++ ) @@ -2373,11 +2061,7 @@ int16_t check_hrtf_data( HRTF_READER_RENDERER_TYPE rend_type, BINAURAL_INPUT_AUD coeff_rptr = tabs_ptrs.coeff_re + ( iIR * BINAURAL_CHANNELS + iChan ) * tabs_dims.max_total_num_fsamp_per_iteration; for ( iIter = 0; iIter < tabs_ptrs.num_iterations[iIR * BINAURAL_CHANNELS + iChan]; iIter++ ) { -#ifdef FIX_POINT_HRTF_FILE_FORMAT ctrl_size = tabs_ptrs.pIndex_frequency_max[iIndex] * sizeof( int32_t ); -#else - ctrl_size = tabs_ptrs.pIndex_frequency_max[iIndex] * sizeof( float ); -#endif if ( memcmp( coeff_rptr, hrtf_data_in_rptr, ctrl_size ) != 0 ) { fprintf( stderr, "check_hrtf_data of binary file failed: bad coeff_re!\n\n" ); @@ -2406,11 +2090,7 @@ int16_t check_hrtf_data( HRTF_READER_RENDERER_TYPE rend_type, BINAURAL_INPUT_AUD coeff_rptr = tabs_ptrs.coeff_im + ( iIR * BINAURAL_CHANNELS + iChan ) * tabs_dims.max_total_num_fsamp_per_iteration; for ( iIter = 0; iIter < tabs_ptrs.num_iterations[iIR * BINAURAL_CHANNELS + iChan]; iIter++ ) { -#ifdef FIX_POINT_HRTF_FILE_FORMAT ctrl_size = tabs_ptrs.pIndex_frequency_max[iIndex] * sizeof( int32_t ); -#else - ctrl_size = tabs_ptrs.pIndex_frequency_max[iIndex] * sizeof( float ); -#endif if ( memcmp( coeff_rptr, hrtf_data_in_rptr, ctrl_size ) != 0 ) { fprintf( stderr, "check_hrtf_data of binary file failed: bad coeff_re!\n\n" ); @@ -2431,21 +2111,12 @@ int16_t check_hrtf_data( HRTF_READER_RENDERER_TYPE rend_type, BINAURAL_INPUT_AUD } // max_total_num_fsamp_per_iteration_diff -#ifdef FIX_POINT_HRTF_FILE_FORMAT if ( tabs_dims.max_total_num_fsamp_per_iteration_diff != *( (uint32_t *) ( hrtf_data_in_rptr ) ) ) { fprintf( stderr, "check_hrtf_data of binary file failed: bad max_total_num_fsamp_per_iteration_diff!\n\n" ); return -1; } hrtf_data_in_rptr += sizeof( uint32_t ); -#else - if ( tabs_dims.max_total_num_fsamp_per_iteration_diff != *( (uint16_t *) ( hrtf_data_in_rptr ) ) ) - { - fprintf( stderr, "check_hrtf_data of binary file failed: bad max_total_num_fsamp_per_iteration_diff!\n\n" ); - return -1; - } - hrtf_data_in_rptr += sizeof( uint16_t ); -#endif if ( tabs_dims.max_total_num_fsamp_per_iteration_diff != 0 ) { @@ -2455,11 +2126,7 @@ int16_t check_hrtf_data( HRTF_READER_RENDERER_TYPE rend_type, BINAURAL_INPUT_AUD coeff_rptr = tabs_ptrs.coeff_diffuse_re + iChan * tabs_dims.max_total_num_fsamp_per_iteration_diff; for ( iIter = 0; iIter < tabs_ptrs.num_iterations_diffuse[iChan]; iIter++ ) { -#ifdef FIX_POINT_HRTF_FILE_FORMAT ctrl_size = tabs_ptrs.pIndex_frequency_max_diffuse[iIndex] * sizeof( int32_t ); -#else - ctrl_size = tabs_ptrs.pIndex_frequency_max_diffuse[iIndex] * sizeof( float ); -#endif if ( memcmp( coeff_rptr, hrtf_data_in_rptr, ctrl_size ) != 0 ) { fprintf( stderr, "check_hrtf_data of binary file failed: bad coeff_diffuse_re!\n\n" ); @@ -2484,11 +2151,7 @@ int16_t check_hrtf_data( HRTF_READER_RENDERER_TYPE rend_type, BINAURAL_INPUT_AUD coeff_rptr = tabs_ptrs.coeff_diffuse_im + iChan * tabs_dims.max_total_num_fsamp_per_iteration_diff; for ( iIter = 0; iIter < tabs_ptrs.num_iterations_diffuse[iChan]; iIter++ ) { -#ifdef FIX_POINT_HRTF_FILE_FORMAT ctrl_size = tabs_ptrs.pIndex_frequency_max_diffuse[iIndex] * sizeof( int32_t ); -#else - ctrl_size = tabs_ptrs.pIndex_frequency_max_diffuse[iIndex] * sizeof( float ); -#endif if ( memcmp( coeff_rptr, hrtf_data_in_rptr, ctrl_size ) != 0 ) { fprintf( stderr, "check_hrtf_data of binary file failed: bad coeff_diffuse_im!\n\n" ); diff --git a/scripts/binauralRenderer_interface/generate_crend_ivas_tables_from_sofa.c b/scripts/binauralRenderer_interface/generate_crend_ivas_tables_from_sofa.c index cb00657403..1625deb04e 100644 --- a/scripts/binauralRenderer_interface/generate_crend_ivas_tables_from_sofa.c +++ b/scripts/binauralRenderer_interface/generate_crend_ivas_tables_from_sofa.c @@ -73,15 +73,9 @@ #define LAST_SAMPLERATE 16000 /* Hz */ #define TEMPLTATE_C_ROM_FILE_NAME "ivas_license_header.template" #define ROM_FILE_NAME "ivas_rom_binaural_crend_head" -#ifdef FIX_POINT_HRTF_FILE_FORMAT #define FORMAT_FLOAT "%a" #define FORMAT_FLOAT_REVERB "%a" #define FORMAT_FLOAT_LATENCY "%a" -#else -#define FORMAT_FLOAT "%8.6f" -#define FORMAT_FLOAT_REVERB "%8.6f" -#define FORMAT_FLOAT_LATENCY "%10.9ff" -#endif #define NUM_SAMPLES_PER_LINES 96 #define NUM_SAMPLES_PER_LINES_REVERB 9 #define DECLARATION_NAME "CRendBin" @@ -121,13 +115,8 @@ typedef struct _crend_hrtf_tables_dimensions int16_t max_num_ir; int16_t max_num_iterations; int16_t max_num_iterations_diffuse; -#ifdef FIX_POINT_HRTF_FILE_FORMAT uint32_t max_total_num_fsamp_per_iteration; uint32_t max_total_num_fsamp_per_iteration_diff; -#else - uint16_t max_total_num_fsamp_per_iteration; - uint16_t max_total_num_fsamp_per_iteration_diff; -#endif } crend_hrtf_tables_dimensions; @@ -153,20 +142,11 @@ extern int32_t float2int32_t( float, int16_t ); extern int16_t float2int16_t( float, int16_t ); void get_binary_tables_dimensions( HRTFS_DATA *hrtf, crend_hrtf_tables_dimensions *hrtf_table_dims /*OUT*/ ); -#ifdef FIX_POINT_HRTF_FILE_FORMAT uint32_t compute_binary_size( HRTFS_DATA *hrtf, crend_hrtf_tables_dimensions *hrtf_table_dims ); -#else -uint32_t compute_binary_size( HRTFS_DATA *hrtf, crend_hrtf_tables_dimensions *hrtf_table_dims ); -#endif ivas_error make_fx_be( HRTFS_DATA *hrtf, struct ivas_layout_config lscfg, const int32_t samplerate, const int16_t frame_len, int16_t factorQ[3] ); ivas_error make_reverb_fx_be( float *pEner_l, float *pEner_r, float *pCoherence, const int32_t samplerate, int16_t *factorQ ); -#ifdef FIX_POINT_HRTF_FILE_FORMAT ivas_error write_binary_file( HRTFS_DATA *hrtf, struct ivas_layout_config lscfg, const int32_t samplerate, const int16_t frame_len, int16_t factorQ[3] ); ivas_error write_reverb_to_binary_file( float *pEner_l, float *pEner_r, float *pCoherence, int16_t factorQ, const int32_t samplerate ); -#else -ivas_error write_binary_file( HRTFS_DATA *hrtf, struct ivas_layout_config lscfg, const int32_t samplerate, const int16_t frame_len ); -ivas_error write_reverb_to_binary_file( float *pEner_l, float *pEner_r, float *pCoherence, const int32_t samplerate ); -#endif /*---------------------------------------------------------------------* * @@ -1326,7 +1306,6 @@ int generate_crend_ivas_tables_from_sofa( const char *file_path, ConfigReader *c #endif if ( binary_file_path != NULL ) { -#ifdef FIX_POINT_HRTF_FILE_FORMAT if ( write_binary_file( &hrtf_data, lscfg, sample_rates[indSR], frame_len, factorQ ) != IVAS_ERR_OK ) { mxDestroyArray( sofa ); @@ -1337,21 +1316,6 @@ int generate_crend_ivas_tables_from_sofa( const char *file_path, ConfigReader *c ivas_hrtf_close( &hrtf_data ); return -1; } -#else - if ( binary_file_path != NULL ) - { - if ( write_binary_file( &hrtf_data, lscfg, sample_rates[indSR], frame_len ) != IVAS_ERR_OK ) - { - mxDestroyArray( sofa ); - fprintf( stderr, "Write binary file error\n" ); - free( sofa_file_path ); - free( index_pos ); - free( ivas_hrtf ); - ivas_hrtf_close( &hrtf_data ); - return -1; - } - } -#endif } if ( ivas_hrtf->latency_s[0] ) @@ -1853,22 +1817,18 @@ int generate_reverb_ivas_tables_from_sofa( const char *file_path ) nr_fc_fft_filter = ( frame_len >> 1 ) + 1; float *p_avg_lr = NULL; float *pCoherence = NULL; -#ifdef FIX_POINT_HRTF_FILE_FORMAT int16_t *p_avg_lr_fx = NULL; int16_t *pCoherence_fx = NULL; int16_t factorQ; -#endif p_avg_lr = (float *) malloc( sizeof( float * ) * nr_fc_fft_filter * 2 ); pCoherence = (float *) malloc( sizeof( float * ) * nr_fc_fft_filter ); memset( p_avg_lr, 0, sizeof( float ) * nr_fc_fft_filter * 2 ); memset( pCoherence, 0, sizeof( float ) * nr_fc_fft_filter ); -#ifdef FIX_POINT_HRTF_FILE_FORMAT p_avg_lr_fx = (int16_t *) malloc( sizeof( int16_t * ) * nr_fc_fft_filter * 2 ); pCoherence_fx = (int16_t *) malloc( sizeof( int16_t * ) * nr_fc_fft_filter ); memset( p_avg_lr_fx, 0, sizeof( int16_t ) * nr_fc_fft_filter * 2 ); memset( pCoherence_fx, 0, sizeof( int16_t ) * nr_fc_fft_filter ); -#endif pHrtf_set_l_re = (float **) malloc( sizeof( float * ) * sofa_M ); pHrtf_set_l_im = (float **) malloc( sizeof( float * ) * sofa_M ); @@ -1939,17 +1899,10 @@ int generate_reverb_ivas_tables_from_sofa( const char *file_path ) #endif if ( binary_file_path != NULL ) { -#ifdef FIX_POINT_HRTF_FILE_FORMAT if ( write_reverb_to_binary_file( p_avg_lr, &p_avg_lr[nr_fc_fft_filter], pCoherence, factorQ, sample_rates[indSR] ) != IVAS_ERR_OK ) { goto cleanup; } -#else - if ( write_reverb_to_binary_file( p_avg_lr, &p_avg_lr[nr_fc_fft_filter], pCoherence, sample_rates[indSR] ) != IVAS_ERR_OK ) - { - goto cleanup; - } -#endif } cleanup: @@ -2737,7 +2690,6 @@ void get_binary_tables_dimensions( HRTFS_DATA *hrtf, crend_hrtf_tables_dimension } } -#ifdef FIX_POINT_HRTF_FILE_FORMAT /*---------------------------------------------------------------------* * compute_binary_size(); @@ -2814,78 +2766,6 @@ uint32_t compute_binary_size( HRTFS_DATA *hrtf, crend_hrtf_tables_dimensions *hr return hrtf_data_size; } -#else - -/*---------------------------------------------------------------------* - * compute_binary_size(); - *---------------------------------------------------------------------*/ -uint32_t compute_binary_size( HRTFS_DATA *hrtf, crend_hrtf_tables_dimensions *hrtf_table_dims ) -{ - int16_t iIR, iIter, iChan; - uint32_t hrtf_data_size; - - hrtf_data_size = 0; - - hrtf_data_size += sizeof( float ); // latency_s - hrtf_data_size += sizeof( uint16_t ); // max_num_ir - hrtf_data_size += sizeof( uint16_t ); // BINAURAL_CHANNELS - hrtf_data_size += sizeof( int16_t ); // max_num_iterations - hrtf_data_size += hrtf->max_num_ir * BINAURAL_CHANNELS * sizeof( uint16_t ); // num_iterations - hrtf_data_size += hrtf->max_num_ir * BINAURAL_CHANNELS * hrtf->max_num_iterations * sizeof( uint16_t ); // pIndex_frequency_max_dyn - - hrtf_data_size += sizeof( int16_t ); // max_num_iterations_diffuse - - if ( hrtf_table_dims->max_num_iterations_diffuse != 0 ) - { - hrtf_data_size += BINAURAL_CHANNELS * sizeof( uint16_t ); // num_iterations_diffuse - // The size of pIndex_frequency_max_diffuse_dyn depends on num_iterations_diffuse - for ( iChan = 0; iChan < BINAURAL_CHANNELS; iChan++ ) - { - hrtf_data_size += hrtf->num_iterations_diffuse[iChan] * sizeof( uint16_t ); - } - } - - hrtf_data_size += sizeof( uint16_t ); // index_frequency_max_diffuse - hrtf_data_size += hrtf->max_num_ir * sizeof( float ) * BINAURAL_CHANNELS; // inv_diffuse_weight - -#ifdef FIX_POINT_HRTF_FILE_FORMAT - hrtf_data_size += sizeof( uint32_t ); // max_total_num_fsamp_per_iteration -#else - hrtf_data_size += sizeof( uint16_t ); // max_total_num_fsamp_per_iteration -#endif - - // The sizes of coeff_re & coeff_im depend on pIndex_frequency_max_dyn - for ( iIR = 0; iIR < hrtf->max_num_ir; iIR++ ) - { - for ( iChan = 0; iChan < BINAURAL_CHANNELS; iChan++ ) - { - for ( iIter = 0; iIter < hrtf->num_iterations[iIR][iChan]; iIter++ ) - { - hrtf_data_size += 2 * hrtf->pIndex_frequency_max_dyn[iIR][iChan][iIter] * sizeof( float ); // 2* : re & im - } - } - } - -#ifdef FIX_POINT_HRTF_FILE_FORMAT - hrtf_data_size += sizeof( uint32_t ); // max_total_num_fsamp_per_iteration_diff -#else - hrtf_data_size += sizeof( uint16_t ); // max_total_num_fsamp_per_iteration_diff -#endif - if ( hrtf_table_dims->max_total_num_fsamp_per_iteration_diff != 0 ) - { - // The sizes of coeff_diffuse_re & coeff_diffuse_im depend on pIndex_frequency_max_dyn - for ( iChan = 0; iChan < BINAURAL_CHANNELS; iChan++ ) - { - for ( iIter = 0; iIter < hrtf->num_iterations_diffuse[iChan]; iIter++ ) - { - hrtf_data_size += 2 * hrtf->pIndex_frequency_max_diffuse_dyn[iChan][iIter] * sizeof( float ); // 2* : re & im - } - } - } - - return hrtf_data_size; -} -#endif /*---------------------------------------------------------------------* * make_fx_be(); *---------------------------------------------------------------------*/ @@ -3197,7 +3077,6 @@ ivas_error make_fx_be( HRTFS_DATA *hrtf, struct ivas_layout_config lscfg, const return IVAS_ERR_OK; } -#ifdef FIX_POINT_HRTF_FILE_FORMAT /*---------------------------------------------------------------------* * write_binary_file(); *---------------------------------------------------------------------*/ @@ -3521,294 +3400,6 @@ ivas_error write_binary_file( HRTFS_DATA *hrtf, struct ivas_layout_config lscfg, return IVAS_ERR_OK; } -#else - -/*---------------------------------------------------------------------* - * write_binary_file(); - *---------------------------------------------------------------------*/ -ivas_error write_binary_file( HRTFS_DATA *hrtf, struct ivas_layout_config lscfg, const int32_t samplerate, const int16_t frame_len ) -{ - FILE *output_binary_file; - - int16_t iIR, iIter, iChan, iTap; - uint32_t data_size_tmp; - float *coeff_rptr; - crend_hrtf_tables_dimensions hrtf_table_dims; - - uint32_t hrtf_data_size; - char *hrtf_bin = NULL, *hrtf_bin_wptr; - - char *binary_file_full_path = NULL; - - if ( hrtf == NULL ) - return IVAS_ERR_FAILED_ALLOC; - - if ( binary_file_path == NULL ) - return IVAS_ERR_FAILED_ALLOC; - - /* Binary file - block description : - - latency_s => float - - max_num_ir => uint16_t - BINAURAL_CHANNELS => uint16_t (BINAURAL_CHANNELS) - - max_num_iterations => int16_t - num_iterations => uint16_t[max_num_ir][BINAURAL_CHANNELS] - pIndex_frequency_max_dyn => uint16_t[max_num_ir][BINAURAL_CHANNELS][max_num_iterations] (Pointer) - - max_num_iterations_diffuse => int16_t - num_iterations_diffuse => uint16_t[BINAURAL_CHANNELS] - pIndex_frequency_max_diffuse_dyn => uint16_t[BINAURAL_CHANNELS][max_num_iterations_diffuse] (Pointer) - - index_frequency_max_diffuse => uint16_t - inv_diffuse_weight => float[BINAURAL_CHANNELS][max_num_ir] - -#ifdef FIX_POINT_HRTF_FILE_FORMAT - max_total_num_fsamp_per_iteration => uint32_t -#else - max_total_num_fsamp_per_iteration => uint16_t -#endif - coeff_re => float[max_num_ir][BINAURAL_CHANNELS][max_total_num_fsamp_per_iteration] (Pointer) - coeff_im => float[max_num_ir][BINAURAL_CHANNELS][max_total_num_fsamp_per_iteration] (Pointer) - -#ifdef FIX_POINT_HRTF_FILE_FORMAT - max_total_num_fsamp_per_iteration_diff => uint32_t -#else - max_total_num_fsamp_per_iteration_diff => uint16_t -#endif - coeff_diffuse_re => float[BINAURAL_CHANNELS][max_total_num_fsamp_per_iteration] (Pointer) - coeff_diffuse_im => float[BINAURAL_CHANNELS][max_total_num_fsamp_per_iteration] (Pointer) - */ - - get_binary_tables_dimensions( hrtf, &hrtf_table_dims ); - - hrtf_data_size = compute_binary_size( hrtf, &hrtf_table_dims ); - - hrtf_bin = NULL; - hrtf_bin = (char *) malloc( hrtf_data_size ); - if ( hrtf_bin == NULL ) - return IVAS_ERR_FAILED_ALLOC; - memset( hrtf_bin, 0x00, hrtf_data_size ); - hrtf_bin_wptr = hrtf_bin; - - // Write the HRTF raw data - - ( (float *) hrtf_bin_wptr )[0] = hrtf->latency_s; - hrtf_bin_wptr += sizeof( float ); - - ( (uint16_t *) hrtf_bin_wptr )[0] = hrtf->max_num_ir; - hrtf_bin_wptr += sizeof( uint16_t ); - - ( (uint16_t *) hrtf_bin_wptr )[0] = BINAURAL_CHANNELS; - hrtf_bin_wptr += sizeof( uint16_t ); - - - ( (int16_t *) hrtf_bin_wptr )[0] = hrtf->max_num_iterations; // max_num_iterations - hrtf_bin_wptr += sizeof( int16_t ); - - data_size_tmp = hrtf->max_num_ir * BINAURAL_CHANNELS * sizeof( uint16_t ); - memcpy( hrtf_bin_wptr, hrtf->num_iterations, data_size_tmp ); // num_iterations - hrtf_bin_wptr += data_size_tmp; - - // pIndex_frequency_max_dyn - data_size_tmp = hrtf->max_num_iterations * sizeof( uint16_t ); - for ( int iIR = 0; iIR < hrtf->max_num_ir; iIR++ ) - { - for ( iChan = 0; iChan < BINAURAL_CHANNELS; iChan++ ) - { - memcpy( hrtf_bin_wptr, hrtf->pIndex_frequency_max_dyn[iIR][iChan], data_size_tmp ); - hrtf_bin_wptr += data_size_tmp; - } - } - - memcpy( hrtf_bin_wptr, &( hrtf_table_dims.max_num_iterations_diffuse ), sizeof( int16_t ) ); // max_num_iterations_diffuse - hrtf_bin_wptr += sizeof( int16_t ); - - if ( hrtf_table_dims.max_num_iterations_diffuse != 0 ) - { - data_size_tmp = BINAURAL_CHANNELS * sizeof( uint16_t ); - memcpy( hrtf_bin_wptr, hrtf->num_iterations_diffuse, data_size_tmp ); // num_iterations_diffuse - hrtf_bin_wptr += data_size_tmp; - - // pIndex_frequency_max_diffuse_dyn (the size depends on num_iterations_diffuse) - for ( iChan = 0; iChan < BINAURAL_CHANNELS; iChan++ ) - { - data_size_tmp = hrtf->num_iterations_diffuse[iChan] * sizeof( uint16_t ); - memcpy( hrtf_bin_wptr, hrtf->pIndex_frequency_max_diffuse_dyn[iChan], data_size_tmp ); - hrtf_bin_wptr += data_size_tmp; - } - } - - memcpy( hrtf_bin_wptr, &( hrtf->index_frequency_max_diffuse ), sizeof( uint16_t ) ); // index_frequency_max_diffuse - hrtf_bin_wptr += sizeof( uint16_t ); - - for ( iIR = 0; iIR < hrtf->max_num_ir; iIR++ ) - { -#ifdef FIX_POINT_HRTF_FILE_FORMAT - ( (float *) hrtf_bin_wptr )[iIR] = hrtf->inv_diffuse_weight[0][iIR]; -#else - sprintf( tmpStr, FORMAT_FLOAT, hrtf->inv_diffuse_weight[0][iIR] ); - sscanf( tmpStr, "%f", &( (float *) hrtf_bin_wptr )[iIR] ); -#endif - } - - data_size_tmp = hrtf->max_num_ir * sizeof( float ); - hrtf_bin_wptr += data_size_tmp; - - for ( iIR = 0; iIR < hrtf->max_num_ir; iIR++ ) - { -#ifdef FIX_POINT_HRTF_FILE_FORMAT - ( (float *) hrtf_bin_wptr )[iIR] = hrtf->inv_diffuse_weight[1][iIR]; -#else - sprintf( tmpStr, FORMAT_FLOAT, hrtf->inv_diffuse_weight[1][iIR] ); - sscanf( tmpStr, "%f", &( (float *) hrtf_bin_wptr )[iIR] ); -#endif - } - data_size_tmp = hrtf->max_num_ir * sizeof( float ); - hrtf_bin_wptr += data_size_tmp; - - -#ifdef FIX_POINT_HRTF_FILE_FORMAT - memcpy( hrtf_bin_wptr, &( hrtf_table_dims.max_total_num_fsamp_per_iteration ), sizeof( uint32_t ) ); // max_total_num_fsamp_per_iteration - hrtf_bin_wptr += sizeof( uint32_t ); -#else - memcpy( hrtf_bin_wptr, &( hrtf_table_dims.max_total_num_fsamp_per_iteration ), sizeof( uint16_t ) ); // max_total_num_fsamp_per_iteration - hrtf_bin_wptr += sizeof( uint16_t ); -#endif - - - // pOut_to_bin_re_dyn (The size depends on pIndex_frequency_max_dyn) - for ( iIR = 0; iIR < hrtf->max_num_ir; iIR++ ) - { - for ( iChan = 0; iChan < BINAURAL_CHANNELS; iChan++ ) - { - coeff_rptr = hrtf->pOut_to_bin_re_dyn[iIR][iChan]; - for ( iIter = 0; iIter < hrtf->num_iterations[iIR][iChan]; iIter++ ) - { - data_size_tmp = hrtf->pIndex_frequency_max_dyn[iIR][iChan][iIter] * sizeof( float ); - // memcpy( hrtf_bin_wptr, coeff_rptr, data_size_tmp ); - for ( iTap = 0; iTap < hrtf->pIndex_frequency_max_dyn[iIR][iChan][iIter]; iTap++ ) - { -#ifdef FIX_POINT_HRTF_FILE_FORMAT - ( (float *) hrtf_bin_wptr )[iTap] = coeff_rptr[iTap]; -#else - //( (float *) hrtf_bin_wptr )[iTap] = coeff_rptr[iTap]; - sprintf( tmpStr, FORMAT_FLOAT, coeff_rptr[iTap] ); - sscanf( tmpStr, "%f", &( ( (float *) hrtf_bin_wptr )[iTap] ) ); -#endif - } - hrtf_bin_wptr += data_size_tmp; - coeff_rptr += hrtf->pIndex_frequency_max_dyn[iIR][iChan][iIter]; - } - } - } - - // pOut_to_bin_im_dyn (The size depends on pIndex_frequency_max_dyn) - for ( iIR = 0; iIR < hrtf->max_num_ir; iIR++ ) - { - for ( iChan = 0; iChan < BINAURAL_CHANNELS; iChan++ ) - { - coeff_rptr = hrtf->pOut_to_bin_im_dyn[iIR][iChan]; - for ( iIter = 0; iIter < hrtf->num_iterations[iIR][iChan]; iIter++ ) - { - data_size_tmp = hrtf->pIndex_frequency_max_dyn[iIR][iChan][iIter] * sizeof( float ); - for ( iTap = 0; iTap < hrtf->pIndex_frequency_max_dyn[iIR][iChan][iIter]; iTap++ ) - { -#ifdef FIX_POINT_HRTF_FILE_FORMAT - ( (float *) hrtf_bin_wptr )[iTap] = coeff_rptr[iTap]; -#else - //( (float *) hrtf_bin_wptr )[iTap] = coeff_rptr[iTap]; - sprintf( tmpStr, FORMAT_FLOAT, coeff_rptr[iTap] ); - sscanf( tmpStr, "%f", &( ( (float *) hrtf_bin_wptr )[iTap] ) ); -#endif - } - hrtf_bin_wptr += data_size_tmp; - coeff_rptr += hrtf->pIndex_frequency_max_dyn[iIR][iChan][iIter]; - } - } - } - -#ifdef FIX_POINT_HRTF_FILE_FORMAT - memcpy( hrtf_bin_wptr, &( hrtf_table_dims.max_total_num_fsamp_per_iteration_diff ), sizeof( uint32_t ) ); // max_total_num_fsamp_per_iteration_diff - hrtf_bin_wptr += sizeof( uint32_t ); -#else - memcpy( hrtf_bin_wptr, &( hrtf_table_dims.max_total_num_fsamp_per_iteration_diff ), sizeof( uint16_t ) ); // max_total_num_fsamp_per_iteration_diff - hrtf_bin_wptr += sizeof( uint16_t ); -#endif - - if ( hrtf_table_dims.max_total_num_fsamp_per_iteration_diff != 0 ) - { - // pOut_to_bin_diffuse_re_dyn : The size depends on pIndex_frequency_max_diffuse_dyn - for ( iChan = 0; iChan < BINAURAL_CHANNELS; iChan++ ) - { - coeff_rptr = hrtf->pOut_to_bin_diffuse_re_dyn[iChan]; - for ( iIter = 0; iIter < hrtf->num_iterations_diffuse[iChan]; iIter++ ) - { - data_size_tmp = hrtf->pIndex_frequency_max_diffuse_dyn[iChan][iIter] * sizeof( float ); - for ( iTap = 0; iTap < hrtf->pIndex_frequency_max_diffuse_dyn[iChan][iIter]; iTap++ ) - { -#ifdef FIX_POINT_HRTF_FILE_FORMAT - ( (float *) hrtf_bin_wptr )[iTap] = coeff_rptr[iTap]; -#else - //( (float *) hrtf_bin_wptr )[iTap] = coeff_rptr[iTap]; - sprintf( tmpStr, FORMAT_FLOAT, coeff_rptr[iTap] ); - sscanf( tmpStr, "%f", &( ( (float *) hrtf_bin_wptr )[iTap] ) ); -#endif - } - hrtf_bin_wptr += data_size_tmp; - coeff_rptr += hrtf->pIndex_frequency_max_diffuse_dyn[iChan][iIter]; - } - } - - // pOut_to_bin_diffuse_im_dyn : The size depends on pIndex_frequency_max_diffuse_dyn - for ( iChan = 0; iChan < BINAURAL_CHANNELS; iChan++ ) - { - coeff_rptr = hrtf->pOut_to_bin_diffuse_im_dyn[iChan]; - for ( iIter = 0; iIter < hrtf->num_iterations_diffuse[iChan]; iIter++ ) - { - data_size_tmp = hrtf->pIndex_frequency_max_diffuse_dyn[iChan][iIter] * sizeof( float ); - for ( iTap = 0; iTap < hrtf->pIndex_frequency_max_diffuse_dyn[iChan][iIter]; iTap++ ) - { -#ifdef FIX_POINT_HRTF_FILE_FORMAT - ( (float *) hrtf_bin_wptr )[iTap] = coeff_rptr[iTap]; -#else - //( (float *) hrtf_bin_wptr )[iTap] = coeff_rptr[iTap]; - sprintf( tmpStr, FORMAT_FLOAT, coeff_rptr[iTap] ); - sscanf( tmpStr, "%f", &( ( (float *) hrtf_bin_wptr )[iTap] ) ); -#endif - } - hrtf_bin_wptr += data_size_tmp; - coeff_rptr += hrtf->pIndex_frequency_max_diffuse_dyn[iChan][iIter]; - } - } - } - - if ( hrtf_bin_wptr - hrtf_bin != hrtf_data_size ) - { - free( hrtf_bin ); - return IVAS_ERR_FAILED_FILE_WRITE; - } - - binary_file_full_path = (char *) malloc( sizeof( char ) * ( strlen( binary_file_path ) + strlen( lscfg.name ) + 2 + 2 + 3 + 4 + 1 ) ); - sprintf( binary_file_full_path, "%s_%s_%ikHz.bin", binary_file_path, lscfg.name, samplerate / 1000 ); - fprintf( stdout, "Write Binary file %s:\n", binary_file_full_path ); - - output_binary_file = fopen( binary_file_full_path, "wb" ); - if ( output_binary_file == NULL ) - { - free( hrtf_bin ); - return IVAS_ERR_FAILED_FILE_WRITE; - } - fwrite( hrtf_bin, hrtf_data_size, 1, output_binary_file ); - fclose( output_binary_file ); - - free( hrtf_bin ); - free( binary_file_full_path ); - - return IVAS_ERR_OK; -} -#endif /*---------------------------------------------------------------------* * make_fx_be(); *---------------------------------------------------------------------*/ @@ -3900,7 +3491,6 @@ ivas_error make_reverb_fx_be( float *pEner_l, float *pEner_r, float *pCoherence, return IVAS_ERR_OK; } -#ifdef FIX_POINT_HRTF_FILE_FORMAT /*---------------------------------------------------------------------* * write_reverb_to_binary_file(); *---------------------------------------------------------------------*/ @@ -4009,108 +3599,6 @@ ivas_error write_reverb_to_binary_file( float *pEner_l, float *pEner_r, float *p return IVAS_ERR_OK; } -#else - -/*---------------------------------------------------------------------* - * write_binary_file(); - *---------------------------------------------------------------------*/ -ivas_error write_reverb_to_binary_file( float *pEner_l, float *pEner_r, float *pCoherence, const int32_t samplerate ) -{ - FILE *output_binary_file; - - int16_t iTap; -#ifndef FIX_POINT_HRTF_FILE_FORMAT - char tmpStr[64]; -#endif - uint32_t hrtf_data_size; - - char *hrtf_bin = NULL, *hrtf_bin_wptr; - - char *binary_file_full_path = NULL; - - int16_t len = LR_IAC_LENGTH_NR_FC; - - if ( samplerate == 16000 ) - { - len = LR_IAC_LENGTH_NR_FC_16KHZ; - } - - if ( pEner_l == NULL ) - return IVAS_ERR_UNEXPECTED_NULL_POINTER; - - if ( pEner_r == NULL ) - return IVAS_ERR_UNEXPECTED_NULL_POINTER; - - if ( pCoherence == NULL ) - return IVAS_ERR_UNEXPECTED_NULL_POINTER; - - if ( binary_file_path == NULL ) - return IVAS_ERR_UNEXPECTED_NULL_POINTER; - - hrtf_bin = NULL; - hrtf_data_size = sizeof( float ) * 3 * len; - hrtf_bin = (char *) malloc( hrtf_data_size ); - if ( hrtf_bin == NULL ) - return IVAS_ERR_UNEXPECTED_NULL_POINTER; - memset( hrtf_bin, 0x00, hrtf_data_size ); - hrtf_bin_wptr = hrtf_bin; - - for ( iTap = 0; iTap < len; iTap++ ) - { -#ifdef FIX_POINT_HRTF_FILE_FORMAT - ( (float *) hrtf_bin_wptr )[iTap] = pEner_l[iTap]; -#else - sprintf( tmpStr, FORMAT_FLOAT, pEner_l[iTap] ); - sscanf( tmpStr, "%f", &( ( (float *) hrtf_bin_wptr )[iTap] ) ); -#endif - } - hrtf_bin_wptr += sizeof( float ) * len; - for ( iTap = 0; iTap < len; iTap++ ) - { -#ifdef FIX_POINT_HRTF_FILE_FORMAT - ( (float *) hrtf_bin_wptr )[iTap] = pEner_r[iTap]; -#else - sprintf( tmpStr, FORMAT_FLOAT, pEner_r[iTap] ); - sscanf( tmpStr, "%f", &( ( (float *) hrtf_bin_wptr )[iTap] ) ); -#endif - } - hrtf_bin_wptr += sizeof( float ) * len; - for ( iTap = 0; iTap < len; iTap++ ) - { -#ifdef FIX_POINT_HRTF_FILE_FORMAT - ( (float *) hrtf_bin_wptr )[iTap] = pCoherence[iTap]; -#else - sprintf( tmpStr, FORMAT_FLOAT, pCoherence[iTap] ); - sscanf( tmpStr, "%f", &( ( (float *) hrtf_bin_wptr )[iTap] ) ); -#endif - } - hrtf_bin_wptr += sizeof( float ) * len; - - if ( hrtf_bin_wptr - hrtf_bin != hrtf_data_size ) - { - free( hrtf_bin ); - return IVAS_ERR_FAILED_FILE_WRITE; - } - - binary_file_full_path = (char *) malloc( sizeof( char ) * ( strlen( binary_file_path ) + strlen( "Reverb" ) + 2 + 2 + 3 + 4 + 1 ) ); - sprintf( binary_file_full_path, "%s_%s_%ikHz.bin", binary_file_path, "Reverb", samplerate / 1000 ); - fprintf( stdout, "Write Binary file %s:\n", binary_file_full_path ); - - output_binary_file = fopen( binary_file_full_path, "wb" ); - if ( output_binary_file == NULL ) - { - free( hrtf_bin ); - return IVAS_ERR_FAILED_FILE_WRITE; - } - fwrite( hrtf_bin, hrtf_data_size, 1, output_binary_file ); - fclose( output_binary_file ); - - free( hrtf_bin ); - free( binary_file_full_path ); - - return IVAS_ERR_OK; -} -#endif /*---------------------------------------------------------------------* *get_ls_layout_config( AUDIO_CONFIG_CONFIG ls_layout_config, struct ivas_layout_config *ls_struct ) * fill ls_struct with proper values depending on ls_layout_config -- GitLab From 3bdd0019f43a71fa06c1618a46a944391ea22b07 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 11 Sep 2024 17:22:05 +0200 Subject: [PATCH 08/29] [cleanup] accept FIX_1123_CREND_16BIT_FMT --- lib_com/options.h | 1 - lib_util/hrtf_file_reader.c | 20 ----- .../generate_tables_from_rom_to_bin.c | 8 -- .../generate_crend_ivas_tables_from_sofa.c | 79 +------------------ 4 files changed, 2 insertions(+), 106 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 053b3cc518..45c91041fd 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -170,7 +170,6 @@ #define TMP_FIX_1119_SPLIT_RENDERING_VOIP /* FhG: Add error check for unsupported config: split rendering with VoIP mode */ #define FIX_POINT_ROM_CONST /* Ora: issue #1150 HRTF ROM tables should be defined as 'const'*/ -#define FIX_1123_CREND_16BIT_FMT /* Ora: update CREND binary file format to 16 bit */ #define FIX_1123_CREND_FLTFX_BE /* Ora: make CREND FLT ROM tables BE to FX file */ #define FIX_1123_FASTCONV_16BIT_FMT /* FhG: issue 1123: update FastConv binary file format and scripts to 16 bit */ #define FIX_RETURN /* VA: fix location of function returns */ diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index fad9380837..339ff8e610 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -1268,13 +1268,8 @@ static ivas_error create_HRTF_from_rawdata( for ( k = 0; k < ( *hHRTF )->num_iterations[i][j]; k++ ) { -#ifdef FIX_1123_CREND_16BIT_FMT mem_size = ( *hHRTF )->pIndex_frequency_max[i][j][k] * sizeof( int16_t ); Word16 *ptW = (Word16 *) hrtf_data_rptr; -#else - mem_size = ( *hHRTF )->pIndex_frequency_max[i][j][k] * sizeof( int32_t ); - Word32 *ptW = (Word32 *) hrtf_data_rptr; -#endif for ( l = 0; l < ( *hHRTF )->pIndex_frequency_max[i][j][k]; l++ ) { pOut_to_bin_wptr[l] = ptW[l] * powf( 2.f, -1.f * factorQ ); @@ -1313,13 +1308,8 @@ static ivas_error create_HRTF_from_rawdata( #endif for ( k = 0; k < ( *hHRTF )->num_iterations[i][j]; k++ ) { -#ifdef FIX_1123_CREND_16BIT_FMT mem_size = ( *hHRTF )->pIndex_frequency_max[i][j][k] * sizeof( int16_t ); Word16 *ptW = (Word16 *) hrtf_data_rptr; -#else - mem_size = ( *hHRTF )->pIndex_frequency_max[i][j][k] * sizeof( int32_t ); - Word32 *ptW = (Word32 *) hrtf_data_rptr; -#endif for ( l = 0; l < ( *hHRTF )->pIndex_frequency_max[i][j][k]; l++ ) { pOut_to_bin_wptr[l] = ptW[l] * powf( 2.f, -1.f * factorQ ); @@ -1365,13 +1355,8 @@ static ivas_error create_HRTF_from_rawdata( for ( k = 0; k < ( *hHRTF )->num_iterations_diffuse[j]; k++ ) { -#ifdef FIX_1123_CREND_16BIT_FMT mem_size = ( *hHRTF )->pIndex_frequency_max_diffuse[j][k] * sizeof( int16_t ); Word16 *ptW = (Word16 *) hrtf_data_rptr; -#else - mem_size = ( *hHRTF )->pIndex_frequency_max_diffuse[j][k] * sizeof( int32_t ); - Word32 *ptW = (Word32 *) hrtf_data_rptr; -#endif for ( l = 0; l < ( *hHRTF )->pIndex_frequency_max_diffuse[j][k]; l++ ) { pOut_to_bin_wptr[l] = ptW[l] * powf( 2.f, -1.f * factorQ ); @@ -1407,13 +1392,8 @@ static ivas_error create_HRTF_from_rawdata( #endif for ( k = 0; k < ( *hHRTF )->num_iterations_diffuse[j]; k++ ) { -#ifdef FIX_1123_CREND_16BIT_FMT mem_size = ( *hHRTF )->pIndex_frequency_max_diffuse[j][k] * sizeof( int16_t ); Word16 *ptW = (Word16 *) hrtf_data_rptr; -#else - mem_size = ( *hHRTF )->pIndex_frequency_max_diffuse[j][k] * sizeof( int32_t ); - Word32 *ptW = (Word32 *) hrtf_data_rptr; -#endif for ( l = 0; l < ( *hHRTF )->pIndex_frequency_max_diffuse[j][k]; l++ ) { pOut_to_bin_wptr[l] = ptW[l] * powf( 2.f, -1.f * factorQ ); diff --git a/scripts/binauralRenderer_interface/Table_Format_Converter/generate_tables_from_rom_to_bin.c b/scripts/binauralRenderer_interface/Table_Format_Converter/generate_tables_from_rom_to_bin.c index e16d826749..6b614f80c8 100644 --- a/scripts/binauralRenderer_interface/Table_Format_Converter/generate_tables_from_rom_to_bin.c +++ b/scripts/binauralRenderer_interface/Table_Format_Converter/generate_tables_from_rom_to_bin.c @@ -1743,11 +1743,7 @@ int32_t compute_crend_hrtf_data_size( crend_hrtf_tables_pointers *hrtf_table_ptr { for ( iIter = 0; iIter < hrtf_table_ptrs->num_iterations[iIR * BINAURAL_CHANNELS + iChan]; iIter++ ) { -#ifdef FIX_1123_CREND_16BIT_FMT hrtf_data_size += 2 * hrtf_table_ptrs->pIndex_frequency_max[iIndex++] * sizeof( int16_t ); // 2* : re & im -#else - hrtf_data_size += 2 * hrtf_table_ptrs->pIndex_frequency_max[iIndex++] * sizeof( int32_t ); // 2* : re & im -#endif } } } @@ -1760,11 +1756,7 @@ int32_t compute_crend_hrtf_data_size( crend_hrtf_tables_pointers *hrtf_table_ptr { for ( iIter = 0; iIter < hrtf_table_ptrs->num_iterations_diffuse[iChan]; iIter++ ) { -#ifdef FIX_1123_CREND_16BIT_FMT hrtf_data_size += 2 * hrtf_table_ptrs->pIndex_frequency_max_diffuse[iIndex++] * sizeof( int16_t ); // 2* : re & im -#else - hrtf_data_size += 2 * hrtf_table_ptrs->pIndex_frequency_max_diffuse[iIndex++] * sizeof( int32_t ); // 2* : re & im -#endif } } } diff --git a/scripts/binauralRenderer_interface/generate_crend_ivas_tables_from_sofa.c b/scripts/binauralRenderer_interface/generate_crend_ivas_tables_from_sofa.c index 1625deb04e..764cd4fabe 100644 --- a/scripts/binauralRenderer_interface/generate_crend_ivas_tables_from_sofa.c +++ b/scripts/binauralRenderer_interface/generate_crend_ivas_tables_from_sofa.c @@ -1300,7 +1300,7 @@ int generate_crend_ivas_tables_from_sofa( const char *file_path, ConfigReader *c #endif } -#if defined( FIX_1123_CREND_16BIT_FMT ) && !defined( FIX_1123_CREND_FLTFX_BE ) +#if !defined( FIX_1123_CREND_FLTFX_BE ) int16_t factorQ[3]; make_fx_be( &hrtf_data, lscfg, sample_rates[indSR], frame_len, factorQ ); #endif @@ -1888,7 +1888,7 @@ int generate_reverb_ivas_tables_from_sofa( const char *file_path ) update_c_file_with_reverb( p_avg_lr, &p_avg_lr[nr_fc_fft_filter], pCoherence, sample_rates[indSR], nr_fc_fft_filter ); #endif } -#if defined( FIX_1123_CREND_16BIT_FMT ) && !defined( FIX_1123_CREND_FLTFX_BE ) +#if !defined( FIX_1123_CREND_FLTFX_BE ) make_reverb_fx_be( p_avg_lr, &p_avg_lr[nr_fc_fft_filter], pCoherence, sample_rates[indSR], &factorQ ); for ( i = 0; i < nr_fc_fft_filter; i++ ) { @@ -2737,11 +2737,7 @@ uint32_t compute_binary_size( HRTFS_DATA *hrtf, crend_hrtf_tables_dimensions *hr { for ( iIter = 0; iIter < hrtf->num_iterations[iIR][iChan]; iIter++ ) { -#ifdef FIX_1123_CREND_16BIT_FMT hrtf_data_size += 2 * hrtf->pIndex_frequency_max_dyn[iIR][iChan][iIter] * sizeof( int16_t ); // 2* : re & im -#else - hrtf_data_size += 2 * hrtf->pIndex_frequency_max_dyn[iIR][iChan][iIter] * sizeof( int32_t ); // 2* : re & im -#endif } } } @@ -2754,11 +2750,7 @@ uint32_t compute_binary_size( HRTFS_DATA *hrtf, crend_hrtf_tables_dimensions *hr { for ( iIter = 0; iIter < hrtf->num_iterations_diffuse[iChan]; iIter++ ) { -#ifdef FIX_1123_CREND_16BIT_FMT hrtf_data_size += 2 * hrtf->pIndex_frequency_max_diffuse_dyn[iChan][iIter] * sizeof( int16_t ); // 2* : re & im -#else - hrtf_data_size += 2 * hrtf->pIndex_frequency_max_diffuse_dyn[iChan][iIter] * sizeof( int32_t ); // 2* : re & im -#endif } } } @@ -2936,27 +2928,16 @@ ivas_error make_fx_be( HRTFS_DATA *hrtf, struct ivas_layout_config lscfg, const if ( maxVal > 0 ) { -#ifdef FIX_1123_CREND_16BIT_FMT factorQ[2] = (int16_t) floorf( 15.f - logf( maxVal ) / logf( 2.f ) ); -#else - factorQ[2] = (int16_t) floorf( 31.f - logf( maxVal ) / logf( 2.f ) ); -#endif } else { factorQ[2] = 0; } -#ifdef FIX_1123_CREND_16BIT_FMT if ( factorQ[2] > 15 ) { factorQ[2] = 15; } -#else - if ( factorQ[2] > 31 ) - { - factorQ[2] = 31; - } -#endif // pOut_to_bin_re_dyn (The size depends on pIndex_frequency_max_dyn) for ( iIR = 0; iIR < hrtf->max_num_ir; iIR++ ) @@ -2970,13 +2951,8 @@ ivas_error make_fx_be( HRTFS_DATA *hrtf, struct ivas_layout_config lscfg, const for ( iTap = 0; iTap < hrtf->pIndex_frequency_max_dyn[iIR][iChan][iIter]; iTap++ ) { tmp = coeff_rptr[iTap]; -#ifdef FIX_1123_CREND_16BIT_FMT tmp16 = float2int16_t( coeff_rptr[iTap], factorQ[2] ); coeff_rptr[iTap] = (float) tmp16 * powf( 2.f, -1.f * (float) factorQ[2] ); -#else - tmp32 = float2int32_t( coeff_rptr[iTap], factorQ[2] ); - coeff_rptr[iTap] = (float) tmp32 * powf( 2.f, -1.f * (float) factorQ[2] ); -#endif diff = fabsf( tmp - coeff_rptr[iTap] ); if ( maxDiff < diff ) { @@ -2999,13 +2975,8 @@ ivas_error make_fx_be( HRTFS_DATA *hrtf, struct ivas_layout_config lscfg, const for ( iTap = 0; iTap < hrtf->pIndex_frequency_max_dyn[iIR][iChan][iIter]; iTap++ ) { tmp = coeff_rptr[iTap]; -#ifdef FIX_1123_CREND_16BIT_FMT tmp16 = float2int16_t( coeff_rptr[iTap], factorQ[2] ); coeff_rptr[iTap] = (float) tmp16 * powf( 2.f, -1.f * (float) factorQ[2] ); -#else - tmp32 = float2int32_t( coeff_rptr[iTap], factorQ[2] ); - coeff_rptr[iTap] = (float) tmp32 * powf( 2.f, -1.f * (float) factorQ[2] ); -#endif diff = fabsf( tmp - coeff_rptr[iTap] ); if ( maxDiff < diff ) { @@ -3030,13 +3001,8 @@ ivas_error make_fx_be( HRTFS_DATA *hrtf, struct ivas_layout_config lscfg, const for ( iTap = 0; iTap < hrtf->pIndex_frequency_max_diffuse_dyn[iChan][iIter]; iTap++ ) { tmp = coeff_rptr[iTap]; -#ifdef FIX_1123_CREND_16BIT_FMT tmp16 = float2int16_t( coeff_rptr[iTap], factorQ[2] ); coeff_rptr[iTap] = (float) tmp16 * powf( 2.f, -1.f * (float) factorQ[2] ); -#else - tmp32 = float2int32_t( coeff_rptr[iTap], factorQ[2] ); - coeff_rptr[iTap] = (float) tmp32 * powf( 2.f, -1.f * (float) factorQ[2] ); -#endif diff = fabsf( tmp - coeff_rptr[iTap] ); if ( maxDiff < diff ) { @@ -3057,13 +3023,8 @@ ivas_error make_fx_be( HRTFS_DATA *hrtf, struct ivas_layout_config lscfg, const for ( iTap = 0; iTap < hrtf->pIndex_frequency_max_diffuse_dyn[iChan][iIter]; iTap++ ) { tmp = coeff_rptr[iTap]; -#ifdef FIX_1123_CREND_16BIT_FMT tmp16 = float2int16_t( coeff_rptr[iTap], factorQ[2] ); coeff_rptr[iTap] = (float) tmp16 * powf( 2.f, -1.f * (float) factorQ[2] ); -#else - tmp32 = float2int32_t( coeff_rptr[iTap], factorQ[2] ); - coeff_rptr[iTap] = (float) tmp32 * powf( 2.f, -1.f * (float) factorQ[2] ); -#endif diff = fabsf( tmp - coeff_rptr[iTap] ); if ( maxDiff < diff ) { @@ -3242,22 +3203,13 @@ ivas_error write_binary_file( HRTFS_DATA *hrtf, struct ivas_layout_config lscfg, coeff_rptr = hrtf->pOut_to_bin_re_dyn[iIR][iChan]; for ( iIter = 0; iIter < hrtf->num_iterations[iIR][iChan]; iIter++ ) { -#ifdef FIX_1123_CREND_16BIT_FMT data_size_tmp = hrtf->pIndex_frequency_max_dyn[iIR][iChan][iIter] * sizeof( int16_t ); -#else - data_size_tmp = hrtf->pIndex_frequency_max_dyn[iIR][iChan][iIter] * sizeof( int32_t ); -#endif // memcpy( hrtf_bin_wptr, coeff_rptr, data_size_tmp ); for ( iTap = 0; iTap < hrtf->pIndex_frequency_max_dyn[iIR][iChan][iIter]; iTap++ ) { tmp = coeff_rptr[iTap]; -#ifdef FIX_1123_CREND_16BIT_FMT ( (int16_t *) hrtf_bin_wptr )[iTap] = float2int16_t( coeff_rptr[iTap], factorQ[2] ); tmp2 = ( (float) ( ( (int16_t *) hrtf_bin_wptr )[iTap] ) ) * powf( 2.f, -1.f * (float) factorQ[2] ); -#else - ( (int32_t *) hrtf_bin_wptr )[iTap] = float2int32_t( coeff_rptr[iTap], factorQ[2] ); - tmp2 = ( (float) ( ( (int32_t *) hrtf_bin_wptr )[iTap] ) ) * powf( 2.f, -1.f * (float) factorQ[2] ); -#endif diff = fabsf( tmp - tmp2 ); if ( maxDiff < diff ) { @@ -3278,21 +3230,12 @@ ivas_error write_binary_file( HRTFS_DATA *hrtf, struct ivas_layout_config lscfg, coeff_rptr = hrtf->pOut_to_bin_im_dyn[iIR][iChan]; for ( iIter = 0; iIter < hrtf->num_iterations[iIR][iChan]; iIter++ ) { -#ifdef FIX_1123_CREND_16BIT_FMT data_size_tmp = hrtf->pIndex_frequency_max_dyn[iIR][iChan][iIter] * sizeof( int16_t ); -#else - data_size_tmp = hrtf->pIndex_frequency_max_dyn[iIR][iChan][iIter] * sizeof( int32_t ); -#endif for ( iTap = 0; iTap < hrtf->pIndex_frequency_max_dyn[iIR][iChan][iIter]; iTap++ ) { tmp = coeff_rptr[iTap]; -#ifdef FIX_1123_CREND_16BIT_FMT ( (int16_t *) hrtf_bin_wptr )[iTap] = float2int16_t( coeff_rptr[iTap], factorQ[2] ); tmp2 = ( (float) ( ( (int16_t *) hrtf_bin_wptr )[iTap] ) ) * powf( 2.f, -1.f * (float) factorQ[2] ); -#else - ( (int32_t *) hrtf_bin_wptr )[iTap] = float2int32_t( coeff_rptr[iTap], factorQ[2] ); - tmp2 = ( (float) ( ( (int32_t *) hrtf_bin_wptr )[iTap] ) ) * powf( 2.f, -1.f * (float) factorQ[2] ); -#endif diff = fabsf( tmp - tmp2 ); if ( maxDiff < diff ) { @@ -3316,22 +3259,13 @@ ivas_error write_binary_file( HRTFS_DATA *hrtf, struct ivas_layout_config lscfg, coeff_rptr = hrtf->pOut_to_bin_diffuse_re_dyn[iChan]; for ( iIter = 0; iIter < hrtf->num_iterations_diffuse[iChan]; iIter++ ) { -#ifdef FIX_1123_CREND_16BIT_FMT data_size_tmp = hrtf->pIndex_frequency_max_diffuse_dyn[iChan][iIter] * sizeof( int16_t ); -#else - data_size_tmp = hrtf->pIndex_frequency_max_diffuse_dyn[iChan][iIter] * sizeof( int32_t ); -#endif // memcpy( hrtf_bin_wptr, coeff_rptr, data_size_tmp ); for ( iTap = 0; iTap < hrtf->pIndex_frequency_max_diffuse_dyn[iChan][iIter]; iTap++ ) { tmp = coeff_rptr[iTap]; -#ifdef FIX_1123_CREND_16BIT_FMT ( (int16_t *) hrtf_bin_wptr )[iTap] = float2int16_t( coeff_rptr[iTap], factorQ[2] ); tmp2 = ( (float) ( ( (int16_t *) hrtf_bin_wptr )[iTap] ) ) * powf( 2.f, -1.f * (float) factorQ[2] ); -#else - ( (int32_t *) hrtf_bin_wptr )[iTap] = float2int32_t( coeff_rptr[iTap], factorQ[2] ); - tmp2 = ( (float) ( ( (int32_t *) hrtf_bin_wptr )[iTap] ) ) * powf( 2.f, -1.f * (float) factorQ[2] ); -#endif diff = fabsf( tmp - tmp2 ); if ( maxDiff < diff ) { @@ -3349,21 +3283,12 @@ ivas_error write_binary_file( HRTFS_DATA *hrtf, struct ivas_layout_config lscfg, coeff_rptr = hrtf->pOut_to_bin_diffuse_im_dyn[iChan]; for ( iIter = 0; iIter < hrtf->num_iterations_diffuse[iChan]; iIter++ ) { -#ifdef FIX_1123_CREND_16BIT_FMT data_size_tmp = hrtf->pIndex_frequency_max_diffuse_dyn[iChan][iIter] * sizeof( int16_t ); -#else - data_size_tmp = hrtf->pIndex_frequency_max_diffuse_dyn[iChan][iIter] * sizeof( int32_t ); -#endif for ( iTap = 0; iTap < hrtf->pIndex_frequency_max_diffuse_dyn[iChan][iIter]; iTap++ ) { tmp = coeff_rptr[iTap]; -#ifdef FIX_1123_CREND_16BIT_FMT ( (int16_t *) hrtf_bin_wptr )[iTap] = float2int16_t( coeff_rptr[iTap], factorQ[2] ); tmp2 = ( (float) ( ( (int16_t *) hrtf_bin_wptr )[iTap] ) ) * powf( 2.f, -1.f * (float) factorQ[2] ); -#else - ( (int32_t *) hrtf_bin_wptr )[iTap] = float2int32_t( coeff_rptr[iTap], factorQ[2] ); - tmp2 = ( (float) ( ( (int32_t *) hrtf_bin_wptr )[iTap] ) ) * powf( 2.f, -1.f * (float) factorQ[2] ); -#endif diff = fabsf( tmp - tmp2 ); if ( maxDiff < diff ) { -- GitLab From eab3359f9c2a97104dd47e1dce850d7a7574101b Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 11 Sep 2024 17:24:31 +0200 Subject: [PATCH 09/29] [cleanup] accept FIX_1123_CREND_FLTFX_BE, FIX_1123_FASTCONV_16BIT_FMT --- lib_com/options.h | 2 - lib_dec/ivas_binRenderer_internal.c | 117 ----- lib_rend/ivas_stat_rend.h | 7 - lib_util/hrtf_file_reader.c | 431 ------------------ .../generate_crend_ivas_tables_from_sofa.c | 38 -- 5 files changed, 595 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 45c91041fd..752c596568 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -170,8 +170,6 @@ #define TMP_FIX_1119_SPLIT_RENDERING_VOIP /* FhG: Add error check for unsupported config: split rendering with VoIP mode */ #define FIX_POINT_ROM_CONST /* Ora: issue #1150 HRTF ROM tables should be defined as 'const'*/ -#define FIX_1123_CREND_FLTFX_BE /* Ora: make CREND FLT ROM tables BE to FX file */ -#define FIX_1123_FASTCONV_16BIT_FMT /* FhG: issue 1123: update FastConv binary file format and scripts to 16 bit */ #define FIX_RETURN /* VA: fix location of function returns */ #define FIX_1135_EXT_RENDERER_HANDLES /* VA: issue 1135: Memory usage reduction in external renderer: Allocate only handles that are really needed. */ #define FIX_1158_FASTCONV_REVERB_HRTF /* Philips: issue 1158: Rendering with FastConv to BINAURAL_ROOM_REVERB uses BRIR convolution instead of HRTF */ diff --git a/lib_dec/ivas_binRenderer_internal.c b/lib_dec/ivas_binRenderer_internal.c index 98cf52caf8..186e3816ce 100644 --- a/lib_dec/ivas_binRenderer_internal.c +++ b/lib_dec/ivas_binRenderer_internal.c @@ -167,11 +167,7 @@ static ivas_error ivas_binRenderer_convModuleOpen( if ( renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) { -#ifdef FIX_1123_FASTCONV_16BIT_FMT hBinRenConvModule->numTaps = hHrtf->ntaps_brir; -#else - hBinRenConvModule->numTaps = BINAURAL_NTAPS_MAX; -#endif /* Use variable order filtering */ bandIdx = 0; @@ -200,7 +196,6 @@ static ivas_error ivas_binRenderer_convModuleOpen( { if ( hBinRenderer->ivas_format == SBA_FORMAT ) { -#ifdef FIX_1123_FASTCONV_16BIT_FMT if ( input_config == IVAS_AUDIO_CONFIG_HOA3 ) { hBinRenConvModule->numTaps = hHrtf->ntaps_hrir_hoa3; @@ -217,17 +212,10 @@ static ivas_error ivas_binRenderer_convModuleOpen( { return IVAS_ERR_INVALID_INPUT_FORMAT; } -#else - hBinRenConvModule->numTaps = BINAURAL_NTAPS_SBA; -#endif } else { -#ifdef FIX_1123_FASTCONV_16BIT_FMT hBinRenConvModule->numTaps = hHrtf->ntaps_hrir; -#else - hBinRenConvModule->numTaps = BINAURAL_NTAPS; -#endif } /* Use fixed order filtering */ @@ -492,13 +480,11 @@ void ivas_init_binaural_hrtf( HrtfFastConv->FASTCONV_FOA_latency_s = 0x00; HrtfFastConv->allocate_init_flag = 0x00; -#ifdef FIX_1123_FASTCONV_16BIT_FMT HrtfFastConv->ntaps_hrir = BINAURAL_NTAPS; HrtfFastConv->ntaps_hrir_foa = BINAURAL_NTAPS_SBA; HrtfFastConv->ntaps_hrir_hoa2 = BINAURAL_NTAPS_SBA; HrtfFastConv->ntaps_hrir_hoa3 = BINAURAL_NTAPS_SBA; HrtfFastConv->ntaps_brir = BINAURAL_NTAPS_MAX; -#endif for ( i = 0; i < CLDFB_NO_CHANNELS_MAX; i++ ) { @@ -577,7 +563,6 @@ ivas_error ivas_allocate_binaural_hrtf( } else { -#ifdef FIX_1123_FASTCONV_16BIT_FMT if ( IVAS_ERR_OK != ivas_alloc_pppMem( &HrtfFastConv->leftHRIRReal_HOA3, BINAURAL_CONVBANDS, HOA3_CHANNELS, HrtfFastConv->ntaps_hrir_hoa3, allocate_init_flag ) ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftHRIRReal_HOA3" ); @@ -594,24 +579,6 @@ ivas_error ivas_allocate_binaural_hrtf( { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightHRIRImag_HOA3" ); } -#else - if ( IVAS_ERR_OK != ivas_alloc_pppMem( &HrtfFastConv->leftHRIRReal_HOA3, BINAURAL_CONVBANDS, HOA3_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftHRIRReal_HOA3" ); - } - if ( IVAS_ERR_OK != ivas_alloc_pppMem( &HrtfFastConv->leftHRIRImag_HOA3, BINAURAL_CONVBANDS, HOA3_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftHRIRImag_HOA3" ); - } - if ( IVAS_ERR_OK != ivas_alloc_pppMem( &HrtfFastConv->rightHRIRReal_HOA3, BINAURAL_CONVBANDS, HOA3_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightHRIRReal_HOA3" ); - } - if ( IVAS_ERR_OK != ivas_alloc_pppMem( &HrtfFastConv->rightHRIRImag_HOA3, BINAURAL_CONVBANDS, HOA3_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightHRIRImag_HOA3" ); - } -#endif } } @@ -623,7 +590,6 @@ ivas_error ivas_allocate_binaural_hrtf( } else { -#ifdef FIX_1123_FASTCONV_16BIT_FMT if ( IVAS_ERR_OK != ivas_alloc_pppMem( &HrtfFastConv->leftHRIRReal_HOA2, BINAURAL_CONVBANDS, HOA2_CHANNELS, HrtfFastConv->ntaps_hrir_hoa2, allocate_init_flag ) ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftHRIRReal_HOA2" ); @@ -640,24 +606,6 @@ ivas_error ivas_allocate_binaural_hrtf( { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightHRIRImag_HOA2" ); } -#else - if ( IVAS_ERR_OK != ivas_alloc_pppMem( &HrtfFastConv->leftHRIRReal_HOA2, BINAURAL_CONVBANDS, HOA2_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftHRIRReal_HOA2" ); - } - if ( IVAS_ERR_OK != ivas_alloc_pppMem( &HrtfFastConv->leftHRIRImag_HOA2, BINAURAL_CONVBANDS, HOA2_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftHRIRImag_HOA2" ); - } - if ( IVAS_ERR_OK != ivas_alloc_pppMem( &HrtfFastConv->rightHRIRReal_HOA2, BINAURAL_CONVBANDS, HOA2_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightHRIRReal_HOA2" ); - } - if ( IVAS_ERR_OK != ivas_alloc_pppMem( &HrtfFastConv->rightHRIRImag_HOA2, BINAURAL_CONVBANDS, HOA2_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightHRIRImag_HOA2" ); - } -#endif } } @@ -669,7 +617,6 @@ ivas_error ivas_allocate_binaural_hrtf( } else { -#ifdef FIX_1123_FASTCONV_16BIT_FMT if ( IVAS_ERR_OK != ivas_alloc_pppMem( &HrtfFastConv->leftHRIRReal_FOA, BINAURAL_CONVBANDS, FOA_CHANNELS, HrtfFastConv->ntaps_hrir_foa, allocate_init_flag ) ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftHRIRReal_FOA" ); @@ -686,36 +633,13 @@ ivas_error ivas_allocate_binaural_hrtf( { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightHRIRImag_FOA" ); } -#else - if ( IVAS_ERR_OK != ivas_alloc_pppMem( &HrtfFastConv->leftHRIRReal_FOA, BINAURAL_CONVBANDS, FOA_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftHRIRReal_FOA" ); - } - if ( IVAS_ERR_OK != ivas_alloc_pppMem( &HrtfFastConv->leftHRIRImag_FOA, BINAURAL_CONVBANDS, FOA_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftHRIRImag_FOA" ); - } - if ( IVAS_ERR_OK != ivas_alloc_pppMem( &HrtfFastConv->rightHRIRReal_FOA, BINAURAL_CONVBANDS, FOA_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightHRIRReal_FOA" ); - } - if ( IVAS_ERR_OK != ivas_alloc_pppMem( &HrtfFastConv->rightHRIRImag_FOA, BINAURAL_CONVBANDS, FOA_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightHRIRImag_FOA" ); - } -#endif } } -#ifdef FIX_1123_FASTCONV_16BIT_FMT else if ( ( renderer_type == RENDERER_BINAURAL_FASTCONV && bin_input_config == BINAURAL_INPUT_AUDIO_CONFIG_COMBINED ) || ( renderer_type == RENDERER_BINAURAL_FASTCONV && input_config != IVAS_AUDIO_CONFIG_INVALID ) ) -#else - if ( renderer_type == RENDERER_BINAURAL_FASTCONV || bin_input_config == BINAURAL_INPUT_AUDIO_CONFIG_COMBINED ) -#endif { if ( ( HrtfFastConv->leftHRIRReal == NULL ) && ( HrtfFastConv->leftHRIRImag == NULL ) && ( HrtfFastConv->rightHRIRReal == NULL ) && ( HrtfFastConv->rightHRIRImag == NULL ) ) { -#ifdef FIX_1123_FASTCONV_16BIT_FMT if ( IVAS_ERR_OK != ivas_alloc_pppMem( &HrtfFastConv->leftHRIRReal, BINAURAL_CONVBANDS, HRTF_LS_CHANNELS, HrtfFastConv->ntaps_hrir, allocate_init_flag ) ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftHRIRReal" ); @@ -732,36 +656,13 @@ ivas_error ivas_allocate_binaural_hrtf( { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightHRIRImag" ); } -#else - if ( IVAS_ERR_OK != ivas_alloc_pppMem( &HrtfFastConv->leftHRIRReal, BINAURAL_CONVBANDS, HRTF_LS_CHANNELS, BINAURAL_NTAPS, allocate_init_flag ) ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftHRIRReal" ); - } - if ( IVAS_ERR_OK != ivas_alloc_pppMem( &HrtfFastConv->leftHRIRImag, BINAURAL_CONVBANDS, HRTF_LS_CHANNELS, BINAURAL_NTAPS, allocate_init_flag ) ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftHRIRImag" ); - } - if ( IVAS_ERR_OK != ivas_alloc_pppMem( &HrtfFastConv->rightHRIRReal, BINAURAL_CONVBANDS, HRTF_LS_CHANNELS, BINAURAL_NTAPS, allocate_init_flag ) ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightHRIRReal" ); - } - if ( IVAS_ERR_OK != ivas_alloc_pppMem( &HrtfFastConv->rightHRIRImag, BINAURAL_CONVBANDS, HRTF_LS_CHANNELS, BINAURAL_NTAPS, allocate_init_flag ) ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightHRIRImag" ); - } -#endif } } -#ifdef FIX_1123_FASTCONV_16BIT_FMT else if ( ( renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM && bin_input_config == BINAURAL_INPUT_AUDIO_CONFIG_COMBINED ) || ( renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM && input_config != IVAS_AUDIO_CONFIG_INVALID ) ) -#else - if ( renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || bin_input_config == BINAURAL_INPUT_AUDIO_CONFIG_COMBINED ) -#endif { if ( ( HrtfFastConv->leftBRIRReal == NULL ) && ( HrtfFastConv->leftBRIRImag == NULL ) && ( HrtfFastConv->rightBRIRReal == NULL ) && ( HrtfFastConv->rightBRIRImag == NULL ) ) { -#ifdef FIX_1123_FASTCONV_16BIT_FMT if ( IVAS_ERR_OK != ivas_alloc_pppMem( &HrtfFastConv->leftBRIRReal, BINAURAL_CONVBANDS, HRTF_LS_CHANNELS, HrtfFastConv->ntaps_brir, allocate_init_flag ) ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftBRIRReal" ); @@ -778,24 +679,6 @@ ivas_error ivas_allocate_binaural_hrtf( { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightBRIRImag" ); } -#else - if ( IVAS_ERR_OK != ivas_alloc_pppMem( &HrtfFastConv->leftBRIRReal, BINAURAL_CONVBANDS, HRTF_LS_CHANNELS, BINAURAL_NTAPS_MAX, allocate_init_flag ) ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftBRIRReal" ); - } - if ( IVAS_ERR_OK != ivas_alloc_pppMem( &HrtfFastConv->leftBRIRImag, BINAURAL_CONVBANDS, HRTF_LS_CHANNELS, BINAURAL_NTAPS_MAX, allocate_init_flag ) ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftBRIRImag" ); - } - if ( IVAS_ERR_OK != ivas_alloc_pppMem( &HrtfFastConv->rightBRIRReal, BINAURAL_CONVBANDS, HRTF_LS_CHANNELS, BINAURAL_NTAPS_MAX, allocate_init_flag ) ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightBRIRReal" ); - } - if ( IVAS_ERR_OK != ivas_alloc_pppMem( &HrtfFastConv->rightBRIRImag, BINAURAL_CONVBANDS, HRTF_LS_CHANNELS, BINAURAL_NTAPS_MAX, allocate_init_flag ) ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightBRIRImag" ); - } -#endif } } diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index 22bd0d277e..a95443d236 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -1260,17 +1260,12 @@ typedef struct ivas_hrtfs_crend_structure typedef struct ivas_hrtfs_fastconv_struct { float FASTCONV_HOA3_latency_s; -#ifndef FIX_1123_FASTCONV_16BIT_FMT - float FASTCONV_HRIR_latency_s; -#endif float ***leftHRIRReal_HOA3; float ***leftHRIRImag_HOA3; float ***rightHRIRReal_HOA3; float ***rightHRIRImag_HOA3; -#ifdef FIX_1123_FASTCONV_16BIT_FMT float FASTCONV_HRIR_latency_s; -#endif float ***leftHRIRReal; float ***leftHRIRImag; float ***rightHRIRReal; @@ -1295,13 +1290,11 @@ typedef struct ivas_hrtfs_fastconv_struct float FASTCONV_FOA_latency_s; int16_t allocate_init_flag; /*Memory allocation flag 0: if the hrtf pointers are allocated at application level , 1: of allocated at ivas_binaural_hrtf_open() */ -#ifdef FIX_1123_FASTCONV_16BIT_FMT uint16_t ntaps_hrir; uint16_t ntaps_hrir_hoa3; uint16_t ntaps_hrir_hoa2; uint16_t ntaps_hrir_foa; uint16_t ntaps_brir; -#endif float fastconvReverberationTimes[CLDFB_NO_CHANNELS_MAX]; float fastconvReverberationEneCorrections[CLDFB_NO_CHANNELS_MAX]; diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index 339ff8e610..28f90b02ea 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -1425,15 +1425,11 @@ static ivas_error create_fastconv_HRTF_from_rawdata( char *hrtf_data_rptr; ivas_error error; Word16 factorQ; -#ifdef FIX_1123_FASTCONV_16BIT_FMT float scaleFactor; int16_t *ptW16; float latency_s; uint16_t ntaps; uint16_t nbchan; -#else - int32_t *ptW32; -#endif if ( hrtf_data == NULL ) { @@ -1442,7 +1438,6 @@ static ivas_error create_fastconv_HRTF_from_rawdata( ( *hHRTF )->allocate_init_flag = 0; -#ifdef FIX_1123_FASTCONV_16BIT_FMT hrtf_data_rptr = hrtf_data; /* latency_s Q factor*/ @@ -1514,12 +1509,6 @@ static ivas_error create_fastconv_HRTF_from_rawdata( { return IVAS_ERROR( IVAS_ERR_BITSTREAM_READER_INVALID_FORMAT, "Can not read hrtf binary file : wrong render type and input config couple " ); } -#else - if ( BINAURAL_NTAPS != *( (uint16_t *) ( hrtf_data_rptr ) ) ) - { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (BINAURAL_NTAPS)" ); - } -#endif if ( rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV ) { @@ -1539,698 +1528,290 @@ static ivas_error create_fastconv_HRTF_from_rawdata( { return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "renderer type not compliant" ); } -#ifndef FIX_1123_FASTCONV_16BIT_FMT - hrtf_data_rptr = hrtf_data; -#endif /* HRIR */ if ( rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_COMBINED ) { -#ifndef FIX_1123_FASTCONV_16BIT_FMT - /* latency_s Q factor*/ - factorQ = *( (Word16 *) ( hrtf_data_rptr ) ); - hrtf_data_rptr += sizeof( Word16 ); - - /* latency_s */ - ( *hHRTF )->FASTCONV_HRIR_latency_s = ( *( (Word32 *) ( hrtf_data_rptr ) ) ) * powf( 2.f, -1.f * factorQ ); - hrtf_data_rptr += sizeof( Word32 ); - - if ( BINAURAL_CONVBANDS != *( (uint16_t *) ( hrtf_data_rptr ) ) ) - { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (BINAURAL_CONVBANDS)" ); - } - hrtf_data_rptr += sizeof( uint16_t ); - - if ( HRTF_LS_CHANNELS != *( (uint16_t *) ( hrtf_data_rptr ) ) ) - { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (HRTF_LS_CHANNELS)" ); - } - hrtf_data_rptr += sizeof( uint16_t ); - - if ( BINAURAL_NTAPS != *( (uint16_t *) ( hrtf_data_rptr ) ) ) - { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (BINAURAL_NTAPS)" ); - } - hrtf_data_rptr += sizeof( uint16_t ); -#endif /* HRIR Q factor*/ factorQ = *( (Word16 *) ( hrtf_data_rptr ) ); hrtf_data_rptr += sizeof( Word16 ); -#ifdef FIX_1123_FASTCONV_16BIT_FMT scaleFactor = powf( 2.f, -1.f * factorQ ); -#endif for ( i = 0; i < BINAURAL_CONVBANDS; i++ ) { for ( j = 0; j < HRTF_LS_CHANNELS; j++ ) { -#ifdef FIX_1123_FASTCONV_16BIT_FMT ptW16 = (Word16 *) hrtf_data_rptr; for ( k = 0; k < ( *hHRTF )->ntaps_hrir; k++ ) -#else - ptW32 = (Word32 *) hrtf_data_rptr; - for ( k = 0; k < BINAURAL_NTAPS; k++ ) -#endif { -#ifdef FIX_1123_FASTCONV_16BIT_FMT ( *hHRTF )->leftHRIRReal[i][j][k] = ptW16[k] * scaleFactor; -#else - ( *hHRTF )->leftHRIRReal[i][j][k] = (float) ptW32[k] * powf( 2.f, -1.f * (float) factorQ ); -#endif } -#ifdef FIX_1123_FASTCONV_16BIT_FMT hrtf_data_rptr += ( *hHRTF )->ntaps_hrir * sizeof( Word16 ); -#else - hrtf_data_rptr += BINAURAL_NTAPS * sizeof( int32_t ); -#endif } } for ( i = 0; i < BINAURAL_CONVBANDS; i++ ) { for ( j = 0; j < HRTF_LS_CHANNELS; j++ ) { -#ifdef FIX_1123_FASTCONV_16BIT_FMT ptW16 = (Word16 *) hrtf_data_rptr; for ( k = 0; k < ( *hHRTF )->ntaps_hrir; k++ ) -#else - ptW32 = (Word32 *) hrtf_data_rptr; - for ( k = 0; k < BINAURAL_NTAPS; k++ ) -#endif { -#ifdef FIX_1123_FASTCONV_16BIT_FMT ( *hHRTF )->leftHRIRImag[i][j][k] = ptW16[k] * scaleFactor; -#else - ( *hHRTF )->leftHRIRImag[i][j][k] = (float) ptW32[k] * powf( 2.f, -1.f * (float) factorQ ); -#endif } -#ifdef FIX_1123_FASTCONV_16BIT_FMT hrtf_data_rptr += ( *hHRTF )->ntaps_hrir * sizeof( Word16 ); -#else - hrtf_data_rptr += BINAURAL_NTAPS * sizeof( int32_t ); -#endif } } for ( i = 0; i < BINAURAL_CONVBANDS; i++ ) { for ( j = 0; j < HRTF_LS_CHANNELS; j++ ) { -#ifdef FIX_1123_FASTCONV_16BIT_FMT ptW16 = (Word16 *) hrtf_data_rptr; for ( k = 0; k < ( *hHRTF )->ntaps_hrir; k++ ) -#else - ptW32 = (Word32 *) hrtf_data_rptr; - for ( k = 0; k < BINAURAL_NTAPS; k++ ) -#endif { -#ifdef FIX_1123_FASTCONV_16BIT_FMT ( *hHRTF )->rightHRIRReal[i][j][k] = ptW16[k] * scaleFactor; -#else - ( *hHRTF )->rightHRIRReal[i][j][k] = (float) ptW32[k] * powf( 2.f, -1.f * (float) factorQ ); -#endif } -#ifdef FIX_1123_FASTCONV_16BIT_FMT hrtf_data_rptr += ( *hHRTF )->ntaps_hrir * sizeof( Word16 ); -#else - hrtf_data_rptr += BINAURAL_NTAPS * sizeof( int32_t ); -#endif } } for ( i = 0; i < BINAURAL_CONVBANDS; i++ ) { for ( j = 0; j < HRTF_LS_CHANNELS; j++ ) { -#ifdef FIX_1123_FASTCONV_16BIT_FMT ptW16 = (Word16 *) hrtf_data_rptr; for ( k = 0; k < ( *hHRTF )->ntaps_hrir; k++ ) -#else - ptW32 = (Word32 *) hrtf_data_rptr; - for ( k = 0; k < BINAURAL_NTAPS; k++ ) -#endif { -#ifdef FIX_1123_FASTCONV_16BIT_FMT ( *hHRTF )->rightHRIRImag[i][j][k] = ptW16[k] * scaleFactor; -#else - ( *hHRTF )->rightHRIRImag[i][j][k] = (float) ptW32[k] * powf( 2.f, -1.f * (float) factorQ ); -#endif } -#ifdef FIX_1123_FASTCONV_16BIT_FMT hrtf_data_rptr += ( *hHRTF )->ntaps_hrir * sizeof( Word16 ); -#else - hrtf_data_rptr += BINAURAL_NTAPS * sizeof( int32_t ); -#endif } } } else if ( rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_HOA3 ) { -#ifndef FIX_1123_FASTCONV_16BIT_FMT - /* latency_s Q factor*/ - factorQ = *( (Word16 *) ( hrtf_data_rptr ) ); - hrtf_data_rptr += sizeof( Word16 ); - - /* latency_s */ - ( *hHRTF )->FASTCONV_HOA3_latency_s = ( *( (Word32 *) ( hrtf_data_rptr ) ) ) * powf( 2.f, -1.f * factorQ ); - hrtf_data_rptr += sizeof( Word32 ); - - if ( BINAURAL_CONVBANDS != *( (uint16_t *) ( hrtf_data_rptr ) ) ) - { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (BINAURAL_CONVBANDS)" ); - } - hrtf_data_rptr += sizeof( uint16_t ); - - if ( HOA3_CHANNELS != *( (uint16_t *) ( hrtf_data_rptr ) ) ) - { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (HOA3_CHANNELS)" ); - } - hrtf_data_rptr += sizeof( uint16_t ); - - if ( BINAURAL_NTAPS_SBA != *( (uint16_t *) ( hrtf_data_rptr ) ) ) - { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (BINAURAL_NTAPS_SBA)" ); - } - hrtf_data_rptr += sizeof( uint16_t ); -#endif /* HRIR Q factor*/ factorQ = *( (Word16 *) ( hrtf_data_rptr ) ); hrtf_data_rptr += sizeof( Word16 ); -#ifdef FIX_1123_FASTCONV_16BIT_FMT scaleFactor = powf( 2.f, -1.f * factorQ ); -#endif for ( i = 0; i < BINAURAL_CONVBANDS; i++ ) { for ( j = 0; j < HOA3_CHANNELS; j++ ) { -#ifdef FIX_1123_FASTCONV_16BIT_FMT ptW16 = (Word16 *) hrtf_data_rptr; for ( k = 0; k < ( *hHRTF )->ntaps_hrir_hoa3; k++ ) -#else - ptW32 = (Word32 *) hrtf_data_rptr; - for ( k = 0; k < BINAURAL_NTAPS_SBA; k++ ) -#endif { -#ifdef FIX_1123_FASTCONV_16BIT_FMT ( *hHRTF )->leftHRIRReal_HOA3[i][j][k] = ptW16[k] * scaleFactor; -#else - ( *hHRTF )->leftHRIRReal_HOA3[i][j][k] = (float) ptW32[k] * powf( 2.f, -1.f * (float) factorQ ); -#endif } -#ifdef FIX_1123_FASTCONV_16BIT_FMT hrtf_data_rptr += ( *hHRTF )->ntaps_hrir_hoa3 * sizeof( Word16 ); -#else - hrtf_data_rptr += BINAURAL_NTAPS_SBA * sizeof( int32_t ); -#endif } } for ( i = 0; i < BINAURAL_CONVBANDS; i++ ) { for ( j = 0; j < HOA3_CHANNELS; j++ ) { -#ifdef FIX_1123_FASTCONV_16BIT_FMT ptW16 = (Word16 *) hrtf_data_rptr; for ( k = 0; k < ( *hHRTF )->ntaps_hrir_hoa3; k++ ) -#else - ptW32 = (Word32 *) hrtf_data_rptr; - for ( k = 0; k < BINAURAL_NTAPS_SBA; k++ ) -#endif { -#ifdef FIX_1123_FASTCONV_16BIT_FMT ( *hHRTF )->leftHRIRImag_HOA3[i][j][k] = ptW16[k] * scaleFactor; -#else - ( *hHRTF )->leftHRIRImag_HOA3[i][j][k] = (float) ptW32[k] * powf( 2.f, -1.f * (float) factorQ ); -#endif } -#ifdef FIX_1123_FASTCONV_16BIT_FMT hrtf_data_rptr += ( *hHRTF )->ntaps_hrir_hoa3 * sizeof( Word16 ); -#else - hrtf_data_rptr += BINAURAL_NTAPS_SBA * sizeof( int32_t ); -#endif } } for ( i = 0; i < BINAURAL_CONVBANDS; i++ ) { for ( j = 0; j < HOA3_CHANNELS; j++ ) { -#ifdef FIX_1123_FASTCONV_16BIT_FMT ptW16 = (Word16 *) hrtf_data_rptr; for ( k = 0; k < ( *hHRTF )->ntaps_hrir_hoa3; k++ ) -#else - ptW32 = (Word32 *) hrtf_data_rptr; - for ( k = 0; k < BINAURAL_NTAPS_SBA; k++ ) -#endif { -#ifdef FIX_1123_FASTCONV_16BIT_FMT ( *hHRTF )->rightHRIRReal_HOA3[i][j][k] = ptW16[k] * scaleFactor; -#else - ( *hHRTF )->rightHRIRReal_HOA3[i][j][k] = (float) ptW32[k] * powf( 2.f, -1.f * (float) factorQ ); -#endif } -#ifdef FIX_1123_FASTCONV_16BIT_FMT hrtf_data_rptr += ( *hHRTF )->ntaps_hrir_hoa3 * sizeof( Word16 ); -#else - hrtf_data_rptr += BINAURAL_NTAPS_SBA * sizeof( int32_t ); -#endif } } for ( i = 0; i < BINAURAL_CONVBANDS; i++ ) { for ( j = 0; j < HOA3_CHANNELS; j++ ) { -#ifdef FIX_1123_FASTCONV_16BIT_FMT ptW16 = (Word16 *) hrtf_data_rptr; for ( k = 0; k < ( *hHRTF )->ntaps_hrir_hoa3; k++ ) -#else - ptW32 = (Word32 *) hrtf_data_rptr; - for ( k = 0; k < BINAURAL_NTAPS_SBA; k++ ) -#endif { -#ifdef FIX_1123_FASTCONV_16BIT_FMT ( *hHRTF )->rightHRIRImag_HOA3[i][j][k] = ptW16[k] * scaleFactor; -#else - ( *hHRTF )->rightHRIRImag_HOA3[i][j][k] = (float) ptW32[k] * powf( 2.f, -1.f * (float) factorQ ); -#endif } -#ifdef FIX_1123_FASTCONV_16BIT_FMT hrtf_data_rptr += ( *hHRTF )->ntaps_hrir_hoa3 * sizeof( Word16 ); -#else - hrtf_data_rptr += BINAURAL_NTAPS_SBA * sizeof( int32_t ); -#endif } } } else if ( rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_HOA2 ) { -#ifndef FIX_1123_FASTCONV_16BIT_FMT - /* latency_s Q factor*/ - factorQ = *( (Word16 *) ( hrtf_data_rptr ) ); - hrtf_data_rptr += sizeof( Word16 ); - - /* latency_s */ - ( *hHRTF )->FASTCONV_HOA2_latency_s = ( *( (Word32 *) ( hrtf_data_rptr ) ) ) * powf( 2.f, -1.f * factorQ ); - hrtf_data_rptr += sizeof( Word32 ); - - if ( BINAURAL_CONVBANDS != *( (uint16_t *) ( hrtf_data_rptr ) ) ) - { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (BINAURAL_CONVBANDS)" ); - } - hrtf_data_rptr += sizeof( uint16_t ); - - if ( HOA2_CHANNELS != *( (uint16_t *) ( hrtf_data_rptr ) ) ) - { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (HOA2_CHANNELS)" ); - } - hrtf_data_rptr += sizeof( uint16_t ); - if ( BINAURAL_NTAPS_SBA != *( (uint16_t *) ( hrtf_data_rptr ) ) ) - { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (BINAURAL_NTAPS_SBA)" ); - } - hrtf_data_rptr += sizeof( uint16_t ); -#endif /* HRIR Q factor*/ factorQ = *( (Word16 *) ( hrtf_data_rptr ) ); hrtf_data_rptr += sizeof( Word16 ); -#ifdef FIX_1123_FASTCONV_16BIT_FMT scaleFactor = powf( 2.f, -1.f * factorQ ); -#endif for ( i = 0; i < BINAURAL_CONVBANDS; i++ ) { for ( j = 0; j < HOA2_CHANNELS; j++ ) { -#ifdef FIX_1123_FASTCONV_16BIT_FMT ptW16 = (Word16 *) hrtf_data_rptr; for ( k = 0; k < ( *hHRTF )->ntaps_hrir_hoa2; k++ ) -#else - ptW32 = (Word32 *) hrtf_data_rptr; - for ( k = 0; k < BINAURAL_NTAPS_SBA; k++ ) -#endif { -#ifdef FIX_1123_FASTCONV_16BIT_FMT ( *hHRTF )->leftHRIRReal_HOA2[i][j][k] = ptW16[k] * scaleFactor; -#else - ( *hHRTF )->leftHRIRReal_HOA2[i][j][k] = (float) ptW32[k] * powf( 2.f, -1.f * (float) factorQ ); -#endif } -#ifdef FIX_1123_FASTCONV_16BIT_FMT hrtf_data_rptr += ( *hHRTF )->ntaps_hrir_hoa2 * sizeof( Word16 ); -#else - hrtf_data_rptr += BINAURAL_NTAPS_SBA * sizeof( int32_t ); -#endif } } for ( i = 0; i < BINAURAL_CONVBANDS; i++ ) { for ( j = 0; j < HOA2_CHANNELS; j++ ) { -#ifdef FIX_1123_FASTCONV_16BIT_FMT ptW16 = (Word16 *) hrtf_data_rptr; for ( k = 0; k < ( *hHRTF )->ntaps_hrir_hoa2; k++ ) -#else - ptW32 = (Word32 *) hrtf_data_rptr; - for ( k = 0; k < BINAURAL_NTAPS_SBA; k++ ) -#endif { -#ifdef FIX_1123_FASTCONV_16BIT_FMT ( *hHRTF )->leftHRIRImag_HOA2[i][j][k] = ptW16[k] * scaleFactor; -#else - ( *hHRTF )->leftHRIRImag_HOA2[i][j][k] = (float) ptW32[k] * powf( 2.f, -1.f * (float) factorQ ); -#endif } -#ifdef FIX_1123_FASTCONV_16BIT_FMT hrtf_data_rptr += ( *hHRTF )->ntaps_hrir_hoa2 * sizeof( Word16 ); -#else - hrtf_data_rptr += BINAURAL_NTAPS_SBA * sizeof( int32_t ); -#endif } } for ( i = 0; i < BINAURAL_CONVBANDS; i++ ) { for ( j = 0; j < HOA2_CHANNELS; j++ ) { -#ifdef FIX_1123_FASTCONV_16BIT_FMT ptW16 = (Word16 *) hrtf_data_rptr; for ( k = 0; k < ( *hHRTF )->ntaps_hrir_hoa2; k++ ) -#else - ptW32 = (Word32 *) hrtf_data_rptr; - for ( k = 0; k < BINAURAL_NTAPS_SBA; k++ ) -#endif { -#ifdef FIX_1123_FASTCONV_16BIT_FMT ( *hHRTF )->rightHRIRReal_HOA2[i][j][k] = ptW16[k] * scaleFactor; -#else - ( *hHRTF )->rightHRIRReal_HOA2[i][j][k] = (float) ptW32[k] * powf( 2.f, -1.f * (float) factorQ ); -#endif } -#ifdef FIX_1123_FASTCONV_16BIT_FMT hrtf_data_rptr += ( *hHRTF )->ntaps_hrir_hoa2 * sizeof( Word16 ); -#else - hrtf_data_rptr += BINAURAL_NTAPS_SBA * sizeof( int32_t ); -#endif } } for ( i = 0; i < BINAURAL_CONVBANDS; i++ ) { for ( j = 0; j < HOA2_CHANNELS; j++ ) { -#ifdef FIX_1123_FASTCONV_16BIT_FMT ptW16 = (Word16 *) hrtf_data_rptr; for ( k = 0; k < ( *hHRTF )->ntaps_hrir_hoa2; k++ ) -#else - ptW32 = (Word32 *) hrtf_data_rptr; - for ( k = 0; k < BINAURAL_NTAPS_SBA; k++ ) -#endif { -#ifdef FIX_1123_FASTCONV_16BIT_FMT ( *hHRTF )->rightHRIRImag_HOA2[i][j][k] = ptW16[k] * scaleFactor; -#else - ( *hHRTF )->rightHRIRImag_HOA2[i][j][k] = (float) ptW32[k] * powf( 2.f, -1.f * (float) factorQ ); -#endif } -#ifdef FIX_1123_FASTCONV_16BIT_FMT hrtf_data_rptr += ( *hHRTF )->ntaps_hrir_hoa2 * sizeof( Word16 ); -#else - hrtf_data_rptr += BINAURAL_NTAPS_SBA * sizeof( int32_t ); -#endif } } } else if ( rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_FOA ) { -#ifndef FIX_1123_FASTCONV_16BIT_FMT - /* latency_s Q factor*/ - factorQ = *( (Word16 *) ( hrtf_data_rptr ) ); - hrtf_data_rptr += sizeof( Word16 ); - - /* latency_s */ - ( *hHRTF )->FASTCONV_FOA_latency_s = ( *( (Word32 *) ( hrtf_data_rptr ) ) ) * powf( 2.f, -1.f * factorQ ); - hrtf_data_rptr += sizeof( Word32 ); - - - if ( BINAURAL_CONVBANDS != *( (uint16_t *) ( hrtf_data_rptr ) ) ) - { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (BINAURAL_CONVBANDS)" ); - } - hrtf_data_rptr += sizeof( uint16_t ); - - if ( FOA_CHANNELS != *( (uint16_t *) ( hrtf_data_rptr ) ) ) - { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (FOA_CHANNELS)" ); - } - hrtf_data_rptr += sizeof( uint16_t ); - - if ( BINAURAL_NTAPS_SBA != *( (uint16_t *) ( hrtf_data_rptr ) ) ) - { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (BINAURAL_NTAPS_SBA)" ); - } - hrtf_data_rptr += sizeof( uint16_t ); -#endif /* HRIR Q factor*/ factorQ = *( (Word16 *) ( hrtf_data_rptr ) ); hrtf_data_rptr += sizeof( Word16 ); -#ifdef FIX_1123_FASTCONV_16BIT_FMT scaleFactor = powf( 2.f, -1.f * factorQ ); -#endif for ( i = 0; i < BINAURAL_CONVBANDS; i++ ) { for ( j = 0; j < FOA_CHANNELS; j++ ) { -#ifdef FIX_1123_FASTCONV_16BIT_FMT ptW16 = (Word16 *) hrtf_data_rptr; for ( k = 0; k < ( *hHRTF )->ntaps_hrir_foa; k++ ) -#else - ptW32 = (Word32 *) hrtf_data_rptr; - for ( k = 0; k < BINAURAL_NTAPS_SBA; k++ ) -#endif { -#ifdef FIX_1123_FASTCONV_16BIT_FMT ( *hHRTF )->leftHRIRReal_FOA[i][j][k] = ptW16[k] * scaleFactor; -#else - ( *hHRTF )->leftHRIRReal_FOA[i][j][k] = (float) ptW32[k] * powf( 2.f, -1.f * (float) factorQ ); -#endif } -#ifdef FIX_1123_FASTCONV_16BIT_FMT hrtf_data_rptr += ( *hHRTF )->ntaps_hrir_foa * sizeof( Word16 ); -#else - hrtf_data_rptr += BINAURAL_NTAPS_SBA * sizeof( int32_t ); -#endif } } for ( i = 0; i < BINAURAL_CONVBANDS; i++ ) { for ( j = 0; j < FOA_CHANNELS; j++ ) { -#ifdef FIX_1123_FASTCONV_16BIT_FMT ptW16 = (Word16 *) hrtf_data_rptr; for ( k = 0; k < ( *hHRTF )->ntaps_hrir_foa; k++ ) -#else - ptW32 = (Word32 *) hrtf_data_rptr; - for ( k = 0; k < BINAURAL_NTAPS_SBA; k++ ) -#endif { -#ifdef FIX_1123_FASTCONV_16BIT_FMT ( *hHRTF )->leftHRIRImag_FOA[i][j][k] = ptW16[k] * scaleFactor; -#else - ( *hHRTF )->leftHRIRImag_FOA[i][j][k] = (float) ptW32[k] * powf( 2.f, -1.f * (float) factorQ ); -#endif } -#ifdef FIX_1123_FASTCONV_16BIT_FMT hrtf_data_rptr += ( *hHRTF )->ntaps_hrir_foa * sizeof( Word16 ); -#else - hrtf_data_rptr += BINAURAL_NTAPS_SBA * sizeof( int32_t ); -#endif } } for ( i = 0; i < BINAURAL_CONVBANDS; i++ ) { for ( j = 0; j < FOA_CHANNELS; j++ ) { -#ifdef FIX_1123_FASTCONV_16BIT_FMT ptW16 = (Word16 *) hrtf_data_rptr; for ( k = 0; k < ( *hHRTF )->ntaps_hrir_foa; k++ ) -#else - ptW32 = (Word32 *) hrtf_data_rptr; - for ( k = 0; k < BINAURAL_NTAPS_SBA; k++ ) -#endif { -#ifdef FIX_1123_FASTCONV_16BIT_FMT ( *hHRTF )->rightHRIRReal_FOA[i][j][k] = ptW16[k] * scaleFactor; -#else - ( *hHRTF )->rightHRIRReal_FOA[i][j][k] = (float) ptW32[k] * powf( 2.f, -1.f * (float) factorQ ); -#endif } -#ifdef FIX_1123_FASTCONV_16BIT_FMT hrtf_data_rptr += ( *hHRTF )->ntaps_hrir_foa * sizeof( Word16 ); -#else - hrtf_data_rptr += BINAURAL_NTAPS_SBA * sizeof( int32_t ); -#endif } } for ( i = 0; i < BINAURAL_CONVBANDS; i++ ) { for ( j = 0; j < FOA_CHANNELS; j++ ) { -#ifdef FIX_1123_FASTCONV_16BIT_FMT ptW16 = (Word16 *) hrtf_data_rptr; for ( k = 0; k < ( *hHRTF )->ntaps_hrir_foa; k++ ) -#else - ptW32 = (Word32 *) hrtf_data_rptr; - for ( k = 0; k < BINAURAL_NTAPS_SBA; k++ ) -#endif { -#ifdef FIX_1123_FASTCONV_16BIT_FMT ( *hHRTF )->rightHRIRImag_FOA[i][j][k] = ptW16[k] * scaleFactor; -#else - ( *hHRTF )->rightHRIRImag_FOA[i][j][k] = (float) ptW32[k] * powf( 2.f, -1.f * (float) factorQ ); -#endif } -#ifdef FIX_1123_FASTCONV_16BIT_FMT hrtf_data_rptr += ( *hHRTF )->ntaps_hrir_foa * sizeof( Word16 ); -#else - hrtf_data_rptr += BINAURAL_NTAPS_SBA * sizeof( int32_t ); -#endif } } } /* BRIR */ else if ( rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV_ROOM && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_COMBINED ) { -#ifndef FIX_1123_FASTCONV_16BIT_FMT - /* latency_s Q factor*/ - factorQ = *( (Word16 *) ( hrtf_data_rptr ) ); - hrtf_data_rptr += sizeof( Word16 ); - - /* latency_s */ - ( *hHRTF )->FASTCONV_BRIR_latency_s = ( *( (Word32 *) ( hrtf_data_rptr ) ) ) * powf( 2.f, -1.f * factorQ ); - hrtf_data_rptr += sizeof( Word32 ); - - if ( BINAURAL_CONVBANDS != *( (uint16_t *) ( hrtf_data_rptr ) ) ) - { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (BINAURAL_CONVBANDS)" ); - } - hrtf_data_rptr += sizeof( uint16_t ); - - if ( HRTF_LS_CHANNELS != *( (uint16_t *) ( hrtf_data_rptr ) ) ) - { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (HRTF_LS_CHANNELS)" ); - } - hrtf_data_rptr += sizeof( uint16_t ); - - if ( BINAURAL_NTAPS_MAX != *( (uint16_t *) ( hrtf_data_rptr ) ) ) - { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (BINAURAL_NTAPS)" ); - } - hrtf_data_rptr += sizeof( uint16_t ); -#endif /* BRIR Q factor*/ factorQ = *( (Word16 *) ( hrtf_data_rptr ) ); hrtf_data_rptr += sizeof( Word16 ); -#ifdef FIX_1123_FASTCONV_16BIT_FMT scaleFactor = powf( 2.f, -1.f * factorQ ); -#endif for ( i = 0; i < BINAURAL_CONVBANDS; i++ ) { for ( j = 0; j < HRTF_LS_CHANNELS; j++ ) { -#ifdef FIX_1123_FASTCONV_16BIT_FMT ptW16 = (Word16 *) hrtf_data_rptr; for ( k = 0; k < ( *hHRTF )->ntaps_brir; k++ ) -#else - ptW32 = (Word32 *) hrtf_data_rptr; - for ( k = 0; k < BINAURAL_NTAPS_MAX; k++ ) -#endif { -#ifdef FIX_1123_FASTCONV_16BIT_FMT ( *hHRTF )->leftBRIRReal[i][j][k] = ptW16[k] * scaleFactor; -#else - ( *hHRTF )->leftBRIRReal[i][j][k] = (float) ptW32[k] * powf( 2.f, -1.f * (float) factorQ ); -#endif } -#ifdef FIX_1123_FASTCONV_16BIT_FMT hrtf_data_rptr += ( *hHRTF )->ntaps_brir * sizeof( Word16 ); -#else - hrtf_data_rptr += BINAURAL_NTAPS_MAX * sizeof( int32_t ); -#endif } } for ( i = 0; i < BINAURAL_CONVBANDS; i++ ) { for ( j = 0; j < HRTF_LS_CHANNELS; j++ ) { -#ifdef FIX_1123_FASTCONV_16BIT_FMT ptW16 = (Word16 *) hrtf_data_rptr; for ( k = 0; k < ( *hHRTF )->ntaps_brir; k++ ) -#else - ptW32 = (Word32 *) hrtf_data_rptr; - for ( k = 0; k < BINAURAL_NTAPS_MAX; k++ ) -#endif { -#ifdef FIX_1123_FASTCONV_16BIT_FMT ( *hHRTF )->leftBRIRImag[i][j][k] = ptW16[k] * scaleFactor; -#else - ( *hHRTF )->leftBRIRImag[i][j][k] = (float) ptW32[k] * powf( 2.f, -1.f * (float) factorQ ); -#endif } -#ifdef FIX_1123_FASTCONV_16BIT_FMT hrtf_data_rptr += ( *hHRTF )->ntaps_brir * sizeof( Word16 ); -#else - hrtf_data_rptr += BINAURAL_NTAPS_MAX * sizeof( int32_t ); -#endif } } for ( i = 0; i < BINAURAL_CONVBANDS; i++ ) { for ( j = 0; j < HRTF_LS_CHANNELS; j++ ) { -#ifdef FIX_1123_FASTCONV_16BIT_FMT ptW16 = (Word16 *) hrtf_data_rptr; for ( k = 0; k < ( *hHRTF )->ntaps_brir; k++ ) -#else - ptW32 = (Word32 *) hrtf_data_rptr; - for ( k = 0; k < BINAURAL_NTAPS_MAX; k++ ) -#endif { -#ifdef FIX_1123_FASTCONV_16BIT_FMT ( *hHRTF )->rightBRIRReal[i][j][k] = ptW16[k] * scaleFactor; -#else - ( *hHRTF )->rightBRIRReal[i][j][k] = (float) ptW32[k] * powf( 2.f, -1.f * (float) factorQ ); -#endif } -#ifdef FIX_1123_FASTCONV_16BIT_FMT hrtf_data_rptr += ( *hHRTF )->ntaps_brir * sizeof( Word16 ); -#else - hrtf_data_rptr += BINAURAL_NTAPS_MAX * sizeof( int32_t ); -#endif } } for ( i = 0; i < BINAURAL_CONVBANDS; i++ ) { for ( j = 0; j < HRTF_LS_CHANNELS; j++ ) { -#ifdef FIX_1123_FASTCONV_16BIT_FMT ptW16 = (Word16 *) hrtf_data_rptr; for ( k = 0; k < ( *hHRTF )->ntaps_brir; k++ ) -#else - ptW32 = (Word32 *) hrtf_data_rptr; - for ( k = 0; k < BINAURAL_NTAPS_MAX; k++ ) -#endif { -#ifdef FIX_1123_FASTCONV_16BIT_FMT ( *hHRTF )->rightBRIRImag[i][j][k] = ptW16[k] * scaleFactor; -#else - ( *hHRTF )->rightBRIRImag[i][j][k] = (float) ptW32[k] * powf( 2.f, -1.f * (float) factorQ ); -#endif } -#ifdef FIX_1123_FASTCONV_16BIT_FMT hrtf_data_rptr += ( *hHRTF )->ntaps_brir * sizeof( Word16 ); -#else - hrtf_data_rptr += BINAURAL_NTAPS_MAX * sizeof( int32_t ); -#endif } } @@ -2244,36 +1825,24 @@ static ivas_error create_fastconv_HRTF_from_rawdata( /* fastconvReverberationTimes Q factor*/ factorQ = *( (Word16 *) ( hrtf_data_rptr ) ); hrtf_data_rptr += sizeof( Word16 ); -#ifdef FIX_1123_FASTCONV_16BIT_FMT scaleFactor = powf( 2.f, -1.f * factorQ ); -#endif ptW16 = (int16_t *) hrtf_data_rptr; for ( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) { -#ifdef FIX_1123_FASTCONV_16BIT_FMT ( *hHRTF )->fastconvReverberationTimes[j] = ptW16[j] * powf( 2.f, -1.f * factorQ ); -#else - ( *hHRTF )->fastconvReverberationTimes[j] = (float) ptW16[j] * scaleFactor; -#endif } hrtf_data_rptr += CLDFB_NO_CHANNELS_MAX * sizeof( int16_t ); /* fastconvReverberationEneCorrections Q factor */ factorQ = *( (Word16 *) ( hrtf_data_rptr ) ); hrtf_data_rptr += sizeof( Word16 ); -#ifdef FIX_1123_FASTCONV_16BIT_FMT scaleFactor = powf( 2.f, -1.f * factorQ ); -#endif ptW16 = (int16_t *) hrtf_data_rptr; for ( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) { -#ifdef FIX_1123_FASTCONV_16BIT_FMT ( *hHRTF )->fastconvReverberationEneCorrections[j] = ptW16[j] * powf( 2.f, -1.f * factorQ ); -#else - ( *hHRTF )->fastconvReverberationEneCorrections[j] = (float) ptW16[j] * scaleFactor; -#endif } hrtf_data_rptr += CLDFB_NO_CHANNELS_MAX * sizeof( int16_t ); } diff --git a/scripts/binauralRenderer_interface/generate_crend_ivas_tables_from_sofa.c b/scripts/binauralRenderer_interface/generate_crend_ivas_tables_from_sofa.c index 764cd4fabe..5c64af8f6d 100644 --- a/scripts/binauralRenderer_interface/generate_crend_ivas_tables_from_sofa.c +++ b/scripts/binauralRenderer_interface/generate_crend_ivas_tables_from_sofa.c @@ -128,13 +128,8 @@ void usage_gen_crend_tables( void ); void get_ls_layout_config( AUDIO_CONFIG ls_layout_config, struct ivas_layout_config *ls_struct ); int generate_crend_ivas_tables_from_sofa( const char *sofa_file_path, ConfigReader *cfgReader ); void update_h_file( HRTFS_DATA *hrtf, struct ivas_layout_config lscfg, const int32_t samplerate, const int16_t frame_len ); -#ifdef FIX_1123_CREND_FLTFX_BE void update_c_file( HRTFS_DATA *hrtf, struct ivas_layout_config lscfg, const int32_t samplerate, const int16_t frame_len, int16_t factorQ[3] ); void update_c_file_with_reverb( float *pEner_l, float *pEner_r, float *pCoherence, int16_t *pEner_l_fx, int16_t *pEner_r_fx, int16_t *pCoherence_fx, int16_t factorQ, const int32_t samplerate, const int16_t len ); -#else -void update_c_file( HRTFS_DATA *hrtf, struct ivas_layout_config lscfg, const int32_t samplerate, const int16_t frame_len ); -void update_c_file_with_reverb( float *pEner_l, float *pEner_r, float *pCoherence, const int32_t samplerate, const int16_t len ); -#endif void update_h_file_with_reverb( const int32_t samplerate ); int generate_reverb_ivas_tables_from_sofa( const char *file_path ); @@ -1286,24 +1281,14 @@ int generate_crend_ivas_tables_from_sofa( const char *file_path, ConfigReader *c } -#ifdef FIX_1123_CREND_FLTFX_BE int16_t factorQ[3]; make_fx_be( &hrtf_data, lscfg, sample_rates[indSR], frame_len, factorQ ); -#endif if ( lib_rend_path != NULL ) { update_h_file( &hrtf_data, lscfg, sample_rates[indSR], frame_len ); -#ifdef FIX_1123_CREND_FLTFX_BE update_c_file( &hrtf_data, lscfg, sample_rates[indSR], frame_len, factorQ ); -#else - update_c_file( &hrtf_data, lscfg, sample_rates[indSR], frame_len ); -#endif } -#if !defined( FIX_1123_CREND_FLTFX_BE ) - int16_t factorQ[3]; - make_fx_be( &hrtf_data, lscfg, sample_rates[indSR], frame_len, factorQ ); -#endif if ( binary_file_path != NULL ) { if ( write_binary_file( &hrtf_data, lscfg, sample_rates[indSR], frame_len, factorQ ) != IVAS_ERR_OK ) @@ -1870,7 +1855,6 @@ int generate_reverb_ivas_tables_from_sofa( const char *file_path ) ivas_reverb_get_hrtf_set_properties( pHrtf_set_l_re, pHrtf_set_l_im, pHrtf_set_r_re, pHrtf_set_r_im, IVAS_AUDIO_CONFIG_5_1, sofa_M, nr_fc_fft_filter, nr_fc_fft_filter, p_avg_lr, &p_avg_lr[nr_fc_fft_filter], pCoherence ); -#ifdef FIX_1123_CREND_FLTFX_BE make_reverb_fx_be( p_avg_lr, &p_avg_lr[nr_fc_fft_filter], pCoherence, sample_rates[indSR], &factorQ ); for ( i = 0; i < nr_fc_fft_filter; i++ ) { @@ -1878,25 +1862,11 @@ int generate_reverb_ivas_tables_from_sofa( const char *file_path ) p_avg_lr_fx[i + nr_fc_fft_filter] = float2int16_t( p_avg_lr[i + nr_fc_fft_filter], factorQ ); pCoherence_fx[i] = float2int16_t( pCoherence[i], factorQ ); } -#endif if ( lib_rend_path != NULL ) { update_h_file_with_reverb( sample_rates[indSR] ); -#ifdef FIX_1123_CREND_FLTFX_BE update_c_file_with_reverb( p_avg_lr, &p_avg_lr[nr_fc_fft_filter], pCoherence, p_avg_lr_fx, &p_avg_lr_fx[nr_fc_fft_filter], pCoherence_fx, factorQ, sample_rates[indSR], nr_fc_fft_filter ); -#else - update_c_file_with_reverb( p_avg_lr, &p_avg_lr[nr_fc_fft_filter], pCoherence, sample_rates[indSR], nr_fc_fft_filter ); -#endif } -#if !defined( FIX_1123_CREND_FLTFX_BE ) - make_reverb_fx_be( p_avg_lr, &p_avg_lr[nr_fc_fft_filter], pCoherence, sample_rates[indSR], &factorQ ); - for ( i = 0; i < nr_fc_fft_filter; i++ ) - { - p_avg_lr_fx[i] = float2int16_t( p_avg_lr[i], factorQ ); - p_avg_lr_fx[i + nr_fc_fft_filter] = float2int16_t( p_avg_lr[i + nr_fc_fft_filter], factorQ ); - pCoherence_fx[i] = float2int16_t( pCoherence[i], factorQ ); - } -#endif if ( binary_file_path != NULL ) { if ( write_reverb_to_binary_file( p_avg_lr, &p_avg_lr[nr_fc_fft_filter], pCoherence, factorQ, sample_rates[indSR] ) != IVAS_ERR_OK ) @@ -2179,11 +2149,7 @@ void write_array_int16_t_to_file( FILE *fp, int16_t *vec, int32_t size_vec, int3 /*---------------------------------------------------------------------* *update_c_file_with_reverb(); *---------------------------------------------------------------------*/ -#ifdef FIX_1123_CREND_FLTFX_BE void update_c_file_with_reverb( float *pEner_l, float *pEner_r, float *pCoherence, int16_t *pEner_l_fx, int16_t *pEner_r_fx, int16_t *pCoherence_fx, int16_t factorQ, const int32_t samplerate, const int16_t len ) -#else -void update_c_file_with_reverb( float *pEner_l, float *pEner_r, float *pCoherence, const int32_t samplerate, const int16_t len ) -#endif { char len_str[26] = "LR_IAC_LENGTH_NR_FC"; if ( samplerate == 16000 ) @@ -2239,11 +2205,7 @@ void update_c_file_with_reverb( float *pEner_l, float *pEner_r, float *pCoherenc /*---------------------------------------------------------------------* *update_c_file(); *---------------------------------------------------------------------*/ -#ifdef FIX_1123_CREND_FLTFX_BE void update_c_file( HRTFS_DATA *hrtf, struct ivas_layout_config lscfg, const int32_t samplerate, const int16_t frame_len, int16_t factorQ[3] ) -#else -void update_c_file( HRTFS_DATA *hrtf, struct ivas_layout_config lscfg, const int32_t samplerate, const int16_t frame_len ) -#endif { if ( c_file_path == NULL ) -- GitLab From 26880763a4803191d06f706a908497771ac5e87a Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 11 Sep 2024 17:25:43 +0200 Subject: [PATCH 10/29] [cleanup] accept FIX_RETURN --- lib_com/options.h | 1 - lib_dec/ivas_binRenderer_internal.c | 5 ----- lib_rend/ivas_dirac_dec_binaural_functions.c | 5 ----- 3 files changed, 11 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 752c596568..72f5689d3f 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -170,7 +170,6 @@ #define TMP_FIX_1119_SPLIT_RENDERING_VOIP /* FhG: Add error check for unsupported config: split rendering with VoIP mode */ #define FIX_POINT_ROM_CONST /* Ora: issue #1150 HRTF ROM tables should be defined as 'const'*/ -#define FIX_RETURN /* VA: fix location of function returns */ #define FIX_1135_EXT_RENDERER_HANDLES /* VA: issue 1135: Memory usage reduction in external renderer: Allocate only handles that are really needed. */ #define FIX_1158_FASTCONV_REVERB_HRTF /* Philips: issue 1158: Rendering with FastConv to BINAURAL_ROOM_REVERB uses BRIR convolution instead of HRTF */ #define FIX_1166_TDREND_DIV0 /* FhG,Eri: issue 1166: potential divide by zero in TD Renderer */ diff --git a/lib_dec/ivas_binRenderer_internal.c b/lib_dec/ivas_binRenderer_internal.c index 186e3816ce..6de77455cc 100644 --- a/lib_dec/ivas_binRenderer_internal.c +++ b/lib_dec/ivas_binRenderer_internal.c @@ -807,13 +807,8 @@ static ivas_error ivas_binaural_hrtf_open( *hHrtfFastConv = HrtfFastConv; -#ifdef FIX_RETURN return IVAS_ERR_OK; -#endif } -#ifndef FIX_RETURN - return IVAS_ERR_OK; -#endif } diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index 19f6c7e554..1d63b23d09 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -412,13 +412,8 @@ ivas_error ivas_dirac_dec_binaural_copy_hrtfs( *hHrtfParambin = hrtfParambin; -#ifdef FIX_RETURN return IVAS_ERR_OK; -#endif } -#ifndef FIX_RETURN - return IVAS_ERR_OK; -#endif } -- GitLab From 9d9a506bb098f52334c50af762a0b667f846a9fe Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 11 Sep 2024 17:26:46 +0200 Subject: [PATCH 11/29] [cleanup] accept FIX_1135_EXT_RENDERER_HANDLES --- apps/renderer.c | 14 ----- lib_com/options.h | 1 - lib_dec/lib_dec.c | 7 --- lib_rend/lib_rend.c | 139 -------------------------------------------- lib_rend/lib_rend.h | 2 - 5 files changed, 163 deletions(-) diff --git a/apps/renderer.c b/apps/renderer.c index cfbc27df37..52d6e81d09 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -169,10 +169,8 @@ typedef struct char customHrtfFilePath[RENDERER_MAX_CLI_ARG_LENGTH]; char renderConfigFilePath[RENDERER_MAX_CLI_ARG_LENGTH]; int8_t orientation_tracking; -#ifdef FIX_1135_EXT_RENDERER_HANDLES int16_t Opt_Headrotation; int16_t Opt_ExternalOrientation; -#endif int16_t nonDiegeticPan; float nonDiegeticPanGain; IVAS_REND_COMPLEXITY_LEVEL complexityLevel; @@ -886,11 +884,7 @@ int main( const int16_t frameSize_smpls = (int16_t) ( ( args.render_framesize ) * args.sampleRate * 5 / ( 1000 ) ); -#ifdef FIX_1135_EXT_RENDERER_HANDLES if ( ( error = IVAS_REND_Open( &hIvasRend, args.sampleRate, args.outConfig.audioConfig, !isEmptyString( args.customHrtfFilePath ), args.nonDiegeticPan, args.nonDiegeticPanGain, args.Opt_Headrotation, args.Opt_ExternalOrientation, (int16_t) args.render_framesize ) ) != IVAS_ERR_OK ) -#else - if ( ( error = IVAS_REND_Open( &hIvasRend, args.sampleRate, args.outConfig.audioConfig, !isEmptyString( args.customHrtfFilePath ), args.nonDiegeticPan, args.nonDiegeticPanGain, (int16_t) args.render_framesize ) ) != IVAS_ERR_OK ) -#endif { fprintf( stderr, "Error opening renderer handle: %s\n", ivas_error_to_string( error ) ); exit( -1 ); @@ -2518,10 +2512,8 @@ static CmdlnArgs defaultArgs( clearString( args.renderConfigFilePath ); clearString( args.externalOrientationFilePath ); -#ifdef FIX_1135_EXT_RENDERER_HANDLES args.Opt_Headrotation = 0; args.Opt_ExternalOrientation = 0; -#endif args.orientation_tracking = IVAS_HEAD_ORIENT_TRK_NONE; args.nonDiegeticPan = 0; @@ -2611,9 +2603,7 @@ static void parseOption( break; case CmdLnOptionId_trajFile: assert( numOptionValues == 1 ); -#ifdef FIX_1135_EXT_RENDERER_HANDLES args->Opt_Headrotation = 1; -#endif strncpy( args->headRotationFilePath, optionValues[0], RENDERER_MAX_CLI_ARG_LENGTH - 1 ); break; case CmdLnOptionId_outputMetadata: @@ -2634,9 +2624,7 @@ static void parseOption( break; case CmdLnOptionId_exteriorOrientationFile: assert( numOptionValues == 1 ); -#ifdef FIX_1135_EXT_RENDERER_HANDLES args->Opt_ExternalOrientation = 1; -#endif strncpy( args->externalOrientationFilePath, optionValues[0], RENDERER_MAX_CLI_ARG_LENGTH - 1 ); break; case CmdLnOptionId_customHrtfFile: @@ -2761,12 +2749,10 @@ static CmdlnArgs parseCmdlnArgs( exit( -1 ); /* Error printout handled by failing function */ } -#ifdef FIX_1135_EXT_RENDERER_HANDLES if ( args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { args.Opt_Headrotation = 1; } -#endif return args; } diff --git a/lib_com/options.h b/lib_com/options.h index 72f5689d3f..d0424d876a 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -170,7 +170,6 @@ #define TMP_FIX_1119_SPLIT_RENDERING_VOIP /* FhG: Add error check for unsupported config: split rendering with VoIP mode */ #define FIX_POINT_ROM_CONST /* Ora: issue #1150 HRTF ROM tables should be defined as 'const'*/ -#define FIX_1135_EXT_RENDERER_HANDLES /* VA: issue 1135: Memory usage reduction in external renderer: Allocate only handles that are really needed. */ #define FIX_1158_FASTCONV_REVERB_HRTF /* Philips: issue 1158: Rendering with FastConv to BINAURAL_ROOM_REVERB uses BRIR convolution instead of HRTF */ #define FIX_1166_TDREND_DIV0 /* FhG,Eri: issue 1166: potential divide by zero in TD Renderer */ #define FIX_835_PARAMMC_BUFFER_VALUES /* FhG: BASOP issue 835: wide range of buffer values for cx in ParamMC */ diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 61ba65f590..81c5e7fe65 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -510,13 +510,6 @@ ivas_error IVAS_DEC_Configure( hDecoderConfig->render_framesize = renderFramesize; } -#ifndef FIX_1135_EXT_RENDERER_HANDLES - if ( hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) - { - hDecoderConfig->Opt_Headrotation = TRUE; - } - -#endif /* Set decoder parameters to initial values */ if ( ( error = ivas_init_decoder_front( st_ivas ) ) != IVAS_ERR_OK ) { diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 3efafb6a29..8bcf544b76 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -204,11 +204,7 @@ struct IVAS_REND AUDIO_CONFIG outputConfig; EFAP_WRAPPER efapOutWrapper; IVAS_LSSETUP_CUSTOM_STRUCT customLsOut; -#ifdef FIX_1135_EXT_RENDERER_HANDLES SPLIT_REND_WRAPPER *splitRendWrapper; -#else - SPLIT_REND_WRAPPER splitRendWrapper; -#endif IVAS_REND_AudioBuffer splitRendEncBuffer; IVAS_REND_HeadRotData headRotData; @@ -1112,11 +1108,7 @@ static ivas_error initHeadRotation( static void closeHeadRotation( IVAS_REND_HANDLE hIvasRend ) { -#ifdef FIX_1135_EXT_RENDERER_HANDLES if ( hIvasRend != NULL && hIvasRend->headRotData.headRotEnabled && hIvasRend->headRotData.hOrientationTracker != NULL ) -#else - if ( ( hIvasRend != NULL ) && ( hIvasRend->headRotData.hOrientationTracker != NULL ) ) -#endif { free( hIvasRend->headRotData.hOrientationTracker ); } @@ -1225,11 +1217,7 @@ static rendering_context getRendCtx( ctx.pHeadRotData = &hIvasRend->headRotData; ctx.hhRendererConfig = &hIvasRend->hRendererConfig; ctx.pSplitRendBFI = &hIvasRend->splitRendBFI; -#ifdef FIX_1135_EXT_RENDERER_HANDLES ctx.pSplitRendWrapper = hIvasRend->splitRendWrapper; -#else - ctx.pSplitRendWrapper = &hIvasRend->splitRendWrapper; -#endif ctx.pCombinedOrientationData = &hIvasRend->hCombinedOrientationData; return ctx; @@ -1275,11 +1263,7 @@ static ivas_error initIsmMasaRendering( ivas_td_binaural_close( &inputIsm->tdRendWrapper.hBinRendererTd ); } -#ifdef FIX_1135_EXT_RENDERER_HANDLES ivas_rend_closeCrend( &inputIsm->crendWrapper, inputIsm->base.ctx.pSplitRendWrapper != NULL ? inputIsm->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses : 1 ); -#else - ivas_rend_closeCrend( &inputIsm->crendWrapper, inputIsm->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses ); -#endif ivas_reverb_close( &inputIsm->hReverb ); @@ -1383,11 +1367,7 @@ static ivas_error setRendInputActiveIsm( } else if ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) { -#ifdef FIX_1135_EXT_RENDERER_HANDLES if ( ( error = ivas_rend_openCrend( &inputIsm->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, hRendCfg, hrtfs->hSetOfHRTF, hrtfs->hHrtfStatistics, *rendCtx.pOutSampleRate, rendCtx.pSplitRendWrapper != NULL ? rendCtx.pSplitRendWrapper->multiBinPoseData.num_poses : 1 ) ) != IVAS_ERR_OK ) -#else - 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 ) -#endif { return error; } @@ -1410,11 +1390,7 @@ static void clearInputIsm( initRendInputBase( &inputIsm->base, IVAS_AUDIO_CONFIG_INVALID, 0, rendCtx, NULL, 0 ); /* Free input's internal handles */ -#ifdef FIX_1135_EXT_RENDERER_HANDLES ivas_rend_closeCrend( &inputIsm->crendWrapper, inputIsm->base.ctx.pSplitRendWrapper != NULL ? inputIsm->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses : 1 ); -#else - ivas_rend_closeCrend( &inputIsm->crendWrapper, inputIsm->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses ); -#endif ivas_reverb_close( &inputIsm->hReverb ); @@ -2112,11 +2088,7 @@ static ivas_error initMcBinauralRendering( /* if we need to use TD renderer and CREND was open, close it */ if ( useTDRend ) { -#ifdef FIX_1135_EXT_RENDERER_HANDLES ivas_rend_closeCrend( &inputMc->crendWrapper, inputMc->base.ctx.pSplitRendWrapper != NULL ? inputMc->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses : 1 ); -#else - ivas_rend_closeCrend( &inputMc->crendWrapper, inputMc->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses ); -#endif } if ( !reconfigureFlag || ( !useTDRend && outConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB && inputMc->hReverb != NULL ) ) @@ -2208,11 +2180,7 @@ static ivas_error initMcMasaRendering( ivas_td_binaural_close( &inputMc->tdRendWrapper.hBinRendererTd ); } -#ifdef FIX_1135_EXT_RENDERER_HANDLES ivas_rend_closeCrend( &inputMc->crendWrapper, inputMc->base.ctx.pSplitRendWrapper != NULL ? inputMc->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses : 1 ); -#else - ivas_rend_closeCrend( &inputMc->crendWrapper, inputMc->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses ); -#endif ivas_reverb_close( &inputMc->hReverb ); @@ -2397,11 +2365,7 @@ static void clearInputMc( efap_free_data( &inputMc->efapInWrapper.hEfap ); } -#ifdef FIX_1135_EXT_RENDERER_HANDLES ivas_rend_closeCrend( &inputMc->crendWrapper, inputMc->base.ctx.pSplitRendWrapper != NULL ? inputMc->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses : 1 ); -#else - ivas_rend_closeCrend( &inputMc->crendWrapper, inputMc->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses ); -#endif ivas_reverb_close( &inputMc->hReverb ); @@ -2574,11 +2538,7 @@ static ivas_error updateSbaPanGains( } else { -#ifdef FIX_1135_EXT_RENDERER_HANDLES if ( ( error = ivas_rend_openCrend( &inputSba->crendWrapper, inConfig, outConfig, hRendCfg, hMixconv, hHrtfStatistics, *rendCtx.pOutSampleRate, rendCtx.pSplitRendWrapper != NULL ? rendCtx.pSplitRendWrapper->multiBinPoseData.num_poses : 1 ) ) != IVAS_ERR_OK ) -#else - if ( ( error = ivas_rend_openCrend( &inputSba->crendWrapper, inConfig, outConfig, hRendCfg, hMixconv, hHrtfStatistics, *rendCtx.pOutSampleRate, rendCtx.pSplitRendWrapper->multiBinPoseData.num_poses ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -2590,11 +2550,7 @@ static ivas_error updateSbaPanGains( return error; } -#ifdef FIX_1135_EXT_RENDERER_HANDLES if ( ( error = ivas_rend_openCrend( &inputSba->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, hRendCfg, hMixconv, hHrtfStatistics, *rendCtx.pOutSampleRate, rendCtx.pSplitRendWrapper != NULL ? rendCtx.pSplitRendWrapper->multiBinPoseData.num_poses : 1 ) ) != IVAS_ERR_OK ) -#else - 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 ) -#endif { return error; } @@ -2626,11 +2582,7 @@ static ivas_error initSbaMasaRendering( { ivas_error error; -#ifdef FIX_1135_EXT_RENDERER_HANDLES ivas_rend_closeCrend( &inputSba->crendWrapper, inputSba->base.ctx.pSplitRendWrapper != NULL ? inputSba->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses : 1 ); -#else - ivas_rend_closeCrend( &inputSba->crendWrapper, inputSba->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses ); -#endif if ( ( error = ivas_dirac_ana_open( &inputSba->hDirAC, inSampleRate ) ) != IVAS_ERR_OK ) { @@ -2708,11 +2660,7 @@ static void clearInputSba( initRendInputBase( &inputSba->base, IVAS_AUDIO_CONFIG_INVALID, 0, rendCtx, NULL, 0 ); /* Free input's internal handles */ -#ifdef FIX_1135_EXT_RENDERER_HANDLES ivas_rend_closeCrend( &inputSba->crendWrapper, rendCtx.pSplitRendWrapper != NULL ? rendCtx.pSplitRendWrapper->multiBinPoseData.num_poses : 1 ); -#else - ivas_rend_closeCrend( &inputSba->crendWrapper, rendCtx.pSplitRendWrapper->multiBinPoseData.num_poses ); -#endif if ( inputSba->cldfbRendWrapper.hCldfbRend != NULL ) { @@ -2810,10 +2758,8 @@ ivas_error IVAS_REND_Open( const bool asHrtfBinary, /* i : load hrtf binary file */ const int16_t nonDiegeticPan, /* i : non-diegetic object flag */ const float nonDiegeticPanGain, /* i : non-diegetic panning gain */ -#ifdef FIX_1135_EXT_RENDERER_HANDLES const int16_t Opt_Headrotation, /* i : indicates whether head-rotation is used */ const int16_t Opt_ExternalOrientation, /* i : indicates whether external orientations are used */ -#endif const int16_t num_subframes /* i : number of subframes */ ) { @@ -2869,46 +2815,34 @@ ivas_error IVAS_REND_Open( } /* Initialize headrotation data */ -#ifdef FIX_1135_EXT_RENDERER_HANDLES hIvasRend->headRotData.headRotEnabled = 0; if ( Opt_Headrotation ) { -#endif if ( ( error = initHeadRotation( hIvasRend ) ) != IVAS_ERR_OK ) { return error; } -#ifdef FIX_1135_EXT_RENDERER_HANDLES } -#endif /* Initialize external orientation data */ -#ifdef FIX_1135_EXT_RENDERER_HANDLES hIvasRend->hExternalOrientationData = NULL; if ( Opt_ExternalOrientation ) { -#endif if ( ( error = ivas_external_orientation_open( &( hIvasRend->hExternalOrientationData ), num_subframes ) ) != IVAS_ERR_OK ) { return error; } -#ifdef FIX_1135_EXT_RENDERER_HANDLES } -#endif /* Initilize combined orientation data */ -#ifdef FIX_1135_EXT_RENDERER_HANDLES hIvasRend->hCombinedOrientationData = NULL; if ( Opt_Headrotation || Opt_ExternalOrientation ) { -#endif if ( ( error = ivas_combined_orientation_open( &( hIvasRend->hCombinedOrientationData ), outputSampleRate, num_subframes ) ) != IVAS_ERR_OK ) { return error; } -#ifdef FIX_1135_EXT_RENDERER_HANDLES } -#endif /* Initialize EFAP */ if ( ( error = initEfap( &hIvasRend->efapOutWrapper, outConfig, &hIvasRend->customLsOut ) ) != IVAS_ERR_OK ) @@ -2918,7 +2852,6 @@ ivas_error IVAS_REND_Open( /* Initialize inputs */ -#ifdef FIX_1135_EXT_RENDERER_HANDLES hIvasRend->splitRendWrapper = NULL; if ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { @@ -2929,9 +2862,6 @@ ivas_error IVAS_REND_Open( isar_init_split_rend_handles( hIvasRend->splitRendWrapper ); } -#else - isar_init_split_rend_handles( &hIvasRend->splitRendWrapper ); -#endif hIvasRend->splitRendEncBuffer.data = NULL; for ( i = 0; i < RENDERER_MAX_ISM_INPUTS; ++i ) @@ -3023,17 +2953,13 @@ ivas_error IVAS_REND_Open( } } -#ifdef FIX_1135_EXT_RENDERER_HANDLES if ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) { -#endif if ( ( error = ivas_HRTF_statistics_init( &( hIvasRend->hHrtfs.hHrtfStatistics ), hIvasRend->sampleRateOut ) ) != IVAS_ERR_OK ) { return error; } -#ifdef FIX_1135_EXT_RENDERER_HANDLES } -#endif return IVAS_ERR_OK; } @@ -3546,11 +3472,7 @@ ivas_error IVAS_REND_AddInput( int16_t cldfb_in_flag; cldfb_in_flag = getCldfbRendFlag( hIvasRend, getAudioConfigType( inConfig ) ); -#ifdef FIX_1135_EXT_RENDERER_HANDLES if ( ( error = ivas_pre_rend_init( hIvasRend->splitRendWrapper, &hIvasRend->splitRendEncBuffer, &hIvasRend->hRendererConfig->split_rend_config, hIvasRend->headRotData, hIvasRend->sampleRateOut, hIvasRend->outputConfig, cldfb_in_flag, hIvasRend->num_subframes ) ) != IVAS_ERR_OK ) -#else - if ( ( error = ivas_pre_rend_init( &hIvasRend->splitRendWrapper, &hIvasRend->splitRendEncBuffer, &hIvasRend->hRendererConfig->split_rend_config, hIvasRend->headRotData, hIvasRend->sampleRateOut, hIvasRend->outputConfig, cldfb_in_flag, hIvasRend->num_subframes ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -3968,11 +3890,7 @@ ivas_error IVAS_REND_GetDelay( { if ( hIvasRend->inputsSba[i].base.inConfig != IVAS_AUDIO_CONFIG_INVALID ) { -#ifdef FIX_1135_EXT_RENDERER_HANDLES if ( hIvasRend->splitRendWrapper != NULL && hIvasRend->splitRendWrapper->hBinHrSplitPreRend != NULL ) -#else - if ( hIvasRend->splitRendWrapper.hBinHrSplitPreRend != NULL ) -#endif { if ( hIvasRend->hRendererConfig->split_rend_config.rendererSelection == ISAR_SPLIT_REND_RENDERER_SELECTION_FASTCONV ) { @@ -4474,22 +4392,14 @@ ivas_error IVAS_REND_FeedRenderConfig( { int16_t cldfb_in_flag; cldfb_in_flag = getCldfbRendFlag( hIvasRend, IVAS_REND_AUDIO_CONFIG_TYPE_UNKNOWN ); -#ifdef FIX_1135_EXT_RENDERER_HANDLES if ( hIvasRend->splitRendWrapper != NULL ) { ISAR_PRE_REND_close( hIvasRend->splitRendWrapper, &hIvasRend->splitRendEncBuffer ); free( hIvasRend->splitRendWrapper ); hIvasRend->splitRendWrapper = NULL; } -#else - ISAR_PRE_REND_close( &hIvasRend->splitRendWrapper, &hIvasRend->splitRendEncBuffer ); -#endif -#ifdef FIX_1135_EXT_RENDERER_HANDLES if ( ( error = ivas_pre_rend_init( hIvasRend->splitRendWrapper, &hIvasRend->splitRendEncBuffer, &hIvasRend->hRendererConfig->split_rend_config, hIvasRend->headRotData, hIvasRend->sampleRateOut, hIvasRend->outputConfig, cldfb_in_flag, hIvasRend->num_subframes ) ) != IVAS_ERR_OK ) -#else - if ( ( error = ivas_pre_rend_init( &hIvasRend->splitRendWrapper, &hIvasRend->splitRendEncBuffer, &hIvasRend->hRendererConfig->split_rend_config, hIvasRend->headRotData, hIvasRend->sampleRateOut, hIvasRend->outputConfig, cldfb_in_flag, hIvasRend->num_subframes ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -4646,12 +4556,10 @@ ivas_error IVAS_REND_SetOrientationTrackingMode( const IVAS_HEAD_ORIENT_TRK_T orientation_tracking /* i : Head orientation tracking type */ ) { -#ifdef FIX_1135_EXT_RENDERER_HANDLES if ( hIvasRend->headRotData.headRotEnabled == 0 ) { return IVAS_ERR_OK; } -#endif return ivas_orient_trk_SetTrackingType( hIvasRend->headRotData.hOrientationTracker, orientation_tracking ); } @@ -5285,11 +5193,7 @@ static ivas_error renderIsmToBinauralRoom( hCombinedOrientationData = ismInput->base.ctx.pCombinedOrientationData; combinedOrientationEnabled = 0; -#ifdef FIX_1135_EXT_RENDERER_HANDLES if ( *hCombinedOrientationData != NULL ) -#else - if ( hCombinedOrientationData != NULL ) -#endif { for ( subframe_idx = 0; subframe_idx < ( *hCombinedOrientationData )->num_subframes; subframe_idx++ ) { @@ -5903,11 +5807,7 @@ static ivas_error renderMcToBinaural( hCombinedOrientationData = mcInput->base.ctx.pCombinedOrientationData; combinedOrientationEnabled = 0; -#ifdef FIX_1135_EXT_RENDERER_HANDLES if ( *hCombinedOrientationData != NULL ) -#else - if ( hCombinedOrientationData != NULL ) -#endif { for ( subframe_idx = 0; subframe_idx < ( *hCombinedOrientationData )->num_subframes; subframe_idx++ ) { @@ -5996,11 +5896,7 @@ static ivas_error renderMcToBinauralRoom( hCombinedOrientationData = mcInput->base.ctx.pCombinedOrientationData; combinedOrientationEnabled = 0; -#ifdef FIX_1135_EXT_RENDERER_HANDLES if ( *hCombinedOrientationData != NULL ) -#else - if ( hCombinedOrientationData != NULL ) -#endif { for ( subframe_idx = 0; subframe_idx < ( *hCombinedOrientationData )->num_subframes; subframe_idx++ ) { @@ -6091,11 +5987,7 @@ static ivas_error renderMcCustomLsToBinauralRoom( hCombinedOrientationData = mcInput->base.ctx.pCombinedOrientationData; combinedOrientationEnabled = 0; -#ifdef FIX_1135_EXT_RENDERER_HANDLES if ( *hCombinedOrientationData != NULL ) -#else - if ( hCombinedOrientationData != NULL ) -#endif { for ( subframe_idx = 0; subframe_idx < ( *hCombinedOrientationData )->num_subframes; subframe_idx++ ) { @@ -6701,11 +6593,7 @@ static ivas_error renderSbaToBinaural( hCombinedOrientationData = sbaInput->base.ctx.pCombinedOrientationData; combinedOrientationEnabled = 0; -#ifdef FIX_1135_EXT_RENDERER_HANDLES if ( *hCombinedOrientationData != NULL ) -#else - if ( hCombinedOrientationData != NULL ) -#endif { for ( subframe_idx = 0; subframe_idx < ( *hCombinedOrientationData )->num_subframes; subframe_idx++ ) { @@ -6782,11 +6670,7 @@ static ivas_error renderSbaToBinauralRoom( hCombinedOrientationData = sbaInput->base.ctx.pCombinedOrientationData; combinedOrientationEnabled = 0; -#ifdef FIX_1135_EXT_RENDERER_HANDLES if ( *hCombinedOrientationData != NULL ) -#else - if ( hCombinedOrientationData != NULL ) -#endif { for ( subframe_idx = 0; subframe_idx < ( *hCombinedOrientationData )->num_subframes; subframe_idx++ ) { @@ -7527,19 +7411,10 @@ static ivas_error getSamplesInternal( ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) { int16_t num_poses_orig; -#ifdef FIX_1135_EXT_RENDERER_HANDLES num_poses_orig = hIvasRend->splitRendWrapper->multiBinPoseData.num_poses; -#else - num_poses_orig = hIvasRend->splitRendWrapper.multiBinPoseData.num_poses; -#endif outAudio = hIvasRend->splitRendEncBuffer; -#ifdef FIX_1135_EXT_RENDERER_HANDLES ISAR_PRE_REND_GetMultiBinPoseData( &hIvasRend->hRendererConfig->split_rend_config, &hIvasRend->splitRendWrapper->multiBinPoseData, hIvasRend->headRotData.sr_pose_pred_axis ); assert( num_poses_orig == hIvasRend->splitRendWrapper->multiBinPoseData.num_poses && "number of poses should not change dynamically" ); -#else - ISAR_PRE_REND_GetMultiBinPoseData( &hIvasRend->hRendererConfig->split_rend_config, &hIvasRend->splitRendWrapper.multiBinPoseData, hIvasRend->headRotData.sr_pose_pred_axis ); - assert( num_poses_orig == hIvasRend->splitRendWrapper.multiBinPoseData.num_poses && "number of poses should not change dynamically" ); -#endif /* Clear output buffer for split rendering bitstream */ set_zero( outAudio.data, outAudio.config.numChannels * outAudio.config.numSamplesPerChannel ); @@ -7604,11 +7479,7 @@ static ivas_error getSamplesInternal( } } -#ifdef FIX_1135_EXT_RENDERER_HANDLES if ( ( error = ISAR_PRE_REND_MultiBinToSplitBinaural( hIvasRend->splitRendWrapper, -#else - if ( ( error = ISAR_PRE_REND_MultiBinToSplitBinaural( &hIvasRend->splitRendWrapper, -#endif hIvasRend->headRotData.headPositions[0], hIvasRend->hRendererConfig->split_rend_config.splitRendBitRate, hIvasRend->hRendererConfig->split_rend_config.codec, @@ -7780,16 +7651,12 @@ void IVAS_REND_Close( ivas_limiter_close( &hIvasRend->hLimiter ); /* Split binaural rendering */ -#ifdef FIX_1135_EXT_RENDERER_HANDLES if ( hIvasRend->splitRendWrapper != NULL ) { ISAR_PRE_REND_close( hIvasRend->splitRendWrapper, &hIvasRend->splitRendEncBuffer ); free( hIvasRend->splitRendWrapper ); hIvasRend->splitRendWrapper = NULL; } -#else - ISAR_PRE_REND_close( &hIvasRend->splitRendWrapper, &hIvasRend->splitRendEncBuffer ); -#endif closeHeadRotation( hIvasRend ); @@ -8437,9 +8304,7 @@ static ivas_error ivas_masa_ext_rend_parambin_init( int32_t output_Fs; RENDERER_TYPE renderer_type; int16_t j, k, bin; -#ifdef FIX_1135_EXT_RENDERER_HANDLES int16_t num_poses; -#endif float binCenterFreq, tmpFloat; ivas_error error; float frequency_axis[CLDFB_NO_CHANNELS_MAX]; @@ -8454,7 +8319,6 @@ static ivas_error ivas_masa_ext_rend_parambin_init( nBins = inputMasa->hMasaExtRend->hSpatParamRendCom->num_freq_bands; renderer_type = inputMasa->hMasaExtRend->renderer_type; -#ifdef FIX_1135_EXT_RENDERER_HANDLES num_poses = 1; if ( inputMasa->base.ctx.pSplitRendWrapper != NULL ) { @@ -8462,9 +8326,6 @@ static ivas_error ivas_masa_ext_rend_parambin_init( } for ( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) -#else - for ( pos_idx = 0; pos_idx < inputMasa->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses; pos_idx++ ) -#endif { hDiracDecBin = inputMasa->hMasaExtRend->hDiracDecBin[pos_idx]; diff --git a/lib_rend/lib_rend.h b/lib_rend/lib_rend.h index 299e4ede26..5886ad769c 100644 --- a/lib_rend/lib_rend.h +++ b/lib_rend/lib_rend.h @@ -113,10 +113,8 @@ ivas_error IVAS_REND_Open( const bool asHrtfBinary, /* i : load hrtf binary file */ const int16_t nonDiegeticPan, /* i : non-diegetic object flag */ const float nonDiegeticPanGain, /* i : non-diegetic panning gain */ -#ifdef FIX_1135_EXT_RENDERER_HANDLES const int16_t Opt_Headrotation, /* i : indicates whether head-rotation is used */ const int16_t Opt_ExternalOrientation, /* i : indicates whether external orientations are used */ -#endif const int16_t num_subframes /* i : number of subframes */ ); -- GitLab From 1fc62bf4dea6184b9967621a87ade7bf23a21f60 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 11 Sep 2024 17:27:37 +0200 Subject: [PATCH 12/29] [cleanup] accept FIX_1166_TDREND_DIV0 --- lib_com/options.h | 1 - lib_rend/ivas_objectRenderer_hrFilt.c | 5 ----- 2 files changed, 6 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index d0424d876a..67bb44a81e 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -171,7 +171,6 @@ #define FIX_POINT_ROM_CONST /* Ora: issue #1150 HRTF ROM tables should be defined as 'const'*/ #define FIX_1158_FASTCONV_REVERB_HRTF /* Philips: issue 1158: Rendering with FastConv to BINAURAL_ROOM_REVERB uses BRIR convolution instead of HRTF */ -#define FIX_1166_TDREND_DIV0 /* FhG,Eri: issue 1166: potential divide by zero in TD Renderer */ #define FIX_835_PARAMMC_BUFFER_VALUES /* FhG: BASOP issue 835: wide range of buffer values for cx in ParamMC */ #define FIX_1161_REDUCE_OMASA_HEAP /* VA: reduction of OMASA heap memory */ diff --git a/lib_rend/ivas_objectRenderer_hrFilt.c b/lib_rend/ivas_objectRenderer_hrFilt.c index 386415afe4..b1f7f11636 100644 --- a/lib_rend/ivas_objectRenderer_hrFilt.c +++ b/lib_rend/ivas_objectRenderer_hrFilt.c @@ -218,13 +218,8 @@ static void GenerateFilter( ESynL += modelEval->BMEnergiesL[modelEval->UseIndsL[i]].val; ESynR += modelEval->BMEnergiesR[modelEval->UseIndsR[i]].val; } -#ifdef FIX_1166_TDREND_DIV0 ScaleL = sqrtf( ETotL / ( ESynL + EPSILON ) ); ScaleR = sqrtf( ETotR / ( ESynR + EPSILON ) ); -#else - ScaleL = sqrtf( ETotL / ESynL ); - ScaleR = sqrtf( ETotR / ESynR ); -#endif /* Build using only the most energetic components. */ for ( k = model->iSecFirst[iSec]; k <= model->iSecLast[iSec]; k++ ) -- GitLab From fa80096293d3f3c67ede6656f9ae1bc104b05d91 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 11 Sep 2024 17:28:20 +0200 Subject: [PATCH 13/29] [cleanup] accept FIX_835_PARAMMC_BUFFER_VALUES --- lib_com/ivas_prot.h | 9 -- lib_com/options.h | 1 - lib_dec/ivas_dirac_output_synthesis_cov.c | 26 ---- lib_dec/ivas_mc_param_dec.c | 154 +--------------------- 4 files changed, 2 insertions(+), 188 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 10d35eab49..acf7d6e0bd 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -4024,7 +4024,6 @@ void ivas_dirac_dec_output_synthesis_cov_close( ); void ivas_dirac_dec_output_synthesis_cov_param_mc_collect_slot( -#ifdef FIX_835_PARAMMC_BUFFER_VALUES float *RealBuffer, /* i : input channel filter bank samples (real part) */ float *ImagBuffer, /* i : input channel filter bank samples (imaginary part */ float cx[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS], /* o : accumulated input covariance (real part) */ @@ -4032,14 +4031,6 @@ void ivas_dirac_dec_output_synthesis_cov_param_mc_collect_slot( const int16_t param_band, /* i : parameter band */ PARAM_MC_DEC_HANDLE hParamMC, /* i : handle to Parametric MC state */ const int16_t nchan_in /* i : number of input channels */ -#else - float *RealBuffer, /* i : input channel filter bank samples (real part) */ - float *ImagBuffer, /* i : input channel filter bank samples (imaginary part) */ - float cx[PARAM_MC_MAX_PARAMETER_BANDS][PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS], /* o : accumulated input covariance (real part) */ - float cx_imag[PARAM_MC_MAX_PARAMETER_BANDS][PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS], /* o : accumulated input covariance (imaginary part) */ - PARAM_MC_DEC_HANDLE hParamMC, /* i : handle to Parametric MC state */ - const int16_t nchan_in /* i : number of input channels */ -#endif ); void ivas_dirac_dec_output_synthesis_cov_param_mc_synthesise_slot( diff --git a/lib_com/options.h b/lib_com/options.h index 67bb44a81e..f40c335c45 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -171,7 +171,6 @@ #define FIX_POINT_ROM_CONST /* Ora: issue #1150 HRTF ROM tables should be defined as 'const'*/ #define FIX_1158_FASTCONV_REVERB_HRTF /* Philips: issue 1158: Rendering with FastConv to BINAURAL_ROOM_REVERB uses BRIR convolution instead of HRTF */ -#define FIX_835_PARAMMC_BUFFER_VALUES /* FhG: BASOP issue 835: wide range of buffer values for cx in ParamMC */ #define FIX_1161_REDUCE_OMASA_HEAP /* VA: reduction of OMASA heap memory */ /* #################### End BE switches ################################## */ diff --git a/lib_dec/ivas_dirac_output_synthesis_cov.c b/lib_dec/ivas_dirac_output_synthesis_cov.c index 2c95cf32ae..a4ae78f65f 100644 --- a/lib_dec/ivas_dirac_output_synthesis_cov.c +++ b/lib_dec/ivas_dirac_output_synthesis_cov.c @@ -312,7 +312,6 @@ void ivas_dirac_dec_output_synthesis_cov_close( *-------------------------------------------------------------------*/ void ivas_dirac_dec_output_synthesis_cov_param_mc_collect_slot( -#ifdef FIX_835_PARAMMC_BUFFER_VALUES float *RealBuffer, /* i : input channel filter bank samples (real part) */ float *ImagBuffer, /* i : input channel filter bank samples (imaginary part */ float cx[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS], /* o : accumulated input covariance (real part) */ @@ -320,21 +319,9 @@ void ivas_dirac_dec_output_synthesis_cov_param_mc_collect_slot( const int16_t param_band, /* i : parameter band */ PARAM_MC_DEC_HANDLE hParamMC, /* i : handle to Parametric MC state */ const int16_t nchan_in /* i : number of input channels */ -#else - float *RealBuffer, /* i : input channel filter bank samples (real part) */ - float *ImagBuffer, /* i : input channel filter bank samples (imaginary part */ - float cx[PARAM_MC_MAX_PARAMETER_BANDS][PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS], /* o : accumulated input covariance (real part) */ - float cx_imag[PARAM_MC_MAX_PARAMETER_BANDS][PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS], /* o : accumulated input covariance (imaginary part) */ - PARAM_MC_DEC_HANDLE hParamMC, /* i : handle to Parametric MC state */ - const int16_t nchan_in /* i : number of input channels */ -#endif ) { -#ifdef FIX_835_PARAMMC_BUFFER_VALUES int16_t band_idx, ch_idx; -#else - int16_t param_band, band_idx, ch_idx; -#endif int16_t brange[2]; float real_in_buffer[PARAM_MC_MAX_BANDS_IN_PARAMETER_BAND * MAX_TRANSPORT_CHANNELS]; float imag_in_buffer[PARAM_MC_MAX_BANDS_IN_PARAMETER_BAND * MAX_TRANSPORT_CHANNELS]; @@ -342,10 +329,6 @@ void ivas_dirac_dec_output_synthesis_cov_param_mc_collect_slot( float imag_buffer[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; /* estimate input covariance */ -#ifndef FIX_835_PARAMMC_BUFFER_VALUES - for ( param_band = 0; param_band < hParamMC->num_param_bands_synth; param_band++ ) - { -#endif /* Already stack here instead of in the process_subframe */ /* collect input frame */ @@ -366,19 +349,10 @@ void ivas_dirac_dec_output_synthesis_cov_param_mc_collect_slot( cmplx_matrix_square( real_in_buffer, imag_in_buffer, num_bands, nchan_in, real_buffer, imag_buffer ); -#ifdef FIX_835_PARAMMC_BUFFER_VALUES v_add( cx, real_buffer, cx, nchan_in * nchan_in ); v_add( cx_imag, imag_buffer, cx_imag, nchan_in * nchan_in ); -#else - v_add( cx[param_band], real_buffer, cx[param_band], nchan_in * nchan_in ); - v_add( cx_imag[param_band], imag_buffer, cx_imag[param_band], nchan_in * nchan_in ); -#endif - -#ifndef FIX_835_PARAMMC_BUFFER_VALUES - } -#endif return; } diff --git a/lib_dec/ivas_mc_param_dec.c b/lib_dec/ivas_mc_param_dec.c index 8b26bfbaba..461b3bcab0 100644 --- a/lib_dec/ivas_mc_param_dec.c +++ b/lib_dec/ivas_mc_param_dec.c @@ -86,11 +86,7 @@ static int16_t ivas_param_mc_uniform_decoder( float *seq, const int16_t sz_seq, static void ivas_param_mc_dequantize_cov( PARAM_MC_DEC_HANDLE hDirAC, float *ild_q, float *icc_q, const int16_t param_band_index, const int16_t nY_int, const PARAM_MC_SYNTHESIS_CONF synth_conf, const int16_t nY, const int16_t nX, float *Cx_state, float *Cproto, float *Cy_state ); -#ifdef FIX_835_PARAMMC_BUFFER_VALUES static void ivas_param_mc_get_mixing_matrices( PARAM_MC_DEC_HANDLE hParamMC, IVAS_OUTPUT_SETUP *hSynthesisOutputSetup, float Cx_in[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS], const int16_t param_band_idx, float *mixing_matrix[], float *mixing_matrix_res[], const int16_t nY_int, const PARAM_MC_SYNTHESIS_CONF synth_conf, const int16_t nX, const int16_t nY ); -#else -static void ivas_param_mc_get_mixing_matrices( PARAM_MC_DEC_HANDLE hParamMC, IVAS_OUTPUT_SETUP *hSynthesisOutputSetup, float Cx_in[PARAM_MC_MAX_PARAMETER_BANDS][PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS], float *mixing_matrix[], float *mixing_matrix_res[], const int16_t nY_int, const PARAM_MC_SYNTHESIS_CONF synth_conf, const int16_t nX, const int16_t nY ); -#endif static void param_mc_update_mixing_matrices( PARAM_MC_DEC_HANDLE hParamMC, float *mixing_matrix[], float *mixing_matrix_res[], const uint16_t nX, const uint16_t nY ); @@ -1336,9 +1332,7 @@ void ivas_param_mc_dec_digest_tc( int16_t nchan_transport; #else int16_t i, ch; -#ifdef FIX_835_PARAMMC_BUFFER_VALUES int16_t is_next_band, skip_next_band; -#endif int16_t slot_idx, param_band_idx; int16_t nchan_transport, nchan_out_transport, nchan_out_cldfb; int16_t nchan_out_cov; @@ -1346,16 +1340,11 @@ void ivas_param_mc_dec_digest_tc( #ifndef OBJ_EDITING_API /*CLDFB*/ -#ifdef FIX_835_PARAMMC_BUFFER_VALUES float *pCx, *pCx_imag; float cx[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; float cx_imag[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; float cx_next_band[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; float cx_imag_next_band[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; -#else - float cx[PARAM_MC_MAX_PARAMETER_BANDS][PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; - float cx_imag[PARAM_MC_MAX_PARAMETER_BANDS][PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; -#endif float real_part, imag_part; /* format converter */ int16_t channel_active[MAX_OUTPUT_CHANNELS]; @@ -1418,7 +1407,6 @@ void ivas_param_mc_dec_digest_tc( ivas_param_mc_dec_compute_interpolator( hParamMC->hMetadataPMC->bAttackPresent, hParamMC->hMetadataPMC->attackIndex, nCldfbSlots, hParamMC->h_output_synthesis_params.interpolator ); -#ifdef FIX_835_PARAMMC_BUFFER_VALUES /* loop over two bands at a time */ for ( param_band_idx = 0; param_band_idx < hParamMC->num_param_bands_synth; param_band_idx += 2 ) { @@ -1429,13 +1417,6 @@ void ivas_param_mc_dec_digest_tc( set_zero( cx_imag, PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS ); set_zero( cx_next_band, PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS ); set_zero( cx_imag_next_band, PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS ); -#else - for ( param_band_idx = 0; param_band_idx < PARAM_MC_MAX_PARAMETER_BANDS; param_band_idx++ ) - { - set_zero( cx[param_band_idx], PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS ); - set_zero( cx_imag[param_band_idx], PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS ); - } -#endif #endif /* slot loop for gathering the input data */ @@ -1443,7 +1424,7 @@ void ivas_param_mc_dec_digest_tc( { if ( st_ivas->hDecoderConfig->Opt_tsm ) { -#if defined( FIX_835_PARAMMC_BUFFER_VALUES ) && !defined( OBJ_EDITING_API ) +#if !defined( OBJ_EDITING_API ) if ( param_band_idx == 0 ) /* only run cldfbAna once */ { #endif @@ -1458,84 +1439,55 @@ void ivas_param_mc_dec_digest_tc( mvr2r( RealBuffer, &hParamMC->Cldfb_RealBuffer_tc[slot_idx * hParamMC->num_freq_bands * nchan_transport + ch * hParamMC->num_freq_bands], hParamMC->num_freq_bands ); mvr2r( ImagBuffer, &hParamMC->Cldfb_ImagBuffer_tc[slot_idx * hParamMC->num_freq_bands * nchan_transport + ch * hParamMC->num_freq_bands], hParamMC->num_freq_bands ); } -#if defined( FIX_835_PARAMMC_BUFFER_VALUES ) && !defined( OBJ_EDITING_API ) +#if !defined( OBJ_EDITING_API ) } #endif } #ifndef OBJ_EDITING_API if ( slot_idx >= 2 * hParamMC->hMetadataPMC->attackIndex ) { -#ifdef FIX_835_PARAMMC_BUFFER_VALUES for ( is_next_band = 0; is_next_band < 2; is_next_band++ ) { if ( is_next_band && skip_next_band ) { continue; } -#endif ivas_dirac_dec_output_synthesis_cov_param_mc_collect_slot( &hParamMC->Cldfb_RealBuffer_tc[slot_idx * hParamMC->num_freq_bands * nchan_transport], &hParamMC->Cldfb_ImagBuffer_tc[slot_idx * hParamMC->num_freq_bands * nchan_transport], -#ifdef FIX_835_PARAMMC_BUFFER_VALUES is_next_band ? cx_next_band : cx, is_next_band ? cx_imag_next_band : cx_imag, param_band_idx + is_next_band, -#else - cx, - cx_imag, -#endif hParamMC, nchan_transport ); -#ifdef FIX_835_PARAMMC_BUFFER_VALUES } -#endif } #endif } #ifndef OBJ_EDITING_API /* map from complex input covariance to real values */ -#ifdef FIX_835_PARAMMC_BUFFER_VALUES for ( is_next_band = 0; is_next_band < 2; is_next_band++ ) { if ( is_next_band && skip_next_band ) { continue; } -#else - for ( param_band_idx = 0; param_band_idx < hParamMC->num_param_bands_synth; param_band_idx++ ) - { -#endif /* Cx for transport channels */ -#ifdef FIX_835_PARAMMC_BUFFER_VALUES pCx = is_next_band ? &cx_next_band[0] : &cx[0]; pCx_imag = is_next_band ? &cx_imag_next_band[0] : &cx_imag[0]; -#endif for ( i = 0; i < nchan_transport * nchan_transport; i++ ) { -#ifdef FIX_835_PARAMMC_BUFFER_VALUES real_part = pCx[i]; imag_part = pCx_imag[i]; -#else - real_part = cx[param_band_idx][i]; - imag_part = cx_imag[param_band_idx][i]; -#endif /* (a-ib)(c+id) = ac + bd + i(ad-bc) */ if ( param_band_idx < hParamMC->max_param_band_abs_cov ) { -#ifdef FIX_835_PARAMMC_BUFFER_VALUES pCx[i] = sqrtf( real_part * real_part + imag_part * imag_part ); -#else - cx[param_band_idx][i] = sqrtf( real_part * real_part + imag_part * imag_part ); -#endif } else { -#ifdef FIX_835_PARAMMC_BUFFER_VALUES pCx[i] = real_part; -#else - cx[param_band_idx][i] = real_part; -#endif } } } @@ -1543,45 +1495,29 @@ void ivas_param_mc_dec_digest_tc( /* we have to do it similar to the encoder in case of attacks (i.e. accumulate two bands) to ensure correct DMX of the target covariance*/ if ( hParamMC->hMetadataPMC->bAttackPresent && ( hParamMC->synthesis_conf == PARAM_MC_SYNTH_LS_CONV_COV || hParamMC->synthesis_conf == PARAM_MC_SYNTH_MONO_STEREO ) ) { -#ifdef FIX_835_PARAMMC_BUFFER_VALUES v_add( cx, cx_next_band, cx, nchan_transport * nchan_transport ); mvr2r( cx, cx_next_band, nchan_transport * nchan_transport ); -#else - for ( param_band_idx = 0; param_band_idx < hParamMC->num_param_bands_synth; param_band_idx += 2 ) - { - v_add( cx[param_band_idx], cx[param_band_idx + 1], cx[param_band_idx], nchan_transport * nchan_transport ); - mvr2r( cx[param_band_idx], cx[param_band_idx + 1], nchan_transport * nchan_transport ); - } -#endif } -#ifdef FIX_835_PARAMMC_BUFFER_VALUES for ( is_next_band = 0; is_next_band < 2; is_next_band++ ) { if ( is_next_band && skip_next_band ) { continue; } -#endif /* generate mixing matrices */ ivas_param_mc_get_mixing_matrices( hParamMC, hSynthesisOutputSetup, -#ifdef FIX_835_PARAMMC_BUFFER_VALUES is_next_band ? cx_next_band : cx, param_band_idx + is_next_band, -#else - cx, -#endif hParamMC->h_output_synthesis_cov_state.mixing_matrix, hParamMC->h_output_synthesis_cov_state.mixing_matrix_res, nchan_out_transport, hParamMC->synthesis_conf, nchan_transport, nchan_out_cov ); -#ifdef FIX_835_PARAMMC_BUFFER_VALUES } } -#endif #endif pop_wmops(); @@ -1602,23 +1538,16 @@ void ivas_param_mc_dec_prepare_renderer( { PARAM_MC_DEC_HANDLE hParamMC; int16_t i; -#ifdef FIX_835_PARAMMC_BUFFER_VALUES int16_t is_next_band, skip_next_band; -#endif int16_t slot_idx, param_band_idx; int16_t nchan_transport, nchan_out_transport, nchan_out_cldfb; int16_t nchan_out_cov; /*CLDFB*/ -#ifdef FIX_835_PARAMMC_BUFFER_VALUES float *pCx, *pCx_imag; float cx[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; float cx_imag[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; float cx_next_band[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; float cx_imag_next_band[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; -#else - float cx[PARAM_MC_MAX_PARAMETER_BANDS][PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; - float cx_imag[PARAM_MC_MAX_PARAMETER_BANDS][PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; -#endif float real_part, imag_part; /* format converter */ int16_t channel_active[MAX_OUTPUT_CHANNELS]; @@ -1677,7 +1606,6 @@ void ivas_param_mc_dec_prepare_renderer( ivas_param_mc_dec_compute_interpolator( hParamMC->hMetadataPMC->bAttackPresent, hParamMC->hMetadataPMC->attackIndex, nCldfbSlots, hParamMC->h_output_synthesis_params.interpolator ); -#ifdef FIX_835_PARAMMC_BUFFER_VALUES /* loop over two bands at a time */ for ( param_band_idx = 0; param_band_idx < hParamMC->num_param_bands_synth; param_band_idx += 2 ) { @@ -1688,88 +1616,52 @@ void ivas_param_mc_dec_prepare_renderer( set_zero( cx_imag, PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS ); set_zero( cx_next_band, PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS ); set_zero( cx_imag_next_band, PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS ); -#else - for ( param_band_idx = 0; param_band_idx < PARAM_MC_MAX_PARAMETER_BANDS; param_band_idx++ ) - { - set_zero( cx[param_band_idx], PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS ); - set_zero( cx_imag[param_band_idx], PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS ); - } -#endif /* slot loop for gathering the input data */ for ( slot_idx = 0; slot_idx < nCldfbSlots; slot_idx++ ) { if ( slot_idx >= 2 * hParamMC->hMetadataPMC->attackIndex ) { -#ifdef FIX_835_PARAMMC_BUFFER_VALUES for ( is_next_band = 0; is_next_band < 2; is_next_band++ ) { if ( is_next_band && skip_next_band ) { continue; } -#endif ivas_dirac_dec_output_synthesis_cov_param_mc_collect_slot( &hParamMC->Cldfb_RealBuffer_tc[slot_idx * hParamMC->num_freq_bands * nchan_transport], &hParamMC->Cldfb_ImagBuffer_tc[slot_idx * hParamMC->num_freq_bands * nchan_transport], -#ifdef FIX_835_PARAMMC_BUFFER_VALUES is_next_band ? cx_next_band : cx, is_next_band ? cx_imag_next_band : cx_imag, param_band_idx + is_next_band, -#else - cx, - cx_imag, -#endif hParamMC, nchan_transport ); -#ifdef FIX_835_PARAMMC_BUFFER_VALUES } -#endif } } /* map from complex input covariance to real values */ -#ifdef FIX_835_PARAMMC_BUFFER_VALUES for ( is_next_band = 0; is_next_band < 2; is_next_band++ ) { if ( is_next_band && skip_next_band ) { continue; } -#else - for ( param_band_idx = 0; param_band_idx < hParamMC->num_param_bands_synth; param_band_idx++ ) - { -#endif /* Cx for transport channels */ -#ifdef FIX_835_PARAMMC_BUFFER_VALUES pCx = is_next_band ? &cx_next_band[0] : &cx[0]; pCx_imag = is_next_band ? &cx_imag_next_band[0] : &cx_imag[0]; -#endif for ( i = 0; i < nchan_transport * nchan_transport; i++ ) { -#ifdef FIX_835_PARAMMC_BUFFER_VALUES real_part = pCx[i]; imag_part = pCx_imag[i]; -#else - real_part = cx[param_band_idx][i]; - imag_part = cx_imag[param_band_idx][i]; -#endif /* (a-ib)(c+id) = ac + bd + i(ad-bc) */ if ( param_band_idx < hParamMC->max_param_band_abs_cov ) { -#ifdef FIX_835_PARAMMC_BUFFER_VALUES pCx[i] = sqrtf( real_part * real_part + imag_part * imag_part ); -#else - cx[param_band_idx][i] = sqrtf( real_part * real_part + imag_part * imag_part ); -#endif } else { -#ifdef FIX_835_PARAMMC_BUFFER_VALUES pCx[i] = real_part; -#else - cx[param_band_idx][i] = real_part; -#endif } } } @@ -1777,46 +1669,30 @@ void ivas_param_mc_dec_prepare_renderer( /* we have to do it similar to the encoder in case of attacks (i.e. accumulate two bands) to ensure correct DMX of the target covariance*/ if ( hParamMC->hMetadataPMC->bAttackPresent && ( hParamMC->synthesis_conf == PARAM_MC_SYNTH_LS_CONV_COV || hParamMC->synthesis_conf == PARAM_MC_SYNTH_MONO_STEREO ) ) { -#ifdef FIX_835_PARAMMC_BUFFER_VALUES v_add( cx, cx_next_band, cx, nchan_transport * nchan_transport ); mvr2r( cx, cx_next_band, nchan_transport * nchan_transport ); -#else - for ( param_band_idx = 0; param_band_idx < hParamMC->num_param_bands_synth; param_band_idx += 2 ) - { - v_add( cx[param_band_idx], cx[param_band_idx + 1], cx[param_band_idx], nchan_transport * nchan_transport ); - mvr2r( cx[param_band_idx], cx[param_band_idx + 1], nchan_transport * nchan_transport ); - } -#endif } -#ifdef FIX_835_PARAMMC_BUFFER_VALUES for ( is_next_band = 0; is_next_band < 2; is_next_band++ ) { if ( is_next_band && skip_next_band ) { continue; } -#endif /* generate mixing matrices */ ivas_param_mc_get_mixing_matrices( hParamMC, hSynthesisOutputSetup, -#ifdef FIX_835_PARAMMC_BUFFER_VALUES is_next_band ? cx_next_band : cx, param_band_idx + is_next_band, -#else - cx, -#endif hParamMC->h_output_synthesis_cov_state.mixing_matrix, hParamMC->h_output_synthesis_cov_state.mixing_matrix_res, nchan_out_transport, hParamMC->synthesis_conf, nchan_transport, nchan_out_cov ); -#ifdef FIX_835_PARAMMC_BUFFER_VALUES } } -#endif pop_wmops(); @@ -2499,7 +2375,6 @@ static void remove_lfe_from_cy( *------------------------------------------------------------------------*/ static void ivas_param_mc_get_mixing_matrices( -#ifdef FIX_835_PARAMMC_BUFFER_VALUES PARAM_MC_DEC_HANDLE hParamMC, /* i : Parametric MC handle */ IVAS_OUTPUT_SETUP *hSynthesisOutputSetup, float Cx_in[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS], /* i : input covariance for all parameter bands */ @@ -2510,22 +2385,8 @@ static void ivas_param_mc_get_mixing_matrices( const PARAM_MC_SYNTHESIS_CONF synth_config, /* i : Parametric MC synthesis config */ const int16_t nX, /* i : number of transport channels */ const int16_t nY_cov /* i : number of covariance synthesis output channels */ -#else - PARAM_MC_DEC_HANDLE hParamMC, /* i : Parametric MC handle */ - IVAS_OUTPUT_SETUP *hSynthesisOutputSetup, - float Cx_in[PARAM_MC_MAX_PARAMETER_BANDS][PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS], /* i : input covariance for all parameter bands */ - float *mixing_matrix[], /* o : direct mixing matrices for all parameter bands */ - float *mixing_matrix_res[], /* o : residual mixing matrices for all parameter bands */ - const int16_t nY_intern, /* i : number of channels in the transported format */ - const PARAM_MC_SYNTHESIS_CONF synth_config, /* i : Parametric MC synthesis config */ - const int16_t nX, /* i : number of transport channels */ - const int16_t nY_cov /* i : number of covariance synthesis output channels */ -#endif ) { -#ifndef FIX_835_PARAMMC_BUFFER_VALUES - int16_t param_band_idx; -#endif float Cx[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; float Cy[MAX_CICP_CHANNELS * MAX_CICP_CHANNELS]; float Cy_diag[MAX_CICP_CHANNELS]; @@ -2595,10 +2456,6 @@ static void ivas_param_mc_get_mixing_matrices( num_lfe_bands = PARAM_MC_MAX_BAND_LFE; } -#ifndef FIX_835_PARAMMC_BUFFER_VALUES - for ( param_band_idx = 0; param_band_idx < hParamMC->num_param_bands_synth; param_band_idx++ ) - { -#endif if ( hSynthesisOutputSetup->num_lfe > 0 && param_band_idx >= num_lfe_bands ) { remove_lfe = 1; @@ -2613,11 +2470,7 @@ static void ivas_param_mc_get_mixing_matrices( brange[0] = hParamMC->band_grouping[param_band_idx]; brange[1] = hParamMC->band_grouping[param_band_idx + 1]; -#ifdef FIX_835_PARAMMC_BUFFER_VALUES Cx_state = Cx_in; -#else - Cx_state = Cx_in[param_band_idx]; -#endif Cx_old_state = hParamMC->h_output_synthesis_cov_state.cx_old[param_band_idx]; Cy_old_state = hParamMC->h_output_synthesis_cov_state.cy_old[param_band_idx]; @@ -2761,9 +2614,6 @@ static void ivas_param_mc_get_mixing_matrices( { mvr2r( mixing_matrix_local, mixing_matrix[param_band_idx], nY_cov * nX ); } -#ifndef FIX_835_PARAMMC_BUFFER_VALUES - } -#endif return; } -- GitLab From dbf590e635820e9d0e9a94281b173dfb3064c591 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 11 Sep 2024 17:29:10 +0200 Subject: [PATCH 14/29] [cleanup] accept FIX_1161_REDUCE_OMASA_HEAP --- lib_com/ivas_prot.h | 4 -- lib_com/options.h | 1 - lib_dec/ivas_init_dec.c | 14 ------ lib_dec/ivas_ism_renderer.c | 31 ------------- lib_dec/ivas_masa_dec.c | 4 -- lib_dec/ivas_omasa_dec.c | 28 ------------ lib_enc/ivas_masa_enc.c | 89 ------------------------------------- lib_enc/ivas_omasa_enc.c | 36 --------------- lib_enc/ivas_stat_enc.h | 8 ---- 9 files changed, 215 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index acf7d6e0bd..afee4bc4d0 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -5775,11 +5775,7 @@ void ivas_omasa_combine_separate_ism_with_masa( const int16_t output_frame /* i : output frame length per channel */ ); -#ifdef FIX_1161_REDUCE_OMASA_HEAP ivas_error ivas_omasa_objects_delay_open( -#else -ivas_error ivas_omasa_render_objects_from_mix_open( -#endif Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ); diff --git a/lib_com/options.h b/lib_com/options.h index f40c335c45..87e7c2d41f 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -171,7 +171,6 @@ #define FIX_POINT_ROM_CONST /* Ora: issue #1150 HRTF ROM tables should be defined as 'const'*/ #define FIX_1158_FASTCONV_REVERB_HRTF /* Philips: issue 1158: Rendering with FastConv to BINAURAL_ROOM_REVERB uses BRIR convolution instead of HRTF */ -#define FIX_1161_REDUCE_OMASA_HEAP /* VA: reduction of OMASA heap memory */ /* #################### End BE switches ################################## */ diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index edd3ed644e..63f3cc026d 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -1898,31 +1898,21 @@ ivas_error ivas_init_decoder( } } -#ifdef FIX_1161_REDUCE_OMASA_HEAP /* Allocate memory for delay buffer within 'hMasaIsmData' */ if ( ( error = ivas_omasa_objects_delay_open( st_ivas ) ) != IVAS_ERR_OK ) { return error; } -#else - /* Allocate 'hIsmRendererData' handle and memory for delay buffer within 'hMasaIsmData' */ - if ( ( error = ivas_omasa_separate_object_renderer_open( st_ivas ) ) != IVAS_ERR_OK ) - { - return error; - } -#endif } if ( ( st_ivas->renderer_type == RENDERER_DIRAC ) && ( st_ivas->ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ || st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ || st_ivas->ism_mode == ISM_MASA_MODE_DISC ) ) { /* Allocate 'hIsmRendererData' handle and memory for delay buffer within 'hMasaIsmData' */ -#ifdef FIX_1161_REDUCE_OMASA_HEAP if ( ( error = ivas_omasa_objects_delay_open( st_ivas ) ) != IVAS_ERR_OK ) { return error; } -#endif if ( ( error = ivas_omasa_separate_object_renderer_open( st_ivas ) ) != IVAS_ERR_OK ) { return error; @@ -1932,11 +1922,7 @@ ivas_error ivas_init_decoder( if ( st_ivas->renderer_type == RENDERER_OMASA_OBJECT_EXT ) { /* Allocate 'hIsmRendererData' handle and memory for delay buffer within 'hMasaIsmData' */ -#ifdef FIX_1161_REDUCE_OMASA_HEAP if ( ( error = ivas_omasa_objects_delay_open( st_ivas ) ) != IVAS_ERR_OK ) -#else - if ( ( error = ivas_omasa_render_objects_from_mix_open( st_ivas ) ) != IVAS_ERR_OK ) -#endif { return error; } diff --git a/lib_dec/ivas_ism_renderer.c b/lib_dec/ivas_ism_renderer.c index daefbfbdcc..9b882089b1 100644 --- a/lib_dec/ivas_ism_renderer.c +++ b/lib_dec/ivas_ism_renderer.c @@ -379,14 +379,10 @@ ivas_error ivas_omasa_separate_object_renderer_open( init_interpolator_length = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC / MAX_PARAM_SPATIAL_SUBFRAMES ); interpolator_length = init_interpolator_length; -#ifdef FIX_1161_REDUCE_OMASA_HEAP if ( ( st_ivas->hIsmRendererData->interpolator = (float *) malloc( sizeof( float ) * init_interpolator_length ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for MASA ISM renderer interpolator \n" ) ); } -#else - st_ivas->hIsmRendererData->interpolator = (float *) malloc( sizeof( float ) * init_interpolator_length ); -#endif for ( i = 0; i < interpolator_length; i++ ) { @@ -394,33 +390,6 @@ ivas_error ivas_omasa_separate_object_renderer_open( } st_ivas->hIsmRendererData->interpolator_length = interpolator_length; -#ifndef FIX_1161_REDUCE_OMASA_HEAP - st_ivas->hMasaIsmData->delayBuffer_size = (int16_t) ( ( st_ivas->hDecoderConfig->output_Fs / 50 ) / MAX_PARAM_SPATIAL_SUBFRAMES ); - - if ( st_ivas->ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ || st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ ) - { - st_ivas->hMasaIsmData->delayBuffer_nchan = 1; - } - else - { - st_ivas->hMasaIsmData->delayBuffer_nchan = st_ivas->nchan_ism; - } - - if ( ( st_ivas->hMasaIsmData->delayBuffer = (float **) malloc( st_ivas->hMasaIsmData->delayBuffer_nchan * sizeof( float * ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for MASA ISM delay buffer \n" ) ); - } - - for ( i = 0; i < st_ivas->hMasaIsmData->delayBuffer_nchan; i++ ) - { - if ( ( st_ivas->hMasaIsmData->delayBuffer[i] = (float *) malloc( st_ivas->hMasaIsmData->delayBuffer_size * sizeof( float ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for MASA ISM delay buffer \n" ) ); - } - set_zero( st_ivas->hMasaIsmData->delayBuffer[i], st_ivas->hMasaIsmData->delayBuffer_size ); - } - -#endif return IVAS_ERR_OK; } diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index c18369d1f6..e4bdb46a98 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -869,11 +869,7 @@ static ivas_error ivas_masa_dec_config( for ( i = 0; i < st_ivas->hQMetaData->no_directions; i++ ) { st_ivas->hQMetaData->q_direction[i].cfg.nbands = hMasa->config.numCodingBands; -#ifdef FIX_1161_REDUCE_OMASA_HEAP st_ivas->hQMetaData->q_direction[i].cfg.nblocks = hMasa->config.joinedSubframes == TRUE ? 1 : MAX_PARAM_SPATIAL_SUBFRAMES; -#else - st_ivas->hQMetaData->q_direction[i].cfg.nblocks = hMasa->config.joinedSubframes == TRUE ? 1 : 4; -#endif if ( st_ivas->ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_MCMASA ) { diff --git a/lib_dec/ivas_omasa_dec.c b/lib_dec/ivas_omasa_dec.c index c38f9bc174..3ab3757688 100644 --- a/lib_dec/ivas_omasa_dec.c +++ b/lib_dec/ivas_omasa_dec.c @@ -445,19 +445,11 @@ ivas_error ivas_omasa_dec_config( } } -#ifdef FIX_1161_REDUCE_OMASA_HEAP /* Allocate memory for delay buffer within 'hMasaIsmData' */ if ( ( error = ivas_omasa_objects_delay_open( st_ivas ) ) != IVAS_ERR_OK ) { return error; } -#else - /* Allocate 'hIsmRendererData' handle and memory for delay buffer within 'hMasaIsmData' */ - if ( ( error = ivas_omasa_separate_object_renderer_open( st_ivas ) ) != IVAS_ERR_OK ) - { - return error; - } -#endif } else { @@ -481,12 +473,10 @@ ivas_error ivas_omasa_dec_config( if ( st_ivas->ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ || st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ || st_ivas->ism_mode == ISM_MASA_MODE_DISC ) { /* Allocate 'hIsmRendererData' handle and memory for delay buffer within 'hMasaIsmData' */ -#ifdef FIX_1161_REDUCE_OMASA_HEAP if ( ( error = ivas_omasa_objects_delay_open( st_ivas ) ) != IVAS_ERR_OK ) { return error; } -#endif if ( ( error = ivas_omasa_separate_object_renderer_open( st_ivas ) ) != IVAS_ERR_OK ) { return error; @@ -513,11 +503,7 @@ ivas_error ivas_omasa_dec_config( DIRAC_CONFIG_FLAG common_rend_config_flag = st_ivas->hSpatParamRendCom == NULL ? DIRAC_OPEN : DIRAC_RECONFIGURE; /* Allocate 'hIsmRendererData' handle and memory for delay buffer within 'hMasaIsmData' */ -#ifdef FIX_1161_REDUCE_OMASA_HEAP if ( ( error = ivas_omasa_objects_delay_open( st_ivas ) ) != IVAS_ERR_OK ) -#else - if ( ( error = ivas_omasa_render_objects_from_mix_open( st_ivas ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -1120,7 +1106,6 @@ void ivas_omasa_combine_separate_ism_with_masa( } -#ifdef FIX_1161_REDUCE_OMASA_HEAP /*-------------------------------------------------------------------------* * ivas_omasa_objects_delay_open() * @@ -1128,21 +1113,11 @@ void ivas_omasa_combine_separate_ism_with_masa( *-------------------------------------------------------------------------*/ ivas_error ivas_omasa_objects_delay_open( -#else -/*-------------------------------------------------------------------------* - * ivas_omasa_render_objects_from_mix_open() - * - * Open structures, reserve memory, and init values. - *-------------------------------------------------------------------------*/ - -ivas_error ivas_omasa_render_objects_from_mix_open( -#endif Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ) { int16_t i; -#ifdef FIX_1161_REDUCE_OMASA_HEAP if ( st_ivas->ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ || st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ ) { st_ivas->hMasaIsmData->delayBuffer_nchan = 1; @@ -1151,9 +1126,6 @@ ivas_error ivas_omasa_render_objects_from_mix_open( { st_ivas->hMasaIsmData->delayBuffer_nchan = st_ivas->nchan_ism; } -#else - st_ivas->hMasaIsmData->delayBuffer_nchan = 1; -#endif st_ivas->hMasaIsmData->delayBuffer_size = (int16_t) ( ( st_ivas->hDecoderConfig->output_Fs / 50 ) / MAX_PARAM_SPATIAL_SUBFRAMES ); diff --git a/lib_enc/ivas_masa_enc.c b/lib_enc/ivas_masa_enc.c index 54d61abc55..44cafe4692 100644 --- a/lib_enc/ivas_masa_enc.c +++ b/lib_enc/ivas_masa_enc.c @@ -174,7 +174,6 @@ ivas_error ivas_masa_enc_open( hOmasaData->lp_noise_CPE = -1; hOmasaData->omasa_stereo_sw_cnt = OMASA_STEREO_SW_CNT_MAX; -#ifdef FIX_1161_REDUCE_OMASA_HEAP if ( st_ivas->ism_mode != ISM_MASA_MODE_DISC ) { if ( ( hOmasaData->hOmasaEnergy = (OMASA_ENCODER_ENERGY_HANDLE) malloc( sizeof( OMASA_ENCODER_ENERGY_STATE ) ) ) == NULL ) @@ -186,7 +185,6 @@ ivas_error ivas_masa_enc_open( { hOmasaData->hOmasaEnergy = NULL; } -#endif hMasa->data.hOmasaData = hOmasaData; } @@ -225,14 +223,12 @@ void ivas_masa_enc_close( if ( ( *hMasa )->data.hOmasaData != NULL ) { -#ifdef FIX_1161_REDUCE_OMASA_HEAP if ( ( *hMasa )->data.hOmasaData->hOmasaEnergy != NULL ) { free( ( *hMasa )->data.hOmasaData->hOmasaEnergy ); ( *hMasa )->data.hOmasaData->hOmasaEnergy = NULL; } -#endif free( ( *hMasa )->data.hOmasaData ); ( *hMasa )->data.hOmasaData = NULL; } @@ -838,11 +834,7 @@ ivas_error ivas_masa_enc_config( for ( i = 0; i < hQMetaData->no_directions; i++ ) { hQMetaData->q_direction[i].cfg.nbands = hMasa->config.numCodingBands; -#ifdef FIX_1161_REDUCE_OMASA_HEAP hQMetaData->q_direction[i].cfg.nblocks = hMasa->config.joinedSubframes == TRUE ? 1 : MAX_PARAM_SPATIAL_SUBFRAMES; -#else - hQMetaData->q_direction[i].cfg.nblocks = hMasa->config.joinedSubframes == TRUE ? 1 : 4; -#endif if ( ivas_format == MC_FORMAT ) { @@ -1355,11 +1347,7 @@ static void move_metadata_to_qmetadata( numCodingBands = hMasa->config.numCodingBands; numDirections = hMasa->config.numberOfDirections; -#ifdef FIX_1161_REDUCE_OMASA_HEAP numSf = hMasa->config.joinedSubframes == TRUE ? 1 : MAX_PARAM_SPATIAL_SUBFRAMES; -#else - numSf = hMasa->config.joinedSubframes == TRUE ? 1 : 4; -#endif hMeta = &( hMasa->masaMetadata ); for ( dir = 0; dir < numDirections; dir++ ) @@ -2655,17 +2643,11 @@ void ivas_merge_masa_metadata( float total_diff_nrg; float eneBand; float energyMerged[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; -#ifdef FIX_1161_REDUCE_OMASA_HEAP OMASA_ENCODER_ENERGY_HANDLE hOmasaEnergy = hMasa->data.hOmasaData->hOmasaEnergy; -#endif numCodingBands = hMasa->config.numCodingBands; numDirections = hMasa->config.numberOfDirections; -#ifdef FIX_1161_REDUCE_OMASA_HEAP numSf = hMasa->config.joinedSubframes == TRUE ? 1 : MAX_PARAM_SPATIAL_SUBFRAMES; -#else - numSf = hMasa->config.joinedSubframes == TRUE ? 1 : 4; -#endif hMeta = &( hMasa->masaMetadata ); for ( sf = 0; sf < numSf; sf++ ) @@ -2686,11 +2668,7 @@ void ivas_merge_masa_metadata( /* Compute energies */ eneBand = hMasa->data.energy[sf][band]; -#ifdef FIX_1161_REDUCE_OMASA_HEAP energyMerged[sf][band] = eneBand + hOmasaEnergy->energy_ism[sf][band]; -#else - energyMerged[sf][band] = eneBand + hMasa->data.hOmasaData->energy_ism[sf][band]; -#endif /* Compute weights */ energyTimesRatioMASA[0] = eneBand * hMeta->directional_meta[0].energy_ratio[sf][band]; @@ -2707,11 +2685,7 @@ void ivas_merge_masa_metadata( total_diff_nrg = eneBand * hMeta->common_meta.diffuse_to_total_ratio[sf][band]; /* criterion is mean of ISM ratio and new ratio */ -#ifdef FIX_1161_REDUCE_OMASA_HEAP energyTimesRatioISM = ( hOMasaMeta->directional_meta[0].energy_ratio[sf][band] + ( 1.0f - total_diff_nrg / ( EPSILON + eneBand + hOmasaEnergy->energy_ism[sf][band] ) ) ) / 2.0f * hMasa->data.hOmasaData->hOmasaEnergy->energy_ism[sf][band]; -#else - energyTimesRatioISM = ( hOMasaMeta->directional_meta[0].energy_ratio[sf][band] + ( 1.0f - total_diff_nrg / ( EPSILON + eneBand + hMasa->data.hOmasaData->energy_ism[sf][band] ) ) ) / 2.0f * hMasa->data.hOmasaData->energy_ism[sf][band]; -#endif /* Determine combined metadata based on the weights */ merge_dest = -1; @@ -2733,11 +2707,7 @@ void ivas_merge_masa_metadata( hMeta->directional_meta[merge_dest].elevation[sf][band] = hOMasaMeta->directional_meta[0].elevation[sf][band]; /* limit with the earlier direct-energy ratio */ -#ifdef FIX_1161_REDUCE_OMASA_HEAP dir_sum = 1.0f - total_diff_nrg / ( EPSILON + eneBand + hOmasaEnergy->energy_ism[sf][band] ); /* new dir ratio */ -#else - dir_sum = 1.0f - total_diff_nrg / ( EPSILON + eneBand + hMasa->data.hOmasaData->energy_ism[sf][band] ); /* new dir ratio */ -#endif hMeta->directional_meta[merge_dest].energy_ratio[sf][band] = min( dir_sum, hOMasaMeta->directional_meta[0].energy_ratio[sf][band] ); /* clip with original ISM dir */ hMeta->common_meta.diffuse_to_total_ratio[sf][band] = 1.0f - hMeta->directional_meta[merge_dest].energy_ratio[sf][band]; @@ -3452,9 +3422,7 @@ static void ivas_encode_masaism_metadata( int16_t tmp, rotate; int16_t n_ism_tmp, i; OMASA_ENCODER_DATA_HANDLE hOmasaData = hMasa->data.hOmasaData; -#ifdef FIX_1161_REDUCE_OMASA_HEAP OMASA_ENCODER_ENERGY_HANDLE hOmasaEnergy = hOmasaData->hOmasaEnergy; -#endif int16_t nbands_work; /* use the values from hQMetaData */ @@ -3465,11 +3433,7 @@ static void ivas_encode_masaism_metadata( { for ( sf = 0; sf < numSf; sf++ ) { -#ifdef FIX_1161_REDUCE_OMASA_HEAP if ( sum_f( hOmasaEnergy->energy_ism[sf], omasa_nbands ) == 0.0f ) -#else - if ( sum_f( hOmasaData->energy_ism[sf], omasa_nbands ) == 0.0f ) -#endif { hOmasaData->masa_to_total_energy_ratio[sf][0] = 1.0f; } @@ -3491,28 +3455,16 @@ static void ivas_encode_masaism_metadata( for ( band = 0; band < omasa_nbands; band++ ) { -#ifdef FIX_1161_REDUCE_OMASA_HEAP energy_ism += hOmasaEnergy->energy_ism[sf][band]; -#else - energy_ism += hOmasaData->energy_ism[sf][band]; -#endif for ( obj = 0; obj < nchan_ism; obj++ ) { -#ifdef FIX_1161_REDUCE_OMASA_HEAP energy_ism_ind[obj] += hOmasaEnergy->energy_ism[sf][band] * hOmasaEnergy->energy_ratio_ism[sf][band][obj]; -#else - energy_ism_ind[obj] += hOmasaData->energy_ism[sf][band] * hOmasaData->energy_ratio_ism[sf][band][obj]; -#endif } } for ( obj = 0; obj < nchan_ism; obj++ ) { -#ifdef FIX_1161_REDUCE_OMASA_HEAP hOmasaEnergy->energy_ratio_ism[sf][0][obj] = energy_ism_ind[obj] / energy_ism; -#else - hOmasaData->energy_ratio_ism[sf][0][obj] = energy_ism_ind[obj] / energy_ism; -#endif } hOmasaData->masa_to_total_energy_ratio[sf][0] = eneBand / ( eneBand + energy_ism + EPSILON ); } @@ -3529,18 +3481,10 @@ static void ivas_encode_masaism_metadata( } for ( sf = 0; sf < omasa_nblocks; sf++ ) { -#ifdef FIX_1161_REDUCE_OMASA_HEAP energy_ism += hOmasaEnergy->energy_ism[sf][band]; -#else - energy_ism += hOmasaData->energy_ism[sf][band]; -#endif for ( obj = 0; obj < nchan_ism; obj++ ) { -#ifdef FIX_1161_REDUCE_OMASA_HEAP energy_ism_ind[obj] += hOmasaEnergy->energy_ism[sf][band] * hOmasaEnergy->energy_ratio_ism[sf][band][obj]; -#else - energy_ism_ind[obj] += hOmasaData->energy_ism[sf][band] * hOmasaData->energy_ratio_ism[sf][band][obj]; -#endif } } @@ -3552,11 +3496,7 @@ static void ivas_encode_masaism_metadata( { for ( obj = 0; obj < nchan_ism; obj++ ) { -#ifdef FIX_1161_REDUCE_OMASA_HEAP hOmasaEnergy->energy_ratio_ism[0][band][obj] = energy_ism_ind[obj] / energy_ism; -#else - hOmasaData->energy_ratio_ism[0][band][obj] = energy_ism_ind[obj] / energy_ism; -#endif } brange[0] = hMasa->data.band_mapping[band]; brange[1] = hMasa->data.band_mapping[band + 1]; @@ -3578,11 +3518,7 @@ static void ivas_encode_masaism_metadata( for ( obj = 0; obj < nchan_ism; obj++ ) { -#ifdef FIX_1161_REDUCE_OMASA_HEAP hOmasaEnergy->energy_ratio_ism[0][band][obj] = hOmasaEnergy->energy_ratio_ism[0][nbands_work - 1][obj]; -#else - hOmasaData->energy_ratio_ism[0][band][obj] = hOmasaData->energy_ratio_ism[0][nbands_work - 1][obj]; -#endif } } } @@ -3592,11 +3528,7 @@ static void ivas_encode_masaism_metadata( { for ( band = 0; band < nbands_work; band++ ) { -#ifdef FIX_1161_REDUCE_OMASA_HEAP if ( hOmasaEnergy->energy_ism[sf][band] == 0.0f ) -#else - if ( hOmasaData->energy_ism[sf][band] == 0.0f ) -#endif { hOmasaData->masa_to_total_energy_ratio[sf][band] = 1.0f; } @@ -3610,11 +3542,7 @@ static void ivas_encode_masaism_metadata( { eneBand += hMasa->data.energy[sf][bin]; } -#ifdef FIX_1161_REDUCE_OMASA_HEAP hOmasaData->masa_to_total_energy_ratio[sf][band] = eneBand / ( eneBand + hOmasaEnergy->energy_ism[sf][band] + EPSILON ); -#else - hOmasaData->masa_to_total_energy_ratio[sf][band] = eneBand / ( eneBand + hOmasaData->energy_ism[sf][band] + EPSILON ); -#endif } } for ( band = nbands_work; band < numCodingBands; band++ ) @@ -3623,11 +3551,7 @@ static void ivas_encode_masaism_metadata( for ( obj = 0; obj < nchan_ism; obj++ ) { -#ifdef FIX_1161_REDUCE_OMASA_HEAP hOmasaEnergy->energy_ratio_ism[sf][band][obj] = hOmasaEnergy->energy_ratio_ism[sf][nbands_work - 1][obj]; -#else - hOmasaData->energy_ratio_ism[sf][band][obj] = hOmasaData->energy_ratio_ism[sf][nbands_work - 1][obj]; -#endif } } } @@ -3649,13 +3573,8 @@ static void ivas_encode_masaism_metadata( { for ( obj = 0; obj < nchan_ism; obj++ ) { -#ifdef FIX_1161_REDUCE_OMASA_HEAP assert( ( hOmasaEnergy->energy_ratio_ism[sf][band][obj] >= 0 ) && ( hOmasaEnergy->energy_ratio_ism[sf][band][obj] <= 1 ) ); ratio_ism[band][obj] = hOmasaEnergy->energy_ratio_ism[sf][band][obj]; -#else - assert( ( hOmasaData->energy_ratio_ism[sf][band][obj] >= 0 ) && ( hOmasaData->energy_ratio_ism[sf][band][obj] <= 1 ) ); - ratio_ism[band][obj] = hOmasaData->energy_ratio_ism[sf][band][obj]; -#endif } /* Quantize ISM ratios */ @@ -3679,11 +3598,7 @@ static void ivas_encode_masaism_metadata( } /* reconstructed values */ -#ifdef FIX_1161_REDUCE_OMASA_HEAP reconstruct_ism_ratios( ratio_ism_idx[band], nchan_ism, step, hOmasaEnergy->q_energy_ratio_ism[sf][band] ); -#else - reconstruct_ism_ratios( ratio_ism_idx[band], nchan_ism, step, hMasa->data.hOmasaData->q_energy_ratio_ism[sf][band] ); -#endif } if ( ( nchan_ism > 2 ) && ( idx_separated_object == nchan_ism - 1 ) ) @@ -3758,11 +3673,7 @@ static void ivas_encode_masaism_metadata( } } -#ifdef FIX_1161_REDUCE_OMASA_HEAP calculate_nbits_meta( nchan_ism, hOmasaEnergy->q_energy_ratio_ism, hOmasaData->masa_to_total_energy_ratio, numSf, numCodingBands, bits_ism, idx_separated_object, ism_imp ); -#else - calculate_nbits_meta( nchan_ism, hOmasaData->q_energy_ratio_ism, hOmasaData->masa_to_total_energy_ratio, numSf, numCodingBands, bits_ism, idx_separated_object, ism_imp ); -#endif /* quantize directions */ for ( obj = 0; obj < nchan_ism; obj++ ) diff --git a/lib_enc/ivas_omasa_enc.c b/lib_enc/ivas_omasa_enc.c index 4e184d59a5..22f642122a 100644 --- a/lib_enc/ivas_omasa_enc.c +++ b/lib_enc/ivas_omasa_enc.c @@ -290,7 +290,6 @@ ivas_error ivas_omasa_enc_config( st_ivas->hOMasa = NULL; } -#ifdef FIX_1161_REDUCE_OMASA_HEAP /* OMASA energy handle */ if ( st_ivas->ism_mode != ISM_MASA_MODE_DISC && st_ivas->hMasa->data.hOmasaData->hOmasaEnergy == NULL ) { @@ -305,7 +304,6 @@ ivas_error ivas_omasa_enc_config( st_ivas->hMasa->data.hOmasaData->hOmasaEnergy = NULL; } -#endif st_ivas->hCPE[0]->element_brate = ivas_total_brate - ism_total_brate; if ( ivas_total_brate - ism_total_brate >= MIN_BRATE_MDCT_STEREO ) @@ -839,9 +837,7 @@ static void ivas_omasa_param_est_enc( float renormalization_factor_diff[MASA_FREQUENCY_BANDS]; float norm_tmp; int16_t mrange[2], brange[2]; -#ifdef FIX_1161_REDUCE_OMASA_HEAP OMASA_ENCODER_ENERGY_HANDLE hOmasaEnergy = hOmasaData->hOmasaEnergy; -#endif num_freq_bins = hOMasa->cldfbAnaEnc[0]->no_channels; num_freq_bands = hOMasa->nbands; @@ -873,11 +869,7 @@ static void ivas_omasa_param_est_enc( hOMasa->direction_vector_m[2][block_m_idx][band_m_idx] = 0.0f; } -#ifdef FIX_1161_REDUCE_OMASA_HEAP set_zero( hOmasaEnergy->energy_ism[block_m_idx], num_freq_bands ); -#else - set_zero( hOmasaData->energy_ism[block_m_idx], num_freq_bands ); -#endif for ( ts = mrange[0]; ts < mrange[1]; ts++ ) { @@ -895,11 +887,7 @@ static void ivas_omasa_param_est_enc( { for ( k = 0; k < nchan_ism; k++ ) { -#ifdef FIX_1161_REDUCE_OMASA_HEAP hOmasaEnergy->energy_ism[block_m_idx][i] += Chnl_RealBuffer[k][j] * Chnl_RealBuffer[k][j] + Chnl_ImagBuffer[k][j] * Chnl_ImagBuffer[k][j]; -#else - hOmasaData->energy_ism[block_m_idx][i] += Chnl_RealBuffer[k][j] * Chnl_RealBuffer[k][j] + Chnl_ImagBuffer[k][j] * Chnl_ImagBuffer[k][j]; -#endif } } } @@ -1027,9 +1015,7 @@ static void ivas_omasa_energy_and_ratio_est( int16_t mrange[2], brange[2]; float tftile_energy; float ism_ratio_sum; -#ifdef FIX_1161_REDUCE_OMASA_HEAP OMASA_ENCODER_ENERGY_HANDLE hOmasaEnergy = hOmasaData->hOmasaEnergy; -#endif num_freq_bands = hOMasa->nbands; l_ts = input_frame / CLDFB_NO_COL_MAX; @@ -1043,17 +1029,9 @@ static void ivas_omasa_energy_and_ratio_est( /* Reset variable */ for ( i = 0; i < hOMasa->nbands; i++ ) { -#ifdef FIX_1161_REDUCE_OMASA_HEAP set_zero( hOmasaEnergy->energy_ratio_ism[block_m_idx][i], nchan_ism ); -#else - set_zero( hOmasaData->energy_ratio_ism[block_m_idx][i], nchan_ism ); -#endif } -#ifdef FIX_1161_REDUCE_OMASA_HEAP set_zero( hOmasaEnergy->energy_ism[block_m_idx], num_freq_bands ); -#else - set_zero( hOmasaData->energy_ism[block_m_idx], num_freq_bands ); -#endif /* Compute CLDFB */ for ( ts = mrange[0]; ts < mrange[1]; ts++ ) @@ -1073,14 +1051,9 @@ static void ivas_omasa_energy_and_ratio_est( for ( k = 0; k < nchan_ism; k++ ) { tftile_energy = Chnl_RealBuffer[k][j] * Chnl_RealBuffer[k][j] + Chnl_ImagBuffer[k][j] * Chnl_ImagBuffer[k][j]; -#ifdef FIX_1161_REDUCE_OMASA_HEAP hOmasaEnergy->energy_ism[block_m_idx][i] += tftile_energy; hOmasaEnergy->energy_ratio_ism[block_m_idx][i][k] += tftile_energy; -#else - hOmasaData->energy_ism[block_m_idx][i] += tftile_energy; - hOmasaData->energy_ratio_ism[block_m_idx][i][k] += tftile_energy; -#endif } } } @@ -1092,13 +1065,8 @@ static void ivas_omasa_energy_and_ratio_est( ism_ratio_sum = 0.0f; for ( j = 0; j < nchan_ism; j++ ) { -#ifdef FIX_1161_REDUCE_OMASA_HEAP hOmasaEnergy->energy_ratio_ism[block_m_idx][i][j] /= ( hOmasaEnergy->energy_ism[block_m_idx][i] + EPSILON ); ism_ratio_sum += hOmasaEnergy->energy_ratio_ism[block_m_idx][i][j]; -#else - hOmasaData->energy_ratio_ism[block_m_idx][i][j] /= ( hOmasaData->energy_ism[block_m_idx][i] + EPSILON ); - ism_ratio_sum += hOmasaData->energy_ratio_ism[block_m_idx][i][j]; -#endif } if ( ism_ratio_sum == 0.0f ) @@ -1106,11 +1074,7 @@ static void ivas_omasa_energy_and_ratio_est( float temp_ism_ratio = 1.0f / ( (float) nchan_ism ); for ( j = 0; j < nchan_ism; j++ ) { -#ifdef FIX_1161_REDUCE_OMASA_HEAP hOmasaEnergy->energy_ratio_ism[block_m_idx][i][j] = temp_ism_ratio; -#else - hOmasaData->energy_ratio_ism[block_m_idx][i][j] = temp_ism_ratio; -#endif } } } diff --git a/lib_enc/ivas_stat_enc.h b/lib_enc/ivas_stat_enc.h index f0284ff788..4bb9a5f417 100644 --- a/lib_enc/ivas_stat_enc.h +++ b/lib_enc/ivas_stat_enc.h @@ -794,7 +794,6 @@ typedef struct ivas_omasa_enc_state_structure } OMASA_ENC_STATE, *OMASA_ENC_HANDLE; -#ifdef FIX_1161_REDUCE_OMASA_HEAP typedef struct ivas_omasa_encoder_energy_struct { float energy_ism[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; @@ -803,16 +802,9 @@ typedef struct ivas_omasa_encoder_energy_struct } OMASA_ENCODER_ENERGY_STATE, *OMASA_ENCODER_ENERGY_HANDLE; -#endif typedef struct ivas_omasa_encoder_data_struct { -#ifdef FIX_1161_REDUCE_OMASA_HEAP OMASA_ENCODER_ENERGY_HANDLE hOmasaEnergy; -#else - float energy_ism[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; - float energy_ratio_ism[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS][MAX_NUM_OBJECTS]; - float q_energy_ratio_ism[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS][MAX_NUM_OBJECTS]; -#endif float masa_to_total_energy_ratio[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; float lp_noise_CPE; /* LP filtered total noise estimation */ int16_t omasa_stereo_sw_cnt; -- GitLab From fbb5568835d349f42a05b22321441e221e3eb5a9 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 11 Sep 2024 17:29:58 +0200 Subject: [PATCH 15/29] [cleanup] accept NONBE_FIX_1141_OSBA_ROOM_RENDERING --- lib_com/options.h | 1 - lib_dec/ivas_dirac_dec.c | 43 ------------------------------------ lib_dec/ivas_ism_param_dec.c | 6 ----- lib_dec/ivas_stat_dec.h | 2 -- 4 files changed, 52 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 87e7c2d41f..0f92c92057 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -178,7 +178,6 @@ /* any switch which is non-be wrt selection floating point code */ /* all switches in this category should start with "NONBE_" */ -#define NONBE_FIX_1141_OSBA_ROOM_RENDERING /* FhG: Fix for issue 1141: render objects in OSBA decoder with room effect */ #define NONE_BE_FIX_816_LFE_PLC_FLOAT /* DLB: issue 816: reduce required precision to float for LFE-PLC*/ diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index f79bd86ad4..ab70598d34 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -2231,40 +2231,22 @@ void ivas_dirac_dec_render_sf( /* render objects in combined format onto the CICP19 channels for BINAURAL_ROOM_IR */ if ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_SBA_MODE_DISC && st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) { -#ifndef NONBE_FIX_1141_OSBA_ROOM_RENDERING - int16_t in_ch; - for ( in_ch = 0; in_ch < st_ivas->nchan_ism; in_ch++ ) - { -#endif int16_t j, k, l; -#ifndef NONBE_FIX_1141_OSBA_ROOM_RENDERING - int16_t j2, lfe_index; -#endif int16_t num_objects, nchan_out_woLFE; int16_t az1, el1; int16_t n_slots_to_render; int16_t n_samples_to_render; -#ifndef NONBE_FIX_1141_OSBA_ROOM_RENDERING - int16_t interp_offset; -#endif float gain, prev_gain; num_objects = st_ivas->nchan_ism; nchan_out_woLFE = st_ivas->hIntSetup.nchan_out_woLFE; n_slots_to_render = st_ivas->hSpar->subframe_nbslots[st_ivas->hSpar->subframes_rendered]; n_samples_to_render = hSpatParamRendCom->num_freq_bands * n_slots_to_render; -#ifndef NONBE_FIX_1141_OSBA_ROOM_RENDERING - interp_offset = st_ivas->hTcBuffer->n_samples_rendered; -#endif if ( st_ivas->hCombinedOrientationData && st_ivas->hCombinedOrientationData->enableCombinedOrientation[0] ) { ivas_jbm_dec_get_adapted_linear_interpolator( n_samples_to_render, n_samples_to_render, st_ivas->hIsmRendererData->interpolator ); -#ifdef NONBE_FIX_1141_OSBA_ROOM_RENDERING st_ivas->hIsmRendererData->interp_offset = 0; -#else - interp_offset = 0; -#endif } for ( i = 0; i < num_objects; i++ ) @@ -2282,19 +2264,8 @@ void ivas_dirac_dec_render_sf( } } -#ifdef NONBE_FIX_1141_OSBA_ROOM_RENDERING for ( j = 0; j < nchan_out_woLFE; j++ ) -#else - lfe_index = 0; - for ( j = 0, j2 = 0; j < nchan_out_woLFE; j++, j2++ ) -#endif { -#ifndef NONBE_FIX_1141_OSBA_ROOM_RENDERING - if ( ( st_ivas->hIntSetup.num_lfe > 0 ) && ( st_ivas->hIntSetup.index_lfe[lfe_index] == j ) ) - { - ( lfe_index < ( st_ivas->hIntSetup.num_lfe - 1 ) ) ? ( lfe_index++, j2++ ) : j2++; - } -#endif gain = st_ivas->hIsmRendererData->gains[i][j]; prev_gain = st_ivas->hIsmRendererData->prev_gains[i][j]; @@ -2303,11 +2274,7 @@ void ivas_dirac_dec_render_sf( float *tc_re, *tc_im; float *w1, w2; -#ifdef NONBE_FIX_1141_OSBA_ROOM_RENDERING w1 = &st_ivas->hIsmRendererData->interpolator[st_ivas->hIsmRendererData->interp_offset]; -#else - w1 = &st_ivas->hIsmRendererData->interpolator[interp_offset]; -#endif tc_re = pppQMfFrame_ts_re[nchan_transport + i][0]; tc_im = pppQMfFrame_ts_im[nchan_transport + i][0]; @@ -2321,13 +2288,8 @@ void ivas_dirac_dec_render_sf( for ( l = 0; l < hSpatParamRendCom->num_freq_bands; l++ ) { -#ifdef NONBE_FIX_1141_OSBA_ROOM_RENDERING Cldfb_RealBuffer[j][k][l] += g * *( tc_re++ ); Cldfb_ImagBuffer[j][k][l] += g * *( tc_im++ ); -#else - Cldfb_RealBuffer[j2][k][l] += g * *( tc_re++ ); - Cldfb_ImagBuffer[j2][k][l] += g * *( tc_im++ ); -#endif } w1 += hSpatParamRendCom->num_freq_bands; } @@ -2340,12 +2302,7 @@ void ivas_dirac_dec_render_sf( } } } -#ifndef NONBE_FIX_1141_OSBA_ROOM_RENDERING - } -#endif -#ifdef NONBE_FIX_1141_OSBA_ROOM_RENDERING st_ivas->hIsmRendererData->interp_offset += hSpatParamRendCom->num_freq_bands * st_ivas->hSpar->subframe_nbslots[st_ivas->hSpar->subframes_rendered]; -#endif } if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index b4a37dddf6..88de728491 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -712,9 +712,7 @@ void ivas_ism_dec_digest_tc( if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC || st_ivas->renderer_type == RENDERER_OSBA_AMBI || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV -#ifdef NONBE_FIX_1141_OSBA_ROOM_RENDERING || ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM && st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) -#endif ) { st_ivas->hIsmRendererData->interpolator[0] = 0.0f; @@ -735,9 +733,7 @@ void ivas_ism_dec_digest_tc( { ivas_jbm_dec_get_adapted_linear_interpolator( (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ), st_ivas->hTcBuffer->n_samples_available, st_ivas->hIsmRendererData->interpolator ); } -#ifdef NONBE_FIX_1141_OSBA_ROOM_RENDERING st_ivas->hIsmRendererData->interp_offset = 0; -#endif /* also get the gains here */ for ( i = 0; i < st_ivas->nchan_ism; i++ ) @@ -767,9 +763,7 @@ void ivas_ism_dec_digest_tc( if ( ( st_ivas->renderer_type == RENDERER_TD_PANNING || st_ivas->renderer_type == RENDERER_OSBA_LS || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM -#ifdef NONBE_FIX_1141_OSBA_ROOM_RENDERING || ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM && st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) -#endif ) && st_ivas->hCombinedOrientationData == NULL ) { diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index c7d03b3fc2..2515b1cc99 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -815,9 +815,7 @@ typedef struct renderer_struct float prev_gains[MAX_NUM_OBJECTS][MAX_OUTPUT_CHANNELS]; float *interpolator; int16_t interpolator_length; -#ifdef NONBE_FIX_1141_OSBA_ROOM_RENDERING int16_t interp_offset; -#endif float gains[MAX_NUM_OBJECTS][MAX_OUTPUT_CHANNELS]; } ISM_RENDERER_DATA, *ISM_RENDERER_HANDLE; -- GitLab From 8ebb79318cbb676940f8028f3a470df7592e3744 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 11 Sep 2024 17:30:45 +0200 Subject: [PATCH 16/29] [cleanup] accept NONE_BE_FIX_816_LFE_PLC_FLOAT --- lib_com/cnst.h | 2 - lib_com/ivas_cnst.h | 4 - lib_com/ivas_prot.h | 4 - lib_com/ivas_rom_com.c | 21 --- lib_com/ivas_rom_com.h | 4 - lib_com/lsf_tools.c | 16 -- lib_com/options.h | 1 - lib_com/prot.h | 4 - lib_dec/ivas_lfe_plc.c | 381 ----------------------------------------- lib_enc/ivas_lfe_enc.c | 4 - 10 files changed, 441 deletions(-) diff --git a/lib_com/cnst.h b/lib_com/cnst.h index 775a8a0e01..3787d63b81 100644 --- a/lib_com/cnst.h +++ b/lib_com/cnst.h @@ -563,9 +563,7 @@ enum #define INT_FS_12k8 12800 /* internal sampling frequency */ #define M 16 /* order of the LP filter @ 12.8kHz */ -#ifdef NONE_BE_FIX_816_LFE_PLC_FLOAT #define MAX_LP_FILTER_ORDER 20 /* Max order of an LP filter */ -#endif #define L_FRAME 256 /* frame size at 12.8kHz */ #define NB_SUBFR 4 /* number of subframes per frame */ diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index 4e5d9d8ae5..105c0e8057 100755 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -1449,11 +1449,7 @@ typedef enum /* LFE PLC */ #define LFE_PLC_BUFLEN 240 #define LFE_PLC_FS 1600 -#ifdef NONE_BE_FIX_816_LFE_PLC_FLOAT #define L_FRAME_1k6 ( LFE_PLC_FS / FRAMES_PER_SEC ) -#else -#define L_FRAME_1k6 ( 20 * LFE_PLC_FS / 1000 ) -#endif #define LFE_PLC_LENANA LFE_PLC_BUFLEN #define LFE_PLC_FDEL 300 diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index afee4bc4d0..700a9cc75c 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -5523,11 +5523,7 @@ void ivas_lfe_dec( void ivas_lfe_tdplc( LFE_DEC_HANDLE hLFE, /* i/o: LFE decoder handle */ -#ifdef NONE_BE_FIX_816_LFE_PLC_FLOAT float *prevsynth, /* i : previous frame synthesis */ -#else - double *prevsynth, /* i : previous frame synthesis */ -#endif float *ytda, /* o : output time-domain buffer */ const int16_t output_frame /* i : output frame length */ ); diff --git a/lib_com/ivas_rom_com.c b/lib_com/ivas_rom_com.c index 12223badd4..5f81d801f7 100644 --- a/lib_com/ivas_rom_com.c +++ b/lib_com/ivas_rom_com.c @@ -3121,7 +3121,6 @@ const int16_t ivas_lfe_min_shift_tbl[IVAS_LFE_NUM_COEFFS_IN_SUBGRP] = { 1, 0 }; const float ivas_lfe_lpf_delay[2] = { 0.00175f, 0.0035f }; -#ifdef NONE_BE_FIX_816_LFE_PLC_FLOAT const float hamm_lfe_plc[LFE_PLC_LENANA / 2] = { 0.08000000000000002f, 0.08015895227847719f, 0.08063569926248770f, 0.08142991147368656f, 0.08254104003450596f, 0.08396831704748331f, 0.08571075612595230f, 0.08776715307573196f, @@ -3140,26 +3139,6 @@ const float hamm_lfe_plc[LFE_PLC_LENANA / 2] = 0.96233504613317988f, 0.96698111571154954f, 0.97133209998031445f, 0.97538499198789563f, 0.97913699079334116f, 0.98258550340204664f, 0.98572814655776630f, 0.98856274838967395f, 0.99108734991333569f, 0.99330020638455863f, 0.99519978850517732f, 0.99678478347994692f, 0.99805409592381300f, 0.99900684861892730f, 0.99964238312089115f, 0.99996026021380402f }; -#else -const double d_hamm_lfe_plc[LFE_PLC_LENANA / 2] = -{ - 0.08000000000000002, 0.08015895227847719, 0.08063569926248770, 0.08142991147368656, 0.08254104003450596, 0.08396831704748331, 0.08571075612595230, 0.08776715307573196, - 0.09013608672734141, 0.09281591991816535, 0.09580480062389246, 0.09910066323844335, 0.10270123000150438, 0.10660401257268071, 0.11080631375118072, 0.11530522933984272, - 0.12009765015221685, 0.12518026416131367, 0.13054955878853602, 0.13620182333121073, 0.14213315152704381, 0.14833944425372619, 0.15481641236182375, 0.16155957963899570, - 0.16856428590349043, 0.17582569022478273, 0.18333877426912554, 0.19109834576770490, 0.19909904210500018, 0.20733533402487142, 0.21580152945181053, 0.22449177742471671, - 0.23340007214047787, 0.24252025710456171, 0.25184602938575001, 0.26137094397207467, 0.27108841822494550, 0.28099173642839037, 0.29107405443026624, 0.30132840437223085, - 0.31174769950520753, 0.32232473908701620, 0.33305221335878232, 0.34392270859668939, 0.35492871223557998, 0.36606261806086549, 0.37731673146515798, 0.38868327476598852, - 0.40015439258093899, 0.41172215725647360, 0.42337857434671339, 0.43511558813837425, 0.44692508721804453, 0.45879891007795709, 0.47072885075638249, 0.48270666450874267, - 0.49472407350552849, 0.50677277255308162, 0.51884443483328757, 0.53093071765821398, 0.54302326823571601, 0.55511372944202464, 0.56719374559732838, 0.57925496824035816, - 0.59128906189798180, 0.60328770984582458, 0.61524261985593010, 0.62714552992749328, 0.63898821399670414, 0.65076248762175315, 0.66246021363907504, 0.67407330778691554, - 0.68559374429233988, 0.69701356141781945, 0.70832486696356345, 0.71951984372179334, 0.73059075487919101, 0.74152994936378558, 0.75232986713258543, 0.76298304439630038, - 0.77348211877754336, 0.78381983439894576, 0.79398904689767136, 0.80398272836286389, 0.81379397219261318, 0.82341599786708708, 0.83284215563452701, 0.84206593110687011, - 0.85108094976182280, 0.85988098134827329, 0.86845994419199846, 0.87681190939868969, 0.88493110495139349, 0.89281191969953333, 0.90044890723675941, 0.90783678966494241, - 0.91497046124171255, 0.92184499190902180, 0.92845563070029180, 0.93479780902379184, 0.94086714381997805, 0.94665944059061280, 0.95217069629756890, 0.95739710212931617, - 0.96233504613317988, 0.96698111571154954, 0.97133209998031445, 0.97538499198789563, 0.97913699079334116, 0.98258550340204664, 0.98572814655776630, 0.98856274838967395, - 0.99108734991333569, 0.99330020638455863, 0.99519978850517732, 0.99678478347994692, 0.99805409592381300, 0.99900684861892730, 0.99964238312089115, 0.99996026021380402 -}; -#endif /*------------------------------------------------------------------------------------------* * MDFT/iMDFT ROM tables diff --git a/lib_com/ivas_rom_com.h b/lib_com/ivas_rom_com.h index 749ae47b75..c6c8250b03 100644 --- a/lib_com/ivas_rom_com.h +++ b/lib_com/ivas_rom_com.h @@ -361,11 +361,7 @@ extern const int16_t ivas_lfe_min_shift_tbl[IVAS_LFE_NUM_COEFFS_IN_SUBGRP]; extern const ivas_lfe_freq_models ivas_str_lfe_freq_models; extern const float ivas_lfe_lpf_delay[2]; -#ifdef NONE_BE_FIX_816_LFE_PLC_FLOAT extern const float hamm_lfe_plc[LFE_PLC_LENANA / 2]; -#else -extern const double d_hamm_lfe_plc[LFE_PLC_LENANA / 2]; -#endif extern const float ivas_sin_twiddle_480[IVAS_480_PT_LEN >> 1]; extern const float ivas_cos_twiddle_480[IVAS_480_PT_LEN >> 1]; diff --git a/lib_com/lsf_tools.c b/lib_com/lsf_tools.c index 89963d1df8..ec69cc399c 100644 --- a/lib_com/lsf_tools.c +++ b/lib_com/lsf_tools.c @@ -959,22 +959,14 @@ void isp2isf( * * Convert from LPC to reflection coeff *-------------------------------------------------------------------*/ -#ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT -void a2rc( -#else /*! r: stability flag */ uint16_t a2rc( -#endif const float *a, /* i : LPC coefficients */ float *refl, /* o : Reflection co-efficients */ const int16_t lpcorder /* i : LPC order */ ) { -#ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT - float f[M]; -#else float f[MAX_LP_FILTER_ORDER]; -#endif int16_t m, j, n; float km, denom, x; @@ -993,11 +985,7 @@ uint16_t a2rc( { refl[j] = 0.f; } -#ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT - return; -#else return 0; -#endif } refl[m] = -km; @@ -1017,11 +1005,7 @@ uint16_t a2rc( } } -#ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT - return; -#else return 1; -#endif } diff --git a/lib_com/options.h b/lib_com/options.h index 0f92c92057..be62e20c94 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -180,7 +180,6 @@ -#define NONE_BE_FIX_816_LFE_PLC_FLOAT /* DLB: issue 816: reduce required precision to float for LFE-PLC*/ #define NONBE_FIX_1220_OMASA_JBM_EXT_USAN /* Nokia: fix issue 1220 OMASA EXT JBM USAN, also fix similar cases of free to avoid future problems */ #define NONBE_FIX_1174_MCMASA_LBR_LOOP_ERROR /* Nokia: Fix issue 1174 by removing the unnecessary inner loop causing problems. */ diff --git a/lib_com/prot.h b/lib_com/prot.h index 4f4222b2f9..c8f70bb4fc 100644 --- a/lib_com/prot.h +++ b/lib_com/prot.h @@ -2998,12 +2998,8 @@ void a2isf( const float *old_isf, const int16_t lpcOrder ); -#ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT -void a2rc( -#else /*! r: stability flag */ uint16_t a2rc( -#endif const float *a, /* i : LPC coefficients */ float *refl, /* o : Reflection co-efficients */ const int16_t lpcorder /* i : LPC order */ diff --git a/lib_dec/ivas_lfe_plc.c b/lib_dec/ivas_lfe_plc.c index 99509970cb..15ddab9723 100644 --- a/lib_dec/ivas_lfe_plc.c +++ b/lib_dec/ivas_lfe_plc.c @@ -46,201 +46,14 @@ *------------------------------------------------------------------------------------------*/ #define LFE_PLC_DSF ( 48000 / LFE_PLC_FS ) -#ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT -#define LFE_PLC_LPCORD ( 20 ) -#else #define LFE_PLC_LPCORD ( MAX_LP_FILTER_ORDER ) -#endif #define POW_THR ( 1.0e-8f ) #define LFE_PLC_RECLEN_48K ( ( IVAS_LFE_NUM_COEFFS_IN_SUBGRP + 1 ) * L_FRAME48k / IVAS_LFE_NUM_COEFFS_IN_SUBGRP + LFE_PLC_FDEL ) #define LFE_PLC_RECLEN ( ( LFE_PLC_RECLEN_48K / LFE_PLC_DSF ) ) #define LFE_PLC_MUTE_THR ( 10 ) -#ifdef NONE_BE_FIX_816_LFE_PLC_FLOAT #define LFE_PLC_BURST_ATT ( powf( powf( 10.0f, -3.0f / 20.0f ), 1.0f / ( LFE_PLC_FS * 20 / 1000 ) ) ) /* attenuate 3dB per frame starting with 10th consecutive loss */ #define EPS_STOP 1e-5f -#else -#define LFE_PLC_BURST_ATT ( pow( pow( 10.0, -3.0 / 20.0 ), 1.0 / ( LFE_PLC_FS * 0.02 ) ) ) /* attenuate 3dB per frame starting with 10th consecutive loss */ -#define MAX_LEN_LP 960 -#define EPS_STOP 1e-5 -#endif - -#ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT -/*------------------------------------------------------------------------------------------* - * Static function declarations - * - * Note (DLB): the local double precision functions defined below are replica of corresponding - * float functions defined in tools.c, lpc_tools.c and syn_filt.c. - * Double precision arithmetic is required for proper functioning of the lfe_plc. - *------------------------------------------------------------------------------------------*/ - -static void mvr2d( - const float x[], /* i : input vector */ - double y[], /* o : output vector */ - const int16_t n /* i : vector size */ -) -{ - int16_t i; - - if ( n <= 0 ) - { - /* cannot transfer vectors with size 0 */ - return; - } - - for ( i = n - 1; i >= 0; i-- ) - { - y[i] = x[i]; - } - - return; -} - - -/*---------------------------------------------------------------------* - * autocorr() - * - * Compute autocorrelations of input signal - *---------------------------------------------------------------------*/ - -static void d_autocorr( - const double *x, /* i : input signal */ - double *r, /* o : autocorrelations vector */ - const int16_t m, /* i : order of LP filter */ - const int16_t len, /* i : window size */ - const double *wind, /* i : window */ - const int16_t rev_flag, /* i : flag to reverse window */ - const int16_t sym_flag, /* i : symmetric window flag */ - const int16_t no_thr /* i : flag to avoid thresholding */ -) -{ - double t[MAX_LEN_LP]; - double s; - int16_t i, j; - - /* Windowing of signal */ - if ( rev_flag == 1 ) - { - /* time reversed window */ - for ( i = 0; i < len; i++ ) - { - t[i] = x[i] * wind[len - i - 1]; - } - } - else if ( sym_flag == 1 ) - { - /* symmetric window of even length */ - for ( i = 0; i < len / 2; i++ ) - { - t[i] = x[i] * wind[i]; - } - - for ( ; i < len; i++ ) - { - t[i] = x[i] * wind[len - 1 - i]; - } - } - else /* assymetric window */ - { - for ( i = 0; i < len; i++ ) - { - t[i] = x[i] * wind[i]; - } - } - - /* Compute r[1] to r[m] */ - for ( i = 0; i <= m; i++ ) - { - s = t[0] * t[i]; - for ( j = 1; j < len - i; j++ ) - { - s += t[j] * t[i + j]; - } - r[i] = s; - } - - if ( r[0] < 100.0f && no_thr == 0 ) - { - r[0] = 100.0f; - } - - return; -} - - -/*---------------------------------------------------------------------* - * lev_dur() - * - * Wiener-Levinson-Durbin algorithm to compute LP parameters from the autocorrelations - * of input signal - *---------------------------------------------------------------------*/ - -/*! r: energy of prediction error */ -static int16_t d_lev_dur( - double *a, /* o : LP coefficients (a[0] = 1.0) */ - const double *r, /* i : vector of autocorrelations */ - const int16_t m, /* i : order of LP filter */ - double epsP[] /* o : prediction error energy */ -) -{ - int16_t i, j, l; - double buf[TCXLTP_LTP_ORDER]; - double *rc; /* reflection coefficients 0,...,m-1 */ - double s, at, err; - int16_t flag = 0; - - rc = &buf[0]; - rc[0] = ( -r[1] ) / r[0]; - a[0] = 1.0; - a[1] = rc[0]; - err = r[0] + r[1] * rc[0]; - - if ( epsP != NULL ) - { - epsP[0] = r[0]; - epsP[1] = err; - } - - for ( i = 2; i <= m; i++ ) - { - s = 0.0; - for ( j = 0; j < i; j++ ) - { - s += r[i - j] * a[j]; - } - - rc[i - 1] = ( -s ) / err; - - if ( fabs( rc[i - 1] ) > 0.99945f ) - { - flag = 1; /* Test for unstable filter. If unstable keep old A(z) */ - } - - for ( j = 1; j <= i / 2; j++ ) - { - l = i - j; - at = a[j] + rc[i - 1] * a[l]; - a[l] += rc[i - 1] * a[j]; - a[j] = at; - } - - a[i] = rc[i - 1]; - - err += rc[i - 1] * s; - if ( err <= 0.0f ) - { - err = 0.01f; - } - - if ( epsP != NULL ) - { - epsP[i] = err; - } - } - - return ( flag ); -} -#else /*---------------------------------------------------------------------* * lfeplc_lev_dur() * @@ -308,104 +121,7 @@ static int16_t lfeplc_lev_dur( return 0; } -#endif - -#ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT -/*-------------------------------------------------------------------* - * a2rc() - * - * Convert from LPC to reflection coeff - *-------------------------------------------------------------------*/ -static uint16_t d_a2rc( - const double *a, /* i : LPC coefficients */ - double *refl, /* o : Reflection co-efficients */ - const int16_t lpcorder /* i : LPC order */ -) -{ - double ff[LFE_PLC_LPCORD]; - double km, denom, x; - int16_t m, j, n; - - for ( m = 0; m < lpcorder; m++ ) - { - ff[m] = -a[m]; - } - - /* Initialization */ - for ( m = lpcorder - 1; m >= 0; m-- ) - { - km = ff[m]; - if ( km <= -1.0 || km >= 1.0 ) - { - for ( j = 0; j < lpcorder; j++ ) - { - refl[j] = 0.0; - } - - return 0; - } - - refl[m] = -km; - denom = 1.0 / ( 1.0 - km * km ); - for ( j = 0; j < m / 2; j++ ) - { - n = m - 1 - j; - x = denom * ff[j] + km * denom * ff[n]; - ff[n] = denom * ff[n] + km * denom * ff[j]; - ff[j] = x; - } - - if ( m & 1 ) - { - ff[j] = denom * ff[j] + km * denom * ff[j]; - } - } - - return 1; -} - -static void d_syn_filt( - const double a[], /* i : LP filter coefficients */ - const int16_t m, /* i : order of LP filter */ - const float x[], /* i : input signal */ - float y[], /* o : output signal */ - const int16_t l, /* i : size of filtering */ - const float mem[] /* i : initial filter states */ -) -{ - int16_t i, j; - double buf[LFE_PLC_LPCORD + LFE_PLC_RECLEN]; /* temporary synthesis buffer */ - double s, *yy; - - yy = &buf[0]; - - /*------------------------------------------------------------------* - * copy initial filter states into synthesis buffer and do synthesis - *------------------------------------------------------------------*/ - for ( i = 0; i < m; i++ ) - { - *yy++ = mem[i]; - } - - /*-----------------------------------------------------------------------* - * Do the filtering - *-----------------------------------------------------------------------*/ - - for ( i = 0; i < l; i++ ) - { - s = x[i]; - for ( j = 1; j <= m; j++ ) - { - s -= a[j] * yy[i - j]; - } - - yy[i] = s; - y[i] = (float) s; - } - return; -} -#endif /*-----------------------------------------------------------------------------------------* * Function check_stab() @@ -413,15 +129,6 @@ static void d_syn_filt( * LPC filter stability check applying given sharpening value delta *-----------------------------------------------------------------------------------------*/ -#ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT -static uint16_t check_stab( - const double *a, - double delta ) -{ - double amod[LFE_PLC_LPCORD], refl[LFE_PLC_LPCORD]; - double fac; - double fac1; -#else static uint16_t check_stab( const float *a, const float delta ) @@ -429,15 +136,10 @@ static uint16_t check_stab( float amod[LFE_PLC_LPCORD], refl[LFE_PLC_LPCORD]; float fac; float fac1; -#endif int16_t i; uint16_t stable; -#ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT - fac = 1.0 + delta; -#else fac = 1.0f + delta; -#endif fac1 = fac; for ( i = 0; i < LFE_PLC_LPCORD; i++ ) @@ -446,11 +148,7 @@ static uint16_t check_stab( fac *= fac1; } -#ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT - stable = d_a2rc( amod, refl, LFE_PLC_LPCORD ); -#else stable = a2rc( amod, refl, LFE_PLC_LPCORD ); -#endif return stable; } @@ -462,30 +160,16 @@ static uint16_t check_stab( * Find maximum LPC filter sharpening by iteration to get a filter that is almost instable *-----------------------------------------------------------------------------------------*/ -#ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT -static double find_max_delta( - double *a ) -{ - double delta; - double eps; - double fac; -#else static float find_max_delta( float *a ) { float delta; float eps; float fac; -#endif uint16_t stable; -#ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT - delta = 0.0; - eps = 0.01; -#else delta = 0.0f; eps = 0.01f; -#endif fac = 2; stable = FALSE; @@ -495,11 +179,7 @@ static float find_max_delta( eps *= fac; stable = TRUE; } -#ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT - fac = 0.5; -#else fac = 0.5f; -#endif if ( stable ) { @@ -521,27 +201,6 @@ static float find_max_delta( delta += eps; stable = check_stab( a, delta ); -#ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT - if ( !stable ) - { - if ( fabs( eps ) > EPS_STOP ) - { - eps = -fabs( eps ) * fac; - } - else - { - eps = -fabs( eps ); - } - } - else - { - if ( fabs( eps ) < EPS_STOP ) - { - break; - } - eps = fabs( eps ) * fac; - } -#else if ( !stable ) { if ( fabsf( eps ) > EPS_STOP ) @@ -561,7 +220,6 @@ static float find_max_delta( } eps = fabsf( eps ) * fac; } -#endif } return delta; @@ -576,54 +234,28 @@ static float find_max_delta( static void recover_samples( const int16_t bfi_count, -#ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT - const float *outbuf, -#else float *outbuf, -#endif float *rec_frame ) { int16_t i; float zeroes[LFE_PLC_RECLEN]; -#ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT - double delta, fac, att; - double d_outbuf[LFE_PLC_BUFLEN], d_r[LFE_PLC_LPCORD + 1], d_a[LFE_PLC_LPCORD + 1], d_pee[LFE_PLC_LPCORD + 1]; - - - mvr2d( outbuf, d_outbuf, LFE_PLC_BUFLEN ); - d_autocorr( d_outbuf, d_r, LFE_PLC_LPCORD, LFE_PLC_BUFLEN, d_hamm_lfe_plc, 0, 1, 1 ); -#else float delta, fac, att; float r[LFE_PLC_LPCORD + 1], a[LFE_PLC_LPCORD + 1]; autocorr( outbuf, r, LFE_PLC_LPCORD, LFE_PLC_BUFLEN, hamm_lfe_plc, 0, 1, 1 ); -#endif -#ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT - if ( d_r[0] < POW_THR * LFE_PLC_BUFLEN ) -#else if ( r[0] < POW_THR * LFE_PLC_BUFLEN ) -#endif { set_zero( rec_frame, LFE_PLC_RECLEN ); return; } -#ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT - d_lev_dur( d_a, d_r, LFE_PLC_LPCORD, d_pee ); - - delta = find_max_delta( d_a + 1 ); - - fac = 1.0 + delta; - att = 1.0; -#else lfeplc_lev_dur( a, r, LFE_PLC_LPCORD ); delta = find_max_delta( a + 1 ); fac = 1.0f + delta; att = 1.0f; -#endif if ( bfi_count >= LFE_PLC_MUTE_THR ) { @@ -633,22 +265,13 @@ static void recover_samples( for ( i = 1; i <= LFE_PLC_LPCORD; i++ ) { -#ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT - d_a[i] = d_a[i] * fac; - fac *= att * ( 1.0 + delta ); -#else a[i] = a[i] * fac; fac *= att * ( 1.0f + delta ); -#endif } set_zero( zeroes, LFE_PLC_RECLEN ); -#ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT - d_syn_filt( d_a, LFE_PLC_LPCORD, zeroes, rec_frame, LFE_PLC_RECLEN, outbuf + LFE_PLC_BUFLEN - LFE_PLC_LPCORD ); -#else syn_filt( a, LFE_PLC_LPCORD, zeroes, rec_frame, LFE_PLC_RECLEN, outbuf + LFE_PLC_BUFLEN - LFE_PLC_LPCORD, 0 ); -#endif return; } @@ -662,11 +285,7 @@ static void recover_samples( void ivas_lfe_tdplc( LFE_DEC_HANDLE hLFE, /* i/o: LFE decoder handle */ -#ifdef NONE_BE_FIX_816_LFE_PLC_FLOAT float *prevsynth, /* i : previous frame synthesis */ -#else - double *prevsynth, /* i : previous frame synthesis */ -#endif float *ytda, /* o : output time-domain buffer */ const int16_t output_frame /* i : output frame length */ ) diff --git a/lib_enc/ivas_lfe_enc.c b/lib_enc/ivas_lfe_enc.c index 18e68b709d..f2fb1fde9a 100644 --- a/lib_enc/ivas_lfe_enc.c +++ b/lib_enc/ivas_lfe_enc.c @@ -164,11 +164,7 @@ static void ivas_lfe_enc_quant( } else { -#ifdef NONE_BE_FIX_816_LFE_PLC_FLOAT shift = (int16_t) floorf( IVAS_LFE_SHIFTS_PER_DOUBLE * log2_f( max_value / lfe_abs_sum ) ); -#else - shift = (int16_t) floor( IVAS_LFE_SHIFTS_PER_DOUBLE * log2_f( max_value / lfe_abs_sum ) ); -#endif } shift = max( min_shift * IVAS_LFE_SHIFTS_PER_DOUBLE, min( max_shift, shift ) ); -- GitLab From ee4d2d3a5240329309df5fb072385024db10670e Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 11 Sep 2024 17:31:24 +0200 Subject: [PATCH 17/29] [cleanup] accept NONBE_FIX_1220_OMASA_JBM_EXT_USAN --- lib_com/options.h | 1 - lib_dec/ivas_masa_dec.c | 18 ------------------ lib_dec/ivas_mct_dec.c | 18 ------------------ 3 files changed, 37 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index be62e20c94..e6e2a495e1 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -180,7 +180,6 @@ -#define NONBE_FIX_1220_OMASA_JBM_EXT_USAN /* Nokia: fix issue 1220 OMASA EXT JBM USAN, also fix similar cases of free to avoid future problems */ #define NONBE_FIX_1174_MCMASA_LBR_LOOP_ERROR /* Nokia: Fix issue 1174 by removing the unnecessary inner loop causing problems. */ /* ##################### End NON-BE switches ########################### */ diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index e4bdb46a98..2335f14147 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -1326,12 +1326,8 @@ ivas_error ivas_masa_dec_reconfigure( ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; last_ivas_total_brate = st_ivas->hDecoderConfig->last_ivas_total_brate; -#ifdef NONBE_FIX_1220_OMASA_JBM_EXT_USAN /* Copy state to TC buffer if granularity matches and we are not in OMASA EXT rendering mode */ if ( st_ivas->hSpatParamRendCom != NULL && st_ivas->hSpatParamRendCom->slot_size == st_ivas->hTcBuffer->n_samples_granularity && st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_EXTERNAL ) -#else - if ( st_ivas->hSpatParamRendCom != NULL && st_ivas->hSpatParamRendCom->slot_size == st_ivas->hTcBuffer->n_samples_granularity ) -#endif { mvs2s( st_ivas->hSpatParamRendCom->subframe_nbslots, st_ivas->hTcBuffer->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); st_ivas->hTcBuffer->nb_subframes = st_ivas->hSpatParamRendCom->nb_subframes; @@ -1352,7 +1348,6 @@ ivas_error ivas_masa_dec_reconfigure( return error; } } -#ifdef NONBE_FIX_1220_OMASA_JBM_EXT_USAN else if ( st_ivas->renderer_type == RENDERER_DISABLE || st_ivas->renderer_type == RENDERER_MONO_DOWNMIX || st_ivas->renderer_type == RENDERER_OMASA_MIX_EXT ) { /* close all unnecessary parametric decoding and rendering */ @@ -1361,19 +1356,6 @@ ivas_error ivas_masa_dec_reconfigure( ivas_spat_hSpatParamRendCom_close( &( st_ivas->hSpatParamRendCom ) ); ivas_dirac_dec_close( &( st_ivas->hDirAC ) ); } -#else - else if ( st_ivas->renderer_type == RENDERER_DISABLE || st_ivas->renderer_type == RENDERER_MONO_DOWNMIX ) - { - if ( st_ivas->hDirAC != NULL ) - { - /* close all unnecessary parametric decoding and rendering */ - ivas_dirac_dec_close_binaural_data( st_ivas->hDiracDecBin ); - ivas_dirac_rend_close( &( st_ivas->hDirACRend ) ); - ivas_spat_hSpatParamRendCom_close( &( st_ivas->hSpatParamRendCom ) ); - ivas_dirac_dec_close( &( st_ivas->hDirAC ) ); - } - } -#endif /* possible reconfigure is done later */ /*-----------------------------------------------------------------* diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index 81b800de8e..888100978a 100644 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -849,17 +849,10 @@ static ivas_error ivas_mc_dec_reconfig( ivas_masa_dec_close( &( st_ivas->hMasa ) ); ivas_qmetadata_close( &st_ivas->hQMetaData ); -#ifndef NONBE_FIX_1220_OMASA_JBM_EXT_USAN - if ( st_ivas->hDirAC != NULL ) - { -#endif ivas_dirac_rend_close( &( st_ivas->hDirACRend ) ); ivas_spat_hSpatParamRendCom_close( &( st_ivas->hSpatParamRendCom ) ); ivas_dirac_dec_close( &( st_ivas->hDirAC ) ); vbap_free_data( &( st_ivas->hVBAPdata ) ); -#ifndef NONBE_FIX_1220_OMASA_JBM_EXT_USAN - } -#endif /* init LS conversion if the renderer type asks for it */ if ( st_ivas->renderer_type == RENDERER_MC && st_ivas->hLsSetUpConversion == NULL ) @@ -939,18 +932,11 @@ static ivas_error ivas_mc_dec_reconfig( ivas_masa_dec_close( &( st_ivas->hMasa ) ); ivas_qmetadata_close( &st_ivas->hQMetaData ); -#ifndef NONBE_FIX_1220_OMASA_JBM_EXT_USAN - if ( st_ivas->hDirAC != NULL ) - { -#endif ivas_dirac_rend_close( &( st_ivas->hDirACRend ) ); ivas_spat_hSpatParamRendCom_close( &( st_ivas->hSpatParamRendCom ) ); ivas_dirac_dec_close( &( st_ivas->hDirAC ) ); vbap_free_data( &( st_ivas->hVBAPdata ) ); -#ifndef NONBE_FIX_1220_OMASA_JBM_EXT_USAN - } -#endif if ( last_mc_mode == MC_MODE_MCT ) { @@ -1185,11 +1171,7 @@ static ivas_error ivas_mc_dec_reconfig( } } } -#ifdef NONBE_FIX_1220_OMASA_JBM_EXT_USAN else if ( st_ivas->renderer_type == RENDERER_DISABLE ) -#else - else if ( st_ivas->renderer_type == RENDERER_DISABLE && st_ivas->hDirAC != NULL ) -#endif { ivas_dirac_rend_close( &( st_ivas->hDirACRend ) ); ivas_spat_hSpatParamRendCom_close( &( st_ivas->hSpatParamRendCom ) ); -- GitLab From cf1683933c61f3dde8f5f6fc812b3a1371647209 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 11 Sep 2024 17:32:56 +0200 Subject: [PATCH 18/29] [cleanup] accept FIX_POINT_ROM_CONST --- lib_com/options.h | 1 - lib_rend/ivas_stat_rend.h | 4 -- lib_util/hrtf_file_reader.c | 127 ------------------------------------ 3 files changed, 132 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index e6e2a495e1..91e0ec2382 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -169,7 +169,6 @@ #define TMP_FIX_1119_SPLIT_RENDERING_VOIP /* FhG: Add error check for unsupported config: split rendering with VoIP mode */ -#define FIX_POINT_ROM_CONST /* Ora: issue #1150 HRTF ROM tables should be defined as 'const'*/ #define FIX_1158_FASTCONV_REVERB_HRTF /* Philips: issue 1158: Rendering with FastConv to BINAURAL_ROOM_REVERB uses BRIR convolution instead of HRTF */ /* #################### End BE switches ################################## */ diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index a95443d236..f1d777699c 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -1175,14 +1175,12 @@ typedef struct ivas_hrtfs_structure float inv_diffuse_weight[BINAURAL_CHANNELS][MAX_INTERN_CHANNELS]; /* inverse diffuse weights array, access one inverse weight by pInvDiffuseWeight[channel] */ int16_t same_inv_diffuse_weight; float gain_lfe; -#ifdef FIX_POINT_ROM_CONST float *pOut_to_bin_re_dyn[MAX_INTERN_CHANNELS][BINAURAL_CHANNELS]; float *pOut_to_bin_im_dyn[MAX_INTERN_CHANNELS][BINAURAL_CHANNELS]; float *pOut_to_bin_diffuse_re_dyn[BINAURAL_CHANNELS]; float *pOut_to_bin_diffuse_im_dyn[BINAURAL_CHANNELS]; uint16_t *pIndex_frequency_max_dyn[MAX_INTERN_CHANNELS][BINAURAL_CHANNELS]; uint16_t *pIndex_frequency_max_diffuse_dyn[BINAURAL_CHANNELS]; -#endif } HRTFS_DATA, *HRTFS_HANDLE; @@ -1307,11 +1305,9 @@ typedef struct ivas_hrtfs_statistics_struct const float *average_energy_l; const float *average_energy_r; const float *inter_aural_coherence; -#ifdef FIX_POINT_ROM_CONST float *average_energy_l_dyn; float *average_energy_r_dyn; float *inter_aural_coherence_dyn; -#endif int16_t fromROM; /* Flag that indicates that the pointers point to tables in ROM (controls init/dealloc).*/ } HRTFS_STATISTICS, *HRTFS_STATISTICS_HANDLE; diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index 28f90b02ea..9982f73aec 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -706,9 +706,6 @@ static ivas_error load_reverb_from_binary( Word16 factorQ; Word16 tmp16; float factorQ_f; -#ifndef FIX_POINT_ROM_CONST - float average_energy; -#endif if ( hHrtfStatistics == NULL || f_hrtf == NULL ) { @@ -773,7 +770,6 @@ static ivas_error load_reverb_from_binary( if ( is_reverb ) { -#ifdef FIX_POINT_ROM_CONST hHrtfStatistics->average_energy_l_dyn = (float *) malloc( lr_iac_len * sizeof( float ) ); hHrtfStatistics->average_energy_r_dyn = (float *) malloc( lr_iac_len * sizeof( float ) ); hHrtfStatistics->inter_aural_coherence_dyn = (float *) malloc( lr_iac_len * sizeof( float ) ); @@ -785,47 +781,22 @@ static ivas_error load_reverb_from_binary( hHrtfStatistics->average_energy_l = hHrtfStatistics->average_energy_l_dyn; hHrtfStatistics->average_energy_r = hHrtfStatistics->average_energy_r_dyn; hHrtfStatistics->inter_aural_coherence = hHrtfStatistics->inter_aural_coherence_dyn; -#else - 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" ); - } -#endif fread( &factorQ, sizeof( Word16 ), 1, f_hrtf ); factorQ_f = powf( 2.f, -1.f * factorQ ); for ( ind = 0; ind < lr_iac_len; ind++ ) { fread( &tmp16, sizeof( Word16 ), 1, f_hrtf ); -#ifdef FIX_POINT_ROM_CONST hHrtfStatistics->average_energy_l_dyn[ind] = factorQ_f * tmp16; -#else - average_energy = factorQ_f * tmp16; - memcpy( (float *) &hHrtfStatistics->average_energy_l[ind], &average_energy, sizeof( float ) ); -#endif } for ( ind = 0; ind < lr_iac_len; ind++ ) { fread( &tmp16, sizeof( Word16 ), 1, f_hrtf ); -#ifdef FIX_POINT_ROM_CONST hHrtfStatistics->average_energy_r_dyn[ind] = factorQ_f * tmp16; -#else - average_energy = factorQ_f * tmp16; - memcpy( (float *) &hHrtfStatistics->average_energy_r[ind], &average_energy, sizeof( float ) ); -#endif } for ( ind = 0; ind < lr_iac_len; ind++ ) { fread( &tmp16, sizeof( Word16 ), 1, f_hrtf ); -#ifdef FIX_POINT_ROM_CONST hHrtfStatistics->inter_aural_coherence_dyn[ind] = factorQ_f * tmp16; -#else - average_energy = factorQ_f * tmp16; - memcpy( (float *) &hHrtfStatistics->inter_aural_coherence[ind], &average_energy, sizeof( float ) ); -#endif } hHrtfStatistics->fromROM = FALSE; @@ -1156,7 +1127,6 @@ static ivas_error create_HRTF_from_rawdata( for ( j = 0; j < BINAURAL_CHANNELS; j++ ) { mem_size = ( *hHRTF )->max_num_iterations * sizeof( uint16_t ); -#ifdef FIX_POINT_ROM_CONST ( *hHRTF )->pIndex_frequency_max_dyn[i][j] = (uint16_t *) malloc( mem_size ); if ( ( *hHRTF )->pIndex_frequency_max_dyn[i][j] == NULL ) { @@ -1164,14 +1134,6 @@ static ivas_error create_HRTF_from_rawdata( } memcpy( ( *hHRTF )->pIndex_frequency_max_dyn[i][j], hrtf_data_rptr, mem_size ); ( *hHRTF )->pIndex_frequency_max[i][j] = ( *hHRTF )->pIndex_frequency_max_dyn[i][j]; -#else - ( *hHRTF )->pIndex_frequency_max[i][j] = (uint16_t *) malloc( mem_size ); - if ( ( *hHRTF )->pIndex_frequency_max[i][j] == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for pIndex_frequency_max" ); - } - memcpy( (uint16_t *) ( *hHRTF )->pIndex_frequency_max[i][j], hrtf_data_rptr, mem_size ); -#endif hrtf_data_rptr += mem_size; } } @@ -1193,7 +1155,6 @@ static ivas_error create_HRTF_from_rawdata( for ( j = 0; j < BINAURAL_CHANNELS; j++ ) { mem_size = ( *hHRTF )->num_iterations_diffuse[j] * sizeof( uint16_t ); -#ifdef FIX_POINT_ROM_CONST ( *hHRTF )->pIndex_frequency_max_diffuse_dyn[j] = (uint16_t *) malloc( mem_size ); if ( ( *hHRTF )->pIndex_frequency_max_diffuse_dyn[j] == NULL ) { @@ -1201,14 +1162,6 @@ static ivas_error create_HRTF_from_rawdata( } memcpy( ( *hHRTF )->pIndex_frequency_max_diffuse_dyn[j], hrtf_data_rptr, mem_size ); ( *hHRTF )->pIndex_frequency_max_diffuse[j] = ( *hHRTF )->pIndex_frequency_max_diffuse_dyn[j]; -#else - ( *hHRTF )->pIndex_frequency_max_diffuse[j] = (uint16_t *) malloc( mem_size ); - if ( (uint16_t *) ( *hHRTF )->pIndex_frequency_max_diffuse[j] == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for pIndex_frequency_max_diffuse" ); - } - memcpy( (uint16_t *) ( *hHRTF )->pIndex_frequency_max_diffuse[j], hrtf_data_rptr, mem_size ); -#endif hrtf_data_rptr += mem_size; } } @@ -1246,7 +1199,6 @@ static ivas_error create_HRTF_from_rawdata( for ( j = 0; j < BINAURAL_CHANNELS; j++ ) { mem_size = max_total_num_fsamp_per_iteration * sizeof( float ); -#ifdef FIX_POINT_ROM_CONST ( *hHRTF )->pOut_to_bin_re_dyn[i][j] = (float *) malloc( mem_size ); if ( ( *hHRTF )->pOut_to_bin_re_dyn[i][j] == NULL ) { @@ -1255,16 +1207,6 @@ static ivas_error create_HRTF_from_rawdata( memset( ( *hHRTF )->pOut_to_bin_re_dyn[i][j], 0x00, mem_size ); ( *hHRTF )->pOut_to_bin_re[i][j] = ( *hHRTF )->pOut_to_bin_re_dyn[i][j]; pOut_to_bin_wptr = ( *hHRTF )->pOut_to_bin_re_dyn[i][j]; -#else - ( *hHRTF )->pOut_to_bin_re[i][j] = (float *) malloc( mem_size ); - if ( ( *hHRTF )->pOut_to_bin_re[i][j] == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for Out_to_bin_re" ); - } - memset( (float *) ( *hHRTF )->pOut_to_bin_re[i][j], 0x00, mem_size ); - - pOut_to_bin_wptr = (float *) ( *hHRTF )->pOut_to_bin_re[i][j]; -#endif for ( k = 0; k < ( *hHRTF )->num_iterations[i][j]; k++ ) { @@ -1286,7 +1228,6 @@ static ivas_error create_HRTF_from_rawdata( for ( j = 0; j < BINAURAL_CHANNELS; j++ ) { mem_size = max_total_num_fsamp_per_iteration * sizeof( float ); -#ifdef FIX_POINT_ROM_CONST ( *hHRTF )->pOut_to_bin_im_dyn[i][j] = (float *) malloc( mem_size ); if ( ( *hHRTF )->pOut_to_bin_im_dyn[i][j] == NULL ) { @@ -1296,16 +1237,6 @@ static ivas_error create_HRTF_from_rawdata( ( *hHRTF )->pOut_to_bin_im[i][j] = ( *hHRTF )->pOut_to_bin_im_dyn[i][j]; pOut_to_bin_wptr = ( *hHRTF )->pOut_to_bin_im_dyn[i][j]; -#else - ( *hHRTF )->pOut_to_bin_im[i][j] = (float *) malloc( mem_size ); - if ( ( *hHRTF )->pOut_to_bin_im[i][j] == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for Out_to_bin_im" ); - } - memset( (float *) ( *hHRTF )->pOut_to_bin_im[i][j], 0x00, mem_size ); - - pOut_to_bin_wptr = (float *) ( *hHRTF )->pOut_to_bin_im[i][j]; -#endif for ( k = 0; k < ( *hHRTF )->num_iterations[i][j]; k++ ) { mem_size = ( *hHRTF )->pIndex_frequency_max[i][j][k] * sizeof( int16_t ); @@ -1332,7 +1263,6 @@ static ivas_error create_HRTF_from_rawdata( for ( j = 0; j < BINAURAL_CHANNELS; j++ ) { mem_size = max_total_num_fsamp_per_iteration_diff * sizeof( float ); -#ifdef FIX_POINT_ROM_CONST ( *hHRTF )->pOut_to_bin_diffuse_re_dyn[j] = (float *) malloc( mem_size ); if ( ( *hHRTF )->pOut_to_bin_diffuse_re_dyn[j] == NULL ) { @@ -1342,16 +1272,6 @@ static ivas_error create_HRTF_from_rawdata( ( *hHRTF )->pOut_to_bin_diffuse_re[j] = ( *hHRTF )->pOut_to_bin_diffuse_re_dyn[j]; pOut_to_bin_wptr = ( *hHRTF )->pOut_to_bin_diffuse_re_dyn[j]; -#else - ( *hHRTF )->pOut_to_bin_diffuse_re[j] = (float *) malloc( mem_size ); - if ( ( *hHRTF )->pOut_to_bin_diffuse_re[j] == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for pOut_to_bin_diffuse_re" ); - } - memset( (uint16_t *) ( *hHRTF )->pOut_to_bin_diffuse_re[j], 0x00, mem_size ); - - pOut_to_bin_wptr = (float *) ( *hHRTF )->pOut_to_bin_diffuse_re[j]; -#endif for ( k = 0; k < ( *hHRTF )->num_iterations_diffuse[j]; k++ ) { @@ -1370,7 +1290,6 @@ static ivas_error create_HRTF_from_rawdata( for ( j = 0; j < BINAURAL_CHANNELS; j++ ) { mem_size = max_total_num_fsamp_per_iteration_diff * sizeof( float ); -#ifdef FIX_POINT_ROM_CONST ( *hHRTF )->pOut_to_bin_diffuse_im_dyn[j] = (float *) malloc( mem_size ); if ( ( *hHRTF )->pOut_to_bin_diffuse_im_dyn[j] == NULL ) { @@ -1380,16 +1299,6 @@ static ivas_error create_HRTF_from_rawdata( ( *hHRTF )->pOut_to_bin_diffuse_im[j] = ( *hHRTF )->pOut_to_bin_diffuse_im_dyn[j]; pOut_to_bin_wptr = ( *hHRTF )->pOut_to_bin_diffuse_im_dyn[j]; -#else - ( *hHRTF )->pOut_to_bin_diffuse_im[j] = (float *) malloc( mem_size ); - if ( ( *hHRTF )->pOut_to_bin_diffuse_im[j] == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for pOut_to_bin_diffuse_im" ); - } - memset( (uint16_t *) ( *hHRTF )->pOut_to_bin_diffuse_im[j], 0x00, mem_size ); - - pOut_to_bin_wptr = (float *) ( *hHRTF )->pOut_to_bin_diffuse_im[j]; -#endif for ( k = 0; k < ( *hHRTF )->num_iterations_diffuse[j]; k++ ) { mem_size = ( *hHRTF )->pIndex_frequency_max_diffuse[j][k] * sizeof( int16_t ); @@ -2280,7 +2189,6 @@ static void destroy_HRTF( { for ( j = 0; j < BINAURAL_CHANNELS; j++ ) { -#ifdef FIX_POINT_ROM_CONST if ( ( *hHRTF )->pIndex_frequency_max[i][j] != NULL ) { free( ( *hHRTF )->pIndex_frequency_max_dyn[i][j] ); @@ -2293,25 +2201,10 @@ static void destroy_HRTF( { free( ( *hHRTF )->pOut_to_bin_im_dyn[i][j] ); } -#else - if ( ( *hHRTF )->pIndex_frequency_max[i][j] != NULL ) - { - free( (uint16_t *) ( *hHRTF )->pIndex_frequency_max[i][j] ); - } - if ( ( *hHRTF )->pOut_to_bin_re[i][j] != NULL ) - { - free( (float *) ( *hHRTF )->pOut_to_bin_re[i][j] ); - } - if ( ( *hHRTF )->pOut_to_bin_im[i][j] != NULL ) - { - free( (float *) ( *hHRTF )->pOut_to_bin_im[i][j] ); - } -#endif } } for ( j = 0; j < BINAURAL_CHANNELS; j++ ) { -#ifdef FIX_POINT_ROM_CONST if ( ( *hHRTF )->pIndex_frequency_max_diffuse[j] != NULL ) { free( ( *hHRTF )->pIndex_frequency_max_diffuse_dyn[j] ); @@ -2324,20 +2217,6 @@ static void destroy_HRTF( { free( ( *hHRTF )->pOut_to_bin_diffuse_im_dyn[j] ); } -#else - if ( ( *hHRTF )->pIndex_frequency_max_diffuse[j] != NULL ) - { - free( (uint16_t *) ( *hHRTF )->pIndex_frequency_max_diffuse[j] ); - } - if ( ( *hHRTF )->pOut_to_bin_diffuse_re[j] != NULL ) - { - free( (float *) ( *hHRTF )->pOut_to_bin_diffuse_re[j] ); - } - if ( ( *hHRTF )->pOut_to_bin_diffuse_im[j] != NULL ) - { - free( (float *) ( *hHRTF )->pOut_to_bin_diffuse_im[j] ); - } -#endif } free( *hHRTF ); @@ -2422,7 +2301,6 @@ void destroy_hrtf_statistics( if ( ( hHrtfStatistics != NULL ) && ( *hHrtfStatistics != NULL ) && ( ( *hHrtfStatistics )->fromROM == FALSE ) ) { -#ifdef FIX_POINT_ROM_CONST if ( ( *hHrtfStatistics )->average_energy_l != NULL ) { free( ( *hHrtfStatistics )->average_energy_l_dyn ); @@ -2435,11 +2313,6 @@ void destroy_hrtf_statistics( { free( ( *hHrtfStatistics )->inter_aural_coherence_dyn ); } -#else - free( (float *) ( *hHrtfStatistics )->average_energy_l ); - free( (float *) ( *hHrtfStatistics )->average_energy_r ); - free( (float *) ( *hHrtfStatistics )->inter_aural_coherence ); -#endif } ivas_HRTF_statistics_close( hHrtfStatistics ); -- GitLab From 2d5fee19c81bff96e97b2af40cfa2fa45b41d99a Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 11 Sep 2024 17:42:20 +0200 Subject: [PATCH 19/29] formatting --- lib_dec/ivas_dirac_dec.c | 106 +++++----- lib_dec/ivas_dirac_output_synthesis_cov.c | 34 ++-- lib_dec/ivas_ism_param_dec.c | 8 +- lib_dec/ivas_lfe_plc.c | 13 +- lib_dec/ivas_mc_param_dec.c | 238 +++++++++++----------- lib_dec/ivas_mct_dec.c | 16 +- lib_enc/ivas_masa_enc.c | 2 +- lib_enc/ivas_omasa_enc.c | 1 - lib_rend/lib_rend.c | 14 +- lib_util/hrtf_file_reader.c | 1 - 10 files changed, 213 insertions(+), 220 deletions(-) diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index ab70598d34..f28378698f 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -2231,77 +2231,77 @@ void ivas_dirac_dec_render_sf( /* render objects in combined format onto the CICP19 channels for BINAURAL_ROOM_IR */ if ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_SBA_MODE_DISC && st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) { - int16_t j, k, l; - int16_t num_objects, nchan_out_woLFE; - int16_t az1, el1; - int16_t n_slots_to_render; - int16_t n_samples_to_render; - float gain, prev_gain; - - num_objects = st_ivas->nchan_ism; - nchan_out_woLFE = st_ivas->hIntSetup.nchan_out_woLFE; - n_slots_to_render = st_ivas->hSpar->subframe_nbslots[st_ivas->hSpar->subframes_rendered]; - n_samples_to_render = hSpatParamRendCom->num_freq_bands * n_slots_to_render; - - if ( st_ivas->hCombinedOrientationData && st_ivas->hCombinedOrientationData->enableCombinedOrientation[0] ) - { - ivas_jbm_dec_get_adapted_linear_interpolator( n_samples_to_render, n_samples_to_render, st_ivas->hIsmRendererData->interpolator ); - st_ivas->hIsmRendererData->interp_offset = 0; - } + int16_t j, k, l; + int16_t num_objects, nchan_out_woLFE; + int16_t az1, el1; + int16_t n_slots_to_render; + int16_t n_samples_to_render; + float gain, prev_gain; + + num_objects = st_ivas->nchan_ism; + nchan_out_woLFE = st_ivas->hIntSetup.nchan_out_woLFE; + n_slots_to_render = st_ivas->hSpar->subframe_nbslots[st_ivas->hSpar->subframes_rendered]; + n_samples_to_render = hSpatParamRendCom->num_freq_bands * n_slots_to_render; + + if ( st_ivas->hCombinedOrientationData && st_ivas->hCombinedOrientationData->enableCombinedOrientation[0] ) + { + ivas_jbm_dec_get_adapted_linear_interpolator( n_samples_to_render, n_samples_to_render, st_ivas->hIsmRendererData->interpolator ); + st_ivas->hIsmRendererData->interp_offset = 0; + } - for ( i = 0; i < num_objects; i++ ) + for ( i = 0; i < num_objects; i++ ) + { + /* Combined rotation: rotate the object positions depending the head and external orientations */ + if ( st_ivas->hCombinedOrientationData != NULL && st_ivas->hCombinedOrientationData->enableCombinedOrientation[0] == 1 ) { - /* Combined rotation: rotate the object positions depending the head and external orientations */ - if ( st_ivas->hCombinedOrientationData != NULL && st_ivas->hCombinedOrientationData->enableCombinedOrientation[0] == 1 ) + rotateAziEle( st_ivas->hIsmMetaData[i]->azimuth, st_ivas->hIsmMetaData[i]->elevation, &az1, &el1, st_ivas->hCombinedOrientationData->Rmat[0], st_ivas->hIntSetup.is_planar_setup ); + if ( st_ivas->hEFAPdata != NULL ) { - rotateAziEle( st_ivas->hIsmMetaData[i]->azimuth, st_ivas->hIsmMetaData[i]->elevation, &az1, &el1, st_ivas->hCombinedOrientationData->Rmat[0], st_ivas->hIntSetup.is_planar_setup ); - if ( st_ivas->hEFAPdata != NULL ) - { - efap_determine_gains( st_ivas->hEFAPdata, st_ivas->hIsmRendererData->gains[i], az1, el1, EFAP_MODE_EFAP ); + efap_determine_gains( st_ivas->hEFAPdata, st_ivas->hIsmRendererData->gains[i], az1, el1, EFAP_MODE_EFAP ); #ifdef OBJ_EDITING_API - v_multc( st_ivas->hIsmRendererData->gains[i], st_ivas->hIsmMetaData[i]->edited_gain, st_ivas->hIsmRendererData->gains[i], nchan_out_woLFE ); + v_multc( st_ivas->hIsmRendererData->gains[i], st_ivas->hIsmMetaData[i]->edited_gain, st_ivas->hIsmRendererData->gains[i], nchan_out_woLFE ); #endif - } } + } - for ( j = 0; j < nchan_out_woLFE; j++ ) - { + for ( j = 0; j < nchan_out_woLFE; j++ ) + { - gain = st_ivas->hIsmRendererData->gains[i][j]; - prev_gain = st_ivas->hIsmRendererData->prev_gains[i][j]; - if ( fabsf( gain ) > 0.0f || fabsf( prev_gain ) > 0.0f ) - { - float *tc_re, *tc_im; - float *w1, w2; + gain = st_ivas->hIsmRendererData->gains[i][j]; + prev_gain = st_ivas->hIsmRendererData->prev_gains[i][j]; + if ( fabsf( gain ) > 0.0f || fabsf( prev_gain ) > 0.0f ) + { + float *tc_re, *tc_im; + float *w1, w2; - w1 = &st_ivas->hIsmRendererData->interpolator[st_ivas->hIsmRendererData->interp_offset]; + w1 = &st_ivas->hIsmRendererData->interpolator[st_ivas->hIsmRendererData->interp_offset]; - tc_re = pppQMfFrame_ts_re[nchan_transport + i][0]; - tc_im = pppQMfFrame_ts_im[nchan_transport + i][0]; + tc_re = pppQMfFrame_ts_re[nchan_transport + i][0]; + tc_im = pppQMfFrame_ts_im[nchan_transport + i][0]; - for ( k = 0; k < n_slots_to_render; k++ ) - { - float g; + for ( k = 0; k < n_slots_to_render; k++ ) + { + float g; - w2 = 1.0f - *w1; - g = ( *w1 * gain + w2 * prev_gain ); + w2 = 1.0f - *w1; + g = ( *w1 * gain + w2 * prev_gain ); - for ( l = 0; l < hSpatParamRendCom->num_freq_bands; l++ ) - { - Cldfb_RealBuffer[j][k][l] += g * *( tc_re++ ); - Cldfb_ImagBuffer[j][k][l] += g * *( tc_im++ ); - } - w1 += hSpatParamRendCom->num_freq_bands; + for ( l = 0; l < hSpatParamRendCom->num_freq_bands; l++ ) + { + Cldfb_RealBuffer[j][k][l] += g * *( tc_re++ ); + Cldfb_ImagBuffer[j][k][l] += g * *( tc_im++ ); } + w1 += hSpatParamRendCom->num_freq_bands; } + } - /* update here only in case of head rotation */ - if ( st_ivas->hCombinedOrientationData != NULL && st_ivas->hCombinedOrientationData->enableCombinedOrientation[0] == 1 ) - { - st_ivas->hIsmRendererData->prev_gains[i][j] = gain; - } + /* update here only in case of head rotation */ + if ( st_ivas->hCombinedOrientationData != NULL && st_ivas->hCombinedOrientationData->enableCombinedOrientation[0] == 1 ) + { + st_ivas->hIsmRendererData->prev_gains[i][j] = gain; } } + } st_ivas->hIsmRendererData->interp_offset += hSpatParamRendCom->num_freq_bands * st_ivas->hSpar->subframe_nbslots[st_ivas->hSpar->subframes_rendered]; } diff --git a/lib_dec/ivas_dirac_output_synthesis_cov.c b/lib_dec/ivas_dirac_output_synthesis_cov.c index a4ae78f65f..6fec493548 100644 --- a/lib_dec/ivas_dirac_output_synthesis_cov.c +++ b/lib_dec/ivas_dirac_output_synthesis_cov.c @@ -328,30 +328,30 @@ void ivas_dirac_dec_output_synthesis_cov_param_mc_collect_slot( float real_buffer[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; float imag_buffer[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; -/* estimate input covariance */ - /* Already stack here instead of in the process_subframe */ + /* estimate input covariance */ + /* Already stack here instead of in the process_subframe */ - /* collect input frame */ - int16_t num_bands; - brange[0] = hParamMC->band_grouping[param_band]; - brange[1] = hParamMC->band_grouping[param_band + 1]; - num_bands = brange[1] - brange[0]; + /* collect input frame */ + int16_t num_bands; + brange[0] = hParamMC->band_grouping[param_band]; + brange[1] = hParamMC->band_grouping[param_band + 1]; + num_bands = brange[1] - brange[0]; - for ( band_idx = 0; band_idx < num_bands; band_idx++ ) + for ( band_idx = 0; band_idx < num_bands; band_idx++ ) + { + int16_t band = brange[0] + band_idx; + for ( ch_idx = 0; ch_idx < nchan_in; ch_idx++ ) { - int16_t band = brange[0] + band_idx; - for ( ch_idx = 0; ch_idx < nchan_in; ch_idx++ ) - { - real_in_buffer[band_idx + num_bands * ch_idx] = RealBuffer[ch_idx * hParamMC->num_freq_bands + band]; - imag_in_buffer[band_idx + num_bands * ch_idx] = ImagBuffer[ch_idx * hParamMC->num_freq_bands + band]; - } + real_in_buffer[band_idx + num_bands * ch_idx] = RealBuffer[ch_idx * hParamMC->num_freq_bands + band]; + imag_in_buffer[band_idx + num_bands * ch_idx] = ImagBuffer[ch_idx * hParamMC->num_freq_bands + band]; } + } - cmplx_matrix_square( real_in_buffer, imag_in_buffer, num_bands, nchan_in, real_buffer, imag_buffer ); + cmplx_matrix_square( real_in_buffer, imag_in_buffer, num_bands, nchan_in, real_buffer, imag_buffer ); - v_add( cx, real_buffer, cx, nchan_in * nchan_in ); + v_add( cx, real_buffer, cx, nchan_in * nchan_in ); - v_add( cx_imag, imag_buffer, cx_imag, nchan_in * nchan_in ); + v_add( cx_imag, imag_buffer, cx_imag, nchan_in * nchan_in ); return; diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index 88de728491..ace799d92e 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -711,9 +711,7 @@ void ivas_ism_dec_digest_tc( if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC || st_ivas->renderer_type == RENDERER_OSBA_AMBI || - st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV - || ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM && st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) - ) + st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM && st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) ) { st_ivas->hIsmRendererData->interpolator[0] = 0.0f; for ( i = 1; i < interpolator_length; i++ ) @@ -762,9 +760,7 @@ void ivas_ism_dec_digest_tc( if ( ( st_ivas->renderer_type == RENDERER_TD_PANNING || st_ivas->renderer_type == RENDERER_OSBA_LS || - st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM - || ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM && st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) - ) && + st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM || ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM && st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) ) && st_ivas->hCombinedOrientationData == NULL ) { if ( st_ivas->hIntSetup.is_planar_setup ) diff --git a/lib_dec/ivas_lfe_plc.c b/lib_dec/ivas_lfe_plc.c index 15ddab9723..91b90891d7 100644 --- a/lib_dec/ivas_lfe_plc.c +++ b/lib_dec/ivas_lfe_plc.c @@ -45,14 +45,14 @@ * Local constants *------------------------------------------------------------------------------------------*/ -#define LFE_PLC_DSF ( 48000 / LFE_PLC_FS ) -#define LFE_PLC_LPCORD ( MAX_LP_FILTER_ORDER ) +#define LFE_PLC_DSF ( 48000 / LFE_PLC_FS ) +#define LFE_PLC_LPCORD ( MAX_LP_FILTER_ORDER ) #define POW_THR ( 1.0e-8f ) #define LFE_PLC_RECLEN_48K ( ( IVAS_LFE_NUM_COEFFS_IN_SUBGRP + 1 ) * L_FRAME48k / IVAS_LFE_NUM_COEFFS_IN_SUBGRP + LFE_PLC_FDEL ) #define LFE_PLC_RECLEN ( ( LFE_PLC_RECLEN_48K / LFE_PLC_DSF ) ) #define LFE_PLC_MUTE_THR ( 10 ) -#define LFE_PLC_BURST_ATT ( powf( powf( 10.0f, -3.0f / 20.0f ), 1.0f / ( LFE_PLC_FS * 20 / 1000 ) ) ) /* attenuate 3dB per frame starting with 10th consecutive loss */ -#define EPS_STOP 1e-5f +#define LFE_PLC_BURST_ATT ( powf( powf( 10.0f, -3.0f / 20.0f ), 1.0f / ( LFE_PLC_FS * 20 / 1000 ) ) ) /* attenuate 3dB per frame starting with 10th consecutive loss */ +#define EPS_STOP 1e-5f /*---------------------------------------------------------------------* * lfeplc_lev_dur() @@ -122,7 +122,6 @@ static int16_t lfeplc_lev_dur( } - /*-----------------------------------------------------------------------------------------* * Function check_stab() * @@ -284,8 +283,8 @@ static void recover_samples( *-----------------------------------------------------------------------------------------*/ void ivas_lfe_tdplc( - LFE_DEC_HANDLE hLFE, /* i/o: LFE decoder handle */ - float *prevsynth, /* i : previous frame synthesis */ + LFE_DEC_HANDLE hLFE, /* i/o: LFE decoder handle */ + float *prevsynth, /* i : previous frame synthesis */ float *ytda, /* o : output time-domain buffer */ const int16_t output_frame /* i : output frame length */ ) diff --git a/lib_dec/ivas_mc_param_dec.c b/lib_dec/ivas_mc_param_dec.c index 461b3bcab0..934fc6fac2 100644 --- a/lib_dec/ivas_mc_param_dec.c +++ b/lib_dec/ivas_mc_param_dec.c @@ -2456,164 +2456,164 @@ static void ivas_param_mc_get_mixing_matrices( num_lfe_bands = PARAM_MC_MAX_BAND_LFE; } - if ( hSynthesisOutputSetup->num_lfe > 0 && param_band_idx >= num_lfe_bands ) - { - remove_lfe = 1; - nY_band = nY_cov - hSynthesisOutputSetup->num_lfe; - proto_matrix_ptr = proto_matrix_noLFE; - } - else - { - proto_matrix_ptr = hParamMC->h_output_synthesis_params.proto_matrix; - } + if ( hSynthesisOutputSetup->num_lfe > 0 && param_band_idx >= num_lfe_bands ) + { + remove_lfe = 1; + nY_band = nY_cov - hSynthesisOutputSetup->num_lfe; + proto_matrix_ptr = proto_matrix_noLFE; + } + else + { + proto_matrix_ptr = hParamMC->h_output_synthesis_params.proto_matrix; + } - brange[0] = hParamMC->band_grouping[param_band_idx]; - brange[1] = hParamMC->band_grouping[param_band_idx + 1]; + brange[0] = hParamMC->band_grouping[param_band_idx]; + brange[1] = hParamMC->band_grouping[param_band_idx + 1]; - Cx_state = Cx_in; - Cx_old_state = hParamMC->h_output_synthesis_cov_state.cx_old[param_band_idx]; - Cy_old_state = hParamMC->h_output_synthesis_cov_state.cy_old[param_band_idx]; + Cx_state = Cx_in; + Cx_old_state = hParamMC->h_output_synthesis_cov_state.cx_old[param_band_idx]; + Cy_old_state = hParamMC->h_output_synthesis_cov_state.cy_old[param_band_idx]; - /* Getting mixing mtx */ - /* estimate target cov from input cov and proto_matrix */ - matrix_product( hParamMC->proto_matrix_int, nY_intern, nX, 0, Cx_state, nX, nX, 0, mat_mult_buffer1 ); + /* Getting mixing mtx */ + /* estimate target cov from input cov and proto_matrix */ + matrix_product( hParamMC->proto_matrix_int, nY_intern, nX, 0, Cx_state, nX, nX, 0, mat_mult_buffer1 ); - matrix_product( mat_mult_buffer1, nY_intern, nX, 0, hParamMC->proto_matrix_int, nY_intern, nX, 1, Cproto ); + matrix_product( mat_mult_buffer1, nY_intern, nX, 0, hParamMC->proto_matrix_int, nY_intern, nX, 1, Cproto ); - for ( ch_idx1 = 0; ch_idx1 < nY_intern; ch_idx1++ ) + for ( ch_idx1 = 0; ch_idx1 < nY_intern; ch_idx1++ ) + { + if ( Cproto[ch_idx1 + ch_idx1 * nY_intern] < 0.0f ) { - if ( Cproto[ch_idx1 + ch_idx1 * nY_intern] < 0.0f ) - { - Cproto[ch_idx1 + ch_idx1 * nY_intern] = 0.0f; - } + Cproto[ch_idx1 + ch_idx1 * nY_intern] = 0.0f; } + } - ivas_param_mc_dequantize_cov( hParamMC, - hParamMC->icld_q + param_band_idx * hParamMC->hMetadataPMC->ild_mapping_conf->ild_map_size_lfe, - hParamMC->icc_q + param_band_idx * hParamMC->hMetadataPMC->icc_mapping_conf->icc_map_size_lfe, - param_band_idx, nY_cov, - synth_config, - nY_intern, - nX, Cx_state, Cproto, Cy_state ); + ivas_param_mc_dequantize_cov( hParamMC, + hParamMC->icld_q + param_band_idx * hParamMC->hMetadataPMC->ild_mapping_conf->ild_map_size_lfe, + hParamMC->icc_q + param_band_idx * hParamMC->hMetadataPMC->icc_mapping_conf->icc_map_size_lfe, + param_band_idx, nY_cov, + synth_config, + nY_intern, + nX, Cx_state, Cproto, Cy_state ); - /* Smoothing: Sum over two buffers */ - if ( hParamMC->hMetadataPMC->bAttackPresent ) - { - /* no smoothing on attacks */ - mvr2r( Cx_state, Cx, nX * nX ); - mvr2r( Cy_state, Cy_full, nY_cov * nY_cov ); - } - else - { - /* smoothing gains are now identical to one, simply add up */ - v_add( Cx_state, Cx_old_state, Cx, nX * nX ); - v_add( Cy_state, Cy_old_state, Cy_full, nY_cov * nY_cov ); - } + /* Smoothing: Sum over two buffers */ + if ( hParamMC->hMetadataPMC->bAttackPresent ) + { + /* no smoothing on attacks */ + mvr2r( Cx_state, Cx, nX * nX ); + mvr2r( Cy_state, Cy_full, nY_cov * nY_cov ); + } + else + { + /* smoothing gains are now identical to one, simply add up */ + v_add( Cx_state, Cx_old_state, Cx, nX * nX ); + v_add( Cy_state, Cy_old_state, Cy_full, nY_cov * nY_cov ); + } - /* cov buffer update */ - mvr2r( Cx_state, Cx_old_state, nX * nX ); - mvr2r( Cy_state, Cy_old_state, nY_cov * nY_cov ); + /* cov buffer update */ + mvr2r( Cx_state, Cx_old_state, nX * nX ); + mvr2r( Cy_state, Cy_old_state, nY_cov * nY_cov ); - /* remove LFE if necessary */ - if ( remove_lfe ) - { - remove_lfe_from_cy( nY_cov, lfe_indices, hSynthesisOutputSetup->num_lfe, Cy_full, Cy ); - } - else - { - mvr2r( Cy_full, Cy, nY_band * nY_band ); - } + /* remove LFE if necessary */ + if ( remove_lfe ) + { + remove_lfe_from_cy( nY_cov, lfe_indices, hSynthesisOutputSetup->num_lfe, Cy_full, Cy ); + } + else + { + mvr2r( Cy_full, Cy, nY_band * nY_band ); + } - matrix_product( proto_matrix_ptr, nY_band, nX, 0, Cx, nX, nX, 0, mat_mult_buffer1 ); + matrix_product( proto_matrix_ptr, nY_band, nX, 0, Cx, nX, nX, 0, mat_mult_buffer1 ); - matrix_product_diag( mat_mult_buffer1, nY_band, nX, 0, proto_matrix_ptr, nY_band, nX, 1, Cproto_diag ); + matrix_product_diag( mat_mult_buffer1, nY_band, nX, 0, proto_matrix_ptr, nY_band, nX, 1, Cproto_diag ); - /* make sure we have no negative entries in Cproto_diag due to rounding errors */ - for ( ch_idx1 = 0; ch_idx1 < nY_band; ch_idx1++ ) + /* make sure we have no negative entries in Cproto_diag due to rounding errors */ + for ( ch_idx1 = 0; ch_idx1 < nY_band; ch_idx1++ ) + { + if ( Cproto_diag[ch_idx1] < 0.0f ) { - if ( Cproto_diag[ch_idx1] < 0.0f ) - { - Cproto_diag[ch_idx1] = 0.0f; - } + Cproto_diag[ch_idx1] = 0.0f; } + } - /* Computing the mixing matrices */ + /* Computing the mixing matrices */ - /* bands with decorr */ - if ( brange[0] < hParamMC->h_output_synthesis_params.max_band_decorr ) - { - computeMixingMatrices( nX, nY_band, Cx, Cy, proto_matrix_ptr, 0, PARAM_MC_REG_SX, PARAM_MC_REG_GHAT, mixing_matrix_local, Cr ); + /* bands with decorr */ + if ( brange[0] < hParamMC->h_output_synthesis_params.max_band_decorr ) + { + computeMixingMatrices( nX, nY_band, Cx, Cy, proto_matrix_ptr, 0, PARAM_MC_REG_SX, PARAM_MC_REG_GHAT, mixing_matrix_local, Cr ); - /* Compute mixing matrix for residual */ - computeMixingMatricesResidual( nY_band, Cproto_diag, Cr, PARAM_MC_REG_SX, PARAM_MC_REG_GHAT, mixing_matrix_res_local ); + /* Compute mixing matrix for residual */ + computeMixingMatricesResidual( nY_band, Cproto_diag, Cr, PARAM_MC_REG_SX, PARAM_MC_REG_GHAT, mixing_matrix_res_local ); - if ( remove_lfe ) - { - set_zero( mixing_matrix_res[param_band_idx], nY_cov * nY_cov ); + if ( remove_lfe ) + { + set_zero( mixing_matrix_res[param_band_idx], nY_cov * nY_cov ); - ptrMM = mixing_matrix_res_local; - ptrMM_out = mixing_matrix_res[param_band_idx]; - for ( lfe_idx1 = 0; lfe_idx1 < hSynthesisOutputSetup->num_lfe + 1; lfe_idx1++ ) + ptrMM = mixing_matrix_res_local; + ptrMM_out = mixing_matrix_res[param_band_idx]; + for ( lfe_idx1 = 0; lfe_idx1 < hSynthesisOutputSetup->num_lfe + 1; lfe_idx1++ ) + { + for ( ch_idx1 = lfe_indices[lfe_idx1] + 1; ch_idx1 < lfe_indices[lfe_idx1 + 1]; ch_idx1++ ) { - for ( ch_idx1 = lfe_indices[lfe_idx1] + 1; ch_idx1 < lfe_indices[lfe_idx1 + 1]; ch_idx1++ ) + for ( lfe_idx2 = 0; lfe_idx2 < hSynthesisOutputSetup->num_lfe + 1; lfe_idx2++ ) { - for ( lfe_idx2 = 0; lfe_idx2 < hSynthesisOutputSetup->num_lfe + 1; lfe_idx2++ ) + for ( ch_idx2 = lfe_indices[lfe_idx2] + 1; ch_idx2 < lfe_indices[lfe_idx2 + 1]; ch_idx2++ ) { - for ( ch_idx2 = lfe_indices[lfe_idx2] + 1; ch_idx2 < lfe_indices[lfe_idx2 + 1]; ch_idx2++ ) - { - *( ptrMM_out++ ) = *( ptrMM++ ); - } - ptrMM_out++; + *( ptrMM_out++ ) = *( ptrMM++ ); } - ptrMM_out--; + ptrMM_out++; } - ptrMM_out += nY_cov; + ptrMM_out--; } - } - else - { - mvr2r( mixing_matrix_res_local, mixing_matrix_res[param_band_idx], nY_cov * nY_cov ); + ptrMM_out += nY_cov; } } - else if ( brange[0] < hParamMC->max_band_energy_compensation ) - { - /* Compute mixing matrices (energy compensation only) */ - computeMixingMatrices( nX, nY_band, Cx, Cy, proto_matrix_ptr, 1, PARAM_MC_REG_SX, PARAM_MC_REG_GHAT, mixing_matrix_local, Cr ); - } else { - /*if neither decorrelation nor energy compensation is applied*/ - for ( i = 0; i < nY_band; i++ ) - { - Cy_diag[i] = Cy[i + nY_band * i]; - Cy_diag[i] = sqrtf( Cy_diag[i] / ( Cproto_diag[i] + EPSILON ) ); - } - - diag_matrix_product( Cy_diag, nY_band, proto_matrix_ptr, nY_band, nX, 0, mixing_matrix_local ); + mvr2r( mixing_matrix_res_local, mixing_matrix_res[param_band_idx], nY_cov * nY_cov ); } - if ( remove_lfe ) + } + else if ( brange[0] < hParamMC->max_band_energy_compensation ) + { + /* Compute mixing matrices (energy compensation only) */ + computeMixingMatrices( nX, nY_band, Cx, Cy, proto_matrix_ptr, 1, PARAM_MC_REG_SX, PARAM_MC_REG_GHAT, mixing_matrix_local, Cr ); + } + else + { + /*if neither decorrelation nor energy compensation is applied*/ + for ( i = 0; i < nY_band; i++ ) { - set_zero( mixing_matrix[param_band_idx], nX * nY_cov ); + Cy_diag[i] = Cy[i + nY_band * i]; + Cy_diag[i] = sqrtf( Cy_diag[i] / ( Cproto_diag[i] + EPSILON ) ); + } + + diag_matrix_product( Cy_diag, nY_band, proto_matrix_ptr, nY_band, nX, 0, mixing_matrix_local ); + } + if ( remove_lfe ) + { + set_zero( mixing_matrix[param_band_idx], nX * nY_cov ); - ptrMM = mixing_matrix_local; - ptrMM_out = mixing_matrix[param_band_idx]; - for ( ch_idx1 = 0; ch_idx1 < nX; ch_idx1++ ) + ptrMM = mixing_matrix_local; + ptrMM_out = mixing_matrix[param_band_idx]; + for ( ch_idx1 = 0; ch_idx1 < nX; ch_idx1++ ) + { + for ( lfe_idx1 = 0; lfe_idx1 < hSynthesisOutputSetup->num_lfe + 1; lfe_idx1++ ) { - for ( lfe_idx1 = 0; lfe_idx1 < hSynthesisOutputSetup->num_lfe + 1; lfe_idx1++ ) + for ( ch_idx2 = lfe_indices[lfe_idx1] + 1; ch_idx2 < lfe_indices[lfe_idx1 + 1]; ch_idx2++ ) { - for ( ch_idx2 = lfe_indices[lfe_idx1] + 1; ch_idx2 < lfe_indices[lfe_idx1 + 1]; ch_idx2++ ) - { - *( ptrMM_out++ ) = *( ptrMM++ ); - } - ptrMM_out++; + *( ptrMM_out++ ) = *( ptrMM++ ); } - ptrMM_out--; + ptrMM_out++; } + ptrMM_out--; } - else - { - mvr2r( mixing_matrix_local, mixing_matrix[param_band_idx], nY_cov * nX ); - } + } + else + { + mvr2r( mixing_matrix_local, mixing_matrix[param_band_idx], nY_cov * nX ); + } return; } diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index 888100978a..08e2de73cd 100644 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -849,10 +849,10 @@ static ivas_error ivas_mc_dec_reconfig( ivas_masa_dec_close( &( st_ivas->hMasa ) ); ivas_qmetadata_close( &st_ivas->hQMetaData ); - ivas_dirac_rend_close( &( st_ivas->hDirACRend ) ); - ivas_spat_hSpatParamRendCom_close( &( st_ivas->hSpatParamRendCom ) ); - ivas_dirac_dec_close( &( st_ivas->hDirAC ) ); - vbap_free_data( &( st_ivas->hVBAPdata ) ); + ivas_dirac_rend_close( &( st_ivas->hDirACRend ) ); + ivas_spat_hSpatParamRendCom_close( &( st_ivas->hSpatParamRendCom ) ); + ivas_dirac_dec_close( &( st_ivas->hDirAC ) ); + vbap_free_data( &( st_ivas->hVBAPdata ) ); /* init LS conversion if the renderer type asks for it */ if ( st_ivas->renderer_type == RENDERER_MC && st_ivas->hLsSetUpConversion == NULL ) @@ -932,11 +932,11 @@ static ivas_error ivas_mc_dec_reconfig( ivas_masa_dec_close( &( st_ivas->hMasa ) ); ivas_qmetadata_close( &st_ivas->hQMetaData ); - ivas_dirac_rend_close( &( st_ivas->hDirACRend ) ); - ivas_spat_hSpatParamRendCom_close( &( st_ivas->hSpatParamRendCom ) ); - ivas_dirac_dec_close( &( st_ivas->hDirAC ) ); + ivas_dirac_rend_close( &( st_ivas->hDirACRend ) ); + ivas_spat_hSpatParamRendCom_close( &( st_ivas->hSpatParamRendCom ) ); + ivas_dirac_dec_close( &( st_ivas->hDirAC ) ); - vbap_free_data( &( st_ivas->hVBAPdata ) ); + vbap_free_data( &( st_ivas->hVBAPdata ) ); if ( last_mc_mode == MC_MODE_MCT ) { diff --git a/lib_enc/ivas_masa_enc.c b/lib_enc/ivas_masa_enc.c index 44cafe4692..fcaad77e88 100644 --- a/lib_enc/ivas_masa_enc.c +++ b/lib_enc/ivas_masa_enc.c @@ -2707,7 +2707,7 @@ void ivas_merge_masa_metadata( hMeta->directional_meta[merge_dest].elevation[sf][band] = hOMasaMeta->directional_meta[0].elevation[sf][band]; /* limit with the earlier direct-energy ratio */ - dir_sum = 1.0f - total_diff_nrg / ( EPSILON + eneBand + hOmasaEnergy->energy_ism[sf][band] ); /* new dir ratio */ + dir_sum = 1.0f - total_diff_nrg / ( EPSILON + eneBand + hOmasaEnergy->energy_ism[sf][band] ); /* new dir ratio */ hMeta->directional_meta[merge_dest].energy_ratio[sf][band] = min( dir_sum, hOMasaMeta->directional_meta[0].energy_ratio[sf][band] ); /* clip with original ISM dir */ hMeta->common_meta.diffuse_to_total_ratio[sf][band] = 1.0f - hMeta->directional_meta[merge_dest].energy_ratio[sf][band]; diff --git a/lib_enc/ivas_omasa_enc.c b/lib_enc/ivas_omasa_enc.c index 22f642122a..a8c793d8f9 100644 --- a/lib_enc/ivas_omasa_enc.c +++ b/lib_enc/ivas_omasa_enc.c @@ -1053,7 +1053,6 @@ static void ivas_omasa_energy_and_ratio_est( tftile_energy = Chnl_RealBuffer[k][j] * Chnl_RealBuffer[k][j] + Chnl_ImagBuffer[k][j] * Chnl_ImagBuffer[k][j]; hOmasaEnergy->energy_ism[block_m_idx][i] += tftile_energy; hOmasaEnergy->energy_ratio_ism[block_m_idx][i][k] += tftile_energy; - } } } diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 8bcf544b76..e3538025ec 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -2752,15 +2752,15 @@ static void clearInputMasa( *------------------------------------------------------------------------*/ ivas_error IVAS_REND_Open( - IVAS_REND_HANDLE *phIvasRend, /* i/o: Pointer to renderer handle */ - const int32_t outputSampleRate, /* i : output sampling rate */ - const IVAS_AUDIO_CONFIG outConfig, /* i : output audio config */ - const bool asHrtfBinary, /* i : load hrtf binary file */ - const int16_t nonDiegeticPan, /* i : non-diegetic object flag */ - const float nonDiegeticPanGain, /* i : non-diegetic panning gain */ + IVAS_REND_HANDLE *phIvasRend, /* i/o: Pointer to renderer handle */ + const int32_t outputSampleRate, /* i : output sampling rate */ + const IVAS_AUDIO_CONFIG outConfig, /* i : output audio config */ + const bool asHrtfBinary, /* i : load hrtf binary file */ + const int16_t nonDiegeticPan, /* i : non-diegetic object flag */ + const float nonDiegeticPanGain, /* i : non-diegetic panning gain */ const int16_t Opt_Headrotation, /* i : indicates whether head-rotation is used */ const int16_t Opt_ExternalOrientation, /* i : indicates whether external orientations are used */ - const int16_t num_subframes /* i : number of subframes */ + const int16_t num_subframes /* i : number of subframes */ ) { int16_t i; diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index 9982f73aec..640f2721e6 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -1878,7 +1878,6 @@ static ivas_error create_parambin_HRTF_from_rawdata( } - /*---------------------------------------------------------------------* * load_fastconv_HRTF_from_binary() * -- GitLab From 8c9b8cc3c0fd33011baf95e62d2b18a54dcd9f4f Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Thu, 12 Sep 2024 09:36:47 +0200 Subject: [PATCH 20/29] revert changes to .gitlab-ci.yml --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 078cca2b01..a57b67497a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1231,7 +1231,7 @@ be-2-evs-windows: be-2-evs-linux: extends: - .test-job-linux - - .rules-merge-request + - .rules-main-push tags: - be-2-evs-temp stage: test -- GitLab From 0b305e74ae25edf1a33778eff9eadb72e7abbbc1 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Thu, 12 Sep 2024 11:35:25 +0200 Subject: [PATCH 21/29] remove "Float" notions from complexity template --- ci/complexity_measurements/index_complexity.html | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/ci/complexity_measurements/index_complexity.html b/ci/complexity_measurements/index_complexity.html index c4972eff5d..3b3964e9d8 100755 --- a/ci/complexity_measurements/index_complexity.html +++ b/ci/complexity_measurements/index_complexity.html @@ -58,14 +58,14 @@
-

IVAS FORMAT - Worst Case WMOPS Performance (Float, native SR)

+

IVAS FORMAT - Worst Case WMOPS Performance

@@ -129,7 +129,7 @@

IVAS FORMAT - Worst Case WMOPS Performance - per Operating Point (Float, native SR)

+ per Operating Point
@@ -192,7 +192,7 @@
--> -

IVAS FORMAT - Worst Case RAM Demand (Float)

+

IVAS FORMAT - Worst Case RAM Demand

@@ -251,7 +251,7 @@
--> -

IVAS FORMAT - Worst Case ROM Demand (Float)

+

IVAS FORMAT - Worst Case ROM Demand

-- GitLab From aeb471131e37e025fbe08b303d19e0c612bca93e Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Thu, 12 Sep 2024 14:03:53 +0200 Subject: [PATCH 22/29] add comment to explain the condition to decode a frame --- lib_dec/lib_dec.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 9bb50ed941..4d4a0c4f43 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -917,7 +917,10 @@ ivas_error IVAS_DEC_FeedFrame_Serial( hIvasDec->nSamplesAvailableNext = hIvasDec->nSamplesFrame; #ifdef OBJ_EDITING_API - /* decode TCs, do TSM and feed to renderer */ + /* Decode TCs, do TSM and feed to renderer. + If TSM is generally enabled, we have to wait for the first good frame. + Otherwise, we directly decode the first frame in any case. + */ if ( ( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm && hIvasDec->hasBeenFedFirstGoodFrame ) || !hIvasDec->st_ivas->hDecoderConfig->Opt_tsm ) { uint16_t l_ts, nTimeScalerOutSamples; -- GitLab From 1f43570770bd490d4f2fa568ef2377fa619e7e7a Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Mon, 16 Sep 2024 13:43:41 +0200 Subject: [PATCH 23/29] Change test_264444.py to recycle the logging and cmp_pcm tools --- tests/cmp_pcm.py | 3 +- tests/conftest.py | 10 +-- tests/test_26444.py | 148 ++++++++++++++++++++++++++++---------------- 3 files changed, 100 insertions(+), 61 deletions(-) diff --git a/tests/cmp_pcm.py b/tests/cmp_pcm.py index e299047492..72cd5af7ce 100755 --- a/tests/cmp_pcm.py +++ b/tests/cmp_pcm.py @@ -15,7 +15,7 @@ sys.path.append(os.path.join(os.path.dirname(THIS_PATH), "../scripts")) import numpy as np import pyaudio3dtools import pyivastest -from .constants import ODG_PATTERN_PQEVALAUDIO +from constants import ODG_PATTERN_PQEVALAUDIO def cmp_pcm( @@ -167,6 +167,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") + parser.add_argument("--get_odg", action="store_true") args = parser.parse_args() result, msg = cmp_pcm(**vars(args)) diff --git a/tests/conftest.py b/tests/conftest.py index 06658dd7e1..b6fffa197a 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -451,9 +451,6 @@ def ref_encoder_path(request) -> str: if request.config.option.ref_encoder_path: return request.config.option.ref_encoder_path - if request.config.option.update_ref == "0": - return None - # assume specifically named encoder when update_ref is selected, but no ref_encoder_path is specified here = Path(__file__).parent.resolve() system = platform.system() @@ -474,7 +471,7 @@ def ref_encoder_path(request) -> str: @pytest.fixture(scope="function") -def ref_encoder_frontend(ref_encoder_path, request) -> Union[None, EncoderFrontend]: +def ref_encoder_frontend(ref_encoder_path, request) -> EncoderFrontend: """ Return a :class:`conftest.EncoderFrontend` instance as REF for the test session. """ @@ -700,9 +697,6 @@ def ref_decoder_path(request) -> str: if request.config.option.ref_decoder_path: return request.config.option.ref_decoder_path - if request.config.option.update_ref == "0": - return None - # assume specifically named decoder when update_ref is selected, but no ref_decoder_path is specified here = Path(__file__).parent.resolve() system = platform.system() @@ -723,7 +717,7 @@ def ref_decoder_path(request) -> str: @pytest.fixture(scope="function") -def ref_decoder_frontend(ref_decoder_path, request) -> Union[None, DecoderFrontend]: +def ref_decoder_frontend(ref_decoder_path, request) -> DecoderFrontend: """ Return a :class:`conftest.DecoderFrontend` instance as DUT for the test session. """ diff --git a/tests/test_26444.py b/tests/test_26444.py index d23c01e8a8..cebc5eb045 100644 --- a/tests/test_26444.py +++ b/tests/test_26444.py @@ -34,10 +34,13 @@ Execute tests specified via a parameter file. import filecmp import os -import subprocess - +import re import pytest +from tests.cmp_pcm import cmp_pcm +from tests.conftest import DecoderFrontend, EncoderFrontend, parse_properties + + test_dict = {} TEST_DIR = "evs_be_test" scripts = [ @@ -47,6 +50,7 @@ scripts = [ "Readme_EVS_enc.txt", "Readme_JBM_dec.txt", ] + for s in scripts: with open(os.path.join(TEST_DIR, s), "r", encoding="UTF-8") as fp: tag = "" @@ -71,61 +75,101 @@ for s in scripts: diff_opts = "" @pytest.mark.parametrize("test_tag", list(test_dict.keys())) -def test_evs_26444(runner_frontend, test_tag): +def test_evs_26444( + record_property, + props_to_record, + dut_encoder_frontend: EncoderFrontend, + dut_decoder_frontend: DecoderFrontend, + ref_decoder_frontend: DecoderFrontend, + test_tag, + get_mld, + get_mld_lim, + abs_tol, + get_ssnr, + get_odg, +): enc_opts, dec_opts, diff_opts = test_dict[test_tag] - result = None - if enc_opts: - enc_opts = enc_opts.replace("./", TEST_DIR + "/") - enc_opts = enc_opts.replace("-rf rf_config.cfg", "-rf " + TEST_DIR + "/rf_config.cfg") # Special handling of this arguments since the path is missing - cmd = ["./IVAS_cod", "-q"] + enc_opts.split()[1:] - print(" ".join(["Encoder command: "] + cmd)) - runner_frontend.run(cmd) - if dec_opts: - dec_opts = dec_opts.replace("./", TEST_DIR + "/") - cmd = ["./IVAS_dec", "-q"] + dec_opts.split()[1:] - print(" ".join(["Decoder command: "] + cmd)) - runner_frontend.run(cmd) - - result = runner_frontend.result - - if result != None and result.returncode: - pytest.fail("Non-zero returncode for command: " + " ".join(cmd)) - diff_opts = diff_opts.replace("./", TEST_DIR + "/") - if ";" in diff_opts: - cmd1, cmd2 = diff_opts.split(";") - cmd1 = cmd1.split() - cmd2 = cmd2.split() - result1 = filecmp.cmp(cmd1[0], cmd1[1]) - result2 = filecmp.cmp(cmd2[2], cmd2[3]) - else: - cmd1 = diff_opts.split() - result1 = filecmp.cmp(cmd1[0], cmd1[1]) - result2 = True - if not (result1 and result2): - pytest.fail("Output differs") + if enc_opts: + args = enc_opts.split()[1:] -class Runner: - def __init__(self) -> None: - self.returncode = None - self.result = None + bitrate = args[-4] + sampling_rate = args[-3] + in_file = args[-2] + out_file = args[-1] + add_option_list = args[:-4] + + dut_encoder_frontend.run( + bitrate, + sampling_rate, + in_file, + out_file, + add_option_list=add_option_list, + run_dir=TEST_DIR, + ) - def run(self, cmd: str) -> None: - result = subprocess.run(cmd, capture_output=True, check=False) - self.result = result - self.returncode = result.returncode - def _check_run(self): - if self.returncode is not None: - if self.returncode: - pytest.fail( "Command terminated with a non-0 return code" ) - -@pytest.fixture(scope="function") -def runner_frontend() -> Runner: - runner = Runner() - yield runner + if dec_opts: + args = dec_opts.split()[1:] + output_config = "" # Empty for EVS operation + sampling_rate = args[-3] + in_file = args[-2] + out_file = args[-1] + add_option_list = args[:-3] + + dut_decoder_frontend.run( + output_config, + sampling_rate, + in_file, + out_file, + add_option_list=add_option_list, + run_dir=TEST_DIR, + ) + + # Run comparison on encoder and decoder test cases + equal = True + for diff_opt in diff_opts.split(';'): + pattern = r'(\$DIFF_BIN\s?-w\s?)?' + diff_opt = re.sub(pattern, '', diff_opt).strip() + [ref, test] = diff_opt.split()[:2] + if enc_opts and (get_mld or get_ssnr or get_odg): + for file in [ref, test]: + output_config = "" # Empty for EVS operation + in_file = file + out_file = file + '.wav' + add_option_list = [] + ref_decoder_frontend.run( + output_config, + sampling_rate, + in_file, + out_file, + add_option_list=add_option_list, + ) + + fs = int(sampling_rate) * 1000 + output_differs, reason = cmp_pcm( + ref + ".wav", + test + ".wav", + output_config, + fs, + get_mld=get_mld, + mld_lim=get_mld_lim, + abs_tol=abs_tol, + allow_differing_lengths=False, + get_ssnr=get_ssnr, + get_odg=get_odg, + ) + + props = parse_properties(reason, output_differs, props_to_record) + for k, v in props.items(): + record_property(k, v) + equal &= output_differs == False + + else: + equal &= filecmp.cmp(ref, test) + + if not equal: + pytest.fail("Output differs") - # Fixture teardown - runner._check_run() -- GitLab From e0c090e9359a7e822b5e146f86becce72cc9d791 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Mon, 16 Sep 2024 15:04:15 +0200 Subject: [PATCH 24/29] Add measurement of decoder outputs for test_26444 --- scripts/parse_xml_report.py | 17 ++++++++++++-- tests/test_26444.py | 45 +++++++++++++++++++++++-------------- 2 files changed, 43 insertions(+), 19 deletions(-) diff --git a/scripts/parse_xml_report.py b/scripts/parse_xml_report.py index 366e02aba5..627f11a55c 100644 --- a/scripts/parse_xml_report.py +++ b/scripts/parse_xml_report.py @@ -12,7 +12,7 @@ Parse a junit report and create a summary report. PROPERTIES = ["MLD", "MAXIMUM ABS DIFF", "MIN_SSNR", "MIN_ODG"] -FORMATS = { +IVAS_FORMATS = { "Stereo": r"stereo", "ISM": r"ISM", "Multichannel": r"Multi-channel", @@ -23,6 +23,15 @@ FORMATS = { "Renderer": r"renderer", } +EVS_FORMATS = { + "AMRWB I/O dec": r"Readme_AMRWB_IO_dec", + "AMRWB I/O enc": r"Readme_AMRWB_IO_enc", + "EVS dec": r"Readme_EVS_dec", + "EVS enc": r"Readme_EVS_enc", + "EVS JBM dec": r"Readme_JBM_dec", +} + + CATEGORIES = { "Normal operation": r".*", "DTX": r"DTX", @@ -42,10 +51,14 @@ if __name__ == "__main__": help="XML junit report input file, e.g. report-junit.xml", ) parser.add_argument("csv_file", type=str, help="Output CSV file, e.g. report.csv") + parser.add_argument("--evs", action="store_true") args = parser.parse_args() xml_report = args.xml_report csv_file = args.csv_file - + if (args.evs): + FORMATS = EVS_FORMATS + else: + FORMATS = IVAS_FORMATS tree = ElementTree.parse(xml_report) testsuite = tree.find(".//testsuite") diff --git a/tests/test_26444.py b/tests/test_26444.py index cebc5eb045..18bdd75b2e 100644 --- a/tests/test_26444.py +++ b/tests/test_26444.py @@ -36,6 +36,7 @@ import filecmp import os import re import pytest +import shutil from tests.cmp_pcm import cmp_pcm from tests.conftest import DecoderFrontend, EncoderFrontend, parse_properties @@ -134,24 +135,34 @@ def test_evs_26444( pattern = r'(\$DIFF_BIN\s?-w\s?)?' diff_opt = re.sub(pattern, '', diff_opt).strip() [ref, test] = diff_opt.split()[:2] - if enc_opts and (get_mld or get_ssnr or get_odg): - for file in [ref, test]: - output_config = "" # Empty for EVS operation - in_file = file - out_file = file + '.wav' - add_option_list = [] - ref_decoder_frontend.run( - output_config, - sampling_rate, - in_file, - out_file, - add_option_list=add_option_list, - ) - - fs = int(sampling_rate) * 1000 + # Run audio file comparison if MLD/SSNR/PEAQ is requested and the test is either a bitstream or audio (not JBM tracefile) + if (get_mld or get_ssnr or get_odg) and ("COD" in ref or "OUT" in ref): + if enc_opts: + for file in [ref, test]: + output_config = "" # Empty for EVS operation + in_file = file + out_file = file + '.wav' + add_option_list = [] + ref_decoder_frontend.run( + output_config, + sampling_rate, + in_file, + out_file, + add_option_list=add_option_list, + ) + fs = int(sampling_rate) * 1000 + reffile = ref + ".wav" + testfile = test + ".wav" + else: + fs = int(re.search(r'(\d+)kHz', ref).group(1)) * 1000 + # pyaudio3dtools.audiofile.readfile only handles .wav, .pcm and .raw suffixes. + reffile = ref +".pcm" + testfile = test + ".pcm" + shutil.copy(ref, reffile) + shutil.copy(test, testfile) output_differs, reason = cmp_pcm( - ref + ".wav", - test + ".wav", + reffile, + testfile, output_config, fs, get_mld=get_mld, -- GitLab From 2f743053b527d5c7e2a82677415d3c5dccd497b6 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Mon, 16 Sep 2024 15:41:27 +0200 Subject: [PATCH 25/29] Restore import in cmp_pcm.py --- tests/cmp_pcm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/cmp_pcm.py b/tests/cmp_pcm.py index 72cd5af7ce..d048fa4b10 100755 --- a/tests/cmp_pcm.py +++ b/tests/cmp_pcm.py @@ -15,7 +15,7 @@ sys.path.append(os.path.join(os.path.dirname(THIS_PATH), "../scripts")) import numpy as np import pyaudio3dtools import pyivastest -from constants import ODG_PATTERN_PQEVALAUDIO +from .constants import ODG_PATTERN_PQEVALAUDIO def cmp_pcm( -- GitLab From 9cb4fc22a97cc260bc2046bdca137782546a6e57 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Mon, 16 Sep 2024 16:44:42 +0200 Subject: [PATCH 26/29] Add EVS categories for improved parsing --- scripts/create_histogram_summary.py | 15 +++++++++++++-- scripts/parse_xml_report.py | 24 +++++++++++++++++------- 2 files changed, 30 insertions(+), 9 deletions(-) diff --git a/scripts/create_histogram_summary.py b/scripts/create_histogram_summary.py index 1ab951ac72..48f62d5641 100644 --- a/scripts/create_histogram_summary.py +++ b/scripts/create_histogram_summary.py @@ -10,7 +10,7 @@ matplotlib.use("Agg") import matplotlib.pyplot as plt import csv import os -from parse_xml_report import FORMATS, CATEGORIES +from parse_xml_report import IVAS_FORMATS, EVS_FORMATS, IVAS_CATEGORIES, EVS_CATEGORIES """ Parses a CSV report and creates a summary report. @@ -44,12 +44,23 @@ if __name__ == "__main__": help="Measure, any of: MLD, DIFF, SSNR, default: MLD", default=["MLD"], ) + parser.add_argument( + "--evs", + action="store_true", + help="Parse using EVS 26.444 formats", + ) args = parser.parse_args() csv_report = args.csv_report csv_summary = args.csv_summary csv_image = args.csv_image measure = args.measure[0] - + if args.evs: + FORMATS = EVS_FORMATS + CATEGORIES = EVS_CATEGORIES + else: + FORMATS = IVAS_FORMATS + CATEGORIES = IVAS_CATEGORIES + limits_per_measure = { "MLD": ("MLD", [0, 5, 10, math.inf]), "DIFF": ("MAXIMUM ABS DIFF", [0, 1024, 16384, 32769]), diff --git a/scripts/parse_xml_report.py b/scripts/parse_xml_report.py index 627f11a55c..396a86d977 100644 --- a/scripts/parse_xml_report.py +++ b/scripts/parse_xml_report.py @@ -24,15 +24,15 @@ IVAS_FORMATS = { } EVS_FORMATS = { - "AMRWB I/O dec": r"Readme_AMRWB_IO_dec", - "AMRWB I/O enc": r"Readme_AMRWB_IO_enc", - "EVS dec": r"Readme_EVS_dec", - "EVS enc": r"Readme_EVS_enc", - "EVS JBM dec": r"Readme_JBM_dec", + "AMRWBIO_dec": r"Readme_AMRWB_IO_dec", + "AMRWBIO_enc": r"Readme_AMRWB_IO_enc", + "EVS_dec": r"Readme_EVS_dec", + "EVS_enc": r"Readme_EVS_enc", + "EVS_JBM_dec": r"Readme_JBM_dec", } -CATEGORIES = { +IVAS_CATEGORIES = { "Normal operation": r".*", "DTX": r"DTX", "PLC": r"%", @@ -40,6 +40,14 @@ CATEGORIES = { "JBM": r"JBM", } +EVS_CATEGORIES = { + "Normal operation": r".*", + "DTX": r"DTX", + "PLC": r"b10|f06", + "Bitrate switching": r"sw", + "JBM": r"JBM", +} + # Main routine if __name__ == "__main__": parser = argparse.ArgumentParser( @@ -51,14 +59,16 @@ if __name__ == "__main__": help="XML junit report input file, e.g. report-junit.xml", ) parser.add_argument("csv_file", type=str, help="Output CSV file, e.g. report.csv") - parser.add_argument("--evs", action="store_true") + parser.add_argument("--evs", action="store_true", help="Parse using EVS 26.444 formats",) args = parser.parse_args() xml_report = args.xml_report csv_file = args.csv_file if (args.evs): FORMATS = EVS_FORMATS + CATEGORIES = EVS_CATEGORIES else: FORMATS = IVAS_FORMATS + CATEGORIES = IVAS_CATEGORIES tree = ElementTree.parse(xml_report) testsuite = tree.find(".//testsuite") -- GitLab From c523bb0aa446880c4cf4a07ab36704b953f06e42 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Tue, 17 Sep 2024 08:59:12 +0200 Subject: [PATCH 27/29] Restore conftest.py. Require -ref_decoder_path for audio comparison in test_26444 --- tests/conftest.py | 10 ++++++++-- tests/test_26444.py | 3 ++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index b6fffa197a..06658dd7e1 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -451,6 +451,9 @@ def ref_encoder_path(request) -> str: if request.config.option.ref_encoder_path: return request.config.option.ref_encoder_path + if request.config.option.update_ref == "0": + return None + # assume specifically named encoder when update_ref is selected, but no ref_encoder_path is specified here = Path(__file__).parent.resolve() system = platform.system() @@ -471,7 +474,7 @@ def ref_encoder_path(request) -> str: @pytest.fixture(scope="function") -def ref_encoder_frontend(ref_encoder_path, request) -> EncoderFrontend: +def ref_encoder_frontend(ref_encoder_path, request) -> Union[None, EncoderFrontend]: """ Return a :class:`conftest.EncoderFrontend` instance as REF for the test session. """ @@ -697,6 +700,9 @@ def ref_decoder_path(request) -> str: if request.config.option.ref_decoder_path: return request.config.option.ref_decoder_path + if request.config.option.update_ref == "0": + return None + # assume specifically named decoder when update_ref is selected, but no ref_decoder_path is specified here = Path(__file__).parent.resolve() system = platform.system() @@ -717,7 +723,7 @@ def ref_decoder_path(request) -> str: @pytest.fixture(scope="function") -def ref_decoder_frontend(ref_decoder_path, request) -> DecoderFrontend: +def ref_decoder_frontend(ref_decoder_path, request) -> Union[None, DecoderFrontend]: """ Return a :class:`conftest.DecoderFrontend` instance as DUT for the test session. """ diff --git a/tests/test_26444.py b/tests/test_26444.py index 18bdd75b2e..de1f4d0158 100644 --- a/tests/test_26444.py +++ b/tests/test_26444.py @@ -136,7 +136,8 @@ def test_evs_26444( diff_opt = re.sub(pattern, '', diff_opt).strip() [ref, test] = diff_opt.split()[:2] # Run audio file comparison if MLD/SSNR/PEAQ is requested and the test is either a bitstream or audio (not JBM tracefile) - if (get_mld or get_ssnr or get_odg) and ("COD" in ref or "OUT" in ref): + # and the ref_decoder_path is specified (otherwise ref_decoder_frontend is None) + if (get_mld or get_ssnr or get_odg) and ("COD" in ref or "OUT" in ref) and ref_decoder_frontend: if enc_opts: for file in [ref, test]: output_config = "" # Empty for EVS operation -- GitLab From ba2973ef2dee931a260869af8f6db5d0eb7784e8 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Tue, 17 Sep 2024 13:01:30 +0200 Subject: [PATCH 28/29] run formatter --- scripts/create_histogram_summary.py | 10 +++++---- scripts/parse_xml_report.py | 8 +++++-- tests/cmp_pcm.py | 20 ++++++++++++----- tests/test_26444.py | 35 ++++++++++++++++------------- 4 files changed, 45 insertions(+), 28 deletions(-) diff --git a/scripts/create_histogram_summary.py b/scripts/create_histogram_summary.py index 48f62d5641..6e940c883a 100644 --- a/scripts/create_histogram_summary.py +++ b/scripts/create_histogram_summary.py @@ -3,9 +3,11 @@ import argparse import math import numpy as np + # These next three lines are added as a precaution in case the gitlab runner # needs DISPLAY to render the plots, even if they are written to file. import matplotlib + matplotlib.use("Agg") import matplotlib.pyplot as plt import csv @@ -45,9 +47,9 @@ if __name__ == "__main__": default=["MLD"], ) parser.add_argument( - "--evs", - action="store_true", - help="Parse using EVS 26.444 formats", + "--evs", + action="store_true", + help="Parse using EVS 26.444 formats", ) args = parser.parse_args() csv_report = args.csv_report @@ -60,7 +62,7 @@ if __name__ == "__main__": else: FORMATS = IVAS_FORMATS CATEGORIES = IVAS_CATEGORIES - + limits_per_measure = { "MLD": ("MLD", [0, 5, 10, math.inf]), "DIFF": ("MAXIMUM ABS DIFF", [0, 1024, 16384, 32769]), diff --git a/scripts/parse_xml_report.py b/scripts/parse_xml_report.py index 396a86d977..3be7a9ca0b 100644 --- a/scripts/parse_xml_report.py +++ b/scripts/parse_xml_report.py @@ -59,11 +59,15 @@ if __name__ == "__main__": help="XML junit report input file, e.g. report-junit.xml", ) parser.add_argument("csv_file", type=str, help="Output CSV file, e.g. report.csv") - parser.add_argument("--evs", action="store_true", help="Parse using EVS 26.444 formats",) + parser.add_argument( + "--evs", + action="store_true", + help="Parse using EVS 26.444 formats", + ) args = parser.parse_args() xml_report = args.xml_report csv_file = args.csv_file - if (args.evs): + if args.evs: FORMATS = EVS_FORMATS CATEGORIES = EVS_CATEGORIES else: diff --git a/tests/cmp_pcm.py b/tests/cmp_pcm.py index d048fa4b10..5b335840e6 100755 --- a/tests/cmp_pcm.py +++ b/tests/cmp_pcm.py @@ -128,18 +128,26 @@ def cmp_pcm( def pqevalaudio_wrapper( - ref_sig: np.ndarray, - eval_sig: np.ndarray, - fs: int, - ) -> str: + ref_sig: np.ndarray, + eval_sig: np.ndarray, + fs: int, +) -> str: with tempfile.TemporaryDirectory() as tmp_dir: tmp_dir = Path(tmp_dir) tmp_file_ref = str(tmp_dir.joinpath("ref.wav")) tmp_file_eval = str(tmp_dir.joinpath("eval.wav")) # PQevalAudio neeeds 48 kHz sampling rate - r48 = np.clip( pyaudio3dtools.audioarray.resample(ref_sig.astype(float), fs, 48000), -32768, 32767 ).astype(np.int16) - t48 = np.clip( pyaudio3dtools.audioarray.resample(eval_sig.astype(float), fs, 48000), -32768, 32767 ).astype(np.int16) + r48 = np.clip( + pyaudio3dtools.audioarray.resample(ref_sig.astype(float), fs, 48000), + -32768, + 32767, + ).astype(np.int16) + t48 = np.clip( + pyaudio3dtools.audioarray.resample(eval_sig.astype(float), fs, 48000), + -32768, + 32767, + ).astype(np.int16) pyaudio3dtools.audiofile.writefile(tmp_file_ref, r48, 48000) pyaudio3dtools.audiofile.writefile(tmp_file_eval, t48, 48000) diff --git a/tests/test_26444.py b/tests/test_26444.py index de1f4d0158..bd3fb98c0c 100644 --- a/tests/test_26444.py +++ b/tests/test_26444.py @@ -75,6 +75,7 @@ for s in scripts: dec_opts = "" diff_opts = "" + @pytest.mark.parametrize("test_tag", list(test_dict.keys())) def test_evs_26444( record_property, @@ -87,10 +88,10 @@ def test_evs_26444( get_mld_lim, abs_tol, get_ssnr, - get_odg, + get_odg, ): enc_opts, dec_opts, diff_opts = test_dict[test_tag] - + diff_opts = diff_opts.replace("./", TEST_DIR + "/") if enc_opts: @@ -101,7 +102,7 @@ def test_evs_26444( in_file = args[-2] out_file = args[-1] add_option_list = args[:-4] - + dut_encoder_frontend.run( bitrate, sampling_rate, @@ -111,10 +112,9 @@ def test_evs_26444( run_dir=TEST_DIR, ) - if dec_opts: args = dec_opts.split()[1:] - output_config = "" # Empty for EVS operation + output_config = "" # Empty for EVS operation sampling_rate = args[-3] in_file = args[-2] out_file = args[-1] @@ -127,22 +127,26 @@ def test_evs_26444( out_file, add_option_list=add_option_list, run_dir=TEST_DIR, - ) + ) # Run comparison on encoder and decoder test cases equal = True - for diff_opt in diff_opts.split(';'): - pattern = r'(\$DIFF_BIN\s?-w\s?)?' - diff_opt = re.sub(pattern, '', diff_opt).strip() + for diff_opt in diff_opts.split(";"): + pattern = r"(\$DIFF_BIN\s?-w\s?)?" + diff_opt = re.sub(pattern, "", diff_opt).strip() [ref, test] = diff_opt.split()[:2] # Run audio file comparison if MLD/SSNR/PEAQ is requested and the test is either a bitstream or audio (not JBM tracefile) # and the ref_decoder_path is specified (otherwise ref_decoder_frontend is None) - if (get_mld or get_ssnr or get_odg) and ("COD" in ref or "OUT" in ref) and ref_decoder_frontend: + if ( + (get_mld or get_ssnr or get_odg) + and ("COD" in ref or "OUT" in ref) + and ref_decoder_frontend + ): if enc_opts: for file in [ref, test]: - output_config = "" # Empty for EVS operation + output_config = "" # Empty for EVS operation in_file = file - out_file = file + '.wav' + out_file = file + ".wav" add_option_list = [] ref_decoder_frontend.run( output_config, @@ -155,9 +159,9 @@ def test_evs_26444( reffile = ref + ".wav" testfile = test + ".wav" else: - fs = int(re.search(r'(\d+)kHz', ref).group(1)) * 1000 - # pyaudio3dtools.audiofile.readfile only handles .wav, .pcm and .raw suffixes. - reffile = ref +".pcm" + fs = int(re.search(r"(\d+)kHz", ref).group(1)) * 1000 + # pyaudio3dtools.audiofile.readfile only handles .wav, .pcm and .raw suffixes. + reffile = ref + ".pcm" testfile = test + ".pcm" shutil.copy(ref, reffile) shutil.copy(test, testfile) @@ -184,4 +188,3 @@ def test_evs_26444( if not equal: pytest.fail("Output differs") - -- GitLab From 2822dd963a3c469cf366c601065b54e2e24f4355 Mon Sep 17 00:00:00 2001 From: norvell Date: Tue, 17 Sep 2024 11:10:20 +0000 Subject: [PATCH 29/29] Update test_26444.py --- tests/test_26444.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_26444.py b/tests/test_26444.py index bd3fb98c0c..fa6214c66a 100644 --- a/tests/test_26444.py +++ b/tests/test_26444.py @@ -181,7 +181,7 @@ def test_evs_26444( props = parse_properties(reason, output_differs, props_to_record) for k, v in props.items(): record_property(k, v) - equal &= output_differs == False + equal &= not output_differs else: equal &= filecmp.cmp(ref, test) -- GitLab