diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index b534415e15956aeb24cdd2c8bc938cd729a48478..779b328d979deb5caa6f25277f0786b5f3ffe410 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -3039,7 +3039,11 @@ void mctStereoIGF_enc( MCT_ENC_HANDLE hMCT, /* i/o: MCT encoder structure */ Encoder_State **sts, /* i/o: encoder state structure */ float *orig_spectrum[MCT_MAX_CHANNELS][NB_DIV], /* i : MDCT spectrum for ITF */ +#ifdef NONBE_FIX_1097_SBA_DTX_BRATE_SWITCHING_ENC + float *powerSpec[MCT_MAX_CHANNELS], /* i/o: MDCT^2 + MDST^2 spectrum,or estimate */ +#else float powerSpec[MCT_MAX_CHANNELS][L_FRAME48k], /* i/o: MDCT^2 + MDST^2 spectrum,or estimate */ +#endif float *powerSpecMsInv[MCT_MAX_CHANNELS][NB_DIV], /* i : same as above but for inverse spect. */ float *inv_spectrum[MCT_MAX_CHANNELS][NB_DIV], /* i : inverse spectrum */ const int16_t sp_aud_decision0[MCT_MAX_CHANNELS] /* i : speech audio decision */ diff --git a/lib_com/ivas_stereo_td_bit_alloc.c b/lib_com/ivas_stereo_td_bit_alloc.c index cdcfa3cbc10f49f2a435a4a2fc8770875f7ad724..07bdfb73a8bc0ad506554b79e8d020befc97db17 100644 --- a/lib_com/ivas_stereo_td_bit_alloc.c +++ b/lib_com/ivas_stereo_td_bit_alloc.c @@ -456,17 +456,48 @@ void td_stereo_param_updt( if ( tdm_use_IAWB_Ave_lpc == 1 ) { mvr2r( IAWB_Ave, tdm_lsfQ_PCh, M ); + +#ifdef FIX_1111_TDM_LSP_BUFFER + if ( tdm_lspQ_PCh != NULL ) + { + lsf2lsp( tdm_lsfQ_PCh, tdm_lspQ_PCh, M, INT_FS_12k8 ); + } +#else lsf2lsp( tdm_lsfQ_PCh, tdm_lspQ_PCh, M, INT_FS_12k8 ); +#endif } else if ( flag_ACELP16k == 1 ) { +#ifdef FIX_1111_TDM_LSP_BUFFER + if ( tdm_lspQ_PCh != NULL ) + { + mvr2r( lsp_old_PCh, tdm_lspQ_PCh, M ); + lsp_convert_poly( tdm_lspQ_PCh, L_FRAME, 0 ); + lsp2lsf( tdm_lspQ_PCh, tdm_lsfQ_PCh, M, INT_FS_12k8 ); + } + else + { + float lsp_temp[M]; + mvr2r( lsp_old_PCh, lsp_temp, M ); + lsp_convert_poly( lsp_temp, L_FRAME, 0 ); + lsp2lsf( lsp_temp, tdm_lsfQ_PCh, M, INT_FS_12k8 ); + } +#else mvr2r( lsp_old_PCh, tdm_lspQ_PCh, M ); lsp_convert_poly( tdm_lspQ_PCh, L_FRAME, 0 ); lsp2lsf( tdm_lspQ_PCh, tdm_lsfQ_PCh, M, INT_FS_12k8 ); +#endif } else { +#ifdef FIX_1111_TDM_LSP_BUFFER + if ( tdm_lspQ_PCh != NULL ) + { + mvr2r( lsp_old_PCh, tdm_lspQ_PCh, M ); + } +#else mvr2r( lsp_old_PCh, tdm_lspQ_PCh, M ); +#endif mvr2r( lsf_old_PCh, tdm_lsfQ_PCh, M ); } diff --git a/lib_com/options.h b/lib_com/options.h index 02e3196e52d0c359de038b315a8ac36681f206ca..6a7b5fc9810151e1f2b5063e221f0a5106b7e31c 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -158,10 +158,11 @@ //#define FIX_CREND_FIX_POINT_HRTF_FILE_FORMAT /* Orange issue 1031 : new fix point hrtf binary file format */ //#define FIX_CREND_SIMPLIFY_CODE /* Ora : simplify line code in crend */ #define FLOAT_FIX_POINT_HRTF_FILE_FORMAT /* allows reading floation or fix point hrtf binary file format */ +#define FIX_1115_FASTCONV_HRTF_FILE_LOAD /* FhG: issue 1115: fix crash when loading FastConv-only binary HRTF file */ #define FIX_1099_JBM_MD_HANDLE_ALLOC /* VA: issue 1099: Limit the allocation of `hJbmMetadata` handle to MASA and OMASA only */ - +#define FIX_1111_TDM_LSP_BUFFER /* VA: issue 1111: remove unused buffer `tdm_lspQ_PCh[]' */ /* #################### End BE switches ################################## */ @@ -169,7 +170,10 @@ /* any switch which is non-be wrt selection floating point code */ /* all switches in this category should start with "NONBE_" */ -#define NONBE_FIX_1070_USAN_SEGFAULT_MC_TO_BIN_BTSW_HEADROT /* fix 1070 USAN: nullptr-with-offset and Segfaults in 7_1_4 to BINAURAL and BINAURAL_ROOM_REVERB decoding with bitrate switching and head rotation*/ +#define NONBE_FIX_1070_USAN_SEGFAULT_MC_TO_BIN_BTSW_HEADROT /* fix 1070 USAN: nullptr-with-offset and Segfaults in 7_1_4 to BINAURAL and BINAURAL_ROOM_REVERB decoding with bitrate switching and head rotation*/ +#define REVERT_ZERO_FLUSH_TRESH /* FhG: issue 1069: revert threshold value introduced with !1518 due to significant complexity increase*/ +#define NONBE_FIX_1097_SBA_DTX_BRATE_SWITCHING_ENC /* FhG: fix out-of-bound errors when switching from SID frame to active frame*/ + /* ##################### End NON-BE switches ########################### */ /* ################## End DEVELOPMENT switches ######################### */ diff --git a/lib_dec/ivas_binRenderer_internal.c b/lib_dec/ivas_binRenderer_internal.c index 1c317c20b63dee2abd0c78e2151851a33f18da76..fbf8c916a0425139b6a2889dd48972d8ab799696 100644 --- a/lib_dec/ivas_binRenderer_internal.c +++ b/lib_dec/ivas_binRenderer_internal.c @@ -618,11 +618,15 @@ ivas_error ivas_allocate_binaural_hrtf( if ( renderer_type == RENDERER_BINAURAL_FASTCONV || bin_input_config == BINAURAL_INPUT_AUDIO_CONFIG_COMBINED ) { +#ifndef FIX_1115_FASTCONV_HRTF_FILE_LOAD if ( ( HrtfFastConv->leftHRIRReal != NULL ) && ( HrtfFastConv->leftHRIRImag != NULL ) && ( HrtfFastConv->rightHRIRReal != NULL ) && ( HrtfFastConv->rightHRIRImag != NULL ) ) { return IVAS_ERR_OK; } else +#else + if ( ( HrtfFastConv->leftHRIRReal == NULL ) && ( HrtfFastConv->leftHRIRImag == NULL ) && ( HrtfFastConv->rightHRIRReal == NULL ) && ( HrtfFastConv->rightHRIRImag == NULL ) ) +#endif { if ( IVAS_ERR_OK != ivas_alloc_pppMem( &HrtfFastConv->leftHRIRReal, BINAURAL_CONVBANDS, HRTF_LS_CHANNELS, BINAURAL_NTAPS, allocate_init_flag ) ) @@ -646,11 +650,15 @@ ivas_error ivas_allocate_binaural_hrtf( if ( renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || bin_input_config == BINAURAL_INPUT_AUDIO_CONFIG_COMBINED ) { +#ifndef FIX_1115_FASTCONV_HRTF_FILE_LOAD if ( ( HrtfFastConv->leftBRIRReal != NULL ) && ( HrtfFastConv->leftBRIRImag != NULL ) && ( HrtfFastConv->rightBRIRReal != NULL ) && ( HrtfFastConv->rightBRIRImag != NULL ) ) { return IVAS_ERR_OK; } else +#else + if ( ( HrtfFastConv->leftBRIRReal == NULL ) && ( HrtfFastConv->leftBRIRImag == NULL ) && ( HrtfFastConv->rightBRIRReal == NULL ) && ( HrtfFastConv->rightBRIRImag == NULL ) ) +#endif { if ( IVAS_ERR_OK != ivas_alloc_pppMem( &HrtfFastConv->leftBRIRReal, BINAURAL_CONVBANDS, HRTF_LS_CHANNELS, BINAURAL_NTAPS_MAX, allocate_init_flag ) ) { diff --git a/lib_dec/ivas_svd_dec.c b/lib_dec/ivas_svd_dec.c index ebef0644ee3dfbf60bc89cdb20ceb4d8600f8708..5c84af950b601e679f4727531e88ca82e0029f8a 100644 --- a/lib_dec/ivas_svd_dec.c +++ b/lib_dec/ivas_svd_dec.c @@ -48,10 +48,14 @@ *-----------------------------------------------------------------------*/ /* The SVD is sensitive to changes to the following constants, so please be careful when trying to tune things */ -#define SVD_MINIMUM_VALUE 1e-32f /* minimum value */ -#define CONVERGENCE_FACTOR 1.0e-04f /* factor for SVD convergence */ -#define SVD_MAX_NUM_ITERATION 75 /* maximum number of interations before exiting the SVD */ +#define SVD_MINIMUM_VALUE 1e-32f /* minimum value */ +#define CONVERGENCE_FACTOR 1.0e-04f /* factor for SVD convergence */ +#define SVD_MAX_NUM_ITERATION 75 /* maximum number of interations before exiting the SVD */ +#ifdef REVERT_ZERO_FLUSH_TRESH +#define SVD_ZERO_FLUSH_THRESHOLD 1.0e-20f +#else #define SVD_ZERO_FLUSH_THRESHOLD 0.0f +#endif /*-----------------------------------------------------------------------* diff --git a/lib_enc/ivas_core_enc.c b/lib_enc/ivas_core_enc.c index 27161bec33b9df8d2231325bea95292c8adb5827..e8a3267687b2bee8825c8d791ac1f199862c441c 100644 --- a/lib_enc/ivas_core_enc.c +++ b/lib_enc/ivas_core_enc.c @@ -99,7 +99,11 @@ ivas_error ivas_core_enc( int16_t Voicing_flag[CPE_CHANNELS]; float pitch_buf[CPE_CHANNELS][NB_SUBFR16k]; int16_t unbits[CPE_CHANNELS]; +#ifdef FIX_1111_TDM_LSP_BUFFER + float tdm_lsfQ_PCh[M]; +#else float tdm_lspQ_PCh[M], tdm_lsfQ_PCh[M]; +#endif int16_t last_element_mode, tdm_Pitch_reuse_flag; int32_t element_brate, last_element_brate, input_Fs; int16_t diff_nBits; @@ -270,7 +274,11 @@ ivas_error ivas_core_enc( if ( st->element_mode == IVAS_CPE_TD && n == 0 ) { +#ifdef FIX_1111_TDM_LSP_BUFFER + td_stereo_param_updt( st->lsp_old, st->lsf_old, pitch_buf[0], NULL, tdm_lsfQ_PCh, hStereoTD->tdm_Pri_pitch_buf, st->flag_ACELP16k, hStereoTD->tdm_use_IAWB_Ave_lpc ); +#else td_stereo_param_updt( st->lsp_old, st->lsf_old, pitch_buf[0], tdm_lspQ_PCh, tdm_lsfQ_PCh, hStereoTD->tdm_Pri_pitch_buf, st->flag_ACELP16k, hStereoTD->tdm_use_IAWB_Ave_lpc ); +#endif } } diff --git a/lib_enc/ivas_mct_core_enc.c b/lib_enc/ivas_mct_core_enc.c index cf2f3d8afd28a0848dfc59db79bf6ba2ca4b77be..0cd304696add7d59d0ba45e68c83b213dfcbf54f 100644 --- a/lib_enc/ivas_mct_core_enc.c +++ b/lib_enc/ivas_mct_core_enc.c @@ -197,13 +197,27 @@ void ivas_mct_core_enc( int16_t i, cpe_id, n, nAvailBits; int16_t nCPE; float *orig_spectrum[MCT_MAX_CHANNELS][2]; /* Pointers to MDCT output for a short block (L/R) */ +#ifdef NONBE_FIX_1097_SBA_DTX_BRATE_SWITCHING_ENC + float powerSpecMsInv_long_cpe0[CPE_CHANNELS][L_FRAME_PLUS]; + float inv_spectrum_long_cpe0[CPE_CHANNELS][L_FRAME_PLUS]; + float powerSpec_long_cpe0[CPE_CHANNELS][L_FRAME_PLUS]; + float powerSpec_long[MCT_MAX_CHANNELS - CPE_CHANNELS][L_FRAME48k]; + float inv_spectrum_long[MCT_MAX_CHANNELS - CPE_CHANNELS][L_FRAME48k]; /* quantized MDCT spectrum, inv ms mask mdst spectrum, scratch for MS spectra in the MS decision */ + float powerSpecMsInv_long[MCT_MAX_CHANNELS - CPE_CHANNELS][L_FRAME48k]; /* MS inv power spectrum, also inverse MDST spectrum */ +#else float powerSpec[MCT_MAX_CHANNELS][L_FRAME48k]; float powerSpecMsInv_long[MCT_MAX_CHANNELS][L_FRAME48k]; /* MS inv power spectrum, also inverse MDST spectrum */ +#endif +#ifdef NONBE_FIX_1097_SBA_DTX_BRATE_SWITCHING_ENC + float *powerSpec[MCT_MAX_CHANNELS]; +#endif float *powerSpecMsInv[MCT_MAX_CHANNELS][2]; float *inv_mdst_spectrum[MCT_MAX_CHANNELS][2]; float *inv_spectrum[MCT_MAX_CHANNELS][2]; float *mdst_spectrum[MCT_MAX_CHANNELS][2]; +#ifndef NONBE_FIX_1097_SBA_DTX_BRATE_SWITCHING_ENC float inv_spectrum_long[MCT_MAX_CHANNELS][L_FRAME48k]; /* quantized MDCT spectrum, inv ms mask mdst spectrum, scratch for MS spectra in the MS decision */ +#endif int16_t total_side_bits; int16_t chBitRatios[MCT_MAX_CHANNELS]; Encoder_State *sts[MCT_MAX_CHANNELS]; @@ -238,12 +252,29 @@ void ivas_mct_core_enc( nCPE++; } +#ifdef NONBE_FIX_1097_SBA_DTX_BRATE_SWITCHING_ENC + /* point first CPE channels to longer buffers where switching from ACELP to TCX may occur in SBA with DTX (total memory saving)*/ + for ( ch = 0; ch < CPE_CHANNELS; ch++ ) + { + inv_mdst_spectrum[ch][0] = powerSpecMsInv[ch][0] = powerSpecMsInv_long_cpe0[ch]; + inv_mdst_spectrum[ch][1] = powerSpecMsInv[ch][1] = powerSpecMsInv_long_cpe0[ch] + N_TCX10_MAX; + inv_spectrum[ch][0] = inv_spectrum_long_cpe0[ch]; + inv_spectrum[ch][1] = inv_spectrum_long_cpe0[ch] + N_TCX10_MAX; + powerSpec[ch] = powerSpec_long_cpe0[ch]; + } + + for ( ch = CPE_CHANNELS; ch < nChannels; ch++ ) +#else for ( ch = 0; ch < nChannels; ch++ ) +#endif { - inv_mdst_spectrum[ch][0] = powerSpecMsInv[ch][0] = powerSpecMsInv_long[ch]; - inv_mdst_spectrum[ch][1] = powerSpecMsInv[ch][1] = powerSpecMsInv_long[ch] + N_TCX10_MAX; - inv_spectrum[ch][0] = inv_spectrum_long[ch]; - inv_spectrum[ch][1] = inv_spectrum_long[ch] + N_TCX10_MAX; + inv_mdst_spectrum[ch][0] = powerSpecMsInv[ch][0] = powerSpecMsInv_long[ch - CPE_CHANNELS]; + inv_mdst_spectrum[ch][1] = powerSpecMsInv[ch][1] = powerSpecMsInv_long[ch - CPE_CHANNELS] + N_TCX10_MAX; + inv_spectrum[ch][0] = inv_spectrum_long[ch - CPE_CHANNELS]; + inv_spectrum[ch][1] = inv_spectrum_long[ch - CPE_CHANNELS] + N_TCX10_MAX; +#ifdef NONBE_FIX_1097_SBA_DTX_BRATE_SWITCHING_ENC + powerSpec[ch] = powerSpec_long[ch - CPE_CHANNELS]; +#endif } for ( cpe_id = 0, i = 0; cpe_id < nCPE; cpe_id++ ) diff --git a/lib_enc/ivas_mct_enc_mct.c b/lib_enc/ivas_mct_enc_mct.c old mode 100755 new mode 100644 index 4e0096984762626539124552b3c40151cd03f306..e8c98e9a726ad3be7af10f522e3e23b2a2f3c651 --- a/lib_enc/ivas_mct_enc_mct.c +++ b/lib_enc/ivas_mct_enc_mct.c @@ -814,10 +814,14 @@ void write_mct_bitstream( *--------------------------------------------------------------------*/ void mctStereoIGF_enc( - MCT_ENC_HANDLE hMCT, /* i/o: MCT encoder structure */ - Encoder_State **sts, /* i/o: encoder state structure */ - float *orig_spectrum[MCT_MAX_CHANNELS][2], /* i : MDCT spectrum for ITF */ - float powerSpec[MCT_MAX_CHANNELS][L_FRAME48k], /* i/o: MDCT^2 + MDST^2 spectrum,or estimate*/ + MCT_ENC_HANDLE hMCT, /* i/o: MCT encoder structure */ + Encoder_State **sts, /* i/o: encoder state structure */ + float *orig_spectrum[MCT_MAX_CHANNELS][2], /* i : MDCT spectrum for ITF */ +#ifdef NONBE_FIX_1097_SBA_DTX_BRATE_SWITCHING_ENC + float *powerSpec[MCT_MAX_CHANNELS], /* i/o: MDCT^2 + MDST^2 spectrum,or estimate*/ +#else + float powerSpec[MCT_MAX_CHANNELS][L_FRAME48k], /* i/o: MDCT^2 + MDST^2 spectrum,or estimate*/ +#endif float *powerSpecMsInv[MCT_MAX_CHANNELS][NB_DIV], /* i : same as above but for inverse spect.*/ float *inv_spectrum[MCT_MAX_CHANNELS][NB_DIV], /* i : inverse spectrum */ const int16_t sp_aud_decision0[MCT_MAX_CHANNELS] /* i : speech audio decision */ diff --git a/tests/codec_be_on_mr_nonselection/test_param_file.py b/tests/codec_be_on_mr_nonselection/test_param_file.py index 619e25276734d59b4da909b556358a3020fc817b..eee9fcd9b274eaadbff8e1c21f222ca397a04458 100644 --- a/tests/codec_be_on_mr_nonselection/test_param_file.py +++ b/tests/codec_be_on_mr_nonselection/test_param_file.py @@ -330,8 +330,8 @@ def test_param_file_tests( ref_tracefile_dec = f"{reference_path}/param_file/dec/{tracefile_dec}" # check for same RTP sequence number in last line of tracefile - dut_rtp_num_last = np.genfromtxt(dut_tracefile_dec, delimiter=";")[-1,0] - ref_rtp_num_last = np.genfromtxt(ref_tracefile_dec, delimiter=";")[-1,0] + dut_rtp_num_last = np.genfromtxt(dut_tracefile_dec, delimiter=";", usecols=[0])[-1] + ref_rtp_num_last = np.genfromtxt(ref_tracefile_dec, delimiter=";", usecols=[0])[-1] tracefile_last_rtp_numbers_differ = dut_rtp_num_last != ref_rtp_num_last # same sequence number -> likely no crash, assume length difference is due to difference in TSM