From b60dac8d96da578d99e4d86043485ae5cea83214 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Sun, 28 Apr 2024 14:32:32 +0530 Subject: [PATCH] Param MC updates and float code cleanup --- lib_com/ivas_cnst.h | 5 + lib_com/ivas_ism_com.c | 25 +- lib_com/ivas_prot.h | 85 +- lib_com/ivas_stat_com.h | 10 +- lib_com/prot.h | 14 +- lib_com/prot_fx2.h | 39 +- lib_dec/acelp_core_dec_fx.c | 5 +- lib_dec/acelp_core_switch_dec_fx.c | 5 +- lib_dec/amr_wb_dec_fx.c | 2 +- lib_dec/bass_psfilter.c | 4 +- lib_dec/bass_psfilter_fx.c | 2 +- lib_dec/cng_dec.c | 4 +- lib_dec/cng_dec_fx.c | 4 +- lib_dec/core_dec_init.c | 4 +- lib_dec/core_dec_init_fx.c | 4 +- lib_dec/core_dec_reconf.c | 2 +- lib_dec/core_dec_reconf_fx.c | 6 +- lib_dec/core_dec_switch.c | 6 +- lib_dec/core_dec_switch_fx.c | 10 +- lib_dec/core_switching_dec_fx.c | 16 +- lib_dec/dec4t64.c | 2 +- lib_dec/dec4t64_fx.c | 9 +- lib_dec/dec_LPD.c | 6 +- lib_dec/dec_LPD_fx.c | 9 +- lib_dec/dec_ace.c | 4 +- lib_dec/dec_ace_fx.c | 9 +- lib_dec/dec_acelp.c | 2 +- lib_dec/dec_acelp_fx.c | 21 +- lib_dec/dec_acelp_tcx_main.c | 12 +- lib_dec/dec_acelp_tcx_main_fx.c | 17 +- lib_dec/dec_amr_wb_fx.c | 5 +- lib_dec/dec_gen_voic_fx.c | 3 +- lib_dec/dec_higher_acelp.c | 4 - lib_dec/dec_nelp_fx.c | 3 +- lib_dec/dec_pit_exc_fx.c | 5 +- lib_dec/evs_dec.c | 2 +- lib_dec/evs_dec_fx.c | 7 +- lib_dec/gs_dec_fx.c | 7 +- lib_dec/init_dec.c | 4 +- lib_dec/init_dec_fx.c | 8 +- lib_dec/inov_dec.c | 19 - lib_dec/inov_dec_fx.c | 7 +- lib_dec/ivas_binRenderer_internal.c | 4 +- lib_dec/ivas_dirac_dec.c | 23 +- lib_dec/ivas_dirac_output_synthesis_cov.c | 1492 +++++++++++++++++---- lib_dec/ivas_init_dec.c | 154 +++ lib_dec/ivas_ism_dec.c | 16 - lib_dec/ivas_ism_metadata_dec.c | 7 +- lib_dec/ivas_ism_param_dec.c | 2 +- lib_dec/ivas_ism_renderer.c | 14 +- lib_dec/ivas_jbm_dec.c | 193 ++- lib_dec/ivas_masa_dec.c | 166 +-- lib_dec/ivas_mc_param_dec.c | 667 +++++++++ lib_dec/ivas_mct_dec.c | 23 - lib_dec/ivas_omasa_dec.c | 169 ++- lib_dec/ivas_osba_dec.c | 101 +- lib_dec/ivas_sba_dec.c | 23 - lib_dec/ivas_sba_rendering_internal.c | 4 +- lib_dec/ivas_sce_dec.c | 2 +- lib_dec/ivas_sce_dec_fx.c | 2 +- lib_dec/ivas_stat_dec.h | 15 +- lib_dec/ivas_stereo_dft_dec.c | 100 -- lib_dec/ivas_stereo_dft_dec_fx.c | 6 +- lib_dec/ivas_stereo_switching_dec.c | 6 +- lib_dec/ivas_tcx_core_dec.c | 2 +- lib_dec/lib_dec_fx.c | 8 + lib_rend/ivas_dirac_rend.c | 4 +- lib_rend/ivas_prot_rend.h | 4 +- lib_rend/ivas_stat_rend.h | 3 +- 69 files changed, 2767 insertions(+), 860 deletions(-) diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index fde8083d8..5f5d16e7c 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -1447,6 +1447,11 @@ typedef enum PARAM_MC_SYNTH_MONO_STEREO /* synthesis to mono or stereo */ } PARAM_MC_SYNTHESIS_CONF; +#ifdef IVAS_FLOAT_FIXED +#define PARAM_MC_REG_SX_FX (429496729) /* Regularization factor for mixing matrix calculation */ +#define PARAM_MC_REG_GHAT_FX (2147483) /* Regularization factor for mixing matrix calculation */ +#endif + #define PARAM_MC_REG_SX (0.2f) /* Regularization factor for mixing matrix calculation */ #define PARAM_MC_REG_GHAT (0.001f) /* Regularization factor for mixing matrix calculation */ #define PARAM_MC_MAX_PARAMETER_BANDS 20 /* Maximum number of parameter bands */ diff --git a/lib_com/ivas_ism_com.c b/lib_com/ivas_ism_com.c index bf04a9b35..45057f786 100644 --- a/lib_com/ivas_ism_com.c +++ b/lib_com/ivas_ism_com.c @@ -739,6 +739,29 @@ ivas_error ivas_ism_config_fx( void ivas_ism_reset_metadata( ISM_METADATA_HANDLE hIsmMeta /* i/o: ISM metadata handle */ ) +{ + hIsmMeta->azimuth_fx = 0; + move32(); + hIsmMeta->elevation_fx = 0; + move32(); + hIsmMeta->yaw_fx = 0; + move32(); + hIsmMeta->pitch_fx = 0; + move32(); + hIsmMeta->radius_fx = 1 << 9; + move16(); + + hIsmMeta->ism_metadata_flag = 0; + move16(); + hIsmMeta->non_diegetic_flag = 0; + move16(); + + return; +} + +void ivas_ism_reset_metadata_enc( + ISM_METADATA_HANDLE hIsmMeta /* i/o: ISM metadata handle */ +) { hIsmMeta->azimuth_fx = 0; move32(); @@ -791,7 +814,7 @@ void ivas_ism_reset_metadata_API( ISM_METADATA_HANDLE hIsmMeta /* i/o: ISM metadata handle */ ) { - ivas_ism_reset_metadata( hIsmMeta ); + ivas_ism_reset_metadata_enc( hIsmMeta ); return; } diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index e185ffa7e..1a14fb4c8 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -1095,7 +1095,11 @@ void bitbudget_to_brate( void ivas_ism_reset_metadata( ISM_METADATA_HANDLE hIsmMeta /* i/o: ISM metadata handles */ ); - +#ifdef IVAS_FLOAT_FIXED //to be removed when converting encoder +void ivas_ism_reset_metadata_enc( + ISM_METADATA_HANDLE hIsmMeta /* i/o: ISM metadata handle */ +); +#endif void ivas_ism_reset_metadata_API( ISM_METADATA_HANDLE hIsmMeta /* i/o: ISM metadata handles */ ); @@ -1684,8 +1688,13 @@ int16_t res_bpf_adapt( const float *bpf_error_signal_8k, /* i : BPF modification signal */ float res_buf[STEREO_DFT_N_8k] /* i : residual buffer */ ); -#endif // IVAS_FLOAT_FIXED - +#else // IVAS_FLOAT_FIXED +Word16 res_bpf_adapt_ivas_fx( + STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: DFT stereo decoder handle */ + const Word32 *bpf_error_signal_8k, /* i : BPF modification signal */ + Word32 res_buf[STEREO_DFT_N_8k] /* i : residual buffer Q12 */ +); +#endif void bpf_pitch_coherence( Decoder_State *st, /* i/o: decoder state structure */ const float pitch_buf[] /* i : pitch for each subframe [0,1,2,3] */ @@ -4640,6 +4649,12 @@ void ivas_param_mc_dec_digest_tc( float *transport_channels_f[] /* i : synthesized core-coder transport channels/DirAC output*/ ); +void ivas_param_mc_dec_digest_tc_fx( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const uint8_t nCldfbSlots, /* i : number of CLFBS slots in the transport channels */ + Word32 *transport_channels_f_fx[], + Word16 transport_f_e ); + 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 */ @@ -4803,6 +4818,28 @@ int16_t computeMixingMatrices( float *Cr /* o : residual covariance matrix */ ); +#ifdef IVAS_FLOAT_FIXED +Word16 computeMixingMatrices_fx( + const Word16 num_inputs, /* i : number of input channels */ + const Word16 num_outputs, /* i : number of output channels */ + const Word32 *Cx, /* i : input channel covariance matrix */ + Word16 Cx_e, + const Word32 *Cy, /* i : target covariance matrix */ + Word16 Cy_e, + const Word32 *Q, /* i : prototype matrix (usually a upmix matrix) */ + Word16 Q_fx_e, + const Word16 energy_compensation_flag, /* i : flag indicating that the energy compensation should be performed (i.e. no residual mixing matrix will follow) */ + const Word32 reg_Sx_fx, /* i : regularization factor for the input channel singular values */ + Word16 reg_Sx_e, + const Word32 reg_ghat_fx, /* i : regularization factor for the normalization matrix */ + Word16 reg_ghat_e, + Word32 *mixing_matrix_fx, /* o : resulting mixing matrix */ + Word16 *mixing_matrix_out_e, + Word32 *Cr_fx, /* o : residual covariance matrix */ + Word16 *Cr_e +); +#endif + int16_t computeMixingMatricesResidual( const int16_t num_outputs, /* i : number of output channels */ const float *Cx, /* i : vector containing the diagonal diffuse prototype covariance */ @@ -4812,6 +4849,22 @@ int16_t computeMixingMatricesResidual( float *mixing_matrix /* o : resulting residual mixing matrix */ ); +#ifdef IVAS_FLOAT_FIXED +Word16 computeMixingMatricesResidual_fx( + const Word32 num_outputs, /* i : number of output channels */ + const Word32 *Cx_fx, /* i : vector containing the diagonal diffuse prototype covariance */ + const Word16 Cx_e, + const Word32 *Cy_fx, /* i : matrix containing the missing cov (Cr from computeMixingMatrices()) */ + const Word16 Cy_fx_e, + const Word32 reg_Sx_fx, /* i : regularization factor for the input channel singular values */ + const Word16 reg_Sx_e, + const Word32 reg_ghat_fx, /* i : regularization factor for the normalization matrix */ + const Word16 reg_ghat_e, + Word32 *mixing_matrix_fx, /* o : resulting residual mixing matrix */ + Word16 *mixing_matrix_ret_e +); +#endif + /*! r: error or success */ int16_t svd( float InputMatrix[][MAX_OUTPUT_CHANNELS], /* i : matrix to be decomposed (M) */ @@ -6469,7 +6522,7 @@ void ivas_ism2sba_sf_fx( const Word16 offset, /* i : offset for the interpolatr */ const Word16 sba_order /* i : Ambisonic (SBA) order */ ); -#endif // IVAS_FLOAT_FIXED +#else // IVAS_FLOAT_FIXED void ivas_ism2sba_sf( float *buffer_in[], /* i : TC buffer */ float *buffer_out[], /* o : TD signal buffers */ @@ -6479,7 +6532,7 @@ void ivas_ism2sba_sf( const int16_t offset, /* i : offset for the interpolatr */ const int16_t sba_order /* i : Ambisonic (SBA) order */ ); - +#endif /*----------------------------------------------------------------------------------* * Amplitude Panning VBAP prototypes @@ -6893,14 +6946,30 @@ ivas_error ivas_osba_dirac_td_binaural_jbm( float *output_f[] /* o : rendered time signal */ ); - +#ifdef IVAS_FLOAT_FIXED +ivas_error ivas_osba_ism_metadata_dec_fx( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const Word32 ism_total_brate, /* i : ISM total bitrate */ + Word16 *nchan_ism, /* o : number of ISM separated channels */ + Word16 nb_bits_metadata[] /* o : number of ISM metadata bits */ +); +#else ivas_error ivas_osba_ism_metadata_dec( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const int32_t ism_total_brate, /* i : ISM total bitrate */ int16_t *nchan_ism, /* o : number of ISM separated channels */ int16_t nb_bits_metadata[] /* o : number of ISM metadata bits */ ); - +#endif +#ifdef IVAS_FLOAT_FIXED +ivas_error ivas_osba_render_sf_fx( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const UWord16 nSamplesAsked, /* i : number of CLDFB slots requested */ + UWord16 *nSamplesRendered, /* o : number of CLDFB slots rendered */ + UWord16 *nSamplesAvailableNext, /* o : number of CLDFB slots still to render */ + Word32 *p_output[] /* o : rendered time signal */ +); +#else ivas_error ivas_osba_render_sf( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ @@ -6908,7 +6977,7 @@ ivas_error ivas_osba_render_sf( uint16_t *nSamplesAvailableNext, /* o : number of CLDFB slots still to render */ float *output_f[] /* o : rendered time signal */ ); - +#endif void ivas_osba_data_close( SBA_ISM_DATA_HANDLE *hSbaIsmData /* i/o: OSBA rendering handle */ ); diff --git a/lib_com/ivas_stat_com.h b/lib_com/ivas_stat_com.h index fe2454d6c..5636c4b64 100644 --- a/lib_com/ivas_stat_com.h +++ b/lib_com/ivas_stat_com.h @@ -59,11 +59,6 @@ typedef struct int16_t ism_metadata_flag; /* flag whether metadata are coded in particular frame of particular object */ int16_t last_ism_metadata_flag; /* last frame ism_metadata_flag */ - float azimuth; /* azimuth value read from the input metadata file */ - float elevation; /* elevation value read from the input metadata file */ - float radius; /* radius value read from the input metadata file */ - float yaw; /* yaw value read from the input metadata file */ - float pitch; /* pitch value read from the input metadata file */ #ifdef IVAS_FLOAT_FIXED Word32 azimuth_fx; /* azimuth value read from the input metadata file */ // q = 22 Word32 elevation_fx; /* elevation value read from the input metadata file */ // q = 22 @@ -71,6 +66,11 @@ typedef struct Word32 yaw_fx; /* yaw value read from the input metadata file */ // q = 22 Word32 pitch_fx; /* pitch value read from the input metadata file */ // q = 22 #endif + float azimuth; /* azimuth value read from the input metadata file */ + float elevation; /* elevation value read from the input metadata file */ + float radius; /* radius value read from the input metadata file */ + float yaw; /* yaw value read from the input metadata file */ + float pitch; /* pitch value read from the input metadata file */ int16_t non_diegetic_flag; /* Non-diegetic (non-headtracked) object flag */ diff --git a/lib_com/prot.h b/lib_com/prot.h index 82ca8a5bc..4b232e19e 100644 --- a/lib_com/prot.h +++ b/lib_com/prot.h @@ -4720,7 +4720,7 @@ void updt_dec_common( const float *synth /* i : decoded synthesis */ ); -void td_cng_dec_init_flt( +void td_cng_dec_init( DEC_CORE_HANDLE st /* i/o: decoder state structure */ ); @@ -6866,7 +6866,7 @@ void D_ACELP_indexing_ivas( int16_t prm[], int16_t *BER_detect ); -void D_ACELP_decode_43bit_flt( +void D_ACELP_decode_43bit( uint16_t idxs[], float code[], int16_t *pulsestrack ); @@ -8155,7 +8155,7 @@ void coder_acelp_rf( float *syn_rf /* i/o: pointer to RF synthesis */ ); -void decoder_acelp_flt( +void decoder_acelp( Decoder_State *st, /* i/o: coder memory state */ int16_t prm[], /* i : parameters */ const float A[], /* i : coefficients NxAz[M+1] */ @@ -9575,7 +9575,7 @@ void longshiftleft( const int16_t len /* i : length of vector a[] and d[] */ ); -void open_decoder_LPD_flt( +void open_decoder_LPD( Decoder_State *st, /* i/o: decoder state structure */ const int32_t total_brate, /* i : total bitrate */ const int32_t last_total_brate, /* i : last total bitrate */ @@ -9615,7 +9615,7 @@ void reconfig_decoder_LPD_ivas( const int16_t L_frame_old /* i : frame length */ ); -void mode_switch_decoder_LPD_flt( +void mode_switch_decoder_LPD( Decoder_State *st, /* i/o: decoder state structure */ const int16_t bwidth, /* i : audio bandwidth */ const int32_t total_brate, /* i : total bitrate */ @@ -9625,7 +9625,7 @@ void mode_switch_decoder_LPD_flt( const int16_t last_element_mode /* i : last element mode */ ); -void dec_acelp_tcx_frame_flt( +void dec_acelp_tcx_frame( Decoder_State *st, /* i/o: decoder state structure */ int16_t *concealWholeFrame, /* i/o: concealment flag */ float *output, /* o : synthesis */ @@ -9637,7 +9637,7 @@ void dec_acelp_tcx_frame_flt( STEREO_CNG_DEC_HANDLE hStereoCng /* i : stereo CNG handle */ ); -void decoder_LPD_flt( +void decoder_LPD( Decoder_State *st, /* i/o: decoder memory state pointer */ float signal_out[], /* o : signal with LPD delay (7 subfrs) */ float signal_outFB[], /* o : synthesis @output_FS */ diff --git a/lib_com/prot_fx2.h b/lib_com/prot_fx2.h index 2099979a9..5f0d68b72 100644 --- a/lib_com/prot_fx2.h +++ b/lib_com/prot_fx2.h @@ -5808,7 +5808,7 @@ void swb_CNG_dec_ivas_fx( const Word16 Qsyn /* i : Q value of ACELP core synthesis */ ); -void td_cng_dec_init( +void td_cng_dec_init_fx( DEC_CORE_HANDLE st /* i/o: decoder state structure */ ); @@ -6298,7 +6298,7 @@ void init_tcx_cfg_fx( Word16 Q_syn, Word16 bpf_noise_buf[] /* o : BPF error signal (at int_fs) */ ); - void addBassPostFilterFx( + void addBassPostFilter_fx( const Word16 *harm_timeIn_Fx, Word32 **rAnalysis_Fx, Word32 **iAnalysis_Fx, @@ -6811,7 +6811,7 @@ void GSC_dec_init_ivas_fx( const Word16 L_subfr /* i : subframe length */ ); #endif - +#ifdef IVAS_FLOAT_FIXED //dec4t64_fx.c void dec_acelp_4t64_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ @@ -6819,11 +6819,12 @@ void GSC_dec_init_ivas_fx( Word16 code[], /* o : algebraic (fixed) codebook excitation Q9*/ const Word16 Opt_AMR_WB ); +#endif + void D_ACELP_decode_43bit_fx(UWord16 idxs[], Word16 code[], Word16 *pulsestrack); - void D_ACELP_decode_43bit(UWord16 idxs[], Word16 code[], Word16 *pulsestrack); - +#ifdef IVAS_FLOAT_FIXED //dec_acelp_fx.c - void D_ACELP_indexing( + void D_ACELP_indexing_fx( Word16 code[], PulseConfig config, Word16 num_tracks, @@ -6831,8 +6832,8 @@ void GSC_dec_init_ivas_fx( , Word16 *BER_detect ); - void fcb_pulse_track_joint_decode(UWord16 *idxs, Word16 wordcnt, UWord32 *index_n, Word16 *pulse_num, Word16 track_num); - + void fcb_pulse_track_joint_decode_fx(UWord16 *idxs, Word16 wordcnt, UWord32 *index_n, Word16 *pulse_num, Word16 track_num); +#endif //dec2t32_fx.c void dec_acelp_2t32_fx( @@ -7792,6 +7793,7 @@ void generate_comfort_noise_dec_hf_ivas_fx( #endif ); +#ifdef IVAS_FLOAT_FIXED //dec_amr_wb_fx.c void decod_amr_wb_fx( Decoder_State *st_fx, /* i/o: decoder static memory */ @@ -7803,6 +7805,7 @@ void generate_comfort_noise_dec_hf_ivas_fx( Word16 *voice_factors_fx, /* o : voicing factors */ Word16 *gain_buf /* o : floating pitch gain for each subframe Q14 */ ); +#endif //rst_dec_fx.c void CNG_reset_dec_fx( @@ -7839,7 +7842,7 @@ void generate_comfort_noise_dec_hf_ivas_fx( ); //core_dec_init_fx.c - void open_decoder_LPD( + void open_decoder_LPD_fx( Decoder_State* st, const Word32 total_brate, #ifdef NEW_IVAS_OPEN_DEC @@ -8150,8 +8153,9 @@ void generate_comfort_noise_dec_hf_ivas_fx( Word16 *ni_seed_fx /* i/o: random seed */ ); +#ifdef IVAS_FLOAT_FIXED //dec_acelp_tck_main_fx.c - Word16 dec_acelp_tcx_frame( + Word16 dec_acelp_tcx_frame_fx( Decoder_State* st, /* i/o: decoder state structure */ Word16* concealWholeFrame, /* i/o: concealment flag */ Word16* pcmBuf, /* o : synthesis */ @@ -8164,9 +8168,10 @@ void generate_comfort_noise_dec_hf_ivas_fx( , STEREO_CNG_DEC_HANDLE hStereoCng /* i : stereo CNG handle */ #endif ); +#endif //dec_LPD_fx.c - void decoder_LPD( + void decoder_LPD_fx( Word16 signal_out[], /* o : signal with LPD delay (7 subfrs) */ Word16 signal_outFB[], /* o : synthesis @output_FS */ Word16* total_nbbits, /* i/o: number of bits / decoded bits */ @@ -8181,7 +8186,7 @@ void generate_comfort_noise_dec_hf_ivas_fx( ); //core_dec_switch_fx.c - void mode_switch_decoder_LPD(Decoder_State *st, Word16 bandwidth_in, Word32 bitrate, Word16 frame_size_index + void mode_switch_decoder_LPD_fx(Decoder_State *st, Word16 bandwidth_in, Word32 bitrate, Word16 frame_size_index ); #ifdef IVAS_FLOAT_FIXED @@ -8672,7 +8677,7 @@ Word16 RCcontextMapping_decode2_no_mem_s17_LCS_fx( ); //core_dec_reconf_fx.c -void reconfig_decoder_LPD(Decoder_State *st, Word16 bits_frame, Word16 bandwidth_mode, Word32 bitrate, Word16 L_frame_old); +void reconfig_decoder_LPD_fx(Decoder_State *st, Word16 bits_frame, Word16 bandwidth_mode, Word32 bitrate, Word16 L_frame_old); #ifdef IVAS_FLOAT_FIXED void reconfig_decoder_LPD_ivas_fx( Decoder_State *st, /* i/o: decoder state structure */ @@ -8935,8 +8940,9 @@ void con_acelp( , Word16 *bwe_exc ); +#ifdef IVAS_FLOAT_FIXED //dec_ace_fx.c -void decoder_acelp( +void decoder_acelp_fx( Decoder_State *st, Word16 prm[], /* i : parameters */ Word16 A[], /* i : coefficients NxAz[M+1] */ @@ -8950,6 +8956,7 @@ void decoder_acelp( const Word16 LSF_Q_prediction,/* i : LSF prediction mode */ Word16 *bwe_exc /* out: excitation for SWB TBE */ ); +#endif //d_gain2p.c void decode_acelp_gains( @@ -9090,7 +9097,7 @@ void configureCldfb_ivas_fx( HANDLE_CLDFB_FILTER_BANK h_cldfb, /* i/o: filter bank handle */ const Word32 sampling_rate /* i : sampling rate */ ); - +#ifdef IVAS_FLOAT_FIXED // dec4t64.c void dec_acelp_fast_fx( Decoder_State *st, /* i/o: decoder state structure */ @@ -9098,7 +9105,7 @@ void dec_acelp_fast_fx( Word16 code[], /* o : algebraic (fixed) codebook excitation */ const int16_t L_subfr /* i : subframe length */ ); - +#endif // codec_tcx_common.c void tcx5SpectrumInterleaving_fx( const Word16 tcx5Size, diff --git a/lib_dec/acelp_core_dec_fx.c b/lib_dec/acelp_core_dec_fx.c index 27a72d6a4..8cacdbd5b 100644 --- a/lib_dec/acelp_core_dec_fx.c +++ b/lib_dec/acelp_core_dec_fx.c @@ -11,7 +11,7 @@ #include "ivas_prot_fx.h" #include "ivas_cnst.h" /* Common constants */ #include "cnst.h" /* Common constants */ - +#ifdef IVAS_FLOAT_FIXED /*==========================================================================*/ /* FUNCTION : void acelp_core_dec_fx () */ /*--------------------------------------------------------------------------*/ @@ -1640,7 +1640,7 @@ ivas_error acelp_core_dec_fx( i = CLDFB_NO_COL_MAX; move16(); } - addBassPostFilterFx( bpf_error_signal, realBuffer, imagBuffer, st_fx->cldfbBPF, workBuffer, negate(st_fx->Q_syn), + addBassPostFilter_fx( bpf_error_signal, realBuffer, imagBuffer, st_fx->cldfbBPF, workBuffer, negate(st_fx->Q_syn), i, st_fx->cldfbAna->no_col, st_fx->cldfbAna->no_channels, &scaleFactor ); /* set output mask for upsampling */ @@ -1825,3 +1825,4 @@ ivas_error acelp_core_dec_fx( return IVAS_ERR_OK; } +#endif diff --git a/lib_dec/acelp_core_switch_dec_fx.c b/lib_dec/acelp_core_switch_dec_fx.c index f30644cc0..a52d669fd 100644 --- a/lib_dec/acelp_core_switch_dec_fx.c +++ b/lib_dec/acelp_core_switch_dec_fx.c @@ -9,7 +9,7 @@ #include "prot_fx1.h" /* Function prototypes */ #include "prot_fx2.h" /* Function prototypes */ #include "prot.h" /* Function prototypes */ - +#ifdef IVAS_FLOAT_FIXED /*---------------------------------------------------------------------* * Local function prototypes *---------------------------------------------------------------------*/ @@ -219,7 +219,7 @@ ivas_error acelp_core_switch_dec_fx( i = CLDFB_NO_COL_MAX_SWITCH; move16(); } - addBassPostFilterFx( bpf_error_signal, realBuffer, imagBuffer, st_fx->cldfbBPF, workBuffer, negate(st_fx->Q_syn), + addBassPostFilter_fx( bpf_error_signal, realBuffer, imagBuffer, st_fx->cldfbBPF, workBuffer, negate(st_fx->Q_syn), i, CLDFB_NO_COL_MAX_SWITCH, st_fx->cldfbAna->no_channels, &scaleFactor ); cldfb_restore_memory( st_fx->cldfbBPF ); @@ -989,3 +989,4 @@ static void decod_gen_voic_core_switch_fx( return; } +#endif diff --git a/lib_dec/amr_wb_dec_fx.c b/lib_dec/amr_wb_dec_fx.c index 1018a2cd4..63056a2cb 100644 --- a/lib_dec/amr_wb_dec_fx.c +++ b/lib_dec/amr_wb_dec_fx.c @@ -873,7 +873,7 @@ ivas_error amr_wb_dec_fx( i = CLDFB_NO_COL_MAX; move16(); } - addBassPostFilterFx( bpf_error_signal, realBuffer, imagBuffer, st_fx->cldfbBPF, workBuffer, negate(st_fx->Q_syn), + addBassPostFilter_fx( bpf_error_signal, realBuffer, imagBuffer, st_fx->cldfbBPF, workBuffer, negate(st_fx->Q_syn), i, st_fx->cldfbAna->no_col, st_fx->cldfbAna->no_channels, &scaleFactor ); st_fx->Q_syn2 = st_fx->Q_syn; move16(); diff --git a/lib_dec/bass_psfilter.c b/lib_dec/bass_psfilter.c index 0084c4410..f7c8c7863 100644 --- a/lib_dec/bass_psfilter.c +++ b/lib_dec/bass_psfilter.c @@ -650,14 +650,14 @@ int16_t res_bpf_adapt( #else /*---------------------------------------------------------------------* - * res_bpf_adapt_fx() + * res_bpf_adapt_ivas_fx() * * Analyze BPF output and decide if it should be applied on DFT stereo * residual signal *---------------------------------------------------------------------*/ /*! r: Decision to enable or disable BPF on DFT stereo residual */ -Word16 res_bpf_adapt_fx( +Word16 res_bpf_adapt_ivas_fx( STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: DFT stereo decoder handle */ const Word32 *bpf_error_signal_8k, /* i : BPF modification signal */ Word32 res_buf[STEREO_DFT_N_8k] /* i : residual buffer Q12 */ diff --git a/lib_dec/bass_psfilter_fx.c b/lib_dec/bass_psfilter_fx.c index 645308b07..e843018a8 100644 --- a/lib_dec/bass_psfilter_fx.c +++ b/lib_dec/bass_psfilter_fx.c @@ -882,7 +882,7 @@ static Word16 Pit_track_fx( /* o : Pitch */ * Add BPF component in cldfb domain *---------------------------------------------------------------------*/ -void addBassPostFilterFx ( +void addBassPostFilter_fx( const Word16 *harm_timeIn_Fx, Word32 **rAnalysis_Fx, Word32 **iAnalysis_Fx, diff --git a/lib_dec/cng_dec.c b/lib_dec/cng_dec.c index 3952cf8f1..a6a2e306b 100644 --- a/lib_dec/cng_dec.c +++ b/lib_dec/cng_dec.c @@ -762,12 +762,12 @@ static void shb_CNG_decod( /*-------------------------------------------------------------------* - * td_cng_dec_init_flt() + * td_cng_dec_init() * * *-------------------------------------------------------------------*/ -void td_cng_dec_init_flt( +void td_cng_dec_init( DEC_CORE_HANDLE st /* i/o: decoder state structure */ ) { diff --git a/lib_dec/cng_dec_fx.c b/lib_dec/cng_dec_fx.c index 54d712118..3617fa5d0 100644 --- a/lib_dec/cng_dec_fx.c +++ b/lib_dec/cng_dec_fx.c @@ -1332,12 +1332,12 @@ static void shb_CNG_decod_ivas_fx( #endif /*-------------------------------------------------------------------* - * td_cng_dec_init() + * td_cng_dec_init_fx() * * *-------------------------------------------------------------------*/ -void td_cng_dec_init( +void td_cng_dec_init_fx( DEC_CORE_HANDLE st /* i/o: decoder state structure */ ) { diff --git a/lib_dec/core_dec_init.c b/lib_dec/core_dec_init.c index 3cb24a1b5..4c6e4be3e 100644 --- a/lib_dec/core_dec_init.c +++ b/lib_dec/core_dec_init.c @@ -43,12 +43,12 @@ #include "wmc_auto.h" #include "prot_fx2.h" /*-----------------------------------------------------------------------* - * open_decoder_LPD_flt() + * open_decoder_LPD() * * Initialization of state variables *-----------------------------------------------------------------------*/ -void open_decoder_LPD_flt( +void open_decoder_LPD( Decoder_State *st, /* i/o: decoder state structure */ const int32_t total_brate, /* i : total bitrate */ const int32_t last_total_brate, /* i : last total bitrate */ diff --git a/lib_dec/core_dec_init_fx.c b/lib_dec/core_dec_init_fx.c index 0c271d9c0..dd8502b67 100644 --- a/lib_dec/core_dec_init_fx.c +++ b/lib_dec/core_dec_init_fx.c @@ -14,12 +14,12 @@ #include "cnst.h" /* for MIN_CNG_LEV */ /*-----------------------------------------------------------------------* - * open_decoder_LPD() + * open_decoder_LPD_fx() * * Initialization of state variables *-----------------------------------------------------------------------*/ #ifdef IVAS_FLOAT_FIXED -void open_decoder_LPD( +void open_decoder_LPD_fx( Decoder_State *st, const Word32 total_brate, #ifdef NEW_IVAS_OPEN_DEC diff --git a/lib_dec/core_dec_reconf.c b/lib_dec/core_dec_reconf.c index c8aaad9da..3718a38d8 100644 --- a/lib_dec/core_dec_reconf.c +++ b/lib_dec/core_dec_reconf.c @@ -130,7 +130,7 @@ void reconfig_decoder_LPD_ivas( if ( st->hTcxCfg != NULL && st->fscale != st->fscale_old && !( st->element_mode == EVS_MONO && st->last_codec_mode == MODE1 && st->last_core == ACELP_CORE && st->prev_bfi != 0 ) ) /* no resempling is needed here when recovering from mode 1 ACELP PLC, since the buffers are already sampled with the - correct sampling rate in open_decoder_LPD_flt() */ + correct sampling rate in open_decoder_LPD() */ { newLen = st->hTcxCfg->tcx_mdct_window_length; oldLen = st->hTcxCfg->tcx_mdct_window_length_old; diff --git a/lib_dec/core_dec_reconf_fx.c b/lib_dec/core_dec_reconf_fx.c index f4b09749a..116bd7f23 100644 --- a/lib_dec/core_dec_reconf_fx.c +++ b/lib_dec/core_dec_reconf_fx.c @@ -104,7 +104,7 @@ void reconfig_decoder_LPD_ivas_fx( EQ_16( st->last_core, ACELP_CORE ) && NE_16(st->prev_bfi , 0 ) ) )) /* no resempling is needed here when recovering from mode 1 ACELP PLC, since the buffers are already sampled with the - correct sampling rate in open_decoder_LPD() */ + correct sampling rate in open_decoder_LPD_fx() */ { newLen = st->hTcxCfg->tcx_mdct_window_length; oldLen = st->hTcxCfg->tcx_mdct_window_length_old; @@ -178,7 +178,7 @@ void reconfig_decoder_LPD_ivas_fx( } #endif -void reconfig_decoder_LPD( +void reconfig_decoder_LPD_fx( Decoder_State *st, /* i/o: decoder state structure */ Word16 bits_frame, /* i : bit budget */ Word16 bwidth, /* i : audio bandwidth */ @@ -281,7 +281,7 @@ void reconfig_decoder_LPD( EQ_16(st->last_core, ACELP_CORE) && st->prev_bfi != 0))) /* no resempling is needed here when recovering from mode 1 acelp plc, since the buffers are already sampled with the - correct sampling rate in open_decoder_LPD() */ + correct sampling rate in open_decoder_LPD_fx() */ { newLen = st->hTcxCfg->tcx_mdct_window_length; diff --git a/lib_dec/core_dec_switch.c b/lib_dec/core_dec_switch.c index 5905f1557..9a7cfd3a3 100644 --- a/lib_dec/core_dec_switch.c +++ b/lib_dec/core_dec_switch.c @@ -42,7 +42,7 @@ #include "wmc_auto.h" /*-------------------------------------------------------------* - * mode_switch_decoder_LPD_flt() + * mode_switch_decoder_LPD() * * *-------------------------------------------------------------*/ @@ -65,7 +65,7 @@ void open_decoder_LPD_ivas_fx( Word16* Q_old_Aq_12_8); #endif // IVAS_FLOAT_FIXED #ifndef IVAS_FLOAT_FIXED -void mode_switch_decoder_LPD_flt( +void mode_switch_decoder_LPD( Decoder_State *st, /* i/o: decoder state structure */ const int16_t bwidth, /* i : audio bandwidth */ const int32_t total_brate, /* i : total bitrate */ @@ -126,7 +126,7 @@ void mode_switch_decoder_LPD_flt( #ifdef IVAS_FLOAT_FIXED open_decoder_LPD_ivas_fx(st, total_brate, last_total_brate, bwidth, MCT_flag, last_element_mode, 0, &Q_syn_Overl_TDAC, &Q_fer_samples, &Q_syn_Overl, &Q_syn_Overl_TDACFB, &Q_syn_OverlFB, &Q_old_out, &Q_old_outLB, &Q_old_Aq_12_8); #endif - open_decoder_LPD_flt( st, total_brate, last_total_brate, bwidth, MCT_flag, last_element_mode, 0 ); + open_decoder_LPD( st, total_brate, last_total_brate, bwidth, MCT_flag, last_element_mode, 0 ); } else { diff --git a/lib_dec/core_dec_switch_fx.c b/lib_dec/core_dec_switch_fx.c index a8923e07d..8f7f18de8 100644 --- a/lib_dec/core_dec_switch_fx.c +++ b/lib_dec/core_dec_switch_fx.c @@ -14,7 +14,7 @@ #include "prot.h" -void mode_switch_decoder_LPD( +void mode_switch_decoder_LPD_fx( Decoder_State *st, /* i/o: decoder state structure */ Word16 bwidth, /* i : audio bandwidth */ Word32 total_brate, /* i : total bitrate */ @@ -100,12 +100,12 @@ void mode_switch_decoder_LPD( IF ( NE_16(fscale, st->fscale)||switchWB!=0||bSwitchFromAmrwbIO!=0||EQ_16(st->last_codec_mode,MODE1)||st->force_lpd_reset) { #ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT - open_decoder_LPD(st, total_brate, last_total_brate, bwidth, MCT_flag, last_element_mode, 0); + open_decoder_LPD_fx(st, total_brate, last_total_brate, bwidth, MCT_flag, last_element_mode, 0); #else #ifdef IVAS_CODE - open_decoder_LPD(st, total_brate, last_total_brate, bwidth, is_mct, 0); + open_decoder_LPD_fx(st, total_brate, last_total_brate, bwidth, is_mct, 0); #else - open_decoder_LPD(st, total_brate, bwidth); + open_decoder_LPD_fx(st, total_brate, bwidth); #endif #endif @@ -160,7 +160,7 @@ void mode_switch_decoder_LPD( frame_size = FrameSizeConfig[frame_size_index].frame_net_bits; move16(); - reconfig_decoder_LPD( st, frame_size, bwidth, total_brate, st->last_L_frame ); + reconfig_decoder_LPD_fx( st, frame_size, bwidth, total_brate, st->last_L_frame ); test(); IF (hTcxDec->envWeighted != 0 && hTcxDec->enableTcxLpc == 0) diff --git a/lib_dec/core_switching_dec_fx.c b/lib_dec/core_switching_dec_fx.c index 8105c3918..8b905e509 100644 --- a/lib_dec/core_switching_dec_fx.c +++ b/lib_dec/core_switching_dec_fx.c @@ -143,12 +143,12 @@ void bandwidth_switching_detect_fx( } /*---------------------------------------------------------------------* - * Calc_freq_ener() + * Calc_freq_ener_fx() * * *---------------------------------------------------------------------*/ -static Word32 Calc_freq_ener(Word32 L_tmp, const Word16 Q_syn2) +static Word32 Calc_freq_ener_fx(Word32 L_tmp, const Word16 Q_syn2) { Word32 enerLL_fx; Word16 exp, tmp; @@ -231,7 +231,7 @@ void bw_switching_pre_proc_fx( #endif } L_tmp = L_shr(L_tmp, 7); /*2*(st_fx->Q_syn2-1)*/ - st_fx->enerLL_fx = Calc_freq_ener(L_tmp, shl(st_fx->Q_syn2,1)); + st_fx->enerLL_fx = Calc_freq_ener_fx(L_tmp, shl(st_fx->Q_syn2,1)); L_tmp = L_deposit_l(0); FOR (; iQ_syn2-1)*/ - st_fx->enerLH_fx = Calc_freq_ener(L_tmp, shl(st_fx->Q_syn2,1)); + st_fx->enerLH_fx = Calc_freq_ener_fx(L_tmp, shl(st_fx->Q_syn2,1)); } ELSE { @@ -258,7 +258,7 @@ void bw_switching_pre_proc_fx( #endif } L_tmp = L_shr(L_tmp, 5); /*st_fx->Q_syn2-1*/ - st_fx->enerLL_fx = Calc_freq_ener(L_tmp, shl(st_fx->Q_syn2,1)); + st_fx->enerLL_fx = Calc_freq_ener_fx(L_tmp, shl(st_fx->Q_syn2,1)); L_tmp = L_deposit_l(0); FOR (; i<64; i++ ) { @@ -269,7 +269,7 @@ void bw_switching_pre_proc_fx( #endif } L_tmp = L_shr(L_tmp, 5); /*st_fx->Q_syn2-1*/ - st_fx->enerLH_fx = Calc_freq_ener(L_tmp, shl(st_fx->Q_syn2,1)); + st_fx->enerLH_fx = Calc_freq_ener_fx(L_tmp, shl(st_fx->Q_syn2,1)); } ELSE { @@ -283,7 +283,7 @@ void bw_switching_pre_proc_fx( #endif } L_tmp = L_shr(L_tmp, 7); /*st_fx->Q_syn2-1*/ - st_fx->enerLL_fx = Calc_freq_ener(L_tmp, shl(st_fx->Q_syn2,1)); + st_fx->enerLL_fx = Calc_freq_ener_fx(L_tmp, shl(st_fx->Q_syn2,1)); L_tmp = L_deposit_l(0); FOR (; iQ_syn2-1*/ - st_fx->enerLH_fx = Calc_freq_ener(L_tmp, shl(st_fx->Q_syn2,1)); + st_fx->enerLH_fx = Calc_freq_ener_fx(L_tmp, shl(st_fx->Q_syn2,1)); } } diff --git a/lib_dec/dec4t64.c b/lib_dec/dec4t64.c index 3e6543bfd..be4ab425d 100644 --- a/lib_dec/dec4t64.c +++ b/lib_dec/dec4t64.c @@ -740,7 +740,7 @@ static void fcb_decode_PI( * Read FCB index * *---------------------------------------------------------------------*/ -void D_ACELP_decode_43bit_flt( +void D_ACELP_decode_43bit( uint16_t idxs[], float code[], int16_t *pulsestrack ) diff --git a/lib_dec/dec4t64_fx.c b/lib_dec/dec4t64_fx.c index 85c6b3157..ec9dc300c 100644 --- a/lib_dec/dec4t64_fx.c +++ b/lib_dec/dec4t64_fx.c @@ -8,7 +8,7 @@ #include "prot_fx2.h" /* Function prototypes */ #include "rom_com.h" /* Static table prototypes */ #include "assert.h" /* Static table prototypes */ - +#ifdef IVAS_FLOAT_FIXED /*-------------------------------------------------------------------* * Local functions *-------------------------------------------------------------------*/ @@ -123,7 +123,7 @@ void dec_acelp_4t64_fx( move16(); } - D_ACELP_indexing( code, config, NB_TRACK_FCB_4T, indexing_indices, &st_fx->BER_detect ); + D_ACELP_indexing_fx( code, config, NB_TRACK_FCB_4T, indexing_indices, &st_fx->BER_detect ); } ELSE { @@ -766,7 +766,7 @@ static void fcb_decode_PI_fx( /* o: return pulse position number */ * Read FCB index * *---------------------------------------------------------------------*/ -void D_ACELP_decode_43bit(UWord16 idxs[], Word16 code[], Word16 *pulsestrack) +void D_ACELP_decode_43bit_fx(UWord16 idxs[], Word16 code[], Word16 *pulsestrack) { Word32 ps[8]; Word16 pos[7]; @@ -1260,4 +1260,5 @@ void dec_acelp_fast_fx( } return; -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/lib_dec/dec_LPD.c b/lib_dec/dec_LPD.c index 54f06355d..df050e043 100644 --- a/lib_dec/dec_LPD.c +++ b/lib_dec/dec_LPD.c @@ -48,12 +48,12 @@ /*-------------------------------------------------------------------* - * decoder_LPD_flt() + * decoder_LPD() * * Core decoder MODE2 *--------------------------------------------------------------------*/ #ifndef IVAS_FLOAT_FIXED -void decoder_LPD_flt( +void decoder_LPD( Decoder_State *st, /* i/o: decoder memory state pointer */ float signal_out[], /* o : signal with LPD delay (7 subfrs) */ float signal_outFB[], /* o : synthesis @output_FS */ @@ -506,7 +506,7 @@ void decoder_LPD_flt( } else { - decoder_acelp_flt( st, prm, Aq, st->acelp_cfg, &synth[0], pitch, pit_gain, st->stab_fac, pitch_buf, voice_factors, LSF_Q_prediction, ptr_bwe_exc ); + decoder_acelp( st, prm, Aq, st->acelp_cfg, &synth[0], pitch, pit_gain, st->stab_fac, pitch_buf, voice_factors, LSF_Q_prediction, ptr_bwe_exc ); if ( st->flagGuidedAcelp > 0 ) { diff --git a/lib_dec/dec_LPD_fx.c b/lib_dec/dec_LPD_fx.c index 158d162e1..dd66fb816 100644 --- a/lib_dec/dec_LPD_fx.c +++ b/lib_dec/dec_LPD_fx.c @@ -10,6 +10,7 @@ #include "prot_fx2.h" #include "basop_util.h" #include "rom_com.h" +#ifdef IVAS_FLOAT_FIXED /* #if defined(_WIN32) && (_MSC_VER <= 1200) /\* disable global optimizations to overcome an internal compiler error *\/ */ #if defined(_MSC_VER) && (_MSC_VER <= 1200) /* disable global optimizations to overcome an internal compiler error */ @@ -17,12 +18,12 @@ #endif /*-------------------------------------------------------------------* -* decoder_LPD() +* decoder_LPD_fx() * * Core decoder MODE2 *--------------------------------------------------------------------*/ -void decoder_LPD( +void decoder_LPD_fx( Word16 signal_out[], /* output: signal with LPD delay (7 subfrs) */ Word16 signal_outFB[], /* o : synthesis @output_FS */ Word16 *total_nbbits, /* i/o: number of bits / decoded bits */ @@ -587,7 +588,7 @@ void decoder_LPD( } ELSE { - decoder_acelp(st, prm, Aq, st->acelp_cfg, &synth[0], pitch, pit_gain, st->stab_fac_fx, pitch_buf, voice_factors, LSF_Q_prediction, ptr_bwe_exc); + decoder_acelp_fx(st, prm, Aq, st->acelp_cfg, &synth[0], pitch, pit_gain, st->stab_fac_fx, pitch_buf, voice_factors, LSF_Q_prediction, ptr_bwe_exc); IF(st->flagGuidedAcelp > 0) { @@ -966,5 +967,5 @@ void decoder_LPD( return; } - +#endif diff --git a/lib_dec/dec_ace.c b/lib_dec/dec_ace.c index f6e9f9c32..9a8c91853 100644 --- a/lib_dec/dec_ace.c +++ b/lib_dec/dec_ace.c @@ -42,12 +42,12 @@ #include "wmc_auto.h" #ifndef IVAS_FLOAT_FIXED /*-------------------------------------------------------------------* - * decoder_acelp_flt() + * decoder_acelp() * * Decode ACELP frame MODE2 *-------------------------------------------------------------------*/ -void decoder_acelp_flt( +void decoder_acelp( Decoder_State *st, /* i/o: coder memory state */ int16_t prm[], /* i : parameters */ const float A[], /* i : coefficients NxAz[M+1] */ diff --git a/lib_dec/dec_ace_fx.c b/lib_dec/dec_ace_fx.c index d613763cc..6d79c5cd6 100644 --- a/lib_dec/dec_ace_fx.c +++ b/lib_dec/dec_ace_fx.c @@ -14,12 +14,12 @@ #include "stl.h" #include "rom_com.h" /*-------------------------------------------------------------------* - * decoder_acelp() + * decoder_acelp_fx() * * Decode ACELP frame MODE2 *-------------------------------------------------------------------*/ - -void decoder_acelp( +#ifdef IVAS_FLOAT_FIXED +void decoder_acelp_fx( Decoder_State *st, Word16 prm[], /* i : parameters */ Word16 A[], /* i : coefficients NxAz[M+1] */ @@ -354,7 +354,7 @@ void decoder_acelp( ELSE { config = PulseConfTable[acelp_cfg.fixed_cdk_index[i_subfr/L_SUBFR]]; - D_ACELP_indexing( code, config, NB_TRACK_FCB_4T, prm, &st->BER_detect ); + D_ACELP_indexing_fx( code, config, NB_TRACK_FCB_4T, prm, &st->BER_detect ); (prm) += 8; /*-------------------------------------------------------* * - Add the fixed-gain pitch contribution to code[]. * @@ -684,3 +684,4 @@ void decoder_acelp( return; } +#endif \ No newline at end of file diff --git a/lib_dec/dec_acelp.c b/lib_dec/dec_acelp.c index d9b4d42fd..2a4c44b7d 100644 --- a/lib_dec/dec_acelp.c +++ b/lib_dec/dec_acelp.c @@ -142,7 +142,7 @@ void D_ACELP_indexing_ivas( if ( config.bits == 43 ) { - D_ACELP_decode_43bit_flt( idxs, code, pulsestrack ); + D_ACELP_decode_43bit( idxs, code, pulsestrack ); } else { diff --git a/lib_dec/dec_acelp_fx.c b/lib_dec/dec_acelp_fx.c index 392adb1df..7766a32ca 100644 --- a/lib_dec/dec_acelp_fx.c +++ b/lib_dec/dec_acelp_fx.c @@ -11,20 +11,20 @@ #include "prot_fx2.h" #include "rom_com.h" #include "rom_basop_util.h" - +#ifdef IVAS_FLOAT_FIXED #define _1_CODE 0x200 /*codebook excitation Q9 */ /*---------------------------------------------------------------------* * Local function prototypes *---------------------------------------------------------------------*/ -static void D_ACELP_decode_arithtrack(Word16 v[], Word32 s, Word16 p, Word16 trackstep, Word16 tracklen); +static void D_ACELP_decode_arithtrack_fx(Word16 v[], Word32 s, Word16 p, Word16 trackstep, Word16 tracklen); /*---------------------------------------------------------------------* -* Function D_ACELP_indexing() +* Function D_ACELP_indexing_fx() * *---------------------------------------------------------------------*/ -void D_ACELP_indexing( +void D_ACELP_indexing_fx( Word16 code[], PulseConfig config, Word16 num_tracks, @@ -137,11 +137,11 @@ void D_ACELP_indexing( IF (EQ_16(config.bits, 43)) { - D_ACELP_decode_43bit(idxs, code, pulsestrack); + D_ACELP_decode_43bit_fx(idxs, code, pulsestrack); } ELSE { - fcb_pulse_track_joint_decode(idxs, wordcnt, index_n, pulsestrack, num_tracks); + fcb_pulse_track_joint_decode_fx(idxs, wordcnt, index_n, pulsestrack, num_tracks); FOR (track = num_tracks - 1; track >=1; track--) { pulses = pulsestrack[track]; @@ -153,7 +153,7 @@ void D_ACELP_indexing( * the integer part goes to next track */ s = index_n[track]; /* decode state to actual pulse positions on track */ - D_ACELP_decode_arithtrack(code+track, s, pulses, num_tracks, 16); + D_ACELP_decode_arithtrack_fx(code+track, s, pulses, num_tracks, 16); } ELSE /* track is empty */ { @@ -180,7 +180,7 @@ void D_ACELP_indexing( IF (pulses) { - D_ACELP_decode_arithtrack(code, s, pulses, num_tracks, 16); + D_ACELP_decode_arithtrack_fx(code, s, pulses, num_tracks, 16); } ELSE {/* track is empty */ FOR (k=0; k < 16*num_tracks; k+=num_tracks) @@ -192,7 +192,7 @@ void D_ACELP_indexing( } } -static void D_ACELP_decode_arithtrack(Word16 v[], Word32 s, Word16 p, Word16 trackstep, Word16 tracklen) +static void D_ACELP_decode_arithtrack_fx(Word16 v[], Word32 s, Word16 p, Word16 trackstep, Word16 tracklen) { Word16 k, idx; @@ -238,7 +238,7 @@ static void D_ACELP_decode_arithtrack(Word16 v[], Word32 s, Word16 p, Word16 tra } } -void fcb_pulse_track_joint_decode(UWord16 *idxs, Word16 wordcnt, UWord32 *index_n, Word16 *pulse_num, Word16 track_num) +void fcb_pulse_track_joint_decode_fx(UWord16 *idxs, Word16 wordcnt, UWord32 *index_n, Word16 *pulse_num, Word16 track_num) { Word16 hi_to_low[10] = { 0, 0, 0, 3, 9, 5, 3, 1, 8, 8}; @@ -374,3 +374,4 @@ void fcb_pulse_track_joint_decode(UWord16 *idxs, Word16 wordcnt, UWord32 *index_ return; } +#endif diff --git a/lib_dec/dec_acelp_tcx_main.c b/lib_dec/dec_acelp_tcx_main.c index ce6dc681b..9c3d8074b 100644 --- a/lib_dec/dec_acelp_tcx_main.c +++ b/lib_dec/dec_acelp_tcx_main.c @@ -195,7 +195,7 @@ static void decode_frame_type_flt( st->rate_switching_init = 1; /* Reconf Core */ - mode_switch_decoder_LPD_flt( st, st->bwidth, st->total_brate, st->last_total_brate, frame_size_index, 0, st->element_mode ); + mode_switch_decoder_LPD( st, st->bwidth, st->total_brate, st->last_total_brate, frame_size_index, 0, st->element_mode ); /* Reconf. CLDFB: check if the CLDFB works on the right sample rate */ if ( ( st->cldfbAna->no_channels * st->cldfbAna->no_col ) != st->L_frame ) @@ -275,12 +275,12 @@ static void decode_frame_type_flt( /*-------------------------------------------------------------------* - * dec_acelp_tcx_frame_flt() + * dec_acelp_tcx_frame() * * Main decoding function *--------------------------------------------------------------------*/ -void dec_acelp_tcx_frame_flt( +void dec_acelp_tcx_frame( Decoder_State *st, /* i/o: decoder state structure */ int16_t *concealWholeFrame, /* i/o: concealment flag */ float *output, /* o : synthesis */ @@ -300,7 +300,7 @@ void dec_acelp_tcx_frame_flt( float old_bwe_exc[( PIT16k_MAX + ( L_FRAME16k + 1 ) + L_SUBFR16k ) * 2]; /* excitation buffer */ float *ptr_bwe_exc; /* pointer to BWE excitation signal in the current frame */ - push_wmops( "dec_acelp_tcx_frame_flt" ); + push_wmops( "dec_acelp_tcx_frame" ); start_bit_pos = st->next_bit_pos; if ( st->rf_flag == 1 ) @@ -405,7 +405,7 @@ void dec_acelp_tcx_frame_flt( /* Decode the LPD data */ if ( st->m_decodeMode == DEC_NO_FRAM_LOSS ) { - decoder_LPD_flt( st, output, pcmbufFB, &tmp, bpf_noise_buf, 0, &bitsRead, param, pitch_buf, voice_factors, ptr_bwe_exc ); + decoder_LPD( st, output, pcmbufFB, &tmp, bpf_noise_buf, 0, &bitsRead, param, pitch_buf, voice_factors, ptr_bwe_exc ); if ( !st->rate_switching_init && ( st->last_codec_mode ) == MODE2 && !( st->use_partial_copy && st->rf_frame_type >= RF_TCXFD && st->rf_frame_type <= RF_TCXTD2 ) && st->bfi ) { @@ -416,7 +416,7 @@ void dec_acelp_tcx_frame_flt( } else if ( st->m_decodeMode == DEC_CONCEALMENT_EXT ) { - decoder_LPD_flt( st, output, pcmbufFB, NULL, bpf_noise_buf, 1, /* bfi - st->bfi can be 0 here - MODE2 stays in PLC when DTX appears after a loss */ + decoder_LPD( st, output, pcmbufFB, NULL, bpf_noise_buf, 1, /* bfi - st->bfi can be 0 here - MODE2 stays in PLC when DTX appears after a loss */ &bitsRead, NULL, pitch_buf, voice_factors, ptr_bwe_exc ); } diff --git a/lib_dec/dec_acelp_tcx_main_fx.c b/lib_dec/dec_acelp_tcx_main_fx.c index 80176e309..9e6ec1898 100644 --- a/lib_dec/dec_acelp_tcx_main_fx.c +++ b/lib_dec/dec_acelp_tcx_main_fx.c @@ -11,9 +11,9 @@ #include "prot_fx1.h" #include "prot_fx2.h" #include "basop_util.h" - +#ifdef IVAS_FLOAT_FIXED static -void decode_frame_type(Decoder_State *st +void decode_frame_type_fx(Decoder_State *st #ifdef IVAS_CODE_CNG , STEREO_CNG_DEC_HANDLE hStereoCng #endif @@ -205,9 +205,9 @@ void decode_frame_type(Decoder_State *st /* Reconf Core */ #ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT - mode_switch_decoder_LPD(st, st->bwidth, st->total_brate, st->last_total_brate, frame_size_index, 0, st->element_mode); + mode_switch_decoder_LPD_fx(st, st->bwidth, st->total_brate, st->last_total_brate, frame_size_index, 0, st->element_mode); #else - mode_switch_decoder_LPD( st, st->bwidth, st->total_brate, frame_size_index ); + mode_switch_decoder_LPD_fx( st, st->bwidth, st->total_brate, frame_size_index ); #endif /* Reconf CLDFB */ IF( NE_16 (i_mult(st->cldfbAna->no_channels,st->cldfbAna->no_col), st->L_frame) ) @@ -287,7 +287,7 @@ void decode_frame_type(Decoder_State *st } -Word16 dec_acelp_tcx_frame( +Word16 dec_acelp_tcx_frame_fx( Decoder_State *st, /* i/o: decoder state structure */ Word16* concealWholeFrame, /* i/o: concealment flag */ Word16* pcmBuf, /* o : synthesis */ @@ -345,7 +345,7 @@ Word16 dec_acelp_tcx_frame( Word16 L_frame = st->L_frame; Word32 total_brate = st->last_total_brate; - decode_frame_type( st + decode_frame_type_fx( st #ifdef IVAS_CODE_CNG , hStereoCng #endif @@ -435,7 +435,7 @@ Word16 dec_acelp_tcx_frame( IF ( EQ_16(st->m_decodeMode, DEC_NO_FRAM_LOSS)) { - decoder_LPD(pcmBuf, pcmbufFB, &tmp, st, bpf_noise_buf, 0, &bitsRead, param, pitch_buf, voice_factors, ptr_bwe_exc ); + decoder_LPD_fx(pcmBuf, pcmbufFB, &tmp, st, bpf_noise_buf, 0, &bitsRead, param, pitch_buf, voice_factors, ptr_bwe_exc ); test(); test(); @@ -456,7 +456,7 @@ Word16 dec_acelp_tcx_frame( ELSE IF (EQ_16(st->m_decodeMode, DEC_CONCEALMENT_EXT)) { /* Decode the LPD data */ - decoder_LPD( pcmBuf, pcmbufFB, NULL, st, bpf_noise_buf, 1, &bitsRead, NULL, pitch_buf, voice_factors, ptr_bwe_exc ); + decoder_LPD_fx( pcmBuf, pcmbufFB, NULL, st, bpf_noise_buf, 1, &bitsRead, NULL, pitch_buf, voice_factors, ptr_bwe_exc ); } test(); @@ -528,3 +528,4 @@ Word16 dec_acelp_tcx_frame( return 0; } +#endif diff --git a/lib_dec/dec_amr_wb_fx.c b/lib_dec/dec_amr_wb_fx.c index 1d609cd6a..dfa79cae1 100644 --- a/lib_dec/dec_amr_wb_fx.c +++ b/lib_dec/dec_amr_wb_fx.c @@ -8,10 +8,10 @@ #include "rom_com.h" /* Static table prototypes */ #include "prot_fx1.h" /* Function prototypes */ #include "prot_fx2.h" /* Function prototypes */ - +#ifdef IVAS_FLOAT_FIXED /*---------------------------------------------------------------------* - * decod_amr_wb() + * decod_amr_wb_fx() * * Decode excitation signal in AMR-WB IO mode *---------------------------------------------------------------------*/ @@ -153,3 +153,4 @@ void decod_amr_wb_fx( return; } +#endif diff --git a/lib_dec/dec_gen_voic_fx.c b/lib_dec/dec_gen_voic_fx.c index f27403cdb..fe1600050 100644 --- a/lib_dec/dec_gen_voic_fx.c +++ b/lib_dec/dec_gen_voic_fx.c @@ -10,7 +10,7 @@ #include "prot_fx2.h" /* Function prototypes */ #include "stl.h" #include "basop_util.h" - +#ifdef IVAS_FLOAT_FIXED /*======================================================================*/ /* FUNCTION : decod_gen_voic_fx() */ @@ -964,3 +964,4 @@ ivas_error decod_gen_voic_ivas_fx( return error; } +#endif \ No newline at end of file diff --git a/lib_dec/dec_higher_acelp.c b/lib_dec/dec_higher_acelp.c index 03f4deff9..304884e71 100644 --- a/lib_dec/dec_higher_acelp.c +++ b/lib_dec/dec_higher_acelp.c @@ -140,11 +140,7 @@ void transf_cdbk_dec( * Encode and multiplex subvectors into bitstream *--------------------------------------------------------------*/ -#ifdef IVAS_FLOAT_FIXED - AVQ_demuxdec_fx( st, x_norm, &nBits, Nsv, nq, avq_bit_sFlag, trgtSvPos ); -#else AVQ_demuxdec( st, x_norm, &nBits, Nsv, nq, avq_bit_sFlag, trgtSvPos ); -#endif // IVAS_FLOAT_FIXED /* save # of AVQ unused bits for next subframe */ *unbits = nBits; diff --git a/lib_dec/dec_nelp_fx.c b/lib_dec/dec_nelp_fx.c index 7df109adc..6ab48efb4 100644 --- a/lib_dec/dec_nelp_fx.c +++ b/lib_dec/dec_nelp_fx.c @@ -6,7 +6,7 @@ #include "cnst.h" /* Common constants */ #include "prot_fx1.h" /* Function prototypes */ #include "prot_fx2.h" /* Function prototypes */ - +#ifdef IVAS_FLOAT_FIXED /*======================================================================*/ /* FUNCTION : decod_nelp_fx() */ /*-----------------------------------------------------------------------*/ @@ -101,3 +101,4 @@ void decod_nelp_fx( } return; } +#endif \ No newline at end of file diff --git a/lib_dec/dec_pit_exc_fx.c b/lib_dec/dec_pit_exc_fx.c index 42940687d..05eef0de0 100644 --- a/lib_dec/dec_pit_exc_fx.c +++ b/lib_dec/dec_pit_exc_fx.c @@ -7,7 +7,7 @@ #include "rom_com.h" /* Static table prototypes */ #include "prot_fx1.h" /* Function prototypes */ #include "prot_fx2.h" /* Function prototypes */ - +#ifdef IVAS_FLOAT_FIXED /*==========================================================================*/ /* FUNCTION : void dec_pit_exc_fx() */ @@ -807,4 +807,5 @@ void dec_pit_exc_ivas_fx( } return; -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/lib_dec/evs_dec.c b/lib_dec/evs_dec.c index 6afa86c00..15276b8a8 100644 --- a/lib_dec/evs_dec.c +++ b/lib_dec/evs_dec.c @@ -518,7 +518,7 @@ ivas_error evs_dec_flt( * Decode core * -------------------------------------------------------------- */ - dec_acelp_tcx_frame_flt( st, &concealWholeFrame, output, st->p_bpf_noise_buf_float, pcmbufFB, bwe_exc_extended, voice_factors, pitch_buf, NULL ); + dec_acelp_tcx_frame( st, &concealWholeFrame, output, st->p_bpf_noise_buf_float, pcmbufFB, bwe_exc_extended, voice_factors, pitch_buf, NULL ); concealWholeFrameTmp = concealWholeFrame; if ( st->bfi ) diff --git a/lib_dec/evs_dec_fx.c b/lib_dec/evs_dec_fx.c index 68e486d6b..39a396892 100644 --- a/lib_dec/evs_dec_fx.c +++ b/lib_dec/evs_dec_fx.c @@ -10,7 +10,7 @@ #include "prot_fx2.h" /* Function prototypes */ #include "basop_util.h" /* Function prototypes */ - +#ifdef IVAS_FLOAT_FIXED /*--------------------------------------------------------------------------* * evs_dec_fx() * @@ -810,7 +810,7 @@ ivas_error evs_dec_fx( /* DECODE CORE */ /* -------------------------------------------------------------- */ - dec_acelp_tcx_frame(st_fx, &concealWholeFrame, output_sp, + dec_acelp_tcx_frame_fx(st_fx, &concealWholeFrame, output_sp, st_fx->p_bpf_noise_buf, pcmbufFB, bwe_exc_extended_fx, voice_factors_fx, pitch_buf_fx); concealWholeFrameTmp = concealWholeFrame; @@ -1126,7 +1126,7 @@ ivas_error evs_dec_fx( move16(); } - addBassPostFilterFx( st_fx->p_bpf_noise_buf, realBuffer, imagBuffer, st_fx->cldfbBPF, workBuffer, + addBassPostFilter_fx( st_fx->p_bpf_noise_buf, realBuffer, imagBuffer, st_fx->cldfbBPF, workBuffer, timeInBpf_e, CLDFB_NO_COL_MAX, st_fx->cldfbAna->no_col, st_fx->cldfbAna->no_channels, &st_fx->scaleFactor ); IF( NE_16(st_fx->m_frame_type,ACTIVE_FRAME)) @@ -1494,3 +1494,4 @@ ivas_error evs_dec_fx( return IVAS_ERR_OK; } +#endif diff --git a/lib_dec/gs_dec_fx.c b/lib_dec/gs_dec_fx.c index a0a3c8fbe..430b1653e 100644 --- a/lib_dec/gs_dec_fx.c +++ b/lib_dec/gs_dec_fx.c @@ -10,7 +10,7 @@ #include "prot_fx1.h" #include "prot_fx2.h" #include "ivas_cnst.h" - +#ifdef IVAS_FLOAT_FIXED /*=========================================================================*/ /* FUNCTION : void decod_audio_fx(); */ /*-------------------------------------------------------------------------*/ @@ -1314,7 +1314,6 @@ void gsc_dec_fx( } -#ifdef IVAS_FLOAT_FIXED /*==========================================================================*/ /* FUNCTION : void gsc_dec_ivas_fx () */ /*--------------------------------------------------------------------------*/ @@ -1644,7 +1643,6 @@ void gsc_dec_ivas_fx( return; } -#endif /*-------------------------------------------------------------------* * GSC_dec_init() @@ -1686,7 +1684,6 @@ void GSC_dec_init( return; } -#ifdef IVAS_FLOAT_FIXED void GSC_dec_init_ivas_fx( GSC_DEC_HANDLE hGSCDec /* i/o: GSC data handle */ ) @@ -1713,4 +1710,4 @@ void GSC_dec_init_ivas_fx( return; } -#endif +#endif \ No newline at end of file diff --git a/lib_dec/init_dec.c b/lib_dec/init_dec.c index 4a171d0af..b753b84d5 100644 --- a/lib_dec/init_dec.c +++ b/lib_dec/init_dec.c @@ -344,7 +344,7 @@ ivas_error init_decoder( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DTX/TD CNG\n" ) ); } - td_cng_dec_init_flt( st ); + td_cng_dec_init( st ); } else { @@ -737,7 +737,7 @@ ivas_error init_decoder( } /* Init Core Decoder */ - open_decoder_LPD_flt( st, st->total_brate, st->last_total_brate, st->bwidth, 0, st->element_mode, 1 ); + open_decoder_LPD( st, st->total_brate, st->last_total_brate, st->bwidth, 0, st->element_mode, 1 ); /* PLC mode initialization */ st->m_decodeMode = DEC_NO_FRAM_LOSS; diff --git a/lib_dec/init_dec_fx.c b/lib_dec/init_dec_fx.c index a33df105d..6d567deb9 100644 --- a/lib_dec/init_dec_fx.c +++ b/lib_dec/init_dec_fx.c @@ -347,7 +347,7 @@ ivas_error init_decoder_fx( return (IVAS_ERROR(IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DTX/TD CNG\n")); } - td_cng_dec_init(st_fx); + td_cng_dec_init_fx(st_fx); } ELSE { @@ -740,7 +740,7 @@ ivas_error init_decoder_fx( move16(); /* Init Decoder */ - open_decoder_LPD( st_fx, st_fx->total_brate, st_fx->bwidth); + open_decoder_LPD_fx( st_fx, st_fx->total_brate, st_fx->bwidth); st_fx->m_decodeMode = DEC_NO_FRAM_LOSS; move16(); @@ -1335,7 +1335,7 @@ ivas_error init_decoder_ivas_fx( #ifdef IVAS_FLOAT_FIXED td_cng_dec_init_ivas_fx( st_fx ); #else - td_cng_dec_init_flt( st_fx ); + td_cng_dec_init( st_fx ); #endif // IVAS_FLOAT_FIXED } ELSE @@ -1890,7 +1890,7 @@ ivas_error init_decoder_ivas_fx( open_decoder_LPD_ivas_fx(st_fx, st_fx->total_brate, st_fx->last_total_brate, st_fx->bwidth, 0, st_fx->element_mode, 1, &Q_syn_Overl_TDAC, &Q_fer_samples, &Q_syn_Overl, &Q_syn_Overl_TDACFB, &Q_syn_OverlFB, &Q_old_out, &Q_old_outLB, &Q_old_Aq_12_8); #ifdef IVAS_FLOAT_FIXED_TO_BE_REMOVED // To be removed when fixed version is available. - open_decoder_LPD_flt(st_fx, st_fx->total_brate, st_fx->last_total_brate, st_fx->bwidth, 0, st_fx->element_mode, 1); + open_decoder_LPD(st_fx, st_fx->total_brate, st_fx->last_total_brate, st_fx->bwidth, 0, st_fx->element_mode, 1); #endif /* PLC mode initialization */ diff --git a/lib_dec/inov_dec.c b/lib_dec/inov_dec.c index c9fc260cb..482d867d9 100644 --- a/lib_dec/inov_dec.c +++ b/lib_dec/inov_dec.c @@ -97,17 +97,7 @@ void inov_decode( } else { -#ifdef IVAS_FLOAT_FIXED - Word16 code_fx[256] = { 0 }; - dec_acelp_fast_fx( st, nBits, code_fx, L_subfr ); - FOR( Word16 lp = 0; lp < L_subfr; lp++ ) - { - code[lp] = (float) code_fx[lp] / 512; - } - -#else dec_acelp_fast( st, nBits, code, L_subfr ); -#endif } } else if ( ( st->idchan == 1 && st->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR] <= 7 ) || ( st->idchan == 0 && st->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR] <= 3 ) ) @@ -118,16 +108,7 @@ void inov_decode( } else { -#ifdef IVAS_FLOAT_FIXED - Word16 code_fx[L_SUBFR] = { 0 }; - dec_acelp_fast_fx( st, st->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR], code_fx, L_SUBFR ); - FOR( Word16 lp = 0; lp < L_SUBFR; lp++ ) - { - code[lp] = (float) code_fx[lp] / 512; - } -#else dec_acelp_fast( st, st->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR], code, L_SUBFR ); -#endif } } else diff --git a/lib_dec/inov_dec_fx.c b/lib_dec/inov_dec_fx.c index 23276389e..53aab75bc 100644 --- a/lib_dec/inov_dec_fx.c +++ b/lib_dec/inov_dec_fx.c @@ -8,7 +8,7 @@ #include "prot_fx1.h" /* Function prototypes */ #include "prot_fx2.h" /* Function prototypes */ #include "rom_com.h" /* Static table prototypes */ - +#ifdef IVAS_FLOAT_FIXED /*======================================================================*/ /* FUNCTION : inov_decode_fx() */ /*-----------------------------------------------------------------------*/ @@ -119,7 +119,7 @@ void inov_decode_fx( indexing_indices[i] = get_next_indice(st_fx, bitcnt); } config = PulseConfTable[st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR]]; - D_ACELP_indexing(code, config, NB_TRACK_FCB_4T, indexing_indices, &st_fx->BER_detect); + D_ACELP_indexing_fx(code, config, NB_TRACK_FCB_4T, indexing_indices, &st_fx->BER_detect); } } else @@ -298,7 +298,7 @@ void inov_decode_ivas_fx( indexing_indices[i] = get_next_indice( st_fx, bitcnt ); } config = PulseConfTable[st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR]]; - D_ACELP_indexing( code, config, NB_TRACK_FCB_4T, indexing_indices, &st_fx->BER_detect ); + D_ACELP_indexing_fx( code, config, NB_TRACK_FCB_4T, indexing_indices, &st_fx->BER_detect ); } } ELSE @@ -364,4 +364,5 @@ void inov_decode_ivas_fx( cb_shape_fx( 1, 1, 0, sharpFlag, 0, g1, g2, p_Aq, code, tilt_code, shr( add( pt_pitch, 26 ), 6 ), 0, L_subfr ); return; } +#endif #endif \ No newline at end of file diff --git a/lib_dec/ivas_binRenderer_internal.c b/lib_dec/ivas_binRenderer_internal.c index 809bc7ad4..b2f057faf 100644 --- a/lib_dec/ivas_binRenderer_internal.c +++ b/lib_dec/ivas_binRenderer_internal.c @@ -1330,8 +1330,8 @@ static void ivas_binaural_obtain_DMX_fx( //outRealRightPtr[bandIdx] += inRealPtr[bandIdx] * ( 1.f - foa_const ); //outImagRightPtr[bandIdx] += inImagPtr[bandIdx] * ( 1.f - foa_const ); - outRealRightPtr_fx[bandIdx] += L_add( outRealRightPtr_fx[bandIdx], Mpy_32_32( inRealPtr_fx[bandIdx], L_sub( ONE_IN_Q30, foa_const_fx ) ) ); //Q_in - 1 - outImagRightPtr_fx[bandIdx] += L_add( outImagRightPtr_fx[bandIdx], Mpy_32_32( inImagPtr_fx[bandIdx], L_sub( ONE_IN_Q30, foa_const_fx ) ) ); //Q_in - 1 + outRealRightPtr_fx[bandIdx] = L_add( outRealRightPtr_fx[bandIdx], Mpy_32_32( inRealPtr_fx[bandIdx], L_sub( ONE_IN_Q30, foa_const_fx ) ) ); //Q_in - 1 + outImagRightPtr_fx[bandIdx] = L_add( outImagRightPtr_fx[bandIdx], Mpy_32_32( inImagPtr_fx[bandIdx], L_sub( ONE_IN_Q30, foa_const_fx ) ) ); //Q_in - 1 } } } diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index 344465320..06f6ae2a6 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -5324,7 +5324,11 @@ void ivas_dirac_dec_render_sf( if ( st_ivas->hCombinedOrientationData && st_ivas->hCombinedOrientationData->enableCombinedOrientation[0] ) { - ivas_jbm_dec_get_adapted_linear_interpolator( n_samples_to_render, n_samples_to_render, st_ivas->hIsmRendererData->interpolator ); +#ifdef IVAS_FLOAT_FIXED + ivas_jbm_dec_get_adapted_linear_interpolator_fx( n_samples_to_render, n_samples_to_render, st_ivas->hIsmRendererData->interpolator_fx ); +#else + ivas_jbm_dec_get_adapted_linear_interpolator( n_samples_to_render, n_samples_to_render, st_ivas->hIsmRendererData->interpolator_fx ); +#endif interp_offset = 0; } @@ -5333,7 +5337,24 @@ void ivas_dirac_dec_render_sf( /* Combined rotation: rotate the object positions depending the head and external orientations */ if ( st_ivas->hCombinedOrientationData != NULL && st_ivas->hCombinedOrientationData->enableCombinedOrientation[0] == 1 ) { +#ifdef IVAS_FLOAT_FIXED + ////////// flt2fix (to be removed) + for ( Word16 col = 0; col < 3; col++ ) + { + for (Word16 row = 0; row < 3; row++ ) + { + st_ivas->hCombinedOrientationData->Rmat_fx[0][col][row] = floatToFixed( st_ivas->hCombinedOrientationData->Rmat[0][col][row], Q30 ); + } + } + Word32 azi_32, ele_32; + ////////// flt2fix end + rotateAziEle_fixed( (Word16) L_shr(st_ivas->hIsmMetaData[i]->azimuth_fx, 22), (Word16) L_shr(st_ivas->hIsmMetaData[i]->elevation_fx, 22), &azi_32, &ele_32, st_ivas->hCombinedOrientationData->Rmat_fx[0], st_ivas->hIntSetup.is_planar_setup ); + // downscaling to Q0 angles + az1 = (Word16) L_shr(azi_32, 22); + el1 = (Word16) L_shr(ele_32, 22); +#else rotateAziEle( st_ivas->hIsmMetaData[i]->azimuth, st_ivas->hIsmMetaData[i]->elevation, &az1, &el1, st_ivas->hCombinedOrientationData->Rmat[0], st_ivas->hIntSetup.is_planar_setup ); +#endif if ( st_ivas->hEFAPdata != NULL ) { #ifdef IVAS_FLOAT_FIXED diff --git a/lib_dec/ivas_dirac_output_synthesis_cov.c b/lib_dec/ivas_dirac_output_synthesis_cov.c index d86071d93..216d41651 100644 --- a/lib_dec/ivas_dirac_output_synthesis_cov.c +++ b/lib_dec/ivas_dirac_output_synthesis_cov.c @@ -54,6 +54,8 @@ #include "ivas_prot_fx.h" #endif +#define IVAS_FLOAT_FIXED_TO_BE_REMOVED + /*-------------------------------------------------------------------* * ivas_dirac_dec_output_synthesis_cov_open() @@ -144,6 +146,39 @@ ivas_error ivas_dirac_dec_output_synthesis_cov_open_fx( h_dirac_output_synthesis_state->mixing_matrix_res_fx[idx] = NULL; } + if ((h_dirac_output_synthesis_state->cx_old_e = (Word16 *)malloc(CLDFB_NO_CHANNELS_MAX * sizeof(Word16))) == 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_e = (Word16 *)malloc(CLDFB_NO_CHANNELS_MAX * sizeof(Word16))) == 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_e = (Word16 *)malloc(CLDFB_NO_CHANNELS_MAX * sizeof(Word16))) == 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_e = (Word16 *)malloc(CLDFB_NO_CHANNELS_MAX * sizeof(Word16))) == 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_res_old_e = (Word16 *)malloc(CLDFB_NO_CHANNELS_MAX * sizeof(Word16))) == 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_res_e = (Word16 *)malloc(CLDFB_NO_CHANNELS_MAX * sizeof(Word16))) == NULL) + { + return (IVAS_ERROR(IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis covariance\n")); + } + + set16_fx(h_dirac_output_synthesis_state->cx_old_e, 0, CLDFB_NO_CHANNELS_MAX); + set16_fx(h_dirac_output_synthesis_state->cy_old_e, 0, CLDFB_NO_CHANNELS_MAX); + set16_fx(h_dirac_output_synthesis_state->mixing_matrix_old_e, 0, CLDFB_NO_CHANNELS_MAX); + + set16_fx(h_dirac_output_synthesis_state->mixing_matrix_e, 0, CLDFB_NO_CHANNELS_MAX); + set16_fx(h_dirac_output_synthesis_state->mixing_matrix_res_old_e, 0, CLDFB_NO_CHANNELS_MAX); + set16_fx(h_dirac_output_synthesis_state->mixing_matrix_res_e, 0, CLDFB_NO_CHANNELS_MAX); + /*-----------------------------------------------------------------* * prepare processing parameters *-----------------------------------------------------------------*/ @@ -524,6 +559,38 @@ void ivas_dirac_dec_output_synthesis_cov_close( h_dirac_output_synthesis_params->proto_matrix_fx = NULL; } + + IF(h_dirac_output_synthesis_state->cx_old_e != NULL) + { + free(h_dirac_output_synthesis_state->cx_old_e); + h_dirac_output_synthesis_state->cx_old_e = NULL; + } + IF(h_dirac_output_synthesis_state->cy_old_e != NULL) + { + free(h_dirac_output_synthesis_state->cy_old_e); + h_dirac_output_synthesis_state->cy_old_e = NULL; + } + IF(h_dirac_output_synthesis_state->mixing_matrix_old_e != NULL) + { + free(h_dirac_output_synthesis_state->mixing_matrix_old_e); + h_dirac_output_synthesis_state->mixing_matrix_old_e = NULL; + } + IF(h_dirac_output_synthesis_state->mixing_matrix_e != NULL) + { + free(h_dirac_output_synthesis_state->mixing_matrix_e); + h_dirac_output_synthesis_state->mixing_matrix_e = NULL; + } + IF(h_dirac_output_synthesis_state->mixing_matrix_res_old_e != NULL) + { + free(h_dirac_output_synthesis_state->mixing_matrix_res_old_e); + h_dirac_output_synthesis_state->mixing_matrix_res_old_e = NULL; + } + IF(h_dirac_output_synthesis_state->mixing_matrix_res_e != NULL) + { + free(h_dirac_output_synthesis_state->mixing_matrix_res_e); + h_dirac_output_synthesis_state->mixing_matrix_res_e = NULL; + } + /* free cov buffers */ FOR ( idx = 0; idx < CLDFB_NO_CHANNELS_MAX; idx++ ) { @@ -1099,21 +1166,7 @@ int16_t computeMixingMatrices( float mat_mult_buffer1[MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS]; float mat_mult_buffer2[MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS]; float mat_mult_buffer3[MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS]; -#ifdef IVAS_FLOAT_FIXED - Word32 svd_in_buffer_fx[MAX_OUTPUT_CHANNELS][MAX_OUTPUT_CHANNELS]; - Word32 mat_mult_buffer1_fx[MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS]; - Word32 mat_mult_buffer2_fx[MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS]; - Word32 Cx_fx[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; - Word32 Cy_fx[MAX_CICP_CHANNELS * MAX_CICP_CHANNELS]; - Word32 svd_u_buffer_fx[MAX_OUTPUT_CHANNELS][MAX_OUTPUT_CHANNELS]; - Word32 svd_v_buffer_fx[MAX_OUTPUT_CHANNELS][MAX_OUTPUT_CHANNELS]; - Word16 mat_mult_buffer1_fx_e; - Word16 Cx_fx_e; - Word16 Cy_fx_e; - Word16 svd_u_buffer_fx_e[MAX_OUTPUT_CHANNELS]; - Word16 svd_v_buffer_fx_e[MAX_OUTPUT_CHANNELS]; -#endif push_wmops( "dirac_cov_mix_mat" ); set_zero( svd_s_buffer, MAX_OUTPUT_CHANNELS ); @@ -1129,16 +1182,9 @@ int16_t computeMixingMatrices( *-----------------------------------------------------------------*/ /* Processing the SVD */ -#ifdef IVAS_FLOAT_FIXED - f2me_buf( Cy, Cy_fx, &Cy_fx_e, lengthCy * lengthCy ); - mat2svdMat_fx( Cy_fx, svd_in_buffer_fx, lengthCy, lengthCy, 0 ); - FOR ( Word32 g = 0; g < lengthCy; g++ ) - { - me2f_buf( ( svd_in_buffer_fx[g] ), Cy_fx_e, ( svd_in_buffer[g] ), lengthCy ); - } -#else + mat2svdMat( Cy, svd_in_buffer, lengthCy, lengthCy, 0 ); -#endif + svd( svd_in_buffer, svd_u_buffer, svd_s_buffer, svd_v_buffer, lengthCy, lengthCy ); /* Computing Ky */ @@ -1156,16 +1202,7 @@ int16_t computeMixingMatrices( /* Processing the SVD */ -#ifdef IVAS_FLOAT_FIXED - f2me_buf( Cx, Cx_fx, &Cx_fx_e, lengthCx * lengthCx ); - mat2svdMat_fx( Cx_fx, svd_in_buffer_fx, lengthCx, lengthCx, 0 ); - FOR ( Word32 g = 0; g < lengthCx; g++ ) - { - me2f_buf( ( svd_in_buffer_fx[g] ), Cx_fx_e, ( svd_in_buffer[g] ), lengthCx ); - } -#else mat2svdMat( Cx, svd_in_buffer, lengthCx, lengthCx, 0 ); -#endif svd( svd_in_buffer, svd_u_buffer, svd_s_buffer, svd_v_buffer, lengthCx, lengthCx ); @@ -1219,43 +1256,7 @@ int16_t computeMixingMatrices( /* Computing Q*Cx*Q' */ matrix_product( Q, lengthCy, lengthCx, 0, Cx, lengthCx, lengthCx, 0, Q_Cx ); -#ifdef IVAS_FLOAT_FIXED - Word32 Q_Cx_fx[MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS]; - Word32 Q_fx[PARAM_MC_MAX_TRANSPORT_CHANS * MAX_CICP_CHANNELS]; - Word32 Cy_hat_diag_fx[MAX_OUTPUT_CHANNELS]; - Word16 Q_Cx_e, Q_e, Cy_hat_diag_e; - Word16 guard_bits = find_guarded_bits_fx( lengthCx + 1 ); - - f2me_buf( Q_Cx, Q_Cx_fx, &Q_Cx_e, lengthCy * lengthCx ); - f2me_buf( Q, Q_fx, &Q_e, lengthCy * lengthCx ); - - for ( i = 0; i < lengthCy * lengthCx; ++i ) - { - if ( Q_Cx_e > Q_e ) - { - Q_fx[i] = L_shr( Q_fx[i], guard_bits ); - } - else - { - Q_Cx_fx[i] = L_shr( Q_Cx_fx[i], guard_bits ); - } - } - - if ( Q_Cx_e > Q_e ) - { - Q_e += guard_bits; - } - else - { - Q_Cx_e += guard_bits; - } - - matrix_product_diag_fx( Q_Cx_fx, Q_Cx_e, lengthCy, lengthCx, 0, Q_fx, Q_e, lengthCy, lengthCx, 1, Cy_hat_diag_fx, &Cy_hat_diag_e ); - - me2f_buf( Cy_hat_diag_fx, Cy_hat_diag_e, Cy_hat_diag, lengthCy ); -#else matrix_product_diag( Q_Cx, lengthCy, lengthCx, 0, Q, lengthCy, lengthCx, 1, Cy_hat_diag ); -#endif /* Computing Cy_hat_diag */ for ( i = 0; i < lengthCy; ++i ) @@ -1285,34 +1286,14 @@ int16_t computeMixingMatrices( /* Computing the input matrix Kx'*Q'*G_hat'*Ky */ matrix_product( Kx, lengthCx, lengthCx, 1, Q, lengthCy, lengthCx, 1, mat_mult_buffer1 ); -#ifdef IVAS_FLOAT_FIXED - Word32 G_hat_fx[MAX_OUTPUT_CHANNELS]; - Word16 mat_mult_buffer1_e, mat_mult_buffer2_e, G_hat_e; - - f2me_buf( mat_mult_buffer1, mat_mult_buffer1_fx, &mat_mult_buffer1_e, lengthCx * lengthCy); - f2me_buf( G_hat, G_hat_fx, &G_hat_e, lengthCy); - - matrix_diag_product_fx( mat_mult_buffer1_fx, mat_mult_buffer1_e, lengthCx, lengthCy, 0, G_hat_fx, G_hat_e, lengthCy, mat_mult_buffer2_fx, &mat_mult_buffer2_e ); - me2f_buf( mat_mult_buffer2_fx, mat_mult_buffer2_e, mat_mult_buffer2, lengthCx * lengthCy); -#else matrix_diag_product( mat_mult_buffer1, lengthCx, lengthCy, 0, G_hat, lengthCy, mat_mult_buffer2 ); -#endif + matrix_product( mat_mult_buffer2, lengthCx, lengthCy, 0, Ky, lengthCy, lengthCy, 0, mat_mult_buffer1 ); if ( lengthCx < lengthCy ) { -#ifdef IVAS_FLOAT_FIXED - f2me_buf( mat_mult_buffer1, mat_mult_buffer1_fx, &mat_mult_buffer1_fx_e, lengthCx * lengthCy ); - mat2svdMat_fx( mat_mult_buffer1_fx, svd_in_buffer_fx, lengthCx, lengthCy, 1 ); - FOR ( Word32 g = 0; g < lengthCy; g++ ) - { - me2f_buf( ( svd_in_buffer_fx[g] ), mat_mult_buffer1_fx_e, ( svd_in_buffer[g] ), lengthCx ); - } -#else mat2svdMat( mat_mult_buffer1, svd_in_buffer, lengthCx, lengthCy, 1 ); -#endif - nL = lengthCy; nC = lengthCx; @@ -1320,18 +1301,8 @@ int16_t computeMixingMatrices( } else { -#ifdef IVAS_FLOAT_FIXED - f2me_buf( mat_mult_buffer1, mat_mult_buffer1_fx, &mat_mult_buffer1_fx_e, lengthCx * lengthCy ); - mat2svdMat_fx( mat_mult_buffer1_fx, svd_in_buffer_fx, lengthCx, lengthCy, 0 ); - FOR ( Word32 g = 0; g < lengthCx; g++ ) - { - me2f_buf( ( svd_in_buffer_fx[g] ), mat_mult_buffer1_fx_e, ( svd_in_buffer[g] ), lengthCy ); - } -#else - mat2svdMat( mat_mult_buffer1, svd_in_buffer, lengthCx, lengthCy, 0 ); -#endif - + mat2svdMat( mat_mult_buffer1, svd_in_buffer, lengthCx, lengthCy, 0 ); nL = lengthCx; nC = lengthCy; @@ -1343,53 +1314,9 @@ int16_t computeMixingMatrices( /* can be skipped: lambda is always column-truncated identity matrix, so this operation just truncates V to num_input_channel columns */ -#ifdef IVAS_FLOAT_FIXED - Word16 min_q = -1; - FOR ( Word32 g = 0; g < lengthCy; g++ ) - { - f2me_buf( svd_v_buffer[g], svd_v_buffer_fx[g], &svd_v_buffer_fx_e[g], lengthCx ); - IF ( svd_v_buffer_fx_e[g] > min_q) - { - min_q = svd_v_buffer_fx_e[g]; - } - } - - FOR ( Word32 g = 0; g < lengthCy; g++ ) - { - FOR ( Word32 h = 0; h < lengthCx; h++ ) - { - svd_v_buffer_fx[g][h] = L_shr( svd_v_buffer_fx[g][h], min_q - svd_v_buffer_fx_e[g] ); - } - } - svd_v_buffer_fx_e[0] = min_q; - - min_q = -1; - FOR ( Word32 g = 0; g < lengthCx; g++ ) - { - f2me_buf( svd_u_buffer[g], svd_u_buffer_fx[g], &svd_u_buffer_fx_e[g], lengthCx ); - IF ( svd_u_buffer_fx_e[g] > min_q ) - { - min_q = svd_u_buffer_fx_e[g]; - } - } - - FOR ( Word32 g = 0; g < lengthCx; g++ ) - { - FOR ( Word32 h = 0; h < lengthCx; h++ ) - { - svd_u_buffer_fx[g][h] = L_shr( svd_u_buffer_fx[g][h], min_q - svd_u_buffer_fx_e[g] ); - } - } - svd_u_buffer_fx_e[0] = min_q; - svdMat2mat_fx( svd_v_buffer_fx, mat_mult_buffer1_fx, lengthCy, lengthCx ); - svdMat2mat_fx( svd_u_buffer_fx, mat_mult_buffer2_fx, lengthCx, lengthCx ); - me2f_buf( mat_mult_buffer1_fx, svd_v_buffer_fx_e[0], mat_mult_buffer1, lengthCy * lengthCx ); - me2f_buf( mat_mult_buffer2_fx, svd_u_buffer_fx_e[0], mat_mult_buffer2, lengthCx * lengthCx ); -#else svdMat2mat( svd_v_buffer, mat_mult_buffer1, lengthCy, lengthCx ); svdMat2mat( svd_u_buffer, mat_mult_buffer2, lengthCx, lengthCx ); -#endif matrix_product( mat_mult_buffer1, lengthCy, lengthCx, 0, mat_mult_buffer2, lengthCx, lengthCx, 1, @@ -1453,22 +1380,8 @@ int16_t computeMixingMatrices( } } -#ifdef IVAS_FLOAT_FIXED - Word32 adj_fx[MAX_OUTPUT_CHANNELS]; - Word32 mixing_matrix_fx[MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS]; - Word32 mat_mult_buffer3_fx[MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS]; - Word16 adj_e, mixing_matrix_e, mat_mult_buffer3_e; - - f2me_buf( adj, adj_fx, &adj_e, lengthCy ); - f2me_buf( mixing_matrix, mixing_matrix_fx, &mixing_matrix_e, lengthCy * lengthCx ); - - diag_matrix_product_fx( adj_fx, adj_e, lengthCy, mixing_matrix_fx, mixing_matrix_e, lengthCy, lengthCx, 0, mat_mult_buffer3_fx, &mat_mult_buffer3_e ); - me2f_buf( mat_mult_buffer3_fx, mat_mult_buffer3_e, mat_mult_buffer3, lengthCx * lengthCy ); -#else diag_matrix_product( adj, lengthCy, mixing_matrix, lengthCy, lengthCx, 0, mat_mult_buffer3 ); -#endif - mvr2r( mat_mult_buffer3, mixing_matrix, lengthCy * lengthCx ); } pop_wmops(); @@ -1477,62 +1390,125 @@ int16_t computeMixingMatrices( } -/*-------------------------------------------------------------------* - * computeMixingMatricesResidual() - * - * compute a residual mixing matrix using the covariance synthesis approach - *-------------------------------------------------------------------*/ -int16_t computeMixingMatricesResidual( - const int16_t num_outputs, /* i : number of output channels */ - const float *Cx, /* i : vector containing the diagonal diffuse prototype covariance */ - const float *Cy, /* i : matrix containing the missing cov (Cr from computeMixingMatrices()) */ - const float reg_Sx, /* i : regularization factor for the input channel singular values */ - const float reg_ghat, /* i : regularization factor for the normalization matrix */ - float *mixing_matrix /* o : resulting residual mixing matrix */ +#ifdef IVAS_FLOAT_FIXED +Word16 computeMixingMatrices_fx( + const Word16 num_inputs, /* i : number of input channels */ + const Word16 num_outputs, /* i : number of output channels */ + const Word32 *Cx, /* i : input channel covariance matrix */ + Word16 Cx_e, + const Word32 *Cy, /* i : target covariance matrix */ + Word16 Cy_e, + const Word32 *Q, /* i : prototype matrix (usually a upmix matrix) */ + Word16 Q_fx_e, + const Word16 energy_compensation_flag, /* i : flag indicating that the energy compensation should be performed (i.e. no residual mixing matrix will follow) */ + const Word32 reg_Sx_fx, /* i : regularization factor for the input channel singular values */ + Word16 reg_Sx_e, + const Word32 reg_ghat_fx, /* i : regularization factor for the normalization matrix */ + Word16 reg_ghat_e, + Word32 *mixing_matrix_fx, /* o : resulting mixing matrix */ + Word16 *mixing_matrix_out_e, + Word32 *Cr_fx, /* o : residual covariance matrix */ + Word16 *Cr_e ) { int16_t i, j; int16_t out = EXIT_SUCCESS; - int16_t lengthCx = num_outputs; + int16_t nL, nC; + int16_t lengthCx = num_inputs; int16_t lengthCy = num_outputs; - float *adj; - float limit; float svd_in_buffer[MAX_OUTPUT_CHANNELS][MAX_OUTPUT_CHANNELS]; float svd_u_buffer[MAX_OUTPUT_CHANNELS][MAX_OUTPUT_CHANNELS]; float svd_s_buffer[MAX_OUTPUT_CHANNELS]; float svd_v_buffer[MAX_OUTPUT_CHANNELS][MAX_OUTPUT_CHANNELS]; - float Kx[MAX_OUTPUT_CHANNELS]; - float Ky[MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS]; - float Kx_reg_inv[MAX_OUTPUT_CHANNELS]; - float Cy_hat_diag[MAX_OUTPUT_CHANNELS]; - float G_hat[MAX_OUTPUT_CHANNELS]; - float Cy_tilde[MAX_OUTPUT_CHANNELS]; - float mat_mult_buffer1[MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS]; - float mat_mult_buffer2[MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS]; - float mat_mult_buffer3[MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS]; -#ifdef IVAS_FLOAT_FIXED Word32 svd_in_buffer_fx[MAX_OUTPUT_CHANNELS][MAX_OUTPUT_CHANNELS]; + Word32 mat_mult_buffer1_fx[MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS]; Word32 mat_mult_buffer2_fx[MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS]; + Word32 Cx_fx[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; Word32 Cy_fx[MAX_CICP_CHANNELS * MAX_CICP_CHANNELS]; Word32 svd_u_buffer_fx[MAX_OUTPUT_CHANNELS][MAX_OUTPUT_CHANNELS]; Word32 svd_v_buffer_fx[MAX_OUTPUT_CHANNELS][MAX_OUTPUT_CHANNELS]; Word16 mat_mult_buffer1_fx_e; + Word16 Cx_fx_e; Word16 Cy_fx_e; Word16 svd_u_buffer_fx_e[MAX_OUTPUT_CHANNELS]; Word16 svd_v_buffer_fx_e[MAX_OUTPUT_CHANNELS]; -#endif - push_wmops( "dirac_cov_mix_mat_r" ); -#ifdef IVAS_FLOAT_FIXED - Word32 mixing_matrix_fx[MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS]; - Word32 Cx_fx[MAX_OUTPUT_CHANNELS]; - Word32 mat_mult_buffer1_fx[MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS]; - Word32 adj_fx[MAX_OUTPUT_CHANNELS]; + Word32 svd_s_buffer_fx[MAX_OUTPUT_CHANNELS]; + Word16 svd_s_buffer_e[MAX_OUTPUT_CHANNELS]; + Word16 svd_s_buffer_fx_e; + + + Word32 limit_fx; + Word16 limit_e; + + Word32 L_tmp; + Word16 tmp_e, tmp, exp; + + Word32 Ky_fx[MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS]; + Word32 Kx_fx[MAX_TRANSPORT_CHANNELS * MAX_TRANSPORT_CHANNELS]; + + Word16 Kx_fx_e[MAX_TRANSPORT_CHANNELS * MAX_TRANSPORT_CHANNELS]; + Word16 Ky_fx_e[MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS]; + + Word32 Kx_reg_inv_fx[MAX_TRANSPORT_CHANNELS * MAX_TRANSPORT_CHANNELS]; + Word16 Kx_reg_inv_e[MAX_TRANSPORT_CHANNELS * MAX_TRANSPORT_CHANNELS]; + + Word32 Q_fx[PARAM_MC_MAX_TRANSPORT_CHANS * MAX_CICP_CHANNELS]; + Word16 Q_e; + + Word32 Q_Cx_fx[MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS]; + Word16 Q_Cx_e; + + Word32 Cy_hat_diag_fx[MAX_OUTPUT_CHANNELS]; + Word16 Cy_hat_diag_e; + Word16 Cy_hat_diag_buff_e[MAX_OUTPUT_CHANNELS]; + Word32 G_hat_fx[MAX_OUTPUT_CHANNELS]; + Word16 G_hat_buff_e[MAX_OUTPUT_CHANNELS]; + Word16 G_hat_e; + + Word16 mat_mult_buffer1_e, mat_mult_buffer2_e, mat_mult_buffer3_e; + Word32 mat_mult_buffer3_fx[MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS]; - Word16 mixing_matrix_e, Cx_e, mat_mult_buffer1_e, adj_e, mat_mult_buffer3_e; -#endif + + Word16 mixing_matrix_e; + + Word16 Cr_buff_e[MAX_CICP_CHANNELS * MAX_CICP_CHANNELS]; + Word16 Cr_fx_e; + + + Word32 adj_fx[MAX_OUTPUT_CHANNELS]; + Word16 adj_e[MAX_OUTPUT_CHANNELS]; + Word32 *adj_fx_p; + Word32 adj_buff_fx[MAX_OUTPUT_CHANNELS]; + Word16 adj_fx_e; + + Word32 *Cr_p_fx, *Cy_tilde_p_fx, *Cy_p_fx; + push_wmops( "dirac_cov_mix_mat" ); + + + + set32_fx( svd_s_buffer_fx, 0, MAX_OUTPUT_CHANNELS ); + FOR ( i = 0; i < MAX_OUTPUT_CHANNELS; i++ ) + { + set32_fx( svd_in_buffer_fx[i], 0, MAX_OUTPUT_CHANNELS ); + set32_fx( svd_u_buffer_fx[i], 0, MAX_OUTPUT_CHANNELS ); + set32_fx( svd_v_buffer_fx[i], 0, MAX_OUTPUT_CHANNELS ); + } + + + Copy32(Q, Q_fx, lengthCy * lengthCx); + Copy32(Cx, Cx_fx, lengthCx * lengthCx); + Copy32(Cy, Cy_fx, lengthCy * lengthCy); + + Q_e = Q_fx_e; + move16(); + Cx_fx_e = Cx_e; + move16(); + Cy_fx_e = Cy_e; + move16(); + /*-----------------------------------------------------------------* * Decomposition of Cy @@ -1540,31 +1516,865 @@ int16_t computeMixingMatricesResidual( /* Processing the SVD */ - /* linear array to svd buffer */ -#ifdef IVAS_FLOAT_FIXED - f2me_buf( Cy, Cy_fx, &Cy_fx_e, lengthCy * lengthCy ); mat2svdMat_fx( Cy_fx, svd_in_buffer_fx, lengthCy, lengthCy, 0 ); - FOR ( Word32 g = 0; g < lengthCy; g++ ) { me2f_buf( ( svd_in_buffer_fx[g] ), Cy_fx_e, ( svd_in_buffer[g] ), lengthCy ); } -#else - mat2svdMat( Cy, svd_in_buffer, lengthCy, lengthCy, 0 ); -#endif - svd( svd_in_buffer, svd_u_buffer, svd_s_buffer, svd_v_buffer, lengthCy, lengthCy ); + f2me_buf(svd_s_buffer, svd_s_buffer_fx, &svd_s_buffer_fx_e, lengthCy); + FOR(Word32 g = 0; g < lengthCy; g++) + { + f2me_buf((svd_u_buffer[g]), (svd_u_buffer_fx[g]), &svd_u_buffer_fx_e[g], lengthCy); + f2me_buf((svd_v_buffer[g]), (svd_v_buffer_fx[g]), &svd_v_buffer_fx_e[g], lengthCy); + } + /* Computing Ky */ + + + /* Computing Ky */ + FOR ( i = 0; i < lengthCy; ++i ) + { + FOR ( j = 0; j < lengthCy; ++j ) + { + tmp_e = svd_s_buffer_fx_e; + L_tmp = Sqrt32(svd_s_buffer_fx[j], &tmp_e); + Ky_fx[i + j * lengthCy] = Mpy_32_32( svd_u_buffer_fx[i][j], L_tmp ); + Ky_fx_e[i + j * lengthCy] = svd_u_buffer_fx_e[i] + tmp_e; + } + } + + exp = Ky_fx_e[0]; + FOR (i = 1; i < lengthCy * lengthCy; i++) + { + IF (exp < Ky_fx_e[i]) + exp = Ky_fx_e[i]; + } + + FOR (i = 0; i < lengthCy * lengthCy; i++) + { + Ky_fx[i] = L_shr(Ky_fx[i], exp - Ky_fx_e[i]); + Ky_fx_e[i] = exp; + } + + + /*-----------------------------------------------------------------* + * Decomposition of Cx + *-----------------------------------------------------------------*/ + + /* Processing the SVD */ + + mat2svdMat_fx( Cx_fx, svd_in_buffer_fx, lengthCx, lengthCx, 0 ); + FOR ( Word32 g = 0; g < lengthCx; g++ ) + { + me2f_buf( ( svd_in_buffer_fx[g] ), Cx_fx_e, ( svd_in_buffer[g] ), lengthCx ); + } + + + svd( svd_in_buffer, svd_u_buffer, svd_s_buffer, svd_v_buffer, lengthCx, lengthCx ); + f2me_buf(svd_s_buffer, svd_s_buffer_fx, &svd_s_buffer_fx_e, lengthCx); + FOR(Word32 g = 0; g < lengthCy; g++) + { + f2me_buf((svd_u_buffer[g]), (svd_u_buffer_fx[g]), &svd_u_buffer_fx_e[g], lengthCx); + f2me_buf((svd_v_buffer[g]), (svd_v_buffer_fx[g]), &svd_v_buffer_fx_e[g], lengthCx); + } + + + + FOR ( i = 0; i < lengthCx; ++i ) + { + FOR ( j = 0; j < lengthCx; ++j ) + { + tmp_e = svd_s_buffer_fx_e; + L_tmp = Sqrt32(svd_s_buffer_fx[j], &tmp_e); + Kx_fx[i + j * lengthCx] = Mpy_32_32( svd_u_buffer_fx[i][j], L_tmp ); + Kx_fx_e[i + j * lengthCx] = svd_u_buffer_fx_e[i] + tmp_e; + } + } + + exp = Kx_fx_e[0]; + FOR (i = 1; i < lengthCx * lengthCx; i++) + { + IF (exp < Kx_fx_e[i]) + exp = Kx_fx_e[i]; + } + + FOR (i = 0; i < lengthCx * lengthCx; i++) + { + Kx_fx[i] = L_shr(Kx_fx[i], exp - Kx_fx_e[i]); + Kx_fx_e[i] = exp; + move16(); + } + + + FOR ( i = 0; i < lengthCx; ++i ) + { + tmp_e = svd_s_buffer_fx_e; + move16(); + svd_s_buffer_fx[i] = Sqrt32(svd_s_buffer_fx[i], &tmp_e); + svd_s_buffer_e[i] = tmp_e; + move16(); + } + + // making the Q common + Word16 max = svd_s_buffer_e[0]; + FOR (i = 1; i < lengthCx; i++) + { + IF (max < svd_s_buffer_e[i]) + { + max = svd_s_buffer_e[i]; + move16(); + } + } + + FOR (i = 0; i < lengthCx; i++) + { + svd_s_buffer_fx[i] = L_shr(svd_s_buffer_fx[i], (max - svd_s_buffer_e[i] )); + } + svd_s_buffer_fx_e = max; + move16(); + + + /*-----------------------------------------------------------------* + * Regularization of Sx + *-----------------------------------------------------------------*/ + + maximum_l( svd_s_buffer_fx, lengthCx, &limit_fx ); + limit_e = svd_s_buffer_fx_e; + move16(); + + L_tmp = Mpy_32_32(limit_fx, reg_Sx_fx); + limit_e = limit_e + reg_Sx_e; + limit_fx = L_add( L_tmp, EPSILON_FX ); + + FOR ( i = 0; i < lengthCx; ++i ) + { + svd_s_buffer_e[i] = svd_s_buffer_fx_e; + IF (BASOP_Util_Cmp_Mant32Exp(svd_s_buffer_fx[i], svd_s_buffer_fx_e, limit_fx, limit_e) < 0) + { + svd_s_buffer_fx[i] = limit_fx; + svd_s_buffer_e[i] = limit_e; + } + } + + + + limit_fx = 0; + move32(); + limit_e = 0; + move16(); + + + /*-----------------------------------------------------------------* + * regularized Kx-1 + *-----------------------------------------------------------------*/ + + FOR ( i = 0; i < lengthCx; ++i ) + { + Word16 scale, reg_fac_fx; + reg_fac_fx = BASOP_Util_Divide3232_Scale(1, svd_s_buffer_fx[i], &scale); + scale = scale + (31 - svd_s_buffer_e[i]); + FOR ( j = 0; j < lengthCx; ++j ) + { + Kx_reg_inv_fx[i + j * lengthCx] = Mpy_32_16_1(svd_u_buffer_fx[j][i], reg_fac_fx ); + Kx_reg_inv_e[i + j * lengthCx] = svd_u_buffer_fx_e[j] + scale; + } + } + + exp = Kx_reg_inv_e[0]; + move16(); + FOR(i = 0; i < lengthCx * lengthCx; i++) + { + IF (exp < Kx_reg_inv_e[i]) + exp = Kx_reg_inv_e[i]; + move16(); + } + + FOR(i = 0; i < lengthCx * lengthCx; i++) + { + Kx_reg_inv_fx[i] = L_shr(Kx_reg_inv_fx[i], exp - Kx_reg_inv_e[i]); + Kx_reg_inv_e[i] = exp; + move16(); + } + + /*-----------------------------------------------------------------* + * normalization matrix G hat + *-----------------------------------------------------------------*/ + + /* Computing Q*Cx*Q' */ + + matrix_product_fx( Q_fx, lengthCy, lengthCx, 0, Cx_fx, lengthCx, lengthCx, 0, Q_Cx_fx ); + Q_Cx_e = Q_e + Cx_fx_e; + + + Word16 guard_bits = find_guarded_bits_fx( lengthCx + 1 ); + + FOR ( i = 0; i < lengthCy * lengthCx; ++i ) + { + IF ( Q_Cx_e > Q_e ) + { + Q_fx[i] = L_shr( Q_fx[i], guard_bits ); + } + ELSE + { + Q_Cx_fx[i] = L_shr( Q_Cx_fx[i], guard_bits ); + } + } + + IF ( Q_Cx_e > Q_e ) + { + Q_e += guard_bits; + } + ELSE + { + Q_Cx_e += guard_bits; + } + + matrix_product_diag_fx( Q_Cx_fx, Q_Cx_e, lengthCy, lengthCx, 0, Q_fx, Q_e, lengthCy, lengthCx, 1, Cy_hat_diag_fx, &Cy_hat_diag_e ); + + + FOR ( i = 0; i < lengthCy; ++i ) + { + IF (BASOP_Util_Cmp_Mant32Exp(Cy_hat_diag_fx[i], Cy_hat_diag_e, limit_fx, limit_e) > 0) + { + limit_fx = Cy_hat_diag_fx[i]; + move32(); + limit_e = Cy_hat_diag_e; + move16(); + } + + L_tmp = Mpy_32_32(limit_fx, reg_ghat_fx); + limit_fx = L_add(L_tmp, EPSILON_FX); + limit_e = limit_e + reg_ghat_e; + } + + + FOR ( i = 0; i < lengthCy; ++i ) + { + Cy_hat_diag_buff_e[i] = Cy_hat_diag_e; + move16(); + IF ( BASOP_Util_Cmp_Mant32Exp(limit_fx, limit_e, Cy_hat_diag_fx[i], Cy_hat_diag_buff_e[i] ) > 0 ) /* Computing Cy_hat_diag = max(Cy_hat_diag,limit) */ + { + Cy_hat_diag_fx[i] = limit_fx; + move32(); + Cy_hat_diag_buff_e[i] = limit_e; + move16(); + } + + tmp = BASOP_Util_Divide3232_Scale(Cy_fx[i + i * lengthCy], Cy_hat_diag_fx[i], &exp); + exp = exp + ( Cy_fx_e - Cy_hat_diag_buff_e[i] ); + L_tmp = Sqrt32(L_deposit_h(tmp), &exp); + G_hat_fx[i] = L_tmp; + move32(); + G_hat_buff_e[i] = exp; + move16(); + } + + exp = G_hat_buff_e[0]; + move16(); + FOR (i = 1; i < lengthCy; i++) + { + IF (exp < G_hat_buff_e[i]) + exp = G_hat_buff_e[i]; + } + + FOR (i = 0; i < lengthCy; i++) + { + G_hat_fx[i] = L_shr(G_hat_fx[i], exp - G_hat_buff_e[i]); + } + + G_hat_e = exp; + move16(); + + /*-----------------------------------------------------------------* + * Formulate optimal P + *-----------------------------------------------------------------*/ + + /* Computing the input matrix Kx'*Q'*G_hat'*Ky */ + + matrix_product_fx(Kx_fx, lengthCx, lengthCx, 1, Q_fx, lengthCy, lengthCx, 1, mat_mult_buffer1_fx); + mat_mult_buffer1_e = Kx_fx_e[0] + Q_e; + + + matrix_diag_product_fx( mat_mult_buffer1_fx, mat_mult_buffer1_e, lengthCx, lengthCy, 0, G_hat_fx, G_hat_e, lengthCy, mat_mult_buffer2_fx, &mat_mult_buffer2_e ); + + matrix_product_fx( mat_mult_buffer2_fx, lengthCx, lengthCy, 0, Ky_fx, lengthCy, lengthCy, 0, mat_mult_buffer1_fx ); + mat_mult_buffer1_e = mat_mult_buffer2_e + Ky_fx_e[0]; + + + IF ( lengthCx < lengthCy ) + { + mat2svdMat_fx( mat_mult_buffer1_fx, svd_in_buffer_fx, lengthCx, lengthCy, 1 ); + +#ifdef IVAS_FLOAT_FIXED_TO_BE_REMOVED + FOR ( Word32 g = 0; g < lengthCy; g++ ) + { + me2f_buf( ( svd_in_buffer_fx[g] ), mat_mult_buffer1_e, ( svd_in_buffer[g] ), lengthCx ); + } + + nL = lengthCy; + move16(); + nC = lengthCx; + move16(); + + svd( svd_in_buffer, svd_v_buffer, svd_s_buffer, svd_u_buffer, nL, nC ); +#endif + } + ELSE + { + mat2svdMat_fx( mat_mult_buffer1_fx, svd_in_buffer_fx, lengthCx, lengthCy, 0 ); + +#ifdef IVAS_FLOAT_FIXED_TO_BE_REMOVED + FOR ( Word32 g = 0; g < lengthCx; g++ ) + { + me2f_buf( ( svd_in_buffer_fx[g] ), mat_mult_buffer1_e, ( svd_in_buffer[g] ), lengthCy ); + } + + nL = lengthCx; + move16(); + nC = lengthCy; + move16(); + + svd( svd_in_buffer, svd_u_buffer, svd_s_buffer, svd_v_buffer, nL, nC ); +#endif + } + + /* Actually Processing P */ + + /* can be skipped: lambda is always column-truncated identity matrix, so this operation just + truncates V to num_input_channel columns */ + + Word16 min_q = -1; + move16(); + FOR ( Word32 g = 0; g < lengthCy; g++ ) + { + f2me_buf( svd_v_buffer[g], svd_v_buffer_fx[g], &svd_v_buffer_fx_e[g], lengthCx ); + IF ( svd_v_buffer_fx_e[g] > min_q) + { + min_q = svd_v_buffer_fx_e[g]; + } + } + + FOR ( Word32 g = 0; g < lengthCy; g++ ) + { + FOR ( Word32 h = 0; h < lengthCx; h++ ) + { + svd_v_buffer_fx[g][h] = L_shr( svd_v_buffer_fx[g][h], min_q - svd_v_buffer_fx_e[g] ); + } + } + svd_v_buffer_fx_e[0] = min_q; + move16(); + + min_q = -1; + move16(); + FOR ( Word32 g = 0; g < lengthCx; g++ ) + { + f2me_buf( svd_u_buffer[g], svd_u_buffer_fx[g], &svd_u_buffer_fx_e[g], lengthCx ); + IF ( svd_u_buffer_fx_e[g] > min_q ) + { + min_q = svd_u_buffer_fx_e[g]; + move16(); + } + } + + FOR ( Word32 g = 0; g < lengthCx; g++ ) + { + FOR ( Word32 h = 0; h < lengthCx; h++ ) + { + svd_u_buffer_fx[g][h] = L_shr( svd_u_buffer_fx[g][h], min_q - svd_u_buffer_fx_e[g] ); + } + } + svd_u_buffer_fx_e[0] = min_q; + move16(); + svdMat2mat_fx( svd_v_buffer_fx, mat_mult_buffer1_fx, lengthCy, lengthCx ); + svdMat2mat_fx( svd_u_buffer_fx, mat_mult_buffer2_fx, lengthCx, lengthCx ); + + mat_mult_buffer1_e = svd_v_buffer_fx_e[0]; + mat_mult_buffer2_e = svd_u_buffer_fx_e[0]; + + guard_bits = find_guarded_bits_fx(lengthCx + 1); + FOR(i = 0; i < lengthCx * lengthCy; ++i) + { + IF(mat_mult_buffer1_e > mat_mult_buffer1_e) + { + mat_mult_buffer1_fx[i] = L_shr(mat_mult_buffer1_fx[i], guard_bits); + } + ELSE + { + mat_mult_buffer2_fx[i] = L_shr(mat_mult_buffer2_fx[i], guard_bits); + } + } + + IF(mat_mult_buffer1_e > mat_mult_buffer2_e ) + { + mat_mult_buffer2_e += guard_bits; + } + ELSE + { + mat_mult_buffer1_e += guard_bits; + } + + matrix_product_fx( mat_mult_buffer1_fx, lengthCy, lengthCx, 0, + mat_mult_buffer2_fx, lengthCx, lengthCx, 1, + mat_mult_buffer3_fx ); + mat_mult_buffer3_e = mat_mult_buffer1_e + mat_mult_buffer2_e; + + /************************ Formulate M **********************/ + + matrix_product_fx( Ky_fx, lengthCy, lengthCy, 0, mat_mult_buffer3_fx, lengthCy, lengthCx, 0, mat_mult_buffer1_fx); + mat_mult_buffer1_e = Ky_fx_e[0] + mat_mult_buffer3_e; + + + matrix_product_fx( mat_mult_buffer1_fx, lengthCy, lengthCx, 0, Kx_reg_inv_fx, lengthCx, lengthCx, 0, mixing_matrix_fx ); + mixing_matrix_e = Kx_reg_inv_e[0] + mat_mult_buffer1_e; + + + /*-----------------------------------------------------------------* + * Formulate Cr + *-----------------------------------------------------------------*/ + + /* Compute Cy_tilde = M*Cx*M' */ + + + matrix_product_fx( mixing_matrix_fx, lengthCy, lengthCx, 0, Cx_fx, lengthCx, lengthCx, 0, mat_mult_buffer1_fx ); + mat_mult_buffer1_e = mixing_matrix_e + Cx_fx_e; + + matrix_product_fx( mat_mult_buffer1_fx, lengthCy, lengthCx, 0, mixing_matrix_fx, lengthCy, lengthCx, 1, mat_mult_buffer2_fx ); + mat_mult_buffer2_e = mat_mult_buffer1_e + mixing_matrix_e; + + Cr_p_fx = Cr_fx; + Cy_p_fx = Cy_fx; + Cy_tilde_p_fx = mat_mult_buffer2_fx; + exp = s_max(Cy_fx_e, mat_mult_buffer2_e); + FOR ( i = 0; i < lengthCy * lengthCy; i++) + { + Cy_fx[i] = L_shr(Cy_p_fx[i], exp - Cy_fx_e); + Cy_tilde_p_fx[i] = L_shr(Cy_tilde_p_fx[i], exp - mat_mult_buffer2_e); + } + Cy_fx_e = exp; + move16(); + mat_mult_buffer2_e = exp; + move16(); + FOR(i = 0; i < lengthCy; ++i) + { + FOR(j = 0; j < lengthCy; ++j) + { + + *(Cr_p_fx++) = *(Cy_p_fx++) - *(Cy_tilde_p_fx++); + } + + /* Avoid Meaningless negative main diagonal elements */ + Cr_buff_e[i + i * lengthCy] = exp; + IF(BASOP_Util_Cmp_Mant32Exp(Cr_fx[i + i * lengthCy], exp, 0, 0) < 0) + { + Cr_fx[i + i * lengthCy] = 0; + move16(); + Cr_buff_e[i + i * lengthCy] = 0; + move16(); + } + } + + Cr_fx_e = exp; + move16(); + + /*-----------------------------------------------------------------* + * Energy Compensation + *-----------------------------------------------------------------*/ + + IF ( energy_compensation_flag == 1 ) + { + adj_fx_p = svd_s_buffer_fx; + Cy_tilde_p_fx = mat_mult_buffer2_fx; + + FOR ( i = 0; i < lengthCy; ++i ) + { + /* Avoid correction for very small energies, + main diagonal elements of Cy_tilde_p may be negative */ + IF (BASOP_Util_Cmp_Mant32Exp(Cy_tilde_p_fx[i + i * lengthCy], mat_mult_buffer2_e, 0, 0) < 0) + { + adj_fx_p[i] = 1073741824; + move32(); + adj_e[i] = 1; + move16(); + } + ELSE + { + tmp = BASOP_Util_Divide3232_Scale(Cy_fx[i + lengthCy * i], L_add( Cy_tilde_p_fx[i + i * lengthCy], EPSILON_FX ), &exp); + exp = exp + (Cy_fx_e - mat_mult_buffer2_e); + L_tmp = L_deposit_h(tmp); + L_tmp = Sqrt32(L_tmp, &exp); + adj_fx_p[i] = L_tmp; + move32(); + adj_e[i] = exp; + move16(); + } + + IF (BASOP_Util_Cmp_Mant32Exp(adj_fx_p[i], adj_e[i], 1073741824, 3) > 0) + { + adj_fx_p[i] = 1073741824; + move32(); + adj_e[i] = 3; + move16(); + } + } + + exp = adj_e[0]; + FOR (i = 1; i < lengthCy; i++) + { + IF (exp < adj_e[i]) + exp = adj_e[i]; + } + + FOR (i = 0; i < lengthCy; i++) + { + adj_fx[i] = L_shr(adj_fx_p[i], exp - adj_e[i]); + } + adj_fx_e = exp; + move16(); + + diag_matrix_product_fx( adj_fx, adj_fx_e, lengthCy, mixing_matrix_fx, mixing_matrix_e, lengthCy, lengthCx, 0, mat_mult_buffer3_fx, &mat_mult_buffer3_e ); + + Copy32(mat_mult_buffer3_fx, mixing_matrix_fx, lengthCx * lengthCy); + mixing_matrix_e = mat_mult_buffer3_e; + move16(); + } + + *mixing_matrix_out_e = mixing_matrix_e; + move16(); + *Cr_e = Cr_fx_e; + move16(); + pop_wmops(); + + return out; +} +#endif + +/*-------------------------------------------------------------------* + * computeMixingMatricesResidual() + * + * compute a residual mixing matrix using the covariance synthesis approach + *-------------------------------------------------------------------*/ + +int16_t computeMixingMatricesResidual( + const int16_t num_outputs, /* i : number of output channels */ + const float *Cx, /* i : vector containing the diagonal diffuse prototype covariance */ + const float *Cy, /* i : matrix containing the missing cov (Cr from computeMixingMatrices()) */ + const float reg_Sx, /* i : regularization factor for the input channel singular values */ + const float reg_ghat, /* i : regularization factor for the normalization matrix */ + float *mixing_matrix /* o : resulting residual mixing matrix */ +) +{ + int16_t i, j; + int16_t out = EXIT_SUCCESS; + int16_t lengthCx = num_outputs; + int16_t lengthCy = num_outputs; + float *adj; + float limit; + float svd_in_buffer[MAX_OUTPUT_CHANNELS][MAX_OUTPUT_CHANNELS]; + float svd_u_buffer[MAX_OUTPUT_CHANNELS][MAX_OUTPUT_CHANNELS]; + float svd_s_buffer[MAX_OUTPUT_CHANNELS]; + float svd_v_buffer[MAX_OUTPUT_CHANNELS][MAX_OUTPUT_CHANNELS]; + float Kx[MAX_OUTPUT_CHANNELS]; + float Ky[MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS]; + float Kx_reg_inv[MAX_OUTPUT_CHANNELS]; + float Cy_hat_diag[MAX_OUTPUT_CHANNELS]; + float G_hat[MAX_OUTPUT_CHANNELS]; + float Cy_tilde[MAX_OUTPUT_CHANNELS]; + float mat_mult_buffer1[MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS]; + float mat_mult_buffer2[MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS]; + float mat_mult_buffer3[MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS]; + + push_wmops( "dirac_cov_mix_mat_r" ); + + /*-----------------------------------------------------------------* + * Decomposition of Cy + *-----------------------------------------------------------------*/ + + /* Processing the SVD */ + + /* linear array to svd buffer */ + mat2svdMat( Cy, svd_in_buffer, lengthCy, lengthCy, 0 ); + + svd( svd_in_buffer, svd_u_buffer, svd_s_buffer, svd_v_buffer, lengthCy, lengthCy ); + + /* Computing Ky */ + for ( i = 0; i < lengthCy; ++i ) + { + for ( j = 0; j < lengthCy; ++j ) + { + Ky[i + j * lengthCy] = svd_u_buffer[i][j] * sqrtf( svd_s_buffer[j] ); + } + } + + /*-----------------------------------------------------------------* + * Decomposition of Cx + *-----------------------------------------------------------------*/ + + /* Processing the SVD of Cx*/ + /* Cx is a diagonal matrix, so SVD would lead to the sorted diagonal as S and u + * would be just indicating the sorting index, so go straight to Kx as the + * square root of the diagonal of Cx */ + + /* Computing Kx */ + for ( i = 0; i < lengthCx; ++i ) + { + Kx[i] = sqrtf( Cx[i] ); + } + + /*-----------------------------------------------------------------* + * Regularization of Sx + *-----------------------------------------------------------------*/ + + maximum( Kx, lengthCx, &limit ); + limit = limit * reg_Sx + EPSILON; + + for ( i = 0; i < lengthCx; ++i ) + { + float reg_fac = ( 1.0f / ( ( Kx[i] > limit ) ? Kx[i] : limit ) ); + Kx_reg_inv[i] = reg_fac; + } + + limit = 0.0f; + + /*-----------------------------------------------------------------* + * regularized Kx-1 + *-----------------------------------------------------------------*/ + + /*-----------------------------------------------------------------* + * normalization matrix G hat + *-----------------------------------------------------------------*/ + + /* Computing Cy_hat_diag */ + mvr2r( Cx, Cy_hat_diag, num_outputs ); + + for ( i = 0; i < lengthCy; ++i ) + { + if ( Cy_hat_diag[i] > limit ) + { + limit = Cy_hat_diag[i]; + } + } + + limit = limit * reg_ghat + EPSILON; + + /* Computing G_hat */ + for ( i = 0; i < lengthCy; ++i ) + { + if ( limit > Cy_hat_diag[i] ) /* Computing Cy_hat_diag = max(Cy_hat_diag,limit) */ + { + Cy_hat_diag[i] = limit; + } + G_hat[i] = sqrtf( Cy[i + i * lengthCy] / Cy_hat_diag[i] ); + } + + /*-----------------------------------------------------------------* + * Formulate optimal P + *-----------------------------------------------------------------*/ + + for ( i = 0; i < num_outputs; i++ ) + { + Kx[i] *= G_hat[i]; + } + + for ( i = 0; i < num_outputs; i++ ) + { + float fac = Kx[i]; + + for ( j = 0; j < num_outputs; j++ ) + { + mat_mult_buffer1[i + j * num_outputs] = Ky[i + j * num_outputs] * fac; + } + } + + mat2svdMat( mat_mult_buffer1, svd_in_buffer, lengthCx, lengthCy, 0 ); + + svd( svd_in_buffer, svd_u_buffer, svd_s_buffer, svd_v_buffer, lengthCx, lengthCy ); + + /* Actually Processing P */ + + svdMat2mat( svd_v_buffer, mat_mult_buffer1, lengthCy, lengthCx ); + svdMat2mat( svd_u_buffer, mat_mult_buffer2, lengthCx, lengthCx ); + + matrix_product( mat_mult_buffer1, lengthCy, lengthCx, 0, + mat_mult_buffer2, lengthCx, lengthCx, 1, + mat_mult_buffer3 ); + + /*-----------------------------------------------------------------* + * Formulate M + *-----------------------------------------------------------------*/ + + matrix_product( Ky, lengthCy, lengthCy, 0, mat_mult_buffer3, lengthCy, lengthCx, 0, mat_mult_buffer1 ); + + for ( i = 0; i < num_outputs; i++ ) + { + float fac = Kx_reg_inv[i]; + + for ( j = 0; j < num_outputs; j++ ) + { + mixing_matrix[j + i * num_outputs] = mat_mult_buffer1[j + i * num_outputs] * fac; + } + } + + /*-----------------------------------------------------------------* + * Formulate Cr + *-----------------------------------------------------------------*/ + + /* Compute Cy_tilde = M*Cx*M' */ + matrix_diag_product( mixing_matrix, lengthCy, lengthCx, 0, Cx, lengthCx, mat_mult_buffer1 ); + matrix_product_diag( mat_mult_buffer1, lengthCy, lengthCx, 0, mixing_matrix, lengthCy, lengthCx, 1, Cy_tilde ); + + /*-----------------------------------------------------------------* + * Energy Compensation + *-----------------------------------------------------------------*/ + + adj = svd_s_buffer; + for ( i = 0; i < lengthCy; ++i ) { - for ( j = 0; j < lengthCy; ++j ) + adj[i] = sqrtf( Cy[i + lengthCy * i] / ( Cy_tilde[i] + EPSILON ) ); + if ( adj[i] > 4.0f ) { - Ky[i + j * lengthCy] = svd_u_buffer[i][j] * sqrtf( svd_s_buffer[j] ); + adj[i] = 4.0f; + } + } + + diag_matrix_product( adj, lengthCy, mixing_matrix, lengthCy, lengthCx, 0, mat_mult_buffer3 ); + + mvr2r( mat_mult_buffer3, mixing_matrix, lengthCy * lengthCx ); + + pop_wmops(); + + return out; +} + +#ifdef IVAS_FLOAT_FIXED +Word16 computeMixingMatricesResidual_fx( + const Word32 num_outputs, /* i : number of output channels */ + const Word32 *Cx_fx, /* i : vector containing the diagonal diffuse prototype covariance */ + const Word16 Cx_e, + const Word32 *Cy_fx, /* i : matrix containing the missing cov (Cr from computeMixingMatrices()) */ + const Word16 Cy_fx_e, + const Word32 reg_Sx_fx, /* i : regularization factor for the input channel singular values */ + const Word16 reg_Sx_e, + const Word32 reg_ghat_fx, /* i : regularization factor for the normalization matrix */ + const Word16 reg_ghat_e, + Word32 *mixing_matrix_fx, /* o : resulting residual mixing matrix */ + Word16 *mixing_matrix_ret_e +) +{ + Word16 i, j; + Word16 out = EXIT_SUCCESS; + Word16 lengthCx = num_outputs; + Word16 lengthCy = num_outputs; + +#ifdef IVAS_FLOAT_FIXED_TO_BE_REMOVED + float svd_in_buffer[MAX_OUTPUT_CHANNELS][MAX_OUTPUT_CHANNELS]; + float svd_u_buffer[MAX_OUTPUT_CHANNELS][MAX_OUTPUT_CHANNELS]; + float svd_s_buffer[MAX_OUTPUT_CHANNELS]; + float svd_v_buffer[MAX_OUTPUT_CHANNELS][MAX_OUTPUT_CHANNELS]; +#endif + + Word32 svd_in_buffer_fx[MAX_OUTPUT_CHANNELS][MAX_OUTPUT_CHANNELS]; + Word32 mat_mult_buffer2_fx[MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS]; + Word32 svd_u_buffer_fx[MAX_OUTPUT_CHANNELS][MAX_OUTPUT_CHANNELS]; + Word32 svd_v_buffer_fx[MAX_OUTPUT_CHANNELS][MAX_OUTPUT_CHANNELS]; + + Word16 svd_u_buffer_fx_e[MAX_OUTPUT_CHANNELS]; + Word16 svd_v_buffer_fx_e[MAX_OUTPUT_CHANNELS]; + + Word16 mat_mult_buffer1_buff_e[MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS]; + + push_wmops( "dirac_cov_mix_mat_r" ); + + Word32 mat_mult_buffer1_fx[MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS]; + Word32 adj_fx[MAX_OUTPUT_CHANNELS]; + Word32 mat_mult_buffer3_fx[MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS]; + Word16 mixing_matrix_e, mat_mult_buffer1_e, adj_e, mat_mult_buffer3_e, mat_mult_buffer2_e; + + Word32 svd_s_buffer_fx[MAX_OUTPUT_CHANNELS]; + Word16 svd_s_buffer_fx_e; + Word32 L_tmp; + Word16 tmp_e; + Word16 tmp, scale; + Word32 div_tmp; + Word16 exp; + + Word32 Kx_fx[MAX_OUTPUT_CHANNELS]; + Word16 Ky_fx_e[MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS]; + Word32 Ky_fx[MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS]; + Word16 Kx_fx_e[MAX_OUTPUT_CHANNELS]; + + Word32 limit_fx; + Word16 limit_e; + + Word32 Kx_reg_inv_fx[MAX_OUTPUT_CHANNELS]; + Word16 Kx_reg_inv_e[MAX_OUTPUT_CHANNELS], Kx_reg_inv_fx_e; + + Word32 Cy_hat_diag_fx[MAX_OUTPUT_CHANNELS]; + Word16 Cy_hat_diag_e; + + Word16 Cy_hat_diag_fx_e[MAX_OUTPUT_CHANNELS]; + Word32 G_hat_fx[MAX_OUTPUT_CHANNELS]; + Word16 G_hat_e[MAX_OUTPUT_CHANNELS]; + + Word32 *adj_fx_p; + Word16 adj_buff_e[MAX_OUTPUT_CHANNELS]; + + Word32 Cy_tilde_fx[MAX_OUTPUT_CHANNELS]; + Word16 Cy_tilde_e; + + /*-----------------------------------------------------------------* + * Decomposition of Cy + *-----------------------------------------------------------------*/ + + /* Processing the SVD */ + + /* linear array to svd buffer */ + mat2svdMat_fx( Cy_fx, svd_in_buffer_fx, lengthCy, lengthCy, 0 ); + +#ifdef IVAS_FLOAT_FIXED_TO_BE_REMOVED + FOR ( Word32 g = 0; g < lengthCy; g++ ) + { + me2f_buf( ( svd_in_buffer_fx[g] ), Cy_fx_e, ( svd_in_buffer[g] ), lengthCy ); + } + + svd(svd_in_buffer, svd_u_buffer, svd_s_buffer, svd_v_buffer, lengthCy, lengthCy); + f2me_buf(svd_s_buffer, svd_s_buffer_fx, &svd_s_buffer_fx_e, lengthCy); + FOR(Word32 g = 0; g < lengthCy; g++) + { + f2me_buf((svd_u_buffer[g]), (svd_u_buffer_fx[g]), &svd_u_buffer_fx_e[g], lengthCy); + f2me_buf((svd_v_buffer[g]), (svd_v_buffer_fx[g]), &svd_v_buffer_fx_e[g], lengthCy); + } +#endif + + /* Computing Ky */ + FOR ( i = 0; i < lengthCy; ++i ) + { + FOR ( j = 0; j < lengthCy; ++j ) + { + tmp_e = svd_s_buffer_fx_e; + L_tmp = Sqrt32(svd_s_buffer_fx[j], &tmp_e); + Ky_fx[i + j * lengthCy] = Mpy_32_32( svd_u_buffer_fx[i][j], L_tmp ); + Ky_fx_e[i + j * lengthCy] = svd_u_buffer_fx_e[i] + tmp_e; } } + exp = Ky_fx_e[0]; + FOR (i = 1; i < lengthCy * lengthCy; i++) + { + IF (exp < Ky_fx_e[i]) + exp = Ky_fx_e[i]; + } + + FOR (i = 0; i < lengthCy * lengthCy; i++) + { + Ky_fx[i] = L_shr(Ky_fx[i], exp - Ky_fx_e[i]); + Ky_fx_e[i] = exp; + move16(); + } + /*-----------------------------------------------------------------* * Decomposition of Cx *-----------------------------------------------------------------*/ @@ -1575,25 +2385,86 @@ int16_t computeMixingMatricesResidual( * square root of the diagonal of Cx */ /* Computing Kx */ - for ( i = 0; i < lengthCx; ++i ) + + FOR ( i = 0; i < lengthCx; ++i ) { - Kx[i] = sqrtf( Cx[i] ); + exp = Cx_e; + move16(); + Kx_fx[i] = Sqrt32(Cx_fx[i], &exp); + Kx_fx_e[i] = exp; + move16(); + } + + exp = Kx_fx_e[0]; + FOR (i = 1; i < lengthCx; i++) + { + IF (exp < Kx_fx_e[i]) + exp = Kx_fx_e[i]; + } + + FOR (i = 0; i < lengthCx; i++) + { + Kx_fx[i] = L_shr(Kx_fx[i], exp - Kx_fx_e[i]); + Kx_fx_e[i] = exp; + move16(); } + /*-----------------------------------------------------------------* * Regularization of Sx *-----------------------------------------------------------------*/ - maximum( Kx, lengthCx, &limit ); - limit = limit * reg_Sx + EPSILON; + maximum_l( Kx_fx, lengthCx, &limit_fx ); + limit_e = Kx_fx_e[0]; + move16(); - for ( i = 0; i < lengthCx; ++i ) + L_tmp = Mpy_32_32(limit_fx, reg_Sx_fx); + L_tmp = L_add(L_tmp, EPSILLON_FX); + limit_fx = L_tmp; + move16(); + limit_e = limit_e + reg_Sx_e; + + FOR ( i = 0; i < lengthCx; ++i ) { - float reg_fac = ( 1.0f / ( ( Kx[i] > limit ) ? Kx[i] : limit ) ); - Kx_reg_inv[i] = reg_fac; + IF (BASOP_Util_Cmp_Mant32Exp(Kx_fx[i], Kx_fx_e[0], limit_fx, limit_e) > 0) + { + div_tmp = Kx_fx[i]; + exp = Kx_fx_e[0]; + move16(); + } + ELSE + { + div_tmp = limit_fx; + exp = limit_e; + move16(); + } + tmp = BASOP_Util_Divide3232_Scale(1073741824, div_tmp, &scale); + scale = scale + ( 1 - exp ); + + Kx_reg_inv_fx[i] = L_deposit_h( tmp); + Kx_reg_inv_e[i] = scale; + move16(); } - limit = 0.0f; + exp = Kx_reg_inv_e[0]; + FOR (i = 1; i < lengthCx; i++) + { + IF (exp < Kx_reg_inv_e[i]) + exp = Kx_reg_inv_e[i]; + } + + FOR (i = 0; i < lengthCx; i++) + { + Kx_reg_inv_fx[i] = L_shr(Kx_reg_inv_fx[i], exp - Kx_reg_inv_e[i]); + } + Kx_reg_inv_fx_e = exp; + move16(); + + + limit_fx = 0; + move32(); + limit_e = 0; + move16(); /*-----------------------------------------------------------------* * regularized Kx-1 @@ -1604,65 +2475,92 @@ int16_t computeMixingMatricesResidual( *-----------------------------------------------------------------*/ /* Computing Cy_hat_diag */ - mvr2r( Cx, Cy_hat_diag, num_outputs ); + Copy32(Cx_fx, Cy_hat_diag_fx, num_outputs); + Cy_hat_diag_e = Cx_e; - for ( i = 0; i < lengthCy; ++i ) + FOR ( i = 0; i < lengthCy; ++i ) { - if ( Cy_hat_diag[i] > limit ) + IF ( BASOP_Util_Cmp_Mant32Exp(Cy_hat_diag_fx[i], Cy_hat_diag_e, limit_fx, limit_e ) > 0 ) { - limit = Cy_hat_diag[i]; + limit_fx = Cy_hat_diag_fx[i]; + move32(); + limit_e = Cy_hat_diag_e; + move16(); } } - limit = limit * reg_ghat + EPSILON; - + L_tmp = Mpy_32_32(limit_fx, reg_ghat_fx); + limit_fx = L_add(L_tmp, EPSILON_FX); + limit_e = limit_e + reg_ghat_e; + /* Computing G_hat */ - for ( i = 0; i < lengthCy; ++i ) + FOR ( i = 0; i < lengthCy; ++i ) { - if ( limit > Cy_hat_diag[i] ) /* Computing Cy_hat_diag = max(Cy_hat_diag,limit) */ + Cy_hat_diag_fx_e[i] = Cy_hat_diag_e; + IF ( BASOP_Util_Cmp_Mant32Exp(limit_fx, limit_e, Cy_hat_diag_fx[i], Cy_hat_diag_e ) > 0 ) /* Computing Cy_hat_diag = max(Cy_hat_diag,limit) */ { - Cy_hat_diag[i] = limit; + Cy_hat_diag_fx[i] = limit_fx; + move32(); + Cy_hat_diag_fx_e[i] = limit_e; + move16(); } - G_hat[i] = sqrtf( Cy[i + i * lengthCy] / Cy_hat_diag[i] ); + tmp = BASOP_Util_Divide3232_Scale(Cy_fx[i + i * lengthCy], Cy_hat_diag_fx[i], &scale ); + scale = scale + (Cy_fx_e - Cy_hat_diag_fx_e[i]); + L_tmp = Sqrt32(L_deposit_h(tmp), &scale); + + G_hat_fx[i] = L_tmp; + move32(); + G_hat_e[i] = scale; + move16(); } /*-----------------------------------------------------------------* * Formulate optimal P *-----------------------------------------------------------------*/ - for ( i = 0; i < num_outputs; i++ ) + FOR ( i = 0; i < num_outputs; i++ ) { - Kx[i] *= G_hat[i]; + L_tmp = Mpy_32_32( Kx_fx[i], G_hat_fx[i] ); + Kx_fx[i] = L_tmp; + Kx_fx_e[i] = Kx_fx_e[i] + G_hat_e[i]; } - for ( i = 0; i < num_outputs; i++ ) + FOR ( i = 0; i < num_outputs; i++ ) { - float fac = Kx[i]; + Word32 fac_fx = Kx_fx[i]; - for ( j = 0; j < num_outputs; j++ ) + FOR ( j = 0; j < num_outputs; j++ ) { - mat_mult_buffer1[i + j * num_outputs] = Ky[i + j * num_outputs] * fac; + L_tmp = Mpy_32_32(Ky_fx[i + j * num_outputs], fac_fx); + mat_mult_buffer1_fx[i + j * num_outputs] = L_tmp; + mat_mult_buffer1_buff_e[i + j * num_outputs] = L_add( Ky_fx_e[i + j * num_outputs], Kx_fx_e[i] ); } } -#ifdef IVAS_FLOAT_FIXED - f2me_buf( mat_mult_buffer1, mat_mult_buffer1_fx, &mat_mult_buffer1_fx_e, lengthCx * lengthCy ); + mat_mult_buffer1_e = mat_mult_buffer1_buff_e[0]; + move16(); + FOR (i = 1; i < num_outputs * num_outputs; i++) + { + IF (mat_mult_buffer1_e < mat_mult_buffer1_buff_e[i]) + mat_mult_buffer1_e = mat_mult_buffer1_buff_e[i]; + } + + FOR (i = 0; i < num_outputs * num_outputs; i++) + { + mat_mult_buffer1_fx[i] = L_shr(mat_mult_buffer1_fx[i], mat_mult_buffer1_e - mat_mult_buffer1_buff_e[i]); + } + mat2svdMat_fx( mat_mult_buffer1_fx, svd_in_buffer_fx, lengthCx, lengthCy, 0 ); FOR ( Word32 g = 0; g < lengthCx; g++ ) { - me2f_buf( ( svd_in_buffer_fx[g] ), mat_mult_buffer1_fx_e, ( svd_in_buffer[g] ), lengthCy ); + me2f_buf( ( svd_in_buffer_fx[g] ), mat_mult_buffer1_e, ( svd_in_buffer[g] ), lengthCy ); } -#else - mat2svdMat( mat_mult_buffer1, svd_in_buffer, lengthCx, lengthCy, 0 ); -#endif - +#ifdef IVAS_FLOAT_FIXED_TO_BE_REMOVED svd( svd_in_buffer, svd_u_buffer, svd_s_buffer, svd_v_buffer, lengthCx, lengthCy ); /* Actually Processing P */ - -#ifdef IVAS_FLOAT_FIXED Word16 min_q = -1; FOR ( Word32 g = 0; g < lengthCy; g++ ) { @@ -1683,12 +2581,14 @@ int16_t computeMixingMatricesResidual( svd_v_buffer_fx_e[0] = min_q; min_q = -1; + move16(); FOR ( Word32 g = 0; g < lengthCx; g++ ) { f2me_buf( svd_u_buffer[g], svd_u_buffer_fx[g], &svd_u_buffer_fx_e[g], lengthCx ); IF ( svd_u_buffer_fx_e[g] > min_q ) { min_q = svd_u_buffer_fx_e[g]; + move16(); } } @@ -1700,33 +2600,58 @@ int16_t computeMixingMatricesResidual( } } svd_u_buffer_fx_e[0] = min_q; - + move16(); +#endif svdMat2mat_fx( svd_v_buffer_fx, mat_mult_buffer1_fx, lengthCy, lengthCx ); svdMat2mat_fx( svd_u_buffer_fx, mat_mult_buffer2_fx, lengthCx, lengthCx ); + mat_mult_buffer2_e = svd_u_buffer_fx_e[0]; + move16(); + mat_mult_buffer1_e = svd_v_buffer_fx_e[0]; + move16(); - me2f_buf( mat_mult_buffer1_fx, svd_v_buffer_fx_e[0], mat_mult_buffer1, lengthCy * lengthCx ); - me2f_buf( mat_mult_buffer2_fx, svd_u_buffer_fx_e[0], mat_mult_buffer2, lengthCx * lengthCx ); -#else - svdMat2mat( svd_v_buffer, mat_mult_buffer1, lengthCy, lengthCx ); - svdMat2mat( svd_u_buffer, mat_mult_buffer2, lengthCx, lengthCx ); -#endif - matrix_product( mat_mult_buffer1, lengthCy, lengthCx, 0, - mat_mult_buffer2, lengthCx, lengthCx, 1, - mat_mult_buffer3 ); + Word16 guard_bits = find_guarded_bits_fx( lengthCx + 1 ); + + FOR ( i = 0; i < lengthCy * lengthCx; ++i ) + { + IF ( mat_mult_buffer1_e > mat_mult_buffer2_e ) + { + mat_mult_buffer2_fx[i] = L_shr(mat_mult_buffer2_fx[i], guard_bits ); + } + ELSE + { + mat_mult_buffer1_fx[i] = L_shr(mat_mult_buffer1_fx[i], guard_bits ); + } + } + + IF ( mat_mult_buffer1_e > mat_mult_buffer2_e ) + { + mat_mult_buffer2_e += guard_bits; + } + ELSE + { + mat_mult_buffer1_e += guard_bits; + } + matrix_product_fx( mat_mult_buffer1_fx, lengthCy, lengthCx, 0, + mat_mult_buffer2_fx, lengthCx, lengthCx, 1, + mat_mult_buffer3_fx ); + mat_mult_buffer3_e = svd_v_buffer_fx_e[0] + svd_u_buffer_fx_e[0]; /*-----------------------------------------------------------------* * Formulate M *-----------------------------------------------------------------*/ - matrix_product( Ky, lengthCy, lengthCy, 0, mat_mult_buffer3, lengthCy, lengthCx, 0, mat_mult_buffer1 ); + matrix_product_fx( Ky_fx, lengthCy, lengthCy, 0, mat_mult_buffer3_fx, lengthCy, lengthCx, 0, mat_mult_buffer1_fx ); + mat_mult_buffer1_e = Ky_fx_e[0] + mat_mult_buffer3_e; - for ( i = 0; i < num_outputs; i++ ) + FOR ( i = 0; i < num_outputs; i++ ) { - float fac = Kx_reg_inv[i]; + Word32 fac_fx = Kx_reg_inv_fx[i]; - for ( j = 0; j < num_outputs; j++ ) + FOR ( j = 0; j < num_outputs; j++ ) { - mixing_matrix[j + i * num_outputs] = mat_mult_buffer1[j + i * num_outputs] * fac; + L_tmp = Mpy_32_32( mat_mult_buffer1_fx[j + i * num_outputs], fac_fx ); + mixing_matrix_fx[j + i * num_outputs] = L_tmp; + mixing_matrix_e = mat_mult_buffer1_e + Kx_reg_inv_fx_e; } } @@ -1735,79 +2660,80 @@ int16_t computeMixingMatricesResidual( *-----------------------------------------------------------------*/ /* Compute Cy_tilde = M*Cx*M' */ -#ifdef IVAS_FLOAT_FIXED - Word32 Cy_tilde_fx[MAX_OUTPUT_CHANNELS]; - Word16 Cy_tilde_e; - - f2me_buf( mixing_matrix, mixing_matrix_fx, &mixing_matrix_e, lengthCy * lengthCx ); - f2me_buf( Cx, Cx_fx, &Cx_e, lengthCx ); matrix_diag_product_fx( mixing_matrix_fx, mixing_matrix_e, lengthCy, lengthCx, 0, Cx_fx, Cx_e, lengthCx, mat_mult_buffer1_fx, &mat_mult_buffer1_e ); - Word16 guard_bits = find_guarded_bits_fx( lengthCx + 1 ); + guard_bits = find_guarded_bits_fx( lengthCx + 1 ); - for ( i = 0; i < lengthCy * lengthCx; ++i ) + FOR ( i = 0; i < lengthCy * lengthCx; ++i ) { - if ( mat_mult_buffer1_e > mixing_matrix_e ) + IF ( mat_mult_buffer1_e > mixing_matrix_e ) { mixing_matrix_fx[i] = L_shr( mixing_matrix_fx[i], guard_bits ); } - else + ELSE { mat_mult_buffer1_fx[i] = L_shr( mat_mult_buffer1_fx[i], guard_bits ); } } - if ( mat_mult_buffer1_e > mixing_matrix_e ) + IF ( mat_mult_buffer1_e > mixing_matrix_e ) { mixing_matrix_e += guard_bits; } - else + ELSE { mat_mult_buffer1_e += guard_bits; } matrix_product_diag_fx( mat_mult_buffer1_fx, mat_mult_buffer1_e, lengthCy, lengthCx, 0, mixing_matrix_fx, mixing_matrix_e, lengthCy, lengthCx, 1, Cy_tilde_fx, &Cy_tilde_e ); - me2f_buf( Cy_tilde_fx, Cy_tilde_e, Cy_tilde, lengthCy ); -#else - matrix_diag_product( mixing_matrix, lengthCy, lengthCx, 0, Cx, lengthCx, mat_mult_buffer1 ); - matrix_product_diag( mat_mult_buffer1, lengthCy, lengthCx, 0, mixing_matrix, lengthCy, lengthCx, 1, Cy_tilde ); -#endif - - /*-----------------------------------------------------------------* * Energy Compensation *-----------------------------------------------------------------*/ - adj = svd_s_buffer; + adj_fx_p = svd_s_buffer_fx; - for ( i = 0; i < lengthCy; ++i ) + FOR ( i = 0; i < lengthCy; ++i ) { - adj[i] = sqrtf( Cy[i + lengthCy * i] / ( Cy_tilde[i] + EPSILON ) ); - if ( adj[i] > 4.0f ) + tmp = BASOP_Util_Divide3232_Scale(Cy_fx[i + lengthCy * i], L_add(Cy_tilde_fx[i], EPSILON_FX), &scale); + scale = scale + ( Cy_fx_e - Cy_tilde_e ); + adj_fx_p[i] = Sqrt32(L_deposit_h(tmp), &scale ); + adj_buff_e[i] = scale; + IF ( BASOP_Util_Cmp_Mant32Exp( adj_fx_p[i], scale, 1073741824, 3 ) > 0 ) { - adj[i] = 4.0f; + adj_fx_p[i] = 1073741824; + move32(); + adj_buff_e[i] = 3; + move16(); } } -#ifdef IVAS_FLOAT_FIXED - f2me_buf( adj, adj_fx, &adj_e, lengthCy ); - f2me_buf( mixing_matrix, mixing_matrix_fx, &mixing_matrix_e, lengthCy * lengthCx ); + adj_e = adj_buff_e[0]; - diag_matrix_product_fx( adj_fx, adj_e, lengthCy, mixing_matrix_fx, mixing_matrix_e, lengthCy, lengthCx, 0, mat_mult_buffer3_fx, &mat_mult_buffer3_e ); + FOR (i = 1; i < lengthCy; i++) + { + IF (adj_e < adj_buff_e[i]) + adj_e = adj_buff_e[i]; + } - me2f_buf( mat_mult_buffer3_fx, mat_mult_buffer3_e, mat_mult_buffer3, lengthCx * lengthCy ); -#else - diag_matrix_product( adj, lengthCy, mixing_matrix, lengthCy, lengthCx, 0, mat_mult_buffer3 ); -#endif - mvr2r( mat_mult_buffer3, mixing_matrix, lengthCy * lengthCx ); + FOR (i = 0; i < lengthCy; i++) + { + adj_fx[i] = L_shr(adj_fx_p[i], adj_e - adj_buff_e[i]); + } + + diag_matrix_product_fx( adj_fx, adj_e, lengthCy, mixing_matrix_fx, mixing_matrix_e, lengthCy, lengthCx, 0, mat_mult_buffer3_fx, &mat_mult_buffer3_e ); + Copy32(mat_mult_buffer3_fx, mixing_matrix_fx, lengthCy * lengthCx); + *mixing_matrix_ret_e = mat_mult_buffer3_e; + move16(); pop_wmops(); return out; } +#endif + /*-------------------------------------------------------------------* diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index d683d65aa..cdd62ba9f 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -222,6 +222,110 @@ ivas_error ivas_dec_setup( { #ifdef IVAS_FLOAT_FIXED + Word16 n_samples_granularity; + + n_samples_granularity = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); + DECODER_TC_BUFFER_HANDLE hTcBuffer; + hTcBuffer = st_ivas->hTcBuffer; + DECODER_CONFIG_HANDLE hDecoderConfig=NULL; + Word16 numch_out_dirac=0; + SPAR_DEC_HANDLE hSpar = NULL; + Word16 numch_in, numch_out, num_md_sub_frames, q1 = 30, q2 = 30; + IF( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) || EQ_16( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) ) + { + IF( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) && NE_16( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) ) + { + IF( LT_16( n_samples_granularity, st_ivas->hTcBuffer->n_samples_granularity ) ) + { + + IF( st_ivas->hCombinedOrientationData ) + FOR( Word16 ind1 = 0; ind1 < 3; ind1++ ) + { + FOR( Word16 ind2 = 0; ind2 < 3; ind2++ ) + { + st_ivas->hCombinedOrientationData->Rmat_fx[0][ind1][ind2] = (Word32) ( st_ivas->hCombinedOrientationData->Rmat[0][ind1][ind2] * ( 1 << 15 ) ); + } + } + if ( st_ivas->hSbaIsmData ) + { + for ( Word16 ch_idx = 0; ch_idx < st_ivas->hSbaIsmData->delayBuffer_nchan; ch_idx++ ) + { + floatToFixed_arr32( st_ivas->hSbaIsmData->delayBuffer[ch_idx], st_ivas->hSbaIsmData->delayBuffer_fx[ch_idx], Q11, st_ivas->hSbaIsmData->delayBuffer_size ); + } + } + hSpar = st_ivas->hSpar; + uint16_t nchan_internal; + nchan_internal = ivas_sba_get_nchan_metadata( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); + hDecoderConfig = st_ivas->hDecoderConfig; + numch_out_dirac = hDecoderConfig->nchan_out; + IF( hSpar ) + { + numch_out = hSpar->hFbMixer->fb_cfg->num_out_chans; + numch_in = hSpar->hFbMixer->fb_cfg->num_in_chans; + num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ); + + for ( int l = 0; l < numch_out; l++ ) + { + for ( int j = 0; j < numch_in; j++ ) + { + for ( int n = 0; n < num_md_sub_frames * IVAS_MAX_NUM_BANDS; n++ ) + { + hSpar->hMdDec->mixer_mat_fx[l][j][n] = floatToFixed( hSpar->hMdDec->mixer_mat[l][j][n], q1 ); + } + } + } + for ( int m = 0; m < MAX_PARAM_SPATIAL_SUBFRAMES + 1; m++ ) + { + for ( int j = 0; j < IVAS_MAX_FB_MIXER_OUT_CH; j++ ) + { + for (int n = 0; n < IVAS_MAX_SPAR_FB_MIXER_IN_CH; n++ ) + { + for ( int l = 0; l < IVAS_MAX_NUM_BANDS; l++ ) + { + hSpar->hMdDec->mixer_mat_prev_fx[m][j][n][l] = floatToFixed( hSpar->hMdDec->mixer_mat_prev[m][j][n][l], q2 ); + } + } + } + } + for ( Word16 in_ch = 0; in_ch < numch_in; in_ch++ ) + { + for ( Word16 i = 0; i < st_ivas->cldfbAnaDec[in_ch]->p_filter_length - st_ivas->cldfbAnaDec[in_ch]->no_channels; i++ ) + { + st_ivas->cldfbAnaDec[in_ch]->cldfb_state_fx[i] = (Word32) ( st_ivas->cldfbAnaDec[in_ch]->cldfb_state[i] * ( 1LL << ( Q11 ) ) ); + } + } + if ( ( hDecoderConfig->ivas_total_brate < IVAS_24k4 ) && ( ( hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_HOA2 ) || ( hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_HOA3 ) ) ) + { + for ( Word16 i = 0; i < IVAS_MAX_NUM_BANDS; i++ ) + { + floatToFixed_arrL( hSpar->hMdDec->smooth_buf[i], hSpar->hMdDec->smooth_buf_fx[i], 0, 2 * SBA_DIRAC_NRG_SMOOTH_LONG + 1 ); + } + floatToFixed_arr( hSpar->hMdDec->smooth_fac, hSpar->hMdDec->smooth_fac_fx, Q15, IVAS_MAX_NUM_BANDS ); + } + FOR( Word16 out_ch = 0; out_ch < numch_out_dirac; out_ch++ ) + { + IF( st_ivas->cldfbSynDec[out_ch] ) + { + FOR( Word16 i = 0; i < st_ivas->cldfbSynDec[out_ch]->p_filter_length; i++ ) + { + st_ivas->cldfbSynDec[out_ch]->cldfb_state_fx[i] = float_to_fix( st_ivas->cldfbSynDec[out_ch]->cldfb_state[i], Q11 ); + } + } + } + } + Word16 n_tc; + if ( st_ivas->ivas_format == MASA_ISM_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) + n_tc = st_ivas->nchan_ism; + else + n_tc = st_ivas->hTcBuffer->nchan_transport_internal; + for ( int ch = 0; ch < n_tc; ch++ ) + { + floatToFixed_arrL( st_ivas->hTcBuffer->tc[ch], st_ivas->hTcBuffer->tc_fx[ch], Q11, L_FRAME48k ); + } + } + } + } + IF ( ( error = ivas_masa_dec_reconfigure_fx( st_ivas, nSamplesRendered, data ) ) != IVAS_ERR_OK ) #else IF ( ( error = ivas_masa_dec_reconfigure( st_ivas, nSamplesRendered, data ) ) != IVAS_ERR_OK ) @@ -229,6 +333,56 @@ ivas_error ivas_dec_setup( { return error; } +#ifdef IVAS_FLOAT_FIXED + //local flt2fix: to be removed + if (hTcBuffer->tc_buffer) + fixedToFloat_arrL(hTcBuffer->tc_buffer_fx, hTcBuffer->tc_buffer, Q11, hTcBuffer->tc_buff_len); + IF(hSpar) + { + numch_in = hSpar->hFbMixer->fb_cfg->num_in_chans; + FOR(Word16 in_ch = 0; in_ch < numch_in; in_ch++) + { + FOR(Word16 i = 0; i < st_ivas->cldfbAnaDec[in_ch]->p_filter_length - st_ivas->cldfbAnaDec[in_ch]->no_channels; i++) + { + st_ivas->cldfbAnaDec[in_ch]->cldfb_state[i] = ((float)(st_ivas->cldfbAnaDec[in_ch]->cldfb_state_fx[i]) / (1LL << (Q11))); /*Rounding off*/ + } + } + FOR(int m = 0; m < MAX_PARAM_SPATIAL_SUBFRAMES + 1; m++) + { + FOR(int j = 0; j < IVAS_MAX_FB_MIXER_OUT_CH; j++) + { + FOR(int n = 0; n < IVAS_MAX_SPAR_FB_MIXER_IN_CH; n++) + { + FOR(int l = 0; l < IVAS_MAX_NUM_BANDS; l++) + { + hSpar->hMdDec->mixer_mat_prev[m][j][n][l] = ((float)hSpar->hMdDec->mixer_mat_prev_fx[m][j][n][l] / (1 << q2)); + } + } + } + } + // fix2float (to be cleaned) + IF((LT_32(hDecoderConfig->ivas_total_brate, IVAS_24k4)) && ((EQ_16(hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_HOA2)) || (EQ_16(hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_HOA3)))) + { + fixedToFloat_arr(hSpar->hMdDec->smooth_fac_fx, hSpar->hMdDec->smooth_fac, Q15, IVAS_MAX_NUM_BANDS); + FOR(Word16 i = 0; i < IVAS_MAX_NUM_BANDS; i++) + { + fixedToFloat_arrL(hSpar->hMdDec->smooth_buf_fx[i], hSpar->hMdDec->smooth_buf[i], 0, 2 * SBA_DIRAC_NRG_SMOOTH_LONG + 1); + } + } + // fix2float end + FOR(Word16 out_ch = 0; out_ch < numch_out_dirac; out_ch++) + { + IF(st_ivas->cldfbSynDec[out_ch]) + { + FOR(Word16 i = 0; i < st_ivas->cldfbSynDec[out_ch]->p_filter_length; i++) + { + st_ivas->cldfbSynDec[out_ch]->cldfb_state[i] = ((float)(st_ivas->cldfbSynDec[out_ch]->cldfb_state_fx[i]) / (float)(1LL << (Q11))); + } + } + } + } + //local fix2flt end +#endif } } ELSE diff --git a/lib_dec/ivas_ism_dec.c b/lib_dec/ivas_ism_dec.c index 94f4718d8..c56520a7a 100644 --- a/lib_dec/ivas_ism_dec.c +++ b/lib_dec/ivas_ism_dec.c @@ -479,14 +479,6 @@ static ivas_error ivas_ism_bitrate_switching_dec( #if 1 /*Float to fixed conversion*/ DECODER_TC_BUFFER_HANDLE hTcBuffer; hTcBuffer = st_ivas->hTcBuffer; - FOR( Word16 ind1 = 0; ind1 < MAX_NUM_OBJECTS; ind1++ ) - { - if ( st_ivas->hIsmMetaData[ind1] ) - { - st_ivas->hIsmMetaData[ind1]->azimuth_fx = (Word32) ( st_ivas->hIsmMetaData[ind1]->azimuth * ( 1 << 22 ) ); - st_ivas->hIsmMetaData[ind1]->elevation_fx = (Word32) ( st_ivas->hIsmMetaData[ind1]->elevation * ( 1 << 22 ) ); - } - } IF( st_ivas->hCombinedOrientationData ) FOR( Word16 ind1 = 0; ind1 < 3; ind1++ ) { @@ -626,14 +618,6 @@ static ivas_error ivas_ism_bitrate_switching_dec( } } } - FOR( Word16 ind1 = 0; ind1 < MAX_NUM_OBJECTS; ind1++ ) - { - if ( st_ivas->hIsmMetaData[ind1] ) - { - st_ivas->hIsmMetaData[ind1]->azimuth = (float) ( st_ivas->hIsmMetaData[ind1]->azimuth_fx ) / (float) ( 1 << 22 ); - st_ivas->hIsmMetaData[ind1]->elevation = (float) ( st_ivas->hIsmMetaData[ind1]->elevation_fx ) / (float) ( 1 << 22 ); - } - } #endif } diff --git a/lib_dec/ivas_ism_metadata_dec.c b/lib_dec/ivas_ism_metadata_dec.c index f983c974f..918f8eb7f 100644 --- a/lib_dec/ivas_ism_metadata_dec.c +++ b/lib_dec/ivas_ism_metadata_dec.c @@ -74,6 +74,7 @@ static int16_t decode_radius( DEC_CORE_HANDLE st0, int16_t *last_radius_idx, int * * Smooth the metadata evolution *-------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED static void ism_metadata_smooth( ISM_METADATA_HANDLE hIsmMeta[], /* i/o: ISM metadata handles */ @@ -136,7 +137,7 @@ static void ism_metadata_smooth( return; } -#ifdef IVAS_FLOAT_FIXED +#else static void ism_metadata_smooth_fx( ISM_METADATA_HANDLE hIsmMeta[], /* i/o: ISM metadata handles */ const Word32 ism_total_brate, /* i : ISms total bitrate */ @@ -205,7 +206,7 @@ static void ism_metadata_smooth_fx( * * decode and dequantize ISM metadata *-------------------------------------------------------------------------*/ - +#ifndef IVAS_FLOAT_FIXED ivas_error ivas_ism_metadata_dec( const int32_t ism_total_brate, /* i : ISM total bitrate */ const int16_t nchan_ism, /* i : number of ISM channels */ @@ -721,7 +722,7 @@ ivas_error ivas_ism_metadata_dec( return IVAS_ERR_OK; } -#ifdef IVAS_FLOAT_FIXED +#else ivas_error ivas_ism_metadata_dec_fx( const Word32 ism_total_brate, /* i : ISM total bitrate */ const Word16 nchan_ism, /* i : number of ISM channels */ diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index e87f2d96e..953792c7b 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -1618,7 +1618,7 @@ void ivas_ism_dec_digest_tc_fx( IF( st_ivas->intern_config == IVAS_AUDIO_CONFIG_STEREO ) { Word16 gains_fx[2]; - ivas_ism_get_stereo_gains_fx( (Word16) st_ivas->hIsmMetaData[i]->azimuth, (Word16) st_ivas->hIsmMetaData[i]->elevation, &gains_fx[0], &gains_fx[1] ); + ivas_ism_get_stereo_gains_fx( (Word16) L_shr(st_ivas->hIsmMetaData[i]->azimuth_fx, 22), (Word16) L_shr(st_ivas->hIsmMetaData[i]->elevation_fx,22), &gains_fx[0], &gains_fx[1] ); st_ivas->hIsmRendererData->gains_fx[i][0] = L_shr( L_deposit_h( gains_fx[0] ), 1 ); move32(); st_ivas->hIsmRendererData->gains_fx[i][1] = L_shr( L_deposit_h( gains_fx[1] ), 1 ); diff --git a/lib_dec/ivas_ism_renderer.c b/lib_dec/ivas_ism_renderer.c index f6a08c7e0..d9e80e09a 100644 --- a/lib_dec/ivas_ism_renderer.c +++ b/lib_dec/ivas_ism_renderer.c @@ -52,6 +52,7 @@ * Open struct for object rendering, reserve memory, and init values. *-------------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED ivas_error ivas_ism_renderer_open( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ) @@ -111,7 +112,7 @@ ivas_error ivas_ism_renderer_open( return IVAS_ERR_OK; } -#ifdef IVAS_FLOAT_FIXED +#else ivas_error ivas_ism_renderer_open_fx( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ) @@ -227,7 +228,7 @@ void ivas_ism_renderer_close( * * Object rendering process *-------------------------------------------------------------------------*/ - +#ifndef IVAS_FLOAT_FIXED void ivas_ism_render_sf( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ float *output_f[], /* i/o: core-coder transport channels/object output */ @@ -288,7 +289,6 @@ void ivas_ism_render_sf( if ( st_ivas->hCombinedOrientationData != NULL && st_ivas->hCombinedOrientationData->enableCombinedOrientation[st_ivas->hCombinedOrientationData->subframe_idx] == 1 ) { rotateAziEle( st_ivas->hIsmMetaData[i]->azimuth, st_ivas->hIsmMetaData[i]->elevation, &azimuth, &elevation, st_ivas->hCombinedOrientationData->Rmat[0], st_ivas->hIntSetup.is_planar_setup ); - if ( st_ivas->hEFAPdata != NULL ) { #ifdef IVAS_FLOAT_FIXED @@ -355,7 +355,7 @@ void ivas_ism_render_sf( return; } -#ifdef IVAS_FLOAT_FIXED +#else void ivas_ism_render_sf_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ Word32 *output_fx[], /* i/o: core-coder transport channels/object output */ @@ -688,7 +688,7 @@ ivas_error ivas_omasa_separate_object_renderer_open( { st_ivas->hIsmRendererData->interpolator_fx[i] = div_s(i, interpolator_length); } - st_ivas->hIsmRendererData->interpolator_length = interpolator_length; + st_ivas->hIsmRendererData->interpolator_len = interpolator_length; move16(); st_ivas->hMasaIsmData->delayBuffer_size = (Word16) ( ( st_ivas->hDecoderConfig->output_Fs / 50 ) / MAX_PARAM_SPATIAL_SUBFRAMES ); @@ -1061,13 +1061,13 @@ void ivas_omasa_separate_object_render_jbm_fx( FOR ( subframe_idx = first_sf; subframe_idx < last_sf; subframe_idx++ ) { n_samples_sf = i_mult(hSpatParamRendCom->subframe_nbslots[subframe_idx], hSpatParamRendCom->slot_size); - IF ( n_samples_sf != hRendererData->interpolator_length ) + IF ( n_samples_sf != hRendererData->interpolator_len ) { FOR ( k = 0; k < n_samples_sf; k++ ) { hRendererData->interpolator_fx[k] = div_s( k, n_samples_sf ); } - hRendererData->interpolator_length = n_samples_sf; + hRendererData->interpolator_len = n_samples_sf; move16(); } diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 9a8c961bd..c8a232407 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -222,15 +222,10 @@ ivas_error ivas_jbm_dec_tc( #if 1 // Float to fix FOR( Word16 ind = 0; ind < st_ivas->nchan_ism; ind++ ) { - st_ivas->hIsmMetaData[ind]->azimuth_fx = (Word32) ( st_ivas->hIsmMetaData[ind]->azimuth * ( 1 << 22 ) ); - st_ivas->hIsmMetaData[ind]->elevation_fx = (Word32) ( st_ivas->hIsmMetaData[ind]->elevation * ( 1 << 22 ) ); st_ivas->hIsmMetaData[ind]->last_azimuth_fx = (Word32) ( st_ivas->hIsmMetaData[ind]->last_azimuth * ( 1 << 22 ) ); st_ivas->hIsmMetaData[ind]->last_elevation_fx = (Word32) ( st_ivas->hIsmMetaData[ind]->last_elevation * ( 1 << 22 ) ); st_ivas->hIsmMetaData[ind]->last_true_azimuth_fx = (Word32) ( st_ivas->hIsmMetaData[ind]->last_true_azimuth * ( 1 << 22 ) ); st_ivas->hIsmMetaData[ind]->last_true_elevation_fx = (Word32) ( st_ivas->hIsmMetaData[ind]->last_true_elevation * ( 1 << 22 ) ); - st_ivas->hIsmMetaData[ind]->radius_fx = (Word16) ( st_ivas->hIsmMetaData[ind]->radius * ( 1 << 9 ) ); - st_ivas->hIsmMetaData[ind]->yaw_fx = (Word32) ( st_ivas->hIsmMetaData[ind]->yaw * ( 1 << 22 ) ); - st_ivas->hIsmMetaData[ind]->pitch_fx = (Word32) ( st_ivas->hIsmMetaData[ind]->pitch * ( 1 << 22 ) ); } #endif /* Metadata decoding and configuration */ @@ -292,15 +287,10 @@ ivas_error ivas_jbm_dec_tc( #if 1 // fix to float FOR( Word16 ind = 0; ind < st_ivas->nchan_ism; ind++ ) { - st_ivas->hIsmMetaData[ind]->azimuth = (float) ( st_ivas->hIsmMetaData[ind]->azimuth_fx ) / (float) ( 1 << 22 ); - st_ivas->hIsmMetaData[ind]->elevation = (float) ( st_ivas->hIsmMetaData[ind]->elevation_fx ) / (float) ( 1 << 22 ); st_ivas->hIsmMetaData[ind]->last_azimuth = (float) ( st_ivas->hIsmMetaData[ind]->last_azimuth_fx ) / (float) ( 1 << 22 ); st_ivas->hIsmMetaData[ind]->last_elevation = (float) ( st_ivas->hIsmMetaData[ind]->last_elevation_fx ) / (float) ( 1 << 22 ); st_ivas->hIsmMetaData[ind]->last_true_azimuth = (float) ( st_ivas->hIsmMetaData[ind]->last_true_azimuth_fx ) / (float) ( 1 << 22 ); st_ivas->hIsmMetaData[ind]->last_true_elevation = (float) ( st_ivas->hIsmMetaData[ind]->last_true_elevation_fx ) / (float) ( 1 << 22 ); - st_ivas->hIsmMetaData[ind]->radius = (float) ( st_ivas->hIsmMetaData[ind]->radius_fx ) / (float) ( 1 << 9 ); - st_ivas->hIsmMetaData[ind]->yaw = (float) ( st_ivas->hIsmMetaData[ind]->yaw_fx ) / (float) ( 1 << 22 ); - st_ivas->hIsmMetaData[ind]->pitch = (float) ( st_ivas->hIsmMetaData[ind]->pitch_fx ) / (float) ( 1 << 22 ); } #endif @@ -1292,15 +1282,10 @@ ivas_error ivas_jbm_dec_tc( } FOR( Word16 ind = 0; ind < tmp_nchan_ism; ind++ ) { - st_ivas->hIsmMetaData[ind]->azimuth_fx = (Word32) ( st_ivas->hIsmMetaData[ind]->azimuth * ( 1 << 22 ) ); - st_ivas->hIsmMetaData[ind]->elevation_fx = (Word32) ( st_ivas->hIsmMetaData[ind]->elevation * ( 1 << 22 ) ); st_ivas->hIsmMetaData[ind]->last_azimuth_fx = (Word32) ( st_ivas->hIsmMetaData[ind]->last_azimuth * ( 1 << 22 ) ); st_ivas->hIsmMetaData[ind]->last_elevation_fx = (Word32) ( st_ivas->hIsmMetaData[ind]->last_elevation * ( 1 << 22 ) ); st_ivas->hIsmMetaData[ind]->last_true_azimuth_fx = (Word32) ( st_ivas->hIsmMetaData[ind]->last_true_azimuth * ( 1 << 22 ) ); st_ivas->hIsmMetaData[ind]->last_true_elevation_fx = (Word32) ( st_ivas->hIsmMetaData[ind]->last_true_elevation * ( 1 << 22 ) ); - st_ivas->hIsmMetaData[ind]->radius_fx = (Word16) ( st_ivas->hIsmMetaData[ind]->radius * ( 1 << 9 ) ); - st_ivas->hIsmMetaData[ind]->yaw_fx = (Word32) ( st_ivas->hIsmMetaData[ind]->yaw * ( 1 << 22 ) ); - st_ivas->hIsmMetaData[ind]->pitch_fx = (Word32) ( st_ivas->hIsmMetaData[ind]->pitch * ( 1 << 22 ) ); } FOR( n = 0; n < tmp_nchan_ism; n++ ) { @@ -1435,15 +1420,10 @@ ivas_error ivas_jbm_dec_tc( } FOR( Word16 ind = 0; ind < tmp_nchan_ism; ind++ ) { - st_ivas->hIsmMetaData[ind]->azimuth = (float) ( st_ivas->hIsmMetaData[ind]->azimuth_fx ) / (float) ( 1 << 22 ); - st_ivas->hIsmMetaData[ind]->elevation = (float) ( st_ivas->hIsmMetaData[ind]->elevation_fx ) / (float) ( 1 << 22 ); st_ivas->hIsmMetaData[ind]->last_azimuth = (float) ( st_ivas->hIsmMetaData[ind]->last_azimuth_fx ) / (float) ( 1 << 22 ); st_ivas->hIsmMetaData[ind]->last_elevation = (float) ( st_ivas->hIsmMetaData[ind]->last_elevation_fx ) / (float) ( 1 << 22 ); st_ivas->hIsmMetaData[ind]->last_true_azimuth = (float) ( st_ivas->hIsmMetaData[ind]->last_true_azimuth_fx ) / (float) ( 1 << 22 ); st_ivas->hIsmMetaData[ind]->last_true_elevation = (float) ( st_ivas->hIsmMetaData[ind]->last_true_elevation_fx ) / (float) ( 1 << 22 ); - st_ivas->hIsmMetaData[ind]->radius = (float) ( st_ivas->hIsmMetaData[ind]->radius_fx ) / (float) ( 1 << 9 ); - st_ivas->hIsmMetaData[ind]->yaw = (float) ( st_ivas->hIsmMetaData[ind]->yaw_fx ) / (float) ( 1 << 22 ); - st_ivas->hIsmMetaData[ind]->pitch = (float) ( st_ivas->hIsmMetaData[ind]->pitch_fx ) / (float) ( 1 << 22 ); } IF( NE_16( output_q, Q11 ) ) { @@ -1464,10 +1444,17 @@ ivas_error ivas_jbm_dec_tc( IF( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { /* set ISM parameters and decode ISM metadata in OSBA format */ - IF( ( error = ivas_osba_ism_metadata_dec( st_ivas, ivas_total_brate, &nchan_ism, &nb_bits_metadata[1] ) ) != IVAS_ERR_OK ) +#ifdef IVAS_FLOAT_FIXED + IF((error = ivas_osba_ism_metadata_dec_fx(st_ivas, ivas_total_brate, &nchan_ism, &nb_bits_metadata[1])) != IVAS_ERR_OK) + { + return error; + } +#else + if ( ( error = ivas_osba_ism_metadata_dec( st_ivas, ivas_total_brate, &nchan_ism, &nb_bits_metadata[1] ) ) != IVAS_ERR_OK ) { return error; } +#endif sba_ch_idx = st_ivas->nchan_ism; } ELSE @@ -4433,7 +4420,7 @@ void ivas_jbm_dec_feed_tc_to_renderer( float *data /* i : transport channels */ ) { - float data_f[MAX_CLDFB_DIGEST_CHANNELS][MAX_JBM_L_FRAME48k]; /* 'float' buffer for transport channels that will be directly converted with the CLDFB */ + float data_f[MAX_CLDFB_DIGEST_CHANNELS][MAX_JBM_L_FRAME48k] = { 0 }; /* 'float' buffer for transport channels that will be directly converted with the CLDFB */ float *p_data_f[MAX_CLDFB_DIGEST_CHANNELS]; int16_t n, n_render_timeslots, i; @@ -5494,7 +5481,105 @@ void ivas_jbm_dec_feed_tc_to_renderer( } else if ( st_ivas->mc_mode == MC_MODE_PARAMMC ) { +#ifdef IVAS_FLOAT_FIXED + Word16 cldfb_slots, i, j; + Word32 p_data_f_fx[MAX_CLDFB_DIGEST_CHANNELS][MAX_JBM_L_FRAME48k]; /* 'float' buffer for transport channels that will be directly converted with the CLDFB */ + cldfb_slots = DEFAULT_JBM_CLDFB_TIMESLOTS; + if (st_ivas->hDecoderConfig->Opt_tsm) + { + cldfb_slots = MAX_JBM_CLDFB_TIMESLOTS; + } + + f2me_buf(st_ivas->hParamMC->Cldfb_RealBuffer_tc, st_ivas->hParamMC->Cldfb_RealBuffer_tc_fx, &st_ivas->hParamMC->Cldfb_RealBuffer_tc_e, cldfb_slots * st_ivas->nchan_transport * st_ivas->hParamMC->num_freq_bands); + f2me_buf(st_ivas->hParamMC->Cldfb_ImagBuffer_tc, st_ivas->hParamMC->Cldfb_ImagBuffer_tc_fx, &st_ivas->hParamMC->Cldfb_ImagBuffer_tc_e, cldfb_slots * st_ivas->nchan_transport * st_ivas->hParamMC->num_freq_bands); + + + + Word16 max_e = 0, input_q[MAX_CLDFB_DIGEST_CHANNELS], in_q; + FOR(i = 0; i < MAX_CLDFB_DIGEST_CHANNELS; i++) + { + f2me_buf(p_data_f[i], p_data_f_fx[i], &input_q[i], MAX_JBM_L_FRAME48k); + } + + max_e = input_q[0]; + + FOR(i = 0; i < MAX_CLDFB_DIGEST_CHANNELS; i++) + { + IF(max_e < input_q[i]) + max_e = input_q[i]; + } + + FOR(i = 0; i < MAX_CLDFB_DIGEST_CHANNELS; i++) + { + FOR(j = 0; j < MAX_JBM_L_FRAME48k; j++) + p_data_f_fx[i][j] = L_shr(p_data_f_fx[i][j], max_e - input_q[i]); + } + + in_q = max_e; + + Word16 nchan_transport = st_ivas->nchan_transport; + Word16 nchan_out_transport = st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe; + Word16 nchan_out_cov; + IF(st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM) + { + nchan_out_cov = st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe; + } + ELSE IF(st_ivas->hParamMC->synthesis_conf == PARAM_MC_SYNTH_LS_CONV_CLDFB) + { + nchan_out_cov = nchan_out_transport; + } + ELSE IF(st_ivas->hParamMC->synthesis_conf == PARAM_MC_SYNTH_LS_CONV_COV || st_ivas->hParamMC->synthesis_conf == PARAM_MC_SYNTH_MONO_STEREO) + { + nchan_out_cov = st_ivas->hOutSetup.nchan_out_woLFE + st_ivas->hOutSetup.num_lfe; + } + ELSE + { + 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); + + 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); + } + + floatToFixed_arr(st_ivas->hParamMC->icld_q, st_ivas->hParamMC->icld_q_fx, 8, st_ivas->hParamMC->hMetadataPMC->num_parameter_bands * st_ivas->hParamMC->hMetadataPMC->ild_mapping_conf->ild_map_size_lfe); + + FOR(Word16 lp = 0; lp < st_ivas->hParamMC->hMetadataPMC->num_parameter_bands * st_ivas->hParamMC->hMetadataPMC->icc_mapping_conf->icc_map_size_lfe; lp++) + { + st_ivas->hParamMC->icc_q_fx[lp] = (Word16)(st_ivas->hParamMC->icc_q[lp] * 32767); + } + + 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], 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, nchan_transport * nchan_out_transport); + + ivas_param_mc_dec_digest_tc_fx( st_ivas, (uint8_t) n_render_timeslots, p_data_f_fx, in_q ); + + me2f_buf_16(st_ivas->hParamMC->h_output_synthesis_params.interpolator_fx, 0, st_ivas->hParamMC->h_output_synthesis_params.interpolator, n_render_timeslots ); + + + 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.mixing_matrix_fx[param_band_idx], st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_e[param_band_idx], st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix[param_band_idx], nchan_out_cov * nchan_transport); + IF(st_ivas->hParamMC->band_grouping[param_band_idx] < st_ivas->hParamMC->h_output_synthesis_params.max_band_decorr) + { + 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_e[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], 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 } else if ( st_ivas->mc_mode == MC_MODE_MCMASA ) { @@ -6099,11 +6184,6 @@ ivas_error ivas_jbm_dec_render( ivas_param_ism_dec_render_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output_fx_tmp ); /*-----------------------------------------fix 2 flt--------------------------------------------*/ - for ( ch = 0; ch < st_ivas->nchan_ism; ch++ ) - { - st_ivas->hIsmMetaData[ch]->azimuth = fixedToFloat( st_ivas->hIsmMetaData[ch]->azimuth_fx, Q22 ); - st_ivas->hIsmMetaData[ch]->elevation = fixedToFloat( st_ivas->hIsmMetaData[ch]->elevation_fx, Q22 ); - } for ( ch = 0; ch < n_out; ch++ ) { fixedToFloat_arrL( st_ivas->cldfbSynDec[ch]->cldfb_state_fx, st_ivas->cldfbSynDec[ch]->cldfb_state, Q11, st_ivas->cldfbSynDec[ch]->p_filter_length ); @@ -6156,11 +6236,6 @@ ivas_error ivas_jbm_dec_render( st_ivas->hTcBuffer->tc_fx[ind1][ind2] = (Word32) ( st_ivas->hTcBuffer->tc[ind1][ind2] * ( 1 << q ) ); } } - FOR( Word16 ind1 = 0; ind1 < MAX_NUM_OBJECTS; ind1++ ) - { - st_ivas->hIsmMetaData[ind1]->azimuth_fx = (Word32) ( st_ivas->hIsmMetaData[ind1]->azimuth * ( 1 << 22 ) ); - st_ivas->hIsmMetaData[ind1]->elevation_fx = (Word32) ( st_ivas->hIsmMetaData[ind1]->elevation * ( 1 << 22 ) ); - } IF( st_ivas->hCombinedOrientationData ) FOR( Word16 ind1 = 0; ind1 < 3; ind1++ ) { @@ -6178,11 +6253,6 @@ ivas_error ivas_jbm_dec_render( p_output[ind1][ind2] = (float) ( p_output_fx[ind1][ind2] ) / (float) ( 1 << q ); } } - FOR( Word16 ind1 = 0; ind1 < MAX_NUM_OBJECTS; ind1++ ) - { - st_ivas->hIsmMetaData[ind1]->azimuth = (float) ( st_ivas->hIsmMetaData[ind1]->azimuth_fx ) / (float) ( 1 << 22 ); - st_ivas->hIsmMetaData[ind1]->elevation = (float) ( st_ivas->hIsmMetaData[ind1]->elevation_fx ) / (float) ( 1 << 22 ); - } } else if ( st_ivas->renderer_type == RENDERER_NON_DIEGETIC_DOWNMIX ) { @@ -6657,11 +6727,6 @@ ivas_error ivas_jbm_dec_render( } } - FOR( Word16 ind1 = 0; ind1 < MAX_NUM_OBJECTS; ind1++ ) - { - st_ivas->hIsmMetaData[ind1]->azimuth_fx = (Word32) ( st_ivas->hIsmMetaData[ind1]->azimuth * ( 1 << 22 ) ); - st_ivas->hIsmMetaData[ind1]->elevation_fx = (Word32) ( st_ivas->hIsmMetaData[ind1]->elevation * ( 1 << 22 ) ); - } IF( st_ivas->hCombinedOrientationData ) FOR( Word16 ind1 = 0; ind1 < 3; ind1++ ) { @@ -6679,11 +6744,6 @@ ivas_error ivas_jbm_dec_render( p_output[ind1][ind2] = (float) ( p_output_fx[ind1][ind2] ) / (float) ( 1 << q ); } } - FOR( Word16 ind1 = 0; ind1 < MAX_NUM_OBJECTS; ind1++ ) - { - st_ivas->hIsmMetaData[ind1]->azimuth = (float) ( st_ivas->hIsmMetaData[ind1]->azimuth_fx ) / (float) ( 1 << 22 ); - st_ivas->hIsmMetaData[ind1]->elevation = (float) ( st_ivas->hIsmMetaData[ind1]->elevation_fx ) / (float) ( 1 << 22 ); - } /* add already rendered SBA part */ for ( n = 0; n < nchan_out; n++ ) @@ -6693,10 +6753,49 @@ ivas_error ivas_jbm_dec_render( } else if ( st_ivas->renderer_type == RENDERER_OSBA_AMBI || st_ivas->renderer_type == RENDERER_OSBA_LS || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) { +#ifdef IVAS_FLOAT_FIXED + Word16 q = 15; + FOR(Word16 ind1 = 0; ind1 < s_max(st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe, s_max(st_ivas->nchan_transport, st_ivas->nchan_ism)); ind1++) + { + FOR(Word16 ind2 = 0; ind2 < L_FRAME48k; ind2++) + { + p_output_fx[ind1][ind2] = (Word32)(p_output[ind1][ind2] * (1 << q)); + } + IF(st_ivas->hTcBuffer->tc) + { + FOR(Word16 ind2 = 0; ind2 < L_FRAME48k; ind2++) + { + st_ivas->hTcBuffer->tc_fx[ind1][ind2] = (Word32)(st_ivas->hTcBuffer->tc[ind1][ind2] * (1 << q)); + } + } + } + IF(st_ivas->hCombinedOrientationData) + { + FOR(Word16 ind1 = 0; ind1 < 3; ind1++) + { + FOR(Word16 ind2 = 0; ind2 < 3; ind2++) + { + st_ivas->hCombinedOrientationData->Rmat_fx[0][ind1][ind2] = (Word32)(st_ivas->hCombinedOrientationData->Rmat[0][ind1][ind2] * (1 << 15)); + } + } + } + IF((error = ivas_osba_render_sf_fx(st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output_fx)) != IVAS_ERR_OK) + { + return error; + } + FOR(Word16 ind1 = 0; ind1 < s_max(st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe, s_max(st_ivas->nchan_transport, st_ivas->nchan_ism)); ind1++) + { + FOR(Word16 ind2 = 0; ind2 < L_FRAME48k; ind2++) + { + p_output[ind1][ind2] = (float)(p_output_fx[ind1][ind2]) / (float)(1 << q); + } + } +#else if ( ( error = ivas_osba_render_sf( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output ) ) != IVAS_ERR_OK ) { return error; } +#endif } else if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) /*EXT output = individual objects + HOA3*/ { diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index 11a4f80ce..d00146d3e 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -3030,7 +3030,7 @@ static Word16 decode_lfe_to_total_energy_ratio_fx( * * Reconfigure IVAS MASA decoder *-------------------------------------------------------------------*/ - +#ifndef IVAS_FLOAT_FIXED ivas_error ivas_masa_dec_reconfigure( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ uint16_t *nSamplesRendered, /* o : number of samples flushed from the previous frame (JBM) */ @@ -3456,7 +3456,7 @@ ivas_error ivas_masa_dec_reconfigure( } -#ifdef IVAS_FLOAT_FIXED +#else /*-------------------------------------------------------------------* * ivas_masa_dec_reconfigure_fx() * @@ -3758,172 +3758,10 @@ ivas_error ivas_masa_dec_reconfigure_fx( IF( LT_16( n_samples_granularity, st_ivas->hTcBuffer->n_samples_granularity ) ) { #ifdef IVAS_FLOAT_FIXED -#if 1 /*Float to fixed conversion*/ - DECODER_TC_BUFFER_HANDLE hTcBuffer; - hTcBuffer = st_ivas->hTcBuffer; - if ( st_ivas->hIsmRendererData ) - { - FOR( Word16 ind1 = 0; ind1 < st_ivas->hIsmRendererData->interpolator_len; ind1++ ) - { - st_ivas->hIsmRendererData->interpolator_fx[ind1] = (Word16) L_min( 32767, floatToFixed( st_ivas->hIsmRendererData->interpolator_fx[ind1], 15 ) ); - } - } - FOR( Word16 ind1 = 0; ind1 < MAX_NUM_OBJECTS; ind1++ ) - { - if ( st_ivas->hIsmMetaData[ind1] ) - { - st_ivas->hIsmMetaData[ind1]->azimuth_fx = (Word32) ( st_ivas->hIsmMetaData[ind1]->azimuth * ( 1 << 22 ) ); - st_ivas->hIsmMetaData[ind1]->elevation_fx = (Word32) ( st_ivas->hIsmMetaData[ind1]->elevation * ( 1 << 22 ) ); - } - } - IF( st_ivas->hCombinedOrientationData ) - FOR( Word16 ind1 = 0; ind1 < 3; ind1++ ) - { - FOR( Word16 ind2 = 0; ind2 < 3; ind2++ ) - { - st_ivas->hCombinedOrientationData->Rmat_fx[0][ind1][ind2] = (Word32) ( st_ivas->hCombinedOrientationData->Rmat[0][ind1][ind2] * ( 1 << 15 ) ); - } - } - if ( st_ivas->hSbaIsmData ) - { - for ( Word16 ch_idx = 0; ch_idx < st_ivas->hSbaIsmData->delayBuffer_nchan; ch_idx++ ) - { - floatToFixed_arr32( st_ivas->hSbaIsmData->delayBuffer[ch_idx], st_ivas->hSbaIsmData->delayBuffer_fx[ch_idx], Q11, st_ivas->hSbaIsmData->delayBuffer_size ); - } - } - SPAR_DEC_HANDLE hSpar; - hSpar = st_ivas->hSpar; - uint16_t nchan_internal; - nchan_internal = ivas_sba_get_nchan_metadata( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); - DECODER_CONFIG_HANDLE hDecoderConfig; - hDecoderConfig = st_ivas->hDecoderConfig; - Word16 numch_in, numch_out, num_md_sub_frames, q1 = 30, q2 = 30; - ; - Word16 numch_out_dirac = hDecoderConfig->nchan_out; - IF( hSpar ) - { - numch_out = hSpar->hFbMixer->fb_cfg->num_out_chans; - numch_in = hSpar->hFbMixer->fb_cfg->num_in_chans; - num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ); - - for ( int l = 0; l < numch_out; l++ ) - { - for ( int j = 0; j < numch_in; j++ ) - { - for ( int k = 0; k < num_md_sub_frames * IVAS_MAX_NUM_BANDS; k++ ) - { - hSpar->hMdDec->mixer_mat_fx[l][j][k] = floatToFixed( hSpar->hMdDec->mixer_mat[l][j][k], q1 ); - } - } - } - for ( int m = 0; m < MAX_PARAM_SPATIAL_SUBFRAMES + 1; m++ ) - { - for ( int j = 0; j < IVAS_MAX_FB_MIXER_OUT_CH; j++ ) - { - for ( int k = 0; k < IVAS_MAX_SPAR_FB_MIXER_IN_CH; k++ ) - { - for ( int l = 0; l < IVAS_MAX_NUM_BANDS; l++ ) - { - hSpar->hMdDec->mixer_mat_prev_fx[m][j][k][l] = floatToFixed( hSpar->hMdDec->mixer_mat_prev[m][j][k][l], q2 ); - } - } - } - } - for ( Word16 in_ch = 0; in_ch < numch_in; in_ch++ ) - { - for ( Word16 i = 0; i < st_ivas->cldfbAnaDec[in_ch]->p_filter_length - st_ivas->cldfbAnaDec[in_ch]->no_channels; i++ ) - { - st_ivas->cldfbAnaDec[in_ch]->cldfb_state_fx[i] = (Word32) ( st_ivas->cldfbAnaDec[in_ch]->cldfb_state[i] * ( 1LL << ( Q11 ) ) ); - } - } - if ( ( hDecoderConfig->ivas_total_brate < IVAS_24k4 ) && ( ( hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_HOA2 ) || ( hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_HOA3 ) ) ) - { - for ( Word16 i = 0; i < IVAS_MAX_NUM_BANDS; i++ ) - { - floatToFixed_arrL( hSpar->hMdDec->smooth_buf[i], hSpar->hMdDec->smooth_buf_fx[i], 0, 2 * SBA_DIRAC_NRG_SMOOTH_LONG + 1 ); - } - floatToFixed_arr( hSpar->hMdDec->smooth_fac, hSpar->hMdDec->smooth_fac_fx, Q15, IVAS_MAX_NUM_BANDS ); - } - FOR( Word16 out_ch = 0; out_ch < numch_out_dirac; out_ch++ ) - { - IF( st_ivas->cldfbSynDec[out_ch] ) - { - FOR( Word16 i = 0; i < st_ivas->cldfbSynDec[out_ch]->p_filter_length; i++ ) - { - st_ivas->cldfbSynDec[out_ch]->cldfb_state_fx[i] = float_to_fix ( st_ivas->cldfbSynDec[out_ch]->cldfb_state[i] ,Q11 ); - } - } - } - } - Word16 n_tc; - if (st_ivas->ivas_format == MASA_ISM_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT) - n_tc = st_ivas->nchan_ism; - else - n_tc = st_ivas->hTcBuffer->nchan_transport_internal; - for (int ch = 0; ch < n_tc; ch++) - { - floatToFixed_arrL(st_ivas->hTcBuffer->tc[ch], st_ivas->hTcBuffer->tc_fx[ch], Q11, L_FRAME48k); - } -#endif IF( ( error = ivas_jbm_dec_flush_renderer_fx( st_ivas, n_samples_granularity, st_ivas->renderer_type, st_ivas->intern_config, &st_ivas->hIntSetup, MC_MODE_NONE, ISM_MASA_MODE_DISC, nSamplesRendered, data ) ) != IVAS_ERR_OK ) { return error; } -#if 1 /*Fixed to float */ - if ( hTcBuffer->tc_buffer ) - fixedToFloat_arrL( hTcBuffer->tc_buffer_fx, hTcBuffer->tc_buffer, Q11, hTcBuffer->tc_buff_len ); - IF( hSpar ) - { - FOR( Word16 in_ch = 0; in_ch < numch_in; in_ch++ ) - { - FOR( Word16 i = 0; i < st_ivas->cldfbAnaDec[in_ch]->p_filter_length - st_ivas->cldfbAnaDec[in_ch]->no_channels; i++ ) - { - st_ivas->cldfbAnaDec[in_ch]->cldfb_state[i] = ( (float) ( st_ivas->cldfbAnaDec[in_ch]->cldfb_state_fx[i] ) / ( 1LL << ( Q11 ) ) ); /*Rounding off*/ - } - } - FOR( int m = 0; m < MAX_PARAM_SPATIAL_SUBFRAMES + 1; m++ ) - { - FOR( int j = 0; j < IVAS_MAX_FB_MIXER_OUT_CH; j++ ) - { - FOR( int k = 0; k < IVAS_MAX_SPAR_FB_MIXER_IN_CH; k++ ) - { - FOR( int l = 0; l < IVAS_MAX_NUM_BANDS; l++ ) - { - hSpar->hMdDec->mixer_mat_prev[m][j][k][l] = ( (float) hSpar->hMdDec->mixer_mat_prev_fx[m][j][k][l] / ( 1 << q2 ) ); - } - } - } - } - // fix2float (to be cleaned) - IF( ( LT_32( hDecoderConfig->ivas_total_brate, IVAS_24k4 ) ) && ( ( EQ_16( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_HOA2 ) ) || ( EQ_16( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_HOA3 ) ) ) ) - { - fixedToFloat_arr( hSpar->hMdDec->smooth_fac_fx, hSpar->hMdDec->smooth_fac, Q15, IVAS_MAX_NUM_BANDS ); - FOR( Word16 i = 0; i < IVAS_MAX_NUM_BANDS; i++ ) - { - fixedToFloat_arrL( hSpar->hMdDec->smooth_buf_fx[i], hSpar->hMdDec->smooth_buf[i], 0, 2 * SBA_DIRAC_NRG_SMOOTH_LONG + 1 ); - } - } - // fix2float end - FOR( Word16 out_ch = 0; out_ch < numch_out_dirac; out_ch++ ) - { - IF( st_ivas->cldfbSynDec[out_ch] ) - { - FOR( Word16 i = 0; i < st_ivas->cldfbSynDec[out_ch]->p_filter_length; i++ ) - { - st_ivas->cldfbSynDec[out_ch]->cldfb_state[i] = ( (float) ( st_ivas->cldfbSynDec[out_ch]->cldfb_state_fx[i] ) / (float) ( 1LL << ( Q11 ) ) ); - } - } - } - } - FOR( Word16 ind1 = 0; ind1 < MAX_NUM_OBJECTS; ind1++ ) - { - if ( st_ivas->hIsmMetaData[ind1] ) - { - st_ivas->hIsmMetaData[ind1]->azimuth = (float) ( st_ivas->hIsmMetaData[ind1]->azimuth_fx ) / (float) ( 1 << 22 ); - st_ivas->hIsmMetaData[ind1]->elevation = (float) ( st_ivas->hIsmMetaData[ind1]->elevation_fx ) / (float) ( 1 << 22 ); - } - } -#endif #else IF( ( error = ivas_jbm_dec_flush_renderer( st_ivas, n_samples_granularity, st_ivas->renderer_type, st_ivas->intern_config, &st_ivas->hIntSetup, MC_MODE_NONE, ISM_MASA_MODE_DISC, nSamplesRendered, data ) ) != IVAS_ERR_OK ) { diff --git a/lib_dec/ivas_mc_param_dec.c b/lib_dec/ivas_mc_param_dec.c index c57ddaac4..f30db50ec 100644 --- a/lib_dec/ivas_mc_param_dec.c +++ b/lib_dec/ivas_mc_param_dec.c @@ -94,6 +94,21 @@ static void ivas_param_mc_dequantize_cov( PARAM_MC_DEC_HANDLE hDirAC, float *ild static void ivas_param_mc_get_mixing_matrices( PARAM_MC_DEC_HANDLE hParamMC, IVAS_OUTPUT_SETUP *hSynthesisOutputSetup, float Cx_in[PARAM_MC_MAX_PARAMETER_BANDS][PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS], float *mixing_matrix[], float *mixing_matrix_res[], const int16_t nY_int, const PARAM_MC_SYNTHESIS_CONF synth_conf, const int16_t nX, const int16_t nY ); +static void ivas_param_mc_get_mixing_matrices_fx( + PARAM_MC_DEC_HANDLE hParamMC, /* i : Parametric MC handle */ + IVAS_OUTPUT_SETUP *hSynthesisOutputSetup, + Word32 Cx_in_fixed[PARAM_MC_MAX_PARAMETER_BANDS][PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS], /* i : input covariance for all parameter bands */ + Word16 Cx_in_e, + Word32 *mixing_matrix_fx[], + Word16 *mixing_matrix_e, + Word32 *mixing_matrix_res_fx[], + Word16 *mixing_matrix_res_e, + const Word16 nY_intern, /* i : number of channels in the transported format */ + const PARAM_MC_SYNTHESIS_CONF synth_config, /* i : Parametric MC synthesis config */ + const Word16 nX, /* i : number of transport channels */ + const Word16 nY_cov /* i : number of covariance synthesis output channels */ +); + static void ivas_param_mc_get_mono_stereo_mixing_matrices( PARAM_MC_DEC_HANDLE hParamMC, float Cx_in[PARAM_MC_MAX_PARAMETER_BANDS][PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS], float *mixing_matrix[], float *mixing_matrix_res[], const int16_t nY_intern, const int16_t nX, const int16_t nY_cov ); static void param_mc_update_mixing_matrices( PARAM_MC_DEC_HANDLE hParamMC, float *mixing_matrix[], float *mixing_matrix_res[], const uint16_t nX, const uint16_t nY ); @@ -2167,6 +2182,240 @@ void ivas_param_mc_dec_read_BS( * *------------------------------------------------------------------------*/ +void ivas_param_mc_dec_digest_tc_fx( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const uint8_t nCldfbSlots, /* i : number of CLFBS slots in the transport channels */ + Word32 *transport_channels_f_fx[], + Word16 transport_f_e +) +{ + PARAM_MC_DEC_HANDLE hParamMC; + Word16 i, ch; + Word16 slot_idx, param_band_idx; + Word16 nchan_transport, nchan_out_transport, nchan_out_cldfb; + Word16 nchan_out_cov; + /*CLDFB*/ + /* format converter */ + Word16 channel_active[MAX_OUTPUT_CHANNELS]; + IVAS_OUTPUT_SETUP *hSynthesisOutputSetup; + + hParamMC = st_ivas->hParamMC; + assert( hParamMC ); + + Word32 cx_fx[PARAM_MC_MAX_PARAMETER_BANDS][PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; + Word16 cx_buff_e[PARAM_MC_MAX_PARAMETER_BANDS][PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; + Word16 cx_e; + + Word32 cx_imag_fx[PARAM_MC_MAX_PARAMETER_BANDS][PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; + Word16 cx_imag_e, tmp_e; + Word16 cldfb_slots, qout = 0; + + Word32 real_part_fx, imag_part_fx, L_tmp1, L_tmp2; + + Word16 max_e; + + push_wmops( "param_mc_dec_digest_tc" ); + + set_s( channel_active, 0, MAX_CICP_CHANNELS ); + nchan_transport = st_ivas->nchan_transport; + nchan_out_transport = st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe; + + IF ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) + { + nchan_out_cldfb = BINAURAL_CHANNELS; + move16(); + set_s( channel_active, 1, nchan_out_cldfb ); + nchan_out_cov = st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe; + hSynthesisOutputSetup = &st_ivas->hTransSetup; + } + ELSE IF ( hParamMC->synthesis_conf == PARAM_MC_SYNTH_LS_CONV_CLDFB ) + { + nchan_out_cov = nchan_out_transport; + move16(); + nchan_out_cldfb = st_ivas->hOutSetup.nchan_out_woLFE + st_ivas->hOutSetup.num_lfe; + hSynthesisOutputSetup = &st_ivas->hTransSetup; + } + ELSE IF ( hParamMC->synthesis_conf == PARAM_MC_SYNTH_LS_CONV_COV || hParamMC->synthesis_conf == PARAM_MC_SYNTH_MONO_STEREO ) + { + nchan_out_cov = st_ivas->hOutSetup.nchan_out_woLFE + st_ivas->hOutSetup.num_lfe; + nchan_out_cldfb = nchan_out_cov; + move16(); + set_s( channel_active, 1, nchan_out_cov ); + hSynthesisOutputSetup = &st_ivas->hOutSetup; + } + ELSE + { + nchan_out_cov = nchan_out_transport; + move16(); + nchan_out_cldfb = nchan_out_transport; + move16(); + set_s( channel_active, 1, nchan_out_cov ); + hSynthesisOutputSetup = &st_ivas->hTransSetup; + } + + /* adapt transient position */ + IF ( hParamMC->hMetadataPMC->bAttackPresent ) + { + hParamMC->hMetadataPMC->attackIndex = (int16_t) max( 0, hParamMC->hMetadataPMC->attackIndex + ( ( nCldfbSlots - DEFAULT_JBM_CLDFB_TIMESLOTS ) / 2 ) ); + } + /* adapt subframes */ + hParamMC->num_slots = nCldfbSlots; + move16(); + hParamMC->slots_rendered = 0; + move16(); + hParamMC->subframes_rendered = 0; + move16(); + ivas_jbm_dec_get_adapted_subframes( nCldfbSlots, hParamMC->subframe_nbslots, &hParamMC->nb_subframes ); + st_ivas->hTcBuffer->nb_subframes = hParamMC->nb_subframes; + mvs2s( hParamMC->subframe_nbslots, st_ivas->hTcBuffer->subframe_nbslots, hParamMC->nb_subframes ); + + ivas_param_mc_dec_compute_interpolator_fx(hParamMC->hMetadataPMC->bAttackPresent, hParamMC->hMetadataPMC->attackIndex, nCldfbSlots, hParamMC->h_output_synthesis_params.interpolator_fx); + + FOR (param_band_idx = 0; param_band_idx < PARAM_MC_MAX_PARAMETER_BANDS; param_band_idx++) + { + set_zero_fx(cx_fx[param_band_idx], PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS); + set_zero_fx(cx_imag_fx[param_band_idx], PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS); + } + + cx_e = 0; + move16(); + cx_imag_e = 0; + move16(); + cldfb_slots = DEFAULT_JBM_CLDFB_TIMESLOTS; + move16(); + IF (st_ivas->hDecoderConfig->Opt_tsm) + { + cldfb_slots = MAX_JBM_CLDFB_TIMESLOTS; + move16(); + } + + /* slot loop for gathering the input data */ + FOR ( slot_idx = 0; slot_idx < nCldfbSlots; slot_idx++ ) + { + IF ( st_ivas->hDecoderConfig->Opt_tsm ) + { + Word32 RealBuffer_fx[CLDFB_NO_CHANNELS_MAX]; + Word32 ImagBuffer_fx[CLDFB_NO_CHANNELS_MAX]; + + /* CLDFB Analysis*/ + FOR ( ch = 0; ch < nchan_transport; ch++ ) + { + qout = transport_f_e; + move16(); + cldfbAnalysis_ts_fx_fixed_q( &( transport_channels_f_fx[ch][hParamMC->num_freq_bands * slot_idx] ), RealBuffer_fx, ImagBuffer_fx, hParamMC->num_freq_bands, st_ivas->cldfbAnaDec[ch], &qout ); + + Copy32( RealBuffer_fx, &hParamMC->Cldfb_RealBuffer_tc_fx[slot_idx * hParamMC->num_freq_bands * nchan_transport + ch * hParamMC->num_freq_bands], hParamMC->num_freq_bands ); + Copy32( ImagBuffer_fx, &hParamMC->Cldfb_ImagBuffer_tc_fx[slot_idx * hParamMC->num_freq_bands * nchan_transport + ch * hParamMC->num_freq_bands], hParamMC->num_freq_bands ); + } + + hParamMC->Cldfb_ImagBuffer_tc_e = qout; + move16(); + } + IF ( slot_idx >= 2 * hParamMC->hMetadataPMC->attackIndex ) + { + ivas_dirac_dec_output_synthesis_cov_param_mc_collect_slot_fx( &hParamMC->Cldfb_RealBuffer_tc_fx[slot_idx * hParamMC->num_freq_bands * nchan_transport], + hParamMC->Cldfb_RealBuffer_tc_e, + &hParamMC->Cldfb_ImagBuffer_tc_fx[slot_idx * hParamMC->num_freq_bands * nchan_transport], + hParamMC->Cldfb_ImagBuffer_tc_e, + cx_fx, + &cx_e, + cx_imag_fx, + &cx_imag_e, + hParamMC, + nchan_transport ); + } + } + + /* map from complex input covariance to real values */ + + FOR(param_band_idx = 0; param_band_idx < hParamMC->num_param_bands_synth; param_band_idx++) + { + /* Cx for transport channels */ + FOR(i = 0; i < nchan_transport * nchan_transport; i++) + { + + real_part_fx = cx_fx[param_band_idx][i]; + imag_part_fx = cx_imag_fx[param_band_idx][i]; + cx_buff_e[param_band_idx][i] = cx_e; + move16(); + + /* (a-ib)(c+id) = ac + bd + i(ad-bc) */ + IF(LT_16(param_band_idx, hParamMC->max_param_band_abs_cov)) + { + L_tmp1 = Mpy_32_32(real_part_fx, real_part_fx); + L_tmp2 = Mpy_32_32(imag_part_fx, imag_part_fx); + L_tmp1 = BASOP_Util_Add_Mant32Exp(L_tmp1, cx_e + cx_e, L_tmp2, cx_imag_e + cx_imag_e, &tmp_e); + cx_fx[param_band_idx][i] = Sqrt32(L_tmp1, &tmp_e); + cx_buff_e[param_band_idx][i] = tmp_e; + move16(); + } + ELSE + { + cx_fx[param_band_idx][i] = real_part_fx; + move32(); + cx_buff_e[param_band_idx][i] = cx_e; + move16(); + } + } + } + + max_e = cx_buff_e[0][0]; + move16(); + + FOR(param_band_idx = 0; param_band_idx < hParamMC->num_param_bands_synth; param_band_idx++) + { + /* Cx for transport channels */ + FOR(i = 0; i < nchan_transport * nchan_transport; i++) + { + + IF( max_e < cx_buff_e[param_band_idx][i] ) + max_e = cx_buff_e[param_band_idx][i]; + } + } + + FOR(param_band_idx = 0; param_band_idx < hParamMC->num_param_bands_synth; param_band_idx++) + { + /* Cx for transport channels */ + FOR(i = 0; i < nchan_transport * nchan_transport; i++) + { + + cx_fx[param_band_idx][i] = L_shr(cx_fx[param_band_idx][i], max_e - cx_buff_e[param_band_idx][i]); + } + } + + cx_e = max_e; + move16(); + + + /* we have to do it similar to the encoder in case of attacks (i.e. accumulate two bands) to ensure correct DMX of the target covariance*/ + + IF ( hParamMC->hMetadataPMC->bAttackPresent && ( EQ_32( hParamMC->synthesis_conf, PARAM_MC_SYNTH_LS_CONV_COV ) || EQ_32( hParamMC->synthesis_conf, PARAM_MC_SYNTH_MONO_STEREO ) ) ) + { + FOR ( param_band_idx = 0; param_band_idx < hParamMC->num_param_bands_synth; param_band_idx += 2 ) + { + v_add_fx( cx_fx[param_band_idx], cx_fx[param_band_idx + 1], cx_fx[param_band_idx], nchan_transport * nchan_transport ); + Copy32( cx_fx[param_band_idx], cx_fx[param_band_idx + 1], nchan_transport * nchan_transport ); + } + } + + IF ( EQ_32( hParamMC->synthesis_conf, PARAM_MC_SYNTH_MONO_STEREO ) ) + { + + // streams not entering into this block + //ivas_param_mc_get_mono_stereo_mixing_matrices( hParamMC, cx, hParamMC->h_output_synthesis_cov_state.mixing_matrix, hParamMC->h_output_synthesis_cov_state.mixing_matrix_res, nchan_out_transport, nchan_transport, nchan_out_cov ); + } + ELSE + { + /* generate mixing matrices */ + ivas_param_mc_get_mixing_matrices_fx( hParamMC, hSynthesisOutputSetup, cx_fx, cx_e, hParamMC->h_output_synthesis_cov_state.mixing_matrix_fx, hParamMC->h_output_synthesis_cov_state.mixing_matrix_e, hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_fx, hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_e, nchan_out_transport, hParamMC->synthesis_conf, nchan_transport, nchan_out_cov ); + } + + pop_wmops(); + + return; +} + + void ivas_param_mc_dec_digest_tc( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ const uint8_t nCldfbSlots, /* i : number of CLFBS slots in the transport channels */ @@ -2788,7 +3037,11 @@ void ivas_param_mc_dec( hParamMC->Cldfb_ImagBuffer_tc = Cldfb_ImagBuffer_in; nSamplesAsked = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); + ivas_param_mc_dec_digest_tc( st_ivas, DEFAULT_JBM_CLDFB_TIMESLOTS, output_f ); + + me2f_buf_16(st_ivas->hParamMC->h_output_synthesis_params.interpolator_fx, 0, st_ivas->hParamMC->h_output_synthesis_params.interpolator, DEFAULT_JBM_CLDFB_TIMESLOTS ); + ivas_param_mc_dec_render( st_ivas, nSamplesAsked, &nSamplesRendered, &nSamplesAvailableNext, output_f ); /* set handle pointers back to NULL */ @@ -3627,6 +3880,420 @@ static void ivas_param_mc_get_mixing_matrices( } +#ifdef IVAS_FLOAT_FIXED +static void ivas_param_mc_get_mixing_matrices_fx( + PARAM_MC_DEC_HANDLE hParamMC, /* i : Parametric MC handle */ + IVAS_OUTPUT_SETUP *hSynthesisOutputSetup, + Word32 Cx_in_fixed[PARAM_MC_MAX_PARAMETER_BANDS][PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS], /* i : input covariance for all parameter bands */ + Word16 Cx_in_e, + Word32 *mixing_matrix_fx[], + Word16 *mixing_matrix_e, + Word32 *mixing_matrix_res_fx[], + Word16 *mixing_matrix_res_e, + const Word16 nY_intern, /* i : number of channels in the transported format */ + const PARAM_MC_SYNTHESIS_CONF synth_config, /* i : Parametric MC synthesis config */ + const Word16 nX, /* i : number of transport channels */ + const Word16 nY_cov /* i : number of covariance synthesis output channels */ +) +{ + Word16 matSize = MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS; + Word16 param_band_idx; + Word16 nY_band; + Word16 num_lfe_bands; + Word16 brange[2]; + uint16_t i; + Word16 ch_idx1, ch_idx2, lfe_idx1, lfe_idx2; + Word16 remove_lfe; + Word16 lfe_indices[PARAM_MC_LOCAL_SZ_LFE_MAP]; + + nY_band = nY_cov; + num_lfe_bands = 0; + remove_lfe = 0; + + Word32 Cx_fx[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; + Word32 Cy_fx[MAX_CICP_CHANNELS * MAX_CICP_CHANNELS]; + + Word32 Cy_full_fx[MAX_CICP_CHANNELS * MAX_CICP_CHANNELS]; + + Word32 Cr_fx[MAX_CICP_CHANNELS * MAX_CICP_CHANNELS]; + Word16 Cr_e; + Word32 Cy_diag_fx[MAX_OUTPUT_CHANNELS]; + Word16 Cy_diag_buff_e[MAX_OUTPUT_CHANNELS]; + Word32 mixing_matrix_local_fx[MAX_CICP_CHANNELS * PARAM_MC_MAX_TRANSPORT_CHANS]; + Word16 Cy_diag_e = 0, mixing_matrix_local_e = 0; + Word32 Cproto_fx[MAX_CICP_CHANNELS * MAX_CICP_CHANNELS]; + Word16 Cproto_buff_e[MAX_CICP_CHANNELS * MAX_CICP_CHANNELS]; + Word16 Cproto_e; + Word32 *proto_matrix_ptr_fx; + Word32 *Cx_state_fx; + Word32 *Cx_old_state_fx; + Word32 Cy_state_fx[MAX_CICP_CHANNELS * MAX_CICP_CHANNELS]; + Word32 *Cy_old_state_fx; + Word16 Cx_state_e; + Word16 Cy_state_e; + Word32 mixing_matrix_res_local_fx[MAX_CICP_CHANNELS * MAX_CICP_CHANNELS]; + Word16 mixing_matrix_res_local_e; + Word32 L_tmp; + Word16 tmp_e, tmp; + + Word16 proto_matrix_e = hParamMC->h_output_synthesis_params.proto_matrix_e; + Word32 proto_matrix_noLFE_fx[PARAM_MC_MAX_TRANSPORT_CHANS * MAX_CICP_CHANNELS]; + + Word32 mat_mult_buffer1_fx[MAX_CICP_CHANNELS * MAX_CICP_CHANNELS]; + + Word32 Cproto_diag_fx[MAX_CICP_CHANNELS]; + Word16 mat_mult_buffer1_e, proto_matrix_ptr_e, Cproto_diag_e; + + Word32 *ptrMM_fx; + Word32 *ptrMM_out_fx; + + Word16 Cy_e, Cx_e; + Word16 Cy_full_e; + + set_zero_fx(Cproto_fx, MAX_CICP_CHANNELS * MAX_CICP_CHANNELS); + set_zero_fx(mat_mult_buffer1_fx, MAX_CICP_CHANNELS * MAX_CICP_CHANNELS); + set_zero_fx(proto_matrix_noLFE_fx, PARAM_MC_MAX_TRANSPORT_CHANS * MAX_CICP_CHANNELS); + Word16 proto_matrix_noLFE_e = 0; + + Word16 guard_bit_cx = find_guarded_bits_fx(nY_intern + 1); + Word16 guard_bit_cy = find_guarded_bits_fx(nY_cov * nY_cov); + Word32 Cx_in_fx[PARAM_MC_MAX_PARAMETER_BANDS][PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; + + + FOR (i = 0; i < PARAM_MC_MAX_PARAMETER_BANDS; i++) + Copy32(Cx_in_fixed[i], Cx_in_fx[i], PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS); + + nY_band = nY_cov; + num_lfe_bands = 0; + remove_lfe = 0; + + set_s( lfe_indices, -1, PARAM_MC_LOCAL_SZ_LFE_MAP ); + IF ( hSynthesisOutputSetup->num_lfe ) + { + Word32 *proto_matrix_ptr_in_fx; + FOR ( lfe_idx1 = 0; lfe_idx1 < hSynthesisOutputSetup->num_lfe; lfe_idx1++ ) + { + lfe_indices[lfe_idx1 + 1] = hSynthesisOutputSetup->index_lfe[lfe_idx1]; + } + lfe_indices[hSynthesisOutputSetup->num_lfe + 1] = nY_cov; + proto_matrix_ptr_fx = &proto_matrix_noLFE_fx[0]; + proto_matrix_ptr_in_fx = &hParamMC->h_output_synthesis_params.proto_matrix_fx[0]; + proto_matrix_noLFE_e = proto_matrix_e; + move16(); + + set_zero_fx(proto_matrix_noLFE_fx, PARAM_MC_MAX_TRANSPORT_CHANS * MAX_CICP_CHANNELS); + + FOR(ch_idx1 = 0; ch_idx1 < nX; ch_idx1++) + { + FOR(lfe_idx1 = 0; lfe_idx1 < hSynthesisOutputSetup->num_lfe + 1; lfe_idx1++) + { + FOR(ch_idx2 = lfe_indices[lfe_idx1] + 1; ch_idx2 < lfe_indices[lfe_idx1 + 1]; ch_idx2++) + { + *(proto_matrix_ptr_fx++) = *(proto_matrix_ptr_in_fx++); + } + proto_matrix_ptr_in_fx++; + } + proto_matrix_ptr_in_fx--; + } + + proto_matrix_ptr_e = proto_matrix_e; + move16(); + } + + IF ( hParamMC->hMetadataPMC->lfe_on ) + { + num_lfe_bands = PARAM_MC_MAX_BAND_LFE; + } + + FOR ( param_band_idx = 0; param_band_idx < hParamMC->num_param_bands_synth; param_band_idx++ ) + { + IF ( hSynthesisOutputSetup->num_lfe > 0 && param_band_idx >= num_lfe_bands ) + { + remove_lfe = 1; + move16(); + nY_band = nY_cov - hSynthesisOutputSetup->num_lfe; + proto_matrix_ptr_fx = proto_matrix_noLFE_fx; + proto_matrix_ptr_e = proto_matrix_noLFE_e; + move16(); + } + ELSE + { + proto_matrix_ptr_fx = hParamMC->h_output_synthesis_params.proto_matrix_fx; + proto_matrix_ptr_e = hParamMC->h_output_synthesis_params.proto_matrix_e; + move16(); + } + + brange[0] = hParamMC->band_grouping[param_band_idx]; + move16(); + brange[1] = hParamMC->band_grouping[param_band_idx + 1]; + move16(); + + Cx_state_fx = Cx_in_fx[param_band_idx]; + Cx_old_state_fx = hParamMC->h_output_synthesis_cov_state.cx_old_fx[param_band_idx]; + Cy_old_state_fx = hParamMC->h_output_synthesis_cov_state.cy_old_fx[param_band_idx]; + + + /* Getting mixing mtx */ + /* estimate target cov from input cov and proto_matrix */ + + Cx_state_e = Cx_in_e; + move16(); + matrix_product_fx(hParamMC->proto_matrix_int_fx, nY_intern, nX, 0, Cx_state_fx, nX, nX, 0, mat_mult_buffer1_fx); + mat_mult_buffer1_e = hParamMC->proto_matrix_int_e + Cx_in_e; + + matrix_product_fx(mat_mult_buffer1_fx, nY_intern, nX, 0, hParamMC->proto_matrix_int_fx, nY_intern, nX, 1, Cproto_fx); + Cproto_e = mat_mult_buffer1_e + hParamMC->proto_matrix_int_e; + move16(); + + + FOR (ch_idx1 = 0; ch_idx1 < nY_intern; ch_idx1++) + { + Cproto_buff_e[ch_idx1 + ch_idx1 * nY_intern] = Cproto_e; + IF (BASOP_Util_Cmp_Mant32Exp( Cproto_fx[ch_idx1 + ch_idx1 * nY_intern], Cproto_e, 0, 0 ) < 0 ) + { + Cproto_fx[ch_idx1 + ch_idx1 * nY_intern] = 0; + move32(); + Cproto_buff_e[ch_idx1 + ch_idx1 * nY_intern] = 0; + move16(); + } + } + + set_zero_fx( Cy_state_fx, matSize ); + Cy_state_e = 0; + move16(); + + ivas_param_mc_dequantize_cov_fx( hParamMC, + hParamMC->icld_q_fx + param_band_idx * hParamMC->hMetadataPMC->ild_mapping_conf->ild_map_size_lfe, + hParamMC->icc_q_fx + param_band_idx * hParamMC->hMetadataPMC->icc_mapping_conf->icc_map_size_lfe, + param_band_idx, nY_cov, + synth_config, + nY_intern, + nX, Cx_state_fx, Cx_state_e, Cproto_fx, Cproto_e, Cy_state_fx, &Cy_state_e ); + + // dbgwrite2_txt(Cy_state_fx,nY_intern*nY_intern,"../cy_state_fx.txt"); + + /* Smoothing: Sum over two buffers */ + IF ( hParamMC->hMetadataPMC->bAttackPresent ) + { + /* no smoothing on attacks */ + Copy32(Cx_state_fx, Cx_fx, nX * nX); + Copy32(Cy_state_fx, Cy_full_fx, nY_cov * nY_cov); + Cy_full_e = Cy_state_e; + move16(); + Cx_e = Cx_state_e; + move16(); + } + ELSE + { + /* smoothing gains are now identical to one, simply add up */ + //v_add( Cy_state, Cy_old_state, Cy_full, nY_cov * nY_cov ); + + tmp_e = max(hParamMC->h_output_synthesis_cov_state.cx_old_e[param_band_idx], Cx_state_e) + guard_bit_cx; + FOR(i = 0; i < nX * nX; i++) + { + Cx_old_state_fx[i] = L_shr(Cx_old_state_fx[i], tmp_e - hParamMC->h_output_synthesis_cov_state.cx_old_e[param_band_idx]); + Cx_state_fx[i] = L_shr(Cx_state_fx[i], tmp_e - Cx_state_e); + } + + hParamMC->h_output_synthesis_cov_state.cx_old_e[param_band_idx] = tmp_e; + Cx_state_e = tmp_e; + move16(); + tmp_e = max(hParamMC->h_output_synthesis_cov_state.cy_old_e[param_band_idx], Cy_state_e) + guard_bit_cy; + FOR(i = 0; i < nY_cov * nY_cov; i++) + { + Cy_old_state_fx[i] = L_shr(Cy_old_state_fx[i], tmp_e - hParamMC->h_output_synthesis_cov_state.cy_old_e[param_band_idx]); + Cy_state_fx[i] = L_shr(Cy_state_fx[i], tmp_e - Cy_state_e); + } + + hParamMC->h_output_synthesis_cov_state.cy_old_e[param_band_idx] = tmp_e; + Cy_state_e = tmp_e; + move16(); + + v_add_32(Cx_state_fx, Cx_old_state_fx, Cx_fx, nX * nX); + v_add_32(Cy_state_fx, Cy_old_state_fx, Cy_full_fx, nY_cov * nY_cov); + + Cy_full_e = Cy_state_e; + move16(); + Cx_e = Cx_state_e; + move16(); + + } + + Copy32(Cx_state_fx, Cx_old_state_fx, nX * nX); + + Copy32(Cy_state_fx, Cy_old_state_fx, nY_cov * nY_cov); + + 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(); + + + /* remove LFE IF necessary */ + IF ( remove_lfe ) + { + + Cy_e = Cy_full_e; + remove_lfe_from_cy_fx( nY_cov, lfe_indices, hSynthesisOutputSetup->num_lfe, Cy_full_fx, Cy_fx ); + } + ELSE + { + Copy32(Cy_full_fx, Cy_fx, nY_band * nY_band); + Cy_e = Cy_full_e; + move16(); + } + + matrix_product_fx(proto_matrix_ptr_fx, nY_band, nX, 0, Cx_fx, nX, nX, 0, mat_mult_buffer1_fx); + mat_mult_buffer1_e = proto_matrix_ptr_e + Cx_e; + + Word16 guard_bits = find_guarded_bits_fx( nY_band + 1 ); + + FOR ( i = 0; i < nY_band * nX; ++i ) + { + proto_matrix_ptr_fx[i] = L_shr( proto_matrix_ptr_fx[i], guard_bits ); + mat_mult_buffer1_fx[i] = L_shr(mat_mult_buffer1_fx[i], guard_bits); + } + + proto_matrix_ptr_e += guard_bits; + mat_mult_buffer1_e += guard_bits; + + matrix_product_diag_fx(mat_mult_buffer1_fx, mat_mult_buffer1_e, nY_band, nX, 0, proto_matrix_ptr_fx, proto_matrix_ptr_e, nY_band, nX, 1, Cproto_diag_fx,&Cproto_diag_e); + + FOR(i = 0; i < nY_band * nX; ++i) + { + proto_matrix_ptr_fx[i] = L_shl(proto_matrix_ptr_fx[i], guard_bits); + mat_mult_buffer1_fx[i] = L_shl(mat_mult_buffer1_fx[i], guard_bits); + } + + proto_matrix_ptr_e -= guard_bits; + mat_mult_buffer1_e -= guard_bits; + + /* make sure we have no negative entries in Cproto_diag due to rounding errors */ + + FOR (ch_idx1 = 0; ch_idx1 < nY_band; ch_idx1++) + { + IF (BASOP_Util_Cmp_Mant32Exp( Cproto_diag_fx[ch_idx1], Cproto_diag_e, 0, 0 ) < 0 ) + { + Cproto_diag_fx[ch_idx1] = 0; + move16(); + } + } + + + /* Computing the mixing matrices */ + + /* bands with decorr */ + IF ( brange[0] < hParamMC->h_output_synthesis_params.max_band_decorr ) + { + computeMixingMatrices_fx( nX, nY_band, Cx_fx, Cx_e, Cy_fx, Cy_e, proto_matrix_ptr_fx, proto_matrix_ptr_e, 0, PARAM_MC_REG_SX_FX, 0, PARAM_MC_REG_GHAT_FX, 0, mixing_matrix_local_fx, &mixing_matrix_local_e, Cr_fx, &Cr_e ); + /* Compute mixing matrix FOR residual */ + computeMixingMatricesResidual_fx( nY_band, Cproto_diag_fx, Cproto_diag_e, Cr_fx, Cr_e, PARAM_MC_REG_SX_FX, 0, PARAM_MC_REG_GHAT_FX, 0, mixing_matrix_res_local_fx, &mixing_matrix_res_local_e); + + IF ( remove_lfe ) + { + set_zero_fx( mixing_matrix_res_fx[param_band_idx], nY_cov * nY_cov ); + + ptrMM_fx = mixing_matrix_res_local_fx; + ptrMM_out_fx = mixing_matrix_res_fx[param_band_idx]; + FOR ( lfe_idx1 = 0; lfe_idx1 < hSynthesisOutputSetup->num_lfe + 1; lfe_idx1++ ) + { + FOR ( ch_idx1 = lfe_indices[lfe_idx1] + 1; ch_idx1 < lfe_indices[lfe_idx1 + 1]; ch_idx1++ ) + { + FOR ( lfe_idx2 = 0; lfe_idx2 < hSynthesisOutputSetup->num_lfe + 1; lfe_idx2++ ) + { + FOR ( ch_idx2 = lfe_indices[lfe_idx2] + 1; ch_idx2 < lfe_indices[lfe_idx2 + 1]; ch_idx2++ ) + { + *( ptrMM_out_fx++ ) = *( ptrMM_fx++ ); + } + ptrMM_out_fx++; + } + ptrMM_out_fx--; + } + ptrMM_out_fx += nY_cov; + } + mixing_matrix_res_e[param_band_idx] = mixing_matrix_res_local_e; + move16(); + } + ELSE + { + Copy32(mixing_matrix_res_local_fx, mixing_matrix_res_fx[param_band_idx], nY_cov * nY_cov); + mixing_matrix_res_e[param_band_idx] = mixing_matrix_res_local_e; + move16(); + } + } + ELSE IF ( brange[0] < hParamMC->max_band_energy_compensation ) + { + /* Compute mixing matrices (energy compensation only) */ + computeMixingMatrices_fx( nX, nY_band, Cx_fx, Cx_e, Cy_fx, Cy_e, proto_matrix_ptr_fx, proto_matrix_ptr_e, 1, PARAM_MC_REG_SX_FX, 0, PARAM_MC_REG_GHAT_FX, 0, mixing_matrix_local_fx, &mixing_matrix_local_e, Cr_fx, &Cr_e ); + } + ELSE + { + /*IF neither decorrelation nor energy compensation is applied*/ + FOR ( i = 0; i < nY_band; i++ ) + { + tmp = BASOP_Util_Divide3232_Scale(Cy_fx[i], L_add(Cproto_diag_fx[i], EPSILON_FX) , &tmp_e); + tmp_e = Cy_diag_e + Cproto_diag_e; + L_tmp = Sqrt32(L_deposit_h(tmp), &tmp_e); + Cy_diag_fx[i] = L_tmp; + move32(); + Cy_diag_buff_e[i] = tmp_e; + move16(); + } + + + Cy_diag_e = Cy_diag_buff_e[0]; + move16(); + + FOR (i = 1; i < nY_band; i++) + { + IF (Cy_diag_e < Cy_diag_buff_e[i]) + Cy_diag_e = Cy_diag_buff_e[i]; + } + + FOR (i = 0; i < nY_band; i++) + { + Cy_diag_fx[i] = L_shr(Cy_diag_fx[i], Cy_diag_e - Cy_diag_buff_e[i]); + } + + diag_matrix_product_fx( Cy_diag_fx, Cy_diag_e, nY_band, proto_matrix_ptr_fx, proto_matrix_ptr_e, nY_band, nX, 0, mixing_matrix_local_fx, &mixing_matrix_local_e ); + } + + IF ( remove_lfe ) + { + set_zero_fx(mixing_matrix_fx[param_band_idx], nX * nY_cov); + ptrMM_fx = mixing_matrix_local_fx; + ptrMM_out_fx = mixing_matrix_fx[param_band_idx]; + FOR (ch_idx1 = 0; ch_idx1 < nX; ch_idx1++) + { + FOR (lfe_idx1 = 0; lfe_idx1 < hSynthesisOutputSetup->num_lfe + 1; lfe_idx1++) + { + FOR (ch_idx2 = lfe_indices[lfe_idx1] + 1; ch_idx2 < lfe_indices[lfe_idx1 + 1]; ch_idx2++) + { + *(ptrMM_out_fx++) = *(ptrMM_fx++); + } + ptrMM_out_fx++; + } + ptrMM_out_fx--; + } + + mixing_matrix_e[param_band_idx] = mixing_matrix_local_e; + move16(); + } + ELSE + { + Copy32( mixing_matrix_local_fx, mixing_matrix_fx[param_band_idx], nY_cov * nX ); + mixing_matrix_e[param_band_idx] = mixing_matrix_local_e; + move16(); + } + } + + return; +} + +#endif + + + /*------------------------------------------------------------------------- * ivas_param_mc_get_mono_stereo_mixing_matrices() * diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index c11abc9a2..a8253fdfb 100644 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -1889,21 +1889,6 @@ static ivas_error ivas_mc_dec_reconfig( #if 1 /*Float to fixed conversion*/ DECODER_TC_BUFFER_HANDLE hTcBuffer; hTcBuffer = st_ivas->hTcBuffer; - if ( st_ivas->hIsmRendererData ) - { - FOR( Word16 ind1 = 0; ind1 < st_ivas->hIsmRendererData->interpolator_len; ind1++ ) - { - st_ivas->hIsmRendererData->interpolator_fx[ind1] = (Word16) L_min( 32767, floatToFixed( st_ivas->hIsmRendererData->interpolator_fx[ind1], 15 ) ); - } - } - FOR( Word16 ind1 = 0; ind1 < MAX_NUM_OBJECTS; ind1++ ) - { - if ( st_ivas->hIsmMetaData[ind1] ) - { - st_ivas->hIsmMetaData[ind1]->azimuth_fx = (Word32) ( st_ivas->hIsmMetaData[ind1]->azimuth * ( 1 << 22 ) ); - st_ivas->hIsmMetaData[ind1]->elevation_fx = (Word32) ( st_ivas->hIsmMetaData[ind1]->elevation * ( 1 << 22 ) ); - } - } IF( st_ivas->hCombinedOrientationData ) FOR( Word16 ind1 = 0; ind1 < 3; ind1++ ) { @@ -2043,14 +2028,6 @@ static ivas_error ivas_mc_dec_reconfig( } } } - FOR( Word16 ind1 = 0; ind1 < MAX_NUM_OBJECTS; ind1++ ) - { - if ( st_ivas->hIsmMetaData[ind1] ) - { - st_ivas->hIsmMetaData[ind1]->azimuth = (float) ( st_ivas->hIsmMetaData[ind1]->azimuth_fx ) / (float) ( 1 << 22 ); - st_ivas->hIsmMetaData[ind1]->elevation = (float) ( st_ivas->hIsmMetaData[ind1]->elevation_fx ) / (float) ( 1 << 22 ); - } - } #endif #else if ( ( error = ivas_jbm_dec_flush_renderer( st_ivas, tc_granularity_new, renderer_type_old, intern_config_old, &hIntSetupOld, last_mc_mode, ISM_MODE_NONE, nSamplesRendered, data ) ) != IVAS_ERR_OK ) diff --git a/lib_dec/ivas_omasa_dec.c b/lib_dec/ivas_omasa_dec.c index 98019a12e..d5fcb4435 100644 --- a/lib_dec/ivas_omasa_dec.c +++ b/lib_dec/ivas_omasa_dec.c @@ -339,9 +339,164 @@ ivas_error ivas_omasa_dec_config_fx( st_ivas->hCPE[0]->nchan_out = 1; move16(); } - ELSE IF( ( error = ivas_masa_dec_reconfigure_fx( st_ivas, nSamplesRendered, data ) ) != IVAS_ERR_OK ) - { - return error; + ELSE{ + ///////////////////////////////local flt2fix: to be removed + Word16 n_samples_granularity; + + n_samples_granularity = NS2SA(st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS); + DECODER_TC_BUFFER_HANDLE hTcBuffer; + hTcBuffer = st_ivas->hTcBuffer; + DECODER_CONFIG_HANDLE hDecoderConfig = NULL; + Word16 numch_out_dirac = 0; + SPAR_DEC_HANDLE hSpar = NULL; + Word16 numch_in, numch_out, num_md_sub_frames, q1 = 30, q2 = 30; + IF(EQ_16(st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC) || EQ_16(st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM) || EQ_16(st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC)) + { + IF(EQ_16(st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC) && NE_16(st_ivas->ism_mode, ISM_MASA_MODE_DISC)) + { + IF(LT_16(n_samples_granularity, st_ivas->hTcBuffer->n_samples_granularity)) + { + + IF(st_ivas->hCombinedOrientationData) + FOR(Word16 ind1 = 0; ind1 < 3; ind1++) + { + FOR(Word16 ind2 = 0; ind2 < 3; ind2++) + { + st_ivas->hCombinedOrientationData->Rmat_fx[0][ind1][ind2] = (Word32)(st_ivas->hCombinedOrientationData->Rmat[0][ind1][ind2] * (1 << 15)); + } + } + if (st_ivas->hSbaIsmData) + { + for (Word16 ch_idx = 0; ch_idx < st_ivas->hSbaIsmData->delayBuffer_nchan; ch_idx++) + { + floatToFixed_arr32(st_ivas->hSbaIsmData->delayBuffer[ch_idx], st_ivas->hSbaIsmData->delayBuffer_fx[ch_idx], Q11, st_ivas->hSbaIsmData->delayBuffer_size); + } + } + hSpar = st_ivas->hSpar; + uint16_t nchan_internal; + nchan_internal = ivas_sba_get_nchan_metadata(st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate); + hDecoderConfig = st_ivas->hDecoderConfig; + numch_out_dirac = hDecoderConfig->nchan_out; + IF(hSpar) + { + numch_out = hSpar->hFbMixer->fb_cfg->num_out_chans; + numch_in = hSpar->hFbMixer->fb_cfg->num_in_chans; + num_md_sub_frames = ivas_get_spar_dec_md_num_subframes(st_ivas->sba_order, hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate); + + for (int l = 0; l < numch_out; l++) + { + for (int j = 0; j < numch_in; j++) + { + for (int n = 0; n < num_md_sub_frames * IVAS_MAX_NUM_BANDS; n++) + { + hSpar->hMdDec->mixer_mat_fx[l][j][n] = floatToFixed(hSpar->hMdDec->mixer_mat[l][j][n], q1); + } + } + } + for (int m = 0; m < MAX_PARAM_SPATIAL_SUBFRAMES + 1; m++) + { + for (int j = 0; j < IVAS_MAX_FB_MIXER_OUT_CH; j++) + { + for (int n = 0; n < IVAS_MAX_SPAR_FB_MIXER_IN_CH; n++) + { + for (int l = 0; l < IVAS_MAX_NUM_BANDS; l++) + { + hSpar->hMdDec->mixer_mat_prev_fx[m][j][n][l] = floatToFixed(hSpar->hMdDec->mixer_mat_prev[m][j][n][l], q2); + } + } + } + } + for (Word16 in_ch = 0; in_ch < numch_in; in_ch++) + { + for (Word16 i = 0; i < st_ivas->cldfbAnaDec[in_ch]->p_filter_length - st_ivas->cldfbAnaDec[in_ch]->no_channels; i++) + { + st_ivas->cldfbAnaDec[in_ch]->cldfb_state_fx[i] = (Word32)(st_ivas->cldfbAnaDec[in_ch]->cldfb_state[i] * (1LL << (Q11))); + } + } + if ((hDecoderConfig->ivas_total_brate < IVAS_24k4) && ((hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_HOA2) || (hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_HOA3))) + { + for (Word16 i = 0; i < IVAS_MAX_NUM_BANDS; i++) + { + floatToFixed_arrL(hSpar->hMdDec->smooth_buf[i], hSpar->hMdDec->smooth_buf_fx[i], 0, 2 * SBA_DIRAC_NRG_SMOOTH_LONG + 1); + } + floatToFixed_arr(hSpar->hMdDec->smooth_fac, hSpar->hMdDec->smooth_fac_fx, Q15, IVAS_MAX_NUM_BANDS); + } + FOR(Word16 out_ch = 0; out_ch < numch_out_dirac; out_ch++) + { + IF(st_ivas->cldfbSynDec[out_ch]) + { + FOR(Word16 i = 0; i < st_ivas->cldfbSynDec[out_ch]->p_filter_length; i++) + { + st_ivas->cldfbSynDec[out_ch]->cldfb_state_fx[i] = float_to_fix(st_ivas->cldfbSynDec[out_ch]->cldfb_state[i], Q11); + } + } + } + } + Word16 n_tc; + if (st_ivas->ivas_format == MASA_ISM_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT) + n_tc = st_ivas->nchan_ism; + else + n_tc = st_ivas->hTcBuffer->nchan_transport_internal; + for (int ch = 0; ch < n_tc; ch++) + { + floatToFixed_arrL(st_ivas->hTcBuffer->tc[ch], st_ivas->hTcBuffer->tc_fx[ch], Q11, L_FRAME48k); + } + } + } + } + //////////////////////////// local flt2fix end + IF((error = ivas_masa_dec_reconfigure_fx(st_ivas, nSamplesRendered, data)) != IVAS_ERR_OK) + { + return error; + } + //////////////////////////// local fix2flt: to be removed + if (hTcBuffer->tc_buffer) + fixedToFloat_arrL(hTcBuffer->tc_buffer_fx, hTcBuffer->tc_buffer, Q11, hTcBuffer->tc_buff_len); + IF(hSpar) + { + numch_in = hSpar->hFbMixer->fb_cfg->num_in_chans; + FOR(Word16 in_ch = 0; in_ch < numch_in; in_ch++) + { + FOR(Word16 i = 0; i < st_ivas->cldfbAnaDec[in_ch]->p_filter_length - st_ivas->cldfbAnaDec[in_ch]->no_channels; i++) + { + st_ivas->cldfbAnaDec[in_ch]->cldfb_state[i] = ((float)(st_ivas->cldfbAnaDec[in_ch]->cldfb_state_fx[i]) / (1LL << (Q11))); /*Rounding off*/ + } + } + FOR(int m = 0; m < MAX_PARAM_SPATIAL_SUBFRAMES + 1; m++) + { + FOR(int j = 0; j < IVAS_MAX_FB_MIXER_OUT_CH; j++) + { + FOR(int n = 0; n < IVAS_MAX_SPAR_FB_MIXER_IN_CH; n++) + { + FOR(int l = 0; l < IVAS_MAX_NUM_BANDS; l++) + { + hSpar->hMdDec->mixer_mat_prev[m][j][n][l] = ((float)hSpar->hMdDec->mixer_mat_prev_fx[m][j][n][l] / (1 << q2)); + } + } + } + } + // fix2float (to be cleaned) + IF((LT_32(hDecoderConfig->ivas_total_brate, IVAS_24k4)) && ((EQ_16(hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_HOA2)) || (EQ_16(hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_HOA3)))) + { + fixedToFloat_arr(hSpar->hMdDec->smooth_fac_fx, hSpar->hMdDec->smooth_fac, Q15, IVAS_MAX_NUM_BANDS); + FOR(Word16 i = 0; i < IVAS_MAX_NUM_BANDS; i++) + { + fixedToFloat_arrL(hSpar->hMdDec->smooth_buf_fx[i], hSpar->hMdDec->smooth_buf[i], 0, 2 * SBA_DIRAC_NRG_SMOOTH_LONG + 1); + } + } + // fix2float end + FOR(Word16 out_ch = 0; out_ch < numch_out_dirac; out_ch++) + { + IF(st_ivas->cldfbSynDec[out_ch]) + { + FOR(Word16 i = 0; i < st_ivas->cldfbSynDec[out_ch]->p_filter_length; i++) + { + st_ivas->cldfbSynDec[out_ch]->cldfb_state[i] = ((float)(st_ivas->cldfbSynDec[out_ch]->cldfb_state_fx[i]) / (float)(1LL << (Q11))); + } + } + } + } + //////////////////////////////////////////////local fix2flt end } IF( LT_32( cpe_brate, MASA_STEREO_MIN_BITRATE ) ) @@ -572,7 +727,7 @@ ivas_error ivas_omasa_dec_config_fx( return IVAS_ERR_OK; } -#endif +#else ivas_error ivas_omasa_dec_config( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ @@ -826,7 +981,7 @@ ivas_error ivas_omasa_dec_config( return IVAS_ERR_OK; } - +#endif /*--------------------------------------------------------------------------* * ivas_set_surplus_brate_dec() @@ -1015,7 +1170,7 @@ void ivas_set_surplus_brate_dec( * * decode ISM metadata in OMASA format *--------------------------------------------------------------------------*/ - +#ifndef IVAS_FLOAT_FIXED ivas_error ivas_omasa_ism_metadata_dec( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const int32_t ism_total_brate, /* i : ISM total bitrate */ @@ -1092,7 +1247,7 @@ ivas_error ivas_omasa_ism_metadata_dec( * * decode ISM metadata in OMASA format *--------------------------------------------------------------------------*/ -#ifdef IVAS_FLOAT_FIXED +#else ivas_error ivas_omasa_ism_metadata_dec_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const Word32 ism_total_brate, /* i : ISM total bitrate */ diff --git a/lib_dec/ivas_osba_dec.c b/lib_dec/ivas_osba_dec.c index a223534ef..54a1c45fd 100644 --- a/lib_dec/ivas_osba_dec.c +++ b/lib_dec/ivas_osba_dec.c @@ -40,6 +40,7 @@ #include "wmc_auto.h" #include "ivas_prot_fx.h" #ifdef IVAS_FLOAT_FIXED +#include "prot_fx1.h" #include "prot_fx2.h" #include "math.h" // temporary (for fabs) #endif // IVAS_FLOAT_FIXED @@ -235,6 +236,31 @@ ivas_error ivas_osba_dirac_td_binaural_jbm( * * ISM metadata decoding in OSBA format. *-------------------------------------------------------------------------*/ +#ifdef IVAS_FLOAT_FIXED +ivas_error ivas_osba_ism_metadata_dec_fx( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const Word32 ism_total_brate, /* i : ISM total bitrate */ + Word16 *nchan_ism, /* o : number of ISM separated channels */ + Word16 nb_bits_metadata[] /* o : number of ISM metadata bits */ +) +{ + ivas_error error; + Word16 nchan_transport_ism; + + /* set ISM parameters */ + nchan_transport_ism = st_ivas->nchan_ism; + *nchan_ism = st_ivas->nchan_ism; + + /* decode ISM metadata */ + IF((error = ivas_ism_metadata_dec_fx(ism_total_brate, *nchan_ism, &nchan_transport_ism, st_ivas->hIsmMetaData, NULL, st_ivas->bfi, + nb_bits_metadata, st_ivas->ism_mode, st_ivas->hISMDTX, NULL, &st_ivas->ism_extmeta_active, &st_ivas->ism_extmeta_cnt, st_ivas->hCPE[0]->hCoreCoder[0])) != IVAS_ERR_OK) + { + return error; + } + + return IVAS_ERR_OK; +} +#else ivas_error ivas_osba_ism_metadata_dec( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ @@ -259,13 +285,85 @@ ivas_error ivas_osba_ism_metadata_dec( return IVAS_ERR_OK; } - +#endif /*-------------------------------------------------------------------------* * ivas_osba_render_sf() * * Object + SBA rendering process. *-------------------------------------------------------------------------*/ +#ifdef IVAS_FLOAT_FIXED +ivas_error ivas_osba_render_sf_fx( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const UWord16 nSamplesAsked, /* i : number of CLDFB slots requested */ + UWord16 *nSamplesRendered, /* o : number of CLDFB slots rendered */ + UWord16 *nSamplesAvailableNext, /* o : number of CLDFB slots still to render */ + Word32 *p_output[] /* o : rendered time signal */ +) +{ + Word16 n; + Word32 output_ism[MAX_OUTPUT_CHANNELS][L_FRAME48k]; + Word32 *p_output_ism[MAX_OUTPUT_CHANNELS]; + ivas_error error; + + FOR(n = 0; n < MAX_OUTPUT_CHANNELS; n++) + { + p_output_ism[n] = &output_ism[n][0]; + } + + FOR(n = 0; n < st_ivas->nchan_ism; n++) + { + Copy32(p_output[n], output_ism[n], nSamplesAsked); + } + +#ifndef IVAS_FLOAT_TO_BE_REMOVED + // Not converted + // Do fixed to float + Word16 q = Q15; + float *p_output_flt[MAX_OUTPUT_CHANNELS]; + FOR(Word16 ind1 = 0; ind1 < st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe; ind1++) + { + p_output_flt[ind1] = (float *)malloc(L_FRAME48k * sizeof(float)); + FOR(Word16 ind2 = 0; ind2 < L_FRAME48k; ind2++) + { + p_output_flt[ind1][ind2] = (float)(p_output[ind1][ind2]) / (float)(1 << q); + } + } +#endif + IF((error = ivas_sba_dec_render(st_ivas, nSamplesAsked, nSamplesRendered, nSamplesAvailableNext, p_output_flt)) != IVAS_ERR_OK) + { + return error; + } +#ifndef IVAS_FLOAT_TO_BE_REMOVED + FOR(Word16 ind1 = 0; ind1 < st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe; ind1++) + { + FOR(Word16 ind2 = 0; ind2 < L_FRAME48k; ind2++) + { + p_output[ind1][ind2] = (Word32)(p_output_flt[ind1][ind2] * (1 << q)); + } + free(p_output_flt[ind1]); + } +#endif + + IF(st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV_ROOM) + { + ivas_ism_render_sf_fx(st_ivas, p_output_ism, *nSamplesRendered); + } + + FOR(n = 0; n < st_ivas->hDecoderConfig->nchan_out; n++) + { + IF(st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV_ROOM) + { + v_add_fixed(p_output[n], p_output_ism[n], p_output[n], *nSamplesRendered, 1); //takes care of downscaling by 0.5f + } + ELSE{ + scale_sig32(p_output[n], *nSamplesRendered, -1); + } + //v_multc_fixed(p_output[n], 1073741824 /* 0.5f in Q31 */, p_output[n], *nSamplesRendered); + } + return IVAS_ERR_OK; +} +#else ivas_error ivas_osba_render_sf( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ @@ -311,3 +409,4 @@ ivas_error ivas_osba_render_sf( return IVAS_ERR_OK; } +#endif diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 65294906b..3674cbd21 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -253,21 +253,6 @@ ivas_error ivas_sba_dec_reconfigure( #if 1 /*Float to fixed conversion*/ DECODER_TC_BUFFER_HANDLE hTcBuffer; hTcBuffer = st_ivas->hTcBuffer; - if ( st_ivas->hIsmRendererData ) - { - FOR( Word16 ind1 = 0; ind1 < st_ivas->hIsmRendererData->interpolator_len; ind1++ ) - { - st_ivas->hIsmRendererData->interpolator_fx[ind1] = (Word16) L_min( 32767, floatToFixed( st_ivas->hIsmRendererData->interpolator_fx[ind1], 15 ) ); - } - } - FOR( Word16 ind1 = 0; ind1 < MAX_NUM_OBJECTS; ind1++ ) - { - if ( st_ivas->hIsmMetaData[ind1] ) - { - st_ivas->hIsmMetaData[ind1]->azimuth_fx = (Word32) ( st_ivas->hIsmMetaData[ind1]->azimuth * ( 1 << 22 ) ); - st_ivas->hIsmMetaData[ind1]->elevation_fx = (Word32) ( st_ivas->hIsmMetaData[ind1]->elevation * ( 1 << 22 ) ); - } - } IF( st_ivas->hCombinedOrientationData ) FOR( Word16 ind1 = 0; ind1 < 3; ind1++ ) { @@ -407,14 +392,6 @@ ivas_error ivas_sba_dec_reconfigure( } } } - FOR( Word16 ind1 = 0; ind1 < MAX_NUM_OBJECTS; ind1++ ) - { - if ( st_ivas->hIsmMetaData[ind1] ) - { - st_ivas->hIsmMetaData[ind1]->azimuth = (float) ( st_ivas->hIsmMetaData[ind1]->azimuth_fx ) / (float) ( 1 << 22 ); - st_ivas->hIsmMetaData[ind1]->elevation = (float) ( st_ivas->hIsmMetaData[ind1]->elevation_fx ) / (float) ( 1 << 22 ); - } - } #endif #else if ( ( error = ivas_jbm_dec_flush_renderer( st_ivas, granularity_new, st_ivas->renderer_type, st_ivas->intern_config, &st_ivas->hIntSetup, st_ivas->mc_mode, ism_mode_old, nSamplesFlushed, data ) ) != IVAS_ERR_OK ) diff --git a/lib_dec/ivas_sba_rendering_internal.c b/lib_dec/ivas_sba_rendering_internal.c index 5a872443a..3829a9213 100644 --- a/lib_dec/ivas_sba_rendering_internal.c +++ b/lib_dec/ivas_sba_rendering_internal.c @@ -652,7 +652,7 @@ void ivas_ism2sba_sf_fx( } return; } -#endif // IVAS_FLOAT_FIXED +#else // IVAS_FLOAT_FIXED void ivas_ism2sba_sf( float *buffer_in[], /* i : TC buffer */ @@ -708,7 +708,7 @@ void ivas_ism2sba_sf( return; } - +#endif /*-------------------------------------------------------------------* * ivas_sba_linear_renderer() diff --git a/lib_dec/ivas_sce_dec.c b/lib_dec/ivas_sce_dec.c index e867dbaf8..781a2504a 100644 --- a/lib_dec/ivas_sce_dec.c +++ b/lib_dec/ivas_sce_dec.c @@ -375,7 +375,7 @@ ivas_error create_sce_dec( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DTX/TD CNG\n" ) ); } - td_cng_dec_init_flt( st ); + td_cng_dec_init( st ); } /*-----------------------------------------------------------------* diff --git a/lib_dec/ivas_sce_dec_fx.c b/lib_dec/ivas_sce_dec_fx.c index d86339188..74a37d1ba 100644 --- a/lib_dec/ivas_sce_dec_fx.c +++ b/lib_dec/ivas_sce_dec_fx.c @@ -458,7 +458,7 @@ ivas_error create_sce_dec( #ifdef IVAS_FLOAT_FIXED td_cng_dec_init_ivas_fx( st ); #else - td_cng_dec_init_flt( st ); + td_cng_dec_init( st ); #endif // IVAS_FLOAT_FIXED } diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 1ad0d9a19..e9602d536 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -778,6 +778,13 @@ typedef struct dirac_output_synthesis_cov_state_structure Word32 *mixing_matrix_fx[CLDFB_NO_CHANNELS_MAX]; Word32 *mixing_matrix_res_old_fx[CLDFB_NO_CHANNELS_MAX]; Word32 *mixing_matrix_res_fx[CLDFB_NO_CHANNELS_MAX]; + + Word16 *cx_old_e; + Word16 *cy_old_e; + Word16 *mixing_matrix_old_e; + Word16 *mixing_matrix_e; + Word16 *mixing_matrix_res_old_e; + Word16 *mixing_matrix_res_e; #endif // IVAS_FLOAT_FIXED } DIRAC_OUTPUT_SYNTHESIS_COV_STATE; @@ -858,6 +865,7 @@ typedef struct ivas_param_mc_dec_data_structure Word32 *ls_conv_dmx_matrix_fx; Word16 ls_conv_dmx_e; Word32 *proto_matrix_int_fx; + Word16 proto_matrix_int_e; #endif /*sub-modules*/ @@ -1218,16 +1226,17 @@ typedef struct ivas_lfe_dec_data_structure typedef struct renderer_struct { - float prev_gains[MAX_CICP_CHANNELS - 1][MAX_OUTPUT_CHANNELS]; - float *interpolator; #ifdef IVAS_FLOAT_FIXED Word32 prev_gains_fx[MAX_CICP_CHANNELS - 1][MAX_OUTPUT_CHANNELS]; Word16 *interpolator_fx; Word16 interpolator_len; Word32 gains_fx[MAX_CICP_CHANNELS - 1][MAX_OUTPUT_CHANNELS]; -#endif +#else + float prev_gains[MAX_CICP_CHANNELS - 1][MAX_OUTPUT_CHANNELS]; + float *interpolator; int16_t interpolator_length; float gains[MAX_CICP_CHANNELS - 1][MAX_OUTPUT_CHANNELS]; +#endif } ISM_RENDERER_DATA, *ISM_RENDERER_HANDLE; diff --git a/lib_dec/ivas_stereo_dft_dec.c b/lib_dec/ivas_stereo_dft_dec.c index c11f9d264..5ac890f7c 100644 --- a/lib_dec/ivas_stereo_dft_dec.c +++ b/lib_dec/ivas_stereo_dft_dec.c @@ -350,11 +350,7 @@ ivas_error stereo_dft_dec_create( } else { -#ifdef IVAS_FLOAT_FIXED - stereo_dft_config_fx( hStereoDft_loc->hConfig, element_brate, &tmpS, &tmpS ); -#else stereo_dft_config( hStereoDft_loc->hConfig, element_brate, &tmpS, &tmpS ); -#endif } stereo_dft_dec_open( hStereoDft_loc, output_Fs, nchan_transport ); @@ -483,51 +479,16 @@ void stereo_dft_dec_open( hStereoDft->dft_trigo_8k = dft_trigo_32k; hStereoDft->dft_trigo_12k8 = dft_trigo_12k8; hStereoDft->dft_trigo_16k = dft_trigo_32k; -#ifdef IVAS_FLOAT_FIXED - switch (output_Fs) - { - case 48000: - hStereoDft->ONE_NFFT = (Word32) ( 0x00222222 ); - BREAK; - case 32000: - hStereoDft->ONE_NFFT = (Word32) ( 0x00333333 ); - BREAK; - case 16000: - hStereoDft->ONE_NFFT = (Word32) ( 0x00666666 ); - BREAK; - case 8000: - hStereoDft->ONE_NFFT = (Word32) ( 0x00CCCCCC ); - BREAK; - default: - assert(0); - } - hStereoDft->dft_trigo_8k_fx = dft_trigo_32k_fx; - hStereoDft->dft_trigo_12k8_fx = dft_trigo_12k8_fx; - hStereoDft->dft_trigo_16k_fx = dft_trigo_32k_fx; -#endif - hStereoDft->dft32ms_ovl = (int16_t) ( ( STEREO_DFT32MS_OVL_MAX * output_Fs ) / 48000 ); hStereoDft->win232ms_8k = dft_win232ms_8k; hStereoDft->win232ms_12k8 = dft_win232ms_12k8; hStereoDft->win232ms_16k = dft_win232ms_16k; -#ifdef IVAS_FLOAT_FIXED - hStereoDft->win232ms_8k_fx = dft_win232ms_8k_fx; - hStereoDft->win232ms_12k8_fx = dft_win232ms_12k8_fx; - hStereoDft->win232ms_16k_fx = dft_win232ms_16k_fx; -#endif - hStereoDft->dft32ms_ovl2 = (int16_t) ( ( STEREO_DFT32MS_OVL2_MAX * output_Fs ) / 48000 ); hStereoDft->win32ms_8k = dft_win232ms_8k + 1; hStereoDft->win32ms_12k8 = dft_win232ms_12k8 + 1; hStereoDft->win32ms_16k = dft_win232ms_16k + 1; -#ifdef IVAS_FLOAT_FIXED - hStereoDft->win32ms_8k_fx = dft_win232ms_8k_fx + 1; - hStereoDft->win32ms_12k8_fx = dft_win232ms_12k8_fx + 1; - hStereoDft->win32ms_16k_fx = dft_win232ms_16k_fx + 1; -#endif - if ( output_Fs == 16000 ) { @@ -535,12 +496,6 @@ void stereo_dft_dec_open( hStereoDft->dft_trigo_step = STEREO_DFT_TRIGO_SRATE_16k_STEP; hStereoDft->win232ms = dft_win232ms_16k; hStereoDft->win32ms = dft_win232ms_16k + 1; - -#ifdef IVAS_FLOAT_FIXED - hStereoDft->dft_trigo_fx = dft_trigo_32k_fx; - hStereoDft->win232ms_fx = dft_win232ms_16k_fx; - hStereoDft->win32ms_fx = dft_win232ms_16k_fx + 1; -#endif } else if ( output_Fs == 32000 ) { @@ -548,12 +503,6 @@ void stereo_dft_dec_open( hStereoDft->dft_trigo_step = STEREO_DFT_TRIGO_SRATE_32k_STEP; hStereoDft->win232ms = dft_win232ms_32k; hStereoDft->win32ms = dft_win232ms_32k + 1; - -#ifdef IVAS_FLOAT_FIXED - hStereoDft->dft_trigo_fx = dft_trigo_32k_fx; - hStereoDft->win232ms_fx = dft_win232ms_32k_fx; - hStereoDft->win32ms_fx = dft_win232ms_32k_fx + 1; -#endif } else { @@ -562,27 +511,14 @@ void stereo_dft_dec_open( hStereoDft->dft_trigo_step = STEREO_DFT_TRIGO_SRATE_48k_STEP; hStereoDft->win232ms = dft_win232ms_48k; hStereoDft->win32ms = dft_win232ms_48k + 1; - -#ifdef IVAS_FLOAT_FIXED - hStereoDft->dft_trigo_fx = dft_trigo_48k_fx; - hStereoDft->win232ms_fx = dft_win232ms_48k_fx; - hStereoDft->win32ms_fx = dft_win232ms_48k_fx + 1; -#endif } hStereoDft->win_8k = dft_win_8k; -#ifdef IVAS_FLOAT_FIXED - hStereoDft->win_8k_fx = dft_win_8k_fx; -#endif /*Bands: find the number of bands, Nyquist freq. is not taken into account*/ set_s( hStereoDft->band_res, hStereoDft->hConfig->band_res, STEREO_DFT_DEC_DFT_NB ); -#ifdef IVAS_FLOAT_FIXED - hStereoDft->nbands = stereo_dft_band_config_fx( hStereoDft->band_limits, hStereoDft->band_res[0], hStereoDft->NFFT, DEC ); -#else hStereoDft->nbands = stereo_dft_band_config( hStereoDft->band_limits, hStereoDft->band_res[0], hStereoDft->NFFT, DEC ); -#endif hStereoDft->hb_stefi_delay = NS2SA( output_Fs, STEREO_DFT_TD_STEFI_DELAY_NS ); if ( nchan_transport > 2 ) @@ -596,19 +532,6 @@ void stereo_dft_dec_open( hStereoDft->max_smooth_gains = max_smooth_gains1; } -#ifdef IVAS_FLOAT_FIXED - if ( nchan_transport > 2 ) - { - hStereoDft->min_smooth_gains_fx = min_smooth_gains2_fx; - hStereoDft->max_smooth_gains_fx = max_smooth_gains2_fx; - } - else - { - hStereoDft->min_smooth_gains_fx = min_smooth_gains1_fx; - hStereoDft->max_smooth_gains_fx = max_smooth_gains1_fx; - } -#endif - /* reset DFT stereo memories */ stereo_dft_dec_reset( hStereoDft ); @@ -2231,11 +2154,7 @@ void stereo_dft_dec( /* make sure number of bands corresponds to output bwidth in case it is lower than parameter bwidth */ if ( output_frame < inner_frame_tbl[st0->bwidth] && !sba_dirac_stereo_flag ) { -#ifdef IVAS_FLOAT_FIXED - hStereoDft->nbands = stereo_dft_band_config_fx( hStereoDft->band_limits, hStereoDft->band_res[k_offset], hStereoDft->NFFT, DEC ); -#else hStereoDft->nbands = stereo_dft_band_config( hStereoDft->band_limits, hStereoDft->band_res[k_offset], hStereoDft->NFFT, DEC ); -#endif } if ( !st0->bfi ) @@ -2304,11 +2223,7 @@ void stereo_dft_dec( if ( hStereoDft->frame_sid_nodata && !sba_dirac_stereo_flag ) { NFFT_inner = STEREO_DFT32MS_N_MAX * inner_frame_tbl[st0->bwidth] / L_FRAME48k; -#ifdef IVAS_FLOAT_FIXED - hStereoDft->nbands = stereo_dft_band_config_fx( hStereoDft->band_limits, 2, NFFT_inner, DEC ); -#else hStereoDft->nbands = stereo_dft_band_config( hStereoDft->band_limits, 2, NFFT_inner, DEC ); -#endif } @@ -2800,22 +2715,7 @@ void stereo_dft_dec_res( bass_psfilter( hCPE->hStereoDft->hBpf, hCPE->hCoreCoder[0]->Opt_AMR_WB, output, L_FRAME8k, hCPE->hCoreCoder[0]->old_pitch_buf + ( L_FRAME8k / STEREO_DFT_L_SUBFR_8k ), hCPE->hCoreCoder[0]->bpf_off, hCPE->hCoreCoder[0]->stab_fac, &hCPE->hStereoDft->stab_fac_smooth_res, hCPE->hCoreCoder[0]->last_coder_type, bpf_error_signal_8k ); -#ifndef IVAS_FLOAT_FIXED res_bpf_flag = res_bpf_adapt( hCPE->hStereoDft, bpf_error_signal_8k, res_buf ); -#else - Word32 bpf_error_signal_8k_fx[L_FRAME8k]; - Word32 res_buf_fx[STEREO_DFT_N_8k]; - FOR( int k = 0; k < STEREO_DFT_N_8k; k++ ) - { - res_buf_fx[k] = (Word32) ( res_buf[k] * ONE_IN_Q12 ); - } - FOR( int k = 0; k < L_FRAME8k; k++ ) - { - bpf_error_signal_8k_fx[k] = (Word32) ( bpf_error_signal_8k[k] * ONE_IN_Q16 ); - } - - res_bpf_flag = res_bpf_adapt_fx( hCPE->hStereoDft, bpf_error_signal_8k_fx, res_buf_fx ); -#endif // IVAS_FLOAT_FIXED if ( prev_bfi ) { diff --git a/lib_dec/ivas_stereo_dft_dec_fx.c b/lib_dec/ivas_stereo_dft_dec_fx.c index 03b0c9fec..a259839b3 100644 --- a/lib_dec/ivas_stereo_dft_dec_fx.c +++ b/lib_dec/ivas_stereo_dft_dec_fx.c @@ -50,7 +50,6 @@ #include "ivas_prot_fx.h" #include "basop_util.h" #include "prot_fx1.h" -#endif // IVAS_FLOAT_FIXED /*-------------------------------------------------------------------* * Local constants @@ -1263,7 +1262,7 @@ void stereo_dft_dec_res_fx( bass_psfilter_fx( hCPE->hStereoDft->hBpf, hCPE->hCoreCoder[0]->Opt_AMR_WB, out_16, L_FRAME8k, hCPE->hCoreCoder[0]->old_pitch_buf_16_fx + ( L_FRAME8k / STEREO_DFT_L_SUBFR_8k ), hCPE->hCoreCoder[0]->bpf_off, hCPE->hCoreCoder[0]->stab_fac_fx, &hCPE->hStereoDft->stab_fac_smooth_res_fx, hCPE->hCoreCoder[0]->last_coder_type, 0, bpf_error_signal_8k_16 ); Copy_Scale_sig_16_32(bpf_error_signal_8k_16, bpf_error_signal_8k, L_FRAME8k, Q15); - res_bpf_flag = res_bpf_adapt_fx( hCPE->hStereoDft, bpf_error_signal_8k, res_buf ); + res_bpf_flag = res_bpf_adapt_ivas_fx( hCPE->hStereoDft, bpf_error_signal_8k, res_buf ); IF ( prev_bfi ) { @@ -3736,4 +3735,5 @@ void stereo_dft_dec_read_BS_fx( return; } -#endif \ No newline at end of file +#endif +#endif // IVAS_FLOAT_FIXED diff --git a/lib_dec/ivas_stereo_switching_dec.c b/lib_dec/ivas_stereo_switching_dec.c index 2c965c287..a4c5ef026 100644 --- a/lib_dec/ivas_stereo_switching_dec.c +++ b/lib_dec/ivas_stereo_switching_dec.c @@ -744,7 +744,7 @@ ivas_error stereo_memory_dec( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DTX/TD CNG\n" ) ); } - td_cng_dec_init_flt( st ); + td_cng_dec_init( st ); } } @@ -1412,9 +1412,9 @@ ivas_error stereo_memory_dec_fx( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DTX/TD CNG\n" ) ); } - td_cng_dec_init( st ); + td_cng_dec_init_fx( st ); #if 1 // TODO: To be removed later - //td_cng_dec_init_flt( st ); + //td_cng_dec_init( st ); #endif } } diff --git a/lib_dec/ivas_tcx_core_dec.c b/lib_dec/ivas_tcx_core_dec.c index d46fa681e..66f5a428e 100644 --- a/lib_dec/ivas_tcx_core_dec.c +++ b/lib_dec/ivas_tcx_core_dec.c @@ -1616,7 +1616,7 @@ static void stereo_tcx_dec_mode_switch_reconf( } /* Reconfigure Core */ - mode_switch_decoder_LPD_flt( st, st->bwidth, st->bits_frame_nominal * FRAMES_PER_SEC, st->last_bits_frame_nominal * FRAMES_PER_SEC, frame_size_index, MCT_flag, last_element_mode ); + mode_switch_decoder_LPD( st, st->bwidth, st->bits_frame_nominal * FRAMES_PER_SEC, st->last_bits_frame_nominal * FRAMES_PER_SEC, frame_size_index, MCT_flag, last_element_mode ); return; } diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 334bf6242..3b06518e7 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -1358,11 +1358,19 @@ ivas_error IVAS_DEC_GetObjectMetadata( } ELSE { +#ifdef IVAS_FLOAT_FIXED + metadata->azimuth = fixedToFloat(hIsmMeta->azimuth_fx, Q22); + metadata->elevation = fixedToFloat(hIsmMeta->elevation_fx, Q22); + metadata->radius = fixedToFloat(hIsmMeta->radius_fx, Q9); + metadata->yaw = fixedToFloat(hIsmMeta->yaw_fx, Q22); + metadata->pitch = fixedToFloat(hIsmMeta->pitch_fx, Q22); +#else metadata->azimuth = hIsmMeta->azimuth; metadata->elevation = hIsmMeta->elevation; metadata->radius = hIsmMeta->radius; metadata->yaw = hIsmMeta->yaw; metadata->pitch = hIsmMeta->pitch; +#endif metadata->spread = 0.f; metadata->gainFactor = 1.f; metadata->non_diegetic_flag = hIsmMeta->non_diegetic_flag; diff --git a/lib_rend/ivas_dirac_rend.c b/lib_rend/ivas_dirac_rend.c index 9662620c5..30686c586 100644 --- a/lib_rend/ivas_dirac_rend.c +++ b/lib_rend/ivas_dirac_rend.c @@ -4543,7 +4543,7 @@ void computeDirectionAngles_fx( return; } -//#else +#else /*------------------------------------------------------------------------- * computeDirectionAngles() * @@ -5002,7 +5002,7 @@ void computeIntensityVector_dec_fx( return; } -//#else +#else /*------------------------------------------------------------------------- * computeIntensityVector_dec() * diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index f39eeaf80..5232930c9 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -433,7 +433,7 @@ void computeIntensityVector_dec_fx( Word32 *intensity_real_z_fx, Word16 *q_intensity_real ); -//#else +#else void computeIntensityVector_dec( float Cldfb_RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], float Cldfb_ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], @@ -600,7 +600,7 @@ void computeDirectionAngles_fx( Word16 *azimuth, Word16 *elevation ); -//#else +#else void computeDirectionAngles( float *intensity_real_x, float *intensity_real_y, diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index 1d234c57b..3cd0917bf 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -343,6 +343,7 @@ typedef struct dirac_output_synthesis_params_structure float diffuse_compensation_factor_decorr; #ifdef IVAS_FLOAT_FIXED Word32 *proto_matrix_fx; + Word16 proto_matrix_e; Word32 diffuse_compensation_factor_fx; // Q27 Word32 diffuse_compensation_factor_decorr_fx; // Q29 #endif @@ -1092,8 +1093,8 @@ typedef struct ivas_combined_orientation_struct IVAS_QUATERNION Quaternion_prev_extOrientation; IVAS_QUATERNION Quaternions_ext_interpolation_start; IVAS_QUATERNION Quaternions_ext_interpolation_target; - float Rmat[MAX_PARAM_SPATIAL_SUBFRAMES][3][3]; Word32 Rmat_fx[MAX_PARAM_SPATIAL_SUBFRAMES][3][3]; + float Rmat[MAX_PARAM_SPATIAL_SUBFRAMES][3][3]; float Rmat_prev[3][3]; Word32 Rmat_prev_fx[3][3]; float chEneIIR[2][MASA_FREQUENCY_BANDS]; /* independent of the format. MASA bands are suitable for the task and readily available in ROM. */ -- GitLab