diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 3376e42adf91c6971bbc34ee04c276b39c750697..132922102b58510346a2185b6fb48f2211414a75 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -2958,6 +2958,13 @@ int16_t check_bounds_s( const int16_t high /* i : High limit */ ); +#ifdef FIX_CRASH_LONG_BRIR +void set_zero_l( + float *vec, /* o : input vector */ + const uint32_t lvec /* i : length of the vector */ +); +#endif + ivas_error stereo_memory_enc( CPE_ENC_HANDLE hCPE, /* i : CPE encoder structure */ const int32_t input_Fs, /* i : input sampling rate */ diff --git a/lib_com/ivas_tools.c b/lib_com/ivas_tools.c index c2183e0e061d86a39f51bd747a053e5fcdf0d431..7d4b0f2c64c8cec26634bb4715260b63410d67db 100644 --- a/lib_com/ivas_tools.c +++ b/lib_com/ivas_tools.c @@ -581,6 +581,28 @@ int16_t check_bounds_s( return value_adj; } +#ifdef FIX_CRASH_LONG_BRIR +/*---------------------------------------------------------------------* + * set_zero_l() + * + * Set a vector vec[] of dimension lvec to zero + *---------------------------------------------------------------------*/ + +void set_zero_l( + float *vec, /* i/o: input/output vector */ + const uint32_t lvec /* i : length of the vector */ +) +{ + uint32_t i; + + for ( i = 0; i < lvec; i++ ) + { + *vec++ = 0.0f; + } + + return; +} +#endif /****************************************************************************/ /* matrix functions */ diff --git a/lib_com/options.h b/lib_com/options.h index eb867740b67ae57e8d20257e2928fca959066471..1be21d8c9d6fb43bc1ad572fca58093cf89946f5 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -184,7 +184,6 @@ #define NONBE_FIX_1277_EVS_DTX_HIGH_RATE_THRESHOLD /* VA/Eri: FLP issue 1277: Fix Mismatch in DTX high-rate threshold between EVS float and BASOP */ #define NONBE_FIX_708_OSBA_BR_SWITCHING_CRASH /* FhG: issue 708: fix crash in OSBA BR switching with long test vectors */ - #define NONBE_1319_M2R_PRECISION_ALIGN /* Nokia: bring updates from PC code related to OMASA masa2total ratios */ /* #################### End FIXES switches ############################ */ @@ -209,6 +208,7 @@ #define FIX_910_REMOVE_DUPLICATION_TD_REND /* VA: issue 910: remove duplication of function ivas_td_binaural_renderer() */ #define FIX_940_DEBUGGING_VARIABLE /* Nokia: issue #940: remove debugging variable */ #define NONBE_FIX_931_IGF_STEREO_DEC_NOISE /* FhG: issue #931: fix noise substitution in the stereo IGF decoder */ +#define FIX_CRASH_LONG_BRIR /* Orange : Fix crash when long BRIR is set */ /* #################### End BASOP porting switches ############################ */ diff --git a/lib_rend/ivas_crend.c b/lib_rend/ivas_crend.c index 06e91135c2fc2a92f8fd13007433e7191b229dad..a6fc32866fadf7bf511f1a2f1075ab1cff06a397 100644 --- a/lib_rend/ivas_crend.c +++ b/lib_rend/ivas_crend.c @@ -1249,7 +1249,11 @@ ivas_error ivas_rend_openCrend( ) { int16_t i, subframe_length; +#ifdef FIX_CRASH_LONG_BRIR + int32_t max_total_ir_len; +#else int16_t max_total_ir_len; +#endif HRTFS_HANDLE hHrtf; CREND_HANDLE hCrend; ivas_error error; @@ -1299,13 +1303,21 @@ ivas_error ivas_rend_openCrend( { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); } +#ifdef FIX_CRASH_LONG_BRIR + set_zero_l( hCrend->freq_buffer_re[i], max_total_ir_len ); +#else set_zero( hCrend->freq_buffer_re[i], max_total_ir_len ); +#endif if ( ( hCrend->freq_buffer_im[i] = (float *) malloc( sizeof( float ) * max_total_ir_len ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); } +#ifdef FIX_CRASH_LONG_BRIR + set_zero_l( hCrend->freq_buffer_im[i], max_total_ir_len ); +#else set_zero( hCrend->freq_buffer_im[i], max_total_ir_len ); +#endif } for ( i = 0; i < BINAURAL_CHANNELS; i++ ) @@ -1314,7 +1326,11 @@ ivas_error ivas_rend_openCrend( { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); } +#ifdef FIX_CRASH_LONG_BRIR + set_zero_l( hCrend->prev_out_buffer[i], subframe_length ); +#else set_zero( hCrend->prev_out_buffer[i], subframe_length ); +#endif } max_total_ir_len = hHrtf->num_iterations_diffuse[0] * subframe_length; @@ -1325,13 +1341,21 @@ ivas_error ivas_rend_openCrend( { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); } +#ifdef FIX_CRASH_LONG_BRIR + set_zero_l( hCrend->freq_buffer_re_diffuse, max_total_ir_len ); +#else set_zero( hCrend->freq_buffer_re_diffuse, max_total_ir_len ); +#endif if ( ( hCrend->freq_buffer_im_diffuse = (float *) malloc( sizeof( float ) * max_total_ir_len ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); } +#ifdef FIX_CRASH_LONG_BRIR + set_zero_l( hCrend->freq_buffer_im_diffuse, max_total_ir_len ); +#else set_zero( hCrend->freq_buffer_im_diffuse, max_total_ir_len ); +#endif } else { @@ -1346,7 +1370,11 @@ ivas_error ivas_rend_openCrend( { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); } +#ifdef FIX_CRASH_LONG_BRIR + set_zero_l( hCrend->lfe_delay_line, max_total_ir_len ); +#else set_zero( hCrend->lfe_delay_line, max_total_ir_len ); +#endif } else { @@ -1589,7 +1617,11 @@ static ivas_error ivas_rend_crendConvolver( int16_t i, j, k, m; int16_t subframe_length, idx_in; int16_t lfe_idx_in; +#ifdef FIX_CRASH_LONG_BRIR + int32_t offset, offset_in, offset_diffuse; +#else int16_t offset, offset_in, offset_diffuse; +#endif int16_t nchan_in, nchan_out; const float *pIn; float *pFreq_buf_re, *pFreq_buf_im;