From 2760d40420779c634b4834cacec998299f2126ad Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Sun, 8 Jun 2025 16:13:22 +0200 Subject: [PATCH 1/2] formatting fixes --- lib_rend/ivas_crend_fx.c | 243 ++++++++++++++++---------------- lib_rend/ivas_reverb_fx.c | 5 +- lib_rend/ivas_reverb_utils_fx.c | 6 +- 3 files changed, 123 insertions(+), 131 deletions(-) diff --git a/lib_rend/ivas_crend_fx.c b/lib_rend/ivas_crend_fx.c index c180c59a8..392d8ea99 100644 --- a/lib_rend/ivas_crend_fx.c +++ b/lib_rend/ivas_crend_fx.c @@ -1741,64 +1741,63 @@ ivas_error ivas_rend_openCrend( #ifdef SPLIT_REND_WITH_HEAD_ROT for ( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) - for ( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) #endif - { + { #ifdef SPLIT_REND_WITH_HEAD_ROT - hCrend = ( *pCrend )->hCrend[pos_idx]; + hCrend = ( *pCrend )->hCrend[pos_idx]; #else hCrend = ( *pCrend )->hCrend; #endif - hHrtf = ( *pCrend )->hHrtfCrend; + hHrtf = ( *pCrend )->hHrtfCrend; - IF( hHrtf != NULL ) - { - max_total_ir_len = L_mult0( hHrtf->max_num_iterations, subframe_length ); + IF( hHrtf != NULL ) + { + max_total_ir_len = L_mult0( hHrtf->max_num_iterations, subframe_length ); - FOR( i = 0; i < hHrtf->max_num_ir; i++ ) + FOR( i = 0; i < hHrtf->max_num_ir; i++ ) + { + IF( ( hCrend->freq_buffer_re_fx[i] = (Word32 *) malloc( sizeof( Word32 ) * max_total_ir_len ) ) == NULL ) { - IF( ( hCrend->freq_buffer_re_fx[i] = (Word32 *) malloc( sizeof( Word32 ) * max_total_ir_len ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); - } - set_zero2_fx( hCrend->freq_buffer_re_fx[i], max_total_ir_len ); + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); + } + set_zero2_fx( hCrend->freq_buffer_re_fx[i], max_total_ir_len ); - 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" ); - } - set_zero2_fx( hCrend->freq_buffer_im_fx[i], max_total_ir_len ); + 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" ); } + set_zero2_fx( hCrend->freq_buffer_im_fx[i], max_total_ir_len ); + } - FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) + FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) + { + IF( ( hCrend->prev_out_buffer_fx[i] = (Word32 *) malloc( sizeof( Word32 ) * subframe_length ) ) == NULL ) { - IF( ( hCrend->prev_out_buffer_fx[i] = (Word32 *) malloc( sizeof( Word32 ) * subframe_length ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); - } - set_zero_fx( hCrend->prev_out_buffer_fx[i], subframe_length ); + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); } + set_zero_fx( hCrend->prev_out_buffer_fx[i], subframe_length ); + } - max_total_ir_len = L_mult0( (Word16) hHrtf->num_iterations_diffuse[0], subframe_length ); + max_total_ir_len = L_mult0( (Word16) hHrtf->num_iterations_diffuse[0], subframe_length ); - IF( max_total_ir_len > 0 ) - { + IF( max_total_ir_len > 0 ) + { #ifdef FIX_INV_DIFFUSE_WEIGHT - IF( ( hCrend->freq_buffer_re_diffuse_fx[0] = (Word32 *) malloc( sizeof( Word32 ) * max_total_ir_len ) ) == NULL ) + IF( ( hCrend->freq_buffer_re_diffuse_fx[0] = (Word32 *) malloc( sizeof( Word32 ) * max_total_ir_len ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); + } + IF( hHrtf->same_inv_diffuse_weight == 0 ) + { + IF( ( hCrend->freq_buffer_re_diffuse_fx[1] = (Word32 *) malloc( sizeof( Word32 ) * max_total_ir_len ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); } - IF( hHrtf->same_inv_diffuse_weight == 0 ) - { - IF( ( hCrend->freq_buffer_re_diffuse_fx[1] = (Word32 *) malloc( sizeof( Word32 ) * max_total_ir_len ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); - } - } - ELSE - { - hCrend->freq_buffer_re_diffuse_fx[1] = NULL; - } + } + ELSE + { + hCrend->freq_buffer_re_diffuse_fx[1] = NULL; + } #else IF( ( hCrend->freq_buffer_re_diffuse_fx = (Word32 *) malloc( sizeof( Word32 ) * max_total_ir_len ) ) == NULL ) { @@ -1806,30 +1805,30 @@ ivas_error ivas_rend_openCrend( } #endif #ifdef FIX_INV_DIFFUSE_WEIGHT - set_zero2_fx( hCrend->freq_buffer_re_diffuse_fx[0], max_total_ir_len ); - IF( hCrend->freq_buffer_re_diffuse_fx[1] != NULL ) - { - set_zero2_fx( hCrend->freq_buffer_re_diffuse_fx[1], max_total_ir_len ); - } + set_zero2_fx( hCrend->freq_buffer_re_diffuse_fx[0], max_total_ir_len ); + IF( hCrend->freq_buffer_re_diffuse_fx[1] != NULL ) + { + set_zero2_fx( hCrend->freq_buffer_re_diffuse_fx[1], max_total_ir_len ); + } #else set_zero2_fx( hCrend->freq_buffer_re_diffuse_fx, max_total_ir_len ); #endif #ifdef FIX_INV_DIFFUSE_WEIGHT - IF( ( hCrend->freq_buffer_im_diffuse_fx[0] = (Word32 *) malloc( sizeof( Word32 ) * max_total_ir_len ) ) == NULL ) + IF( ( hCrend->freq_buffer_im_diffuse_fx[0] = (Word32 *) malloc( sizeof( Word32 ) * max_total_ir_len ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); + } + IF( hHrtf->same_inv_diffuse_weight == 0 ) + { + IF( ( hCrend->freq_buffer_im_diffuse_fx[1] = (Word32 *) malloc( sizeof( Word32 ) * max_total_ir_len ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); } - IF( hHrtf->same_inv_diffuse_weight == 0 ) - { - IF( ( hCrend->freq_buffer_im_diffuse_fx[1] = (Word32 *) malloc( sizeof( Word32 ) * max_total_ir_len ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); - } - } - ELSE - { - hCrend->freq_buffer_im_diffuse_fx[1] = NULL; - } + } + ELSE + { + hCrend->freq_buffer_im_diffuse_fx[1] = NULL; + } #else IF( ( hCrend->freq_buffer_im_diffuse_fx = (Word32 *) malloc( sizeof( Word32 ) * max_total_ir_len ) ) == NULL ) { @@ -1837,109 +1836,109 @@ ivas_error ivas_rend_openCrend( } #endif #ifdef FIX_INV_DIFFUSE_WEIGHT - set_zero2_fx( hCrend->freq_buffer_im_diffuse_fx[0], max_total_ir_len ); - IF( hCrend->freq_buffer_im_diffuse_fx[1] != NULL ) - { - set_zero2_fx( hCrend->freq_buffer_im_diffuse_fx[1], max_total_ir_len ); - } + set_zero2_fx( hCrend->freq_buffer_im_diffuse_fx[0], max_total_ir_len ); + IF( hCrend->freq_buffer_im_diffuse_fx[1] != NULL ) + { + set_zero2_fx( hCrend->freq_buffer_im_diffuse_fx[1], max_total_ir_len ); + } #else set_zero2_fx( hCrend->freq_buffer_im_diffuse_fx, max_total_ir_len ); #endif - } - ELSE - { + } + ELSE + { #ifdef FIX_INV_DIFFUSE_WEIGHT - hCrend->freq_buffer_re_diffuse_fx[0] = NULL; - hCrend->freq_buffer_im_diffuse_fx[0] = NULL; - hCrend->freq_buffer_re_diffuse_fx[1] = NULL; - hCrend->freq_buffer_im_diffuse_fx[1] = NULL; + hCrend->freq_buffer_re_diffuse_fx[0] = NULL; + hCrend->freq_buffer_im_diffuse_fx[0] = NULL; + hCrend->freq_buffer_re_diffuse_fx[1] = NULL; + hCrend->freq_buffer_im_diffuse_fx[1] = NULL; #else hCrend->freq_buffer_re_diffuse_fx = NULL; hCrend->freq_buffer_im_diffuse_fx = NULL; #endif - } + } - max_total_ir_len = add( extract_l( L_shr( L_add( L_shl( Mult_32_32( hHrtf->latency_s_fx, output_Fs ), 1 ), 1 ), 1 ) ), subframe_length ); /*(int16_t) ( hHrtf->latency_s * output_Fs + 0.5f ) + subframe_length;*/ - IF( max_total_ir_len > 0 ) - { - IF( ( hCrend->lfe_delay_line_fx = (Word32 *) malloc( sizeof( Word32 ) * max_total_ir_len ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); - } - set_zero2_fx( hCrend->lfe_delay_line_fx, max_total_ir_len ); - } - ELSE + max_total_ir_len = add( extract_l( L_shr( L_add( L_shl( Mult_32_32( hHrtf->latency_s_fx, output_Fs ), 1 ), 1 ), 1 ) ), subframe_length ); /*(int16_t) ( hHrtf->latency_s * output_Fs + 0.5f ) + subframe_length;*/ + IF( max_total_ir_len > 0 ) + { + IF( ( hCrend->lfe_delay_line_fx = (Word32 *) malloc( sizeof( Word32 ) * max_total_ir_len ) ) == NULL ) { - hCrend->lfe_delay_line_fx = NULL; + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); } + set_zero2_fx( hCrend->lfe_delay_line_fx, max_total_ir_len ); + } + ELSE + { + hCrend->lfe_delay_line_fx = NULL; + } - IF( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) - { + IF( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) + { #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES - IF( NE_32( ( error = ivas_reverb_open_fx( &( hCrend->hReverb ), hHrtfStatistics, hRendCfg, output_Fs ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = ivas_reverb_open_fx( &( hCrend->hReverb ), hHrtfStatistics, hRendCfg, output_Fs ) ), IVAS_ERR_OK ) ) #else IF( NE_32( ( error = ivas_reverb_open_fx( &( hCrend->hReverb ), inConfig, ( *pCrend )->hHrtfCrend, NULL, hRendCfg, output_Fs ) ), IVAS_ERR_OK ) ) #endif + { + return error; + } + + IF( EQ_16( hRendCfg->roomAcoustics.use_er, 1 ) ) + { + + /* Allocate memory for reflections */ + hCrend->reflections = (er_struct_t *) malloc( sizeof( er_struct_t ) ); + IF( !hCrend->reflections ) { - return error; + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Early Reflections" ); } - - IF( EQ_16( hRendCfg->roomAcoustics.use_er, 1 ) ) + IF( NE_32( ( error = ivas_er_init_handle( hCrend->reflections ) ), IVAS_ERR_OK ) ) { + return error; + } - /* Allocate memory for reflections */ - hCrend->reflections = (er_struct_t *) malloc( sizeof( er_struct_t ) ); - IF( !hCrend->reflections ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Early Reflections" ); - } - IF( NE_32( ( error = ivas_er_init_handle( hCrend->reflections ) ), IVAS_ERR_OK ) ) - { - return error; - } - - hCrend->reflections->use_er = hRendCfg->roomAcoustics.use_er; - hCrend->reflections->lowComplexity = hRendCfg->roomAcoustics.lowComplexity; - move16(); - move32(); + hCrend->reflections->use_er = hRendCfg->roomAcoustics.use_er; + hCrend->reflections->lowComplexity = hRendCfg->roomAcoustics.lowComplexity; + move16(); + move32(); - /* Set sample rate and frame size */ + /* Set sample rate and frame size */ - hCrend->reflections->output_Fs_fx = output_Fs; // Q0 - move32(); + hCrend->reflections->output_Fs_fx = output_Fs; // Q0 + move32(); - hCrend->reflections->max_frame_size = extract_l( Mult_32_16( output_Fs, INV_FRAME_PER_SEC_Q15 ) ); - move32(); + hCrend->reflections->max_frame_size = extract_l( Mult_32_16( output_Fs, INV_FRAME_PER_SEC_Q15 ) ); + move32(); - /* Init Shoebox */ - ivas_shoebox_config_init( &hCrend->reflections->shoebox_lib.cal, hRendCfg ); + /* Init Shoebox */ + ivas_shoebox_config_init( &hCrend->reflections->shoebox_lib.cal, hRendCfg ); - /* Init and compute Reflections */ - IF( NE_32( ( error = ivas_er_init( hCrend->reflections, inConfig ) ), IVAS_ERR_OK ) ) - { - return error; - } - } - ELSE + /* Init and compute Reflections */ + IF( NE_32( ( error = ivas_er_init( hCrend->reflections, inConfig ) ), IVAS_ERR_OK ) ) { - hCrend->reflections = NULL; + return error; } } ELSE { - hCrend->hReverb = NULL; + hCrend->reflections = NULL; } - - ( *pCrend )->binaural_latency_ns = Mult_32_32( ( *pCrend )->hHrtfCrend->latency_s_fx, (Word32) 1000000000 ); - move32(); } + ELSE + { + hCrend->hReverb = NULL; + } + + ( *pCrend )->binaural_latency_ns = Mult_32_32( ( *pCrend )->hHrtfCrend->latency_s_fx, (Word32) 1000000000 ); + move32(); + } #ifdef SPLIT_REND_WITH_HEAD_ROT - ( *pCrend )->hCrend[pos_idx] = hCrend; + ( *pCrend )->hCrend[pos_idx] = hCrend; #else ( *pCrend )->hCrend = hCrend; #endif - } + } return IVAS_ERR_OK; } diff --git a/lib_rend/ivas_reverb_fx.c b/lib_rend/ivas_reverb_fx.c index 336b9da3f..74c2a0c0a 100644 --- a/lib_rend/ivas_reverb_fx.c +++ b/lib_rend/ivas_reverb_fx.c @@ -2502,15 +2502,12 @@ ivas_error ivas_binaural_reverb_init( { float t60_temp[CLDFB_NO_CHANNELS_MAX]; float ene_temp[CLDFB_NO_CHANNELS_MAX]; - // fixedToFloat_arrL( t60, t60_temp, Q15, CLDFB_NO_CHANNELS_MAX ); - // fixedToFloat_arrL( ene, ene_temp, Q15, CLDFB_NO_CHANNELS_MAX ); - // if ( ( error = ivas_reverb_prepare_cldfb_params( roomAcoustics, hHrtfStatistics, sampling_rate, t60, ene ) ) != IVAS_ERR_OK ) if ( ( error = ivas_reverb_prepare_cldfb_params( roomAcoustics, hHrtfStatistics, sampling_rate, t60_temp, ene_temp ) ) != IVAS_ERR_OK ) { return error; } floatToFixed_arrL32( t60_temp, t60, Q15, CLDFB_NO_CHANNELS_MAX ); - floatToFixed_arrL32( t60_temp, t60, Q15, CLDFB_NO_CHANNELS_MAX ); + floatToFixed_arrL32( ene_temp, ene, Q15, CLDFB_NO_CHANNELS_MAX ); revTimes = t60; revEne = ene; diff --git a/lib_rend/ivas_reverb_utils_fx.c b/lib_rend/ivas_reverb_utils_fx.c index 6b9ecf3ab..75cc4b816 100644 --- a/lib_rend/ivas_reverb_utils_fx.c +++ b/lib_rend/ivas_reverb_utils_fx.c @@ -101,7 +101,7 @@ ivas_error ivas_reverb_prepare_cldfb_params( float avg_pwr_right[CLDFB_NO_CHANNELS_MAX]; float delay_diff, ln_1e6_inverted, exp_argument; const float dist = DEFAULT_SRC_DIST; - const float dmx_gain_2 = 4.0f * EVS_PI * dist * dist / 0.001f; // Represent in fixed point? + const float dmx_gain_2 = 4.0f * EVS_PI * dist * dist / 0.001f; #ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES ivas_error error; #endif @@ -149,10 +149,6 @@ ivas_error ivas_reverb_prepare_cldfb_params( pOutput_ene[idx] *= expf( exp_argument ); } #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES - - // Word32 avg_pwr_left_temp[CLDFB_NO_CHANNELS_MAX]; - // Word32 avg_pwr_right_temp[CLDFB_NO_CHANNELS_MAX]; - ivas_reverb_set_energies( hHrtfStatistics->average_energy_l, hHrtfStatistics->average_energy_r, output_Fs, avg_pwr_left, avg_pwr_right ); #else if ( ( error = ivas_reverb_get_fastconv_hrtf_set_energies( hHrtfFastConv, input_audio_config, use_brir, output_Fs, avg_pwr_left, avg_pwr_right ) ) != IVAS_ERR_OK ) -- GitLab From 7a59cc5c78501ad0865d315e4af4aab706bb6d9b Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Sun, 8 Jun 2025 16:28:52 +0200 Subject: [PATCH 2/2] marked branch as ready, trigger full pipeline -- GitLab