From ba5ac41d3d5c622606ca23be55a2e67f12eb6af9 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Tue, 8 Apr 2025 15:21:28 +0200 Subject: [PATCH 1/4] port commit 64b4d63f2414406e8f5ed7e07cec6258a3a890c4 on top of main-pc --- lib_com/options.h | 1 + lib_rend/ivas_crend_fx.c | 66 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index 70b82e17f..67ef4c3d1 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -194,6 +194,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_1440_PORT_1202_FROM_FLT_REPO /* Orange : port 1202 Fix crash when long BRIR is set */ /* #################### End BASOP porting switches ############################ */ diff --git a/lib_rend/ivas_crend_fx.c b/lib_rend/ivas_crend_fx.c index 8daeb7cf4..5960fe8ce 100644 --- a/lib_rend/ivas_crend_fx.c +++ b/lib_rend/ivas_crend_fx.c @@ -1526,7 +1526,11 @@ ivas_error ivas_rend_openCrend( ) { Word16 i, subframe_length; +#ifdef FIX_1440_PORT_1202_FROM_FLT_REPO + Word32 max_total_ir_len; +#else Word16 max_total_ir_len; +#endif HRTFS_HANDLE hHrtf; CREND_HANDLE hCrend; ivas_error error; @@ -1569,7 +1573,11 @@ ivas_error ivas_rend_openCrend( IF( hHrtf != NULL ) { +#ifdef FIX_1440_PORT_1202_FROM_FLT_REPO + max_total_ir_len = L_mult0( hHrtf->max_num_iterations, subframe_length ); +#else max_total_ir_len = imult1616( hHrtf->max_num_iterations, subframe_length ); +#endif FOR( i = 0; i < hHrtf->max_num_ir; i++ ) { @@ -1577,12 +1585,20 @@ ivas_error ivas_rend_openCrend( { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); } +#ifdef FIX_1440_PORT_1202_FROM_FLT_REPO + set_zero2_fx( hCrend->freq_buffer_re_fx[i], max_total_ir_len ); +#else set_zero_fx( hCrend->freq_buffer_re_fx[i], max_total_ir_len ); +#endif IF( ( hCrend->freq_buffer_im_fx[i] = (Word32 *) malloc( sizeof( Word32 ) * max_total_ir_len ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); } +#ifdef FIX_1440_PORT_1202_FROM_FLT_REPO + set_zero2_fx( hCrend->freq_buffer_im_fx[i], max_total_ir_len ); +#else set_zero_fx( hCrend->freq_buffer_im_fx[i], max_total_ir_len ); +#endif } FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) @@ -1594,7 +1610,11 @@ ivas_error ivas_rend_openCrend( set_zero_fx( hCrend->prev_out_buffer_fx[i], subframe_length ); } +#ifdef FIX_1440_PORT_1202_FROM_FLT_REPO + max_total_ir_len = L_mult0( (Word16) hHrtf->num_iterations_diffuse[0], subframe_length ); +#else max_total_ir_len = imult1616( (Word16) hHrtf->num_iterations_diffuse[0], subframe_length ); +#endif IF( max_total_ir_len > 0 ) { @@ -1602,12 +1622,20 @@ ivas_error ivas_rend_openCrend( { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); } +#ifdef FIX_1440_PORT_1202_FROM_FLT_REPO + set_zero2_fx( hCrend->freq_buffer_re_diffuse_fx, max_total_ir_len ); +#else set_zero_fx( hCrend->freq_buffer_re_diffuse_fx, max_total_ir_len ); +#endif IF( ( hCrend->freq_buffer_im_diffuse_fx = (Word32 *) malloc( sizeof( Word32 ) * max_total_ir_len ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); } +#ifdef FIX_1440_PORT_1202_FROM_FLT_REPO + set_zero2_fx( hCrend->freq_buffer_im_diffuse_fx, max_total_ir_len ); +#else set_zero_fx( hCrend->freq_buffer_im_diffuse_fx, max_total_ir_len ); +#endif } ELSE { @@ -1622,7 +1650,11 @@ ivas_error ivas_rend_openCrend( { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); } +#ifdef FIX_1440_PORT_1202_FROM_FLT_REPO + set_zero2_fx( hCrend->lfe_delay_line_fx, max_total_ir_len ); +#else set_zero_fx( hCrend->lfe_delay_line_fx, max_total_ir_len ); +#endif } ELSE { @@ -1865,7 +1897,12 @@ static ivas_error ivas_rend_crendConvolver( Word16 i, j, k, m; Word16 subframe_length, idx_in; Word16 lfe_idx_in; +#ifdef FIX_1440_PORT_1202_FROM_FLT_REPO + Word32 offset, offset_in, offset_diffuse; + Word16 index_in; +#else Word16 offset, offset_in, offset_diffuse; +#endif Word16 nchan_in, nchan_out; const Word32 *pIn; Word32 *pFreq_buf_re, *pFreq_buf_im; @@ -1911,8 +1948,13 @@ static ivas_error ivas_rend_crendConvolver( } } +#ifdef FIX_1440_PORT_1202_FROM_FLT_REPO + offset = L_mult0( hCrend->delay_line_rw_index, subframe_length ); /* subframe_length * ( pCrend->hHrtfCrend->max_num_iterations - 1 ); */ + offset_diffuse = L_mult0( hCrend->diffuse_delay_line_rw_index, subframe_length ); /* subframe_length *( pCrend->hHrtfCrend->num_iterations_diffuse[0] - 1 ); */ +#else offset = imult1616( hCrend->delay_line_rw_index, subframe_length ); /* subframe_length * ( pCrend->hHrtfCrend->max_num_iterations - 1 ); */ offset_diffuse = imult1616( hCrend->diffuse_delay_line_rw_index, subframe_length ); /* subframe_length *( pCrend->hHrtfCrend->num_iterations_diffuse[0] - 1 ); */ +#endif IF( pCrend->hHrtfCrend->num_iterations_diffuse[0] > 0 ) { @@ -1969,10 +2011,17 @@ static ivas_error ivas_rend_crendConvolver( move16(); FOR( m = 0; m < pCrend->hHrtfCrend->num_iterations[i][j]; m++ ) { +#ifdef FIX_1440_PORT_1202_FROM_FLT_REPO + index_in = add( add( hCrend->delay_line_rw_index, sub( pCrend->hHrtfCrend->max_num_iterations, pCrend->hHrtfCrend->num_iterations[i][j] ) ), add( m, 1 ) ); + index_in = index_in % ( pCrend->hHrtfCrend->max_num_iterations ); + move16(); + offset_in = L_mult0( offset_in, subframe_length ); +#else offset_in = add( add( hCrend->delay_line_rw_index, sub( pCrend->hHrtfCrend->max_num_iterations, pCrend->hHrtfCrend->num_iterations[i][j] ) ), add( m, 1 ) ); offset_in = offset_in % ( pCrend->hHrtfCrend->max_num_iterations ); move16(); offset_in = imult1616( offset_in, subframe_length ); +#endif pFreq_buf_re = &hCrend->freq_buffer_re_fx[i][offset_in]; // Qx pFreq_buf_im = &hCrend->freq_buffer_im_fx[i][offset_in]; // Qx pFreq_filt_re = &pCrend->hHrtfCrend->pOut_to_bin_re_fx[i][j][offset]; // Q29 @@ -1985,7 +2034,11 @@ static ivas_error ivas_rend_crendConvolver( move32(); move32(); } +#ifdef FIX_1440_PORT_1202_FROM_FLT_REPO + offset = L_add( offset, k ); +#else offset = add( offset, k ); +#endif } i = add( i, 1 ); } @@ -1995,10 +2048,17 @@ static ivas_error ivas_rend_crendConvolver( move16(); FOR( m = 0; m < pCrend->hHrtfCrend->num_iterations_diffuse[j]; m++ ) { +#ifdef FIX_1440_PORT_1202_FROM_FLT_REPO + index_in = add( hCrend->diffuse_delay_line_rw_index, add( m, 1 ) ); + index_in = index_in % pCrend->hHrtfCrend->num_iterations_diffuse[0]; + move16(); + offset_diffuse = L_mult0( offset_diffuse, subframe_length ); +#else offset_diffuse = add( hCrend->diffuse_delay_line_rw_index, add( m, 1 ) ); offset_diffuse = offset_diffuse % pCrend->hHrtfCrend->num_iterations_diffuse[0]; move16(); offset_diffuse = imult1616( offset_diffuse, subframe_length ); +#endif pFreq_buf_re = &hCrend->freq_buffer_re_diffuse_fx[offset_diffuse]; // Qx pFreq_buf_im = &hCrend->freq_buffer_im_diffuse_fx[offset_diffuse]; // Qx pFreq_filt_re = &pCrend->hHrtfCrend->pOut_to_bin_diffuse_re_fx[j][offset]; // Q31 @@ -2010,7 +2070,13 @@ static ivas_error ivas_rend_crendConvolver( move32(); move32(); } +#ifdef FIX_1440_PORT_1202_FROM_FLT_REPO + offset = L_add( offset, k ); + move32(); +#else offset = add( offset, k ); + move16(); +#endif } ivas_imdft_fx( tmp_out_re, tmp_out_im, pOut, subframe_length ); -- GitLab From bfcd32d6468e886f07d6a987ddf8b68716e8dd91 Mon Sep 17 00:00:00 2001 From: marc emerit Date: Tue, 8 Apr 2025 15:33:34 +0200 Subject: [PATCH 2/4] rename switch name with original name from float version --- lib_com/options.h | 2 +- lib_rend/ivas_crend_fx.c | 28 ++++++++++++++-------------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 67ef4c3d1..aa9f085cc 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -194,7 +194,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_1440_PORT_1202_FROM_FLT_REPO /* Orange : port 1202 Fix crash when long BRIR is set */ +#define FIX_CRASH_LONG_BRIR /* Orange : port 1202 Fix crash when long BRIR is set */ /* #################### End BASOP porting switches ############################ */ diff --git a/lib_rend/ivas_crend_fx.c b/lib_rend/ivas_crend_fx.c index 5960fe8ce..bb75eac9b 100644 --- a/lib_rend/ivas_crend_fx.c +++ b/lib_rend/ivas_crend_fx.c @@ -1526,7 +1526,7 @@ ivas_error ivas_rend_openCrend( ) { Word16 i, subframe_length; -#ifdef FIX_1440_PORT_1202_FROM_FLT_REPO +#ifdef FIX_CRASH_LONG_BRIR Word32 max_total_ir_len; #else Word16 max_total_ir_len; @@ -1573,7 +1573,7 @@ ivas_error ivas_rend_openCrend( IF( hHrtf != NULL ) { -#ifdef FIX_1440_PORT_1202_FROM_FLT_REPO +#ifdef FIX_CRASH_LONG_BRIR max_total_ir_len = L_mult0( hHrtf->max_num_iterations, subframe_length ); #else max_total_ir_len = imult1616( hHrtf->max_num_iterations, subframe_length ); @@ -1585,7 +1585,7 @@ ivas_error ivas_rend_openCrend( { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); } -#ifdef FIX_1440_PORT_1202_FROM_FLT_REPO +#ifdef FIX_CRASH_LONG_BRIR set_zero2_fx( hCrend->freq_buffer_re_fx[i], max_total_ir_len ); #else set_zero_fx( hCrend->freq_buffer_re_fx[i], max_total_ir_len ); @@ -1594,7 +1594,7 @@ ivas_error ivas_rend_openCrend( { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); } -#ifdef FIX_1440_PORT_1202_FROM_FLT_REPO +#ifdef FIX_CRASH_LONG_BRIR set_zero2_fx( hCrend->freq_buffer_im_fx[i], max_total_ir_len ); #else set_zero_fx( hCrend->freq_buffer_im_fx[i], max_total_ir_len ); @@ -1610,7 +1610,7 @@ ivas_error ivas_rend_openCrend( set_zero_fx( hCrend->prev_out_buffer_fx[i], subframe_length ); } -#ifdef FIX_1440_PORT_1202_FROM_FLT_REPO +#ifdef FIX_CRASH_LONG_BRIR max_total_ir_len = L_mult0( (Word16) hHrtf->num_iterations_diffuse[0], subframe_length ); #else max_total_ir_len = imult1616( (Word16) hHrtf->num_iterations_diffuse[0], subframe_length ); @@ -1622,7 +1622,7 @@ ivas_error ivas_rend_openCrend( { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); } -#ifdef FIX_1440_PORT_1202_FROM_FLT_REPO +#ifdef FIX_CRASH_LONG_BRIR set_zero2_fx( hCrend->freq_buffer_re_diffuse_fx, max_total_ir_len ); #else set_zero_fx( hCrend->freq_buffer_re_diffuse_fx, max_total_ir_len ); @@ -1631,7 +1631,7 @@ ivas_error ivas_rend_openCrend( { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); } -#ifdef FIX_1440_PORT_1202_FROM_FLT_REPO +#ifdef FIX_CRASH_LONG_BRIR set_zero2_fx( hCrend->freq_buffer_im_diffuse_fx, max_total_ir_len ); #else set_zero_fx( hCrend->freq_buffer_im_diffuse_fx, max_total_ir_len ); @@ -1650,7 +1650,7 @@ ivas_error ivas_rend_openCrend( { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); } -#ifdef FIX_1440_PORT_1202_FROM_FLT_REPO +#ifdef FIX_CRASH_LONG_BRIR set_zero2_fx( hCrend->lfe_delay_line_fx, max_total_ir_len ); #else set_zero_fx( hCrend->lfe_delay_line_fx, max_total_ir_len ); @@ -1897,7 +1897,7 @@ static ivas_error ivas_rend_crendConvolver( Word16 i, j, k, m; Word16 subframe_length, idx_in; Word16 lfe_idx_in; -#ifdef FIX_1440_PORT_1202_FROM_FLT_REPO +#ifdef FIX_CRASH_LONG_BRIR Word32 offset, offset_in, offset_diffuse; Word16 index_in; #else @@ -1948,7 +1948,7 @@ static ivas_error ivas_rend_crendConvolver( } } -#ifdef FIX_1440_PORT_1202_FROM_FLT_REPO +#ifdef FIX_CRASH_LONG_BRIR offset = L_mult0( hCrend->delay_line_rw_index, subframe_length ); /* subframe_length * ( pCrend->hHrtfCrend->max_num_iterations - 1 ); */ offset_diffuse = L_mult0( hCrend->diffuse_delay_line_rw_index, subframe_length ); /* subframe_length *( pCrend->hHrtfCrend->num_iterations_diffuse[0] - 1 ); */ #else @@ -2011,7 +2011,7 @@ static ivas_error ivas_rend_crendConvolver( move16(); FOR( m = 0; m < pCrend->hHrtfCrend->num_iterations[i][j]; m++ ) { -#ifdef FIX_1440_PORT_1202_FROM_FLT_REPO +#ifdef FIX_CRASH_LONG_BRIR index_in = add( add( hCrend->delay_line_rw_index, sub( pCrend->hHrtfCrend->max_num_iterations, pCrend->hHrtfCrend->num_iterations[i][j] ) ), add( m, 1 ) ); index_in = index_in % ( pCrend->hHrtfCrend->max_num_iterations ); move16(); @@ -2034,7 +2034,7 @@ static ivas_error ivas_rend_crendConvolver( move32(); move32(); } -#ifdef FIX_1440_PORT_1202_FROM_FLT_REPO +#ifdef FIX_CRASH_LONG_BRIR offset = L_add( offset, k ); #else offset = add( offset, k ); @@ -2048,7 +2048,7 @@ static ivas_error ivas_rend_crendConvolver( move16(); FOR( m = 0; m < pCrend->hHrtfCrend->num_iterations_diffuse[j]; m++ ) { -#ifdef FIX_1440_PORT_1202_FROM_FLT_REPO +#ifdef FIX_CRASH_LONG_BRIR index_in = add( hCrend->diffuse_delay_line_rw_index, add( m, 1 ) ); index_in = index_in % pCrend->hHrtfCrend->num_iterations_diffuse[0]; move16(); @@ -2070,7 +2070,7 @@ static ivas_error ivas_rend_crendConvolver( move32(); move32(); } -#ifdef FIX_1440_PORT_1202_FROM_FLT_REPO +#ifdef FIX_CRASH_LONG_BRIR offset = L_add( offset, k ); move32(); #else -- GitLab From a829bf26dc2740bc7db9497ac704eee51d28dd7e Mon Sep 17 00:00:00 2001 From: marc emerit Date: Tue, 8 Apr 2025 15:36:36 +0200 Subject: [PATCH 3/4] bug fix --- lib_rend/ivas_crend_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_rend/ivas_crend_fx.c b/lib_rend/ivas_crend_fx.c index bb75eac9b..6e4247bc9 100644 --- a/lib_rend/ivas_crend_fx.c +++ b/lib_rend/ivas_crend_fx.c @@ -2015,7 +2015,7 @@ static ivas_error ivas_rend_crendConvolver( index_in = add( add( hCrend->delay_line_rw_index, sub( pCrend->hHrtfCrend->max_num_iterations, pCrend->hHrtfCrend->num_iterations[i][j] ) ), add( m, 1 ) ); index_in = index_in % ( pCrend->hHrtfCrend->max_num_iterations ); move16(); - offset_in = L_mult0( offset_in, subframe_length ); + offset_in = L_mult0( index_in, subframe_length ); #else offset_in = add( add( hCrend->delay_line_rw_index, sub( pCrend->hHrtfCrend->max_num_iterations, pCrend->hHrtfCrend->num_iterations[i][j] ) ), add( m, 1 ) ); offset_in = offset_in % ( pCrend->hHrtfCrend->max_num_iterations ); @@ -2052,7 +2052,7 @@ static ivas_error ivas_rend_crendConvolver( index_in = add( hCrend->diffuse_delay_line_rw_index, add( m, 1 ) ); index_in = index_in % pCrend->hHrtfCrend->num_iterations_diffuse[0]; move16(); - offset_diffuse = L_mult0( offset_diffuse, subframe_length ); + offset_diffuse = L_mult0( index_in, subframe_length ); #else offset_diffuse = add( hCrend->diffuse_delay_line_rw_index, add( m, 1 ) ); offset_diffuse = offset_diffuse % pCrend->hHrtfCrend->num_iterations_diffuse[0]; -- GitLab From 33ee2cc4c9ea2010835aca0df6db0fc4c1b23fdc Mon Sep 17 00:00:00 2001 From: marc emerit Date: Fri, 11 Apr 2025 11:12:01 +0200 Subject: [PATCH 4/4] trigger-test -- GitLab