From 2b0ea951607f9f28582addf02276087aa1e634bc Mon Sep 17 00:00:00 2001 From: Nishant S Kulgod <100793@ittiam.com> Date: Tue, 30 Jul 2024 16:40:07 +0530 Subject: [PATCH 1/2] fix for 3gpp issue 381 --- lib_dec/ivas_dirac_dec.c | 14 +- lib_rend/ivas_dirac_dec_binaural_functions.c | 98 ++++-- lib_rend/ivas_dirac_rend.c | 1 + lib_rend/ivas_prot_rend.h | 8 + lib_rend/ivas_stat_rend.h | 1 + lib_rend/lib_rend.c | 331 +++++++++---------- 6 files changed, 247 insertions(+), 206 deletions(-) diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index 2d84e7604..2d68fe786 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -4591,7 +4591,7 @@ void ivas_dirac_dec_render_sf_fx( test(); IF( L_and( h_dirac_output_synthesis_params->use_onset_filters, L_and( NE_16( hDirAC->hConfig->dec_param_estim, TRUE ), NE_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) ) ) { - Scale_sig32( h_dirac_output_synthesis_state->diffuse_power_factor_fx, h_dirac_output_synthesis_params->max_band_decorr, sub( Q31, h_dirac_output_synthesis_state->diffuse_power_factor_q ) ); + Scale_sig32( h_dirac_output_synthesis_state->diffuse_power_factor_fx, h_dirac_output_synthesis_state->diff_dir_power_factor_len, sub( Q31, h_dirac_output_synthesis_state->diffuse_power_factor_q ) ); h_dirac_output_synthesis_state->diffuse_power_factor_q = Q31; move16(); @@ -4603,11 +4603,11 @@ void ivas_dirac_dec_render_sf_fx( test(); IF( L_and( EQ_16( hDirAC->hConfig->dec_param_estim, TRUE ), NE_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) ) { - scale_sig32( h_dirac_output_synthesis_state->direct_power_factor_fx, hSpatParamRendCom->num_freq_bands, sub( Q31, h_dirac_output_synthesis_state->direct_power_factor_q ) ); + scale_sig32( h_dirac_output_synthesis_state->direct_power_factor_fx, h_dirac_output_synthesis_state->diff_dir_power_factor_len, sub( Q31, h_dirac_output_synthesis_state->direct_power_factor_q ) ); h_dirac_output_synthesis_state->direct_power_factor_q = Q31; move16(); - scale_sig32( h_dirac_output_synthesis_state->diffuse_power_factor_fx, hSpatParamRendCom->num_freq_bands, sub( Q31, h_dirac_output_synthesis_state->diffuse_power_factor_q ) ); + scale_sig32( h_dirac_output_synthesis_state->diffuse_power_factor_fx, h_dirac_output_synthesis_state->diff_dir_power_factor_len, sub( Q31, h_dirac_output_synthesis_state->diffuse_power_factor_q ) ); h_dirac_output_synthesis_state->diffuse_power_factor_q = Q31; move16(); @@ -4801,7 +4801,7 @@ void ivas_dirac_dec_render_sf_fx( } IF( NE_16( hDirACRend->h_output_synthesis_psd_state.direct_power_factor_q, Q31 ) ) { - Scale_sig32( hDirACRend->h_output_synthesis_psd_state.direct_power_factor_fx, ( size_ho / hDirACRend->num_outputs_dir ), sub( Q31, hDirACRend->h_output_synthesis_psd_state.direct_power_factor_q ) ); + Scale_sig32( hDirACRend->h_output_synthesis_psd_state.direct_power_factor_fx, h_dirac_output_synthesis_state->diff_dir_power_factor_len, sub( Q31, hDirACRend->h_output_synthesis_psd_state.direct_power_factor_q ) ); } IF( NE_16( hDirACRend->h_output_synthesis_psd_state.direct_responses_q, Q31 ) ) { @@ -4809,7 +4809,7 @@ void ivas_dirac_dec_render_sf_fx( } IF( NE_16( hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_q, Q31 ) ) { - Scale_sig32( hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_fx, hDirACRend->h_output_synthesis_psd_params.max_band_decorr, sub( Q31, hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_q ) ); + Scale_sig32( hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_fx, h_dirac_output_synthesis_state->diff_dir_power_factor_len, sub( Q31, hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_q ) ); } IF( NE_16( hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth, Q26 ) ) { @@ -4884,7 +4884,7 @@ void ivas_dirac_dec_render_sf_fx( IF( NE_16( hDirACRend->h_output_synthesis_psd_state.direct_power_factor_q, Q31 ) ) { - Scale_sig32( hDirACRend->h_output_synthesis_psd_state.direct_power_factor_fx, hSpatParamRendCom->num_freq_bands, sub( Q31, hDirACRend->h_output_synthesis_psd_state.direct_power_factor_q ) ); + Scale_sig32( hDirACRend->h_output_synthesis_psd_state.direct_power_factor_fx, h_dirac_output_synthesis_state->diff_dir_power_factor_len, sub( Q31, hDirACRend->h_output_synthesis_psd_state.direct_power_factor_q ) ); } IF( NE_16( hDirACRend->h_output_synthesis_psd_state.direct_responses_q, Q31 ) ) { @@ -4892,7 +4892,7 @@ void ivas_dirac_dec_render_sf_fx( } IF( NE_16( hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_q, Q31 ) ) { - Scale_sig32( hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_fx, hSpatParamRendCom->num_freq_bands, sub( Q31, hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_q ) ); + Scale_sig32( hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_fx, h_dirac_output_synthesis_state->diff_dir_power_factor_len, sub( Q31, hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_q ) ); } IF( NE_16( q_diffuseness_vector, Q31 ) ) { diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index 590704a99..09c8f2a87 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -178,9 +178,11 @@ static void matrixMul( float Are[BINAURAL_CHANNELS][BINAURAL_CHANNELS], float Ai static void matrixTransp2Mul( float Are[BINAURAL_CHANNELS][BINAURAL_CHANNELS], float Aim[BINAURAL_CHANNELS][BINAURAL_CHANNELS], float Bre[BINAURAL_CHANNELS][BINAURAL_CHANNELS], float Bim[BINAURAL_CHANNELS][BINAURAL_CHANNELS], float outRe[BINAURAL_CHANNELS][BINAURAL_CHANNELS], float outIm[BINAURAL_CHANNELS][BINAURAL_CHANNELS] ); #endif - +#ifdef IVAS_FLOAT_FIXED +static void ivas_masa_ext_rend_parambin_internal_fx( MASA_EXT_REND_HANDLE hMasaExtRend, COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, Word32 *output_fx[], const Word16 subframe ); +#else static void ivas_masa_ext_rend_parambin_internal( MASA_EXT_REND_HANDLE hMasaExtRend, COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, float *output_f[], const int16_t subframe ); - +#endif #ifdef IVAS_FLOAT_FIXED static void formulate2x2MixingMatrix_fx( Word32 Ein1_fx, Word32 Ein2_fx, Word16 q_Ein, Word32 CinRe_fx, Word32 CinIm_fx, Word16 q_Cin, Word32 Eout1_fx, Word32 Eout2_fx, Word16 q_Eout, Word32 CoutRe_fx, Word32 CoutIm_fx, Word16 q_Cout, Word32 Q_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], Word32 Mre_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], Word32 Mim_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], Word16 *q_M, const Word16 regularizationFactor_fx ); @@ -7812,10 +7814,10 @@ static void ivas_masa_ext_rend_parambin_internal( return; } #else -static void ivas_masa_ext_rend_parambin_internal( +static void ivas_masa_ext_rend_parambin_internal_fx( MASA_EXT_REND_HANDLE hMasaExtRend, COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, - float *output_f[], + Word32 *output_fx[], /* Q11*/ const Word16 subframe ) { @@ -7828,21 +7830,20 @@ static void ivas_masa_ext_rend_parambin_internal( Word16 i, j; Word16 nchan_transport; Word16 q_mat; - -#if 1 hDiracDecBin = hMasaExtRend->hDiracDecBin; hSpatParamRendCom = hMasaExtRend->hSpatParamRendCom; - Word32 *output_fx[MAX_OUTPUT_CHANNELS]; - Word32 output_fx_buff[MAX_OUTPUT_CHANNELS][L_FRAME48k]; - FOR( ch = 0; ch < 2; ch++ ) - { - output_fx[ch] = output_fx_buff[ch]; - floatToFixed_arrL32( output_f[ch], output_fx[ch], Q11, L_FRAME48k ); - } -#endif Word32 Cldfb_RealBuffer_in_fx[6][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; Word32 Cldfb_ImagBuffer_in_fx[6][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; + + FOR( i = 0; i < 6; i++ ) + { + FOR( j = 0; j < CLDFB_SLOTS_PER_SUBFRAME; j++ ) + { + set32_fx( Cldfb_RealBuffer_in_fx[i][j], 0, CLDFB_NO_CHANNELS_MAX ); + set32_fx( Cldfb_ImagBuffer_in_fx[i][j], 0, CLDFB_NO_CHANNELS_MAX ); + } + } Word32 Rmat_fx[3][3]; hDiracDecBin = hMasaExtRend->hDiracDecBin; @@ -7863,8 +7864,16 @@ static void ivas_masa_ext_rend_parambin_internal( move16(); config_data.qualityBasedSmFactor_fx = ONE_IN_Q31; move32(); - config_data.processReverb = hMasaExtRend->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ? 1 : 0; - move16(); + IF( EQ_16( hMasaExtRend->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) + { + config_data.processReverb = 1; + move16(); + } + ELSE + { + config_data.processReverb = 0; + move16(); + } config_data.ism_mode = ISM_MODE_NONE; move32(); @@ -7926,6 +7935,7 @@ static void ivas_masa_ext_rend_parambin_internal( } } Word16 q_inp = Q6; + move16(); IF( hCombinedOrientationData ) { FOR( i = 0; i < 3; i++ ) @@ -7982,20 +7992,15 @@ static void ivas_masa_ext_rend_parambin_internal( hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[hCombinedOrientationData->subframe_idx] > 0, 0, NULL ); -#if 1 Word16 q_out; q_inp = Q6; move16(); - FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) - { - output_fx[ch] = output_fx_buff[ch]; - } + FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { hMasaExtRend->cldfbSynRend[ch]->Q_cldfb_state = Q11; move16(); } -#endif // Float to fix ends q_mat = hDiracDecBin->q_processMtx; move16(); @@ -8042,20 +8047,18 @@ static void ivas_masa_ext_rend_parambin_internal( move16(); move16(); -#if 1 // Fix to float FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { - fixedToFloat_arrL32( output_fx[ch], output_f[ch], q_out, nBins * hSpatParamRendCom->subframe_nbslots[subframe] ); + scale_sig32( output_fx[ch], nBins * hSpatParamRendCom->subframe_nbslots[subframe], sub( Q11, q_out ) ); scale_sig32( hMasaExtRend->cldfbSynRend[ch]->cldfb_state_fx, hMasaExtRend->cldfbSynRend[ch]->cldfb_size, sub( Q11, hMasaExtRend->cldfbSynRend[ch]->Q_cldfb_state ) ); hMasaExtRend->cldfbSynRend[ch]->Q_cldfb_state = Q11; } -#endif return; } #endif - +#ifndef IVAS_FLOAT_FIXED void ivas_masa_ext_rend_parambin_render( MASA_EXT_REND_HANDLE hMasaExtRend, /* i/o: MASA ext rend structure */ COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined orientation handle */ @@ -8095,3 +8098,46 @@ void ivas_masa_ext_rend_parambin_render( return; } +#else +void ivas_masa_ext_rend_parambin_render_fx( + MASA_EXT_REND_HANDLE hMasaExtRend, /* i/o: MASA ext rend structure */ + COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined orientation handle */ + Word32 *output_f[], /* i/o: synthesized core-coder transport channels/DirAC output Q11*/ + const Word16 num_subframes ) /* i : number of subframes to render */ +{ + Word16 subframe; + SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; + Word32 *p_output[BINAURAL_CHANNELS]; + Word16 ch; + + hSpatParamRendCom = hMasaExtRend->hSpatParamRendCom; + + FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + p_output[ch] = output_f[ch]; + } + + hSpatParamRendCom->subframes_rendered = hSpatParamRendCom->dirac_read_idx; + move16(); + FOR( subframe = 0; subframe < num_subframes; subframe++ ) + { + Word16 n_samples_sf = i_mult( hSpatParamRendCom->slot_size, CLDFB_SLOTS_PER_SUBFRAME ); + hSpatParamRendCom->slots_rendered = 0; + move16(); + + ivas_masa_ext_rend_parambin_internal_fx( hMasaExtRend, hCombinedOrientationData, p_output, hSpatParamRendCom->dirac_read_idx ); + + FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + p_output[ch] += n_samples_sf; + } + + ivas_combined_orientation_update_index( hCombinedOrientationData, n_samples_sf ); + + hSpatParamRendCom->dirac_read_idx = ( add( hSpatParamRendCom->dirac_read_idx, 1 ) ) % hSpatParamRendCom->dirac_md_buffer_length; + move16(); + } + + return; +} +#endif diff --git a/lib_rend/ivas_dirac_rend.c b/lib_rend/ivas_dirac_rend.c index f70fec75b..a96e1cf5f 100644 --- a/lib_rend/ivas_dirac_rend.c +++ b/lib_rend/ivas_dirac_rend.c @@ -1471,6 +1471,7 @@ ivas_error ivas_dirac_alloc_mem_fx( hDirACRend->h_output_synthesis_psd_state.direct_power_factor_fx = hDirAC_mem->direct_power_factor_fx; hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_fx = hDirAC_mem->diffuse_power_factor_fx; + hDirACRend->h_output_synthesis_psd_state.diff_dir_power_factor_len = size_pf; set_zero_fx( hDirACRend->h_output_synthesis_psd_state.direct_power_factor_fx, size_pf ); set_zero_fx( hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_fx, size_pf ); hDirACRend->h_output_synthesis_psd_state.direct_power_factor_q = Q31; diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index dc331271f..78ee3d424 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -357,12 +357,20 @@ void ivas_dirac_dec_binaural_render_fx( Word32 *output_f[] /* o : rendered time signal */ ); #endif +#ifndef IVAS_FLOAT_FIXED void ivas_masa_ext_rend_parambin_render( MASA_EXT_REND_HANDLE hMasaExtRend, /* i/o: MASA ext rend structure */ COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined orientation handle */ float *output_f[], /* i/o: synthesized core-coder transport channels/DirAC output */ const int16_t num_subframes /* i : number of subframes to render */ ); +#else +void ivas_masa_ext_rend_parambin_render_fx( + MASA_EXT_REND_HANDLE hMasaExtRend, /* i/o: MASA ext rend structure */ + COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined orientation handle */ + Word32 *output_f[], /* i/o: synthesized core-coder transport channels/DirAC output Q11*/ + const Word16 num_subframes ); /* i : number of subframes to render */ +#endif #ifndef IVAS_FLOAT_FIXED ivas_error ivas_dirac_dec_init_binaural_data( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index b8ac1194b..869fd98bd 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -451,6 +451,7 @@ typedef struct dirac_output_synthesis_state_structure Word16 direct_power_factor_q; Word16 diffuse_power_factor_q; + Word16 diff_dir_power_factor_len; Word32 *proto_power_smooth_fx; /* Smoothed power of the prototype signals. Size: num_freq_bands*num_channels. */ Word16 proto_power_smooth_q; diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 45d03afd3..d51e11142 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -130,8 +130,11 @@ typedef struct AUDIO_CONFIG inConfig; IVAS_REND_InputId id; IVAS_REND_AudioBuffer inputBuffer; - float gain; /* Linear, not in dB */ +#ifndef IVAS_FLOAT_FIXED + float gain; /* Linear, not in dB */ +#else Word32 gain_fx; /* Linear, not in dB */ +#endif rendering_context ctx; Word32 numNewSamplesPerChannel; /* Used to keep track how much new audio was fed before rendering current frame */ } input_base; @@ -384,8 +387,6 @@ static void freeMasaExtRenderer( MASA_EXT_REND_HANDLE *hMasaExtRendOut ); #ifdef IVAS_FLOAT_FIXED // TOBE REMOVED static void intermidiate_ext_dirac_render( MASA_EXT_REND_HANDLE hMasaExtRend, /* i/o: MASA renderer structure */ - Word32 *output_f[], /* i/o: input/output signals in time domain */ - float *output_f_flt[], /* i/o: input/output signals in time domain */ Word16 to_fix ); #endif /*-------------------------------------------------------------------* @@ -572,7 +573,7 @@ static void copyBufferTo2dArray_fx( return; } -#endif +#else static void copyBufferTo2dArray( const IVAS_REND_AudioBuffer buffer, float array[][L_FRAME48k] ) @@ -593,6 +594,7 @@ static void copyBufferTo2dArray( return; } +#endif #ifdef IVAS_FLOAT_FIXED static void accumulate2dArrayToBuffer_fx( Word32 array[][L_FRAME48k], @@ -614,7 +616,7 @@ static void accumulate2dArrayToBuffer_fx( return; } -#endif +#else static void accumulate2dArrayToBuffer( float array[][L_FRAME48k], IVAS_REND_AudioBuffer *buffer ) @@ -633,6 +635,7 @@ static void accumulate2dArrayToBuffer( return; } +#endif #ifdef IVAS_FLOAT_FIXED /*-------------------------------------------------------------------* * limitRendererOutput() @@ -2156,7 +2159,7 @@ static void initRendInputBase_fx( return; } -#endif +#else static void initRendInputBase( input_base *inputBase, const AUDIO_CONFIG inConfig, @@ -2181,7 +2184,7 @@ static void initRendInputBase( return; } - +#endif #ifdef IVAS_FLOAT_FIXED static IVAS_ISM_METADATA defaultObjectPosition( @@ -5338,7 +5341,7 @@ static void clearInputMasa( freeMasaExtRenderer( &inputMasa->hMasaExtRend ); - initRendInputBase( &inputMasa->base, IVAS_AUDIO_CONFIG_INVALID, 0, rendCtx, NULL, 0 ); + initRendInputBase_fx( &inputMasa->base, IVAS_AUDIO_CONFIG_INVALID, 0, rendCtx, NULL, 0 ); return; } @@ -5500,7 +5503,7 @@ ivas_error IVAS_REND_Open( FOR( i = 0; i < RENDERER_MAX_MASA_INPUTS; ++i ) { - initRendInputBase( &hIvasRend->inputsMasa[i].base, IVAS_AUDIO_CONFIG_INVALID, 0, getRendCtx( hIvasRend ), NULL, 0 ); + initRendInputBase_fx( &hIvasRend->inputsMasa[i].base, IVAS_AUDIO_CONFIG_INVALID, 0, getRendCtx( hIvasRend ), NULL, 0 ); hIvasRend->inputsMasa[i].metadataHasBeenFed = false; hIvasRend->inputsMasa[i].bufferData = NULL; @@ -12587,14 +12590,11 @@ static ivas_error renderInputMasa( IVAS_REND_AudioBuffer outAudio ) { IVAS_REND_AudioBuffer inAudio; - int16_t ch; - int16_t maxBin; - float *tmpBuffer[MAX_OUTPUT_CHANNELS]; - float tmpBuffer_buff[MAX_OUTPUT_CHANNELS][L_FRAME48k]; -#ifdef IVAS_FLOAT_FIXED + Word16 ch; + Word16 maxBin; Word32 *tmpBuffer_fx[MAX_OUTPUT_CHANNELS]; Word32 tmpBuffer_buff_fx[MAX_OUTPUT_CHANNELS][L_FRAME48k]; -#endif + IF( !masaInput->metadataHasBeenFed ) { return IVAS_ERR_MISSING_METADATA; @@ -12608,70 +12608,56 @@ static ivas_error renderInputMasa( masaInput->base.numNewSamplesPerChannel = 0; move32(); -#ifdef IVAS_FLOAT_FIXED - masaInput->base.gain = fix_to_float( masaInput->base.gain_fx, Q30 ); *outAudio.pq_fact = outAudio.q_factor; move16(); /* Apply input gain to new audio */ v_multc_fixed( inAudio.data_fx, masaInput->base.gain_fx, inAudio.data_fx, inAudio.config.numSamplesPerChannel * inAudio.config.numChannels ); *outAudio.pq_fact = sub( *outAudio.pq_fact, 1 ); // to compensate for the qfactor reduction in gain multiplication. -#endif // IVAS_FLOAT_FIXED - /* Apply input gain to new audio */ - v_multc( inAudio.data, masaInput->base.gain, inAudio.data, inAudio.config.numSamplesPerChannel * inAudio.config.numChannels ); - - maxBin = (Word16) ( *masaInput->base.ctx.pOutSampleRate * INV_CLDFB_BANDWIDTH ); + maxBin = extract_l( Mpy_32_32( *masaInput->base.ctx.pOutSampleRate, INV_CLDFB_BANDWIDTH_Q31 ) ); /* set combined orientation subframe info to start info */ ivas_combined_orientation_set_to_start_index( *( masaInput->base.ctx.pCombinedOrientationData ) ); - if ( EQ_32( getAudioConfigType( outConfig ), IVAS_REND_AUDIO_CONFIG_TYPE_MASA ) ) + IF( EQ_32( getAudioConfigType( outConfig ), IVAS_REND_AUDIO_CONFIG_TYPE_MASA ) ) { /* MASA prerendering path for MASA -> MASA */ renderMasaToMasa( masaInput, outAudio ); -#ifdef IVAS_FLOAT_FIXED - for ( Word16 i = 0; i < outAudio.config.numChannels * outAudio.config.numSamplesPerChannel; i++ ) - { - outAudio.data[i] = (float) outAudio.data_fx[i] / ( 1 << *outAudio.pq_fact ); - } -#endif } - else + ELSE { /* MASA external renderer -> other formats */ - int16_t num_subframes; - for ( ch = 0; ch < MAX_OUTPUT_CHANNELS; ch++ ) - { - tmpBuffer[ch] = tmpBuffer_buff[ch]; - } -#ifdef IVAS_FLOAT_FIXED - for ( ch = 0; ch < MAX_OUTPUT_CHANNELS; ch++ ) + Word16 num_subframes, exp; + FOR( ch = 0; ch < MAX_OUTPUT_CHANNELS; ch++ ) { tmpBuffer_fx[ch] = tmpBuffer_buff_fx[ch]; } copyBufferTo2dArray_fx( masaInput->base.inputBuffer, tmpBuffer_buff_fx ); -#endif - copyBufferTo2dArray( masaInput->base.inputBuffer, tmpBuffer_buff ); - num_subframes = (int16_t) ( masaInput->base.inputBuffer.config.numSamplesPerChannel / ( *masaInput->base.ctx.pOutSampleRate / ( IVAS_NUM_FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) ); + num_subframes = BASOP_Util_Divide3232_Scale( L_mult0( masaInput->base.inputBuffer.config.numSamplesPerChannel, IVAS_NUM_FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ), *masaInput->base.ctx.pOutSampleRate, &exp ); + num_subframes = shr( num_subframes, sub( 15, exp ) ); - switch ( masaInput->hMasaExtRend->renderer_type ) + SWITCH( masaInput->hMasaExtRend->renderer_type ) { case RENDERER_DIRAC: -#ifdef IVAS_FLOAT_FIXED + copyMasaMetadataToDiracRenderer_fx( &masaInput->masaMetadata, masaInput->hMasaExtRend->hSpatParamRendCom, maxBin ); -#else - copyMasaMetadataToDiracRenderer( &masaInput->masaMetadata, masaInput->hMasaExtRend->hSpatParamRendCom, maxBin ); -#endif -#ifdef IVAS_FLOAT_FIXED #if 1 // TOBE REMOVED - intermidiate_ext_dirac_render( masaInput->hMasaExtRend, tmpBuffer_fx, tmpBuffer, 1 ); + intermidiate_ext_dirac_render( masaInput->hMasaExtRend, 1 ); #endif FOR( ch = 0; ch < masaInput->hMasaExtRend->hDirACRend->hOutSetup.nchan_out_woLFE + masaInput->hMasaExtRend->hDirACRend->hOutSetup.num_lfe; ch++ ) { masaInput->hMasaExtRend->cldfbAnaRend[0]->Q_cldfb_state = Q11; } + FOR( ch = 0; ch < MAX_OUTPUT_CHANNELS; ch++ ) + { + Scale_sig32( tmpBuffer_buff_fx[ch], L_FRAME48k, sub( Q11, *outAudio.pq_fact ) ); + } ivas_masa_ext_dirac_render_fx( masaInput->hMasaExtRend, tmpBuffer_fx, num_subframes ); + + *outAudio.pq_fact = Q11; + move16(); + FOR( ch = 0; ch < masaInput->hMasaExtRend->hDirACRend->hOutSetup.nchan_out_woLFE + masaInput->hMasaExtRend->hDirACRend->hOutSetup.num_lfe; ch++ ) { scale_sig32( masaInput->hMasaExtRend->cldfbSynRend[ch]->cldfb_state_fx, masaInput->hMasaExtRend->cldfbSynRend[ch]->cldfb_size, sub( Q11, masaInput->hMasaExtRend->cldfbAnaRend[0]->Q_cldfb_state ) ); @@ -12679,29 +12665,29 @@ static ivas_error renderInputMasa( } #if 1 // TOBE REMOVED - intermidiate_ext_dirac_render( masaInput->hMasaExtRend, tmpBuffer_fx, tmpBuffer, 0 ); -#endif -#else - ivas_masa_ext_dirac_render( masaInput->hMasaExtRend, tmpBuffer, num_subframes ); + intermidiate_ext_dirac_render( masaInput->hMasaExtRend, 0 ); #endif - break; + BREAK; case RENDERER_STEREO_PARAMETRIC: case RENDERER_BINAURAL_PARAMETRIC: case RENDERER_BINAURAL_PARAMETRIC_ROOM: -#ifdef IVAS_FLOAT_FIXED + copyMasaMetadataToDiracRenderer_fx( &masaInput->masaMetadata, masaInput->hMasaExtRend->hSpatParamRendCom, maxBin ); -#else - copyMasaMetadataToDiracRenderer( &masaInput->masaMetadata, masaInput->hMasaExtRend->hSpatParamRendCom, maxBin ); -#endif - ivas_masa_ext_rend_parambin_render( masaInput->hMasaExtRend, *masaInput->base.ctx.pCombinedOrientationData, tmpBuffer, num_subframes ); - break; + + Scale_sig32( tmpBuffer_buff_fx[0], L_FRAME48k, sub( Q11, *outAudio.pq_fact ) ); + Scale_sig32( tmpBuffer_buff_fx[1], L_FRAME48k, sub( Q11, *outAudio.pq_fact ) ); + + ivas_masa_ext_rend_parambin_render_fx( masaInput->hMasaExtRend, *masaInput->base.ctx.pCombinedOrientationData, tmpBuffer_fx, num_subframes ); + *outAudio.pq_fact = Q11; + move16(); + BREAK; case RENDERER_DISABLE: - break; /* This happens for 1TC MASA to MONO where we just copy input transport to output */ + BREAK; /* This happens for 1TC MASA to MONO where we just copy input transport to output */ default: return ( IVAS_ERROR( IVAS_ERR_IO_CONFIG_PAIR_NOT_SUPPORTED, "Wrong output config for MASA input in external renderer\n" ) ); } - accumulate2dArrayToBuffer( tmpBuffer_buff, &outAudio ); + accumulate2dArrayToBuffer_fx( tmpBuffer_buff_fx, &outAudio ); } return IVAS_ERR_OK; @@ -12780,23 +12766,43 @@ static ivas_error renderInputMasa( return IVAS_ERR_OK; } #endif - +#ifdef IVAS_FLOAT_FIXED static ivas_error renderActiveInputsMasa( IVAS_REND_HANDLE hIvasRend, IVAS_REND_AudioBuffer outAudio ) { - int16_t i; + Word16 i; input_masa *pCurrentInput; ivas_error error; -#ifdef IVAS_FLOAT_FIXED - if ( hIvasRend->inputsSba[0].base.inConfig != IVAS_AUDIO_CONFIG_INVALID ) + + FOR( ( i = 0, pCurrentInput = hIvasRend->inputsMasa ); i < RENDERER_MAX_MASA_INPUTS; ( ++i, ++pCurrentInput ) ) { - for ( i = 0; i < outAudio.config.numChannels * outAudio.config.numSamplesPerChannel; i++ ) + IF( EQ_16( pCurrentInput->base.inConfig, IVAS_AUDIO_CONFIG_INVALID ) ) { - outAudio.data[i] = (float) outAudio.data_fx[i] / ( 1 << *outAudio.pq_fact ); + /* Skip inactive inputs */ + CONTINUE; + } + + *outAudio.pq_fact = Q8; + move16(); + + IF( NE_32( ( error = renderInputMasa( pCurrentInput, hIvasRend->outputConfig, outAudio ) ), IVAS_ERR_OK ) ) + { + return error; } } -#endif + + return IVAS_ERR_OK; +} +#else +static ivas_error renderActiveInputsMasa( + IVAS_REND_HANDLE hIvasRend, + IVAS_REND_AudioBuffer outAudio ) +{ + int16_t i; + input_masa *pCurrentInput; + ivas_error error; + for ( i = 0, pCurrentInput = hIvasRend->inputsMasa; i < RENDERER_MAX_MASA_INPUTS; ++i, ++pCurrentInput ) { if ( pCurrentInput->base.inConfig == IVAS_AUDIO_CONFIG_INVALID ) @@ -12805,27 +12811,15 @@ static ivas_error renderActiveInputsMasa( continue; } -#ifdef IVAS_FLOAT_FIXED - *outAudio.pq_fact = Q8; -#endif // IVAS_FLOAT_FIXED if ( ( error = renderInputMasa( pCurrentInput, hIvasRend->outputConfig, outAudio ) ) != IVAS_ERR_OK ) { return error; } -#ifdef IVAS_FLOAT_FIXED - if ( ( hIvasRend->inputsSba[0].base.inConfig != IVAS_AUDIO_CONFIG_INVALID ) && ( getAudioConfigType( hIvasRend->outputConfig ) != IVAS_REND_AUDIO_CONFIG_TYPE_MASA ) ) - { - for ( Word16 k = 0; k < outAudio.config.numChannels * outAudio.config.numSamplesPerChannel; k++ ) - { - outAudio.data_fx[k] = (Word32) outAudio.data[k] * ( 1 << *outAudio.pq_fact ); - } - } -#endif } return IVAS_ERR_OK; } - +#endif /*---------------------------------------------------------------------* * IVAS_REND_GetMasaMetadata( ) @@ -13309,18 +13303,10 @@ static ivas_error getSamplesInternal( test(); test(); - IF( NE_32( hIvasRend->inputsSba[0].base.inConfig, IVAS_AUDIO_CONFIG_INVALID ) || NE_32( hIvasRend->inputsMc[0].base.inConfig, IVAS_AUDIO_CONFIG_INVALID ) || NE_32( hIvasRend->inputsIsm[0].base.inConfig, IVAS_AUDIO_CONFIG_INVALID ) ) - { - Word32 limiter_thresold = L_lshl( IVAS_LIMITER_THRESHOLD, *outAudio.pq_fact ); - limitRendererOutput_fx( hIvasRend->hLimiter, outAudio.data_fx, outAudio.config.numSamplesPerChannel, limiter_thresold, *outAudio.pq_fact ); - } - ELSE - { - floatToFixed_arrL( outAudio.data, outAudio.data_fx, *outAudio.pq_fact, hIvasRend->hLimiter->num_channels * outAudio.config.numSamplesPerChannel ); - Word32 limiter_thresold = L_lshl( IVAS_LIMITER_THRESHOLD, *outAudio.pq_fact ); - limitRendererOutput_fx( hIvasRend->hLimiter, outAudio.data_fx, outAudio.config.numSamplesPerChannel, limiter_thresold, *outAudio.pq_fact ); - fixedToFloat_arrL( outAudio.data_fx, outAudio.data, *outAudio.pq_fact, hIvasRend->hLimiter->num_channels * outAudio.config.numSamplesPerChannel ); - } + + Word32 limiter_thresold = L_lshl( IVAS_LIMITER_THRESHOLD, *outAudio.pq_fact ); + limitRendererOutput_fx( hIvasRend->hLimiter, outAudio.data_fx, outAudio.config.numSamplesPerChannel, limiter_thresold, *outAudio.pq_fact ); + /* update global cominbed orientation start index */ ivas_combined_orientation_update_start_index( hIvasRend->hCombinedOrientationData, outAudio.config.numSamplesPerChannel ); @@ -15143,19 +15129,16 @@ static void freeMasaExtRenderer( #ifdef IVAS_FLOAT_FIXED static void intermidiate_ext_dirac_render( MASA_EXT_REND_HANDLE hMasaExtRend, /* i/o: MASA renderer structure */ - Word32 *output_f[], /* i/o: input/output signals in time domain */ - float *output_f_flt[], /* i/o: input/output signals in time domain */ Word16 to_fix ) { SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; hSpatParamRendCom = hMasaExtRend->hSpatParamRendCom; DIRAC_DEC_STACK_MEM DirAC_mem; - int16_t i, ch, q_cldfb; + Word16 ch; DIRAC_REND_HANDLE hDirACRend; - int16_t subframe_idx; - int16_t slot_idx; - int16_t nchan_transport; - int16_t masa_band_mapping[MASA_FREQUENCY_BANDS + 1]; + Word16 subframe_idx; + Word16 slot_idx; + Word16 nchan_transport; Word16 tmp; hDirACRend = hMasaExtRend->hDirACRend; @@ -15169,120 +15152,118 @@ static void intermidiate_ext_dirac_render( DirAC_mem = hDirACRend->stack_mem; - if ( to_fix ) + IF( to_fix ) { DirAC_mem.reference_power_smooth_q = DirAC_mem.reference_power_q = Q31; - q_cldfb = 11; - for ( i = 0; i < MAX_OUTPUT_CHANNELS; i++ ) - { - floatToFixed_arrL( output_f_flt[i], output_f[i], q_cldfb, L_FRAME48k ); - } - - for ( slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[subframe_idx]; slot_idx++ ) + move16(); + move16(); + FOR( slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[subframe_idx]; slot_idx++ ) { - IF( EQ_16( hDirACRend->panningConf, DIRAC_PANNING_VBAP ) ) - { - Scale_sig32( hDirACRend->h_output_synthesis_psd_state.direct_responses_fx, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ), sub( Q30, hDirACRend->h_output_synthesis_psd_state.direct_responses_q ) ); - hDirACRend->h_output_synthesis_psd_state.direct_responses_q = Q30; - } - else - { - if ( hDirACRend->panningConf == DIRAC_PANNING_HOA3 ) - { - if ( masa_band_mapping == NULL && hDirACRend->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD ) - { - Scale_sig32( hDirACRend->h_output_synthesis_psd_state.direct_responses_fx, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ), sub( Q30, hDirACRend->h_output_synthesis_psd_state.direct_responses_q ) ); - hDirACRend->h_output_synthesis_psd_state.direct_responses_q = Q30; - } - else if ( ( ( hDirACRend->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD ) && ( masa_band_mapping != NULL ) ) || - hDirACRend->synthesisConf == DIRAC_SYNTHESIS_PSD_SHD || hDirACRend->synthesisConf == DIRAC_SYNTHESIS_MONO ) - { - Scale_sig32( hDirACRend->h_output_synthesis_psd_state.direct_responses_fx, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ), sub( Q30, hDirACRend->h_output_synthesis_psd_state.direct_responses_q ) ); - hDirACRend->h_output_synthesis_psd_state.direct_responses_q = Q30; - } - ELSE IF( EQ_16( hDirACRend->panningConf, DIRAC_PANNING_VBAP ) ) /*VBAP*/ - { - Scale_sig32( hDirACRend->h_output_synthesis_psd_state.direct_responses_fx, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ), sub( Q30, hDirACRend->h_output_synthesis_psd_state.direct_responses_q ) ); - hDirACRend->h_output_synthesis_psd_state.direct_responses_q = Q30; - } - } - else if ( hDirACRend->panningConf == DIRAC_PANNING_VBAP ) /*VBAP*/ - { - Scale_sig32( hDirACRend->h_output_synthesis_psd_state.direct_responses_fx, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ), sub( Q30, hDirACRend->h_output_synthesis_psd_state.direct_responses_q ) ); - hDirACRend->h_output_synthesis_psd_state.direct_responses_q = Q30; - } - } + Scale_sig32( hDirACRend->h_output_synthesis_psd_state.direct_responses_fx, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ), sub( Q30, hDirACRend->h_output_synthesis_psd_state.direct_responses_q ) ); + hDirACRend->h_output_synthesis_psd_state.direct_responses_q = Q30; + move16(); } - if ( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_fx ) + IF( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_fx ) { Word16 shift = L_norm_arr( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_fx, hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_len ); scale_sig32( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_fx, hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_len, shift ); - hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth += shift; + hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth = add( hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth, shift ); } - if ( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev_fx ) + IF( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev_fx ) { Word16 shift = L_norm_arr( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev_len ); scale_sig32( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev_len, shift ); - hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev += shift; + hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev = add( hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev, shift ); } - if ( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_fx ) + IF( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_fx ) { Word16 shift = L_norm_arr( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_fx, hDirACRend->num_outputs_dir * hSpatParamRendCom->num_freq_bands ); scale_sig32( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_fx, hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_len, shift ); - hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth += shift; + hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth = add( hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth, shift ); } + Word16 num_channels_dir = hDirACRend->num_outputs_dir; + move16(); - if ( hDirACRend->synthesisConf == DIRAC_SYNTHESIS_PSD_LS ) + IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_PSD_LS ) ) { num_channels_dir = hDirACRend->hOutSetup.nchan_out_woLFE; + move16(); } - if ( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx ) + + IF( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx ) { tmp = L_norm_arr( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx, num_channels_dir * hSpatParamRendCom->num_freq_bands ); scale_sig32( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx, hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_len, tmp ); - h_dirac_output_synthesis_state->q_cy_auto_diff_smooth += tmp; + h_dirac_output_synthesis_state->q_cy_auto_diff_smooth = add( h_dirac_output_synthesis_state->q_cy_auto_diff_smooth, tmp ); + move16(); } - if ( hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev_fx ) + IF( hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev_fx ) { tmp = L_norm_arr( hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev_len ); scale_sig32( hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev_len, tmp ); - hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth_prev += tmp; + hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth_prev = add( hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth_prev, tmp ); + move16(); } scale_sig32( hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_fx, hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_len, Q26 - hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_q ); hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_q = Q26; + move16(); scale_sig32( hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_fx, hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_len, Q26 - hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_q ); hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_q = Q26; - if ( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_prev_fx ) + move16(); + IF( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_prev_fx ) { Word16 shift = L_norm_arr( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_prev_fx, hSpatParamRendCom->num_freq_bands * hDirACRend->num_outputs_dir ); scale_sig32( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_prev_len, shift ); - hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth_prev += shift; + hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth_prev = add( hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth_prev, shift ); + move16(); } - if ( hDirACRend->proto_signal_decorr_on == 1 ) + IF( EQ_16( hDirACRend->proto_signal_decorr_on, 1 ) ) { tmp = L_norm_arr( hDirACRend->h_freq_domain_decorr_ap_state->decorr_buffer_fx, hDirACRend->h_freq_domain_decorr_ap_state->decorr_buffer_len ); scale_sig32( hDirACRend->h_freq_domain_decorr_ap_state->decorr_buffer_fx, hDirACRend->h_freq_domain_decorr_ap_state->decorr_buffer_len, tmp ); - hDirACRend->h_freq_domain_decorr_ap_state->q_decorr_buffer += tmp; + hDirACRend->h_freq_domain_decorr_ap_state->q_decorr_buffer = add( hDirACRend->h_freq_domain_decorr_ap_state->q_decorr_buffer, tmp ); + move16(); } - if ( hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_len > 0 ) + IF( hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_len > 0 ) { - Word16 shift; + Word16 shift, norm1, norm2; Word32 tmp1, tmp2; maximum_abs_32_fx( hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_fx, hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_len, &tmp2 ); maximum_abs_32_fx( hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_fx, hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_len, &tmp1 ); - shift = s_min( ( tmp1 == 0 ) ? 31 : norm_l( tmp1 ), ( tmp2 == 0 ) ? 31 : norm_l( tmp2 ) ); - Word16 hr_exp = 31 - shift; + IF( tmp1 == 0 ) + { + norm1 = 31; + move16(); + } + ELSE + { + norm1 = norm_l( tmp1 ); + } + + IF( tmp2 == 0 ) + { + norm2 = 31; + move16(); + } + ELSE + { + norm2 = norm_l( tmp2 ); + } + + shift = s_min( norm1, norm2 ); - Scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_fx, hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_len, ( 31 - hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q ) - hr_exp ); - hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q = 31 - hr_exp; + Word16 hr_exp = sub( 31, shift ); + + Scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_fx, hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_len, sub( sub( 31, hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q ), hr_exp ) ); + hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q = sub( 31, hr_exp ); } FOR( slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[subframe_idx]; slot_idx++ ) @@ -15291,32 +15272,38 @@ static void intermidiate_ext_dirac_render( FOR( ch = 0; ch < nchan_transport; ch++ ) { hMasaExtRend->cldfbAnaRend[ch]->Q_cldfb_state = Q11; + move16(); } } - hDirACRend->proto_frame_dec_f_q = 31 - hDirACRend->proto_frame_dec_f_q; + hDirACRend->proto_frame_dec_f_q = sub( 31, hDirACRend->proto_frame_dec_f_q ); + move16(); - if ( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx ) + IF( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx ) { tmp = L_norm_arr( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx, hDirACRend->num_protos_dir * hSpatParamRendCom->num_freq_bands ); scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_len, tmp ); - hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q += tmp; + hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q = add( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, tmp ); + move16(); tmp = L_norm_arr( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_fx, hDirACRend->num_protos_dir * hSpatParamRendCom->num_freq_bands ); scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_len, tmp ); - hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q += tmp; + hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q = add( tmp, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q ); + move16(); } tmp = L_norm_arr( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_len ); scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_len, tmp ); - hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_q += tmp; + hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_q = add( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_q, tmp ); + move16(); - if ( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_fx != 0 ) + IF( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_fx != 0 ) { tmp = L_norm_arr( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_len ); scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_len, tmp ); - hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_q += tmp; + hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_q = add( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_q, tmp ); + move16(); } } - else + ELSE { FOR( slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[hSpatParamRendCom->subframes_rendered]; slot_idx++ ) { @@ -15325,17 +15312,15 @@ static void intermidiate_ext_dirac_render( { scale_sig32( hMasaExtRend->cldfbAnaRend[ch]->cldfb_state_fx, hMasaExtRend->cldfbAnaRend[ch]->cldfb_size, sub( Q11, hMasaExtRend->cldfbAnaRend[0]->Q_cldfb_state ) ); hMasaExtRend->cldfbAnaRend[ch]->Q_cldfb_state = Q11; + move16(); } } - for ( ch = 0; ch < hDirACRend->hOutSetup.nchan_out_woLFE + hDirACRend->hOutSetup.num_lfe; ch++ ) + FOR( ch = 0; ch < hDirACRend->hOutSetup.nchan_out_woLFE + hDirACRend->hOutSetup.num_lfe; ch++ ) { scale_sig32( hMasaExtRend->cldfbSynRend[ch]->cldfb_state_fx, hMasaExtRend->cldfbSynRend[ch]->cldfb_size, sub( Q11, hMasaExtRend->cldfbSynRend[0]->Q_cldfb_state ) ); hMasaExtRend->cldfbSynRend[ch]->Q_cldfb_state = Q11; - } - for ( i = 0; i < MAX_OUTPUT_CHANNELS; i++ ) - { - fixedToFloat_arrL( output_f[i], output_f_flt[i], hMasaExtRend->cldfbSynRend[0]->Q_cldfb_state, L_FRAME48k ); + move16(); } } } -- GitLab From e94ed014767d5a892ac6eb0c61d1b13dd30ecd51 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Thu, 1 Aug 2024 12:01:42 +0530 Subject: [PATCH 2/2] Revert some renderer cleanup changes --- lib_rend/ivas_dirac_dec_binaural_functions.c | 98 ++---- lib_rend/ivas_prot_rend.h | 8 - lib_rend/lib_rend.c | 331 ++++++++++--------- 3 files changed, 199 insertions(+), 238 deletions(-) diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index 09c8f2a87..590704a99 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -178,11 +178,9 @@ static void matrixMul( float Are[BINAURAL_CHANNELS][BINAURAL_CHANNELS], float Ai static void matrixTransp2Mul( float Are[BINAURAL_CHANNELS][BINAURAL_CHANNELS], float Aim[BINAURAL_CHANNELS][BINAURAL_CHANNELS], float Bre[BINAURAL_CHANNELS][BINAURAL_CHANNELS], float Bim[BINAURAL_CHANNELS][BINAURAL_CHANNELS], float outRe[BINAURAL_CHANNELS][BINAURAL_CHANNELS], float outIm[BINAURAL_CHANNELS][BINAURAL_CHANNELS] ); #endif -#ifdef IVAS_FLOAT_FIXED -static void ivas_masa_ext_rend_parambin_internal_fx( MASA_EXT_REND_HANDLE hMasaExtRend, COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, Word32 *output_fx[], const Word16 subframe ); -#else + static void ivas_masa_ext_rend_parambin_internal( MASA_EXT_REND_HANDLE hMasaExtRend, COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, float *output_f[], const int16_t subframe ); -#endif + #ifdef IVAS_FLOAT_FIXED static void formulate2x2MixingMatrix_fx( Word32 Ein1_fx, Word32 Ein2_fx, Word16 q_Ein, Word32 CinRe_fx, Word32 CinIm_fx, Word16 q_Cin, Word32 Eout1_fx, Word32 Eout2_fx, Word16 q_Eout, Word32 CoutRe_fx, Word32 CoutIm_fx, Word16 q_Cout, Word32 Q_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], Word32 Mre_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], Word32 Mim_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], Word16 *q_M, const Word16 regularizationFactor_fx ); @@ -7814,10 +7812,10 @@ static void ivas_masa_ext_rend_parambin_internal( return; } #else -static void ivas_masa_ext_rend_parambin_internal_fx( +static void ivas_masa_ext_rend_parambin_internal( MASA_EXT_REND_HANDLE hMasaExtRend, COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, - Word32 *output_fx[], /* Q11*/ + float *output_f[], const Word16 subframe ) { @@ -7830,20 +7828,21 @@ static void ivas_masa_ext_rend_parambin_internal_fx( Word16 i, j; Word16 nchan_transport; Word16 q_mat; + +#if 1 hDiracDecBin = hMasaExtRend->hDiracDecBin; hSpatParamRendCom = hMasaExtRend->hSpatParamRendCom; + Word32 *output_fx[MAX_OUTPUT_CHANNELS]; + Word32 output_fx_buff[MAX_OUTPUT_CHANNELS][L_FRAME48k]; + FOR( ch = 0; ch < 2; ch++ ) + { + output_fx[ch] = output_fx_buff[ch]; + floatToFixed_arrL32( output_f[ch], output_fx[ch], Q11, L_FRAME48k ); + } +#endif Word32 Cldfb_RealBuffer_in_fx[6][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; Word32 Cldfb_ImagBuffer_in_fx[6][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; - - FOR( i = 0; i < 6; i++ ) - { - FOR( j = 0; j < CLDFB_SLOTS_PER_SUBFRAME; j++ ) - { - set32_fx( Cldfb_RealBuffer_in_fx[i][j], 0, CLDFB_NO_CHANNELS_MAX ); - set32_fx( Cldfb_ImagBuffer_in_fx[i][j], 0, CLDFB_NO_CHANNELS_MAX ); - } - } Word32 Rmat_fx[3][3]; hDiracDecBin = hMasaExtRend->hDiracDecBin; @@ -7864,16 +7863,8 @@ static void ivas_masa_ext_rend_parambin_internal_fx( move16(); config_data.qualityBasedSmFactor_fx = ONE_IN_Q31; move32(); - IF( EQ_16( hMasaExtRend->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) - { - config_data.processReverb = 1; - move16(); - } - ELSE - { - config_data.processReverb = 0; - move16(); - } + config_data.processReverb = hMasaExtRend->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ? 1 : 0; + move16(); config_data.ism_mode = ISM_MODE_NONE; move32(); @@ -7935,7 +7926,6 @@ static void ivas_masa_ext_rend_parambin_internal_fx( } } Word16 q_inp = Q6; - move16(); IF( hCombinedOrientationData ) { FOR( i = 0; i < 3; i++ ) @@ -7992,15 +7982,20 @@ static void ivas_masa_ext_rend_parambin_internal_fx( hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[hCombinedOrientationData->subframe_idx] > 0, 0, NULL ); +#if 1 Word16 q_out; q_inp = Q6; move16(); - + FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + output_fx[ch] = output_fx_buff[ch]; + } FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { hMasaExtRend->cldfbSynRend[ch]->Q_cldfb_state = Q11; move16(); } +#endif // Float to fix ends q_mat = hDiracDecBin->q_processMtx; move16(); @@ -8047,18 +8042,20 @@ static void ivas_masa_ext_rend_parambin_internal_fx( move16(); move16(); +#if 1 // Fix to float FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { - scale_sig32( output_fx[ch], nBins * hSpatParamRendCom->subframe_nbslots[subframe], sub( Q11, q_out ) ); + fixedToFloat_arrL32( output_fx[ch], output_f[ch], q_out, nBins * hSpatParamRendCom->subframe_nbslots[subframe] ); scale_sig32( hMasaExtRend->cldfbSynRend[ch]->cldfb_state_fx, hMasaExtRend->cldfbSynRend[ch]->cldfb_size, sub( Q11, hMasaExtRend->cldfbSynRend[ch]->Q_cldfb_state ) ); hMasaExtRend->cldfbSynRend[ch]->Q_cldfb_state = Q11; } +#endif return; } #endif -#ifndef IVAS_FLOAT_FIXED + void ivas_masa_ext_rend_parambin_render( MASA_EXT_REND_HANDLE hMasaExtRend, /* i/o: MASA ext rend structure */ COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined orientation handle */ @@ -8098,46 +8095,3 @@ void ivas_masa_ext_rend_parambin_render( return; } -#else -void ivas_masa_ext_rend_parambin_render_fx( - MASA_EXT_REND_HANDLE hMasaExtRend, /* i/o: MASA ext rend structure */ - COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined orientation handle */ - Word32 *output_f[], /* i/o: synthesized core-coder transport channels/DirAC output Q11*/ - const Word16 num_subframes ) /* i : number of subframes to render */ -{ - Word16 subframe; - SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; - Word32 *p_output[BINAURAL_CHANNELS]; - Word16 ch; - - hSpatParamRendCom = hMasaExtRend->hSpatParamRendCom; - - FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) - { - p_output[ch] = output_f[ch]; - } - - hSpatParamRendCom->subframes_rendered = hSpatParamRendCom->dirac_read_idx; - move16(); - FOR( subframe = 0; subframe < num_subframes; subframe++ ) - { - Word16 n_samples_sf = i_mult( hSpatParamRendCom->slot_size, CLDFB_SLOTS_PER_SUBFRAME ); - hSpatParamRendCom->slots_rendered = 0; - move16(); - - ivas_masa_ext_rend_parambin_internal_fx( hMasaExtRend, hCombinedOrientationData, p_output, hSpatParamRendCom->dirac_read_idx ); - - FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) - { - p_output[ch] += n_samples_sf; - } - - ivas_combined_orientation_update_index( hCombinedOrientationData, n_samples_sf ); - - hSpatParamRendCom->dirac_read_idx = ( add( hSpatParamRendCom->dirac_read_idx, 1 ) ) % hSpatParamRendCom->dirac_md_buffer_length; - move16(); - } - - return; -} -#endif diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index 78ee3d424..dc331271f 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -357,20 +357,12 @@ void ivas_dirac_dec_binaural_render_fx( Word32 *output_f[] /* o : rendered time signal */ ); #endif -#ifndef IVAS_FLOAT_FIXED void ivas_masa_ext_rend_parambin_render( MASA_EXT_REND_HANDLE hMasaExtRend, /* i/o: MASA ext rend structure */ COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined orientation handle */ float *output_f[], /* i/o: synthesized core-coder transport channels/DirAC output */ const int16_t num_subframes /* i : number of subframes to render */ ); -#else -void ivas_masa_ext_rend_parambin_render_fx( - MASA_EXT_REND_HANDLE hMasaExtRend, /* i/o: MASA ext rend structure */ - COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined orientation handle */ - Word32 *output_f[], /* i/o: synthesized core-coder transport channels/DirAC output Q11*/ - const Word16 num_subframes ); /* i : number of subframes to render */ -#endif #ifndef IVAS_FLOAT_FIXED ivas_error ivas_dirac_dec_init_binaural_data( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index d51e11142..45d03afd3 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -130,11 +130,8 @@ typedef struct AUDIO_CONFIG inConfig; IVAS_REND_InputId id; IVAS_REND_AudioBuffer inputBuffer; -#ifndef IVAS_FLOAT_FIXED - float gain; /* Linear, not in dB */ -#else + float gain; /* Linear, not in dB */ Word32 gain_fx; /* Linear, not in dB */ -#endif rendering_context ctx; Word32 numNewSamplesPerChannel; /* Used to keep track how much new audio was fed before rendering current frame */ } input_base; @@ -387,6 +384,8 @@ static void freeMasaExtRenderer( MASA_EXT_REND_HANDLE *hMasaExtRendOut ); #ifdef IVAS_FLOAT_FIXED // TOBE REMOVED static void intermidiate_ext_dirac_render( MASA_EXT_REND_HANDLE hMasaExtRend, /* i/o: MASA renderer structure */ + Word32 *output_f[], /* i/o: input/output signals in time domain */ + float *output_f_flt[], /* i/o: input/output signals in time domain */ Word16 to_fix ); #endif /*-------------------------------------------------------------------* @@ -573,7 +572,7 @@ static void copyBufferTo2dArray_fx( return; } -#else +#endif static void copyBufferTo2dArray( const IVAS_REND_AudioBuffer buffer, float array[][L_FRAME48k] ) @@ -594,7 +593,6 @@ static void copyBufferTo2dArray( return; } -#endif #ifdef IVAS_FLOAT_FIXED static void accumulate2dArrayToBuffer_fx( Word32 array[][L_FRAME48k], @@ -616,7 +614,7 @@ static void accumulate2dArrayToBuffer_fx( return; } -#else +#endif static void accumulate2dArrayToBuffer( float array[][L_FRAME48k], IVAS_REND_AudioBuffer *buffer ) @@ -635,7 +633,6 @@ static void accumulate2dArrayToBuffer( return; } -#endif #ifdef IVAS_FLOAT_FIXED /*-------------------------------------------------------------------* * limitRendererOutput() @@ -2159,7 +2156,7 @@ static void initRendInputBase_fx( return; } -#else +#endif static void initRendInputBase( input_base *inputBase, const AUDIO_CONFIG inConfig, @@ -2184,7 +2181,7 @@ static void initRendInputBase( return; } -#endif + #ifdef IVAS_FLOAT_FIXED static IVAS_ISM_METADATA defaultObjectPosition( @@ -5341,7 +5338,7 @@ static void clearInputMasa( freeMasaExtRenderer( &inputMasa->hMasaExtRend ); - initRendInputBase_fx( &inputMasa->base, IVAS_AUDIO_CONFIG_INVALID, 0, rendCtx, NULL, 0 ); + initRendInputBase( &inputMasa->base, IVAS_AUDIO_CONFIG_INVALID, 0, rendCtx, NULL, 0 ); return; } @@ -5503,7 +5500,7 @@ ivas_error IVAS_REND_Open( FOR( i = 0; i < RENDERER_MAX_MASA_INPUTS; ++i ) { - initRendInputBase_fx( &hIvasRend->inputsMasa[i].base, IVAS_AUDIO_CONFIG_INVALID, 0, getRendCtx( hIvasRend ), NULL, 0 ); + initRendInputBase( &hIvasRend->inputsMasa[i].base, IVAS_AUDIO_CONFIG_INVALID, 0, getRendCtx( hIvasRend ), NULL, 0 ); hIvasRend->inputsMasa[i].metadataHasBeenFed = false; hIvasRend->inputsMasa[i].bufferData = NULL; @@ -12590,11 +12587,14 @@ static ivas_error renderInputMasa( IVAS_REND_AudioBuffer outAudio ) { IVAS_REND_AudioBuffer inAudio; - Word16 ch; - Word16 maxBin; + int16_t ch; + int16_t maxBin; + float *tmpBuffer[MAX_OUTPUT_CHANNELS]; + float tmpBuffer_buff[MAX_OUTPUT_CHANNELS][L_FRAME48k]; +#ifdef IVAS_FLOAT_FIXED Word32 *tmpBuffer_fx[MAX_OUTPUT_CHANNELS]; Word32 tmpBuffer_buff_fx[MAX_OUTPUT_CHANNELS][L_FRAME48k]; - +#endif IF( !masaInput->metadataHasBeenFed ) { return IVAS_ERR_MISSING_METADATA; @@ -12608,56 +12608,70 @@ static ivas_error renderInputMasa( masaInput->base.numNewSamplesPerChannel = 0; move32(); +#ifdef IVAS_FLOAT_FIXED + masaInput->base.gain = fix_to_float( masaInput->base.gain_fx, Q30 ); *outAudio.pq_fact = outAudio.q_factor; move16(); /* Apply input gain to new audio */ v_multc_fixed( inAudio.data_fx, masaInput->base.gain_fx, inAudio.data_fx, inAudio.config.numSamplesPerChannel * inAudio.config.numChannels ); *outAudio.pq_fact = sub( *outAudio.pq_fact, 1 ); // to compensate for the qfactor reduction in gain multiplication. +#endif // IVAS_FLOAT_FIXED - maxBin = extract_l( Mpy_32_32( *masaInput->base.ctx.pOutSampleRate, INV_CLDFB_BANDWIDTH_Q31 ) ); + /* Apply input gain to new audio */ + v_multc( inAudio.data, masaInput->base.gain, inAudio.data, inAudio.config.numSamplesPerChannel * inAudio.config.numChannels ); + + maxBin = (Word16) ( *masaInput->base.ctx.pOutSampleRate * INV_CLDFB_BANDWIDTH ); /* set combined orientation subframe info to start info */ ivas_combined_orientation_set_to_start_index( *( masaInput->base.ctx.pCombinedOrientationData ) ); - IF( EQ_32( getAudioConfigType( outConfig ), IVAS_REND_AUDIO_CONFIG_TYPE_MASA ) ) + if ( EQ_32( getAudioConfigType( outConfig ), IVAS_REND_AUDIO_CONFIG_TYPE_MASA ) ) { /* MASA prerendering path for MASA -> MASA */ renderMasaToMasa( masaInput, outAudio ); +#ifdef IVAS_FLOAT_FIXED + for ( Word16 i = 0; i < outAudio.config.numChannels * outAudio.config.numSamplesPerChannel; i++ ) + { + outAudio.data[i] = (float) outAudio.data_fx[i] / ( 1 << *outAudio.pq_fact ); + } +#endif } - ELSE + else { /* MASA external renderer -> other formats */ - Word16 num_subframes, exp; - FOR( ch = 0; ch < MAX_OUTPUT_CHANNELS; ch++ ) + int16_t num_subframes; + for ( ch = 0; ch < MAX_OUTPUT_CHANNELS; ch++ ) + { + tmpBuffer[ch] = tmpBuffer_buff[ch]; + } +#ifdef IVAS_FLOAT_FIXED + for ( ch = 0; ch < MAX_OUTPUT_CHANNELS; ch++ ) { tmpBuffer_fx[ch] = tmpBuffer_buff_fx[ch]; } copyBufferTo2dArray_fx( masaInput->base.inputBuffer, tmpBuffer_buff_fx ); +#endif + copyBufferTo2dArray( masaInput->base.inputBuffer, tmpBuffer_buff ); - num_subframes = BASOP_Util_Divide3232_Scale( L_mult0( masaInput->base.inputBuffer.config.numSamplesPerChannel, IVAS_NUM_FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ), *masaInput->base.ctx.pOutSampleRate, &exp ); - num_subframes = shr( num_subframes, sub( 15, exp ) ); + num_subframes = (int16_t) ( masaInput->base.inputBuffer.config.numSamplesPerChannel / ( *masaInput->base.ctx.pOutSampleRate / ( IVAS_NUM_FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) ); - SWITCH( masaInput->hMasaExtRend->renderer_type ) + switch ( masaInput->hMasaExtRend->renderer_type ) { case RENDERER_DIRAC: - +#ifdef IVAS_FLOAT_FIXED copyMasaMetadataToDiracRenderer_fx( &masaInput->masaMetadata, masaInput->hMasaExtRend->hSpatParamRendCom, maxBin ); +#else + copyMasaMetadataToDiracRenderer( &masaInput->masaMetadata, masaInput->hMasaExtRend->hSpatParamRendCom, maxBin ); +#endif +#ifdef IVAS_FLOAT_FIXED #if 1 // TOBE REMOVED - intermidiate_ext_dirac_render( masaInput->hMasaExtRend, 1 ); + intermidiate_ext_dirac_render( masaInput->hMasaExtRend, tmpBuffer_fx, tmpBuffer, 1 ); #endif FOR( ch = 0; ch < masaInput->hMasaExtRend->hDirACRend->hOutSetup.nchan_out_woLFE + masaInput->hMasaExtRend->hDirACRend->hOutSetup.num_lfe; ch++ ) { masaInput->hMasaExtRend->cldfbAnaRend[0]->Q_cldfb_state = Q11; } - FOR( ch = 0; ch < MAX_OUTPUT_CHANNELS; ch++ ) - { - Scale_sig32( tmpBuffer_buff_fx[ch], L_FRAME48k, sub( Q11, *outAudio.pq_fact ) ); - } ivas_masa_ext_dirac_render_fx( masaInput->hMasaExtRend, tmpBuffer_fx, num_subframes ); - - *outAudio.pq_fact = Q11; - move16(); - FOR( ch = 0; ch < masaInput->hMasaExtRend->hDirACRend->hOutSetup.nchan_out_woLFE + masaInput->hMasaExtRend->hDirACRend->hOutSetup.num_lfe; ch++ ) { scale_sig32( masaInput->hMasaExtRend->cldfbSynRend[ch]->cldfb_state_fx, masaInput->hMasaExtRend->cldfbSynRend[ch]->cldfb_size, sub( Q11, masaInput->hMasaExtRend->cldfbAnaRend[0]->Q_cldfb_state ) ); @@ -12665,29 +12679,29 @@ static ivas_error renderInputMasa( } #if 1 // TOBE REMOVED - intermidiate_ext_dirac_render( masaInput->hMasaExtRend, 0 ); + intermidiate_ext_dirac_render( masaInput->hMasaExtRend, tmpBuffer_fx, tmpBuffer, 0 ); #endif - BREAK; +#else + ivas_masa_ext_dirac_render( masaInput->hMasaExtRend, tmpBuffer, num_subframes ); +#endif + break; case RENDERER_STEREO_PARAMETRIC: case RENDERER_BINAURAL_PARAMETRIC: case RENDERER_BINAURAL_PARAMETRIC_ROOM: - +#ifdef IVAS_FLOAT_FIXED copyMasaMetadataToDiracRenderer_fx( &masaInput->masaMetadata, masaInput->hMasaExtRend->hSpatParamRendCom, maxBin ); - - Scale_sig32( tmpBuffer_buff_fx[0], L_FRAME48k, sub( Q11, *outAudio.pq_fact ) ); - Scale_sig32( tmpBuffer_buff_fx[1], L_FRAME48k, sub( Q11, *outAudio.pq_fact ) ); - - ivas_masa_ext_rend_parambin_render_fx( masaInput->hMasaExtRend, *masaInput->base.ctx.pCombinedOrientationData, tmpBuffer_fx, num_subframes ); - *outAudio.pq_fact = Q11; - move16(); - BREAK; +#else + copyMasaMetadataToDiracRenderer( &masaInput->masaMetadata, masaInput->hMasaExtRend->hSpatParamRendCom, maxBin ); +#endif + ivas_masa_ext_rend_parambin_render( masaInput->hMasaExtRend, *masaInput->base.ctx.pCombinedOrientationData, tmpBuffer, num_subframes ); + break; case RENDERER_DISABLE: - BREAK; /* This happens for 1TC MASA to MONO where we just copy input transport to output */ + break; /* This happens for 1TC MASA to MONO where we just copy input transport to output */ default: return ( IVAS_ERROR( IVAS_ERR_IO_CONFIG_PAIR_NOT_SUPPORTED, "Wrong output config for MASA input in external renderer\n" ) ); } - accumulate2dArrayToBuffer_fx( tmpBuffer_buff_fx, &outAudio ); + accumulate2dArrayToBuffer( tmpBuffer_buff, &outAudio ); } return IVAS_ERR_OK; @@ -12766,43 +12780,23 @@ static ivas_error renderInputMasa( return IVAS_ERR_OK; } #endif -#ifdef IVAS_FLOAT_FIXED + static ivas_error renderActiveInputsMasa( IVAS_REND_HANDLE hIvasRend, IVAS_REND_AudioBuffer outAudio ) { - Word16 i; + int16_t i; input_masa *pCurrentInput; ivas_error error; - - FOR( ( i = 0, pCurrentInput = hIvasRend->inputsMasa ); i < RENDERER_MAX_MASA_INPUTS; ( ++i, ++pCurrentInput ) ) +#ifdef IVAS_FLOAT_FIXED + if ( hIvasRend->inputsSba[0].base.inConfig != IVAS_AUDIO_CONFIG_INVALID ) { - IF( EQ_16( pCurrentInput->base.inConfig, IVAS_AUDIO_CONFIG_INVALID ) ) + for ( i = 0; i < outAudio.config.numChannels * outAudio.config.numSamplesPerChannel; i++ ) { - /* Skip inactive inputs */ - CONTINUE; - } - - *outAudio.pq_fact = Q8; - move16(); - - IF( NE_32( ( error = renderInputMasa( pCurrentInput, hIvasRend->outputConfig, outAudio ) ), IVAS_ERR_OK ) ) - { - return error; + outAudio.data[i] = (float) outAudio.data_fx[i] / ( 1 << *outAudio.pq_fact ); } } - - return IVAS_ERR_OK; -} -#else -static ivas_error renderActiveInputsMasa( - IVAS_REND_HANDLE hIvasRend, - IVAS_REND_AudioBuffer outAudio ) -{ - int16_t i; - input_masa *pCurrentInput; - ivas_error error; - +#endif for ( i = 0, pCurrentInput = hIvasRend->inputsMasa; i < RENDERER_MAX_MASA_INPUTS; ++i, ++pCurrentInput ) { if ( pCurrentInput->base.inConfig == IVAS_AUDIO_CONFIG_INVALID ) @@ -12811,15 +12805,27 @@ static ivas_error renderActiveInputsMasa( continue; } +#ifdef IVAS_FLOAT_FIXED + *outAudio.pq_fact = Q8; +#endif // IVAS_FLOAT_FIXED if ( ( error = renderInputMasa( pCurrentInput, hIvasRend->outputConfig, outAudio ) ) != IVAS_ERR_OK ) { return error; } +#ifdef IVAS_FLOAT_FIXED + if ( ( hIvasRend->inputsSba[0].base.inConfig != IVAS_AUDIO_CONFIG_INVALID ) && ( getAudioConfigType( hIvasRend->outputConfig ) != IVAS_REND_AUDIO_CONFIG_TYPE_MASA ) ) + { + for ( Word16 k = 0; k < outAudio.config.numChannels * outAudio.config.numSamplesPerChannel; k++ ) + { + outAudio.data_fx[k] = (Word32) outAudio.data[k] * ( 1 << *outAudio.pq_fact ); + } + } +#endif } return IVAS_ERR_OK; } -#endif + /*---------------------------------------------------------------------* * IVAS_REND_GetMasaMetadata( ) @@ -13303,10 +13309,18 @@ static ivas_error getSamplesInternal( test(); test(); - - Word32 limiter_thresold = L_lshl( IVAS_LIMITER_THRESHOLD, *outAudio.pq_fact ); - limitRendererOutput_fx( hIvasRend->hLimiter, outAudio.data_fx, outAudio.config.numSamplesPerChannel, limiter_thresold, *outAudio.pq_fact ); - + IF( NE_32( hIvasRend->inputsSba[0].base.inConfig, IVAS_AUDIO_CONFIG_INVALID ) || NE_32( hIvasRend->inputsMc[0].base.inConfig, IVAS_AUDIO_CONFIG_INVALID ) || NE_32( hIvasRend->inputsIsm[0].base.inConfig, IVAS_AUDIO_CONFIG_INVALID ) ) + { + Word32 limiter_thresold = L_lshl( IVAS_LIMITER_THRESHOLD, *outAudio.pq_fact ); + limitRendererOutput_fx( hIvasRend->hLimiter, outAudio.data_fx, outAudio.config.numSamplesPerChannel, limiter_thresold, *outAudio.pq_fact ); + } + ELSE + { + floatToFixed_arrL( outAudio.data, outAudio.data_fx, *outAudio.pq_fact, hIvasRend->hLimiter->num_channels * outAudio.config.numSamplesPerChannel ); + Word32 limiter_thresold = L_lshl( IVAS_LIMITER_THRESHOLD, *outAudio.pq_fact ); + limitRendererOutput_fx( hIvasRend->hLimiter, outAudio.data_fx, outAudio.config.numSamplesPerChannel, limiter_thresold, *outAudio.pq_fact ); + fixedToFloat_arrL( outAudio.data_fx, outAudio.data, *outAudio.pq_fact, hIvasRend->hLimiter->num_channels * outAudio.config.numSamplesPerChannel ); + } /* update global cominbed orientation start index */ ivas_combined_orientation_update_start_index( hIvasRend->hCombinedOrientationData, outAudio.config.numSamplesPerChannel ); @@ -15129,16 +15143,19 @@ static void freeMasaExtRenderer( #ifdef IVAS_FLOAT_FIXED static void intermidiate_ext_dirac_render( MASA_EXT_REND_HANDLE hMasaExtRend, /* i/o: MASA renderer structure */ + Word32 *output_f[], /* i/o: input/output signals in time domain */ + float *output_f_flt[], /* i/o: input/output signals in time domain */ Word16 to_fix ) { SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; hSpatParamRendCom = hMasaExtRend->hSpatParamRendCom; DIRAC_DEC_STACK_MEM DirAC_mem; - Word16 ch; + int16_t i, ch, q_cldfb; DIRAC_REND_HANDLE hDirACRend; - Word16 subframe_idx; - Word16 slot_idx; - Word16 nchan_transport; + int16_t subframe_idx; + int16_t slot_idx; + int16_t nchan_transport; + int16_t masa_band_mapping[MASA_FREQUENCY_BANDS + 1]; Word16 tmp; hDirACRend = hMasaExtRend->hDirACRend; @@ -15152,118 +15169,120 @@ static void intermidiate_ext_dirac_render( DirAC_mem = hDirACRend->stack_mem; - IF( to_fix ) + if ( to_fix ) { DirAC_mem.reference_power_smooth_q = DirAC_mem.reference_power_q = Q31; - move16(); - move16(); - FOR( slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[subframe_idx]; slot_idx++ ) + q_cldfb = 11; + for ( i = 0; i < MAX_OUTPUT_CHANNELS; i++ ) { - Scale_sig32( hDirACRend->h_output_synthesis_psd_state.direct_responses_fx, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ), sub( Q30, hDirACRend->h_output_synthesis_psd_state.direct_responses_q ) ); - hDirACRend->h_output_synthesis_psd_state.direct_responses_q = Q30; - move16(); + floatToFixed_arrL( output_f_flt[i], output_f[i], q_cldfb, L_FRAME48k ); + } + + for ( slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[subframe_idx]; slot_idx++ ) + { + IF( EQ_16( hDirACRend->panningConf, DIRAC_PANNING_VBAP ) ) + { + Scale_sig32( hDirACRend->h_output_synthesis_psd_state.direct_responses_fx, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ), sub( Q30, hDirACRend->h_output_synthesis_psd_state.direct_responses_q ) ); + hDirACRend->h_output_synthesis_psd_state.direct_responses_q = Q30; + } + else + { + if ( hDirACRend->panningConf == DIRAC_PANNING_HOA3 ) + { + if ( masa_band_mapping == NULL && hDirACRend->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD ) + { + Scale_sig32( hDirACRend->h_output_synthesis_psd_state.direct_responses_fx, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ), sub( Q30, hDirACRend->h_output_synthesis_psd_state.direct_responses_q ) ); + hDirACRend->h_output_synthesis_psd_state.direct_responses_q = Q30; + } + else if ( ( ( hDirACRend->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD ) && ( masa_band_mapping != NULL ) ) || + hDirACRend->synthesisConf == DIRAC_SYNTHESIS_PSD_SHD || hDirACRend->synthesisConf == DIRAC_SYNTHESIS_MONO ) + { + Scale_sig32( hDirACRend->h_output_synthesis_psd_state.direct_responses_fx, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ), sub( Q30, hDirACRend->h_output_synthesis_psd_state.direct_responses_q ) ); + hDirACRend->h_output_synthesis_psd_state.direct_responses_q = Q30; + } + ELSE IF( EQ_16( hDirACRend->panningConf, DIRAC_PANNING_VBAP ) ) /*VBAP*/ + { + Scale_sig32( hDirACRend->h_output_synthesis_psd_state.direct_responses_fx, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ), sub( Q30, hDirACRend->h_output_synthesis_psd_state.direct_responses_q ) ); + hDirACRend->h_output_synthesis_psd_state.direct_responses_q = Q30; + } + } + else if ( hDirACRend->panningConf == DIRAC_PANNING_VBAP ) /*VBAP*/ + { + Scale_sig32( hDirACRend->h_output_synthesis_psd_state.direct_responses_fx, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ), sub( Q30, hDirACRend->h_output_synthesis_psd_state.direct_responses_q ) ); + hDirACRend->h_output_synthesis_psd_state.direct_responses_q = Q30; + } + } } - IF( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_fx ) + if ( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_fx ) { Word16 shift = L_norm_arr( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_fx, hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_len ); scale_sig32( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_fx, hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_len, shift ); - hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth = add( hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth, shift ); + hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth += shift; } - IF( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev_fx ) + if ( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev_fx ) { Word16 shift = L_norm_arr( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev_len ); scale_sig32( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev_len, shift ); - hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev = add( hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev, shift ); + hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev += shift; } - IF( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_fx ) + if ( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_fx ) { Word16 shift = L_norm_arr( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_fx, hDirACRend->num_outputs_dir * hSpatParamRendCom->num_freq_bands ); scale_sig32( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_fx, hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_len, shift ); - hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth = add( hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth, shift ); + hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth += shift; } - Word16 num_channels_dir = hDirACRend->num_outputs_dir; - move16(); - IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_PSD_LS ) ) + if ( hDirACRend->synthesisConf == DIRAC_SYNTHESIS_PSD_LS ) { num_channels_dir = hDirACRend->hOutSetup.nchan_out_woLFE; - move16(); } - - IF( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx ) + if ( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx ) { tmp = L_norm_arr( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx, num_channels_dir * hSpatParamRendCom->num_freq_bands ); scale_sig32( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx, hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_len, tmp ); - h_dirac_output_synthesis_state->q_cy_auto_diff_smooth = add( h_dirac_output_synthesis_state->q_cy_auto_diff_smooth, tmp ); - move16(); + h_dirac_output_synthesis_state->q_cy_auto_diff_smooth += tmp; } - IF( hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev_fx ) + if ( hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev_fx ) { tmp = L_norm_arr( hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev_len ); scale_sig32( hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev_len, tmp ); - hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth_prev = add( hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth_prev, tmp ); - move16(); + hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth_prev += tmp; } scale_sig32( hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_fx, hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_len, Q26 - hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_q ); hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_q = Q26; - move16(); scale_sig32( hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_fx, hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_len, Q26 - hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_q ); hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_q = Q26; - move16(); - IF( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_prev_fx ) + if ( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_prev_fx ) { Word16 shift = L_norm_arr( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_prev_fx, hSpatParamRendCom->num_freq_bands * hDirACRend->num_outputs_dir ); scale_sig32( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_prev_len, shift ); - hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth_prev = add( hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth_prev, shift ); - move16(); + hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth_prev += shift; } - IF( EQ_16( hDirACRend->proto_signal_decorr_on, 1 ) ) + if ( hDirACRend->proto_signal_decorr_on == 1 ) { tmp = L_norm_arr( hDirACRend->h_freq_domain_decorr_ap_state->decorr_buffer_fx, hDirACRend->h_freq_domain_decorr_ap_state->decorr_buffer_len ); scale_sig32( hDirACRend->h_freq_domain_decorr_ap_state->decorr_buffer_fx, hDirACRend->h_freq_domain_decorr_ap_state->decorr_buffer_len, tmp ); - hDirACRend->h_freq_domain_decorr_ap_state->q_decorr_buffer = add( hDirACRend->h_freq_domain_decorr_ap_state->q_decorr_buffer, tmp ); - move16(); + hDirACRend->h_freq_domain_decorr_ap_state->q_decorr_buffer += tmp; } - IF( hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_len > 0 ) + if ( hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_len > 0 ) { - Word16 shift, norm1, norm2; + Word16 shift; Word32 tmp1, tmp2; maximum_abs_32_fx( hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_fx, hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_len, &tmp2 ); maximum_abs_32_fx( hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_fx, hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_len, &tmp1 ); - IF( tmp1 == 0 ) - { - norm1 = 31; - move16(); - } - ELSE - { - norm1 = norm_l( tmp1 ); - } - - IF( tmp2 == 0 ) - { - norm2 = 31; - move16(); - } - ELSE - { - norm2 = norm_l( tmp2 ); - } - - shift = s_min( norm1, norm2 ); + shift = s_min( ( tmp1 == 0 ) ? 31 : norm_l( tmp1 ), ( tmp2 == 0 ) ? 31 : norm_l( tmp2 ) ); + Word16 hr_exp = 31 - shift; - Word16 hr_exp = sub( 31, shift ); - - Scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_fx, hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_len, sub( sub( 31, hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q ), hr_exp ) ); - hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q = sub( 31, hr_exp ); + Scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_fx, hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_len, ( 31 - hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q ) - hr_exp ); + hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q = 31 - hr_exp; } FOR( slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[subframe_idx]; slot_idx++ ) @@ -15272,38 +15291,32 @@ static void intermidiate_ext_dirac_render( FOR( ch = 0; ch < nchan_transport; ch++ ) { hMasaExtRend->cldfbAnaRend[ch]->Q_cldfb_state = Q11; - move16(); } } - hDirACRend->proto_frame_dec_f_q = sub( 31, hDirACRend->proto_frame_dec_f_q ); - move16(); + hDirACRend->proto_frame_dec_f_q = 31 - hDirACRend->proto_frame_dec_f_q; - IF( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx ) + if ( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx ) { tmp = L_norm_arr( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx, hDirACRend->num_protos_dir * hSpatParamRendCom->num_freq_bands ); scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_len, tmp ); - hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q = add( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, tmp ); - move16(); + hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q += tmp; tmp = L_norm_arr( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_fx, hDirACRend->num_protos_dir * hSpatParamRendCom->num_freq_bands ); scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_len, tmp ); - hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q = add( tmp, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q ); - move16(); + hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q += tmp; } tmp = L_norm_arr( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_len ); scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_len, tmp ); - hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_q = add( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_q, tmp ); - move16(); + hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_q += tmp; - IF( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_fx != 0 ) + if ( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_fx != 0 ) { tmp = L_norm_arr( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_len ); scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_len, tmp ); - hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_q = add( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_q, tmp ); - move16(); + hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_q += tmp; } } - ELSE + else { FOR( slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[hSpatParamRendCom->subframes_rendered]; slot_idx++ ) { @@ -15312,15 +15325,17 @@ static void intermidiate_ext_dirac_render( { scale_sig32( hMasaExtRend->cldfbAnaRend[ch]->cldfb_state_fx, hMasaExtRend->cldfbAnaRend[ch]->cldfb_size, sub( Q11, hMasaExtRend->cldfbAnaRend[0]->Q_cldfb_state ) ); hMasaExtRend->cldfbAnaRend[ch]->Q_cldfb_state = Q11; - move16(); } } - FOR( ch = 0; ch < hDirACRend->hOutSetup.nchan_out_woLFE + hDirACRend->hOutSetup.num_lfe; ch++ ) + for ( ch = 0; ch < hDirACRend->hOutSetup.nchan_out_woLFE + hDirACRend->hOutSetup.num_lfe; ch++ ) { scale_sig32( hMasaExtRend->cldfbSynRend[ch]->cldfb_state_fx, hMasaExtRend->cldfbSynRend[ch]->cldfb_size, sub( Q11, hMasaExtRend->cldfbSynRend[0]->Q_cldfb_state ) ); hMasaExtRend->cldfbSynRend[ch]->Q_cldfb_state = Q11; - move16(); + } + for ( i = 0; i < MAX_OUTPUT_CHANNELS; i++ ) + { + fixedToFloat_arrL( output_f[i], output_f_flt[i], hMasaExtRend->cldfbSynRend[0]->Q_cldfb_state, L_FRAME48k ); } } } -- GitLab