From 010c4af772b1828f780d8a2a9cc024891f052069 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Wed, 15 May 2024 10:05:17 +0530 Subject: [PATCH] Renderer cleanup changes, MSAN error fixes, MC reconfig cleanup [x] Few MSAN errors for stereo fixed. [x] renderMcToMasa(), renderInputMc(), renderActiveInputsMc() cleaned up [x] MC dec config cleanup --- lib_com/float_to_fix_ops.c | 10 +- lib_com/ivas_prot_fx.h | 2 +- lib_dec/TonalComponentDetection_fx.c | 9 +- lib_dec/acelp_core_dec_ivas_fx.c | 4 + lib_dec/core_switching_dec_fx.c | 5 + lib_dec/ivas_binRenderer_internal.c | 2 +- lib_dec/ivas_core_dec.c | 28 ++--- lib_dec/ivas_dirac_dec.c | 17 +++ lib_dec/ivas_dirac_output_synthesis_cov.c | 48 ++------- lib_dec/ivas_jbm_dec.c | 119 +++++++++++---------- lib_dec/ivas_mc_param_dec.c | 58 +++++++--- lib_dec/ivas_mct_dec.c | 54 ++++------ lib_dec/ivas_stat_dec.h | 2 + lib_dec/ivas_stereo_ica_dec.c | 5 + lib_dec/ivas_stereo_icbwe_dec.c | 5 +- lib_dec/ivas_tcx_core_dec.c | 6 +- lib_dec/swb_tbe_dec_fx.c | 2 +- lib_dec/updt_dec_fx.c | 1 + lib_rend/ivas_dirac_output_synthesis_dec.c | 20 ++-- lib_rend/ivas_mcmasa_ana.c | 7 +- lib_rend/lib_rend.c | 113 +++++-------------- 21 files changed, 240 insertions(+), 277 deletions(-) diff --git a/lib_com/float_to_fix_ops.c b/lib_com/float_to_fix_ops.c index 780f87270..883f3ba54 100644 --- a/lib_com/float_to_fix_ops.c +++ b/lib_com/float_to_fix_ops.c @@ -683,7 +683,7 @@ void stereo_tcx_dec_mode_switch_reconf_To_fixed_2( st->hTcxDec->conNoiseLevelIndex = st->hTcxDec->NoiseLevelIndex_bfi; st->hTcxDec->conCurrLevelIndex = st->hTcxDec->CurrLevelIndex_bfi; st->hTcxDec->conLastFrameLevel = st->hTcxDec->LastFrameLevel_bfi_fx; - st->hTcxDec->conLastFrameLevel_e = 0; + //st->hTcxDec->conLastFrameLevel_e = 0; } IF( st->hHQ_core ) @@ -756,10 +756,10 @@ void stereo_tcx_dec_mode_switch_reconf_To_fixed_2( st->prev_Q_syn = st->Q_syn; //st->hTcxDec->conceal_eof_gain = (Word16) floatToFixed( st->hTcxDec->conceal_eof_gain_float, Q14 ); //st->hTcxDec->conCngLevelBackgroundTrace = (Word16) floatToFixed( st->hTcxDec->CngLevelBackgroundTrace_bfi, Q15 - st->hTcxDec->conCngLevelBackgroundTrace_e ); - if ( st->hTcxDec->conNoiseLevelMemory_e[0] < 0 ) - { - set16_fx( st->hTcxDec->conNoiseLevelMemory_e, 0, PLC_MIN_STAT_BUFF_SIZE ); - } + //if ( st->hTcxDec->conNoiseLevelMemory_e[0] < 0 ) + //{ + // set16_fx( st->hTcxDec->conNoiseLevelMemory_e, 0, PLC_MIN_STAT_BUFF_SIZE ); + //} st->hTcxDec->conNoiseLevelIndex = st->hTcxDec->NoiseLevelIndex_bfi; st->hTcxDec->conCurrLevelIndex = st->hTcxDec->CurrLevelIndex_bfi; if ( hTcxLtpDec->tcxltp ) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 4bbd60e31..e6c840fef 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -1865,7 +1865,7 @@ void stereo_tcx_core_dec_fx( const FRAME_MODE frameMode, /* i : Decoder frame mode */ Word16 *signal_out, /* o : synthesis @internal_Fs, Q0 */ Word16 *signal_outFB, /* o : synthesis @output_Fs, Q0 */ - Word32 pitch_buf[], /* o : floating pitch for each subframe, Q6 */ + Word16 pitch_buf[], /* o : floating pitch for each subframe, Q6 */ const Word16 sba_dirac_stereo_flag, /* i : signal stereo output for SBA DirAC */ STEREO_TD_DEC_DATA_HANDLE hStereoTD, /* i/o: TD stereo decoder handle */ const Word16 last_element_mode, /* i : last element mode */ diff --git a/lib_dec/TonalComponentDetection_fx.c b/lib_dec/TonalComponentDetection_fx.c index 1cc38172d..e40828adc 100644 --- a/lib_dec/TonalComponentDetection_fx.c +++ b/lib_dec/TonalComponentDetection_fx.c @@ -73,7 +73,12 @@ void ivas_DetectTonalComponents_fx( { pScaledMdctSpectrum[i] = L_shl(lastMDCTSpectrum[i], 16); // Q31 - lastMDCTSpectrum_exp } - +#ifdef MSAN_FIX + FOR(Word16 i = 0; i < FDNS_NPTS; i++) + { + sns_int_scf_fx[i] = L_shl_sat(scaleFactors[i], 1 + scaleFactors_exp[i]); // Q16 + } +#endif IF (psychParamsCurrent == NULL) { nBands = FDNS_NPTS; @@ -84,10 +89,12 @@ void ivas_DetectTonalComponents_fx( } ELSE { +#ifndef MSAN_FIX FOR(Word16 i = 0; i < FDNS_NPTS; i++) { sns_int_scf_fx[i] = L_shl(scaleFactors[i], 1 + scaleFactors_exp[i]); // Q16 } +#endif q_pScaledMdctSpectrum = 31 - lastMDCTSpectrum_exp; sns_shape_spectrum_fx(pScaledMdctSpectrum, &q_pScaledMdctSpectrum, psychParamsCurrent, sns_int_scf_fx,16, nSamplesCore); q_pScaledMdctSpectrum = q_pScaledMdctSpectrum + 1; diff --git a/lib_dec/acelp_core_dec_ivas_fx.c b/lib_dec/acelp_core_dec_ivas_fx.c index 810a04adc..fea2a55ac 100644 --- a/lib_dec/acelp_core_dec_ivas_fx.c +++ b/lib_dec/acelp_core_dec_ivas_fx.c @@ -1104,7 +1104,11 @@ ivas_error acelp_core_dec_ivas_fx( lsf_dec_bfi(MODE1, lsf_new_fx, st->lsf_old_fx, st->lsf_adaptive_mean_fx, NULL, st->mem_MA_fx, st->mem_AR_fx, st->stab_fac_fx, st->last_coder_type, st->L_frame, st->last_good, st->nbLostCmpt, 0, NULL, NULL, NULL, st->hGSCDec->Last_GSC_pit_band_idx, st->Opt_AMR_WB, 0, st->bwidth); FEC_lsf2lsp_interp(st, st->L_frame, Aq_fx, lsf_new_fx, lsp_new_fx); +#ifndef MSAN_FIX for (int nsf = 0; nsf < NB_SUBFR16k; nsf++) { +#else + FOR(int nsf = 0; nsf < st->nb_subfr; nsf++) { +#endif Scale_sig(Aq_fx + (nsf * (M + 1)), M + 1, norm_s(Aq_fx[nsf * (M + 1)]) - Q2); Aq_fx[nsf * (M + 1)] = ONE_IN_Q12; } diff --git a/lib_dec/core_switching_dec_fx.c b/lib_dec/core_switching_dec_fx.c index d82aaea62..252bec195 100644 --- a/lib_dec/core_switching_dec_fx.c +++ b/lib_dec/core_switching_dec_fx.c @@ -2259,8 +2259,13 @@ static void smoothTransitionDtxToTcx_fx( Word16 i, filter_len; Word16 w, step, fade_in; Word32 mem; +#ifdef MSAN_FIX + Word16 smoothing_input_buffer[2 * NS2SA( 48000, DELAY_CLDFB_NS ) + TRANSITION_SMOOTHING_LEN_48k] = { 0 }; + Word16 smoothing_out_buffer[2 * NS2SA( 48000, DELAY_CLDFB_NS ) + TRANSITION_SMOOTHING_LEN_48k] = { 0 }; +#else Word16 smoothing_input_buffer[2 * NS2SA( 48000, DELAY_CLDFB_NS ) + TRANSITION_SMOOTHING_LEN_48k]; Word16 smoothing_out_buffer[2 * NS2SA( 48000, DELAY_CLDFB_NS ) + TRANSITION_SMOOTHING_LEN_48k]; +#endif filter_len = TRANSITION_SMOOTHING_LEN_16k; IF( EQ_16( output_frame, L_FRAME32k ) ) diff --git a/lib_dec/ivas_binRenderer_internal.c b/lib_dec/ivas_binRenderer_internal.c index 890c8367d..d3b86d78b 100644 --- a/lib_dec/ivas_binRenderer_internal.c +++ b/lib_dec/ivas_binRenderer_internal.c @@ -2614,7 +2614,7 @@ void ivas_binRenderer_fx( /* memory reset for the binaural output */ FOR(chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++) { - FOR(k = 0; k < MAX_PARAM_SPATIAL_SUBFRAMES; k++) + FOR(k = 0; k < numTimeSlots; k++) { set32_fx(Cldfb_RealBuffer_Binaural_fx[chIdx][k], 0, CLDFB_NO_CHANNELS_MAX); set32_fx(Cldfb_ImagBuffer_Binaural_fx[chIdx][k], 0, CLDFB_NO_CHANNELS_MAX); diff --git a/lib_dec/ivas_core_dec.c b/lib_dec/ivas_core_dec.c index 8826be540..27e9a3ede 100644 --- a/lib_dec/ivas_core_dec.c +++ b/lib_dec/ivas_core_dec.c @@ -148,7 +148,6 @@ ivas_error ivas_core_dec( set16_fx( output_16_fx[i], 0, L_FRAME48k ); } - Word32 pitch_buf_32fx[CPE_CHANNELS][NB_SUBFR16k]; Word16 tdm_lsfQ_PCh_fx[M], tdm_lspQ_PCh_fx[M]; Word32 conceal_eof_gain32; @@ -525,12 +524,10 @@ ivas_error ivas_core_dec( Scale_sig32(st->hFdCngDec->msNoiseEst, NPART_SHAPING, sub(st->hFdCngDec->msNoiseEst_exp, 27)); st->hFdCngDec->msNoiseEst_exp = 27; - stereo_tcx_core_dec_fx( st, frameMode[n], output_16_fx[n], synth_16_fx[n], pitch_buf_32fx[n], sba_dirac_stereo_flag, hStereoTD, last_element_mode, flag_sec_CNA, hCPE == NULL ? NULL : hCPE->hStereoCng, nchan_out, st_ivas == NULL ? 0 : st_ivas->ivas_format ); + stereo_tcx_core_dec_fx( st, frameMode[n], output_16_fx[n], synth_16_fx[n], pitch_buf_fx[n], sba_dirac_stereo_flag, hStereoTD, last_element_mode, flag_sec_CNA, hCPE == NULL ? NULL : hCPE->hStereoCng, nchan_out, st_ivas == NULL ? 0 : st_ivas->ivas_format ); Copy_Scale_sig_16_32(output_16_fx[n],output_32_fx[n],L_FRAME48k,Q11); - Copy_Scale_sig_32_16(pitch_buf_32fx[n], pitch_buf_fx[n],NB_SUBFR16k,0); - stereo_tcx_dec_mode_switch_reconf_To_fixed_2( st, 0, last_element_mode, frameMode[n]); fixed_to_float_stereo_tcx_core_dec( st, output_16_fx[n] ); } @@ -623,14 +620,14 @@ ivas_error ivas_core_dec( IF( st->hHQ_core ) floatToFixed_arr( st->hHQ_core->old_out, st->hHQ_core->old_out_fx, st->Q_syn, 960 ); - if ( st->hTcxDec && st->hTcxDec->conLastFrameLevel_e < 0 ) - { - st->hTcxDec->conLastFrameLevel_e = 0; - } - if ( st->hTcxDec && st->hTcxDec->conNoiseLevelMemory_e[0] < 0 ) - { - set16_fx( st->hTcxDec->conNoiseLevelMemory_e, 0, PLC_MIN_STAT_BUFF_SIZE ); - } + //if ( st->hTcxDec && st->hTcxDec->conLastFrameLevel_e < 0 ) + //{ + // st->hTcxDec->conLastFrameLevel_e = 0; + //} + //if ( st->hTcxDec && st->hTcxDec->conNoiseLevelMemory_e[0] < 0 ) + //{ + // set16_fx( st->hTcxDec->conNoiseLevelMemory_e, 0, PLC_MIN_STAT_BUFF_SIZE ); + //} IF( st->hTcxDec ) st->hTcxDec->conNoiseLevelIndex = st->hTcxDec->NoiseLevelIndex_bfi; IF( st->hTcxDec ) @@ -1155,8 +1152,11 @@ ivas_error ivas_core_dec( Scale_sig( tmp_buffer_fx, L_FRAME48k, Q11 - Q_white_exc ); stereo_icBWE_dec_fx( hCPE, hb_synth_32_fx[0], hb_synth_32_fx[1], tmp_buffer_fx /*fb_synth_ref*/, voice_factors_fx[0], output_frame, &q ); #ifdef MSAN_FIX - Scale_sig32(hb_synth_32_fx[0], output_frame, sub(Q11 , q)); - Scale_sig32(hb_synth_32_fx[1], output_frame, sub(Q11 , q)); + IF( !( EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) && EQ_16( hCPE->nchan_out, 1 ) || ( NE_16( st->core, ACELP_CORE ) || EQ_16( st->extl, -1 ) || ( EQ_16( hCPE->element_mode, IVAS_CPE_TD ) && NE_16( hCPE->hCoreCoder[0]->tdm_LRTD_flag, 0 ) ) ) ) ) + { + Scale_sig32( hb_synth_32_fx[0], output_frame, sub( Q11, q ) ); + Scale_sig32( hb_synth_32_fx[1], output_frame, sub( Q11, q ) ); + } #else Scale_sig32(hb_synth_32_fx[0], L_FRAME48k, sub(Q11 , q)); Scale_sig32(hb_synth_32_fx[1], L_FRAME48k, sub(Q11 , q)); diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index 82b21930d..2cb597e7d 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -5278,12 +5278,29 @@ void ivas_dirac_dec_render_sf_fx( /* Perform binaural rendering */ Word16 input_q = Q6; + + IF( st_ivas->hCombinedOrientationData != NULL ) + { + FOR( i = 0; i < 3; i++ ) + { + scale_sig32( st_ivas->hCombinedOrientationData->Rmat_fx[st_ivas->hCombinedOrientationData->subframe_idx][i], 3, Q1 ); /* Q29 -> Q30 */ + } + } + ivas_binRenderer_fx( st_ivas->hBinRenderer, st_ivas->hCombinedOrientationData, hSpatParamRendCom->subframe_nbslots[subframe_idx], Cldfb_RealBuffer_Binaural_fx, Cldfb_ImagBuffer_Binaural_fx, Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, &input_q ); + IF( st_ivas->hCombinedOrientationData != NULL ) + { + FOR( i = 0; i < 3; i++ ) + { + scale_sig32( st_ivas->hCombinedOrientationData->Rmat_fx[st_ivas->hCombinedOrientationData->subframe_idx][i], 3, -Q1 ); /* Q30 -> Q29 */ + } + } + FOR ( Word16 idx1 = 0; idx1 < BINAURAL_CHANNELS; idx1++ ) { FOR ( Word16 idx2 = 0; idx2 < MAX_PARAM_SPATIAL_SUBFRAMES; idx2++ ) diff --git a/lib_dec/ivas_dirac_output_synthesis_cov.c b/lib_dec/ivas_dirac_output_synthesis_cov.c index 8fbb8bb9b..dd9cf413c 100644 --- a/lib_dec/ivas_dirac_output_synthesis_cov.c +++ b/lib_dec/ivas_dirac_output_synthesis_cov.c @@ -209,21 +209,10 @@ ivas_error ivas_dirac_dec_output_synthesis_cov_open_fx( /* cov buffers */ for ( idx = 0; idx < num_param_bands; idx++ ) { - - if ( ( h_dirac_output_synthesis_state->cx_old[idx] = (float *) malloc( nchan_in * nchan_in * sizeof( float ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis covariance\n" ) ); - } - if ( ( h_dirac_output_synthesis_state->cy_old[idx] = (float *) malloc( nchan_out * nchan_out * sizeof( float ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis covariance\n" ) ); - } if ( ( h_dirac_output_synthesis_state->mixing_matrix_old[idx] = (float *) malloc( nchan_out * nchan_in * sizeof( float ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis covariance\n" ) ); } - set_zero( h_dirac_output_synthesis_state->cx_old[idx], nchan_in * nchan_in ); - set_zero( h_dirac_output_synthesis_state->cy_old[idx], nchan_out * nchan_out ); set_zero( h_dirac_output_synthesis_state->mixing_matrix_old[idx], nchan_out * nchan_in ); if ( ( h_dirac_output_synthesis_state->mixing_matrix[idx] = (float *) malloc( nchan_out * nchan_in * sizeof( float ) ) ) == NULL ) @@ -234,8 +223,6 @@ ivas_error ivas_dirac_dec_output_synthesis_cov_open_fx( } for ( ; idx < CLDFB_NO_CHANNELS_MAX; idx++ ) { - h_dirac_output_synthesis_state->cx_old[idx] = NULL; - h_dirac_output_synthesis_state->cy_old[idx] = NULL; h_dirac_output_synthesis_state->mixing_matrix_old[idx] = NULL; h_dirac_output_synthesis_state->mixing_matrix[idx] = NULL; } @@ -278,7 +265,7 @@ ivas_error ivas_dirac_dec_output_synthesis_cov_open_fx( #endif return IVAS_ERR_OK; } -#endif +#else ivas_error ivas_dirac_dec_output_synthesis_cov_open( DIRAC_OUTPUT_SYNTHESIS_PARAMS *h_dirac_output_synthesis_params, /* i/o: handle for the covariance synthesis parameters */ DIRAC_OUTPUT_SYNTHESIS_COV_STATE *h_dirac_output_synthesis_state, /* i/o: hanlde for the covariance synthesis state */ @@ -312,15 +299,6 @@ ivas_error ivas_dirac_dec_output_synthesis_cov_open( /* cov buffers */ for ( idx = 0; idx < num_param_bands; idx++ ) { - - if ( ( h_dirac_output_synthesis_state->cx_old[idx] = (float *) malloc( nchan_in * nchan_in * sizeof( float ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis covariance\n" ) ); - } - if ( ( h_dirac_output_synthesis_state->cy_old[idx] = (float *) malloc( nchan_out * nchan_out * sizeof( float ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis covariance\n" ) ); - } if ( ( h_dirac_output_synthesis_state->mixing_matrix_old[idx] = (float *) malloc( nchan_out * nchan_in * sizeof( float ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis covariance\n" ) ); @@ -337,8 +315,6 @@ ivas_error ivas_dirac_dec_output_synthesis_cov_open( } for ( ; idx < CLDFB_NO_CHANNELS_MAX; idx++ ) { - h_dirac_output_synthesis_state->cx_old[idx] = NULL; - h_dirac_output_synthesis_state->cy_old[idx] = NULL; h_dirac_output_synthesis_state->mixing_matrix_old[idx] = NULL; h_dirac_output_synthesis_state->mixing_matrix[idx] = NULL; } @@ -392,6 +368,7 @@ ivas_error ivas_dirac_dec_output_synthesis_cov_open( return IVAS_ERR_OK; } +#endif #ifdef IVAS_FLOAT_FIXED /*-------------------------------------------------------------------* @@ -483,8 +460,6 @@ void ivas_dirac_dec_output_synthesis_cov_init_fx( #if 1/*TODO: To be removed :Floating point initializations*/ FOR ( idx = 0; idx < n_param_bands; idx++ ) { - set_zero( h_dirac_output_synthesis_state->cx_old[idx], nchan_in * nchan_in ); - set_zero( h_dirac_output_synthesis_state->cy_old[idx], nchan_out * nchan_out ); set_zero( h_dirac_output_synthesis_state->mixing_matrix_old[idx], nchan_out * nchan_in ); set_zero( h_dirac_output_synthesis_state->mixing_matrix[idx], nchan_out * nchan_in ); } @@ -498,8 +473,7 @@ void ivas_dirac_dec_output_synthesis_cov_init_fx( return; } -#endif // IVAS_FLOAT_FIXED - +#else void ivas_dirac_dec_output_synthesis_cov_init( DIRAC_OUTPUT_SYNTHESIS_COV_STATE *h_dirac_output_synthesis_state, /* i/o: pointer to the state of the covariance synthesis */ const int16_t nchan_in, /* i : number of input (tranport) channels */ @@ -528,6 +502,7 @@ void ivas_dirac_dec_output_synthesis_cov_init( return; } +#endif // IVAS_FLOAT_FIXED /*-------------------------------------------------------------------* @@ -669,17 +644,6 @@ void ivas_dirac_dec_output_synthesis_cov_close_fx( /* free cov buffers */ FOR ( idx = 0; idx < CLDFB_NO_CHANNELS_MAX; idx++ ) { - IF ( h_dirac_output_synthesis_state->cx_old[idx] != NULL ) - { - free( h_dirac_output_synthesis_state->cx_old[idx] ); - h_dirac_output_synthesis_state->cx_old[idx] = NULL; - } - - IF ( h_dirac_output_synthesis_state->cy_old[idx] != NULL ) - { - free( h_dirac_output_synthesis_state->cy_old[idx] ); - h_dirac_output_synthesis_state->cy_old[idx] = NULL; - } IF ( h_dirac_output_synthesis_state->mixing_matrix_old[idx] != NULL ) { @@ -1022,6 +986,7 @@ void ivas_dirac_dec_output_synthesis_cov_param_mc_collect_slot_fx( * samples with the covariance synthesis *-------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED void ivas_dirac_dec_output_synthesis_cov_param_mc_synthesise_slot( float *Cldfb_RealBuffer_in, /* i : input channel filter bank samples (real part) */ float *Cldfb_ImagBuffer_in, /* i : input channel filter bank samples (imaginary part) */ @@ -1137,8 +1102,7 @@ void ivas_dirac_dec_output_synthesis_cov_param_mc_synthesise_slot( return; } - -#ifdef IVAS_FLOAT_FIXED +#else void ivas_dirac_dec_output_synthesis_cov_param_mc_synthesise_slot_fx( Word32 *Cldfb_RealBuffer_in_fx, Word32 *Cldfb_ImagBuffer_in_fx, diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 1400daddf..b40f30bc6 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -439,14 +439,14 @@ ivas_error ivas_jbm_dec_tc( } } - if ( st->hTcxDec && st->hTcxDec->conLastFrameLevel_e < 0 ) - { - st->hTcxDec->conLastFrameLevel_e = 0; - } - if ( st->hTcxDec && st->hTcxDec->conNoiseLevelMemory_e[0] < 0 ) - { - set16_fx( st->hTcxDec->conNoiseLevelMemory_e, 0, PLC_MIN_STAT_BUFF_SIZE ); - } + //if ( st->hTcxDec && st->hTcxDec->conLastFrameLevel_e < 0 ) + //{ + // st->hTcxDec->conLastFrameLevel_e = 0; + //} + //if ( st->hTcxDec && st->hTcxDec->conNoiseLevelMemory_e[0] < 0 ) + //{ + // set16_fx( st->hTcxDec->conNoiseLevelMemory_e, 0, PLC_MIN_STAT_BUFF_SIZE ); + //} IF( st->hTcxDec ) st->hTcxDec->conNoiseLevelIndex = st->hTcxDec->NoiseLevelIndex_bfi; IF( st->hTcxDec ) @@ -1053,14 +1053,14 @@ ivas_error ivas_jbm_dec_tc( sts[n]->hIGFDec->infoTCXNoise_evs[l] = (Word16) sts[n]->hIGFDec->infoTCXNoise[l]; } } - if ( st->hTcxDec && st->hTcxDec->conLastFrameLevel_e < 0 ) - { - st->hTcxDec->conLastFrameLevel_e = 0; - } - if ( st->hTcxDec && st->hTcxDec->conNoiseLevelMemory_e[0] < 0 ) - { - set16_fx( st->hTcxDec->conNoiseLevelMemory_e, 0, PLC_MIN_STAT_BUFF_SIZE ); - } + //if ( st->hTcxDec && st->hTcxDec->conLastFrameLevel_e < 0 ) + //{ + // st->hTcxDec->conLastFrameLevel_e = 0; + //} + //if ( st->hTcxDec && st->hTcxDec->conNoiseLevelMemory_e[0] < 0 ) + //{ + // set16_fx( st->hTcxDec->conNoiseLevelMemory_e, 0, PLC_MIN_STAT_BUFF_SIZE ); + //} IF( st->hTcxDec ) st->hTcxDec->conNoiseLevelIndex = st->hTcxDec->NoiseLevelIndex_bfi; IF( st->hTcxDec ) @@ -1435,14 +1435,14 @@ ivas_error ivas_jbm_dec_tc( sts[n]->hIGFDec->infoTCXNoise_evs[l] = (Word16) sts[n]->hIGFDec->infoTCXNoise[l]; } } - if ( st->hTcxDec && st->hTcxDec->conLastFrameLevel_e < 0 ) - { - st->hTcxDec->conLastFrameLevel_e = 0; - } - if ( st->hTcxDec && st->hTcxDec->conNoiseLevelMemory_e[0] < 0 ) - { - set16_fx( st->hTcxDec->conNoiseLevelMemory_e, 0, PLC_MIN_STAT_BUFF_SIZE ); - } + //if ( st->hTcxDec && st->hTcxDec->conLastFrameLevel_e < 0 ) + //{ + // st->hTcxDec->conLastFrameLevel_e = 0; + //} + //if ( st->hTcxDec && st->hTcxDec->conNoiseLevelMemory_e[0] < 0 ) + //{ + // set16_fx( st->hTcxDec->conNoiseLevelMemory_e, 0, PLC_MIN_STAT_BUFF_SIZE ); + //} IF( st->hTcxDec ) st->hTcxDec->conNoiseLevelIndex = st->hTcxDec->NoiseLevelIndex_bfi; IF( st->hTcxDec ) @@ -1639,14 +1639,14 @@ ivas_error ivas_jbm_dec_tc( sts[n]->hIGFDec->infoTCXNoise_evs[l] = (Word16) sts[n]->hIGFDec->infoTCXNoise[l]; } } - if ( st->hTcxDec && st->hTcxDec->conLastFrameLevel_e < 0 ) - { - st->hTcxDec->conLastFrameLevel_e = 0; - } - if ( st->hTcxDec && st->hTcxDec->conNoiseLevelMemory_e[0] < 0 ) - { - set16_fx( st->hTcxDec->conNoiseLevelMemory_e, 0, PLC_MIN_STAT_BUFF_SIZE ); - } + //if ( st->hTcxDec && st->hTcxDec->conLastFrameLevel_e < 0 ) + //{ + // st->hTcxDec->conLastFrameLevel_e = 0; + //} + //if ( st->hTcxDec && st->hTcxDec->conNoiseLevelMemory_e[0] < 0 ) + //{ + // set16_fx( st->hTcxDec->conNoiseLevelMemory_e, 0, PLC_MIN_STAT_BUFF_SIZE ); + //} IF( st->hTcxDec ) st->hTcxDec->conNoiseLevelIndex = st->hTcxDec->NoiseLevelIndex_bfi; IF( st->hTcxDec ) @@ -1847,14 +1847,14 @@ ivas_error ivas_jbm_dec_tc( sts[n]->hIGFDec->infoTCXNoise_evs[l] = (Word16) sts[n]->hIGFDec->infoTCXNoise[l]; } } - if ( st->hTcxDec && st->hTcxDec->conLastFrameLevel_e < 0 ) - { - st->hTcxDec->conLastFrameLevel_e = 0; - } - if ( st->hTcxDec && st->hTcxDec->conNoiseLevelMemory_e[0] < 0 ) - { - set16_fx( st->hTcxDec->conNoiseLevelMemory_e, 0, PLC_MIN_STAT_BUFF_SIZE ); - } + //if ( st->hTcxDec && st->hTcxDec->conLastFrameLevel_e < 0 ) + //{ + // st->hTcxDec->conLastFrameLevel_e = 0; + //} + //if ( st->hTcxDec && st->hTcxDec->conNoiseLevelMemory_e[0] < 0 ) + //{ + // set16_fx( st->hTcxDec->conNoiseLevelMemory_e, 0, PLC_MIN_STAT_BUFF_SIZE ); + //} IF( st->hTcxDec ) st->hTcxDec->conNoiseLevelIndex = st->hTcxDec->NoiseLevelIndex_bfi; IF( st->hTcxDec ) @@ -3859,20 +3859,20 @@ void ivas_jbm_dec_feed_tc_to_renderer( nchan_out_cov = nchan_out_transport; } f2me_buf(st_ivas->hParamMC->h_output_synthesis_params.proto_matrix, st_ivas->hParamMC->h_output_synthesis_params.proto_matrix_fx, &st_ivas->hParamMC->h_output_synthesis_params.proto_matrix_e, nchan_out_cov * nchan_transport); + f2me_buf(st_ivas->hParamMC->proto_matrix_int, st_ivas->hParamMC->proto_matrix_int_fx, &st_ivas->hParamMC->proto_matrix_int_e, s_min(st_ivas->hParamMC->proto_matrix_int_len, nchan_transport * nchan_out_transport)); - //IF (st_ivas->hParamMC->synthesis_conf == PARAM_MC_SYNTH_LS_CONV_COV) - //{ - // f2me_buf(st_ivas->hParamMC->ls_conv_dmx_matrix, st_ivas->hParamMC->ls_conv_dmx_matrix_fx, &st_ivas->hParamMC->ls_conv_dmx_e, nchan_out_cov * nchan_out_transport); - //} - + ivas_param_mc_dec_digest_tc_fx( st_ivas, (uint8_t) n_render_timeslots, (Word32 **)p_data_f_fx, in_q ); + Word16 shift; FOR(Word16 param_band_idx = 0; param_band_idx < st_ivas->hParamMC->num_param_bands_synth; param_band_idx++) { - f2me_buf(st_ivas->hParamMC->h_output_synthesis_cov_state.cx_old[param_band_idx], st_ivas->hParamMC->h_output_synthesis_cov_state.cx_old_fx[param_band_idx], &st_ivas->hParamMC->h_output_synthesis_cov_state.cx_old_e[param_band_idx], s_min(st_ivas->hParamMC->h_output_synthesis_cov_state.cx_old_len, nchan_transport * nchan_transport)); - f2me_buf(st_ivas->hParamMC->h_output_synthesis_cov_state.cy_old[param_band_idx], st_ivas->hParamMC->h_output_synthesis_cov_state.cy_old_fx[param_band_idx], &st_ivas->hParamMC->h_output_synthesis_cov_state.cy_old_e[param_band_idx], nchan_out_cov * nchan_out_cov); - } - f2me_buf(st_ivas->hParamMC->proto_matrix_int, st_ivas->hParamMC->proto_matrix_int_fx, &st_ivas->hParamMC->proto_matrix_int_e, s_min(st_ivas->hParamMC->proto_matrix_int_len, nchan_transport * nchan_out_transport)); + shift = getScaleFactor32(st_ivas->hParamMC->h_output_synthesis_cov_state.cx_old_fx[param_band_idx], s_min(st_ivas->hParamMC->h_output_synthesis_cov_state.cx_old_len, nchan_transport * nchan_transport)); + scale_sig32(st_ivas->hParamMC->h_output_synthesis_cov_state.cx_old_fx[param_band_idx], s_min(st_ivas->hParamMC->h_output_synthesis_cov_state.cx_old_len, nchan_transport * nchan_transport), shift); + st_ivas->hParamMC->h_output_synthesis_cov_state.cx_old_e[param_band_idx] = sub(st_ivas->hParamMC->h_output_synthesis_cov_state.cx_old_e[param_band_idx], shift); - ivas_param_mc_dec_digest_tc_fx( st_ivas, (uint8_t) n_render_timeslots, (Word32 **)p_data_f_fx, in_q ); + shift = getScaleFactor32(st_ivas->hParamMC->h_output_synthesis_cov_state.cy_old_fx[param_band_idx], nchan_out_cov * nchan_out_cov); + scale_sig32(st_ivas->hParamMC->h_output_synthesis_cov_state.cy_old_fx[param_band_idx], nchan_out_cov * nchan_out_cov, shift); + st_ivas->hParamMC->h_output_synthesis_cov_state.cy_old_e[param_band_idx] = sub(st_ivas->hParamMC->h_output_synthesis_cov_state.cy_old_e[param_band_idx], shift); + } me2f_buf_16(st_ivas->hParamMC->h_output_synthesis_params.interpolator_fx, 0, st_ivas->hParamMC->h_output_synthesis_params.interpolator, n_render_timeslots ); @@ -3885,13 +3885,6 @@ void ivas_jbm_dec_feed_tc_to_renderer( me2f_buf(st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_fx[param_band_idx], st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_exp[param_band_idx], st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_res[param_band_idx], nchan_out_cov * nchan_out_cov); } } - - FOR(Word16 param_band_idx = 0; param_band_idx < st_ivas->hParamMC->num_param_bands_synth; param_band_idx++) - { - me2f_buf(st_ivas->hParamMC->h_output_synthesis_cov_state.cx_old_fx[param_band_idx], st_ivas->hParamMC->h_output_synthesis_cov_state.cx_old_e[param_band_idx], st_ivas->hParamMC->h_output_synthesis_cov_state.cx_old[param_band_idx], s_min(st_ivas->hParamMC->h_output_synthesis_cov_state.cx_old_len, nchan_transport * nchan_transport)); - me2f_buf(st_ivas->hParamMC->h_output_synthesis_cov_state.cy_old_fx[param_band_idx], st_ivas->hParamMC->h_output_synthesis_cov_state.cy_old_e[param_band_idx], st_ivas->hParamMC->h_output_synthesis_cov_state.cy_old[param_band_idx], nchan_out_cov * nchan_out_cov); - } - #else ivas_param_mc_dec_digest_tc( st_ivas, (uint8_t) n_render_timeslots, p_data_f ); #endif @@ -5762,9 +5755,21 @@ ivas_error ivas_jbm_dec_render( { FOR(Word16 param_band_idx = 0; param_band_idx < st_ivas->hParamMC->hMetadataPMC->nbands_coded; param_band_idx++) { IF(st_ivas->hParamMC->band_grouping[param_band_idx] < st_ivas->hParamMC->h_output_synthesis_params.max_band_decorr) { +#ifdef IVAS_FLOAT_FIXED + mvl2l(st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_fx[param_band_idx], st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_old_fx[param_band_idx], nchan_transport_tmp * nchan_out_cov); + st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_old_exp[param_band_idx] = st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_exp[param_band_idx]; + move16(); +#else mvr2r(st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_res[param_band_idx], st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_old[param_band_idx], nchan_transport_tmp * nchan_out_cov); +#endif } +#ifdef IVAS_FLOAT_FIXED + mvl2l(st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_fx[param_band_idx], st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_old_fx[param_band_idx], nchan_transport_tmp * nchan_out_cov); + st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_old_exp[param_band_idx] = st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_exp[param_band_idx]; + move16(); +#else mvr2r(st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix[param_band_idx], st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_old[param_band_idx], nchan_transport_tmp * nchan_out_cov); +#endif } } #endif diff --git a/lib_dec/ivas_mc_param_dec.c b/lib_dec/ivas_mc_param_dec.c index 033e4ad46..1a68db7ee 100644 --- a/lib_dec/ivas_mc_param_dec.c +++ b/lib_dec/ivas_mc_param_dec.c @@ -1631,10 +1631,10 @@ ivas_error ivas_param_mc_dec_reconfig_fx( { /* Cx */ v_multc_fixed_16( cov_state_old.cx_old_fx[parameter_band_mapping.source_band_idx[new_param_band_idx][source_param_idx]], parameter_band_mapping.source_band_factor_fx[new_param_band_idx][source_param_idx], tmp_buf_fx, nchan_transport_old * nchan_transport_old ); - v_add_fx( tmp_buf_fx, hParamMC->h_output_synthesis_cov_state.cx_old_fx[new_param_band_idx], hParamMC->h_output_synthesis_cov_state.cx_old_fx[new_param_band_idx], nchan_transport_old * nchan_transport_old ); + v_add_fixed_me( tmp_buf_fx, cov_state_old.cx_old_e[parameter_band_mapping.source_band_idx[new_param_band_idx][source_param_idx]], hParamMC->h_output_synthesis_cov_state.cx_old_fx[new_param_band_idx], hParamMC->h_output_synthesis_cov_state.cx_old_e[new_param_band_idx], hParamMC->h_output_synthesis_cov_state.cx_old_fx[new_param_band_idx], &hParamMC->h_output_synthesis_cov_state.cx_old_e[new_param_band_idx], nchan_transport_old * nchan_transport_old, 0 ); /* Cy */ v_multc_fixed_16( cov_state_old.cy_old_fx[parameter_band_mapping.source_band_idx[new_param_band_idx][source_param_idx]], parameter_band_mapping.source_band_factor_fx[new_param_band_idx][source_param_idx], tmp_buf_fx, nchan_out_cov * nchan_out_cov ); - v_add_fx( tmp_buf_fx, hParamMC->h_output_synthesis_cov_state.cy_old_fx[new_param_band_idx], hParamMC->h_output_synthesis_cov_state.cy_old_fx[new_param_band_idx], nchan_out_cov * nchan_out_cov ); + v_add_fixed_me( tmp_buf_fx, cov_state_old.cy_old_e[parameter_band_mapping.source_band_idx[new_param_band_idx][source_param_idx]], hParamMC->h_output_synthesis_cov_state.cy_old_fx[new_param_band_idx], hParamMC->h_output_synthesis_cov_state.cy_old_e[new_param_band_idx], hParamMC->h_output_synthesis_cov_state.cy_old_fx[new_param_band_idx], &hParamMC->h_output_synthesis_cov_state.cy_old_e[new_param_band_idx], nchan_out_cov * nchan_out_cov, 0 ); /* mixing matrix*/ v_multc_fixed_16( cov_state_old.mixing_matrix_old_fx[parameter_band_mapping.source_band_idx[new_param_band_idx][source_param_idx]], parameter_band_mapping.source_band_factor_fx[new_param_band_idx][source_param_idx], tmp_buf_fx, nchan_transport_old * nchan_out_cov ); v_add_fx( tmp_buf_fx, hParamMC->h_output_synthesis_cov_state.mixing_matrix_old_fx[new_param_band_idx], hParamMC->h_output_synthesis_cov_state.mixing_matrix_old_fx[new_param_band_idx], nchan_transport_old * nchan_out_cov ); @@ -3903,8 +3903,7 @@ void ivas_param_mc_dec_render_fx( return; } -#endif - +#else void ivas_param_mc_dec_render( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ @@ -4459,7 +4458,7 @@ pop_wmops(); return; } - +#endif /*------------------------------------------------------------------------- * ivas_param_mc_dec() * @@ -4562,7 +4561,7 @@ static void ivas_param_mc_dec_init_fx( return; } -#endif // IVAS_FLOAT_FIXED +#else static void ivas_param_mc_dec_init( PARAM_MC_DEC_HANDLE hParamMC, /* i/o: decoder DirAC handle */ const int16_t nchan_transport, /* i : number of input (transport) channels */ @@ -4615,7 +4614,7 @@ static void ivas_param_mc_dec_init( return; } - +#endif /*------------------------------------------------------------------------- * Local functions @@ -5104,6 +5103,7 @@ static void remove_lfe_from_cy_fx( * using the covariance method *------------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED static void ivas_param_mc_get_mixing_matrices( PARAM_MC_DEC_HANDLE hParamMC, /* i : Parametric MC handle */ IVAS_OUTPUT_SETUP *hSynthesisOutputSetup, @@ -5462,9 +5462,7 @@ static void ivas_param_mc_get_mixing_matrices( return; } - - -#ifdef IVAS_FLOAT_FIXED +#else static void ivas_param_mc_get_mixing_matrices_fx( PARAM_MC_DEC_HANDLE hParamMC, /* i : Parametric MC handle */ IVAS_OUTPUT_SETUP *hSynthesisOutputSetup, @@ -5707,11 +5705,40 @@ static void ivas_param_mc_get_mixing_matrices_fx( Copy32(Cy_state_fx, Cy_old_state_fx, nY_cov * nY_cov); + Word16 new_e = 0; + + hParamMC->h_output_synthesis_cov_state.cx_old_e[param_band_idx] = Cx_state_e; move16(); hParamMC->h_output_synthesis_cov_state.cy_old_e[param_band_idx] = Cy_state_e; move16(); + FOR( i = 0; i < nX * nX; i++ ) + { + IF(NE_32(Cx_old_state_fx[i], 0)) + { + new_e = hParamMC->h_output_synthesis_cov_state.cx_old_e[param_band_idx]; + move16(); + } + } + + hParamMC->h_output_synthesis_cov_state.cx_old_e[param_band_idx] = new_e; + move16(); + + new_e = 0; + move16(); + + FOR( i = 0; i < nY_cov * nY_cov; i++ ) + { + IF(NE_32(Cy_old_state_fx[i], 0)) + { + new_e = hParamMC->h_output_synthesis_cov_state.cy_old_e[param_band_idx]; + move16(); + } + } + + hParamMC->h_output_synthesis_cov_state.cy_old_e[param_band_idx] = new_e; + move16(); /* remove LFE IF necessary */ IF ( remove_lfe ) @@ -5873,9 +5900,7 @@ static void ivas_param_mc_get_mixing_matrices_fx( return; } - -#else - +#endif /*------------------------------------------------------------------------- @@ -5885,6 +5910,7 @@ static void ivas_param_mc_get_mixing_matrices_fx( * for mono and stereo output *------------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED // Not used anywhere static void ivas_param_mc_get_mono_stereo_mixing_matrices( PARAM_MC_DEC_HANDLE hParamMC, /* i : Parametric MC handle */ float Cx_in[PARAM_MC_MAX_PARAMETER_BANDS][PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS], /* i : transport channel covariance for all parameter bands */ @@ -6047,14 +6073,15 @@ static void ivas_param_mc_get_mono_stereo_mixing_matrices( return; } - #endif + /*------------------------------------------------------------------------- * param_mc_update_mixing_matrices() * * update mixing matrix buffers *------------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED static void param_mc_update_mixing_matrices( PARAM_MC_DEC_HANDLE hParamMC, /* i/o: Parametric MC handle */ float *mixing_matrix[], /* i : direct mixing matrices for the frame just processed */ @@ -6081,8 +6108,7 @@ static void param_mc_update_mixing_matrices( return; } - -#ifdef IVAS_FLOAT_FIXED +#else static void param_mc_update_mixing_matrices_fx( PARAM_MC_DEC_HANDLE hParamMC, /* i/o: Parametric MC handle */ Word32 *mixing_matrix[], /* i : direct mixing matrices for the frame just processed */ diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index 0aa255316..b16252440 100644 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -1385,7 +1385,7 @@ ivas_error ivas_mc_dec_config( { floatToFixed_arrL( st_ivas->hTcBuffer->tc[ch], st_ivas->hTcBuffer->tc_fx[ch], Q11, L_FRAME48k ); } - Word16 cx_e = 0, cy_e = 0, mmo_e = 0, mmro_e = 0; + Word16 mmo_e = 0, mmro_e = 0; PARAM_MC_DEC_HANDLE hParamMC; hParamMC = st_ivas->hParamMC; Word16 nchan_out_transport, nchan_out_cov; @@ -1406,22 +1406,16 @@ ivas_error ivas_mc_dec_config( { nchan_out_cov = nchan_out_transport; } - Word32 max_cx_old_fx, max_cy_old_fx, max_mix_matrix_old_fx, max_mix_matrix_res_old_fx; - float max_cx_old = hParamMC->h_output_synthesis_cov_state.cx_old[0][0], max_cy_old = hParamMC->h_output_synthesis_cov_state.cy_old[0][0], max_mix_matrix_old = hParamMC->h_output_synthesis_cov_state.mixing_matrix_old[0][0], max_mix_matrix_res_old = hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_old[0][0]; + Word32 max_mix_matrix_old_fx, max_mix_matrix_res_old_fx; + float max_mix_matrix_old = hParamMC->h_output_synthesis_cov_state.mixing_matrix_old[0][0], max_mix_matrix_res_old = hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_old[0][0]; for ( int i = 0; i < hParamMC->hMetadataPMC->num_parameter_bands; i++ ) { - if ( hParamMC->h_output_synthesis_cov_state.cx_old[i] ) + if ( hParamMC->h_output_synthesis_cov_state.mixing_matrix_old[i] ) { - for ( int j = 0; j < nchan_transport_old * nchan_transport_old; j++ ) - max_cx_old = max( max_cx_old, hParamMC->h_output_synthesis_cov_state.cx_old[i][j] ); - for ( int j = 0; j < nchan_out_cov * nchan_out_cov; j++ ) - max_cy_old = max( max_cy_old, hParamMC->h_output_synthesis_cov_state.cy_old[i][j] ); for ( int j = 0; j < nchan_transport_old * nchan_out_cov; j++ ) max_mix_matrix_old = max( max_mix_matrix_old, hParamMC->h_output_synthesis_cov_state.mixing_matrix_old[i][j] ); } } - /*IF(st_ivas->hParamMC->ls_conv_dmx_matrix_fx ) - floatToFixed_arr32( st_ivas->hParamMC->ls_conv_dmx_matrix, st_ivas->hParamMC->ls_conv_dmx_matrix_fx, Q30, st_ivas->hDecoderConfig->nchan_out * ( st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe ) );*/ for ( int i = 0; i < CLDFB_NO_CHANNELS_MAX; i++ ) { if ( hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_old[i] ) @@ -1430,8 +1424,6 @@ ivas_error ivas_mc_dec_config( max_mix_matrix_res_old = max( max_mix_matrix_res_old, hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_old[i][j] ); } } - f2me( max_cx_old, &max_cx_old_fx, &cx_e ); - f2me( max_cy_old, &max_cy_old_fx, &cy_e ); f2me( max_mix_matrix_old, &max_mix_matrix_old_fx, &mmo_e ); f2me( max_mix_matrix_res_old, &max_mix_matrix_res_old_fx, &mmro_e ); if ( mmo_e < 0 ) @@ -1440,11 +1432,8 @@ ivas_error ivas_mc_dec_config( mmro_e = 0; for ( int i = 0; i < hParamMC->hMetadataPMC->num_parameter_bands; i++ ) { - if ( hParamMC->h_output_synthesis_cov_state.cx_old[i] ) + if ( hParamMC->h_output_synthesis_cov_state.mixing_matrix_old[i] ) { - - floatToFixed_arrL( hParamMC->h_output_synthesis_cov_state.cx_old[i], hParamMC->h_output_synthesis_cov_state.cx_old_fx[i], 31 - cx_e, nchan_transport_old * nchan_transport_old ); - floatToFixed_arrL( hParamMC->h_output_synthesis_cov_state.cy_old[i], hParamMC->h_output_synthesis_cov_state.cy_old_fx[i], 31 - cy_e, nchan_out_cov * nchan_out_cov ); floatToFixed_arrL( hParamMC->h_output_synthesis_cov_state.mixing_matrix_old[i], hParamMC->h_output_synthesis_cov_state.mixing_matrix_old_fx[i], 31 - mmo_e, nchan_transport_old * nchan_out_cov ); } } @@ -1463,18 +1452,25 @@ ivas_error ivas_mc_dec_config( } } } - if ( st_ivas->hRenderConfig ) +#endif + IF ( st_ivas->hRenderConfig ) + { FOR( Word16 i = 0; i < 4; i++ ) { - st_ivas->hRenderConfig->directivity_fx[i * 3] = (Word16) floatToFixed( st_ivas->hRenderConfig->directivity[i * 3], 6 ); - st_ivas->hRenderConfig->directivity_fx[i * 3 + 1] = (Word16) floatToFixed( st_ivas->hRenderConfig->directivity[i * 3 + 1], 6 ); - st_ivas->hRenderConfig->directivity_fx[i * 3 + 2] = (Word16) floatToFixed( st_ivas->hRenderConfig->directivity[i * 3 + 2], 15 ); + st_ivas->hRenderConfig->directivity_fx[i * 3 + 2] = shl_sat( st_ivas->hRenderConfig->directivity_fx[i * 3 + 2], 9 ); } -#endif + } if ( ( error = ivas_mc_dec_reconfig( st_ivas, nSamplesRendered, data ) ) != IVAS_ERR_OK ) { return error; } + IF ( st_ivas->hRenderConfig ) + { + FOR( Word16 i = 0; i < 4; i++ ) + { + st_ivas->hRenderConfig->directivity_fx[i * 3 + 2] = shr( st_ivas->hRenderConfig->directivity_fx[i * 3 + 2], 9 ); + } + } #if 1 if ( st_ivas->mc_mode == MC_MODE_PARAMMC ) { @@ -1493,16 +1489,6 @@ ivas_error ivas_mc_dec_config( } if ( hParamMC ) { - //if ( st_ivas->hLsSetUpConversion ) - //{ - // for ( Word16 k = 0; k < nchan_transport; k++ ) - // { - // for ( int16_t i = 0; i < nchan_out_cov; i++ ) - // { - // st_ivas->hLsSetUpConversion->dmxMtx[k][i] = fixedToFloat( st_ivas->hLsSetUpConversion->dmxMtx_fx[k][i], Q30 ); - // } - // } - //} fixedToFloat_arrL( hParamMC->h_output_synthesis_params.proto_matrix_fx, hParamMC->h_output_synthesis_params.proto_matrix, 26, nchan_transport * nchan_out_cov ); IF( hParamMC->diff_proto_info ) FOR( Word16 i = 0; i < hParamMC->diff_proto_info->num_protos_diff; i++ ) @@ -1510,16 +1496,12 @@ ivas_error ivas_mc_dec_config( fixedToFloat_arrL( hParamMC->diff_proto_info->proto_fac_fx[i], hParamMC->diff_proto_info->proto_fac[i], 26, hParamMC->diff_proto_info->num_source_chan_diff[i] ); } fixedToFloat_arrL( hParamMC->proto_matrix_int_fx, hParamMC->proto_matrix_int, Q31, s_min(st_ivas->hParamMC->proto_matrix_int_len, nchan_out_transport * nchan_transport) ); - /*IF(st_ivas->hParamMC->ls_conv_dmx_matrix_fx ) - fixedToFloat_arrL( st_ivas->hParamMC->ls_conv_dmx_matrix_fx, st_ivas->hParamMC->ls_conv_dmx_matrix, Q30, st_ivas->hDecoderConfig->nchan_out * ( st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe ) );*/ if ( last_mc_mode == MC_MODE_PARAMMC ) { for ( int i = 0; i < hParamMC->hMetadataPMC->num_parameter_bands; i++ ) { - if ( hParamMC->h_output_synthesis_cov_state.cx_old[i] ) + if ( hParamMC->h_output_synthesis_cov_state.mixing_matrix_old[i] ) { - fixedToFloat_arrL( hParamMC->h_output_synthesis_cov_state.cx_old_fx[i], hParamMC->h_output_synthesis_cov_state.cx_old[i], 31 - cx_e, nchan_transport_old * nchan_transport_old ); - fixedToFloat_arrL( hParamMC->h_output_synthesis_cov_state.cy_old_fx[i], hParamMC->h_output_synthesis_cov_state.cy_old[i], 31 - cy_e, nchan_out_cov * nchan_out_cov ); fixedToFloat_arrL( hParamMC->h_output_synthesis_cov_state.mixing_matrix_old_fx[i], hParamMC->h_output_synthesis_cov_state.mixing_matrix_old[i], 31 - mmo_e, nchan_transport_old * nchan_out_cov ); } } diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 246d2b1fb..49b4b3b22 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -779,8 +779,10 @@ typedef struct dirac_output_synthesis_cov_state_structure float *proto_power; /* Smoothed power of the prototype signals. Size: num_freq_bands*num_channels. */ float *proto_power_diff; #endif +#ifndef IVAS_FLOAT_FIXED float *cx_old[CLDFB_NO_CHANNELS_MAX]; float *cy_old[CLDFB_NO_CHANNELS_MAX]; +#endif float *mixing_matrix_old[CLDFB_NO_CHANNELS_MAX]; float *mixing_matrix_res_old[CLDFB_NO_CHANNELS_MAX]; float *mixing_matrix[CLDFB_NO_CHANNELS_MAX]; diff --git a/lib_dec/ivas_stereo_ica_dec.c b/lib_dec/ivas_stereo_ica_dec.c index 0286ac027..fb98f4a51 100644 --- a/lib_dec/ivas_stereo_ica_dec.c +++ b/lib_dec/ivas_stereo_ica_dec.c @@ -62,8 +62,13 @@ void stereo_tca_dec_fx( ) { /* Buffers, input Left and right channels @ input_Fs*/ +#ifdef MSAN_FIX + Word32 bufChanL_fx[L_DEC_MEM_LEN_ICA + L_FRAME48k] = { 0 }; + Word32 bufChanR_fx[L_DEC_MEM_LEN_ICA + L_FRAME48k] = { 0 }; +#else Word32 bufChanL_fx[L_DEC_MEM_LEN_ICA + L_FRAME48k]; Word32 bufChanR_fx[L_DEC_MEM_LEN_ICA + L_FRAME48k]; +#endif Word32 *ptrChanL_fx, *ptrChanR_fx; Word32 *target_fx; Word16 target_idx, prevNCShift, currentNCShift, l_shift_adapt; diff --git a/lib_dec/ivas_stereo_icbwe_dec.c b/lib_dec/ivas_stereo_icbwe_dec.c index 997e6d9f4..77717273e 100644 --- a/lib_dec/ivas_stereo_icbwe_dec.c +++ b/lib_dec/ivas_stereo_icbwe_dec.c @@ -1247,8 +1247,11 @@ void stereo_icBWE_dec_fx( hStereoICBWE->prev_Q_fsout = tmp; move16(); } - +#ifndef MSAN_FIX Scale_sig32( synth_fx, L_FRAME48k, sub( *Q_syn, add( 1, tmp ) ) ); +#else + Scale_sig32( synth_fx, output_frame, sub( *Q_syn, add( 1, tmp ) ) ); +#endif *Q_syn = sub( *Q_syn, 1 ); diff --git a/lib_dec/ivas_tcx_core_dec.c b/lib_dec/ivas_tcx_core_dec.c index 21745b288..63eb0eba2 100644 --- a/lib_dec/ivas_tcx_core_dec.c +++ b/lib_dec/ivas_tcx_core_dec.c @@ -251,7 +251,7 @@ void stereo_tcx_core_dec_fx( const FRAME_MODE frameMode, /* i : Decoder frame mode */ Word16 *signal_out_fx, /* o : synthesis @internal_Fs, Q0 */ Word16 *signal_outFB_fx, /* o : synthesis @output_Fs, Q0 */ - Word32 pitch_buf_fx[], /* o : floating pitch for each subframe, Q6 */ + Word16 pitch_buf_fx[], /* o : floating pitch for each subframe, Q6 */ const Word16 sba_dirac_stereo_flag, /* i : signal stereo output for SBA DirAC */ STEREO_TD_DEC_DATA_HANDLE hStereoTD, /* i/o: TD stereo decoder handle */ const Word16 last_element_mode, /* i : last element mode */ @@ -795,11 +795,11 @@ void stereo_tcx_core_dec_fx( { Word32 tcxltp_pitch_tmp = L_add( L_deposit_h( hTcxLtpDec->tcxltp_pitch_int ), L_shl( L_deposit_l( div_s( hTcxLtpDec->tcxltp_pitch_fr, st->pit_res_max ) ), 1 ) ); /*15Q16*/ tcxltp_pitch_tmp = L_shr( tcxltp_pitch_tmp, 10 ); // Q6 - set32_fx( pitch_buf_fx, tcxltp_pitch_tmp, NB_SUBFR16k ); + set16_fx( pitch_buf_fx, extract_l( tcxltp_pitch_tmp ), NB_SUBFR16k ); } ELSE { - set32_fx( pitch_buf_fx, L_shl( L_SUBFR, 6 ), NB_SUBFR16k ); + set16_fx( pitch_buf_fx, shl( L_SUBFR, 6 ), NB_SUBFR16k ); } } diff --git a/lib_dec/swb_tbe_dec_fx.c b/lib_dec/swb_tbe_dec_fx.c index 6f7ef267f..2334893c6 100644 --- a/lib_dec/swb_tbe_dec_fx.c +++ b/lib_dec/swb_tbe_dec_fx.c @@ -559,7 +559,7 @@ void ResetSHBbuffer_Dec_fx( Decoder_State* st_fx /* i/o: SHB encoder structure * set16_fx(hBWE_TD->mem_stp_swb_fx, 0, LPC_SHB_ORDER); hBWE_TD->gain_prec_swb_fx = 16384;/*Q14 =1*/ set16_fx( &st_fx->GainShape_Delay[0], 0, NUM_SHB_SUBFR / 2 ); - + hBWE_TD->prev_pow_exc16kWhtnd_fx32 = 1; /* Q0 1.f */ hBWE_TD->prev_mix_factor_fx = 32767; /*Q15 1.f*/ set16_fx(hBWE_TD->old_core_synth_fx, 0, L_FRAME16k); diff --git a/lib_dec/updt_dec_fx.c b/lib_dec/updt_dec_fx.c index a9576c88d..9749f039a 100644 --- a/lib_dec/updt_dec_fx.c +++ b/lib_dec/updt_dec_fx.c @@ -249,6 +249,7 @@ void updt_IO_switch_dec_fx( hBWE_TD->syn_overlap_fx, hBWE_TD->state_syn_shbexc_fx, &hBWE_TD->tbe_demph_fx, &hBWE_TD->tbe_premph_fx , hBWE_TD->mem_stp_swb_fx,&(hBWE_TD->gain_prec_swb_fx) ); set16_fx( st_fx->GainShape_Delay, 0, NUM_SHB_SUBFR/2 ); + hBWE_TD->prev_pow_exc16kWhtnd_fx32 = 1; /*Q0 1.f*/ hBWE_TD->prev_mix_factor_fx = 32767; /*Q15 1.f*/ swb_tbe_reset_synth_fx(hBWE_TD->genSHBsynth_Hilbert_Mem_fx, hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx ); } diff --git a/lib_rend/ivas_dirac_output_synthesis_dec.c b/lib_rend/ivas_dirac_output_synthesis_dec.c index 1479d8885..e8260a818 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec.c @@ -3215,6 +3215,7 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( Word32 L_tmp; Word16 exp_arr[CLDFB_NO_CHANNELS_MAX * MAX_OUTPUT_CHANNELS]; Word16 exp = 0, exp1, tmp, q_com, q_tmp, min_exp; + Word32 tmp32; move16(); push_wmops( "dirac_out_synth_sfr" ); @@ -3303,23 +3304,25 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( exp = sub( Q31, Q31 ); exp1 = 0; move16(); - tmp = BASOP_Util_Divide3232_Scale( L_shl( p_cy_auto_dir_smooth[num_freq_bands], sub( q_com, h_dirac_output_synthesis_state->q_cy_auto_dir_smooth ) ), + tmp32 = BASOP_Util_Divide3232_Scale_cadence( L_shl( p_cy_auto_dir_smooth[num_freq_bands], sub( q_com, h_dirac_output_synthesis_state->q_cy_auto_dir_smooth ) ), ( L_add( Sqrt32( h_dirac_output_synthesis_state->direct_power_factor_fx[0], &exp ), EPSILON_FX ) ), // (Q31 - exp) &exp1 ); - target_power_y = L_shl( L_deposit_l( tmp ), exp1 ); // Q15 + (q_com - (31 - exp)) - q_target_power_y = add( Q15, sub( q_com, sub( Q31, exp ) ) ); + target_power_y = L_shr( tmp32, 1 ); // Q31 + (q_com - (31 - exp)) + q_target_power_y = add( Q31 - exp1, sub( q_com, sub( Q31, exp ) ) ); + q_target_power_y = sub(q_target_power_y, 1); exp = sub( Q31, Q31 ); exp1 = 0; move16(); - tmp = BASOP_Util_Divide3232_Scale( L_shl( p_cy_auto_diff_smooth[num_freq_bands], sub( q_com, h_dirac_output_synthesis_state->q_cy_auto_diff_smooth ) ), + tmp32 = BASOP_Util_Divide3232_Scale_cadence( L_shl( p_cy_auto_diff_smooth[num_freq_bands], sub( q_com, h_dirac_output_synthesis_state->q_cy_auto_diff_smooth ) ), ( L_add( Sqrt32( h_dirac_output_synthesis_state->diffuse_power_factor_fx[0], &exp ), EPSILON_FX ) ), // (Q31 - exp) &exp1 ); - target_power_y1 = L_shl( L_deposit_l( tmp ), exp1 ); // Q15 + (q_com - (31 - exp)) - q_target_power_y1 = add( Q15, sub( q_com, sub( Q31, exp ) ) ); + target_power_y1 = L_shr( tmp32, 1 ); // Q31 + (q_com - (31 - exp)) + q_target_power_y1 = add( Q31 - exp1, sub( q_com, sub( Q31, exp ) ) ); + q_target_power_y1 = sub(q_target_power_y1, 1); - target_power_y = L_add( target_power_y, target_power_y1 ); - exp = q_target_power_y; + target_power_y = L_add( L_shl(target_power_y, sub(s_min(q_target_power_y1, q_target_power_y), q_target_power_y)), L_shl(target_power_y1, sub(s_min(q_target_power_y1, q_target_power_y), q_target_power_y1))); + exp = s_min(q_target_power_y1 - 1, q_target_power_y - 1); move16(); } ELSE @@ -3346,7 +3349,6 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( Mpy_32_32( b, masa_stereo_type_detect->target_power_y_smooth_fx ) ); //(Q31, q_com) -> q_com masa_stereo_type_detect->q_target_power_y_smooth = q_com; move16(); - masa_stereo_type_detect->subtract_power_y_smooth_fx = L_add( Mpy_32_32( a, subtract_power_y ), Mpy_32_32( b, masa_stereo_type_detect->subtract_power_y_smooth_fx ) ); //(Q31, q_subtract_power_y) -> q_subtract_power_y diff --git a/lib_rend/ivas_mcmasa_ana.c b/lib_rend/ivas_mcmasa_ana.c index bf57b3fe7..83b4b4fc0 100644 --- a/lib_rend/ivas_mcmasa_ana.c +++ b/lib_rend/ivas_mcmasa_ana.c @@ -347,9 +347,10 @@ ivas_error ivas_mcmasa_ana_open( hMcMasa->prevMultiChEne_fx = 0; hMcMasa->prevDownmixEne_fx = 0; - hMcMasa->prevEQ_fx = 2147483647; - hMcMasa->prevEQ_e = 0; - + hMcMasa->prevMultiChEne_e = 0; + hMcMasa->prevDownmixEne_e = 0; + hMcMasa->prevEQ_e = 1; + hMcMasa->prevEQ_fx = 1073741824; input_frame = (int16_t) ( input_Fs / FRAMES_PER_SEC ); FOR ( i = 0; i < input_frame; i++ ) { diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index e20c61254..f0d024b31 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -10155,50 +10155,20 @@ static void renderMcToMasa( input_mc *mcInput, IVAS_REND_AudioBuffer outAudio ) { - float tmpRendBuffer[MAX_OUTPUT_CHANNELS][L_FRAME48k]; - - push_wmops( "renderMcToMasa" ); - copyBufferTo2dArray( mcInput->base.inputBuffer, tmpRendBuffer ); - #ifdef IVAS_FLOAT_FIXED + push_wmops( "renderMcToMasa" ); Word32 tmpRendBuffer_fx[MAX_OUTPUT_CHANNELS][L_FRAME48k]; copyBufferTo2dArray_fx( mcInput->base.inputBuffer, tmpRendBuffer_fx ); -#if 1 /*TODO: To be removed later: Float to fixed */ - /*From here: Cleanup changes for ivas_mcmasa_param_est_ana_fx*/ - MCMASA_ANA_HANDLE hMcMasa = mcInput->hMcMasa; - Word16 i, nchan_inp = mcInput->base.inputBuffer.config.numChannels; - Word16 q_data = *( outAudio.pq_fact ); - FOR( i = 0; i < nchan_inp - 1; i++ ) - { - floatToFixed_arrL( hMcMasa->cldfbAnaEnc[i]->cldfb_state, hMcMasa->cldfbAnaEnc[i]->cldfb_state_fx, q_data, hMcMasa->cldfbAnaEnc[i]->p_filter_length - hMcMasa->cldfbAnaEnc[i]->no_channels ); - } - /*From here: Cleanup changes for ivas_mcmasa_dmx_fx*/ -#endif ivas_mcmasa_ana_fx( mcInput->hMcMasa, tmpRendBuffer_fx, *( outAudio.pq_fact ), mcInput->base.inputBuffer.config.numSamplesPerChannel, outAudio.config.numChannels, mcInput->base.inputBuffer.config.numChannels ); -#if 1 /*TODO: To be removed later(fixed to float)*/ - /*From here : Cleanup changes for ivas_mcmasa_param_est_ana_fx*/ - FOR( i = 0; i < nchan_inp - 1; i++ ) - { - fixedToFloat_arrL( hMcMasa->cldfbAnaEnc[i]->cldfb_state_fx, hMcMasa->cldfbAnaEnc[i]->cldfb_state, q_data, hMcMasa->cldfbAnaEnc[i]->p_filter_length - hMcMasa->cldfbAnaEnc[i]->no_channels ); - } - FOR( int j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ ) - { - FOR( int k = 0; k < MASA_FREQUENCY_BANDS; k++ ) - { - hMcMasa->energy[j][k] = me2f( hMcMasa->energy_fx[j][k], hMcMasa->energy_e[j][k] ); - } - } - /*From here : cleanup changes for ivas_mcmasa_dmx_fx*/ - FOR( i = 0; i < MAX_OUTPUT_CHANNELS; i++ ) - { - fixedToFloat_arrL( tmpRendBuffer_fx[i], tmpRendBuffer[i], q_data, L_FRAME48k ); - } -#endif + accumulate2dArrayToBuffer_fx( tmpRendBuffer_fx, &outAudio ); + #else + push_wmops( "renderMcToMasa" ); + float tmpRendBuffer[MAX_OUTPUT_CHANNELS][L_FRAME48k]; + copyBufferTo2dArray( mcInput->base.inputBuffer, tmpRendBuffer ); ivas_mcmasa_ana( mcInput->hMcMasa, tmpRendBuffer, mcInput->base.inputBuffer.config.numSamplesPerChannel, outAudio.config.numChannels, mcInput->base.inputBuffer.config.numChannels ); -#endif // IVAS_FLOAT_FIXED - accumulate2dArrayToBuffer( tmpRendBuffer, &outAudio ); +#endif // IVAS_FLOAT_FIXED pop_wmops(); return; @@ -10212,80 +10182,54 @@ static ivas_error renderInputMc( { ivas_error error; IVAS_REND_AudioBuffer inAudio; - Word16 i; error = IVAS_ERR_OK; inAudio = mcInput->base.inputBuffer; - if ( mcInput->base.numNewSamplesPerChannel != outAudio.config.numSamplesPerChannel ) + IF ( NE_32(mcInput->base.numNewSamplesPerChannel , outAudio.config.numSamplesPerChannel) ) { return IVAS_ERROR( IVAS_ERR_INVALID_BUFFER_SIZE, "Mismatch between the number of input samples vs number of requested output samples - currently not allowed" ); } mcInput->base.numNewSamplesPerChannel = 0; - /* To be removed */ - mcInput->base.gain = fix_to_float( mcInput->base.gain_fx, Q30 ); - - /* Apply input gain to new audio */ -#ifndef IVAS_FLOAT_FIXED - v_multc( inAudio.data, mcInput->base.gain, inAudio.data, inAudio.config.numSamplesPerChannel * inAudio.config.numChannels ); -#endif + move32(); v_multc_fixed( inAudio.data_fx, mcInput->base.gain_fx, inAudio.data_fx, inAudio.config.numSamplesPerChannel * inAudio.config.numChannels ); - *outAudio.pq_fact -= 1; // reducing the Q by 1 compensating for the v_mult_fixed done + *outAudio.pq_fact = sub( *outAudio.pq_fact, 1 ); // reducing the Q by 1 compensating for the v_mult_fixed done /* set combined orientation subframe info to start info */ ivas_combined_orientation_set_to_start_index( *( mcInput->base.ctx.pCombinedOrientationData ) ); - switch ( getAudioConfigType( outConfig ) ) + SWITCH ( getAudioConfigType( outConfig ) ) { case IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED: renderMcToMc( mcInput, outAudio ); - for ( i = 0; i < outAudio.config.numChannels * outAudio.config.numSamplesPerChannel; i++ ) - { - outAudio.data[i] = fix_to_float( outAudio.data_fx[i], *outAudio.pq_fact ); - } - break; + BREAK; case IVAS_REND_AUDIO_CONFIG_TYPE_AMBISONICS: renderMcToSba( mcInput, outAudio ); - for ( i = 0; i < outAudio.config.numChannels * outAudio.config.numSamplesPerChannel; i++ ) - { - outAudio.data[i] = fix_to_float( outAudio.data_fx[i], *outAudio.pq_fact ); - } - break; + BREAK; case IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL: - switch ( outConfig ) + SWITCH ( outConfig ) { case IVAS_AUDIO_CONFIG_BINAURAL: error = renderMcToBinaural( mcInput, outConfig, outAudio ); - for ( i = 0; i < outAudio.config.numChannels * outAudio.config.numSamplesPerChannel; i++ ) - { - outAudio.data[i] = fix_to_float( outAudio.data_fx[i], *outAudio.pq_fact ); - } - break; + BREAK; case IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR: case IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB: - if ( mcInput->base.inConfig == IVAS_AUDIO_CONFIG_LS_CUSTOM ) + IF ( mcInput->base.inConfig == IVAS_AUDIO_CONFIG_LS_CUSTOM ) { error = renderMcCustomLsToBinauralRoom( mcInput, outConfig, outAudio ); - for ( i = 0; i < outAudio.config.numChannels * outAudio.config.numSamplesPerChannel; i++ ) - { - outAudio.data[i] = fix_to_float( outAudio.data_fx[i], *outAudio.pq_fact ); - } } - else + ELSE { error = renderMcToBinauralRoom( mcInput, outConfig, outAudio ); - for ( i = 0; i < outAudio.config.numChannels * outAudio.config.numSamplesPerChannel; i++ ) - { - outAudio.data[i] = fix_to_float( outAudio.data_fx[i], *outAudio.pq_fact ); - } + } - break; + BREAK; default: return IVAS_ERR_INVALID_OUTPUT_FORMAT; } - break; + BREAK; case IVAS_REND_AUDIO_CONFIG_TYPE_MASA: renderMcToMasa( mcInput, outAudio ); - break; + BREAK; default: return IVAS_ERR_INVALID_OUTPUT_FORMAT; } @@ -10357,28 +10301,23 @@ static ivas_error renderActiveInputsMc( IVAS_REND_HANDLE hIvasRend, IVAS_REND_AudioBuffer outAudio ) { - int16_t i; + Word16 i; input_mc *pCurrentInput; ivas_error error; - Word16 input_q = *outAudio.pq_fact; for ( i = 0, pCurrentInput = hIvasRend->inputsMc; i < RENDERER_MAX_MC_INPUTS; ++i, ++pCurrentInput ) { - if ( pCurrentInput->base.inConfig == IVAS_AUDIO_CONFIG_INVALID ) + IF ( pCurrentInput->base.inConfig == IVAS_AUDIO_CONFIG_INVALID ) { /* Skip inactive inputs */ - continue; + CONTINUE; } - if ( ( error = renderInputMc( pCurrentInput, hIvasRend->outputConfig, outAudio ) ) != IVAS_ERR_OK ) + IF ( ( error = renderInputMc( pCurrentInput, hIvasRend->outputConfig, outAudio ) ) != IVAS_ERR_OK ) { return error; } } - for ( i = 0; i < outAudio.config.numSamplesPerChannel * outAudio.config.numChannels; ++i ) - { - outAudio.data_fx[i] = (Word32) ( outAudio.data[i] * ( 1 << ( input_q - 1 ) ) ); // to make the output buffer Q same as input when it reaches renderActiveInputsSba - } return IVAS_ERR_OK; } #else @@ -11743,7 +11682,7 @@ static ivas_error getSamplesInternal( return error; } - IF( NE_32( hIvasRend->inputsSba[0].base.inConfig, IVAS_AUDIO_CONFIG_INVALID ) ) + IF( NE_32( hIvasRend->inputsSba[0].base.inConfig, IVAS_AUDIO_CONFIG_INVALID ) || NE_32( hIvasRend->inputsMc[0].base.inConfig, IVAS_AUDIO_CONFIG_INVALID ) ) { #ifndef DISABLE_LIMITER Word32 limiter_thresold = L_lshl( IVAS_LIMITER_THRESHOLD, *outAudio.pq_fact ); -- GitLab