From be30e10fdc062b6be7ab20e4cdf1d5fcbb430c45 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Fri, 24 May 2024 10:50:38 +0530 Subject: [PATCH] Cleanup in initializations, lib_rend, JBM files [x] Float dependencies clean up in lib_rend modules [x] Float dependencies clean up in jbm_dec [x] Cleanup of decoder initializations [x] Macro additions for float code and fixed code --- apps/renderer.c | 13 +- lib_com/float_to_fix_ops.c | 4 +- lib_com/ivas_prot.h | 20 +- lib_com/ivas_prot_fx.h | 4 +- lib_com/ivas_tools.c | 26 + lib_com/prot.h | 36 +- lib_com/rom_com.c | 28 +- lib_com/swb_tbe_com_fx.c | 29 +- lib_dec/core_dec_init.c | 793 ---------- lib_dec/core_dec_init_fx.c | 35 +- lib_dec/core_switching_dec.c | 58 +- lib_dec/dec_tcx.c | 4 +- lib_dec/fd_cng_dec.c | 60 +- lib_dec/hdecnrm.c | 13 +- lib_dec/hq_classifier_dec.c | 2 + lib_dec/hq_classifier_dec_fx.c | 3 +- lib_dec/hq_conf_fec.c | 2 + lib_dec/hq_conf_fec_fx.c | 2 + lib_dec/hq_core_dec_fx.c | 6 +- lib_dec/hq_env_dec.c | 4 + lib_dec/hq_env_dec_fx.c | 4 + lib_dec/hq_hr_dec_fx.c | 4 +- lib_dec/hq_lr_dec_fx.c | 3 +- lib_dec/igf_dec.c | 57 +- lib_dec/igf_dec_fx.c | 23 +- lib_dec/igf_scf_dec.c | 2 + lib_dec/igf_scf_dec_fx.c | 3 +- lib_dec/init_dec.c | 11 +- lib_dec/init_dec_fx.c | 4 - lib_dec/ivas_core_dec.c | 124 -- lib_dec/ivas_cpe_dec_fx.c | 77 +- lib_dec/ivas_dirac_dec.c | 1546 +++++++++----------- lib_dec/ivas_init_dec.c | 5 +- lib_dec/ivas_ism_renderer.c | 2 +- lib_dec/ivas_jbm_dec.c | 1268 ++-------------- lib_dec/ivas_ls_custom_dec.c | 4 +- lib_dec/ivas_mc_param_dec.c | 2 +- lib_dec/ivas_mct_dec.c | 2 + lib_dec/ivas_mdct_core_dec.c | 4 +- lib_dec/ivas_out_setup_conversion.c | 2 +- lib_dec/ivas_sce_dec_fx.c | 17 +- lib_dec/ivas_spar_decoder.c | 86 +- lib_dec/ivas_stereo_dft_dec_fx.c | 6 +- lib_dec/ivas_stereo_mdct_core_dec_fx.c | 2 +- lib_dec/ivas_stereo_switching_dec.c | 9 +- lib_dec/lib_dec_fx.c | 363 ++++- lib_dec/peak_vq_dec.c | 18 + lib_dec/stat_dec.h | 14 +- lib_rend/ivas_dirac_output_synthesis_dec.c | 7 +- lib_rend/ivas_dirac_rend.c | 7 +- lib_rend/ivas_objectRenderer.c | 6 +- lib_rend/ivas_output_init.c | 28 - lib_rend/ivas_rotation.c | 18 +- lib_rend/ivas_stat_rend.h | 7 +- lib_rend/lib_rend.c | 545 ++++++- lib_util/ism_file_reader.c | 7 + 56 files changed, 1990 insertions(+), 3439 deletions(-) diff --git a/apps/renderer.c b/apps/renderer.c index 5667a3042..82eb11067 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -48,7 +48,6 @@ #include "vector3_pair_file_reader.h" #include "wmc_auto.h" - #define WMC_TOOL_SKIP /*------------------------------------------------------------------------------------------* @@ -2538,6 +2537,10 @@ void getMetadataFromFileReader( fprintf( stderr, "\nError (%s) while reading ISM metadata from: %s\n\n", ivas_error_to_string( error ), IsmFileReader_getFilePath( ismReader ) ); exit( -1 ); } +#ifdef IVAS_FLOAT_FIXED + objectMetadataBuffer->positions[objIdx].azimuth_fx = (Word32)(ismMetadata.azimuth * (1<<22)); + objectMetadataBuffer->positions[objIdx].elevation_fx = (Word32)(ismMetadata.elevation * (1 << 22)); +#endif // DEBUG objectMetadataBuffer->positions[objIdx].azimuth = ismMetadata.azimuth; objectMetadataBuffer->positions[objIdx].elevation = ismMetadata.elevation; @@ -2617,6 +2620,10 @@ static void IsmPositionProvider_getNextFrame( /* Clamp elevation to lie within [-90, 90] range (can't be wrapped easily) */ objectMetadataBuffer->positions[objIdx].elevation = min( max( objectMetadataBuffer->positions[objIdx].elevation, -90 ), 90 ); +#ifdef IVAS_FLOAT_FIXED + objectMetadataBuffer->positions[objIdx].azimuth_fx = (Word32)(objectMetadataBuffer->positions[objIdx].azimuth * (1 << 22)); + objectMetadataBuffer->positions[objIdx].elevation_fx = (Word32)(objectMetadataBuffer->positions[objIdx].elevation * (1 << 22)); +#endif // IVAS_FLOAT_FIXED /* Wrap yaw to lie within (-180, 180] range */ while ( objectMetadataBuffer->positions[objIdx].yaw < 0.0f ) { @@ -2935,6 +2942,10 @@ static void parseObjectPosition( position->azimuth = meta_prm[0]; position->elevation = meta_prm[1]; +#ifdef IVAS_FLOAT_FIXED + position->azimuth_fx = (Word32)(meta_prm[0] * (1 << 22)); + position->elevation_fx = (Word32)(meta_prm[1] * (1 << 22)); +#endif // IVAS_FLOAT_FIXED position->radius = meta_prm[2]; position->yaw = meta_prm[5]; position->pitch = meta_prm[6]; diff --git a/lib_com/float_to_fix_ops.c b/lib_com/float_to_fix_ops.c index 62c15f1f1..41d1d6b2f 100644 --- a/lib_com/float_to_fix_ops.c +++ b/lib_com/float_to_fix_ops.c @@ -368,8 +368,8 @@ void stereo_tcx_dec_mode_switch_reconf_To_fixed( } IF( st->hHQ_core ) { - st->hHQ_core->Q_old_out = Q_factor_arr( st->hHQ_core->old_out, L_FRAME48k ); - st->hHQ_core->Q_old_outLB = Q_factor_arr( st->hHQ_core->old_outLB, L_FRAME32k ); + //st->hHQ_core->Q_old_out = Q_factor_arr( st->hHQ_core->old_out, L_FRAME48k ); + //st->hHQ_core->Q_old_outLB = Q_factor_arr( st->hHQ_core->old_outLB, L_FRAME32k ); st->hHQ_core->Q_fer_samples = 0; //floatToFixed_arr( st->hHQ_core->old_out, st->hHQ_core->old_out_fx, st->hHQ_core->Q_old_out, L_FRAME48k ); //floatToFixed_arr( st->hHQ_core->old_outLB, st->hHQ_core->old_out_LB_fx, st->hHQ_core->Q_old_outLB, L_FRAME32k ); diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 290ef3f88..aa02ae30c 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -280,6 +280,15 @@ void ivas_syn_output_f( float *synth_out /* o : integer 16 bits synthesis signal */ ); +#ifdef IVAS_FLOAT_FIXED +void ivas_syn_output_f_fx( + Word32 *synth[], /* i/o: float synthesis signal */ + const Word16 output_frame, /* i : output frame length (one channel) */ + const Word16 n_channels, /* i : number of output channels */ + Word32 *synth_out /* o : integer 16 bits synthesis signal */ +); +#endif + void ivas_initialize_handles_enc( Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ ); @@ -881,12 +890,14 @@ void TonalMdctConceal_whiten_noise_shape_ivas( const TONALMDCTCONC_NOISE_SHAPE_WHITENING_MODE ); +#ifndef IVAS_FLOAT_FIXED /*! r: IGF start line */ int16_t get_igf_startline_flt( Decoder_State *st, /* i : decoder state */ const int16_t L_frame, /* i : length of the frame */ const int16_t L_frameTCX /* i : full band frame length */ ); +#endif float rand_triangular_signed( int16_t *seed ); @@ -918,10 +929,17 @@ void ivas_apply_non_diegetic_panning( * JBM prototypes *----------------------------------------------------------------------------------*/ +#ifdef IVAS_FLOAT_FIXED +ivas_error ivas_jbm_dec_tc_fx( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + Word32 *data_fx +); +#else ivas_error ivas_jbm_dec_tc( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - float *data /* o : output synthesis signals */ + float *data /* o : output synthesis signals */ ); +#endif ivas_error ivas_jbm_dec_render( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index c1c36e15b..177156f76 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -2111,8 +2111,8 @@ void ivas_dirac_dec_render_sf_fx( Word32 *output_fx[], /* i/o: synthesized core-coder transport channels/DirAC output */ #endif // MSAN_FIX const int16_t nchan_transport, /* i : number of transport channels */ - float *pppQMfFrame_ts_re[IVAS_MAX_FB_MIXER_IN_CH][CLDFB_NO_COL_MAX], - float *pppQMfFrame_ts_im[IVAS_MAX_FB_MIXER_IN_CH][CLDFB_NO_COL_MAX] + Word32 *pppQMfFrame_ts_re_fx[IVAS_MAX_FB_MIXER_IN_CH][CLDFB_NO_COL_MAX], + Word32 *pppQMfFrame_ts_im_fx[IVAS_MAX_FB_MIXER_IN_CH][CLDFB_NO_COL_MAX] ); void ivas_dirac_dec_render_fx( diff --git a/lib_com/ivas_tools.c b/lib_com/ivas_tools.c index 49b1fea1d..c8a0475b5 100644 --- a/lib_com/ivas_tools.c +++ b/lib_com/ivas_tools.c @@ -215,6 +215,32 @@ void ivas_syn_output_f( return; } +#ifdef IVAS_FLOAT_FIXED +void ivas_syn_output_f_fx( + Word32 *synth[], /* i/o: float synthesis signal */ + const Word16 output_frame, /* i : output frame length (one channel) */ + const Word16 n_channels, /* i : number of output channels */ + Word32 *synth_out /* o : integer 16 bits synthesis signal */ +) +{ + Word16 i, n; + + /*-----------------------------------------------------------------* + * float to integer conversion with saturation control + *-----------------------------------------------------------------*/ + + FOR ( n = 0; n < n_channels; n++ ) + { + FOR ( i = 0; i < output_frame; i++ ) + { + synth_out[i * n_channels + n] = synth[n][i]; + } + } + + return; +} + +#endif /*-------------------------------------------------------------------* * mvr2r_inc() diff --git a/lib_com/prot.h b/lib_com/prot.h index f47b3d917..18a0d52b9 100644 --- a/lib_com/prot.h +++ b/lib_com/prot.h @@ -1756,6 +1756,7 @@ void diff_envelope_coding( int16_t *difidx /* o : differential code */ ); +#ifndef IVAS_FLOAT_FIXED /*! r: Number of bits */ int16_t decode_envelope_indices( Decoder_State *st, /* i/o: decoder state structure */ @@ -1766,7 +1767,9 @@ int16_t decode_envelope_indices( const int16_t flag_HQ2, /* i : indicator of HQ2 core */ const int16_t is_transient /* i : transient flag */ ); +#endif +#ifndef IVAS_FLOAT_FIXED /*! r: Number of bits */ void dequantize_norms( Decoder_State *st, /* i/o: decoder state structure */ @@ -1776,6 +1779,7 @@ void dequantize_norms( int16_t *ynrm, /* o : Decoded norm indices */ int16_t *normqlg2 /* o : Log2 of decoded norms */ ); +#endif void hq_configure( const int16_t length, /* i : Frame length */ @@ -1822,6 +1826,7 @@ int16_t hq_classifier_enc( int16_t *hqswb_clas /* o : HQ class */ ); +#ifndef IVAS_FLOAT_FIXED /*! r: Consumed bits */ int16_t hq_classifier_dec( Decoder_State *st, /* i/o: decoder state structure */ @@ -1830,6 +1835,7 @@ int16_t hq_classifier_dec( int16_t *is_transient, /* o : Transient flag */ int16_t *hqswb_clas /* o : HQ class */ ); +#endif void hq_bit_allocation( const int32_t core_brate, /* i : Core bitrate */ @@ -5440,6 +5446,7 @@ void logqnorm( const int16_t N, /* i : sub-vector size */ const float *thren ); +#ifndef IVAS_FLOAT_FIXED void huff_dec( Decoder_State *st, /* i/o: decoder state structure */ const int16_t N, /* i : Number of codewords to decode */ @@ -5450,6 +5457,7 @@ void huff_dec( const int16_t *huff_tab, /* i : Huffman table order by codeword lengths */ int16_t *index /* o : Decoded index */ ); +#endif void calc_norm( const float *x, /* i : Input vector. */ @@ -5590,30 +5598,38 @@ void hq_hr_dec( ); +#ifndef IVAS_FLOAT_FIXED void hdecnrm_context( Decoder_State *st, /* i/o: decoder state structure */ const int16_t N, /* i : number of norms */ int16_t *index, /* o : indices of quantized norms */ int16_t *n_length /* o : decoded stream length */ ); +#endif +#ifndef IVAS_FLOAT_FIXED void hdecnrm_tran( Decoder_State *st, /* i/o: decoder state structure */ const int16_t N, /* i : number of norms */ int16_t *index /* o : indices of quantized norms */ ); +#endif +#ifndef IVAS_FLOAT_FIXED void hdecnrm_resize( Decoder_State *st, /* i/o: decoder state structure */ const int16_t N, /* i : number of SFMs */ int16_t *index /* o : norm quantization index vector */ ); +#endif +#ifndef IVAS_FLOAT_FIXED void hdecnrm( Decoder_State *st, /* i/o: decoder state structure */ const int16_t N, /* i : number of norms */ int16_t *index /* o : indices of quantized norms */ ); +#endif /*! r: index of last band */ int16_t find_last_band( @@ -8881,13 +8897,13 @@ void generate_masking_noise_ivas_fx( Word32 *timeDomainBuffer, /* i/o: time-domain signal */ Word16 *exp_out, /* o : time-domain signal exp */ HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */ - const int16_t length, /* i : frame size */ - const int16_t core, /* i : core */ - const int16_t return_noise, /* i : noise is returned instead of added */ - const int16_t secondary, /* i : flag to indicate secondary noise generation */ - const int16_t element_mode, /* i : element mode */ + const Word16 length, /* i : frame size */ + const Word16 core, /* i : core */ + const Word16 return_noise, /* i : noise is returned instead of added */ + const Word16 secondary, /* i : flag to indicate secondary noise generation */ + const Word16 element_mode, /* i : element mode */ STEREO_CNG_DEC_HANDLE hStereoCng, /* i : stereo CNG handle */ - const int16_t nchan_out /* i : number of output channels */ + const Word16 nchan_out /* i : number of output channels */ ); #endif @@ -10244,6 +10260,7 @@ void IGFDecReadData_flt( const int16_t isIndepFrame /* i : if 1: arith dec force reset, if 0: no reset */ ); +#ifndef IVAS_FLOAT_FIXED /*! r: return igfAllZero flag indicating if no envelope is transmitted */ int16_t IGFDecReadLevel_flt( const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* i/o: instance handle of IGF Deccoder */ @@ -10251,6 +10268,7 @@ int16_t IGFDecReadLevel_flt( const int16_t igfGridIdx, /* i : in case of CELP->TCX switching, use 1.25 framelength */ const int16_t isIndepFrame /* i : if 1: arith dec force reset, if 0: no reset */ ); +#endif void IGFDecRestoreTCX10SubFrameData_flt( const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* o : instance handle of IGF Decoder */ @@ -10354,6 +10372,7 @@ void IGFSCFEncoderRestoreContextState( const int16_t igfGridIdx /* i : igf grid index see declaration of IGF_GRID_IDX for details */ ); +#ifndef IVAS_FLOAT_FIXED void IGFSCFDecoderOpen_ivas( IGFSCFDEC_INSTANCE_HANDLE hPublicData, /* i : handle to public data */ H_IGF_INFO hIgfInfo, /* i : IGF info handle */ @@ -10361,11 +10380,15 @@ void IGFSCFDecoderOpen_ivas( const int16_t bwidth, const int16_t element_mode, const int16_t rf_mode ); +#endif +#ifndef IVAS_FLOAT_FIXED void IGFSCFDecoderReset_ivas( IGFSCFDEC_INSTANCE_HANDLE hPublicData /* i : handle to public data or NULL in case there was no instance created */ ); +#endif +#ifndef IVAS_FLOAT_FIXED void IGFSCFDecoderDecode_ivas( IGFSCFDEC_INSTANCE_HANDLE hPublicData, /* i : handle to public data or NULL in case there was no instance created */ Decoder_State *st, /* i/o: pointer to decoder state */ @@ -10374,6 +10397,7 @@ void IGFSCFDecoderDecode_ivas( const int16_t indepFlag /* i : if 1 on input the decoder will be forced to reset, if 0 on input the decoder will be forced to encode without a reset */ ); +#endif /*! r: offset value */ int16_t tbe_celp_exc_offset_flt( diff --git a/lib_com/rom_com.c b/lib_com/rom_com.c index f41b789b1..256fc16d7 100644 --- a/lib_com/rom_com.c +++ b/lib_com/rom_com.c @@ -10980,25 +10980,25 @@ const SCALE_SETUP scaleTableMono[SIZE_SCALE_TABLE_MONO] = const SCALE_SETUP scaleTable_cn_only[SIZE_SCALE_TABLE_CN] = { - { 0, 0, 8000, -3.5f, 20295/*1.2387211385 Q14*/ /*-3.5f*/, -28672 }, - { 0, 8000, 9600, -3.0f, 16306/*0.9952622652 Q14*/ /*-3.0f*/, -24576 }, - { 0, 9600, 13200, -2.5f, 12751/*0.7782794237 Q14*/ /*-2.5f*/, -20480 }, - { 0, 13200, 16400, -2.0f, 9583/*0.5848932266 Q14*/ /*-2.0f*/, -16384 }, + { 0, 0, 8000, -3.5f, 20295/*1.2387211385 Q14*/ /*-3.5f*/, 20295 }, + { 0, 8000, 9600, -3.0f, 16306/*0.9952622652 Q14*/ /*-3.0f*/, 16306 }, + { 0, 9600, 13200, -2.5f, 12751/*0.7782794237 Q14*/ /*-2.5f*/, 12751 }, + { 0, 13200, 16400, -2.0f, 9583/*0.5848932266 Q14*/ /*-2.0f*/, 9583 }, { 0, 16400,128001, 0.0f, 0/*0.0000000000 Q14*/ /* 0.0f*/, 0 }, - { 1, 0, 8000, -3.0f, 16306/*0.9952622652 Q14*/ /*-3.0f*/, -24576 }, - { 1, 8000, 9600, -2.5f, 12751/*0.7782794237 Q14*/ /*-2.5f*/, -20480 }, - { 1, 9600, 13200, -1.5f, 6759/*0.4125375748 Q14*/ /*-1.5f*/, -12288 }, - { 1, 13200, 16400, -2.5f, 12751/*0.7782794237 Q14*/ /*-2.5f*/, -20480 }, - { 1, 16400, 24400, -0.5f, 1999/*0.1220184565 Q14*/ /*-0.5f*/, -4096 }, + { 1, 0, 8000, -3.0f, 16306/*0.9952622652 Q14*/ /*-3.0f*/, 16306 }, + { 1, 8000, 9600, -2.5f, 12751/*0.7782794237 Q14*/ /*-2.5f*/, 12751 }, + { 1, 9600, 13200, -1.5f, 6759/*0.4125375748 Q14*/ /*-1.5f*/, 6759 }, + { 1, 13200, 16400, -2.5f, 12751/*0.7782794237 Q14*/ /*-2.5f*/, 12751 }, + { 1, 16400, 24400, -0.5f, 1999/*0.1220184565 Q14*/ /*-0.5f*/, 1999 }, { 1, 24400,128001, 0.0f, 0/*0.0000000000 Q14*/ /* 0.0f*/, 0 }, - { 2, 0, 8000, -2.5f, 12751/*0.7782794237 Q14*/ /*-2.5f*/, -20480 }, - { 2, 8000, 9600, -2.5f, 12751/*0.7782794237 Q14*/ /*-2.5f*/, -20480 }, - { 2, 9600, 13200, -2.0f, 9583/*0.5848932266 Q14*/ /*-2.0f*/, -16384 }, - { 2, 13200, 16400, -1.0f, 4242/*0.2589254379 Q14*/ /*-1.0f*/, -8192 }, + { 2, 0, 8000, -2.5f, 12751/*0.7782794237 Q14*/ /*-2.5f*/, 12751 }, + { 2, 8000, 9600, -2.5f, 12751/*0.7782794237 Q14*/ /*-2.5f*/, 12751 }, + { 2, 9600, 13200, -2.0f, 9583/*0.5848932266 Q14*/ /*-2.0f*/, 9583 }, + { 2, 13200, 16400, -1.0f, 4242/*0.2589254379 Q14*/ /*-1.0f*/, 4242 }, - { 2, 16400, 24400, -0.5f, 1999/*0.1220184565 Q14*/ /*-0.5f*/, -4096 }, + { 2, 16400, 24400, -0.5f, 1999/*0.1220184565 Q14*/ /*-0.5f*/, 1999 }, { 2, 24400, 32000, 0.0f, 0/*0.0000000000 Q14*/ /* 0.0f*/, 0 }, { 2, 32000,128001, 0.0f, 0/*0.0000000000 Q14*/ /* 0.0f*/, 0 } }; diff --git a/lib_com/swb_tbe_com_fx.c b/lib_com/swb_tbe_com_fx.c index 97a0ff3d2..dea9b6a63 100644 --- a/lib_com/swb_tbe_com_fx.c +++ b/lib_com/swb_tbe_com_fx.c @@ -2828,7 +2828,7 @@ void GenShapedSHBExcitation_ivas_fx( } White_exc16k = exc16k; - + Word16 Q_excTmp2 = getScaleFactor16(excTmp2, L_FRAME16k) + *Q_bwe_exc; /* Track the low band envelope */ IF(element_mode == IVAS_CPE_TD || element_mode == IVAS_CPE_DFT) { @@ -2839,13 +2839,13 @@ void GenShapedSHBExcitation_ivas_fx( FOR (k = 0; k < L_FRAME16k; k++) { //excNoisyEnvLeft[k] = mem_csfilt_left + csfilt_num2[0] * excTmp2[k]; - excNoisyEnvLeft[k] = add(mem_csfilt_left, mult_r(csfilt_num2[0], excTmp2[k])); + excNoisyEnvLeft[k] = add(mem_csfilt_left, mult_r(csfilt_num2[0], shl(excTmp2[k], sub(Q_excTmp2, *Q_bwe_exc)))); //Q_excTmp2 //mem_csfilt_left = -csfilt_den2[1] * excNoisyEnvLeft[k]; - mem_csfilt_left = mult_r(neg_csfilt_den2[1], excNoisyEnvLeft[k]); + mem_csfilt_left = mult_r(neg_csfilt_den2[1], excNoisyEnvLeft[k]); //Q_excTmp2 //excNoisyEnvRight[L_FRAME16k - k - 1] = mem_csfilt_right + csfilt_num2[0] * excTmp2[L_FRAME16k - k - 1]; - excNoisyEnvRight[L_FRAME16k - k - 1] = add(mem_csfilt_right, mult_r(csfilt_num2[0], excTmp2[L_FRAME16k - k - 1])); + excNoisyEnvRight[L_FRAME16k - k - 1] = add(mem_csfilt_right, mult_r(csfilt_num2[0], shl(excTmp2[L_FRAME16k - k - 1], sub(Q_excTmp2, *Q_bwe_exc)))); //Q_excTmp2 //mem_csfilt_right = -csfilt_den2[1] * excNoisyEnvRight[L_FRAME16k - k - 1]; - mem_csfilt_right = mult_r(neg_csfilt_den2[1], excNoisyEnvRight[L_FRAME16k - k - 1]); + mem_csfilt_right = mult_r(neg_csfilt_den2[1], excNoisyEnvRight[L_FRAME16k - k - 1]); //Q_excTmp2 } alpha = 0; @@ -2854,7 +2854,7 @@ void GenShapedSHBExcitation_ivas_fx( FOR (k = 0; k < L_FRAME16k; k++) { //excNoisyEnv[k] = alpha * excNoisyEnvLeft[k] + (1 - alpha) * excNoisyEnvRight[k]; - excNoisyEnv[k] = add(mult_r(alpha, excNoisyEnvLeft[k]), mult_r((32767 - alpha), excNoisyEnvRight[k])); + excNoisyEnv[k] = add(mult_r(alpha, excNoisyEnvLeft[k]), mult_r((32767 - alpha), excNoisyEnvRight[k])); //Q_excTmp2 alpha = add(alpha, step); } } @@ -2867,11 +2867,11 @@ void GenShapedSHBExcitation_ivas_fx( move32(); FOR(i = 0; i < L_FRAME16k; i++) { - excNoisyEnv[i] = mac_r(L_tmp, csfilt_num2[0], excTmp2[i]); + excNoisyEnv[i] = mac_r(L_tmp, csfilt_num2[0], shl(excTmp2[i], sub(Q_excTmp2, *Q_bwe_exc))); move16(); - /* excNoisyEnv : Q_bwe_exc, - *mem_csfilt: Q_bwe_exc+16, excTmp2: Q_bwe_exc, csfilt_num2[0] Q15 */ - L_tmp = L_mult(excNoisyEnv[i], neg_csfilt_den2[1]); /* Q_bwe_exc+16 */ + /* excNoisyEnv : Q_excTmp2, + *mem_csfilt: Q_excTmp2+16, excTmp2: Q_excTmp2, csfilt_num2[0] Q_excTmp2 */ + L_tmp = L_mult(excNoisyEnv[i], neg_csfilt_den2[1]); /* Q_excTmp2 + 16 */ } *mem_csfilt = L_tmp; move32(); @@ -2928,7 +2928,7 @@ void GenShapedSHBExcitation_ivas_fx( #endif IF (excNoisyEnv[k] != 0) { - L_tmp4 = L_mult(excNoisyEnv[k], White_exc16k[k]);/* (Q_bwe_exc) +5 +1*/ + L_tmp4 = L_mult(shr(excNoisyEnv[k], sub(Q_excTmp2, *Q_bwe_exc)), White_exc16k[k]);/* (Q_bwe_exc) +5 +1*/ } White_exc16k_32[k] = L_tmp4; move32(); @@ -2944,8 +2944,8 @@ void GenShapedSHBExcitation_ivas_fx( /* calculate pow22 */ /* pow22=0.00001f */ - tmp = sub(shl(sub(*Q_bwe_exc, NOISE_QADJ), 1), 31); - pow22 = L_shl(21475l/*0.00001f Q31*/, tmp); /* 0.00001f in 2*(Q_bwe_exc-NOISE_QADJ) */ + tmp = sub(shl(sub(Q_excTmp2, NOISE_QADJ), 1), 31); + pow22 = L_shl(21475l/*0.00001f Q31*/, tmp); /* 0.00001f in 2*(Q_excTmp2-NOISE_QADJ) */ tmp = sub(NOISE_QFAC, 5); FOR(k = 0; k < L_FRAME16k; k++) { @@ -2963,7 +2963,8 @@ void GenShapedSHBExcitation_ivas_fx( #endif } /*Q_pow22 = sub( shl(*Q_bwe_exc,1), 18 );*/ - Q_pow22 = shl(sub(*Q_bwe_exc, NOISE_QADJ), 1); + Q_pow22 = shl(sub(Q_excTmp2, NOISE_QADJ), 1); + Scale_sig(White_exc16k, L_FRAME16k, sub(*Q_bwe_exc, Q_excTmp2)); } #if 1//def ADD_IVAS_TBE_CODE diff --git a/lib_dec/core_dec_init.c b/lib_dec/core_dec_init.c index 3d9ae2933..04f66be5b 100644 --- a/lib_dec/core_dec_init.c +++ b/lib_dec/core_dec_init.c @@ -47,760 +47,7 @@ * * Initialization of state variables *-----------------------------------------------------------------------*/ -#ifdef IVAS_FLOAT_FIXED -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 */ - const int16_t bwidth, /* i : audio bandwidth */ - const int16_t MCT_flag, /* i : hMCT handle allocated (1) or not (0) */ - const int16_t last_element_mode, /* i : last element mode */ - const int16_t is_init /* i : indicate call during initialization */ -) -{ -#ifndef IVAS_FLOAT_FIXED - int16_t mem_syn_r_size_old; - int16_t mem_syn_r_size_new; -#endif -#ifndef IVAS_FLOAT_FIXED - int16_t fscaleFB; -#endif - -#ifndef IVAS_FLOAT_FIXED - int16_t encoderLookahead; - int16_t encoderLookaheadFB; -#endif - TCX_LTP_DEC_HANDLE hTcxLtpDec = st->hTcxLtpDec; - TCX_DEC_HANDLE hTcxDec = st->hTcxDec; - - if ( st->codec_mode != MODE1 ) /*already updated in MODE1*/ - { - st->fscale_old = st->fscale; - } - - st->sr_core = getCoreSamplerateMode2_flt( st->element_mode, total_brate, bwidth, st->flag_ACELP16k, st->rf_flag, st->is_ism_format ); - st->fscale = sr2fscale( st->sr_core ); -#ifndef IVAS_FLOAT_FIXED - fscaleFB = sr2fscale( st->output_Fs ); -#endif - - /* initializing variables for frame lengths etc. right in the beginning */ - st->L_frame = (int16_t) ( st->sr_core / FRAMES_PER_SEC ); - if ( st->ini_frame == 0 ) - { - st->last_L_frame = st->L_frame_past = st->L_frame; - } - if ( st->hTcxDec != NULL ) - { - st->hTcxDec->L_frameTCX = (int16_t) ( st->output_Fs / FRAMES_PER_SEC ); - if ( st->ini_frame == 0 ) - { - st->L_frameTCX_past = st->hTcxDec->L_frameTCX; - } - } - - st->tcxonly = getTcxonly_ivas( st->element_mode, total_brate, MCT_flag, st->is_ism_format ); - - /* the TD TCX PLC in MODE1 still runs with 80ms subframes */ - if ( ( st->element_mode == EVS_MONO && st->L_frame == L_FRAME16k && total_brate <= ACELP_32k ) || ( st->element_mode > EVS_MONO && st->L_frame == L_FRAME16k && total_brate <= MAX_ACELP_BRATE ) || ( st->tcxonly && ( st->sr_core == 32000 || st->sr_core == 16000 ) ) ) - { - st->nb_subfr = NB_SUBFR16k; - } - else - { - st->nb_subfr = NB_SUBFR; - } - st->bits_frame = (int16_t) ( ( (float) st->L_frame / (float) st->fscale ) * (float) FSCALE_DENOM / 128.0f * (float) total_brate / 100.0f + 0.49f ); -#ifndef IVAS_FLOAT_FIXED - st->TcxBandwidth_float = getTcxBandwidth_flt(bwidth); -#endif - st->narrowBand = (bwidth == NB) ? 1 : 0; - -#ifndef IVAS_FLOAT_FIXED - encoderLookahead = (L_LOOK_12k8 * st->fscale) / FSCALE_DENOM; - encoderLookaheadFB = (L_LOOK_12k8 * fscaleFB) / FSCALE_DENOM; -#endif - - if (st->element_mode == IVAS_CPE_MDCT) - { - st->pit_res_max = initPitchLagParameters(12800, &st->pit_min, &st->pit_fr1, &st->pit_fr1b, &st->pit_fr2, &st->pit_max); - hTcxDec->pit_max_TCX = (int16_t)(st->pit_max * st->output_Fs / 12800); - hTcxDec->pit_min_TCX = (int16_t)(st->pit_min * st->output_Fs / 12800); - } - else - { - st->pit_res_max = initPitchLagParameters(st->sr_core, &st->pit_min, &st->pit_fr1, &st->pit_fr1b, &st->pit_fr2, &st->pit_max); - if (hTcxDec != NULL) - { - hTcxDec->pit_max_TCX = (int16_t)(st->pit_max * st->output_Fs / st->sr_core); - hTcxDec->pit_min_TCX = (int16_t)(st->pit_min * st->output_Fs / st->sr_core); - } - } - - if (st->ini_frame == 0) - { - st->pit_res_max_past = st->pit_res_max; - } - -#ifndef IVAS_FLOAT_FIXED - /*Preemphasis param*/ - if (st->fscale < (16000 * FSCALE_DENOM) / 12800) - { - st->preemph_fac_float = PREEMPH_FAC_FLT; /*NB*/ - } - else if (st->fscale < (24000 * FSCALE_DENOM) / 12800) - { - st->preemph_fac_float = PREEMPH_FAC_16k_FLT; /*WB*/ - } - else - { - st->preemph_fac_float = PREEMPH_FAC_SWB_FLT; /*SWB*/ - } - - if (st->sr_core == INT_FS_16k) - { - st->gamma_float = GAMMA16k_FLT; - } - else if (st->sr_core > INT_FS_16k && st->element_mode == IVAS_CPE_MDCT) - { - st->gamma_float = GAMMA16k_FLT; - } - else - { - st->gamma_float = GAMMA1_FLT; - } -#endif // #ifndef IVAS_FLOAT_FIXED - - /* LPC quantization */ - if (st->sr_core <= INT_FS_16k && st->tcxonly == 0) - { - st->lpcQuantization = 1; - } - else - { - st->lpcQuantization = 0; - } - - if (st->tcxonly == 0) - { - st->numlpc = 1; - } - else - { - st->numlpc = 2; - } - - /* Initialize TBE */ - st->prev_coder_type = GENERIC; -#ifndef IVAS_FLOAT_FIXED - if (st->hBWE_TD != NULL) - { - set_f(st->hBWE_TD->prev_lsf_diff, 0.5f, LPC_SHB_ORDER - 2); - st->hBWE_TD->prev_tilt_para = 0.0f; - set_zero(st->hBWE_TD->cur_sub_Aq, M + 1); - } -#endif -#ifdef IVAS_FLOAT_FIXED - if (st->hBWE_TD != NULL) - { - set16_fx(st->hBWE_TD->prev_lsf_diff_fx, 16384, LPC_SHB_ORDER - 2); - st->hBWE_TD->prev_tilt_para_fx = 0; - set16_fx(st->hBWE_TD->cur_sub_Aq_fx, 0, M + 1); - } -#endif - - if (st->hIGFDec != NULL) - { - if (!is_init || st->element_mode != IVAS_CPE_MDCT) - { -#ifndef IVAS_FLOAT_FIXED - init_tcx_cfg(st->hTcxCfg, total_brate, st->sr_core, st->output_Fs, st->L_frame, st->bwidth, st->hTcxDec->L_frameTCX, st->fscale, encoderLookahead, encoderLookaheadFB, st->preemph_fac_float, st->tcxonly, st->rf_flag, st->igf, st->hIGFDec->infoIGFStopFreq, st->element_mode, st->ini_frame, MCT_flag); -#endif - - } - else - { - st->hTcxCfg->tcx_curr_overlap_mode = st->hTcxCfg->tcx_last_overlap_mode = ALDO_WINDOW; - st->hTcxCfg->last_aldo = 1; - } - } - -#ifndef IVAS_FLOAT_FIXED - if (st->hTECDec != NULL) - { - resetTecDec(st->hTECDec); - } -#endif -#ifdef IVAS_FLOAT_FIXED - if ( st->hTECDec != NULL ) - { - resetTecDec_Fx( st->hTECDec ); - } -#endif - - if (st->element_mode != IVAS_SCE) - { - st->flag_cna = 0; - } - if (st->ini_frame == 0) - { - st->flag_cna = 0; - st->last_flag_cna = 0; - } - - /* Static vectors to zero */ - if (st->ini_frame == 0) - { - st->last_is_cng = 0; - - st->rate_switching_reset = 0; -#ifndef IVAS_FLOAT_FIXED - if (st->hTcxDec != NULL) - { - reset_tcx_overl_buf(st->hTcxDec); - - set_zero(st->hTcxDec->syn_OverlFB_float, L_FRAME_MAX / 2); - set_zero(st->hTcxDec->old_synth_float, OLD_SYNTH_INTERNAL_DEC); - - set_zero(st->hTcxDec->synth_history, L_PROT48k + L_FRAME_MAX); - } -#endif - -#ifndef IVAS_FLOAT_FIXED - set_zero(st->syn_float, M + 1); - set_zero(st->mem_syn_r_float, L_SYN_MEM); -#endif // #ifndef IVAS_FLOAT_FIXED - -#ifndef IVAS_FLOAT_FIXED - mem_syn_r_size_old = 0; /* just to avoid MSVC warnings */ - mem_syn_r_size_new = 0; /* just to avoid MSVC warnings */ -#endif - - st->con_tcx = 0; - } - else - { - /* Reset old_synth in case of core sampling rate switching and Mode 1/2 switching*/ -#ifndef IVAS_FLOAT_FIXED - if (st->hTcxDec != NULL && ((st->L_frame != st->last_L_frame) || (st->last_codec_mode == MODE1 && st->element_mode == EVS_MONO))) - { - set_zero(st->hTcxDec->old_synth_float, OLD_SYNTH_INTERNAL_DEC); - } -#endif - /*Compute size of old and new memories*/ -#ifndef IVAS_FLOAT_FIXED - mem_syn_r_size_old = (int16_t)(1.25 * st->last_L_frame / 20.f); - mem_syn_r_size_new = (int16_t)(1.25 * st->L_frame / 20.f); -#endif - -#ifndef IVAS_FLOAT_FIXED - /*Reset LPC mem*/ - if ((st->L_frame != st->last_L_frame) || (st->last_core == AMR_WB_CORE) || (st->last_core == HQ_CORE)) - { - set_zero(st->mem_MA, M); - if (st->sr_core == INT_FS_16k) - { - mvr2r(GEWB2_Ave, st->mem_AR, M); - } - else - { - mvr2r(GEWB_Ave, st->mem_AR, M); - } - } -#endif - /*Mode 1/2 switching*/ - if (st->last_codec_mode == MODE1 && st->element_mode == EVS_MONO) - { -#ifndef IVAS_FLOAT_FIXED - mvr2r(st->lsp_old, st->lspold_uw_float, M); - mvr2r(st->lsf_old, st->lsfold_uw_float, M); - set_zero(st->syn_float, M); -#endif - } - if (st->last_core == AMR_WB_CORE) - { - st->last_core = ACELP_CORE; - st->last_core_bfi = ACELP_CORE; - } - - if (((st->element_mode != IVAS_CPE_DFT) || (st->element_mode == IVAS_CPE_DFT && st->prev_bfi)) && st->last_codec_mode == MODE1 && st->last_core == ACELP_CORE) - { - /* Switching from Mode 1 ACELP */ - st->last_core_bfi = ACELP_CORE; -#ifndef IVAS_FLOAT_FIXED - acelp_plc_mdct_transition(st); -#endif - } - - if (st->last_codec_mode == MODE2 && - st->L_frame != st->last_L_frame && - ((st->m_frame_type == SID_FRAME && st->last_core > ACELP_CORE) || - (st->last_core > ACELP_CORE && st->core > ACELP_CORE) || st->prev_bfi)) - { - lerp_flt(st->hHQ_core->old_outLB, st->hHQ_core->old_outLB, st->L_frame, st->last_L_frame); - } - - /* Rate switching */ - if (st->last_codec_mode == MODE1 && st->last_core == HQ_CORE) - { - /* Switching from MDCT */ - - /*Reset of ACELP memories*/ - st->rate_switching_reset = 1; -#ifndef IVAS_FLOAT_FIXED - st->tilt_code = TILT_CODE_FLT; - set_zero(st->old_exc, L_EXC_MEM_DEC); - set_zero(st->mem_syn2, M); - set_zero(st->syn_float, 1 + M); -#endif -#ifndef IVAS_FLOAT_FIXED - /*OLA -> zero */ - if (st->hTcxDec != NULL) - { - reset_tcx_overl_buf(st->hTcxDec); - - } -#endif - if (st->hTcxCfg != NULL) - { -#ifndef IVAS_FLOAT_FIXED - mvr2r(st->hHQ_core->old_out + NS2SA(st->output_Fs, N_ZERO_MDCT_NS), st->hTcxDec->syn_OverlFB_float, st->hTcxCfg->tcx_mdct_window_lengthFB); -#endif - st->hTcxCfg->last_aldo = 1; /*It was previously ALDO*/ - st->hTcxCfg->tcx_curr_overlap_mode = ALDO_WINDOW; - } - - /*OLA for Mode 2 TCX always reset in Mode switching cases*/ - if (st->hHQ_core != NULL) - { - set_f(st->hHQ_core->old_outLB, 0, st->L_frame); - } - - st->last_core_bfi = TCX_20_CORE; - - if (st->hPFstat != NULL) - { - st->hPFstat->on = 0; - } - - /* reset CLDFB memories */ - cldfb_reset_memory_ivas(st->cldfbAna); - cldfb_reset_memory_ivas(st->cldfbBPF); - cldfb_reset_memory_ivas(st->cldfbSyn); - if (st->cldfbSynHB != NULL) - { - cldfb_reset_memory_ivas(st->cldfbSynHB); - } - } - else if ((st->L_frame != st->last_L_frame) && (st->L_frame <= L_FRAME16k) && (st->last_L_frame <= L_FRAME16k)) /* Rate switching between 12.8 and 16 kHz*/ - { - /*Interpolation of ACELP memories*/ - - /* convert quantized LSP vector */ -#ifndef IVAS_FLOAT_FIXED - st->rate_switching_reset = lsp_convert_poly(st->lsp_old, st->L_frame, 0); - lsp2a_stab(st->lsp_old, st->old_Aq_12_8, M); - - lsp2lsf(st->lsp_old, st->lsf_old, M, st->sr_core); - mvr2r(st->lsp_old, st->lspold_uw_float, M); - mvr2r(st->lsf_old, st->lsfold_uw_float, M); - - if (!st->last_con_tcx) - { - synth_mem_updt2_flt(st->L_frame, st->last_L_frame, st->old_exc, st->mem_syn_r_float, st->mem_syn2, NULL, DEC); - } - -#endif - /*mem of deemphasis stayed unchanged.*/ - } - else if (st->L_frame != st->last_L_frame) /* Rate switching involving TCX only modes */ - { - /*Partial reset of ACELP memories*/ - st->rate_switching_reset = 1; - - /*reset partly some memories*/ -#ifndef IVAS_FLOAT_FIXED - st->tilt_code = TILT_CODE_FLT; - if (!st->last_con_tcx) - { - set_zero(st->old_exc, L_EXC_MEM_DEC); - } - set_zero(st->old_Aq_12_8, M + 1); - - /*Resamp others memories*/ - /*Size of LPC syn memory*/ - lerp_flt(st->mem_syn_r_float + L_SYN_MEM - mem_syn_r_size_old, st->mem_syn_r_float + L_SYN_MEM - mem_syn_r_size_new, mem_syn_r_size_new, mem_syn_r_size_old); - mvr2r(st->mem_syn_r_float + L_SYN_MEM - M, st->mem_syn2, M); -#endif // #ifndef IVAS_FLOAT_FIXED - } - /* update of lsf_old only needed in BASOP */ - /* else if( !st->tcxonly && (st->L_frame == L_FRAME16k) && (st->last_total_brate > ACELP_32k) ) */ - /* { */ - /* lsp2lsf( st->lsp_old, st->lsf_old, M, st->sr_core ); */ - /* } */ - } - - if (st->last_bwidth == NB && st->bwidth != NB && st->ini_frame != 0) - { - st->rate_switching_reset = 1; - } - - if (st->hTcxDec != NULL) - { - st->hTcxDec->old_synth_len = 2 * st->L_frame; - st->hTcxDec->old_synth_lenFB = 2 * st->hTcxDec->L_frameTCX; - } - - /* bass pf reset */ - st->bpf_gain_param = 0; -#ifndef IVAS_FLOAT_FIXED - if (st->hBPF != NULL) - { - set_f(st->hBPF->pst_old_syn, 0, NBPSF_PIT_MAX); - } -#endif - /* Formant postfilter */ - if (st->ini_frame == 0) - { - /* do nothing */ - } -#ifndef IVAS_FLOAT_FIXED - else if (st->last_codec_mode == MODE2) - { - if (!st->tcxonly) - { - if (st->hPFstat->on) - { - lerp_flt(st->hPFstat->mem_stp_flt + L_SYN_MEM - mem_syn_r_size_old, st->hPFstat->mem_stp_flt + L_SYN_MEM - mem_syn_r_size_new, mem_syn_r_size_new, mem_syn_r_size_old); - lerp_flt(st->hPFstat->mem_pf_in_flt + L_SYN_MEM - mem_syn_r_size_old, st->hPFstat->mem_pf_in_flt + L_SYN_MEM - mem_syn_r_size_new, mem_syn_r_size_new, mem_syn_r_size_old); - } - else - { - set_zero(st->hPFstat->mem_stp_flt, L_SYN_MEM); - set_zero(st->hPFstat->mem_pf_in_flt, L_SYN_MEM); - st->hPFstat->reset = 1; - st->hPFstat->gain_prec_flt = 1.f; - } - } - else if (st->hPFstat->on) - { - lerp_flt(st->hPFstat->mem_stp_flt + L_SYN_MEM - mem_syn_r_size_old, st->hPFstat->mem_stp_flt + L_SYN_MEM - mem_syn_r_size_new, mem_syn_r_size_new, mem_syn_r_size_old); - lerp_flt(st->hPFstat->mem_pf_in_flt + L_SYN_MEM - mem_syn_r_size_old, st->hPFstat->mem_pf_in_flt + L_SYN_MEM - mem_syn_r_size_new, mem_syn_r_size_new, mem_syn_r_size_old); - } - } - else - { - /*codec mode switching*/ - - /*reset post-filter except for Narrowband*/ - if (((int16_t)(st->output_Fs / FRAMES_PER_SEC)) != L_FRAME8k) - { - if (st->hPFstat != NULL) - { - st->hPFstat->reset = 1; - if (st->hPFstat->on != 0) - { - st->hPFstat->reset = 0; - lerp_flt(st->hPFstat->mem_stp_flt + L_SYN_MEM - mem_syn_r_size_old, st->hPFstat->mem_stp_flt + L_SYN_MEM - mem_syn_r_size_new, mem_syn_r_size_new, mem_syn_r_size_old); - lerp_flt(st->hPFstat->mem_pf_in_flt + L_SYN_MEM - mem_syn_r_size_old, st->hPFstat->mem_pf_in_flt + L_SYN_MEM - mem_syn_r_size_new, mem_syn_r_size_new, mem_syn_r_size_old); - } - } - } - else - { - /*feed last value old_synth as it is used for pre-emphasis mem*/ - if (st->hTcxDec != NULL) - { - st->hTcxDec->old_synth_float[st->hTcxDec->old_synth_len - 1] = st->syn_float[M]; - } -#ifndef IVAS_FLOAT_FIXED - if (st->hBPF != NULL) - { - st->hBPF->pst_old_syn[NBPSF_PIT_MAX - 1] = st->syn_float[M]; - } -#endif - } - } -#endif - /* lsf and lsp initialization */ -#ifndef IVAS_FLOAT_FIXED - if (st->ini_frame == 0) - { - mvr2r(st->lsp_old, st->lspold_uw_float, M); - mvr2r(st->lsf_old, st->lsfold_uw_float, M); - - set_zero(st->lsf_cng_float, M); - } - st->gc_threshold = 0.0f; -#endif - - st->seed_tcx_plc = RANDOM_INITSEED; - st->plcBackgroundNoiseUpdated = 0; -#ifndef IVAS_FLOAT_FIXED - st->past_gpit_float = 0.0f; - st->past_gcode_float = 0.0f; - - lsf2lsp(st->lsf_cng_float, st->lspold_cng_float, M, INT_FS_12k8); - lsp2a_stab(st->lspold_cng_float, st->Aq_cng_float, M); - mvr2r(st->lsf_old, st->lsf_q_cng_float, M); - mvr2r(st->lsf_old, st->old_lsf_q_cng_float, M); - mvr2r(st->lsp_old, st->lsp_q_cng_float, M); - mvr2r(st->lsp_old, st->old_lsp_q_cng_float, M); - set_zero(st->mem_syn_unv_back_float, M); - st->last_gain_syn_deemph_float = 1.f; -#endif // #ifndef IVAS_FLOAT_FIXED - - if (st->last_codec_mode == MODE1 || st->ini_frame == 0) - { - /* this assumes that MODE1 fades out in the frequency domain - - otherwise some data from MODE1 would be needed here */ -#ifndef IVAS_FLOAT_FIXED - st->last_concealed_gain_syn_deemph_float = 1.f; - if (hTcxDec != NULL) - { - hTcxDec->conceal_eof_gain_float = 1.0f; - } -#endif // #ifndef IVAS_FLOAT_FIXED - } - /* Post processing */ -#ifndef IVAS_FLOAT_FIXED - set_zero(st->mem_Aq_float, NB_SUBFR16k * (M + 1)); - - st->lp_ener_bfi = 60.0f; -#endif - if (st->ini_frame == 0) - { - st->prev_bfi = 0; - st->last_core_bfi = -1; - if (st->hTcxDec != NULL) - { - hTcxDec->tcxConceal_recalc_exc = 0; - } - } - st->prev_old_bfi = 0; - - if (st->hTcxDec != NULL) - { - st->hTcxDec->noise_filling_index[0] = st->hTcxDec->noise_filling_index[1] = 0; - st->hTcxDec->tnsActive[0] = st->hTcxDec->tnsActive[1] = 0; -#ifndef IVAS_FLOAT_FIXED - set_f(st->hTcxDec->ltpGainMemory, 0.0f, N_LTP_GAIN_MEMS); -#endif - } - -#ifndef IVAS_FLOAT_FIXED - mvr2r(st->lsf_old, st->lsf_adaptive_mean, M); - mvr2r(st->lsf_old, st->lsfoldbfi0, M); - mvr2r(st->lsf_old, st->lsfoldbfi1, M); - - if (!st->last_con_tcx) - { - st->old_enr_LP_float = 0.0f; /* LP filter E of last good voiced frame or local LP filter E in TD TCX PLC */ - } -#endif - - st->clas_dec = UNVOICED_CLAS; - - if (st->prev_bfi) - { -#ifndef IVAS_FLOAT_FIXED - /* calculate energy at the end of the previous frame */ - if (st->core == ACELP_CORE && st->last_core == HQ_CORE) - { - fer_energy(st->hTcxDec->L_frameTCX, UNVOICED_CLAS, st->previoussynth, -1, &st->enr_old, 1); - } -#endif // #ifndef IVAS_FLOAT_FIXED - } - else - { - st->last_good = UNVOICED_CLAS; /* last good received frame for concealment */ -#ifndef IVAS_FLOAT_FIXED - st->enr_old = 0.0f; /* energy at the end of the previous frame */ -#endif // #ifndef IVAS_FLOAT_FIXED - } -#ifndef IVAS_FLOAT_FIXED - st->lp_gainc = 0.0f; - st->lp_gainp = 0.0f; -#endif // #ifndef IVAS_FLOAT_FIXED - - if (st->hTcxDec != NULL) - { - st->hTcxDec->prev_widow_left_rect = 0; - - if (is_init || MCT_flag || !(st->element_mode == IVAS_CPE_MDCT && st->element_mode == last_element_mode)) - { - st->hTcxDec->NoiseLevelIndex_bfi = PLC_MIN_STAT_BUFF_SIZE - 1; - st->hTcxDec->CurrLevelIndex_bfi = 0; -#ifndef IVAS_FLOAT_FIXED - st->hTcxDec->CngLevelBackgroundTrace_bfi = PLC_MIN_CNG_LEV_FLT; - st->hTcxDec->LastFrameLevel_bfi = PLC_MIN_CNG_LEV_FLT; - set_f(st->hTcxDec->NoiseLevelMemory_bfi, PLC_MIN_CNG_LEV_FLT, PLC_MIN_STAT_BUFF_SIZE); - - st->hTcxDec->cummulative_damping_tcx_float = 1.0f; -#endif - } - } - - - -#ifndef IVAS_FLOAT_FIXED - for (i = 0; i < 2 * NB_SUBFR16k + 2; i++) - { - st->old_pitch_buf[i] = (float)st->pit_min; - } - st->cummulative_damping_float = 1.0f; - for (i = 0; i < 2 * NB_SUBFR16k + 2; i++) - { - st->mem_pitch_gain_float[i] = 1.f; - } - st->old_fpitch_float = (float)st->pit_min; -#endif // #ifndef IVAS_FLOAT_FIXED - - - st->rate_switching_init = 1; - - st->reset_mem_AR = 0; - -#ifndef IVAS_FLOAT_FIXED - /* For phase dispersion */ - set_zero(st->dispMem, 8); - st->voice_fac_float = -1; /* purely unvoiced */ -#endif // #ifndef IVAS_FLOAT_FIXED - - /* TCX-LTP */ - if (hTcxLtpDec != NULL) - { - tcxltp_dec_init(hTcxLtpDec, st->ini_frame, st->last_codec_mode, st->element_mode, st->pit_max, st->sr_core); - } - - /* TCX */ - if (hTcxDec != NULL) - { -#ifndef IVAS_FLOAT_FIXED - st->old_fpitchFB_float = (float)hTcxDec->pit_min_TCX; -#endif // #ifndef IVAS_FLOAT_FIXED - - if (st->ini_frame == 0 || (st->last_codec_mode == MODE1 && st->element_mode == EVS_MONO)) - { - //hTcxDec->tcxltp_last_gain_unmodified_float = 0.f; - } - - /* TCX */ - hTcxDec->tcx_lpc_shaped_ari = getTcxLpcShapedAri(total_brate, st->rf_flag, st->element_mode); - - hTcxDec->envWeighted = 0; - } #ifndef IVAS_FLOAT_FIXED - if (st->hBPF != NULL) - { - st->hBPF->pst_mem_deemp_err = 0.0f; - } - if (st->tcxonly) - { - st->p_bpf_noise_buf_float = NULL; - - } - else - { - st->p_bpf_noise_buf_float = st->bpf_noise_buf_float; - - } -#endif - - if (bwidth == SWB && (total_brate == ACELP_16k40 || total_brate == ACELP_24k40) && st->element_mode == EVS_MONO) - { - st->tec_tfa = 1; - } - else - { - st->tec_tfa = 0; - } - - st->tec_flag = 0; - st->tfa_flag = 0; - - /* needed in decoder to read the bitstream */ - st->enableGplc = 0; - - st->flagGuidedAcelp = 0; - st->tonal_mdct_plc_active = 0; - st->T0_4th = L_SUBFR; - st->guidedT0 = st->T0_4th; - - if (st->hPlcInfo != NULL && total_brate >= HQ_48k && st->element_mode == EVS_MONO) - { - st->enablePlcWaveadjust = 1; - - if (st->hTcxDec != NULL && (st->ini_frame == 0 || last_total_brate < HQ_48k || st->last_codec_mode == MODE1 || st->force_lpd_reset)) - { - concealment_init(st->hTcxDec->L_frameTCX, st->hPlcInfo); - } - } - else - { - st->enablePlcWaveadjust = 0; - } - - /* PLC: [TCX: Tonal Concealment] */ - if (st->hTonalMDCTConc != NULL && !(st->element_mode > EVS_MONO && st->ini_frame != 0 && st->hTonalMDCTConc->nSamples == st->hTcxDec->L_frameTCX)) - { - st->hTonalMDCTConc->nScaleFactors = 0; - st->hTonalMDCTConc->nSamples = 0; -#ifndef IVAS_FLOAT_FIXED - st->hTonalMDCTConc->lastPcmOut_float = 0x0; -#endif - st->hTonalMDCTConc->lastBlockData.tonalConcealmentActive = 0; - st->hTonalMDCTConc->lastBlockData.nSamples = 0; - - TonalMDCTConceal_Init_ivas(st->hTonalMDCTConc, st->hTcxDec->L_frameTCX, st->L_frame, FDNS_NPTS, st->hTcxCfg); - } - - st->last_tns_active = 0; - st->second_last_tns_active = 0; - st->second_last_core = -1; - - if (st->hTcxCfg != NULL && - st->element_mode != EVS_MONO) - { - st->hTcxCfg->fIsTNSAllowed = getTnsAllowed(is_init ? total_brate : st->bits_frame_nominal * FRAMES_PER_SEC, st->igf, st->element_mode); - } -#ifndef IVAS_FLOAT_FIXED - if (hTcxDec != NULL) - { - hTcxDec->tcxltp_second_last_pitch_float = st->old_fpitch_float; - hTcxDec->tcxltp_third_last_pitch_float = st->old_fpitch_float; - } -#endif // #ifndef IVAS_FLOAT_FIXED - - if ( ( total_brate == ACELP_9k60 || total_brate == ACELP_16k40 || total_brate == ACELP_24k40 ) && st->element_mode == EVS_MONO ) - { - st->dec_glr = 1; - } - else - { - st->dec_glr = 0; - } - - st->dec_glr_idx = 0; - - st->VAD = 0; - if ( hTcxDec != NULL ) - { - hTcxDec->enableTcxLpc = 1; -#ifndef IVAS_FLOAT_FIXED - hTcxDec->old_gaintcx_bfi_float = 0.0f; -#endif - hTcxDec->tcx_hm_LtpPitchLag = -1; - } - - if ( st->hTcxCfg != NULL ) - { - st->hTcxCfg->na_scale_flt = 1.f; - } - - return; -} -#else void open_decoder_LPD( Decoder_State *st, /* i/o: decoder state structure */ const int32_t total_brate, /* i : total bitrate */ @@ -1467,47 +714,7 @@ void open_decoder_LPD( * * Initialization TCX-LTP handle *-----------------------------------------------------------------------*/ -#ifdef IVAS_FLOAT_FIXED -void tcxltp_dec_init( - TCX_LTP_DEC_HANDLE hTcxLtpDec, - const int16_t ini_frame, - const int16_t last_codec_mode, - const int16_t element_mode, - const int16_t pit_max, - const int32_t sr_core ) -{ #ifndef IVAS_FLOAT_FIXED - hTcxLtpDec->tcxltp_gain_float = 0.0f; -#endif - hTcxLtpDec->tcxltp = getTcxLtp( sr_core ); - - if ( ini_frame == 0 || ( last_codec_mode == MODE1 && element_mode == EVS_MONO ) ) - { - - hTcxLtpDec->tcxltp_pitch_int = pit_max; - hTcxLtpDec->tcxltp_pitch_fr = 0; - - if ( ini_frame == 0 ) - { - //set_f( hTcxLtpDec->tcxltp_mem_in_float, 0.0f, TCXLTP_MAX_DELAY ); - //set_f( hTcxLtpDec->tcxltp_mem_out_float, 0.0f, L_FRAME48k ); -#ifdef IVAS_FLOAT_FIXED - set32_fx(hTcxLtpDec->tcxltp_mem_in_32, 0, TCXLTP_MAX_DELAY); - set32_fx(hTcxLtpDec->tcxltp_mem_out_32, 0, L_FRAME48k); -#endif // IVAS_FLOAT_FIXED - hTcxLtpDec->tcxltp_pitch_int_post_prev = 0; - hTcxLtpDec->tcxltp_pitch_fr_post_prev = 0; - //hTcxLtpDec->tcxltp_gain_post_prev_float = 0.f; -#ifdef IVAS_FLOAT_FIXED - hTcxLtpDec->tcxltp_gain_post_prev = 0; -#endif // IVAS_FLOAT_FIXED - hTcxLtpDec->tcxltp_filt_idx_prev = -1; - } - } - - return; -} -#else void tcxltp_dec_init( TCX_LTP_DEC_HANDLE hTcxLtpDec, const int16_t ini_frame, diff --git a/lib_dec/core_dec_init_fx.c b/lib_dec/core_dec_init_fx.c index ab367e3a4..045c54345 100644 --- a/lib_dec/core_dec_init_fx.c +++ b/lib_dec/core_dec_init_fx.c @@ -8,6 +8,7 @@ #include #include "options.h" #include "prot_fx1.h" +#include "prot.h" //Can be removed later #include "prot_fx2.h" #include "basop_util.h" #include "rom_com.h" @@ -1034,6 +1035,8 @@ void tcxltp_dec_init_fx( { set16_fx( hTcxLtpDec->tcxltp_mem_in, 0, TCXLTP_MAX_DELAY ); set16_fx( hTcxLtpDec->tcxltp_mem_out, 0, L_FRAME48k ); + set32_fx(hTcxLtpDec->tcxltp_mem_in_32, 0, TCXLTP_MAX_DELAY); + set32_fx(hTcxLtpDec->tcxltp_mem_out_32, 0, L_FRAME48k); hTcxLtpDec->tcxltp_pitch_int_post_prev = 0; hTcxLtpDec->tcxltp_pitch_fr_post_prev = 0; hTcxLtpDec->tcxltp_gain_post_prev = 0; @@ -1814,19 +1817,6 @@ void open_decoder_LPD_ivas_fx( IF( st->hTcxDec != NULL && ( EQ_16( st->ini_frame, 0 ) || LT_32( last_total_brate, HQ_48k ) || EQ_16( st->last_codec_mode, MODE1 ) || st->force_lpd_reset ) ) { concealment_init_ivas_fx( st->hTcxDec->L_frameTCX, st->hPlcInfo ); - //---------------- To be removed later : Only initializations -#ifndef IVAS_FLOAT_FIXED - st->hPlcInfo->outx_new_n1 = 0.0f; - st->hPlcInfo->nsapp_gain = 0.0f; -#endif -#ifndef IVAS_FLOAT_FIXED - st->hPlcInfo->nsapp_gain_n = 0.0f; - st->hPlcInfo->ener_mean = 59.4260f; - st->hPlcInfo->ener = 0.0f; - st->hPlcInfo->recovery_gain_float = 0.0f; - st->hPlcInfo->step_concealgain = 0.0f; -#endif - //-------------------To be removed later } } ELSE @@ -1840,28 +1830,9 @@ void open_decoder_LPD_ivas_fx( st->hTonalMDCTConc->nScaleFactors = 0; st->hTonalMDCTConc->nSamples = 0; st->hTonalMDCTConc->lastPcmOut = 0x0; -#ifndef IVAS_FLOAT_FIXED - //----------To be removed later: pointer initializations - st->hTonalMDCTConc->lastPcmOut_float = 0x0; - //---------- - st->hTonalMDCTConc->lastPcmOut_float = 0x0; -#endif st->hTonalMDCTConc->lastBlockData.tonalConcealmentActive = 0; st->hTonalMDCTConc->lastBlockData.nSamples = 0; TonalMDCTConceal_Init_ivas_fx( st->hTonalMDCTConc, st->hTcxDec->L_frameTCX, st->L_frame, FDNS_NPTS, st->hTcxCfg ); -#ifndef IVAS_FLOAT_FIXED - //st->hTonalMDCTConc->pTCI = (TonalComponentsInfo *) st->hTonalMDCTConc->timeDataBuffer_float; - st->hTonalMDCTConc->pTCI = &st->hTonalMDCTConc->pTCI1; - st->hTonalMDCTConc->lastPitchLag_float = 0; - st->hTonalMDCTConc->scf_fadeout_flt = 1.0f; - st->hTonalMDCTConc->last_block_nrg_flt = 0.0f; - st->hTonalMDCTConc->curr_noise_nrg_flt = 0.0f; - st->hTonalMDCTConc->faded_signal_nrg_flt = 0.0f; - st->hTonalMDCTConc->secondLastPcmOut_float = &st->hTonalMDCTConc->timeDataBuffer_float[( 3 * L_FRAME_MAX ) / 2 - imult1616( 3, shr( s_min( L_FRAME_MAX, st->hTcxDec->L_frameTCX ), 1 ) )]; - st->hTonalMDCTConc->lastPcmOut_float = &st->hTonalMDCTConc->timeDataBuffer_float[( 3 * L_FRAME_MAX ) / 2 - s_min( L_FRAME_MAX, st->hTcxDec->L_frameTCX )]; - //---------------To be removed later - assert( sizeof( *st->hTonalMDCTConc->pTCI ) <= ( st->hTonalMDCTConc->lastPcmOut_float - st->hTonalMDCTConc->timeDataBuffer_float ) * sizeof( st->hTonalMDCTConc->timeDataBuffer_float[0] ) ); -#endif // #ifndef IVAS_FLOAT_FIXED } st->last_tns_active = 0; diff --git a/lib_dec/core_switching_dec.c b/lib_dec/core_switching_dec.c index 654fd2293..a1c1db294 100644 --- a/lib_dec/core_switching_dec.c +++ b/lib_dec/core_switching_dec.c @@ -218,38 +218,25 @@ ivas_error core_switching_pre_dec_ivas_fx( { /*TODO None of the test dtreams are entering this block,hence enabled assert(0)*/ assert( 0 ); -#ifdef IVAS_FLOAT_FIXED Word32 *realBuffer_fx[CLDFB_NO_COL_MAX_SWITCH], *imagBuffer_fx[CLDFB_NO_COL_MAX_SWITCH]; Word32 realBufferTmp_fx[CLDFB_NO_COL_MAX_SWITCH][CLDFB_NO_CHANNELS_MAX], imagBufferTmp_fx[CLDFB_NO_COL_MAX_SWITCH][CLDFB_NO_CHANNELS_MAX]; Word32 syn_Overl_fx[320]; Word32 fer_samples_fx[960]; Copy_Scale_sig_16_32( st->hTcxDec->syn_Overl, syn_Overl_fx, 320, 15 ); Copy_Scale_sig_16_32( st->hHQ_core->fer_samples_fx, fer_samples_fx, 960, 15 ); -#else - float *realBuffer[CLDFB_NO_COL_MAX_SWITCH], *imagBuffer[CLDFB_NO_COL_MAX_SWITCH]; - float realBufferTmp[CLDFB_NO_COL_MAX_SWITCH][CLDFB_NO_CHANNELS_MAX], imagBufferTmp[CLDFB_NO_COL_MAX_SWITCH][CLDFB_NO_CHANNELS_MAX]; -#endif // IVAS_FLOAT_FIXED FOR( i = 0; i < CLDFB_NO_COL_MAX_SWITCH; i++ ) { -#ifdef IVAS_FLOAT_FIXED set32_fx( realBufferTmp_fx[i], 0, CLDFB_NO_CHANNELS_MAX ); set32_fx( imagBufferTmp_fx[i], 0, CLDFB_NO_CHANNELS_MAX ); realBuffer_fx[i] = realBufferTmp_fx[i]; imagBuffer_fx[i] = imagBufferTmp_fx[i]; move32(); move32(); -#else - set_f( realBufferTmp[i], 0, CLDFB_NO_CHANNELS_MAX ); - set_f( imagBufferTmp[i], 0, CLDFB_NO_CHANNELS_MAX ); - realBuffer[i] = realBufferTmp[i]; - imagBuffer[i] = imagBufferTmp[i]; -#endif // IVAS_FLOAT_FIXED } /* CLDFB analysis of the synthesis at internal sampling rate */ -#ifdef IVAS_FLOAT_FIXED IF( ( error = cldfb_save_memory_ivas_fx( st->cldfbAna ) ) != IVAS_ERR_OK ) { return error; @@ -268,23 +255,6 @@ ivas_error core_switching_pre_dec_ivas_fx( cldfb_restore_memory_ivas_fx( st->cldfbSyn ); Copy_Scale_sig_32_16( syn_Overl_fx, st->hTcxDec->syn_Overl, 320, 15 ); Copy_Scale_sig_32_16( fer_samples_fx, st->hHQ_core->fer_samples_fx, 960, 9 ); -#else - if ( ( error = cldfb_save_memory_ivas( st->cldfbAna ) ) != IVAS_ERR_OK ) - { - return error; - } - cldfbAnalysis_ivas( st->hTcxDec->syn_Overl_float, realBuffer, imagBuffer, delay_comp, st->cldfbAna ); - cldfb_restore_memory_ivas( st->cldfbAna ); - - /* CLDFB synthesis of the combined signal */ - if ( ( error = cldfb_save_memory_ivas( st->cldfbSyn ) ) != IVAS_ERR_OK ) - { - return error; - } - - cldfbSynthesis_ivas( realBuffer, imagBuffer, st->hHQ_core->fer_samples, delay_comp, st->cldfbSyn ); - cldfb_restore_memory_ivas( st->cldfbSyn ); -#endif // IVAS_FLOAT_FIXED } IF( !st->last_con_tcx && EQ_16( st->last_core_bfi, ACELP_CORE ) && EQ_16( st->core, HQ_CORE ) ) @@ -425,9 +395,6 @@ ivas_error core_switching_pre_dec_ivas_fx( st->lp_gainc_fx = extract_h( Sqrt32( st->lp_ener_fx, &exp ) ); /*Q=15-exp*/ st->lp_gainc_fx = shr( st->lp_gainc_fx, 12 - exp ); /*Q3*/ -#ifndef IVAS_FLOAT_FIXED /*To be removed later: floating point initializations*/ - st->last_voice_factor = 0; -#endif st->last_voice_factor_fx = 0; st->Last_GSC_noisy_speech_flag = 0; move16(); @@ -476,12 +443,7 @@ ivas_error core_switching_pre_dec_ivas_fx( move32(); set16_fx( st->hBWE_TD->old_bwe_exc_fx, 0, PIT16k_MAX * 2 ); } -#if 1 - //st->tilt_code = 0.0f; - //st->gc_threshold = 0.0f; - //set_f( st->dispMem, 0, 8 ); -#endif st->tilt_code_fx = 0; st->gc_threshold_fx = 0; st->dm_fx.prev_gain_code = 0; @@ -500,9 +462,6 @@ ivas_error core_switching_pre_dec_ivas_fx( st->lp_gainc_fx = extract_h( Sqrt32( st->lp_ener_fx, &exp ) ); /*Q=15-exp*/ st->lp_gainc_fx = shr( st->lp_gainc_fx, 12 - exp ); /*Q3*/ -#ifndef IVAS_FLOAT_FIXED - st->last_voice_factor = 0; -#endif // st->last_voice_factor_fx = 0; st->Last_GSC_noisy_speech_flag = 0; move16(); @@ -567,10 +526,6 @@ ivas_error core_switching_pre_dec_ivas_fx( IF( NE_16(st->last_core , TCX_20_CORE) && NE_16(st->last_core , TCX_10_CORE) ) { -#if 1 /*Floating point initialization*/ - set_f( st->hHQ_core->old_out, 0, output_frame ); - set_f( st->hHQ_core->old_outLB, 0, L_FRAME16k ); -#endif // 1 set16_fx( st->hHQ_core->old_out_fx, 0, output_frame ); set32_fx( st->hHQ_core->old_outLB_fx, 0, L_FRAME16k ); set16_fx(st->hHQ_core->old_out_LB_fx, 0, L_FRAME16k); @@ -578,12 +533,6 @@ ivas_error core_switching_pre_dec_ivas_fx( st->hHQ_core->no_att_hangover = 0; move16(); -#if 1 /*To be removed later: Floating point initialization*/ - //st->hHQ_core->energy_lt = 300.0f; - //set_f( st->hHQ_core->prev_noise_level, 0.0f, 2 ); - //st->hHQ_core->prev_ni_ratio = 0.5f; - //set_f( st->hHQ_core->prev_En_sb, 0.0f, NB_SWB_SUBBANDS ); -#endif st->hHQ_core->energy_lt_fx = 2457600;/*300.0f Q13*/ move32(); set16_fx( st->hHQ_core->old_is_transient, 0, 3 ); @@ -599,10 +548,6 @@ ivas_error core_switching_pre_dec_ivas_fx( } ELSE { -#if 1 /*To be removed later: Floating point initialization*/ - set_f( st->hHQ_core->old_out, 0, output_frame ); - set_f( st->hHQ_core->old_outLB, 0, L_FRAME16k ); -#endif // set16_fx( st->hHQ_core->old_out_fx, 0, output_frame ); set32_fx( st->hHQ_core->old_outLB_fx, 0, L_FRAME16k ); } @@ -1660,6 +1605,7 @@ void core_switching_hq_prepare_dec( * Classification for band-width switching *---------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED void bandwidth_switching_detect( Decoder_State *st /* i/o: decoder state structure */ ) @@ -1706,7 +1652,7 @@ void bandwidth_switching_detect( return; } -#ifdef IVAS_FLOAT_FIXED +#else void bandwidth_switching_detect_ivas_fx( Decoder_State *st_fx /* i/o: encoder state structure */ ) diff --git a/lib_dec/dec_tcx.c b/lib_dec/dec_tcx.c index c995f2a50..0c7d6c194 100644 --- a/lib_dec/dec_tcx.c +++ b/lib_dec/dec_tcx.c @@ -2170,7 +2170,7 @@ void decoder_tcx_imdct_fx( * * Initialize lengths for TCX processing, update IGF subframe info *-------------------------------------------------------------------*/ - +#ifndef IVAS_FLOAT_FIXED void init_tcx_info( Decoder_State *st, /* i/o: coder memory state */ const int16_t L_frame_glob, /* i : global frame length */ @@ -2264,7 +2264,7 @@ void init_tcx_info( return; } - +#endif #ifndef IVAS_FLOAT_FIXED /*-------------------------------------------------------------------* diff --git a/lib_dec/fd_cng_dec.c b/lib_dec/fd_cng_dec.c index 7cdbfbc2b..ba1d1f4b1 100644 --- a/lib_dec/fd_cng_dec.c +++ b/lib_dec/fd_cng_dec.c @@ -2001,13 +2001,13 @@ void generate_masking_noise_ivas_fx( Word32 *timeDomainBuffer, /* i/o: time-domain signal */ Word16 *exp_out, /* o : time-domain signal exp */ HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */ - const int16_t length, /* i : frame size */ - const int16_t core, /* i : core */ - const int16_t return_noise, /* i : noise is returned instead of added */ - const int16_t secondary, /* i : flag to indicate secondary noise generation */ - const int16_t element_mode, /* i : element mode */ + const Word16 length, /* i : frame size */ + const Word16 core, /* i : core */ + const Word16 return_noise, /* i : noise is returned instead of added */ + const Word16 secondary, /* i : flag to indicate secondary noise generation */ + const Word16 element_mode, /* i : element mode */ STEREO_CNG_DEC_HANDLE hStereoCng, /* i : stereo CNG handle */ - const int16_t nchan_out /* i : number of output channels */ + const Word16 nchan_out /* i : number of output channels */ ) { Word32 *cngNoiseLevel_fx = hFdCngCom->cngNoiseLevel; @@ -2020,51 +2020,49 @@ void generate_masking_noise_ivas_fx( Word16 startBand = hFdCngCom->startBand; Word16 *seed = &( hFdCngCom->seed ); Word32 scale_fx = 0x40000000; // 1.0 in Q30 + move32(); /* skip noise generating if level is very low, to avoid problems with possibly running into denormals */ *exp_out = Q15; - IF( hFdCngCom->likelihood_noisy_speech_32fx > DELTA_MASKING_NOISE_Q31 ) + move16(); + IF( GT_32( hFdCngCom->likelihood_noisy_speech_32fx, DELTA_MASKING_NOISE_Q31 ) ) { - IF( core != AMR_WB_CORE ) + IF( NE_16( core, AMR_WB_CORE ) ) { /* Compute additional CN level */ FOR( i = 0; i < SIZE_SCALE_TABLE_CN; i++ ) { - IF( ( hFdCngCom->CngBandwidth == scaleTable_cn_only[i].bwmode ) && - ( hFdCngCom->CngBitrate >= scaleTable_cn_only[i].bitrateFrom ) && - ( hFdCngCom->CngBitrate < scaleTable_cn_only[i].bitrateTo ) ) + test(); + test(); + IF( EQ_16( hFdCngCom->CngBandwidth, scaleTable_cn_only[i].bwmode ) && + GE_32( hFdCngCom->CngBitrate, scaleTable_cn_only[i].bitrateFrom ) && + LT_32( hFdCngCom->CngBitrate, scaleTable_cn_only[i].bitrateTo ) ) { - break; + BREAK; } } - Word16 exp; - //Word32 scale_temp = BASOP_util_Pow2( Mpy_32_32( float_to_fix( -scaleTable_cn_only[i].scale_flt / 10.f, Q31 ), LOG_10_BASE_2 ), Q2, &exp ); - Word32 scale_temp = BASOP_util_Pow2( Mpy_32_32( L_shl( negate( scaleTable_cn_only[i].scale_ivas / 10 ), 18 ), LOG_10_BASE_2 ), Q2, &exp ); - scale_temp = L_sub( scale_temp, L_shl( 1, Q31 - exp ) ); - scale_fx = L_shl( scale_temp, exp - Q1 ); // Q30 + scale_fx = L_deposit_h( scaleTable_cn_only[i].scale_ivas ); /* Q30 */ } ELSE { /* Compute additional CN level */ FOR( i = 0; i < SIZE_SCALE_TABLE_CN_AMRWB; i++ ) { - IF( hFdCngCom->CngBitrate >= scaleTable_cn_only_amrwbio_flt[i][0] ) + IF( GE_32( hFdCngCom->CngBitrate, scaleTable_cn_only_amrwbio[i][0] ) ) { - break; + BREAK; } } IF( i < SIZE_SCALE_TABLE_CN_AMRWB ) { - Word16 exp; - Word32 scale_temp = BASOP_util_Pow2( Mpy_32_32( scaleTable_cn_only_amrwbio_fx_by_10f[i][1], LOG_10_BASE_2 ), Q2, &exp ); - scale_temp = L_sub( scale_temp, L_shl( 1, Q31 - exp ) ); - scale_fx = L_shl( Mpy_32_32( scale_fx, scale_temp ), exp ); // Q30 + scale_fx = L_deposit_h( scaleTable_cn_only_amrwbio[i][1] ); /* Q30 */ } ELSE { scale_fx = 0; + move32(); } } @@ -2073,9 +2071,9 @@ void generate_masking_noise_ivas_fx( /* Generate Gaussian random noise in real and imaginary parts of the FFT bins Amplitudes are adjusted to the estimated noise level cngNoiseLevel_flt in each bin */ - IF( startBand == 0 ) + IF( EQ_16( startBand, 0 ) ) { - rand_gauss_fx( &fftBuffer_fx[0], seed, *exp_out); // Q15 + rand_gauss_fx( &fftBuffer_fx[0], seed, *exp_out ); // Q15 ptr_r_fx = fftBuffer_fx + 2; Word16 exp1 = 32 - hFdCngCom->cngNoiseLevelExp; Word32 mpy1 = Sqrt32( Mpy_32_32( scale_fx, *ptr_level_fx ), &exp1 ); // Q = noise_exp-1 @@ -2086,6 +2084,7 @@ void generate_masking_noise_ivas_fx( ELSE { fftBuffer_fx[0] = 0; + move32(); set_l( fftBuffer_fx + 2, 0, 2 * ( startBand - 1 ) ); ptr_r_fx = fftBuffer_fx + 2 * startBand; } @@ -2093,14 +2092,14 @@ void generate_masking_noise_ivas_fx( FOR( ; ptr_level_fx < cngNoiseLevel_fx + hFdCngCom->stopFFTbin - startBand; ptr_level_fx++ ) { /* Real part in FFT bins */ - rand_gauss_fx( ptr_r_fx, seed, *exp_out); // Q15 + rand_gauss_fx( ptr_r_fx, seed, *exp_out ); // Q15 Word16 exp2 = 32 - hFdCngCom->cngNoiseLevelExp; Word32 mpy2 = Sqrt32( L_shr( Mpy_32_32( scale_fx, *ptr_level_fx ), 1 ), &exp2 ); // Q = noise_exp-1 ( *ptr_r_fx ) = L_shl( Mpy_32_32( *ptr_r_fx, mpy2 ), exp2 ); // Q = Q15 ptr_r_fx += 2; /* Imaginary part in FFT bins */ - rand_gauss_fx( ptr_i_fx, seed, *exp_out); // Q15 + rand_gauss_fx( ptr_i_fx, seed, *exp_out ); // Q15 ( *ptr_i_fx ) = L_shl( Mpy_32_32( *ptr_i_fx, mpy2 ), exp2 ); // Q = Q15 ptr_i_fx += 2; } @@ -2109,6 +2108,7 @@ void generate_masking_noise_ivas_fx( set_l( fftBuffer_fx + 2 * hFdCngCom->stopFFTbin, 0, hFdCngCom->fftlen - 2 * hFdCngCom->stopFFTbin ); /* Nyquist frequency is discarded */ fftBuffer_fx[1] = 0; + move32(); } ELSE { @@ -2121,25 +2121,21 @@ void generate_masking_noise_ivas_fx( /* Perform STFT synthesis */ IF( secondary ) { - // SynthesisSTFT_flt(fftBuffer, maskingNoise, hStereoCng->olapBufferSynth22, hFdCngCom->olapWinSyn_flt, 0, hFdCngCom, element_mode, nchan_out); SynthesisSTFT_fx( fftBuffer_fx, *exp_out, maskingNoise_fx, hStereoCng->olapBufferSynth22_32fx, hFdCngCom->olapWinSyn_fx, 0, hFdCngCom, element_mode, nchan_out ); } ELSE { - // SynthesisSTFT_flt(fftBuffer, maskingNoise, hFdCngCom->olapBufferSynth2_flt, hFdCngCom->olapWinSyn_flt, 0, hFdCngCom, element_mode, nchan_out); SynthesisSTFT_fx( fftBuffer_fx, *exp_out, maskingNoise_fx, hFdCngCom->olapBufferSynth2_fx, hFdCngCom->olapWinSyn_fx, 0, hFdCngCom, element_mode, nchan_out ); } - *exp_out = *exp_out - 9; + *exp_out = sub( *exp_out, Q9 ); /* Add some comfort noise on top of decoded signal */ IF( return_noise ) { - // mvr2r(maskingNoise, timeDomainBuffer, min(hFdCngCom->frameSize, length)); mvl2l( maskingNoise_fx, timeDomainBuffer, min( hFdCngCom->frameSize, length ) ); } ELSE { - // v_add(maskingNoise, timeDomainBuffer, timeDomainBuffer, min(hFdCngCom->frameSize, length)); v_add_fixed( maskingNoise_fx, timeDomainBuffer, timeDomainBuffer, min( hFdCngCom->frameSize, length ), 0 ); } diff --git a/lib_dec/hdecnrm.c b/lib_dec/hdecnrm.c index 861e7c96c..907926b68 100644 --- a/lib_dec/hdecnrm.c +++ b/lib_dec/hdecnrm.c @@ -49,6 +49,7 @@ /* Context based Huffman decoding for indices of quantized norms */ /*--------------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED /*! r: decoded index */ static int16_t decode_huff_context( Decoder_State *st, /* i/o: decoder state structure */ @@ -64,7 +65,7 @@ static int16_t decode_huff_context( return ( -*hufftab ); } - +#endif /*--------------------------------------------------------------------------*/ /* Function hdecnrm() */ @@ -72,6 +73,7 @@ static int16_t decode_huff_context( /* Huffman decoding for indices of quantized norms */ /*--------------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED void hdecnrm( Decoder_State *st, /* i/o: decoder state structure */ const int16_t N, /* i : number of norms */ @@ -143,6 +145,7 @@ void hdecnrm( return; } +#endif /*-------------------------------------------------------------------------- * huff_dec() @@ -150,6 +153,7 @@ void hdecnrm( * Huffman decoding *--------------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED void huff_dec( Decoder_State *st, /* i/o: decoder state structure */ const int16_t N, /* i : Number of codewords to decode */ @@ -189,6 +193,7 @@ void huff_dec( return; } +#endif /*-------------------------------------------------------------------------- @@ -197,6 +202,7 @@ void huff_dec( * Huffman decoding for indices of quantized norms *--------------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED void hdecnrm_context( Decoder_State *st, /* i/o: decoder state structure */ const int16_t N, /* i : number of norms */ @@ -233,6 +239,7 @@ void hdecnrm_context( return; } +#endif /*-------------------------------------------------------------------------- @@ -241,6 +248,7 @@ void hdecnrm_context( * *--------------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED void hdecnrm_resize( Decoder_State *st, /* i/o: decoder state structure */ const int16_t N, /* i : number of SFMs */ @@ -300,6 +308,7 @@ void hdecnrm_resize( return; } +#endif /*-------------------------------------------------------------------------- @@ -308,6 +317,7 @@ void hdecnrm_resize( * Huffman decoding for indices of quantized norms *--------------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED void hdecnrm_tran( Decoder_State *st, /* i/o: decoder state structure */ const int16_t N, /* i : number of norms */ @@ -398,3 +408,4 @@ void hdecnrm_tran( return; } +#endif diff --git a/lib_dec/hq_classifier_dec.c b/lib_dec/hq_classifier_dec.c index 3700d0df2..06678866c 100644 --- a/lib_dec/hq_classifier_dec.c +++ b/lib_dec/hq_classifier_dec.c @@ -41,6 +41,7 @@ #include "rom_com.h" #include "wmc_auto.h" +#ifndef IVAS_FLOAT_FIXED /*--------------------------------------------------------------------------* * hq_classifier_dec() * @@ -101,3 +102,4 @@ int16_t hq_classifier_dec( return bits; } +#endif diff --git a/lib_dec/hq_classifier_dec_fx.c b/lib_dec/hq_classifier_dec_fx.c index af6521ae8..bf263e431 100644 --- a/lib_dec/hq_classifier_dec_fx.c +++ b/lib_dec/hq_classifier_dec_fx.c @@ -85,6 +85,7 @@ Word16 ivas_hq_classifier_dec_fx( /* o : Consumed bits } #endif +#ifdef IVAS_FLOAT_FIXED Word16 hq_classifier_dec_fx( /* o : Consumed bits Q0 */ Decoder_State *st_fx, /* i/o: decoder state structure */ const Word32 core_brate, /* i : Core bit rate Q0 */ @@ -158,4 +159,4 @@ Word16 hq_classifier_dec_fx( /* o : Consumed bits Q0 */ return bits; } - +#endif diff --git a/lib_dec/hq_conf_fec.c b/lib_dec/hq_conf_fec.c index 80c61052a..fc1431311 100644 --- a/lib_dec/hq_conf_fec.c +++ b/lib_dec/hq_conf_fec.c @@ -41,6 +41,7 @@ #include "prot.h" #include "wmc_auto.h" +#ifndef IVAS_FLOAT_FIXED /*--------------------------------------------------------------------------* * hq_configure_bfi() * @@ -65,3 +66,4 @@ void hq_configure_bfi( return; } +#endif \ No newline at end of file diff --git a/lib_dec/hq_conf_fec_fx.c b/lib_dec/hq_conf_fec_fx.c index 31c13c254..86bdfd6bc 100644 --- a/lib_dec/hq_conf_fec_fx.c +++ b/lib_dec/hq_conf_fec_fx.c @@ -10,6 +10,7 @@ #include "cnst.h" +#ifdef IVAS_FLOAT_FIXED /*--------------------------------------------------------------------------* * hq_configure_bfi_fx() * @@ -37,3 +38,4 @@ void hq_configure_bfi_fx( move16(); return; } +#endif diff --git a/lib_dec/hq_core_dec_fx.c b/lib_dec/hq_core_dec_fx.c index bc433d630..9157a79b6 100644 --- a/lib_dec/hq_core_dec_fx.c +++ b/lib_dec/hq_core_dec_fx.c @@ -1209,15 +1209,11 @@ void HQ_core_dec_init_fx( HQ_DEC_HANDLE hHQ_core /* i/o: HQ core data handle */ ) { -#if 1 //TOBE Removed later - set_f( hHQ_core->old_out, 0, L_FRAME48k ); - set_f( hHQ_core->old_outLB, 0, L_FRAME32k ); -#endif set16_fx(hHQ_core->old_out_fx, 0, L_FRAME48k); set16_fx(hHQ_core->old_out_LB_fx, 0, L_FRAME32k); set32_fx(hHQ_core->oldOut_fx, 0, L_FRAME48k); set32_fx(hHQ_core->old_outLB_fx, 0, L_FRAME32k); - hHQ_core->Q_old_wtda = 15; + hHQ_core->Q_old_wtda = 15; hHQ_core->Q_old_postdec = 0; hHQ_core->Q_old_wtda_LB = 0; hHQ_core->Q_old_out = 0; diff --git a/lib_dec/hq_env_dec.c b/lib_dec/hq_env_dec.c index 77f897c45..e806f1b62 100644 --- a/lib_dec/hq_env_dec.c +++ b/lib_dec/hq_env_dec.c @@ -40,6 +40,7 @@ #include "rom_com.h" #include "wmc_auto.h" +#ifndef IVAS_FLOAT_FIXED /*------------------------------------------------------------------------* * decode_envelope_indices() * @@ -137,7 +138,9 @@ int16_t decode_envelope_indices( return hcode_l; } +#endif +#ifndef IVAS_FLOAT_FIXED /*------------------------------------------------------------------------* * dequantize_norms() * @@ -197,3 +200,4 @@ void dequantize_norms( return; } +#endif diff --git a/lib_dec/hq_env_dec_fx.c b/lib_dec/hq_env_dec_fx.c index 6362cc798..8ecc8b6da 100644 --- a/lib_dec/hq_env_dec_fx.c +++ b/lib_dec/hq_env_dec_fx.c @@ -8,6 +8,7 @@ #include "prot_fx2.h" /* Function prototypes */ #include "rom_com.h" /* Static table prototypes */ +#ifdef IVAS_FLOAT_FIXED /*------------------------------------------------------------------------* * decode_envelope_indices_fx() * @@ -136,7 +137,9 @@ Word16 decode_envelope_indices_fx( /* o : Number of bits */ return hcode_l; } +#endif +#ifdef IVAS_FLOAT_FIXED /*------------------------------------------------------------------------* * dequantize_norms_fx() * @@ -213,4 +216,5 @@ void dequantize_norms_fx( return; } +#endif diff --git a/lib_dec/hq_hr_dec_fx.c b/lib_dec/hq_hr_dec_fx.c index abd15b6a7..f8b66cb29 100644 --- a/lib_dec/hq_hr_dec_fx.c +++ b/lib_dec/hq_hr_dec_fx.c @@ -68,7 +68,6 @@ void ivas_hq_pred_hb_bws_fx( return; } -#endif void hq_pred_hb_bws_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ @@ -135,6 +134,7 @@ void hq_pred_hb_bws_fx( return; } +#endif /*--------------------------------------------------------------------------* * hq_hr_dec_fx() * @@ -404,7 +404,6 @@ void ivas_hq_hr_dec_fx( return; } -#endif void hq_hr_dec_fx( Decoder_State *st_fx, /* i/o: decoder state structure fx */ @@ -668,3 +667,4 @@ void hq_hr_dec_fx( return; } +#endif \ No newline at end of file diff --git a/lib_dec/hq_lr_dec_fx.c b/lib_dec/hq_lr_dec_fx.c index a7b4d7041..e233a420a 100644 --- a/lib_dec/hq_lr_dec_fx.c +++ b/lib_dec/hq_lr_dec_fx.c @@ -14,7 +14,7 @@ /*--------------------------------------------------------------------------* * Local function prototypes *--------------------------------------------------------------------------*/ - +#ifdef IVAS_FLOAT_FIXED static Word16 p2a_threshold_dequant_fx( Decoder_State *st_fx, Word16 *p2a_flags, const Word16 bands, const Word16 p2a_bands ); static void mdct_spectrum_fine_gain_dec_fx( Decoder_State *st_fx, Word32 L_y2[], const Word16 band_start[], const Word16 band_end[], @@ -1383,3 +1383,4 @@ static void mdct_spectrum_fine_gain_dec_fx( return; } +#endif \ No newline at end of file diff --git a/lib_dec/igf_dec.c b/lib_dec/igf_dec.c index 494780d7b..d6eb6d466 100644 --- a/lib_dec/igf_dec.c +++ b/lib_dec/igf_dec.c @@ -196,6 +196,7 @@ static void IGF_replaceTCXNoise_2_new_flt( * reads whitening levels *-------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED static void IGF_decode_whitening_level_flt( Decoder_State *st, /* i : decoder state */ IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /* i/o: instance handle of IGF Deccoder */ @@ -225,6 +226,7 @@ static void IGF_decode_whitening_level_flt( return; } +#endif /*-------------------------------------------------------------------* @@ -1007,6 +1009,7 @@ static void IGF_RefineGrid_flt( * reads whitening information from the bitstream *-------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED void IGFDecReadData_flt( const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* i/o: instance handle of IGF Deccoder */ Decoder_State *st, /* i : decoder state */ @@ -1085,8 +1088,9 @@ void IGFDecReadData_flt( return; } +#endif - +#ifndef IVAS_FLOAT_FIXED /*-------------------------------------------------------------------* * IGFDecReadLevel_flt() * @@ -1133,6 +1137,7 @@ int16_t IGFDecReadLevel_flt( return IGFAllZero; } +#endif #ifndef IVAS_FLOAT_FIXED /*-------------------------------------------------------------------* @@ -1441,7 +1446,7 @@ void IGFDecSetMode_flt( * * updates the start/stop frequency of IGF according to igfGridIdx *-------------------------------------------------------------------*/ - +#ifndef IVAS_FLOAT_FIXED void IGFDecUpdateInfo_flt( const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* i/o: instance handle of IGF Decoder */ const int16_t subFrameIdx, /* i : index of subframe */ @@ -1453,14 +1458,8 @@ void IGFDecUpdateInfo_flt( hIGFDec->flag_sparse = &hIGFDec->flag_sparseBuf[0]; hIGFDec->infoTCXNoise = &hIGFDec->infoTCXNoiseBuf[0]; -#ifndef IVAS_FLOAT_FIXED hIGFDec->virtualSpec_float = &hIGFDec->virtualSpecBuf[0]; hIGFDec->igfData.pSpecFlat_float = &hIGFDec->igfData.pSpecFlatBuf[0]; -#endif -#ifdef IVAS_FLOAT_FIXED - hIGFDec->virtualSpec_fx = &hIGFDec->virtualSpec[0]; - hIGFDec->igfData.pSpecFlat = &hIGFDec->igfData.pSpecFlatBuf_fx[0]; -#endif hIGFDec->igfData.igfInfo.nfSeed = &hIGFDec->igfData.igfInfo.nfSeedBuf[0]; if ( igfGridIdx == IGF_GRID_LB_SHORT ) @@ -1480,7 +1479,7 @@ void IGFDecUpdateInfo_flt( return; } - +#endif #ifndef IVAS_FLOAT_FIXED /*-------------------------------------------------------------------* @@ -1544,7 +1543,7 @@ void IGFDecCopyLPCFlatSpectrum_flt( * * store the IGF bitstream information for TCX10 subframes *-------------------------------------------------------------------*/ - +#ifndef IVAS_FLOAT_FIXED void IGFDecStoreTCX10SubFrameData_flt( const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* i/o: instance handle of IGF Decoder */ const int16_t subFrameIdx /* i : index of subframe */ @@ -1567,14 +1566,14 @@ void IGFDecStoreTCX10SubFrameData_flt( return; } - +#endif /*-------------------------------------------------------------------* * IGFDecRestoreTCX10SubFrameData_flt() * * restore the IGF bitstream information for TCX10 subframes *-------------------------------------------------------------------*/ - +#ifndef IVAS_FLOAT_FIXED void IGFDecRestoreTCX10SubFrameData_flt( const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* i/o: instance handle of IGF Decoder */ const int16_t subFrameIdx /* i : index of subframe */ @@ -1596,49 +1595,19 @@ void IGFDecRestoreTCX10SubFrameData_flt( hIGFDec->flatteningTrigger = hPrivateData->igf_flatteningTrigger_subframe[subFrameIdx]; hIGFDec->flag_sparse = &hIGFDec->flag_sparseBuf[subFrameIdx * ( N_MAX_TCX - IGF_START_MN ) / 2]; hIGFDec->infoTCXNoise = &hIGFDec->infoTCXNoiseBuf[subFrameIdx * ( IGF_START_MX ) / 2]; -#ifndef IVAS_FLOAT_FIXED hIGFDec->virtualSpec_float = &hIGFDec->virtualSpecBuf[subFrameIdx * ( N_MAX_TCX - IGF_START_MN ) / 2]; hIGFDec->igfData.pSpecFlat_float = &hIGFDec->igfData.pSpecFlatBuf[subFrameIdx * IGF_START_MX / 2]; -#endif -#ifdef IVAS_FLOAT_FIXED - hIGFDec->virtualSpec_fx = &hIGFDec->virtualSpec[subFrameIdx * ( N_MAX_TCX - IGF_START_MN ) / 2]; -#endif -#ifdef IVAS_FLOAT_FIXED - hIGFDec->igfData.pSpecFlat = &hIGFDec->igfData.pSpecFlatBuf_fx[subFrameIdx * IGF_START_MX / 2]; -#endif hIGFDec->igfData.igfInfo.nfSeed = &hIGFDec->igfData.igfInfo.nfSeedBuf[subFrameIdx]; return; } - +#endif /*-----------------------------------------------------------------------* * init_igf_dec_flt() * * Initialize IGF decoder parameters *-----------------------------------------------------------------------*/ -#ifdef IVAS_FLOAT_FIXED -void init_igf_dec_flt( - IGF_DEC_INSTANCE_HANDLE hIGFDec /* i/o: IGF decoder handle */ -) -{ - set_c( (int8_t *) ( hIGFDec->infoTCXNoiseBuf ), 0, IGF_START_MX ); -#ifndef IVAS_FLOAT_FIXED - set_f( hIGFDec->igfData.pSpecFlatBuf, 0, IGF_START_MX ); -#endif - hIGFDec->igfData.igfInfo.nfSeedBuf[0] = 9733; - hIGFDec->igfData.igfInfo.nfSeedBuf[1] = 9733; - hIGFDec->igfData.igfInfo.nfSeed = &hIGFDec->igfData.igfInfo.nfSeedBuf[0]; #ifndef IVAS_FLOAT_FIXED - hIGFDec->igfData.pSpecFlat_float = &hIGFDec->igfData.pSpecFlatBuf[0]; -#endif - hIGFDec->flag_sparse = &hIGFDec->flag_sparseBuf[0]; - hIGFDec->infoTCXNoise = &hIGFDec->infoTCXNoiseBuf[0]; -#ifndef IVAS_FLOAT_FIXED - hIGFDec->virtualSpec_float = &hIGFDec->virtualSpecBuf[0]; -#endif - return; -} -#else void init_igf_dec_flt( IGF_DEC_INSTANCE_HANDLE hIGFDec /* i/o: IGF decoder handle */ ) @@ -1662,6 +1631,7 @@ void init_igf_dec_flt( * *-----------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED /*! r: IGF start line */ int16_t get_igf_startline_flt( Decoder_State *st, /* i : decoder state */ @@ -1691,3 +1661,4 @@ int16_t get_igf_startline_flt( return igf_startline; } +#endif diff --git a/lib_dec/igf_dec_fx.c b/lib_dec/igf_dec_fx.c index 8f32c1179..8a9d8fc87 100644 --- a/lib_dec/igf_dec_fx.c +++ b/lib_dec/igf_dec_fx.c @@ -22,7 +22,7 @@ #include "ivas_prot_fx.h" #endif - +#ifdef IVAS_FLOAT_FIXED /**********************************************************************/ /* get scalefactor of an Word32 array with condition **************************************************************************/ @@ -2969,7 +2969,6 @@ static void IGF_RefineGrid(H_IGF_GRID hGrid } -#ifdef IVAS_FLOAT_FIXED static void IGF_RefineGrid_ivas_fx( H_IGF_GRID hGrid /**< in/out: | IGF grid handle */ ) { @@ -3025,11 +3024,10 @@ static void IGF_RefineGrid_ivas_fx( H_IGF_GRID hGrid /**< in/out: | IGF grid han move16(); } } -#endif // IVAS_FLOAT_FIXED + /**********************************************************************/ /* reads whitening information from the bitstream **************************************************************************/ -#ifdef IVAS_FLOAT_FIXED void IGFDecReadData_ivas_fx( const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Deccoder */ Decoder_State *st, /**< in: | decoder state */ const Word16 igfGridIdx, /**< in: Q0 | in case of CELP->TCX switching, use 1.25 framelength */ @@ -3112,7 +3110,7 @@ void IGFDecReadData_ivas_fx( const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: IGF_decode_temp_flattening_trigger( st, hInstance ); } } -#endif + void IGFDecReadData(const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Deccoder */ Decoder_State *st, /**< in: | decoder state */ const Word16 igfGridIdx, /**< in: Q0 | in case of CELP->TCX switching, use 1.25 framelength */ @@ -3939,7 +3937,6 @@ void IGFDecSetMode( } -#ifdef IVAS_FLOAT_FIXED void IGFDecSetMode_ivas_fx( const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* i : instance handle of IGF Decoder */ const Word32 total_brate, /* i : bitrate */ @@ -4001,7 +3998,6 @@ void IGFDecSetMode_ivas_fx( hIGFDec->infoTCXNoise = &hIGFDec->infoTCXNoiseBuf[0]; return; } -#endif // IVAS_FLOAT_FIXED /**********************************************************************/ /* updates the start/stop frequency of IGF according to igfGridIdx **************************************************************************/ @@ -4049,12 +4045,6 @@ void IGFDecUpdateInfo_ivas_fx( hIGFDec->virtualSpec_fx = &hIGFDec->virtualSpec[0]; hIGFDec->igfData.pSpecFlat = &hIGFDec->igfData.pSpecFlatBuf_fx[0]; - /* TODO: remove float init */ -#ifndef IVAS_FLOAT_FIXED - hIGFDec->virtualSpec_float = &hIGFDec->virtualSpecBuf[0]; - hIGFDec->igfData.pSpecFlat_float = &hIGFDec->igfData.pSpecFlatBuf[0]; -#endif - hIGFDec->igfData.igfInfo.nfSeed = &hIGFDec->igfData.igfInfo.nfSeedBuf[0]; IF ( EQ_16( igfGridIdx, IGF_GRID_LB_SHORT ) ) @@ -4231,12 +4221,6 @@ void IGFDecRestoreTCX10SubFrameData_fx( hIGFDec->virtualSpec_fx = &hIGFDec->virtualSpec[subFrameIdx * ( N_MAX_TCX - IGF_START_MN ) / 2]; hIGFDec->igfData.pSpecFlat = &hIGFDec->igfData.pSpecFlatBuf_fx[subFrameIdx * IGF_START_MX / 2]; - /* TODO: remove float init */ -#ifndef IVAS_FLOAT_FIXED - hIGFDec->virtualSpec_float = &hIGFDec->virtualSpecBuf[subFrameIdx * ( N_MAX_TCX - IGF_START_MN ) / 2]; - hIGFDec->igfData.pSpecFlat_float = &hIGFDec->igfData.pSpecFlatBuf[subFrameIdx * IGF_START_MX / 2]; -#endif - hIGFDec->igfData.igfInfo.nfSeed = &hIGFDec->igfData.igfInfo.nfSeedBuf[subFrameIdx]; return; @@ -4317,3 +4301,4 @@ Word16 get_igf_startline( return igf_startline; } +#endif \ No newline at end of file diff --git a/lib_dec/igf_scf_dec.c b/lib_dec/igf_scf_dec.c index 57c8ff6a4..f92142600 100644 --- a/lib_dec/igf_scf_dec.c +++ b/lib_dec/igf_scf_dec.c @@ -41,6 +41,7 @@ #include "wmc_auto.h" +#ifndef IVAS_FLOAT_FIXED /*---------------------------------------------------------------------* * IGFSCFDecoderOpen_ivas() * @@ -325,3 +326,4 @@ void IGFSCFDecoderDecode_ivas( return; } +#endif \ No newline at end of file diff --git a/lib_dec/igf_scf_dec_fx.c b/lib_dec/igf_scf_dec_fx.c index 2a4d4cad2..b08bcf499 100644 --- a/lib_dec/igf_scf_dec_fx.c +++ b/lib_dec/igf_scf_dec_fx.c @@ -13,7 +13,7 @@ #include "stat_dec.h" #include "basop_util.h" - +#ifdef IVAS_FLOAT_FIXED /**********************************************************************/ /** initialization of an instance of this module **************************************************************************/ @@ -335,3 +335,4 @@ void IGFSCFDecoderDecode( hPublicData->bitsRead = sub(st->next_bit_pos, hPublicData->bitsRead); } +#endif \ No newline at end of file diff --git a/lib_dec/init_dec.c b/lib_dec/init_dec.c index e2ff37a54..954ed19fa 100644 --- a/lib_dec/init_dec.c +++ b/lib_dec/init_dec.c @@ -742,25 +742,23 @@ ivas_error init_decoder( * * Initialization of static variables for pre-echo *----------------------------------------------------------------------*/ - +#ifndef IVAS_FLOAT_FIXED void reset_preecho_dec( HQ_DEC_HANDLE hHQ_core /* i/o: HQ decoder handle */ ) -{ -#ifndef IVAS_FLOAT_FIXED +{ hHQ_core->memfilt_lb = 0; hHQ_core->mean_prev_hb = 0; hHQ_core->smoothmem = 1; hHQ_core->mean_prev = 0; hHQ_core->mean_prev_nc = 0; hHQ_core->wmold_hb = 1; -#endif hHQ_core->prevflag = 0; hHQ_core->pastpre = 0; return; } - +#endif /*----------------------------------------------------------------------* * destroy_cldfb_decoder_flt() @@ -782,7 +780,7 @@ void destroy_cldfb_decoder_ivas_fx( return; } -#endif // IVAS_FLOAT_FIXED +#else // IVAS_FLOAT_FIXED void destroy_cldfb_decoder_flt( Decoder_State *st /* o : Decoder static variables structure */ @@ -798,3 +796,4 @@ void destroy_cldfb_decoder_flt( return; } +#endif \ No newline at end of file diff --git a/lib_dec/init_dec_fx.c b/lib_dec/init_dec_fx.c index 9f74296f3..195c656cd 100644 --- a/lib_dec/init_dec_fx.c +++ b/lib_dec/init_dec_fx.c @@ -14,7 +14,6 @@ #include "ivas_prot_fx.h" #endif #ifdef IVAS_FLOAT_FIXED -#define IVAS_FLOAT_FIXED_TO_BE_REMOVED /*----------------------------------------------------------------------* * init_decoder() @@ -1627,9 +1626,6 @@ ivas_error init_decoder_ivas_fx( move16(); move16(); 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( st_fx, st_fx->total_brate, st_fx->last_total_brate, st_fx->bwidth, 0, st_fx->element_mode, 1 ); -#endif /* PLC mode initialization */ st_fx->m_decodeMode = DEC_NO_FRAM_LOSS; diff --git a/lib_dec/ivas_core_dec.c b/lib_dec/ivas_core_dec.c index 2129ca3db..f82732ab3 100644 --- a/lib_dec/ivas_core_dec.c +++ b/lib_dec/ivas_core_dec.c @@ -233,7 +233,6 @@ ivas_error ivas_core_dec( L_tmp = L_shl( L_tmp, st->last_concealed_gain_syn_deemph_e ); st->hHQ_core->old_out_LB_fx[i] = extract_l( L_tmp ); // Q0 } - //Copy_Scale_sig_16_32( st->hHQ_core->old_out_LB_fx, st->hHQ_core->old_outLB_fx, st->L_frame, 11 ); } set16_fx( voice_factors_fx[n], 0, NB_SUBFR16k ); @@ -486,9 +485,6 @@ ivas_error ivas_core_dec( /* HQ core decoder */ Q_synth = 0; Word16 Q_output = 0; - //HQ_DEC_HANDLE hHQ_core; - - //hHQ_core = st->hHQ_core; ivas_hq_core_dec_fx( st, synth_16_fx[n], &Q_synth, output_frame, NORMAL_HQ_CORE, core_switching_flag[n], output_16_fx[n], &Q_output ); @@ -499,12 +495,6 @@ ivas_error ivas_core_dec( Scale_sig(synth_16_fx[n], L_FRAME48k, -Q_synth); #endif Scale_sig(output_16_fx[n], L_FRAME48k, -Q_output); - -#ifndef IVAS_FLOAT_CONV_TO_BE_REMOVED - //fixedToFloat_arr( hHQ_core->old_out_fx, hHQ_core->old_out, hHQ_core->Q_old_wtda, L_FRAME48k ); - //fixedToFloat_arr( hHQ_core->old_out_LB_fx, hHQ_core->old_outLB, hHQ_core->Q_old_wtda_LB, L_FRAME32k ); -#endif - } /*---------------------------------------------------------------------* @@ -544,10 +534,6 @@ ivas_error ivas_core_dec( Word16 e_sig = 17; Word16 ch; sts = hCPE->hCoreCoder; - Word16 will_estimate_noise_on_channel[CPE_CHANNELS]; - - will_estimate_noise_on_channel[0] = sts[0]->core == TCX_20_CORE && !sts[0]->VAD; - will_estimate_noise_on_channel[1] = sts[1]->core == TCX_20_CORE && !sts[1]->VAD; FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) { stereo_tcx_dec_mode_switch_reconf_To_fixed( sts[ch], 1, hCPE->last_element_mode ); @@ -559,47 +545,18 @@ ivas_error ivas_core_dec( Scale_sig(st->hHQ_core->old_out_LB_fx, L_FRAME32k, st->Q_syn - st->hHQ_core->Q_old_wtda_LB); Scale_sig(st->hHQ_core->old_out_fx, L_FRAME48k, st->Q_syn - st->hHQ_core->Q_old_wtda); - //IF( st->hHQ_core ) - //floatToFixed_arr( st->hHQ_core->old_outLB, st->hHQ_core->old_out_LB_fx, st->Q_syn, L_FRAME32k ); - - //IF( st->hHQ_core ) - //floatToFixed_arr( st->hHQ_core->old_out, st->hHQ_core->old_out_fx, st->Q_syn, 960 ); - //if ( st->hTcxDec && st->hTcxDec->conLastFrameLevel_e < 0 ) - //{ - // st->hTcxDec->conLastFrameLevel_e = 0; - //} - //if ( st->hTcxDec && st->hTcxDec->conNoiseLevelMemory_e[0] < 0 ) - //{ - // set16_fx( st->hTcxDec->conNoiseLevelMemory_e, 0, PLC_MIN_STAT_BUFF_SIZE ); - //} IF( st->hTcxDec ) st->hTcxDec->conNoiseLevelIndex = st->hTcxDec->NoiseLevelIndex_bfi; IF( st->hTcxDec ) st->hTcxDec->conCurrLevelIndex = st->hTcxDec->CurrLevelIndex_bfi; } - //IF( st_ivas->hLsSetUpConversion ) - //f2me_buf( st_ivas->hLsSetUpConversion->targetEnergyPrev[0], st_ivas->hLsSetUpConversion->targetEnergyPrev_fx[0], &st_ivas->hLsSetUpConversion->te_prev_exp, st_ivas->hLsSetUpConversion->sfbCnt ); - //IF( st_ivas->hLsSetUpConversion ) - //f2me_buf( st_ivas->hLsSetUpConversion->dmxEnergyPrev[0], st_ivas->hLsSetUpConversion->dmxEnergyPrev_fx[0], &st_ivas->hLsSetUpConversion->dmx_prev_exp, st_ivas->hLsSetUpConversion->sfbCnt ); - FOR( Word16 chOutIdx = 0; chOutIdx < st_ivas->hDecoderConfig->nchan_out; chOutIdx++ ) - { - FOR( Word16 chInIdx = 0; chInIdx < s_min( st_ivas->nchan_transport, 16 ); chInIdx++ ) - { - //IF( st_ivas->hLsSetUpConversion && st_ivas->hLsSetUpConversion->dmxMtx_fx[chInIdx] ) - //st_ivas->hLsSetUpConversion->dmxMtx_fx[chInIdx][chOutIdx] = float_to_fix( st_ivas->hLsSetUpConversion->dmxMtx[chInIdx][chOutIdx], 30 ); /*Q30*/ - } - } #endif stereo_mdct_core_dec_fx( st_ivas, hCPE, output_32_fx, synth_16_fx ); #if 1 // Fix to float conversion - //IF( st_ivas->hLsSetUpConversion ) - //me2f_buf( st_ivas->hLsSetUpConversion->targetEnergyPrev_fx[0], st_ivas->hLsSetUpConversion->te_prev_exp, st_ivas->hLsSetUpConversion->targetEnergyPrev[0], st_ivas->hLsSetUpConversion->sfbCnt ); - //IF( st_ivas->hLsSetUpConversion ) - //me2f_buf( st_ivas->hLsSetUpConversion->dmxEnergyPrev_fx[0], st_ivas->hLsSetUpConversion->dmx_prev_exp, st_ivas->hLsSetUpConversion->dmxEnergyPrev[0], st_ivas->hLsSetUpConversion->sfbCnt ); FOR( ch = 0; ch < 2; ch++ ) { @@ -607,39 +564,8 @@ ivas_error ivas_core_dec( st = hCPE->hCoreCoder[ch]; - IF( will_estimate_noise_on_channel[0] || will_estimate_noise_on_channel[1] || sts[ch]->bfi ) - { - if ( !sts[ch]->bfi ) - { - for ( int p = 0; p < s_min( 62, sts[ch]->hFdCngDec->npart_shaping ); p++ ) - { - //sts[ch]->hFdCngDec->msNoiseEst_float[p] = ( (float) sts[ch]->hFdCngDec->msNoiseEst[p] / ( 1u << ( 31 - sts[ch]->hFdCngDec->msNoiseEst_exp ) ) ); - } - } - } st->hHQ_core->Q_old_wtda_LB = st->Q_syn; st->hHQ_core->Q_old_wtda = st->Q_syn; - if(st->Q_syn >= 0){ - //for ( int p = 0; p < 640; p++ ) - //{ - // st->hHQ_core->old_outLB[p] = (float) st->hHQ_core->old_out_LB_fx[p] / ( 1u << st->Q_syn ); - //} - - //for ( int p = 0; p < 960; p++ ) - //{ - // st->hHQ_core->old_out[p] = (float) st->hHQ_core->old_out_fx[p] / ( 1u << st->Q_syn ); - //} - }else{ - //for ( int p = 0; p < 640; p++ ) - //{ - // st->hHQ_core->old_outLB[p] = (float) st->hHQ_core->old_out_LB_fx[p] * ( 1u << (-st->Q_syn) ); - //} - - //for ( int p = 0; p < 960; p++ ) - //{ - // st->hHQ_core->old_out[p] = (float) st->hHQ_core->old_out_fx[p] * ( 1u << (-st->Q_syn) ); - //} - } } #ifdef MSAN_FIX @@ -664,8 +590,6 @@ ivas_error ivas_core_dec( { sts[0]->hHQ_core->exp_old_out = 15 - sts[0]->hHQ_core->Q_old_wtda; sts[1]->hHQ_core->exp_old_out = 15 - sts[1]->hHQ_core->Q_old_wtda; - // f2me_buf_16( sts[0]->hHQ_core->old_out, sts[0]->hHQ_core->old_out_fx, &sts[0]->hHQ_core->exp_old_out, L_FRAME48k ); - // f2me_buf_16( sts[1]->hHQ_core->old_out, sts[1]->hHQ_core->old_out_fx, &sts[1]->hHQ_core->exp_old_out, L_FRAME48k ); } updateBuffersForDmxMdctStereo_fx( hCPE, output_frame, output_32_fx[0], output_32_fx[1], synth_16_fx ); @@ -673,8 +597,6 @@ ivas_error ivas_core_dec( { sts[0]->hHQ_core->Q_old_wtda = 15 - sts[0]->hHQ_core->exp_old_out; sts[1]->hHQ_core->Q_old_wtda = 15 - sts[1]->hHQ_core->exp_old_out; - //me2f_buf_16( sts[0]->hHQ_core->old_out_fx, sts[0]->hHQ_core->exp_old_out, sts[0]->hHQ_core->old_out, L_FRAME48k ); - //me2f_buf_16( sts[1]->hHQ_core->old_out_fx, sts[1]->hHQ_core->exp_old_out, sts[1]->hHQ_core->old_out, L_FRAME48k ); } #else @@ -762,8 +684,6 @@ ivas_error ivas_core_dec( { Scale_sig( st->hHQ_core->old_out_fx, L_FRAME48k, -st->hHQ_core->Q_old_wtda ); st->hHQ_core->Q_old_wtda = 0; - - //floatToFixed_arr(st->hHQ_core->old_out, st->hHQ_core->old_out_fx, st->hHQ_core->Q_old_wtda, L_FRAME48k); } /*size of synth is choosen as delay comp to start with*/ @@ -828,7 +748,6 @@ ivas_error ivas_core_dec( test(); test(); test(); IF (sba_dirac_stereo_flag && NE_16(st->element_mode, IVAS_CPE_MDCT) && !(EQ_32(st->core_brate, SID_2k40) && EQ_16(st->cng_type, FD_CNG))) { - //Copy_Scale_sig_16_32(synth_16_fx[n], hSCE->save_synth_fx, output_frame, Q11 - Q_synth); Copy_Scale_sig_16_32(synth_16_fx[n], hSCE->save_synth_fx, output_frame, hSCE->q_save_synth_fx - Q_synth); } @@ -841,7 +760,6 @@ ivas_error ivas_core_dec( test(); test(); test(); IF (sba_dirac_stereo_flag && hSCE && EQ_32(st->core_brate, SID_2k40) && EQ_16(st->cng_type, FD_CNG)) { - //Copy_Scale_sig_16_32(synth_16_fx[n], hSCE->save_synth_fx, output_frame, Q11 - Q_synth); Copy_Scale_sig_16_32(synth_16_fx[n], hSCE->save_synth_fx, output_frame, hSCE->q_save_synth_fx - Q_synth); } @@ -884,13 +802,6 @@ ivas_error ivas_core_dec( #else Scale_sig(synth_16_fx[n], L_FRAME48k, negate(Q_synth)); #endif - IF(st->hHQ_core != NULL) - { - //st->hHQ_core->Q_old_wtda = 0; - //fixedToFloat_arr(st->hHQ_core->old_out_fx, st->hHQ_core->old_out, st->hHQ_core->Q_old_wtda, L_FRAME48k); - } - - /*------------------reset-code-start---------------------*/ @@ -920,9 +831,6 @@ ivas_error ivas_core_dec( Q_synth_fx = 0; move16(); - //TD_BWE_DEC_HANDLE hBWE_TD; - //hBWE_TD = st->hBWE_TD; - FD_BWE_DEC_HANDLE hBWE_FD; hBWE_FD = st->hBWE_FD; @@ -1080,7 +988,6 @@ ivas_error ivas_core_dec( if ( hCPE->hStereoDft != NULL ) { - //floatToFixed_arrL( hCPE->hStereoDft->hb_stefi_sig, hCPE->hStereoDft->hb_stefi_sig_fx, q, L_FRAME48k + NS2SA( 48000, STEREO_DFT_TD_STEFI_DELAY_NS ) ); hCPE->hStereoDft->td_gain_fx[0] = 1; } Scale_sig( tmp_buffer_fx, L_FRAME48k, Q11 - Q_white_exc ); @@ -1221,12 +1128,6 @@ ivas_error ivas_core_dec( } st->old_bwe_delay = tmps; -#ifndef IVAS_FLOAT_FIXED - IF( st->hBWE_TD != NULL ) - { - Copy_Scale_sig_32_16( hb_synth_32_fx[n], st->hBWE_TD->old_hb_synth_fx, output_frame, negate( Q11 ) ); - } -#endif /* SWB CNG/DTX - calculate SHB energy */ test(); test(); test(); @@ -1288,15 +1189,7 @@ ivas_error ivas_core_dec( if (hCPE->hCoreCoder[ch_ind]->hHQ_core != NULL) { Copy_Scale_sig_16_32(hCPE->hCoreCoder[ch_ind]->hHQ_core->old_out_LB_fx, hCPE->hCoreCoder[ch_ind]->hHQ_core->old_outLB_fx, L_FRAME32k, Q11 - hCPE->hCoreCoder[ch_ind]->hHQ_core->Q_old_wtda_LB); - //FOR(int ind = 0; ind < L_FRAME32k; ind++) - //{ - // hCPE->hCoreCoder[ch_ind]->hHQ_core->old_outLB_fx[ind] = (Word32)(hCPE->hCoreCoder[ch_ind]->hHQ_core->old_outLB[ind] * (1 << 11)); - //} Copy_Scale_sig_16_32(hCPE->hCoreCoder[ch_ind]->hHQ_core->old_out_fx, hCPE->hCoreCoder[ch_ind]->hHQ_core->oldOut_fx, L_FRAME48k, Q11 - hCPE->hCoreCoder[ch_ind]->hHQ_core->Q_old_wtda); - //FOR(int ind = 0; ind < L_FRAME48k; ind++) - //{ - // hCPE->hCoreCoder[ch_ind]->hHQ_core->oldOut_fx[ind] = (Word32)(hCPE->hCoreCoder[ch_ind]->hHQ_core->old_out[ind] * (1 << 11)); - //} } } } @@ -1308,15 +1201,7 @@ ivas_error ivas_core_dec( if ( hSCE->hCoreCoder[0]->hHQ_core != NULL ) { Copy_Scale_sig_16_32( hSCE->hCoreCoder[0]->hHQ_core->old_out_LB_fx, hSCE->hCoreCoder[0]->hHQ_core->old_outLB_fx, L_FRAME32k, Q11 - hSCE->hCoreCoder[0]->hHQ_core->Q_old_wtda_LB ); - /*FOR( int ind = 0; ind < L_FRAME32k; ind++ ) - { - hSCE->hCoreCoder[0]->hHQ_core->old_outLB_fx[ind] = (Word32) ( hSCE->hCoreCoder[0]->hHQ_core->old_outLB[ind] * ( 1 << 11 ) ); - }*/ Copy_Scale_sig_16_32( hSCE->hCoreCoder[0]->hHQ_core->old_out_fx, hSCE->hCoreCoder[0]->hHQ_core->oldOut_fx, L_FRAME48k, Q11 - hSCE->hCoreCoder[0]->hHQ_core->Q_old_wtda ); - /*FOR( int ind = 0; ind < L_FRAME48k; ind++ ) - { - hSCE->hCoreCoder[0]->hHQ_core->oldOut_fx[ind] = (Word32) ( hSCE->hCoreCoder[0]->hHQ_core->old_out[ind] * ( 1 << 11 ) ); - }*/ } } } @@ -1421,15 +1306,6 @@ ivas_error ivas_core_dec( } /* n_channels loop */ - for ( Word16 k = 0; k < n_channels; k++ ) - { - if ( sts[k]->hHQ_core != NULL ) - { - fixedToFloat_arr( sts[k]->hHQ_core->old_out_fx, sts[k]->hHQ_core->old_out, sts[k]->hHQ_core->Q_old_wtda, L_FRAME48k ); - //fixedToFloat_arr( sts[k]->hHQ_core->old_out_LB_fx, sts[k]->hHQ_core->old_outLB, sts[k]->hHQ_core->Q_old_wtda_LB, L_FRAME32k ); - } - } - pop_wmops(); return error; } diff --git a/lib_dec/ivas_cpe_dec_fx.c b/lib_dec/ivas_cpe_dec_fx.c index 26cefab72..cdb223d87 100644 --- a/lib_dec/ivas_cpe_dec_fx.c +++ b/lib_dec/ivas_cpe_dec_fx.c @@ -121,42 +121,23 @@ ivas_error ivas_cpe_dec_fx( *----------------------------------------------------------------*/ #if 1 // Float to fix conversions - float maxim = 0; - Word16 q_old_out = 31, q_old_out_LB = 31; + Word16 q_old_out_LB = 31; //q_output_mem = 11; - maxim = 0; //q_buff_LBTCX_mem = 11; //q_input_mem_LB = q_buff_LBTCX_mem; - maxim = 0; - q_old_out = Q11; FOR( Word16 ind1 = 0; ind1 < 2; ind1++ ) { IF( hCPE->hCoreCoder[ind1] && hCPE->hCoreCoder[ind1]->hHQ_core ) - FOR( Word16 ind2 = 0; ind2 < 960; ind2++ ) { - hCPE->hCoreCoder[ind1]->hHQ_core->oldOut_fx[ind2] = (Word32) ( hCPE->hCoreCoder[ind1]->hHQ_core->old_out[ind2] * ( 1 << q_old_out ) ); + Copy_Scale_sig_16_32( hCPE->hCoreCoder[ind1]->hHQ_core->old_out_fx, hCPE->hCoreCoder[ind1]->hHQ_core->oldOut_fx, L_FRAME48k, Q11 - hCPE->hCoreCoder[ind1]->hHQ_core->Q_old_wtda ); } } - maxim = 0; - FOR( Word16 ind1 = 0; ind1 < 2; ind1++ ) - { - IF( hCPE->hCoreCoder[ind1]->hHQ_core ) - FOR( Word16 ind2 = 0; ind2 < L_FRAME32k; ind2++ ) - { - maxim = fmaxf( fabsf( hCPE->hCoreCoder[ind1]->hHQ_core->old_outLB[ind2] ), maxim ); - } - } - IF( maxim > 1.f ) - q_old_out_LB = norm_l( (Word32) maxim ); - q_old_out_LB -= 1; + q_old_out_LB = Q11; FOR( Word16 ind1 = 0; ind1 < 1; ind1++ ) { IF( hCPE->hCoreCoder[ind1]->hHQ_core ) { - FOR( Word16 ind2 = 0; ind2 < L_FRAME32k; ind2++ ) - { - hCPE->hCoreCoder[ind1]->hHQ_core->old_outLB_fx[ind2] = (Word32) ( hCPE->hCoreCoder[ind1]->hHQ_core->old_outLB[ind2] * ( 1 << q_old_out_LB ) ); - } + Copy_Scale_sig_16_32( hCPE->hCoreCoder[ind1]->hHQ_core->old_out_LB_fx, hCPE->hCoreCoder[ind1]->hHQ_core->old_outLB_fx, L_FRAME32k, Q11 - hCPE->hCoreCoder[ind1]->hHQ_core->Q_old_wtda_LB ); hCPE->hCoreCoder[ind1]->hHQ_core->q_old_outLB_fx = q_old_out_LB; } } @@ -176,17 +157,15 @@ ivas_error ivas_cpe_dec_fx( FOR( Word16 ind1 = 0; ind1 < 2; ind1++ ) { IF( hCPE->hCoreCoder[ind1] && hCPE->hCoreCoder[ind1]->hHQ_core ) - FOR( Word16 ind2 = 0; ind2 < 960; ind2++ ) { - hCPE->hCoreCoder[ind1]->hHQ_core->old_out[ind2] = (float) ( hCPE->hCoreCoder[ind1]->hHQ_core->oldOut_fx[ind2] ) / ( 1 << q_old_out ); + Copy_Scale_sig_32_16( hCPE->hCoreCoder[ind1]->hHQ_core->oldOut_fx, hCPE->hCoreCoder[ind1]->hHQ_core->old_out_fx, L_FRAME48k, hCPE->hCoreCoder[ind1]->hHQ_core->Q_old_wtda - Q11 ); } } FOR( Word16 ind1 = 0; ind1 < 2; ind1++ ) { IF( hCPE->hCoreCoder[ind1] && hCPE->hCoreCoder[ind1]->hHQ_core ) - FOR( Word16 ind2 = 0; ind2 < L_FRAME32k; ind2++ ) { - hCPE->hCoreCoder[ind1]->hHQ_core->old_outLB[ind2] = (float) ( hCPE->hCoreCoder[ind1]->hHQ_core->old_outLB_fx[ind2] ) / ( 1 << q_old_out_LB ); + Copy_Scale_sig_32_16( hCPE->hCoreCoder[ind1]->hHQ_core->old_outLB_fx, hCPE->hCoreCoder[ind1]->hHQ_core->old_out_LB_fx, L_FRAME32k, hCPE->hCoreCoder[ind1]->hHQ_core->Q_old_wtda_LB - Q11 ); } } #endif @@ -541,31 +520,10 @@ ivas_error ivas_cpe_dec_fx( test(); IF( NE_16( hCPE->element_mode, IVAS_CPE_DFT ) || ( EQ_16( hCPE->nchan_out, 1 ) && EQ_16( hCPE->hStereoDft->hConfig->res_cod_mode, STEREO_DFT_RES_COD_OFF ) ) ) { -#ifndef TO_BE_REMOVED_CONVERSION - Word16 k; - for ( k = 0; k < n_channels; k++ ) - { - if ( sts[k]->hHQ_core != NULL ) - { - floatToFixed_arr( sts[k]->hHQ_core->old_out, sts[k]->hHQ_core->old_out_fx, sts[k]->hHQ_core->Q_old_wtda, L_FRAME48k ); - floatToFixed_arr( sts[k]->hHQ_core->old_outLB, sts[k]->hHQ_core->old_out_LB_fx, sts[k]->hHQ_core->Q_old_wtda_LB, L_FRAME32k ); - floatToFixed_arrL( sts[k]->hHQ_core->old_outLB, sts[k]->hHQ_core->old_outLB_fx, 11, L_FRAME32k ); - } - } -#endif IF( ( error = ivas_core_dec( st_ivas, NULL, hCPE, st_ivas->hMCT, n_channels, output, outputHB_fx, NULL, st_ivas->sba_dirac_stereo_flag ) ) != IVAS_ERR_OK ) { return error; } - - for ( k = 0; k < n_channels; k++ ) - { - if ( sts[k]->hHQ_core != NULL ) - { - fixedToFloat_arr( sts[k]->hHQ_core->old_out_fx, sts[k]->hHQ_core->old_out, sts[k]->hHQ_core->Q_old_wtda, L_FRAME48k ); - fixedToFloat_arr( sts[k]->hHQ_core->old_out_LB_fx, sts[k]->hHQ_core->old_outLB, sts[k]->hHQ_core->Q_old_wtda_LB, L_FRAME32k ); - } - } } IF( st_ivas->hMCT ) @@ -586,35 +544,12 @@ ivas_error ivas_cpe_dec_fx( set32_fx( DFT_fx[0], 0, STEREO_DFT_BUF_MAX ); set32_fx( DFT_fx[1], 0, STEREO_DFT_BUF_MAX ); -#ifndef TO_BE_REMOVED_CONVERSION - Word16 k; - for ( k = 0; k < n_channels; k++ ) - { - if ( sts[k]->hHQ_core != NULL ) - { - floatToFixed_arr( sts[k]->hHQ_core->old_out, sts[k]->hHQ_core->old_out_fx, sts[k]->hHQ_core->Q_old_wtda, L_FRAME48k ); - floatToFixed_arr( sts[k]->hHQ_core->old_outLB, sts[k]->hHQ_core->old_out_LB_fx, sts[k]->hHQ_core->Q_old_wtda_LB, L_FRAME32k ); - floatToFixed_arrL( sts[k]->hHQ_core->old_outLB, sts[k]->hHQ_core->old_outLB_fx, 11, L_FRAME32k ); - } - } - -#endif - /* core decoder */ IF( ( error = ivas_core_dec( NULL, NULL, hCPE, st_ivas->hMCT, n_channels, output, outputHB_fx, DFT_fx, 0 ) ) != IVAS_ERR_OK ) { return error; } - for ( k = 0; k < n_channels; k++ ) - { - if ( sts[k]->hHQ_core != NULL ) - { - fixedToFloat_arr( sts[k]->hHQ_core->old_out_fx, sts[k]->hHQ_core->old_out, sts[k]->hHQ_core->Q_old_wtda, L_FRAME48k ); - fixedToFloat_arr( sts[k]->hHQ_core->old_out_LB_fx, sts[k]->hHQ_core->old_outLB, sts[k]->hHQ_core->Q_old_wtda_LB, L_FRAME32k ); - } - } - // Scaling of DFT's Word16 shift; Word32 tmp1, tmp2; diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index 5ec1d414c..d78695d1e 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -3543,33 +3543,28 @@ void ivas_dirac_dec_render_sf_fx( #ifdef MSAN_FIX Word32 *output_buf_fx[], /* i/o: synthesized core-coder transport channels/DirAC output */ #endif // MSAN_FIX - const int16_t nchan_transport, /* i : number of transport channels */ - float *pppQMfFrame_ts_re[IVAS_MAX_FB_MIXER_IN_CH][CLDFB_NO_COL_MAX], - float *pppQMfFrame_ts_im[IVAS_MAX_FB_MIXER_IN_CH][CLDFB_NO_COL_MAX] ) + const Word16 nchan_transport, /* i : number of transport channels */ + Word32 *pppQMfFrame_ts_re_fx[IVAS_MAX_FB_MIXER_IN_CH][CLDFB_NO_COL_MAX], + Word32 *pppQMfFrame_ts_im_fx[IVAS_MAX_FB_MIXER_IN_CH][CLDFB_NO_COL_MAX] ) { - int16_t i, ch, idx_in, idx_lfe; + Word16 i, ch, idx_in, idx_lfe; DIRAC_DEC_HANDLE hDirAC; DIRAC_REND_HANDLE hDirACRend; - int16_t subframe_idx; - int16_t slot_idx, index_slot; - int16_t hodirac_flag; -#ifndef IVAS_FLOAT_FIXED - float *p_Rmat; -#endif - int16_t slot_idx_start, slot_idx_start_cldfb_synth, md_idx; + Word16 subframe_idx; + Word16 slot_idx, index_slot; + Word16 hodirac_flag; + Word16 slot_idx_start, slot_idx_start_cldfb_synth, md_idx; /*CLDFB: last output channels reserved to LFT for CICPx*/ Word32 Cldfb_RealBuffer_fx[MAX_OUTPUT_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; Word32 Cldfb_ImagBuffer_fx[MAX_OUTPUT_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; Word32 Cldfb_RealBuffer_Binaural_fx[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; Word32 Cldfb_ImagBuffer_Binaural_fx[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; - int16_t index = 0, num_freq_bands = 0; + Word16 index = 0, num_freq_bands = 0; /* local copies of azi, ele, diffuseness */ Word16 azimuth[CLDFB_NO_CHANNELS_MAX]; Word16 elevation[CLDFB_NO_CHANNELS_MAX]; - float diffuseness_vector[CLDFB_NO_CHANNELS_MAX]; -#ifdef IVAS_FLOAT_FIXED Word32 diffuseness_vector_fx[CLDFB_NO_CHANNELS_MAX]; Word32 *p_Rmat_fx; Word32 *reference_power_fx, *reference_power_smooth_fx, *onset_filter_fx, *onset_filter_subframe_fx; @@ -3580,32 +3575,23 @@ void ivas_dirac_dec_render_sf_fx( Word32 Cldfb_RealBuffer_Temp_fx[2][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; Word32 Cldfb_ImagBuffer_Temp_fx[2][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; Word16 cldfb_buf_q; - Word16 offset; - Word32 pppQMfFrame_ts_re_fx[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; - Word32 pppQMfFrame_ts_im_fx[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; - set_zero_fx( surCohRatio_fx, CLDFB_NO_CHANNELS_MAX ); + Word16 offset, buff_len; Word16 q_cldfb, q_temp_cldfb = 0; Word16 proto_length = 0; - Word32 proto_diffuse_buffer_f_fx[2 * MAX_OUTPUT_CHANNELS * CLDFB_SLOTS_PER_SUBFRAME * CLDFB_NO_CHANNELS_MAX]; - set_zero_fx( &proto_diffuse_buffer_f_fx[0], 2 * CLDFB_SLOTS_PER_SUBFRAME * CLDFB_NO_CHANNELS_MAX * MAX_OUTPUT_CHANNELS ); Word16 q_proto_direct_buffer[CLDFB_SLOTS_PER_SUBFRAME]; Word16 q_proto_diffuse_buffer[CLDFB_SLOTS_PER_SUBFRAME]; -#endif + Word16 size, size_ho; DIRAC_DEC_STACK_MEM DirAC_mem; - float *reference_power, *reference_power_smooth; - float *onset_filter, *onset_filter_subframe, *p_onset_filter = NULL; -#ifdef IVAS_FLOAT_FIXED Word32 *p_onset_filter_fx = NULL; -#endif uint16_t coherence_flag; SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; - Word16 q_onset_filter = 0; Word16 scale = 0; DIRAC_OUTPUT_SYNTHESIS_PARAMS *h_dirac_output_synthesis_params; DIRAC_OUTPUT_SYNTHESIS_STATE *h_dirac_output_synthesis_state; Word16 num_channels_dir, exp; Word16 q_diffuseness_vector = Q31, q_reference_power_smooth = Q31; + Word16 proto_power_smooth_len = 0; push_wmops( "ivas_dirac_dec_render" ); @@ -3616,10 +3602,6 @@ void ivas_dirac_dec_render_sf_fx( DirAC_mem = hDirACRend->stack_mem; - reference_power = DirAC_mem.reference_power; - reference_power_smooth = ( DirAC_mem.reference_power == NULL ) ? NULL : DirAC_mem.reference_power + hSpatParamRendCom->num_freq_bands; - onset_filter = DirAC_mem.onset_filter; - onset_filter_subframe = ( DirAC_mem.onset_filter == NULL ) ? NULL : DirAC_mem.onset_filter + hSpatParamRendCom->num_freq_bands; reference_power_fx = DirAC_mem.reference_power_fx; reference_power_smooth_fx = ( DirAC_mem.reference_power_fx == NULL ) ? NULL : DirAC_mem.reference_power_fx + hSpatParamRendCom->num_freq_bands; onset_filter_fx = DirAC_mem.onset_filter_fx; @@ -3628,33 +3610,18 @@ void ivas_dirac_dec_render_sf_fx( move16(); set_s( q_proto_direct_buffer, hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, CLDFB_SLOTS_PER_SUBFRAME ); set_s( q_proto_diffuse_buffer, hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q, CLDFB_SLOTS_PER_SUBFRAME ); - + set_zero_fx( surCohRatio_fx, CLDFB_NO_CHANNELS_MAX ); //////////////////////////////////////////////////////////////////////////// to be removed /////////////////////////////////////////////////////////////////// IF( EQ_16( hDirAC->hConfig->dec_param_estim, FALSE ) ) { - mvr2r( hSpatParamRendCom->diffuseness_vector[hSpatParamRendCom->render_to_md_map[hSpatParamRendCom->subframes_rendered]], diffuseness_vector, hSpatParamRendCom->num_freq_bands ); - // Copy32( hSpatParamRendCom->diffuseness_vector_fx[hSpatParamRendCom->render_to_md_map[hSpatParamRendCom->subframes_rendered]], diffuseness_vector_fx, hSpatParamRendCom->num_freq_bands ); - floatToFixed_arrL32( diffuseness_vector, hSpatParamRendCom->diffuseness_vector_fx[hSpatParamRendCom->render_to_md_map[hSpatParamRendCom->subframes_rendered]], Q30, hSpatParamRendCom->num_freq_bands ); + floatToFixed_arrL32( hSpatParamRendCom->diffuseness_vector[hSpatParamRendCom->render_to_md_map[hSpatParamRendCom->subframes_rendered]], hSpatParamRendCom->diffuseness_vector_fx[hSpatParamRendCom->render_to_md_map[hSpatParamRendCom->subframes_rendered]], Q30, hSpatParamRendCom->num_freq_bands ); md_idx = hSpatParamRendCom->render_to_md_map[hSpatParamRendCom->subframes_rendered]; } ELSE { - set_zero( diffuseness_vector, hSpatParamRendCom->num_freq_bands ); md_idx = hSpatParamRendCom->render_to_md_map[hSpatParamRendCom->slots_rendered]; } - IF( hDirACRend->synthesisConf != DIRAC_SYNTHESIS_GAIN_SHD ) - { - set_zero( reference_power_smooth, hSpatParamRendCom->num_freq_bands ); - } - ELSE - { - set_zero( onset_filter_subframe, hSpatParamRendCom->num_freq_bands ); -#ifdef IVAS_FLOAT_FIXED - set_zero_fx( onset_filter_subframe_fx, hSpatParamRendCom->num_freq_bands ); -#endif - } - IF( st_ivas->hCombinedOrientationData && st_ivas->hCombinedOrientationData->enableCombinedOrientation[st_ivas->hCombinedOrientationData->subframe_idx] ) { p_Rmat_fx = &st_ivas->hCombinedOrientationData->Rmat_fx[st_ivas->hCombinedOrientationData->subframe_idx][0][0]; @@ -3683,11 +3650,7 @@ void ivas_dirac_dec_render_sf_fx( { IF( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) { - FOR( ch = 0; ch < nchan_transport; ch++ ) - { - floatToFixed_arrL32( pppQMfFrame_ts_re[ch][slot_idx], pppQMfFrame_ts_re_fx[ch][slot_idx], Q6, hSpatParamRendCom->num_freq_bands ); - floatToFixed_arrL32( pppQMfFrame_ts_im[ch][slot_idx], pppQMfFrame_ts_im_fx[ch][slot_idx], Q6, hSpatParamRendCom->num_freq_bands ); - } + } ELSE { @@ -3751,6 +3714,7 @@ void ivas_dirac_dec_render_sf_fx( { hDirACRend->masa_stereo_type_detect->subtract_target_ratio_db_fx = floatToFixed( hDirACRend->masa_stereo_type_detect->subtract_target_ratio_db, Q21 ); } + hDirACRend->masa_stereo_type_detect->subtract_power_y_fx = floatToFixed(hDirACRend->masa_stereo_type_detect->subtract_power_y, hDirACRend->masa_stereo_type_detect->q_subtract_power_y); } } BREAK; @@ -3824,6 +3788,130 @@ void ivas_dirac_dec_render_sf_fx( h_dirac_output_synthesis_state->q_cy_auto_diff_smooth = L_get_q_buf( h_dirac_output_synthesis_state->cy_auto_diff_smooth, num_channels_dir * hSpatParamRendCom->num_freq_bands ); floatToFixed_arrL( h_dirac_output_synthesis_state->cy_auto_diff_smooth, h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx, h_dirac_output_synthesis_state->q_cy_auto_diff_smooth, num_channels_dir * hSpatParamRendCom->num_freq_bands ); } + + if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) + { + FOR( ch = 0; ch < st_ivas->hDecoderConfig->nchan_out; ch++ ) + { + st_ivas->cldfbSynDec[ch]->Q_cldfb_state = Q_factor_arrL( st_ivas->cldfbSynDec[ch]->cldfb_state, st_ivas->cldfbSynDec[ch]->p_filter_length ); + floatToFixed_arrL( st_ivas->cldfbSynDec[ch]->cldfb_state, st_ivas->cldfbSynDec[ch]->cldfb_state_fx, st_ivas->cldfbSynDec[ch]->Q_cldfb_state, st_ivas->cldfbSynDec[ch]->p_filter_length ); + } + } + else if ( !L_or( EQ_16( st_ivas->ivas_format, SBA_FORMAT ), EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) ) + { + idx_lfe = 0; + idx_in = 0; + Word16 outchannels = add( hDirACRend->hOutSetup.nchan_out_woLFE, hDirACRend->hOutSetup.num_lfe ); + + IF( hDirACRend->hOutSetup.separateChannelEnabled && ( EQ_16( hDirACRend->hOutSetup.output_config, IVAS_AUDIO_CONFIG_5_1 ) || + EQ_16( hDirACRend->hOutSetup.output_config, IVAS_AUDIO_CONFIG_7_1 ) || + EQ_16( hDirACRend->hOutSetup.output_config, IVAS_AUDIO_CONFIG_5_1_2 ) || + EQ_16( hDirACRend->hOutSetup.output_config, IVAS_AUDIO_CONFIG_5_1_4 ) || + EQ_16( hDirACRend->hOutSetup.output_config, IVAS_AUDIO_CONFIG_7_1_4 ) || + ( EQ_16( hDirACRend->hOutSetup.output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) && st_ivas->hLsSetupCustom->separate_ch_found ) ) ) + { + outchannels = add( outchannels, 1 ); + } + + IF( ( hDirACRend->hOutSetup.separateChannelEnabled && EQ_16( hDirACRend->hOutSetup.output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) ) ) + { + FOR( ch = 0; ch < outchannels; ch++ ) + { + IF( L_and( GT_16( hDirACRend->hOutSetup.num_lfe, 0 ), ( EQ_16( hDirACRend->hOutSetup.index_lfe[idx_lfe], ch ) ) ) ) + { + IF( LT_16( idx_lfe, sub( hDirACRend->hOutSetup.num_lfe, 1 ) ) ) + { + idx_lfe = add( idx_lfe, 1 ); + } + } + } + } + ELSE + { + FOR( ch = 0; ch < outchannels; ch++ ) + { + IF( L_and( GT_16( hDirACRend->hOutSetup.num_lfe, 0 ), ( EQ_16( hDirACRend->hOutSetup.index_lfe[idx_lfe], ch ) ) ) ) + { + IF( EQ_16( st_ivas->mc_mode, MC_MODE_MCMASA ) && !hDirACRend->hOutSetup.separateChannelEnabled ) + { + Word16 cldfbSynIdx = add( hDirACRend->hOutSetup.nchan_out_woLFE, idx_lfe ); + st_ivas->cldfbSynDec[cldfbSynIdx]->Q_cldfb_state = Q_factor_arrL( st_ivas->cldfbSynDec[cldfbSynIdx]->cldfb_state, st_ivas->cldfbSynDec[cldfbSynIdx]->p_filter_length ); + floatToFixed_arrL( st_ivas->cldfbSynDec[cldfbSynIdx]->cldfb_state, st_ivas->cldfbSynDec[cldfbSynIdx]->cldfb_state_fx, st_ivas->cldfbSynDec[cldfbSynIdx]->Q_cldfb_state, st_ivas->cldfbSynDec[cldfbSynIdx]->p_filter_length ); + } + } + ELSE IF( ( hDirACRend->hOutSetup.separateChannelEnabled ) && EQ_16( hDirACRend->hOutSetup.separateChannelIndex, ch ) ) + { + } + ELSE + { + st_ivas->cldfbSynDec[idx_in]->Q_cldfb_state = Q_factor_arrL( st_ivas->cldfbSynDec[idx_in]->cldfb_state, st_ivas->cldfbSynDec[idx_in]->p_filter_length ); + floatToFixed_arrL( st_ivas->cldfbSynDec[idx_in]->cldfb_state, st_ivas->cldfbSynDec[idx_in]->cldfb_state_fx, st_ivas->cldfbSynDec[idx_in]->Q_cldfb_state, st_ivas->cldfbSynDec[idx_in]->p_filter_length ); + idx_in = add( idx_in, 1 ); + } + } + } + } + + /////////////////////////////////////////////////////////////////////////////////////////////// + size = hDirACRend->num_outputs_dir * hSpatParamRendCom->num_freq_bands; + size_ho = ( hodirac_flag ) ? size * DIRAC_HO_NUMSECTORS : size; + hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_q = Q26; + hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_q = Q26; + floatToFixed_arrL( hDirACRend->h_output_synthesis_psd_state.gains_dir_prev, hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_fx, hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_q, size ); + IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) + { + hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth = L_get_q_buf1( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth, size_ho ); + floatToFixed_arrL( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth, hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_fx, hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth, size_ho ); + + hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev = Q26; + floatToFixed_arrL( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev, hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev, size_ho ); + + hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth = Q26; + floatToFixed_arrL( hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth, hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_fx, hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth, hDirACRend->num_outputs_diff * hDirACRend->h_output_synthesis_psd_params.max_band_decorr ); + + hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth_prev = Q26; + floatToFixed_arrL( hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev, hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth_prev, hDirACRend->num_outputs_diff * hDirACRend->h_output_synthesis_psd_params.max_band_decorr ); + + hDirACRend->diffuse_response_function_q = Q15; + floatToFixed_arr( hDirACRend->diffuse_response_function, hDirACRend->diffuse_response_function_fx, hDirACRend->diffuse_response_function_q, hDirACRend->num_outputs_dir ); + } + ELSE + { + IF( st_ivas->hMasa != NULL ) + { + st_ivas->hMasa->data.dir_decode_quality_fx = float_to_fix16( st_ivas->hMasa->data.dir_decode_quality, Q15 ); + } + floatToFixed_arrL( hDirACRend->h_output_synthesis_psd_state.gains_diff_prev, hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_fx, hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_q, hSpatParamRendCom->num_freq_bands * hDirACRend->hOutSetup.nchan_out_woLFE ); + IF( hDirACRend->masa_stereo_type_detect != NULL ) + { + hDirACRend->masa_stereo_type_detect->q_target_power_y_smooth = L_get_q( hDirACRend->masa_stereo_type_detect->target_power_y_smooth ); + hDirACRend->masa_stereo_type_detect->target_power_y_smooth_fx = floatToFixed( hDirACRend->masa_stereo_type_detect->target_power_y_smooth, hDirACRend->masa_stereo_type_detect->q_target_power_y_smooth ); + hDirACRend->masa_stereo_type_detect->q_subtract_power_y = L_get_q( hDirACRend->masa_stereo_type_detect->subtract_power_y ); + hDirACRend->masa_stereo_type_detect->q_subtract_power_y_smooth = L_get_q( hDirACRend->masa_stereo_type_detect->subtract_power_y_smooth ); + hDirACRend->masa_stereo_type_detect->subtract_power_y_smooth_fx = floatToFixed( hDirACRend->masa_stereo_type_detect->subtract_power_y_smooth, hDirACRend->masa_stereo_type_detect->q_subtract_power_y_smooth ); + hDirACRend->masa_stereo_type_detect->subtract_power_y_fx = floatToFixed( hDirACRend->masa_stereo_type_detect->subtract_power_y, hDirACRend->masa_stereo_type_detect->q_subtract_power_y ); + } + hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q = L_get_q_buf( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev, hSpatParamRendCom->num_freq_bands ); + floatToFixed_arrL( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev, hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q, hSpatParamRendCom->num_freq_bands ); + + hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth_prev = L_get_q_buf1( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_prev, size_ho ); + floatToFixed_arrL( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_prev, hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth_prev, size_ho ); + + hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev = L_get_q_buf1( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev, size_ho ); + floatToFixed_arrL( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev, hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev, size_ho ); + + hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth_prev = L_get_q_buf1( hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev, hSpatParamRendCom->num_freq_bands * hDirACRend->hOutSetup.nchan_out_woLFE ); + floatToFixed_arrL( hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev, hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth_prev, hSpatParamRendCom->num_freq_bands * hDirACRend->hOutSetup.nchan_out_woLFE ); + + hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q = L_get_q_buf1( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev, hDirACRend->num_protos_dir * hSpatParamRendCom->num_freq_bands ); + floatToFixed_arrL( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q, hDirACRend->num_protos_dir * hSpatParamRendCom->num_freq_bands ); + + IF( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev != 0 ) + { + hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_q = L_get_q_buf1( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev, hDirACRend->h_output_synthesis_psd_params.max_band_decorr * hDirACRend->hOutSetup.nchan_out_woLFE ); + floatToFixed_arrL( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev, hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_q, hDirACRend->h_output_synthesis_psd_params.max_band_decorr * hDirACRend->hOutSetup.nchan_out_woLFE ); + } + } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// hodirac_flag = ivas_get_hodirac_flag_fx( st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->sba_analysis_order ); @@ -3861,12 +3949,16 @@ void ivas_dirac_dec_render_sf_fx( IF( EQ_16( hDirAC->hConfig->dec_param_estim, FALSE ) ) { Copy32( hSpatParamRendCom->diffuseness_vector_fx[hSpatParamRendCom->render_to_md_map[subframe_idx]], diffuseness_vector_fx, hSpatParamRendCom->num_freq_bands ); + q_diffuseness_vector = Q30; + move16(); Copy( hSpatParamRendCom->azimuth[hSpatParamRendCom->render_to_md_map[subframe_idx]], azimuth, hSpatParamRendCom->num_freq_bands ); Copy( hSpatParamRendCom->elevation[hSpatParamRendCom->render_to_md_map[subframe_idx]], elevation, hSpatParamRendCom->num_freq_bands ); } ELSE { set32_fx( diffuseness_vector_fx, 0, hSpatParamRendCom->num_freq_bands ); + q_diffuseness_vector = Q31; + move16(); } IF( hDirACRend->synthesisConf != DIRAC_SYNTHESIS_GAIN_SHD ) @@ -4117,7 +4209,7 @@ void ivas_dirac_dec_render_sf_fx( protoSignalComputation_shd_fx( Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx, &hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, - proto_diffuse_buffer_f_fx, + hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_fx, &hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q, reference_power_fx, &DirAC_mem.reference_power_q, slot_idx, nchan_transport, @@ -4130,7 +4222,7 @@ void ivas_dirac_dec_render_sf_fx( protoSignalComputation_shd_fx( Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx, &hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, - proto_diffuse_buffer_f_fx, + hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_fx, &hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q, reference_power_fx, &DirAC_mem.reference_power_q, slot_idx, nchan_transport, @@ -4161,6 +4253,7 @@ void ivas_dirac_dec_render_sf_fx( move16(); proto_length = i_mult( 6, hSpatParamRendCom->num_freq_bands ); + proto_power_smooth_len = i_mult( 2, hSpatParamRendCom->num_freq_bands ); } ELSE { @@ -4185,6 +4278,7 @@ void ivas_dirac_dec_render_sf_fx( nchan_transport, hDirACRend->sba_map_tc, q_cldfb ); proto_length = i_mult( 2, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_diff ) ); + proto_power_smooth_len = i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_diff ); BREAK; case 2: protoSignalComputation2_fx( Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, hDirACRend->proto_frame_f_fx, @@ -4201,6 +4295,14 @@ void ivas_dirac_dec_render_sf_fx( hDirACRend->masa_stereo_type_detect, q_cldfb ); proto_length = i_mult( 6, hSpatParamRendCom->num_freq_bands ); + IF( hDirACRend->hOutSetup.is_loudspeaker_setup ) + { + proto_power_smooth_len = i_mult( 3, hSpatParamRendCom->num_freq_bands ); + } + ELSE + { + proto_power_smooth_len = i_mult( 2, hSpatParamRendCom->num_freq_bands ); + } BREAK; case 1: protoSignalComputation1_fx( Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, @@ -4216,6 +4318,8 @@ void ivas_dirac_dec_render_sf_fx( hDirACRend->num_protos_diff, hSpatParamRendCom->num_freq_bands, q_cldfb ); proto_length = i_mult( 2, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_protos_diff ) ); + proto_power_smooth_len = hSpatParamRendCom->num_freq_bands; + move16(); BREAK; default: return; @@ -4286,21 +4390,21 @@ void ivas_dirac_dec_render_sf_fx( hDirACRend->num_protos_diff, hDirACRend->synthesisConf, nchan_transport, - &proto_diffuse_buffer_f_fx[slot_idx * 2 * hSpatParamRendCom->num_freq_bands * hDirACRend->num_outputs_diff], + &hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_fx[slot_idx * 2 * hSpatParamRendCom->num_freq_bands * hDirACRend->num_outputs_diff], hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q, hDirACRend->num_protos_diff, hDirACRend->proto_index_diff, - &proto_diffuse_buffer_f_fx[slot_idx * 2 * hSpatParamRendCom->num_freq_bands * hDirACRend->num_outputs_diff + 2 * hSpatParamRendCom->num_freq_bands * min( 4, nchan_transport )], + &hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_fx[slot_idx * 2 * hSpatParamRendCom->num_freq_bands * hDirACRend->num_outputs_diff + 2 * hSpatParamRendCom->num_freq_bands * min( 4, nchan_transport )], &hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q, onset_filter_fx, hDirACRend->h_freq_domain_decorr_ap_params, hDirACRend->h_freq_domain_decorr_ap_state ); - q_onset_filter = Q31; + DirAC_mem.q_onset_filter = Q31; move16(); v_multc_fixed( onset_filter_fx, 268435456, onset_filter_fx, hSpatParamRendCom->num_freq_bands ); // 268435456 = 0.25 in Q30 - q_onset_filter = sub( add( q_onset_filter, Q30 ), Q31 ); + DirAC_mem.q_onset_filter = sub( add( DirAC_mem.q_onset_filter, Q30 ), Q31 ); v_add_fixed( onset_filter_fx, onset_filter_subframe_fx, onset_filter_subframe_fx, hSpatParamRendCom->num_freq_bands, 0 ); // Q30 p_onset_filter_fx = onset_filter_subframe_fx; @@ -4332,8 +4436,8 @@ void ivas_dirac_dec_render_sf_fx( move16(); p_onset_filter_fx = onset_filter_fx; - scale_sig32( onset_filter_fx, hSpatParamRendCom->num_freq_bands * hDirACRend->num_outputs_diff, -1 ); - q_onset_filter = Q30; + scale_sig32( onset_filter_fx, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_diff ), -1 ); + DirAC_mem.q_onset_filter = Q30; move16(); } } @@ -4342,7 +4446,7 @@ void ivas_dirac_dec_render_sf_fx( IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) { set_l( onset_filter_subframe_fx, ONE_IN_Q30, hSpatParamRendCom->num_freq_bands ); - q_onset_filter = Q30; + DirAC_mem.q_onset_filter = Q30; move16(); p_onset_filter_fx = onset_filter_subframe_fx; } @@ -4522,18 +4626,28 @@ void ivas_dirac_dec_render_sf_fx( } } -#ifdef IVAS_FLOAT_FIXED - ////////////////////////////////// to be removed ///////////////////////////////////// + minimum_s( q_proto_direct_buffer, hSpatParamRendCom->subframe_nbslots[subframe_idx], &hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q ); + IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) + { + minimum_s( q_proto_diffuse_buffer, hSpatParamRendCom->subframe_nbslots[subframe_idx], &hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q ); + } FOR( slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[subframe_idx]; slot_idx++ ) { IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) { - fixedToFloat_arrL32( &hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx[i_mult( i_mult( slot_idx, 2 ), i_mult( hSpatParamRendCom->num_freq_bands, nchan_transport ) )], hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f + i_mult( i_mult( slot_idx, 2 ), i_mult( hSpatParamRendCom->num_freq_bands, nchan_transport ) ), q_proto_direct_buffer[slot_idx], 2 * nchan_transport * hSpatParamRendCom->num_freq_bands ); - fixedToFloat_arrL32( &proto_diffuse_buffer_f_fx[i_mult( i_mult( slot_idx, 2 ), i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_diff ) )], hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f + i_mult( i_mult( slot_idx, 2 ), i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_diff ) ), q_proto_diffuse_buffer[slot_idx], 2 * hDirACRend->num_outputs_diff * hSpatParamRendCom->num_freq_bands ); + offset = i_mult( i_mult( slot_idx, 2 ), i_mult( hSpatParamRendCom->num_freq_bands, nchan_transport ) ); + buff_len = i_mult( 2, i_mult( nchan_transport, hSpatParamRendCom->num_freq_bands ) ); + scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx + offset, buff_len, sub( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, q_proto_direct_buffer[slot_idx] ) ); + + offset = i_mult( i_mult( slot_idx, 2 ), i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_diff ) ); + buff_len = 2 * hDirACRend->num_outputs_diff * hSpatParamRendCom->num_freq_bands; + scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_fx + offset, buff_len, sub( hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q, q_proto_diffuse_buffer[slot_idx] ) ); } ELSE IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_MONO ) ) { - fixedToFloat_arrL32( &hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx[i_mult( i_mult( i_mult( slot_idx, 2 ), hSpatParamRendCom->num_freq_bands ), 2 )], hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f + i_mult( i_mult( i_mult( slot_idx, 2 ), hSpatParamRendCom->num_freq_bands ), 2 ), q_proto_direct_buffer[slot_idx], i_mult( 4, hSpatParamRendCom->num_freq_bands ) ); + offset = i_mult( slot_idx, i_mult( 4, hSpatParamRendCom->num_freq_bands ) ); + buff_len = i_mult( 4, hSpatParamRendCom->num_freq_bands ); + scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx + offset, buff_len, sub( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, q_proto_direct_buffer[slot_idx] ) ); } ELSE { @@ -4544,304 +4658,93 @@ void ivas_dirac_dec_render_sf_fx( case 6: case 4: offset = i_mult( i_mult( slot_idx, 2 ), i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_diff ) ); - fixedToFloat_arrL32( &hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx[offset], &hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f[offset], q_proto_direct_buffer[slot_idx], i_mult( 2, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_diff ) ) ); + buff_len = i_mult( 2, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_diff ) ); + scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx + offset, buff_len, sub( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, q_proto_direct_buffer[slot_idx] ) ); BREAK; case 2: IF( hDirACRend->hOutSetup.is_loudspeaker_setup ) { - fixedToFloat_arrL32( &hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx[i_mult( i_mult( i_mult( slot_idx, 2 ), hSpatParamRendCom->num_freq_bands ), 3 )], hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f + i_mult( i_mult( i_mult( slot_idx, 2 ), hSpatParamRendCom->num_freq_bands ), 3 ), q_proto_direct_buffer[slot_idx], i_mult( 6, hSpatParamRendCom->num_freq_bands ) ); + offset = i_mult( i_mult( i_mult( slot_idx, 2 ), hSpatParamRendCom->num_freq_bands ), 3 ); + buff_len = i_mult( 6, hSpatParamRendCom->num_freq_bands ); } ELSE { - fixedToFloat_arrL32( &hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx[i_mult( i_mult( i_mult( slot_idx, 2 ), hSpatParamRendCom->num_freq_bands ), 2 )], hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f + i_mult( i_mult( i_mult( slot_idx, 2 ), hSpatParamRendCom->num_freq_bands ), 2 ), q_proto_direct_buffer[slot_idx], i_mult( 4, hSpatParamRendCom->num_freq_bands ) ); + offset = i_mult( i_mult( i_mult( slot_idx, 2 ), hSpatParamRendCom->num_freq_bands ), 2 ); + buff_len = i_mult( 4, hSpatParamRendCom->num_freq_bands ); } + scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx + offset, buff_len, sub( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, q_proto_direct_buffer[slot_idx] ) ); BREAK; case 1: - fixedToFloat_arrL32( &hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx[i_mult( slot_idx, i_mult( 2, hSpatParamRendCom->num_freq_bands ) )], hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f + i_mult( slot_idx, i_mult( 2, hSpatParamRendCom->num_freq_bands ) ), q_proto_direct_buffer[slot_idx], i_mult( 2, hSpatParamRendCom->num_freq_bands ) ); + offset = i_mult( slot_idx, i_mult( 2, hSpatParamRendCom->num_freq_bands ) ); + buff_len = i_mult( 2, hSpatParamRendCom->num_freq_bands ); + scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx + offset, buff_len, sub( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, q_proto_direct_buffer[slot_idx] ) ); BREAK; } } + q_proto_direct_buffer[slot_idx] = hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q; } - IF( EQ_16( hDirAC->hConfig->dec_param_estim, FALSE ) ) - { - IF( hDirACRend->synthesisConf != DIRAC_SYNTHESIS_GAIN_SHD ) - { - fixedToFloat_arrL32( hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_fx, hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor, hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_q, hSpatParamRendCom->num_freq_bands ); - fixedToFloat_arrL32( hDirACRend->h_output_synthesis_psd_state.direct_power_factor_fx, hDirACRend->h_output_synthesis_psd_state.direct_power_factor, hDirACRend->h_output_synthesis_psd_state.direct_power_factor_q, hSpatParamRendCom->num_freq_bands ); - } - ELSE - { - me2f_buf( hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_fx, 31 - hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_q, hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor, hSpatParamRendCom->num_freq_bands ); - me2f_buf( hDirACRend->h_output_synthesis_psd_state.direct_power_factor_fx, 31 - hDirACRend->h_output_synthesis_psd_state.direct_power_factor_q, hDirACRend->h_output_synthesis_psd_state.direct_power_factor, hSpatParamRendCom->num_freq_bands ); - } - } - IF( st_ivas->hMasa == NULL && EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) - { - fixedToFloat_arrL32( hDirACRend->h_output_synthesis_psd_state.direct_responses_fx, hDirACRend->h_output_synthesis_psd_state.direct_responses, hDirACRend->h_output_synthesis_psd_state.direct_responses_q, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ) ); - IF( hodirac_flag ) - { - fixedToFloat_arrL32( &hDirACRend->h_output_synthesis_psd_state.direct_responses_fx[i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir )], &hDirACRend->h_output_synthesis_psd_state.direct_responses[i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir )], hDirACRend->h_output_synthesis_psd_state.direct_responses_q, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ) ); - } + ivas_dirac_dec_output_synthesis_get_interpolator_fx( &hDirACRend->h_output_synthesis_psd_params, hSpatParamRendCom->subframe_nbslots[subframe_idx] ); + + size = i_mult( hDirACRend->num_outputs_dir, hSpatParamRendCom->num_freq_bands ); + IF( hodirac_flag ) + { + size_ho = i_mult( size, DIRAC_HO_NUMSECTORS ); } ELSE { - fixedToFloat_arrL32( hDirACRend->h_output_synthesis_psd_state.direct_responses_fx, hDirACRend->h_output_synthesis_psd_state.direct_responses, hDirACRend->h_output_synthesis_psd_state.direct_responses_q, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ) ); - IF( hDirACRend->synthesisConf != DIRAC_SYNTHESIS_GAIN_SHD ) - { - fixedToFloat_arrL32( hDirACRend->h_output_synthesis_psd_state.direct_responses_square_fx, hDirACRend->h_output_synthesis_psd_state.direct_responses_square, hDirACRend->h_output_synthesis_psd_state.direct_responses_square_q, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ) ); - } + size_ho = size; + move16(); } - IF( !( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) ) + + IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) { - FOR( ch = 0; ch < nchan_transport; ch++ ) + IF( NE_16( hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth, Q26 ) ) { - fixedToFloat_arrL32( st_ivas->cldfbAnaDec[ch]->cldfb_state_fx, st_ivas->cldfbAnaDec[ch]->cldfb_state, Q11, ( st_ivas->cldfbAnaDec[ch]->p_filter_length - st_ivas->cldfbAnaDec[ch]->no_channels ) ); + Scale_sig32( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_fx, size_ho, sub( Q26, hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth ) ); + hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth = Q26; } - } - IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) - { - IF( nchan_transport >= 4 ) + IF( NE_16( hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev, Q26 ) ) { - fixedToFloat_arrL32( reference_power_fx, reference_power, DirAC_mem.reference_power_q, 5 * hSpatParamRendCom->num_freq_bands ); + scale_sig32( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev_fx, size_ho, sub( Q26, hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev ) ); } - } - ELSE IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_MONO ) ) - { - fixedToFloat_arrL32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, i_mult( 2, hSpatParamRendCom->num_freq_bands ) ); - fixedToFloat_arrL32( hDirACRend->proto_frame_f_fx, hDirACRend->proto_frame_f, hDirACRend->proto_frame_f_q, i_mult( 6, hSpatParamRendCom->num_freq_bands ) ); - fixedToFloat_arrL32( reference_power_fx, reference_power, DirAC_mem.reference_power_q, hSpatParamRendCom->num_freq_bands ); - IF( hDirACRend->masa_stereo_type_detect ) + IF( NE_16( hDirACRend->h_output_synthesis_psd_state.direct_power_factor_q, Q31 ) ) { - hDirACRend->masa_stereo_type_detect->subtract_power_y = fixedToFloat_32( hDirACRend->masa_stereo_type_detect->subtract_power_y_fx, hDirACRend->masa_stereo_type_detect->q_subtract_power_y ); + Scale_sig32( hDirACRend->h_output_synthesis_psd_state.direct_power_factor_fx, ( size_ho / hDirACRend->num_outputs_dir ), sub( Q31, hDirACRend->h_output_synthesis_psd_state.direct_power_factor_q ) ); } - } - ELSE - { - SWITCH( nchan_transport ) + IF( NE_16( hDirACRend->h_output_synthesis_psd_state.direct_responses_q, Q31 ) ) { - case 11: - case 8: - case 6: - case 4: - fixedToFloat_arrL32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_diff ) ); - me2f_buf( hDirACRend->proto_frame_f_fx, hDirACRend->proto_frame_f_q, hDirACRend->proto_frame_f, i_mult( 2, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_diff ) ) ); - fixedToFloat_arrL32( reference_power_fx, reference_power, DirAC_mem.reference_power_q, hSpatParamRendCom->num_freq_bands ); - BREAK; - case 2: - IF( hDirACRend->hOutSetup.is_loudspeaker_setup ) - { - fixedToFloat_arrL32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, i_mult( 3, hSpatParamRendCom->num_freq_bands ) ); - } - ELSE - { - fixedToFloat_arrL32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, i_mult( 2, hSpatParamRendCom->num_freq_bands ) ); - IF( hDirACRend->masa_stereo_type_detect ) - { - hDirACRend->masa_stereo_type_detect->subtract_power_y = fixedToFloat_32( hDirACRend->masa_stereo_type_detect->subtract_power_y_fx, hDirACRend->masa_stereo_type_detect->q_subtract_power_y ); - } - } - me2f_buf( hDirACRend->proto_frame_f_fx, hDirACRend->proto_frame_f_q, hDirACRend->proto_frame_f, i_mult( 6, hSpatParamRendCom->num_freq_bands ) ); - fixedToFloat_arrL32( reference_power_fx, reference_power, DirAC_mem.reference_power_q, hSpatParamRendCom->num_freq_bands ); - BREAK; - case 1: - fixedToFloat_arrL32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, hSpatParamRendCom->num_freq_bands ); - me2f_buf( hDirACRend->proto_frame_f_fx, hDirACRend->proto_frame_f_q, hDirACRend->proto_frame_f, i_mult( 2, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_protos_diff ) ) ); - fixedToFloat_arrL32( reference_power_fx, reference_power, DirAC_mem.reference_power_q, hSpatParamRendCom->num_freq_bands ); - BREAK; + Scale_sig32( hDirACRend->h_output_synthesis_psd_state.direct_responses_fx, size_ho, sub( Q31, hDirACRend->h_output_synthesis_psd_state.direct_responses_q ) ); } - } - - IF( EQ_16( hDirAC->hConfig->dec_param_estim, TRUE ) ) - { - FOR( i = 0; i < DIRAC_NO_COL_AVG_DIFF; i++ ) + IF( NE_16( hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_q, Q31 ) ) { - fixedToFloat_arrL32( hDirACRend->buffer_intensity_real_fx[0][i], hDirACRend->buffer_intensity_real[0][i], hDirACRend->q_buffer_intensity_real[i], hDirAC->band_grouping[hDirAC->hConfig->enc_param_start_band] ); - fixedToFloat_arrL32( hDirACRend->buffer_intensity_real_fx[1][i], hDirACRend->buffer_intensity_real[1][i], hDirACRend->q_buffer_intensity_real[i], hDirAC->band_grouping[hDirAC->hConfig->enc_param_start_band] ); - fixedToFloat_arrL32( hDirACRend->buffer_intensity_real_fx[2][i], hDirACRend->buffer_intensity_real[2][i], hDirACRend->q_buffer_intensity_real[i], hDirAC->band_grouping[hDirAC->hConfig->enc_param_start_band] ); - fixedToFloat_arrL32( &hDirACRend->buffer_energy_fx[i * num_freq_bands], &hDirACRend->buffer_energy[i * num_freq_bands], hDirACRend->q_buffer_energy[i], hDirAC->band_grouping[hDirAC->hConfig->enc_param_start_band] ); + Scale_sig32( hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_fx, hDirACRend->h_output_synthesis_psd_params.max_band_decorr, sub( Q31, hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_q ) ); } - FOR( slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[subframe_idx]; slot_idx++ ) + IF( NE_16( hDirACRend->diffuse_response_function_q, Q15 ) ) { - md_idx = hSpatParamRendCom->render_to_md_map[add( hSpatParamRendCom->slots_rendered, slot_idx )]; - fixedToFloat_arrL32( hSpatParamRendCom->diffuseness_vector_fx[md_idx], hSpatParamRendCom->diffuseness_vector[md_idx], Q30, hDirAC->band_grouping[hDirAC->hConfig->enc_param_start_band] ); + Scale_sig( hDirACRend->diffuse_response_function_fx, hDirACRend->num_outputs_dir, sub( Q15, hDirACRend->diffuse_response_function_q ) ); } - } - - IF( EQ_16( hDirACRend->proto_signal_decorr_on, 1 ) ) - { - IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) + IF( NE_16( hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth, Q26 ) ) { - fixedToFloat_arrL( onset_filter_fx, onset_filter, q_onset_filter, hSpatParamRendCom->num_freq_bands ); - fixedToFloat_arrL( onset_filter_subframe_fx, onset_filter_subframe, q_onset_filter, hSpatParamRendCom->num_freq_bands ); - p_onset_filter = onset_filter_subframe; + scale_sig32( hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_fx, i_mult( hDirACRend->num_outputs_diff, hDirACRend->h_output_synthesis_psd_params.max_band_decorr ), sub( Q26, hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth ) ); } - ELSE + IF( NE_16( hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth_prev, Q26 ) ) { - fixedToFloat_arrL( onset_filter_fx, onset_filter, q_onset_filter, hSpatParamRendCom->num_freq_bands * hDirACRend->num_outputs_diff ); - me2f_buf( DirAC_mem.frame_dec_f_fx, 31 - DirAC_mem.frame_dec_f_q, DirAC_mem.frame_dec_f, DirAC_mem.frame_dec_f_len ); - - hDirACRend->proto_frame_dec_f = DirAC_mem.frame_dec_f; - p_onset_filter = onset_filter; + scale_sig32( hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev_fx, i_mult( hDirACRend->num_outputs_diff, hDirACRend->h_output_synthesis_psd_params.max_band_decorr ), sub( Q26, hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth_prev ) ); } - } - ELSE - { - IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) + IF( NE_16( q_diffuseness_vector, Q30 ) ) { - fixedToFloat_arrL( onset_filter_fx, onset_filter, q_onset_filter, hSpatParamRendCom->num_freq_bands ); - p_onset_filter = onset_filter_subframe; + scale_sig32( diffuseness_vector_fx, hSpatParamRendCom->num_freq_bands, sub( Q30, q_diffuseness_vector ) ); } - ELSE + IF( NE_16( hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_q, Q26 ) ) { - hDirACRend->proto_frame_dec_f = hDirACRend->proto_frame_f; - p_onset_filter = NULL; + scale_sig32( hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_fx, size, sub( Q26, hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_q ) ); } - } - IF( L_or( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_PSD_LS ), EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_PSD_SHD ) ) ) - { - if ( hDirACRend->h_output_synthesis_psd_params.max_band_decorr != 0 ) + IF( NE_16( hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_q, Q26 ) ) { - DIRAC_OUTPUT_SYNTHESIS_STATE *state = &( hDirACRend->h_output_synthesis_psd_state ); - me2f_buf( state->proto_power_diff_smooth_fx, - 31 - state->proto_power_diff_smooth_q, - state->proto_power_diff_smooth, - state->proto_power_diff_smooth_len ); - me2f_buf( state->proto_diffuse_buffer_f_fx, - 31 - state->proto_diffuse_buffer_f_q, - state->proto_diffuse_buffer_f, - state->proto_diffuse_buffer_f_len ); - } - } - - if ( hDirAC->hConfig->dec_param_estim == FALSE && hodirac_flag ) - { - if ( hDirACRend->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD ) - { - fixedToFloat_arrL( h_dirac_output_synthesis_state->direct_power_factor_fx, h_dirac_output_synthesis_state->direct_power_factor, h_dirac_output_synthesis_state->direct_power_factor_q, 2 * hSpatParamRendCom->num_freq_bands ); - fixedToFloat_arrL( h_dirac_output_synthesis_state->diffuse_power_factor_fx, h_dirac_output_synthesis_state->diffuse_power_factor, h_dirac_output_synthesis_state->diffuse_power_factor_q, 2 * hSpatParamRendCom->num_freq_bands ); - } - else - { - FOR( i = 0; i < hSpatParamRendCom->num_freq_bands; i++ ) - { - hDirACRend->h_output_synthesis_psd_state.direct_power_factor[i] = me2f( hDirACRend->h_output_synthesis_psd_state.direct_power_factor_fx[i], 31 - hDirACRend->h_output_synthesis_psd_state.direct_power_factor_q ); - hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor[i] = me2f( hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_fx[i], 31 - hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_q ); - } - } - } - else if ( hDirAC->hConfig->dec_param_estim == TRUE ) - { - if ( hDirACRend->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD ) - { - FOR( i = 0; i < hSpatParamRendCom->num_freq_bands; i++ ) - { - hDirACRend->h_output_synthesis_psd_state.direct_power_factor[i] = me2f( hDirACRend->h_output_synthesis_psd_state.direct_power_factor_fx[i], 31 - h_dirac_output_synthesis_state->direct_power_factor_q ); - hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor[i] = me2f( hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_fx[i], 31 - h_dirac_output_synthesis_state->diffuse_power_factor_q ); - } - fixedToFloat_arrL( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx, h_dirac_output_synthesis_state->cy_cross_dir_smooth, h_dirac_output_synthesis_state->q_cy_cross_dir_smooth, (num_channels_dir) *hSpatParamRendCom->num_freq_bands ); - } - else - { - FOR( i = 0; i < hSpatParamRendCom->num_freq_bands; i++ ) - { - hDirACRend->h_output_synthesis_psd_state.direct_power_factor[i] = fix_to_float( hDirACRend->h_output_synthesis_psd_state.direct_power_factor_fx[i], hDirACRend->h_output_synthesis_psd_state.direct_power_factor_q ); - hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor[i] = fix_to_float( hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_fx[i], hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_q ); - } + scale_sig32( hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_fx, i_mult( hDirACRend->num_outputs_diff, hDirACRend->h_output_synthesis_psd_params.max_band_decorr ), sub( Q26, hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_q ) ); } - } - - if ( h_dirac_output_synthesis_params->use_onset_filters && ( hDirAC->hConfig->dec_param_estim != TRUE && hDirACRend->synthesisConf != DIRAC_SYNTHESIS_GAIN_SHD ) ) - { - fixedToFloat_arrL( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx, h_dirac_output_synthesis_state->cy_auto_diff_smooth, h_dirac_output_synthesis_state->q_cy_auto_diff_smooth, hDirACRend->num_outputs_diff * hSpatParamRendCom->num_freq_bands ); - } - - if ( hDirAC->hConfig->dec_param_estim == TRUE && hDirACRend->synthesisConf != DIRAC_SYNTHESIS_GAIN_SHD ) - { - fixedToFloat_arrL( h_dirac_output_synthesis_state->cy_auto_dir_smooth_fx, h_dirac_output_synthesis_state->cy_auto_dir_smooth, h_dirac_output_synthesis_state->q_cy_auto_dir_smooth, num_channels_dir * hSpatParamRendCom->num_freq_bands ); - fixedToFloat_arrL( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx, h_dirac_output_synthesis_state->cy_cross_dir_smooth, h_dirac_output_synthesis_state->q_cy_cross_dir_smooth, num_channels_dir * hSpatParamRendCom->num_freq_bands ); - fixedToFloat_arrL( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx, h_dirac_output_synthesis_state->cy_auto_diff_smooth, h_dirac_output_synthesis_state->q_cy_auto_diff_smooth, num_channels_dir * hSpatParamRendCom->num_freq_bands ); - } - - if ( hDirAC->hConfig->dec_param_estim ) - { - fixedToFloat_arrL32( diffuseness_vector_fx, diffuseness_vector, q_diffuseness_vector, hSpatParamRendCom->num_freq_bands ); - } - - if ( hDirACRend->synthesisConf != DIRAC_SYNTHESIS_GAIN_SHD ) - { - fixedToFloat_arrL32( reference_power_smooth_fx, reference_power_smooth, q_reference_power_smooth, hSpatParamRendCom->num_freq_bands ); - } - ////////////////////////////////////////////////////////////////////////////////////// -#endif - -#ifdef IVAS_FLOAT_FIXED - ivas_dirac_dec_output_synthesis_get_interpolator_fx( &hDirACRend->h_output_synthesis_psd_params, hSpatParamRendCom->subframe_nbslots[subframe_idx] ); - fixedToFloat_arr( hDirACRend->h_output_synthesis_psd_params.interpolator_fx, hDirACRend->h_output_synthesis_psd_params.interpolator, Q15, hSpatParamRendCom->subframe_nbslots[subframe_idx] ); -#else - ivas_dirac_dec_output_synthesis_get_interpolator( &hDirACRend->h_output_synthesis_psd_params, hSpatParamRendCom->subframe_nbslots[subframe_idx] ); -#endif - - - if ( hDirACRend->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD ) - { -#ifdef IVAS_FLOAT_FIXED - Word16 size, size_ho; - size = hDirACRend->num_outputs_dir * hSpatParamRendCom->num_freq_bands; - size_ho = ( hodirac_flag ) ? size * DIRAC_HO_NUMSECTORS : size; - - hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth = Q26; - floatToFixed_arrL( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth, hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_fx, hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth, size_ho ); - - hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev = Q26; - floatToFixed_arrL( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev, hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev, size_ho ); - - hDirACRend->h_output_synthesis_psd_state.direct_power_factor_q = Q31; - floatToFixed_arrL( hDirACRend->h_output_synthesis_psd_state.direct_power_factor, hDirACRend->h_output_synthesis_psd_state.direct_power_factor_fx, hDirACRend->h_output_synthesis_psd_state.direct_power_factor_q, ( hodirac_flag ) ? hSpatParamRendCom->num_freq_bands * DIRAC_HO_NUMSECTORS : hSpatParamRendCom->num_freq_bands ); - hDirACRend->h_output_synthesis_psd_state.direct_responses_q = Q31; - floatToFixed_arrL( hDirACRend->h_output_synthesis_psd_state.direct_responses, hDirACRend->h_output_synthesis_psd_state.direct_responses_fx, hDirACRend->h_output_synthesis_psd_state.direct_responses_q, size_ho ); - - hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_q = Q31; - floatToFixed_arrL( hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor, hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_fx, hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_q, hDirACRend->h_output_synthesis_psd_params.max_band_decorr ); - - hDirACRend->diffuse_response_function_q = Q15; - floatToFixed_arr( hDirACRend->diffuse_response_function, hDirACRend->diffuse_response_function_fx, hDirACRend->diffuse_response_function_q, hDirACRend->num_outputs_dir ); - - hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth = Q26; - floatToFixed_arrL( hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth, hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_fx, hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth, hDirACRend->num_outputs_diff * hDirACRend->h_output_synthesis_psd_params.max_band_decorr ); - - hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth_prev = Q26; - floatToFixed_arrL( hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev, hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth_prev, hDirACRend->num_outputs_diff * hDirACRend->h_output_synthesis_psd_params.max_band_decorr ); - - FOR( slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[subframe_idx]; slot_idx++ ) - { - floatToFixed_arrL( &hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f[i_mult( i_mult( slot_idx, 2 ), - i_mult( hSpatParamRendCom->num_freq_bands, nchan_transport ) )], - hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx + - i_mult( i_mult( slot_idx, 2 ), i_mult( hSpatParamRendCom->num_freq_bands, nchan_transport ) ), - hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, - 2 * nchan_transport * hSpatParamRendCom->num_freq_bands ); - floatToFixed_arrL( &hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f[i_mult( i_mult( slot_idx, 2 ), - i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_diff ) )], - hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_fx + - i_mult( i_mult( slot_idx, 2 ), i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_diff ) ), - hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q, - 2 * hDirACRend->num_outputs_diff * hSpatParamRendCom->num_freq_bands ); - } - - floatToFixed_arrL( p_onset_filter, p_onset_filter_fx, Q30, hSpatParamRendCom->num_freq_bands ); // Q30 - floatToFixed_arrL( diffuseness_vector, diffuseness_vector_fx, Q30, hSpatParamRendCom->num_freq_bands ); // Q30 - hDirACRend->h_output_synthesis_psd_params.diffuse_compensation_factor_fx = floatToFixed( hDirACRend->h_output_synthesis_psd_params.diffuse_compensation_factor, Q27 ); // Q27 - - hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_q = Q26; - floatToFixed_arrL( hDirACRend->h_output_synthesis_psd_state.gains_dir_prev, hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_fx, hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_q, size ); - - hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_q = Q26; - floatToFixed_arrL( hDirACRend->h_output_synthesis_psd_state.gains_diff_prev, hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_fx, hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_q, hDirACRend->num_outputs_diff * hDirACRend->h_output_synthesis_psd_params.max_band_decorr ); -#endif - -#ifdef IVAS_FLOAT_FIXED ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, hSpatParamRendCom, @@ -4854,29 +4757,6 @@ void ivas_dirac_dec_render_sf_fx( hDirAC->hConfig->dec_param_estim, &hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev, &hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth_prev ); -#else - ivas_dirac_dec_output_synthesis_process_subframe_gain_shd( Cldfb_RealBuffer, - Cldfb_ImagBuffer, - hSpatParamRendCom, - hDirACRend, - nchan_transport, - hSpatParamRendCom->subframe_nbslots[subframe_idx], - p_onset_filter, - diffuseness_vector, - hodirac_flag, - hDirAC->hConfig->dec_param_estim ); -#endif - -#ifdef IVAS_FLOAT_FIXED - fixedToFloat_arrL( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_fx, hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth, hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth, size_ho ); - fixedToFloat_arrL( hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_fx, hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth, hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth, hDirACRend->num_outputs_diff * hDirACRend->h_output_synthesis_psd_params.max_band_decorr ); - fixedToFloat_arrL( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev, hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev, size_ho ); - fixedToFloat_arrL( hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev, hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth_prev, hDirACRend->num_outputs_diff * hDirACRend->h_output_synthesis_psd_params.max_band_decorr ); - - hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_q = hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev; - hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_q = hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth_prev; - fixedToFloat_arrL( hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_fx, hDirACRend->h_output_synthesis_psd_state.gains_dir_prev, hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_q, size ); - fixedToFloat_arrL( hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_fx, hDirACRend->h_output_synthesis_psd_state.gains_diff_prev, hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_q, hDirACRend->num_outputs_diff * hDirACRend->h_output_synthesis_psd_params.max_band_decorr ); IF( hDirACRend->hOutSetup.is_loudspeaker_setup && hDirACRend->hoa_decoder != NULL ) { @@ -4900,24 +4780,17 @@ void ivas_dirac_dec_render_sf_fx( } } } -#endif } - else + ELSE { -#ifdef IVAS_FLOAT_FIXED - Word16 size, size_ho, q_Cldfb; - size = hDirACRend->num_outputs_dir * hSpatParamRendCom->num_freq_bands; - size_ho = ( hodirac_flag ) ? size * DIRAC_HO_NUMSECTORS : size; -#endif /* Determine encoding quality based additional smoothing factor */ -#ifdef IVAS_FLOAT_FIXED Word32 qualityBasedSmFactor_fx = ONE_IN_Q31; move32(); + Word16 q_Cldfb = 0; + move16(); IF( st_ivas->hMasa != NULL ) { - st_ivas->hMasa->data.dir_decode_quality_fx = float_to_fix16( st_ivas->hMasa->data.dir_decode_quality, Q15 ); - IF( EQ_16( st_ivas->hMasa->data.dir_decode_quality_fx, MAX_16 ) ) { qualityBasedSmFactor_fx = MAX_32; @@ -4927,116 +4800,115 @@ void ivas_dirac_dec_render_sf_fx( qualityBasedSmFactor_fx = L_mult( st_ivas->hMasa->data.dir_decode_quality_fx, st_ivas->hMasa->data.dir_decode_quality_fx ); // (Q15, Q15) -> Q31 } } -#else - float qualityBasedSmFactor = 1.0f; - if ( st_ivas->hMasa != NULL ) + IF( NE_16( hDirACRend->h_output_synthesis_psd_state.direct_power_factor_q, Q31 ) ) { - qualityBasedSmFactor = st_ivas->hMasa->data.dir_decode_quality; - qualityBasedSmFactor *= qualityBasedSmFactor; + Scale_sig32( hDirACRend->h_output_synthesis_psd_state.direct_power_factor_fx, hSpatParamRendCom->num_freq_bands, sub( Q31, hDirACRend->h_output_synthesis_psd_state.direct_power_factor_q ) ); + } + IF( NE_16( hDirACRend->h_output_synthesis_psd_state.direct_responses_q, Q31 ) ) + { + Scale_sig32( hDirACRend->h_output_synthesis_psd_state.direct_responses_fx, size, sub( Q31, hDirACRend->h_output_synthesis_psd_state.direct_responses_q ) ); + } + IF( NE_16( hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_q, Q31 ) ) + { + Scale_sig32( hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_fx, hSpatParamRendCom->num_freq_bands, sub( Q31, hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_q ) ); + } + IF( NE_16( q_diffuseness_vector, Q31 ) ) + { + Scale_sig32( diffuseness_vector_fx, hSpatParamRendCom->num_freq_bands, sub( Q31, q_diffuseness_vector ) ); + } + IF( NE_16( hDirACRend->h_output_synthesis_psd_state.direct_responses_square_q, Q31 ) ) + { + Scale_sig32( hDirACRend->h_output_synthesis_psd_state.direct_responses_square_fx, i_mult( hDirACRend->num_outputs_dir, hSpatParamRendCom->num_freq_bands ), sub( Q31, hDirACRend->h_output_synthesis_psd_state.direct_responses_square_q ) ); + } + IF( NE_16( hDirACRend->h_output_synthesis_psd_state.diffuse_responses_square_q, Q31 ) ) + { + scale_sig32( hDirACRend->h_output_synthesis_psd_state.diffuse_responses_square_fx, hDirACRend->num_outputs_dir, sub( Q31, hDirACRend->h_output_synthesis_psd_state.diffuse_responses_square_q ) ); } -#endif - -#ifdef IVAS_FLOAT_FIXED - hDirACRend->h_output_synthesis_psd_state.direct_power_factor_q = Q31; - floatToFixed_arrL( hDirACRend->h_output_synthesis_psd_state.direct_power_factor, hDirACRend->h_output_synthesis_psd_state.direct_power_factor_fx, hDirACRend->h_output_synthesis_psd_state.direct_power_factor_q, hSpatParamRendCom->num_freq_bands ); - - hDirACRend->h_output_synthesis_psd_state.direct_responses_q = Q31; - floatToFixed_arrL( hDirACRend->h_output_synthesis_psd_state.direct_responses, hDirACRend->h_output_synthesis_psd_state.direct_responses_fx, hDirACRend->h_output_synthesis_psd_state.direct_responses_q, hDirACRend->num_outputs_dir * hSpatParamRendCom->num_freq_bands ); - - hDirACRend->h_output_synthesis_psd_state.direct_responses_square_q = Q31; - floatToFixed_arrL( hDirACRend->h_output_synthesis_psd_state.direct_responses_square, hDirACRend->h_output_synthesis_psd_state.direct_responses_square_fx, hDirACRend->h_output_synthesis_psd_state.direct_responses_square_q, hDirACRend->num_outputs_dir * hSpatParamRendCom->num_freq_bands ); - - hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_q = Q31; - floatToFixed_arrL( hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor, hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_fx, hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_q, hSpatParamRendCom->num_freq_bands ); - - hDirACRend->h_output_synthesis_psd_state.diffuse_responses_square_q = Q31; - floatToFixed_arrL( hDirACRend->h_output_synthesis_psd_state.diffuse_responses_square, hDirACRend->h_output_synthesis_psd_state.diffuse_responses_square_fx, hDirACRend->h_output_synthesis_psd_state.diffuse_responses_square_q, hDirACRend->num_outputs_dir ); - - floatToFixed_arrL( diffuseness_vector, diffuseness_vector_fx, Q31, hSpatParamRendCom->num_freq_bands ); // Q31 - - q_reference_power_smooth = L_get_q_buf( reference_power_smooth, hSpatParamRendCom->num_freq_bands ); - q_reference_power_smooth = s_min( q_reference_power_smooth, L_get_q_buf( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev, hSpatParamRendCom->num_freq_bands ) ); - floatToFixed_arrL( reference_power_smooth, reference_power_smooth_fx, q_reference_power_smooth, hSpatParamRendCom->num_freq_bands ); - floatToFixed_arrL( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev, hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_fx, q_reference_power_smooth, hSpatParamRendCom->num_freq_bands ); - - hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth = L_get_q_buf1( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth, size_ho ); - floatToFixed_arrL( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth, hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_fx, hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth, size_ho ); - - hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth = L_get_q_buf1( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth, size_ho ); - floatToFixed_arrL( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth, hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_fx, hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth, size_ho ); - - hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth = L_get_q_buf1( hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth, hSpatParamRendCom->num_freq_bands * hDirACRend->hOutSetup.nchan_out_woLFE ); - floatToFixed_arrL( hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth, hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_fx, hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth, hSpatParamRendCom->num_freq_bands * hDirACRend->hOutSetup.nchan_out_woLFE ); - - hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth_prev = L_get_q_buf1( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_prev, size_ho ); - floatToFixed_arrL( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_prev, hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth_prev, size_ho ); - - hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev = L_get_q_buf1( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev, size_ho ); - floatToFixed_arrL( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev, hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev, size_ho ); - hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth_prev = L_get_q_buf1( hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev, hSpatParamRendCom->num_freq_bands * hDirACRend->hOutSetup.nchan_out_woLFE ); - floatToFixed_arrL( hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev, hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth_prev, hSpatParamRendCom->num_freq_bands * hDirACRend->hOutSetup.nchan_out_woLFE ); + exp = L_norm_arr( reference_power_smooth_fx, hSpatParamRendCom->num_freq_bands ); + scale_sig32( reference_power_smooth_fx, hSpatParamRendCom->num_freq_bands, exp ); + q_reference_power_smooth = add( q_reference_power_smooth, exp ); + IF( LT_16( q_reference_power_smooth, hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q ) ) + { + scale_sig32( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_fx, hSpatParamRendCom->num_freq_bands, sub( q_reference_power_smooth, hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q ) ); + hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q = q_reference_power_smooth; + move16(); + } + ELSE + { + scale_sig32( reference_power_smooth_fx, hSpatParamRendCom->num_freq_bands, sub( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q, q_reference_power_smooth ) ); + q_reference_power_smooth = hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q; + move16(); + } IF( hDirACRend->masa_stereo_type_detect != NULL ) { - hDirACRend->masa_stereo_type_detect->q_target_power_y_smooth = L_get_q( hDirACRend->masa_stereo_type_detect->target_power_y_smooth ); - hDirACRend->masa_stereo_type_detect->target_power_y_smooth_fx = floatToFixed( hDirACRend->masa_stereo_type_detect->target_power_y_smooth, hDirACRend->masa_stereo_type_detect->q_target_power_y_smooth ); - - hDirACRend->masa_stereo_type_detect->q_subtract_power_y = s_min( L_get_q( hDirACRend->masa_stereo_type_detect->subtract_power_y ), - L_get_q( hDirACRend->masa_stereo_type_detect->subtract_power_y_smooth ) ); - hDirACRend->masa_stereo_type_detect->subtract_power_y_smooth_fx = floatToFixed( hDirACRend->masa_stereo_type_detect->subtract_power_y_smooth, hDirACRend->masa_stereo_type_detect->q_subtract_power_y ); - hDirACRend->masa_stereo_type_detect->subtract_power_y_fx = floatToFixed( hDirACRend->masa_stereo_type_detect->subtract_power_y, hDirACRend->masa_stereo_type_detect->q_subtract_power_y ); + IF( LT_16( hDirACRend->masa_stereo_type_detect->q_subtract_power_y, hDirACRend->masa_stereo_type_detect->q_subtract_power_y_smooth ) ) + { + hDirACRend->masa_stereo_type_detect->subtract_power_y_smooth_fx = L_shr( hDirACRend->masa_stereo_type_detect->subtract_power_y_smooth_fx, sub( hDirACRend->masa_stereo_type_detect->q_subtract_power_y_smooth, hDirACRend->masa_stereo_type_detect->q_subtract_power_y ) ); + hDirACRend->masa_stereo_type_detect->q_subtract_power_y_smooth = hDirACRend->masa_stereo_type_detect->q_subtract_power_y; + move16(); + } + ELSE + { + hDirACRend->masa_stereo_type_detect->subtract_power_y_fx = L_shr( hDirACRend->masa_stereo_type_detect->subtract_power_y_fx, sub( hDirACRend->masa_stereo_type_detect->q_subtract_power_y, hDirACRend->masa_stereo_type_detect->q_subtract_power_y_smooth ) ); + hDirACRend->masa_stereo_type_detect->q_subtract_power_y = hDirACRend->masa_stereo_type_detect->q_subtract_power_y_smooth; + move16(); + } } - hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q = L_get_q_buf1( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth, hDirACRend->num_protos_dir * hSpatParamRendCom->num_freq_bands ); - hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q = s_min( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, - L_get_q_buf1( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev, hDirACRend->num_protos_dir * hSpatParamRendCom->num_freq_bands ) ); - floatToFixed_arrL( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, hDirACRend->num_protos_dir * hSpatParamRendCom->num_freq_bands ); - floatToFixed_arrL( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, hDirACRend->num_protos_dir * hSpatParamRendCom->num_freq_bands ); + exp = getScaleFactor32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx, proto_power_smooth_len ); + scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx, proto_power_smooth_len, exp ); + hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q = add( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, exp ); - hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_q = L_get_q_buf1( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth, hDirACRend->h_output_synthesis_psd_params.max_band_decorr * hDirACRend->hOutSetup.nchan_out_woLFE ); - IF( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev != 0 ) + IF( LT_16( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q ) ) { - hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_q = s_min( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_q, - L_get_q_buf1( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev, hDirACRend->h_output_synthesis_psd_params.max_band_decorr * hDirACRend->hOutSetup.nchan_out_woLFE ) ); + scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_fx, i_mult( hDirACRend->num_protos_dir, hSpatParamRendCom->num_freq_bands ), sub( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q ) ); + hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q = hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q; + move16(); } - floatToFixed_arrL( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth, hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_q, hDirACRend->h_output_synthesis_psd_params.max_band_decorr * hDirACRend->hOutSetup.nchan_out_woLFE ); - IF( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev != 0 ) + ELSE { - floatToFixed_arrL( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev, hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_q, hDirACRend->h_output_synthesis_psd_params.max_band_decorr * hDirACRend->hOutSetup.nchan_out_woLFE ); + scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx, i_mult( hDirACRend->num_protos_dir, hSpatParamRendCom->num_freq_bands ), sub( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q ) ); + hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q = hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q; + move16(); } - hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_q = Q26; - hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_q = Q26; - floatToFixed_arrL( hDirACRend->h_output_synthesis_psd_state.gains_dir_prev, hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_fx, hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_q, size ); - floatToFixed_arrL( hDirACRend->h_output_synthesis_psd_state.gains_diff_prev, hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_fx, hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_q, hSpatParamRendCom->num_freq_bands * hDirACRend->hOutSetup.nchan_out_woLFE ); + exp = getScaleFactor32( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_fx, i_mult( hDirACRend->h_output_synthesis_psd_params.max_band_decorr, hDirACRend->hOutSetup.nchan_out_woLFE ) ); + scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_fx, i_mult( hDirACRend->h_output_synthesis_psd_params.max_band_decorr, hDirACRend->hOutSetup.nchan_out_woLFE ), exp ); + hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_q = add( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_q, exp ); + IF( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_fx != 0 ) + { + IF( LT_16( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_q, hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_q ) ) + { + scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_fx, i_mult( hDirACRend->h_output_synthesis_psd_params.max_band_decorr, hDirACRend->hOutSetup.nchan_out_woLFE ), sub( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_q, hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_q ) ); + hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_q = hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_q; + move16(); + } + ELSE + { + scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_fx, i_mult( hDirACRend->h_output_synthesis_psd_params.max_band_decorr, hDirACRend->hOutSetup.nchan_out_woLFE ), sub( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_q, hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_q ) ); + hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_q = hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_q; + move16(); + } + } - FOR( slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[subframe_idx]; slot_idx++ ) + IF( NE_16( hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_q, Q26 ) ) + { + scale_sig32( hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_fx, size, sub( Q26, hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_q ) ); + } + IF( NE_16( hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_q, Q26 ) ) { - floatToFixed_arrL( &hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f[i_mult( i_mult( slot_idx, 2 ), - i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_protos_dir ) )], - hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx + - i_mult( i_mult( slot_idx, 2 ), i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_protos_dir ) ), - hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, - 2 * hDirACRend->num_protos_dir * hSpatParamRendCom->num_freq_bands ); + scale_sig32( hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_fx, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->hOutSetup.nchan_out_woLFE ), sub( Q26, hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_q ) ); } IF( hDirACRend->proto_signal_decorr_on ) { + Scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_fx, hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_len, sub( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q ) ); hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q = hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q; - FOR( slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[subframe_idx]; slot_idx++ ) - { - floatToFixed_arrL( &hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f[i_mult( i_mult( slot_idx, 2 ), - i_mult( hDirACRend->h_output_synthesis_psd_params.max_band_decorr, hDirACRend->hOutSetup.nchan_out_woLFE ) )], - hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_fx + - i_mult( i_mult( slot_idx, 2 ), i_mult( hDirACRend->h_output_synthesis_psd_params.max_band_decorr, hDirACRend->hOutSetup.nchan_out_woLFE ) ), - hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q, - 2 * hDirACRend->hOutSetup.nchan_out_woLFE * hDirACRend->h_output_synthesis_psd_params.max_band_decorr ); - } + move16(); } -#endif - -#ifdef IVAS_FLOAT_FIXED + ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, hSpatParamRendCom, @@ -5048,47 +4920,6 @@ void ivas_dirac_dec_render_sf_fx( qualityBasedSmFactor_fx, hDirAC->hConfig->enc_param_start_band, &q_Cldfb ); -#else - ivas_dirac_dec_output_synthesis_process_subframe_psd_ls( Cldfb_RealBuffer, - Cldfb_ImagBuffer, - hSpatParamRendCom, - hDirACRend, - hSpatParamRendCom->subframe_nbslots[subframe_idx], - diffuseness_vector, - reference_power_smooth, - qualityBasedSmFactor, - hDirAC->hConfig->enc_param_start_band ); -#endif - -#ifdef IVAS_FLOAT_FIXED - fixedToFloat_arrL( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev, q_reference_power_smooth, hSpatParamRendCom->num_freq_bands ); - - IF( hDirACRend->masa_stereo_type_detect != NULL ) - { - hDirACRend->masa_stereo_type_detect->subtract_target_ratio_db = fixedToFloat( hDirACRend->masa_stereo_type_detect->subtract_target_ratio_db_fx, Q21 ); - - hDirACRend->masa_stereo_type_detect->target_power_y_smooth = fixedToFloat( hDirACRend->masa_stereo_type_detect->target_power_y_smooth_fx, hDirACRend->masa_stereo_type_detect->q_target_power_y_smooth ); - hDirACRend->masa_stereo_type_detect->subtract_power_y_smooth = fixedToFloat( hDirACRend->masa_stereo_type_detect->subtract_power_y_smooth_fx, hDirACRend->masa_stereo_type_detect->q_subtract_power_y ); - hDirACRend->masa_stereo_type_detect->subtract_power_y = fixedToFloat( hDirACRend->masa_stereo_type_detect->subtract_power_y_fx, hDirACRend->masa_stereo_type_detect->q_subtract_power_y ); - } - - fixedToFloat_arrL( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_fx, hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth, hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth, size ); - fixedToFloat_arrL( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_fx, hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth, hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth, size_ho ); - fixedToFloat_arrL( hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_fx, hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth, hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth, size ); - fixedToFloat_arrL( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_prev, hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth_prev, size ); - fixedToFloat_arrL( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev, hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev, size_ho ); - fixedToFloat_arrL( hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev, hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth_prev, hSpatParamRendCom->num_freq_bands * hDirACRend->hOutSetup.nchan_out_woLFE ); - - fixedToFloat_arrL( hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_fx, hDirACRend->h_output_synthesis_psd_state.gains_dir_prev, hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_q, size ); - fixedToFloat_arrL( hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_fx, hDirACRend->h_output_synthesis_psd_state.gains_diff_prev, hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_q, hSpatParamRendCom->num_freq_bands * hDirACRend->hOutSetup.nchan_out_woLFE ); - - fixedToFloat_arrL( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, hDirACRend->num_protos_dir * hSpatParamRendCom->num_freq_bands ); - fixedToFloat_arrL( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q, hDirACRend->num_protos_dir * hSpatParamRendCom->num_freq_bands ); - fixedToFloat_arrL( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth, hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_q, hDirACRend->h_output_synthesis_psd_params.max_band_decorr * hDirACRend->hOutSetup.nchan_out_woLFE ); - IF( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev != 0 ) - { - fixedToFloat_arrL( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev, hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_q, hDirACRend->h_output_synthesis_psd_params.max_band_decorr * hDirACRend->hOutSetup.nchan_out_woLFE ); - } FOR( ch = 0; ch < hDirACRend->hOutSetup.nchan_out_woLFE; ch++ ) { @@ -5098,7 +4929,6 @@ void ivas_dirac_dec_render_sf_fx( scale_sig32( Cldfb_ImagBuffer_fx[ch][slot_idx], hSpatParamRendCom->num_freq_bands, sub( Q6, q_Cldfb ) ); } } -#endif } /*-----------------------------------------------------------------* @@ -5106,58 +4936,15 @@ void ivas_dirac_dec_render_sf_fx( *-----------------------------------------------------------------*/ index_slot = slot_idx_start_cldfb_synth; + move16(); -#ifdef IVAS_FLOAT_FIXED - //////////////////////////////////////////////// FLOAT TO FIXED ///////////////////////////////////////////// -#ifndef MSAN_FIX - Word32 output_buf_fx[MAX_OUTPUT_CHANNELS][L_FRAME48k]; -#endif // MSAN_FIX - if (st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM) + IF( L_or( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ), EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) ) { - // Float to fixed -#ifndef MSAN_FIX - for (i = 0; i < st_ivas->hDecoderConfig->nchan_out; i++) - { - floatToFixed_arrL(output_f[i], output_buf_fx[i], Q11, L_FRAME48k); - } -#endif - } - else if (st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT) - { - /* output_f not being used here. */ - } - else - { - Word16 outchannels = add(hDirACRend->hOutSetup.nchan_out_woLFE, hDirACRend->hOutSetup.num_lfe); - - IF(hDirACRend->hOutSetup.separateChannelEnabled && (hDirACRend->hOutSetup.output_config == IVAS_AUDIO_CONFIG_5_1 || - hDirACRend->hOutSetup.output_config == IVAS_AUDIO_CONFIG_7_1 || - hDirACRend->hOutSetup.output_config == IVAS_AUDIO_CONFIG_5_1_2 || - hDirACRend->hOutSetup.output_config == IVAS_AUDIO_CONFIG_5_1_4 || - hDirACRend->hOutSetup.output_config == IVAS_AUDIO_CONFIG_7_1_4 || - (hDirACRend->hOutSetup.output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM && st_ivas->hLsSetupCustom->separate_ch_found))) - { - outchannels = add(outchannels, 1); - } - -#ifndef MSAN_FIX - for (i = 0; i < outchannels; i++) - { - floatToFixed_arrL(output_f[i], output_buf_fx[i], Q11, L_FRAME48k); - } -#endif - } - ////////////////////////////////////////////////////////////////////////////////////////////////////////////// -#endif - -#ifdef IVAS_FLOAT_FIXED - IF( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) - { - /* render objects in combined format onto the CICP19 channels for BINAURAL_ROOM_IR */ - IF ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_SBA_MODE_DISC && st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) + /* render objects in combined format onto the CICP19 channels for BINAURAL_ROOM_IR */ + IF( L_and( L_and( EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ), EQ_16( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) ), EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) ) { Word16 in_ch; - FOR ( in_ch = 0; in_ch < st_ivas->nchan_ism; in_ch++ ) + FOR( in_ch = 0; in_ch < st_ivas->nchan_ism; in_ch++ ) { Word16 j, k, j2, l; Word16 num_objects, nchan_out_woLFE, lfe_index; @@ -5187,7 +4974,7 @@ void ivas_dirac_dec_render_sf_fx( FOR( i = 0; i < num_objects; i++ ) { /* Combined rotation: rotate the object positions depending the head and external orientations */ - IF( st_ivas->hCombinedOrientationData != NULL && st_ivas->hCombinedOrientationData->enableCombinedOrientation[0] == 1 ) + IF( st_ivas->hCombinedOrientationData != NULL && EQ_16( st_ivas->hCombinedOrientationData->enableCombinedOrientation[0], 1 ) ) { Word16 az_q0 = extract_l( L_shr( st_ivas->hIsmMetaData[i]->azimuth_fx, Q22 ) ); Word16 el_q0 = extract_l( L_shr( st_ivas->hIsmMetaData[i]->elevation_fx, Q22 ) ); @@ -5208,19 +4995,31 @@ void ivas_dirac_dec_render_sf_fx( move16(); for ( j = 0, j2 = 0; j < nchan_out_woLFE; j++, j2++ ) { - IF( ( st_ivas->hIntSetup.num_lfe > 0 ) && ( EQ_16( st_ivas->hIntSetup.index_lfe[lfe_index], j ) ) ) + IF( L_and( GT_16( st_ivas->hIntSetup.num_lfe, 0 ), ( EQ_16( st_ivas->hIntSetup.index_lfe[lfe_index], j ) ) ) ) { - ( lfe_index < ( st_ivas->hIntSetup.num_lfe - 1 ) ) ? ( lfe_index++, j2++ ) : j2++; + IF( LT_16( lfe_index, sub( st_ivas->hIntSetup.num_lfe, 1 ) ) ) + { + lfe_index++; + j2++; + } + ELSE + { + j2++; + } } gain_fx = st_ivas->hIsmRendererData->gains_fx[i][j]; + move32(); prev_gain_fx = st_ivas->hIsmRendererData->prev_gains_fx[i][j]; - IF( L_abs( gain_fx ) > 0 || L_abs( prev_gain_fx ) > 0 ) + move32(); + IF( L_or( GT_32( L_abs( gain_fx ), 0 ), GT_32( L_abs( prev_gain_fx ), 0 ) ) ) { Word32 *tc_re_fx, *tc_im_fx; Word16 *w1_fx, w2_fx; w1_fx = &st_ivas->hIsmRendererData->interpolator_fx[interp_offset]; - tc_re_fx = pppQMfFrame_ts_re_fx[nchan_transport + i][0]; - tc_im_fx = pppQMfFrame_ts_im_fx[nchan_transport + i][0]; + tc_re_fx = pppQMfFrame_ts_re_fx[add( nchan_transport, i )][0]; + move32(); + tc_im_fx = pppQMfFrame_ts_im_fx[add( nchan_transport, i )][0]; + move32(); FOR( k = 0; k < n_slots_to_render; k++ ) { Word32 g_fx; @@ -5230,10 +5029,10 @@ void ivas_dirac_dec_render_sf_fx( { Word32 tmp; tmp = Mpy_32_32( g_fx, *tc_re_fx ); - Cldfb_RealBuffer_fx[j2][0][k * hSpatParamRendCom->num_freq_bands + l] = L_add( Cldfb_RealBuffer_fx[j2][0][k * hSpatParamRendCom->num_freq_bands + l], tmp ); + Cldfb_RealBuffer_fx[j2][0][add( i_mult( k, hSpatParamRendCom->num_freq_bands ), l )] = L_add( Cldfb_RealBuffer_fx[j2][0][add( i_mult( k, hSpatParamRendCom->num_freq_bands ), l )], tmp ); tc_re_fx++; tmp = Mpy_32_32( g_fx, *tc_im_fx ); - Cldfb_ImagBuffer_fx[j2][0][k * hSpatParamRendCom->num_freq_bands + l] = L_add( Cldfb_ImagBuffer_fx[j2][0][k * hSpatParamRendCom->num_freq_bands + l], tmp ); + Cldfb_ImagBuffer_fx[j2][0][add( i_mult( k, hSpatParamRendCom->num_freq_bands ), l )] = L_add( Cldfb_ImagBuffer_fx[j2][0][add( i_mult( k, hSpatParamRendCom->num_freq_bands ), l )], tmp ); tc_re_fx++; } w1_fx += hSpatParamRendCom->num_freq_bands; @@ -5243,6 +5042,7 @@ void ivas_dirac_dec_render_sf_fx( IF( st_ivas->hCombinedOrientationData != NULL && st_ivas->hCombinedOrientationData->enableCombinedOrientation[0] == 1 ) { st_ivas->hIsmRendererData->prev_gains_fx[i][j] = gain_fx; + move32(); } } } @@ -5251,6 +5051,7 @@ void ivas_dirac_dec_render_sf_fx( /* Perform binaural rendering */ Word16 input_q = Q6; + move16(); IF( st_ivas->hCombinedOrientationData != NULL ) { @@ -5274,59 +5075,50 @@ void ivas_dirac_dec_render_sf_fx( } } - FOR ( Word16 idx1 = 0; idx1 < BINAURAL_CHANNELS; idx1++ ) - { - FOR ( Word16 idx2 = 0; idx2 < MAX_PARAM_SPATIAL_SUBFRAMES; idx2++ ) - { - Scale_sig32(Cldfb_RealBuffer_Binaural_fx[idx1][idx2], CLDFB_NO_CHANNELS_MAX, Q6 - input_q ); - Scale_sig32(Cldfb_ImagBuffer_Binaural_fx[idx1][idx2], CLDFB_NO_CHANNELS_MAX, Q6 - input_q ); - } - } + Scale_sig32( Cldfb_RealBuffer_Binaural_fx[0][0], i_mult( BINAURAL_CHANNELS, i_mult( MAX_PARAM_SPATIAL_SUBFRAMES, CLDFB_NO_CHANNELS_MAX ) ), sub( Q6, input_q ) ); + Scale_sig32( Cldfb_ImagBuffer_Binaural_fx[0][0], i_mult( BINAURAL_CHANNELS, i_mult( MAX_PARAM_SPATIAL_SUBFRAMES, CLDFB_NO_CHANNELS_MAX ) ), sub( Q6, input_q ) ); /* Inverse CLDFB*/ - FOR ( ch = 0; ch < st_ivas->hDecoderConfig->nchan_out; ch++ ) + FOR( ch = 0; ch < st_ivas->hDecoderConfig->nchan_out; ch++ ) { /* open CLDFB buffer up to CLDFB_NO_CHANNELS_MAX bands for 48kHz */ -#if 1 // TODOD: remove float to fixed - st_ivas->cldfbSynDec[ch]->Q_cldfb_state = Q_factor_arrL( st_ivas->cldfbSynDec[ch]->cldfb_state, st_ivas->cldfbSynDec[ch]->p_filter_length ); - floatToFixed_arrL( st_ivas->cldfbSynDec[ch]->cldfb_state, st_ivas->cldfbSynDec[ch]->cldfb_state_fx, st_ivas->cldfbSynDec[ch]->Q_cldfb_state, st_ivas->cldfbSynDec[ch]->p_filter_length ); -#endif - Word32 *synth_fx = &output_buf_fx[ch][index_slot * hSpatParamRendCom->num_freq_bands]; - + Word32 *synth_fx = &output_buf_fx[ch][i_mult( index_slot, hSpatParamRendCom->num_freq_bands )]; Word32 *RealBuffer_fx[MAX_PARAM_SPATIAL_SUBFRAMES]; Word32 *ImagBuffer_fx[MAX_PARAM_SPATIAL_SUBFRAMES]; - FOR ( i = 0; i < hSpatParamRendCom->subframe_nbslots[subframe_idx]; i++ ) + FOR( i = 0; i < hSpatParamRendCom->subframe_nbslots[subframe_idx]; i++ ) { RealBuffer_fx[i] = Cldfb_RealBuffer_Binaural_fx[ch][i]; + move32(); ImagBuffer_fx[i] = Cldfb_ImagBuffer_Binaural_fx[ch][i]; + move32(); } - scale_sig32( st_ivas->cldfbSynDec[ch]->cldfb_state_fx, st_ivas->cldfbSynDec[ch]->p_filter_length, sub( Q6 - 1, st_ivas->cldfbSynDec[ch]->Q_cldfb_state ) ); - st_ivas->cldfbSynDec[ch]->Q_cldfb_state = Q6 - 1; + scale_sig32( st_ivas->cldfbSynDec[ch]->cldfb_state_fx, st_ivas->cldfbSynDec[ch]->p_filter_length, sub( sub( Q6, 1 ), st_ivas->cldfbSynDec[ch]->Q_cldfb_state ) ); + st_ivas->cldfbSynDec[ch]->Q_cldfb_state = sub( Q6, 1 ); move16(); - cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, synth_fx, hSpatParamRendCom->num_freq_bands * hSpatParamRendCom->subframe_nbslots[subframe_idx], st_ivas->cldfbSynDec[ch] ); + cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, synth_fx, i_mult( hSpatParamRendCom->num_freq_bands, hSpatParamRendCom->subframe_nbslots[subframe_idx] ), st_ivas->cldfbSynDec[ch] ); - Word16 no_col = st_ivas->cldfbSynDec[ch]->no_col, no_channels = st_ivas->cldfbSynDec[ch]->no_channels; - Word16 samplesToProcess = hSpatParamRendCom->num_freq_bands * hSpatParamRendCom->subframe_nbslots[subframe_idx]; + Word16 no_col = st_ivas->cldfbSynDec[ch]->no_col; + move16(); + Word16 no_channels = st_ivas->cldfbSynDec[ch]->no_channels; + move16(); + Word16 samplesToProcess = i_mult( hSpatParamRendCom->num_freq_bands, hSpatParamRendCom->subframe_nbslots[subframe_idx] ); + move16(); IF( GT_16( samplesToProcess, -1 ) ) { - no_col = s_min( no_col, ( samplesToProcess + st_ivas->cldfbSynDec[ch]->no_channels - 1 ) / st_ivas->cldfbSynDec[ch]->no_channels ); + no_col = s_min( no_col, ( add( samplesToProcess, sub( st_ivas->cldfbSynDec[ch]->no_channels, 1 ) ) ) / st_ivas->cldfbSynDec[ch]->no_channels ); } Word16 synth_len = imult1616( no_col, no_channels ); - scale_sig32( synth_fx, synth_len, Q11 - ( Q6 - 1 ) ); - -#if 1 // TODOD: remove Fixed to float - fixedToFloat_arrL( st_ivas->cldfbSynDec[ch]->cldfb_state_fx, st_ivas->cldfbSynDec[ch]->cldfb_state, st_ivas->cldfbSynDec[ch]->Q_cldfb_state, st_ivas->cldfbSynDec[ch]->p_filter_length ); -#endif + scale_sig32( synth_fx, synth_len, sub( Q11, sub( Q6, 1 ) ) ); } } - ELSE IF( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) + ELSE IF( L_or( EQ_16( st_ivas->ivas_format, SBA_FORMAT ), EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) ) { - for ( ch = 0; ch < hDirACRend->hOutSetup.nchan_out_woLFE; ch++ ) + FOR( ch = 0; ch < hDirACRend->hOutSetup.nchan_out_woLFE; ch++ ) { - for ( slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[subframe_idx]; slot_idx++ ) + FOR( slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[subframe_idx]; slot_idx++ ) { Copy32( Cldfb_RealBuffer_fx[ch][slot_idx], pppQMfFrame_ts_re_fx[ch][slot_idx], hSpatParamRendCom->num_freq_bands ); // Q6 Copy32( Cldfb_ImagBuffer_fx[ch][slot_idx], pppQMfFrame_ts_im_fx[ch][slot_idx], hSpatParamRendCom->num_freq_bands ); // Q6 @@ -5346,17 +5138,17 @@ void ivas_dirac_dec_render_sf_fx( outchannels = add( hDirACRend->hOutSetup.nchan_out_woLFE, hDirACRend->hOutSetup.num_lfe ); - IF ( hDirACRend->hOutSetup.separateChannelEnabled && ( hDirACRend->hOutSetup.output_config == IVAS_AUDIO_CONFIG_5_1 || - hDirACRend->hOutSetup.output_config == IVAS_AUDIO_CONFIG_7_1 || - hDirACRend->hOutSetup.output_config == IVAS_AUDIO_CONFIG_5_1_2 || - hDirACRend->hOutSetup.output_config == IVAS_AUDIO_CONFIG_5_1_4 || - hDirACRend->hOutSetup.output_config == IVAS_AUDIO_CONFIG_7_1_4 || - ( hDirACRend->hOutSetup.output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM && st_ivas->hLsSetupCustom->separate_ch_found ) ) ) + IF( hDirACRend->hOutSetup.separateChannelEnabled && ( EQ_16( hDirACRend->hOutSetup.output_config, IVAS_AUDIO_CONFIG_5_1 ) || + EQ_16( hDirACRend->hOutSetup.output_config, IVAS_AUDIO_CONFIG_7_1 ) || + EQ_16( hDirACRend->hOutSetup.output_config, IVAS_AUDIO_CONFIG_5_1_2 ) || + EQ_16( hDirACRend->hOutSetup.output_config, IVAS_AUDIO_CONFIG_5_1_4 ) || + EQ_16( hDirACRend->hOutSetup.output_config, IVAS_AUDIO_CONFIG_7_1_4 ) || + ( EQ_16( hDirACRend->hOutSetup.output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) && st_ivas->hLsSetupCustom->separate_ch_found ) ) ) { - outchannels = add(outchannels, 1); + outchannels = add( outchannels, 1 ); } - IF( hDirACRend->hOutSetup.separateChannelEnabled && hDirACRend->hOutSetup.output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM ) + IF( hDirACRend->hOutSetup.separateChannelEnabled && EQ_16( hDirACRend->hOutSetup.output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) ) { Word32 tmp_separated_fx[L_FRAME48k / MAX_PARAM_SPATIAL_SUBFRAMES]; Word32 tmp_lfe_fx[L_FRAME48k / MAX_PARAM_SPATIAL_SUBFRAMES]; @@ -5368,7 +5160,7 @@ void ivas_dirac_dec_render_sf_fx( Copy32( &( output_buf_fx[LFE_CHANNEL][subframe_start_sample] ), tmp_lfe_fx, num_samples_subframe ); FOR( ch = 0; ch < outchannels; ch++ ) { - IF( ( hDirACRend->hOutSetup.num_lfe > 0 ) && ( EQ_16( hDirACRend->hOutSetup.index_lfe[idx_lfe], ch ) ) ) + IF( L_and( GT_16( hDirACRend->hOutSetup.num_lfe, 0 ), ( EQ_16( hDirACRend->hOutSetup.index_lfe[idx_lfe], ch ) ) ) ) { /* Move the LFE channel to the correct place */ Copy32( tmp_lfe_fx, &( output_buf_fx[ch][subframe_start_sample] ), num_samples_subframe ); @@ -5390,7 +5182,9 @@ void ivas_dirac_dec_render_sf_fx( FOR( i = 0; i < hSpatParamRendCom->subframe_nbslots[subframe_idx]; i++ ) { RealBuffer_fx[i] = Cldfb_RealBuffer_fx[idx_in][i]; + move32(); ImagBuffer_fx[i] = Cldfb_ImagBuffer_fx[idx_in][i]; + move32(); } cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, &( output_buf_fx[ch][subframe_start_sample] ), num_samples_subframe, st_ivas->cldfbSynDec[idx_in] ); @@ -5407,58 +5201,55 @@ void ivas_dirac_dec_render_sf_fx( } ELSE { - FOR ( ch = 0; ch < outchannels; ch++ ) + FOR( ch = 0; ch < outchannels; ch++ ) { - IF ( ( hDirACRend->hOutSetup.num_lfe > 0 ) && ( EQ_16( hDirACRend->hOutSetup.index_lfe[idx_lfe], ch ) ) ) + IF( L_and( GT_16( hDirACRend->hOutSetup.num_lfe, 0 ), ( EQ_16( hDirACRend->hOutSetup.index_lfe[idx_lfe], ch ) ) ) ) { - IF(st_ivas->mc_mode == MC_MODE_MCMASA && !hDirACRend->hOutSetup.separateChannelEnabled) + IF( EQ_16( st_ivas->mc_mode, MC_MODE_MCMASA ) && !hDirACRend->hOutSetup.separateChannelEnabled ) { - FOR(i = 0; i < hSpatParamRendCom->subframe_nbslots[subframe_idx]; i++) + FOR( i = 0; i < hSpatParamRendCom->subframe_nbslots[subframe_idx]; i++ ) { - RealBuffer_fx[i] = Cldfb_RealBuffer_fx[MAX_OUTPUT_CHANNELS - 1][i]; - ImagBuffer_fx[i] = Cldfb_ImagBuffer_fx[MAX_OUTPUT_CHANNELS - 1][i]; + RealBuffer_fx[i] = Cldfb_RealBuffer_fx[sub( MAX_OUTPUT_CHANNELS, 1 )][i]; + move32(); + ImagBuffer_fx[i] = Cldfb_ImagBuffer_fx[sub( MAX_OUTPUT_CHANNELS, 1 )][i]; + move32(); } - Word16 cldfbSynIdx = hDirACRend->hOutSetup.nchan_out_woLFE + idx_lfe; + Word16 cldfbSynIdx = add( hDirACRend->hOutSetup.nchan_out_woLFE, idx_lfe ); + Word16 samplesToProcess = i_mult( hSpatParamRendCom->num_freq_bands, hSpatParamRendCom->subframe_nbslots[subframe_idx] ); + Word32 *p_out = &( output_buf_fx[ch][i_mult( index_slot, hSpatParamRendCom->num_freq_bands )] ); -#if 1 // TODO: remove float to fixed code - st_ivas->cldfbSynDec[cldfbSynIdx]->Q_cldfb_state = Q_factor_arrL(st_ivas->cldfbSynDec[cldfbSynIdx]->cldfb_state, st_ivas->cldfbSynDec[cldfbSynIdx]->p_filter_length); - floatToFixed_arrL(st_ivas->cldfbSynDec[cldfbSynIdx]->cldfb_state, st_ivas->cldfbSynDec[cldfbSynIdx]->cldfb_state_fx, st_ivas->cldfbSynDec[cldfbSynIdx]->Q_cldfb_state, st_ivas->cldfbSynDec[cldfbSynIdx]->p_filter_length); -#endif - Word16 samplesToProcess = hSpatParamRendCom->num_freq_bands * hSpatParamRendCom->subframe_nbslots[subframe_idx]; - Word32 *p_out = &(output_buf_fx[ch][index_slot * hSpatParamRendCom->num_freq_bands]); + scale_sig32( st_ivas->cldfbSynDec[cldfbSynIdx]->cldfb_state_fx, st_ivas->cldfbSynDec[cldfbSynIdx]->p_filter_length, sub( sub( Q6, 1 ), st_ivas->cldfbSynDec[cldfbSynIdx]->Q_cldfb_state ) ); + st_ivas->cldfbSynDec[cldfbSynIdx]->Q_cldfb_state = sub( Q6, 1 ); - scale_sig32(st_ivas->cldfbSynDec[cldfbSynIdx]->cldfb_state_fx, st_ivas->cldfbSynDec[cldfbSynIdx]->p_filter_length, sub(Q6 - 1, st_ivas->cldfbSynDec[cldfbSynIdx]->Q_cldfb_state)); - st_ivas->cldfbSynDec[cldfbSynIdx]->Q_cldfb_state = Q6 - 1; - - cldfbSynthesis_ivas_fx(RealBuffer_fx, ImagBuffer_fx, p_out, samplesToProcess, st_ivas->cldfbSynDec[cldfbSynIdx]); + cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, p_out, samplesToProcess, st_ivas->cldfbSynDec[cldfbSynIdx] ); // Calculating length of output - Word16 no_col = st_ivas->cldfbSynDec[cldfbSynIdx]->no_col, no_channels = st_ivas->cldfbSynDec[cldfbSynIdx]->no_channels; - IF(GT_16(samplesToProcess, -1)) + Word16 no_col = st_ivas->cldfbSynDec[cldfbSynIdx]->no_col; + move16(); + Word16 no_channels = st_ivas->cldfbSynDec[cldfbSynIdx]->no_channels; + move16(); + IF( GT_16( samplesToProcess, -1 ) ) { - no_col = s_min(no_col, (samplesToProcess + st_ivas->cldfbSynDec[cldfbSynIdx]->no_channels - 1) / st_ivas->cldfbSynDec[cldfbSynIdx]->no_channels); + no_col = s_min( no_col, ( add( samplesToProcess, sub( st_ivas->cldfbSynDec[cldfbSynIdx]->no_channels, 1 ) ) ) / st_ivas->cldfbSynDec[cldfbSynIdx]->no_channels ); } - Word16 synth_len = imult1616(no_col, no_channels); + Word16 synth_len = imult1616( no_col, no_channels ); - scale_sig32(p_out, synth_len, (Q11 - (Q6 - 1))); -#if 1 // TODO: remove fixed to float code - fixedToFloat_arrL(st_ivas->cldfbSynDec[cldfbSynIdx]->cldfb_state_fx, st_ivas->cldfbSynDec[cldfbSynIdx]->cldfb_state, st_ivas->cldfbSynDec[cldfbSynIdx]->Q_cldfb_state, st_ivas->cldfbSynDec[cldfbSynIdx]->p_filter_length); -#endif + scale_sig32( p_out, synth_len, sub( Q11, sub( Q6, 1 ) ) ); } - ELSE IF( st_ivas->mc_mode == MC_MODE_MCMASA && hDirACRend->hOutSetup.separateChannelEnabled ) + ELSE IF( EQ_16( st_ivas->mc_mode, MC_MODE_MCMASA ) && hDirACRend->hOutSetup.separateChannelEnabled ) { /* LFE has been synthesized in the time domain, do nothing. */ } ELSE { - set32_fx( &( output_buf_fx[ch][index_slot * hSpatParamRendCom->num_freq_bands] ), 0, imult1616( hSpatParamRendCom->subframe_nbslots[subframe_idx], hSpatParamRendCom->num_freq_bands ) ); + set32_fx( &( output_buf_fx[ch][i_mult( index_slot, hSpatParamRendCom->num_freq_bands )] ), 0, imult1616( hSpatParamRendCom->subframe_nbslots[subframe_idx], hSpatParamRendCom->num_freq_bands ) ); } IF( LT_16( idx_lfe, sub( hDirACRend->hOutSetup.num_lfe, 1 ) ) ) { idx_lfe = add( idx_lfe, 1 ); } } - ELSE IF ( ( hDirACRend->hOutSetup.separateChannelEnabled ) && EQ_16( hDirACRend->hOutSetup.separateChannelIndex, ch ) ) + ELSE IF( ( hDirACRend->hOutSetup.separateChannelEnabled ) && EQ_16( hDirACRend->hOutSetup.separateChannelIndex, ch ) ) { /* The separated channel is already set to output_f[hOutSetup.separateChannelIndex]. Thus, the separated * channel is combined with the synthesized channels here. */ @@ -5466,44 +5257,38 @@ void ivas_dirac_dec_render_sf_fx( ELSE { /* open CLDFB buffer up to CLDFB_NO_CHANNELS_MAX bands for 48kHz */ - -#if 1 // TODO: remove float to fixed code - st_ivas->cldfbSynDec[idx_in]->Q_cldfb_state = Q_factor_arrL(st_ivas->cldfbSynDec[idx_in]->cldfb_state, st_ivas->cldfbSynDec[idx_in]->p_filter_length); - floatToFixed_arrL(st_ivas->cldfbSynDec[idx_in]->cldfb_state, st_ivas->cldfbSynDec[idx_in]->cldfb_state_fx, st_ivas->cldfbSynDec[idx_in]->Q_cldfb_state, st_ivas->cldfbSynDec[idx_in]->p_filter_length); -#endif Word32 *p_out = &( output_buf_fx[ch][index_slot * hSpatParamRendCom->num_freq_bands] ); Word16 samplesToProcess, out_len; FOR( i = 0; i < hSpatParamRendCom->subframe_nbslots[subframe_idx]; i++ ) { - RealBuffer_fx[i] = Cldfb_RealBuffer_fx[idx_in][i]; // Q6 - ImagBuffer_fx[i] = Cldfb_ImagBuffer_fx[idx_in][i]; // Q6 + RealBuffer_fx[i] = Cldfb_RealBuffer_fx[idx_in][i]; // Q6 + move32(); + ImagBuffer_fx[i] = Cldfb_ImagBuffer_fx[idx_in][i]; // Q6 + move32(); } samplesToProcess = imult1616( hSpatParamRendCom->num_freq_bands, hSpatParamRendCom->subframe_nbslots[subframe_idx] ); - + // Calculating length of processed output - Word16 no_col = st_ivas->cldfbSynDec[idx_in]->no_col, no_channels = st_ivas->cldfbSynDec[idx_in]->no_channels; - IF(GT_16(samplesToProcess, -1)) + Word16 no_col = st_ivas->cldfbSynDec[idx_in]->no_col; + move16(); + Word16 no_channels = st_ivas->cldfbSynDec[idx_in]->no_channels; + move16(); + IF( GT_16( samplesToProcess, -1 ) ) { - no_col = s_min(no_col, (samplesToProcess + st_ivas->cldfbSynDec[idx_in]->no_channels - 1) / st_ivas->cldfbSynDec[idx_in]->no_channels); + no_col = s_min( no_col, ( add( samplesToProcess, sub( st_ivas->cldfbSynDec[idx_in]->no_channels, 1 ) ) ) / st_ivas->cldfbSynDec[idx_in]->no_channels ); } - out_len = imult1616(no_col, no_channels); + out_len = imult1616( no_col, no_channels ); // Scaling cldfb_state to Q6-1 - scale_sig32(st_ivas->cldfbSynDec[idx_in]->cldfb_state_fx, st_ivas->cldfbSynDec[idx_in]->p_filter_length, sub(Q6 - 1, st_ivas->cldfbSynDec[idx_in]->Q_cldfb_state)); - st_ivas->cldfbSynDec[idx_in]->Q_cldfb_state = Q6 - 1; + scale_sig32( st_ivas->cldfbSynDec[idx_in]->cldfb_state_fx, st_ivas->cldfbSynDec[idx_in]->p_filter_length, sub( sub( Q6, 1 ), st_ivas->cldfbSynDec[idx_in]->Q_cldfb_state ) ); + st_ivas->cldfbSynDec[idx_in]->Q_cldfb_state = sub( Q6, 1 ); move16(); - // Scaling the output to Q8 - scale_sig32(output_buf_fx[ch], samplesToProcess + index_slot * hSpatParamRendCom->num_freq_bands, Q8 - Q11 ); - cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, p_out, samplesToProcess, st_ivas->cldfbSynDec[idx_in] ); - // Scaling output from Q6-1 to Q8 - scale_sig32(p_out, out_len, (Q8 - (Q6 - 1))); + // Scaling output from Q6-1 to Q11 + Scale_sig32(p_out, out_len, (Q11 - (Q6 - 1))); -#if 1 /* TODO: remove fixed to float */ - fixedToFloat_arrL(st_ivas->cldfbSynDec[idx_in]->cldfb_state_fx, st_ivas->cldfbSynDec[idx_in]->cldfb_state, st_ivas->cldfbSynDec[idx_in]->Q_cldfb_state, st_ivas->cldfbSynDec[idx_in]->p_filter_length); -#endif idx_in = add( idx_in, 1 ); } } @@ -5513,302 +5298,349 @@ void ivas_dirac_dec_render_sf_fx( hSpatParamRendCom->slots_rendered = add( hSpatParamRendCom->slots_rendered, hSpatParamRendCom->subframe_nbslots[subframe_idx] ); hSpatParamRendCom->subframes_rendered = add( hSpatParamRendCom->subframes_rendered, 1 ); -#else - if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) + +#ifdef IVAS_FLOAT_FIXED + /////////////////////////////////////////////////////// FIXED TO FLOAT ////////////////////////////////////////////////////////////////////////////////////////// + IF( EQ_16( hDirAC->hConfig->dec_param_estim, FALSE ) ) { - /* render objects in combined format onto the CICP19 channels for BINAURAL_ROOM_IR */ - if ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_SBA_MODE_DISC && st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) + IF( hDirACRend->synthesisConf != DIRAC_SYNTHESIS_GAIN_SHD ) { - int16_t in_ch; - for ( in_ch = 0; in_ch < st_ivas->nchan_ism; in_ch++ ) - { - int16_t j, k, j2, l; - int16_t num_objects, nchan_out_woLFE, lfe_index; - int16_t az1, el1; - int16_t n_slots_to_render; - int16_t n_samples_to_render; - int16_t interp_offset; - - float gain, prev_gain; - - num_objects = st_ivas->nchan_ism; - nchan_out_woLFE = st_ivas->hIntSetup.nchan_out_woLFE; - n_slots_to_render = st_ivas->hSpar->subframe_nbslots[st_ivas->hSpar->subframes_rendered]; - n_samples_to_render = hSpatParamRendCom->num_freq_bands * n_slots_to_render; - interp_offset = st_ivas->hTcBuffer->n_samples_rendered; + fixedToFloat_arrL32( hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_fx, hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor, hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_q, hSpatParamRendCom->num_freq_bands ); + fixedToFloat_arrL32( hDirACRend->h_output_synthesis_psd_state.direct_power_factor_fx, hDirACRend->h_output_synthesis_psd_state.direct_power_factor, hDirACRend->h_output_synthesis_psd_state.direct_power_factor_q, hSpatParamRendCom->num_freq_bands ); + } + ELSE + { + me2f_buf( hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_fx, 31 - hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_q, hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor, hSpatParamRendCom->num_freq_bands ); + me2f_buf( hDirACRend->h_output_synthesis_psd_state.direct_power_factor_fx, 31 - hDirACRend->h_output_synthesis_psd_state.direct_power_factor_q, hDirACRend->h_output_synthesis_psd_state.direct_power_factor, hSpatParamRendCom->num_freq_bands ); + } + } + IF( st_ivas->hMasa == NULL && EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) + { + fixedToFloat_arrL32( hDirACRend->h_output_synthesis_psd_state.direct_responses_fx, hDirACRend->h_output_synthesis_psd_state.direct_responses, hDirACRend->h_output_synthesis_psd_state.direct_responses_q, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ) ); - if ( st_ivas->hCombinedOrientationData && st_ivas->hCombinedOrientationData->enableCombinedOrientation[0] ) + IF( hodirac_flag ) + { + fixedToFloat_arrL32( &hDirACRend->h_output_synthesis_psd_state.direct_responses_fx[i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir )], &hDirACRend->h_output_synthesis_psd_state.direct_responses[i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir )], hDirACRend->h_output_synthesis_psd_state.direct_responses_q, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ) ); + } + } + ELSE + { + fixedToFloat_arrL32( hDirACRend->h_output_synthesis_psd_state.direct_responses_fx, hDirACRend->h_output_synthesis_psd_state.direct_responses, hDirACRend->h_output_synthesis_psd_state.direct_responses_q, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ) ); + IF( hDirACRend->synthesisConf != DIRAC_SYNTHESIS_GAIN_SHD ) + { + fixedToFloat_arrL32( hDirACRend->h_output_synthesis_psd_state.direct_responses_square_fx, hDirACRend->h_output_synthesis_psd_state.direct_responses_square, hDirACRend->h_output_synthesis_psd_state.direct_responses_square_q, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ) ); + } + } + IF( !( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) ) + { + FOR( ch = 0; ch < nchan_transport; ch++ ) + { + fixedToFloat_arrL32( st_ivas->cldfbAnaDec[ch]->cldfb_state_fx, st_ivas->cldfbAnaDec[ch]->cldfb_state, Q11, ( st_ivas->cldfbAnaDec[ch]->p_filter_length - st_ivas->cldfbAnaDec[ch]->no_channels ) ); + } + } + IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) + { + IF( nchan_transport >= 4 ) + { + fixedToFloat_arrL32( reference_power_fx, DirAC_mem.reference_power, DirAC_mem.reference_power_q, 5 * hSpatParamRendCom->num_freq_bands ); + } + fixedToFloat_arrL32( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx, hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f, hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, 2 * nchan_transport * hSpatParamRendCom->num_freq_bands * hSpatParamRendCom->subframe_nbslots[subframe_idx] ); + fixedToFloat_arrL32( hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_fx, hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f, hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q, 2 * hDirACRend->num_outputs_diff * hSpatParamRendCom->num_freq_bands * hSpatParamRendCom->subframe_nbslots[subframe_idx] ); + } + ELSE IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_MONO ) ) + { + fixedToFloat_arrL32( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx, hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f, hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, i_mult( hSpatParamRendCom->subframe_nbslots[subframe_idx], i_mult( 4, hSpatParamRendCom->num_freq_bands ) ) ); + fixedToFloat_arrL32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, i_mult( 2, hSpatParamRendCom->num_freq_bands ) ); + fixedToFloat_arrL32( hDirACRend->proto_frame_f_fx, hDirACRend->proto_frame_f, hDirACRend->proto_frame_f_q, i_mult( 6, hSpatParamRendCom->num_freq_bands ) ); + fixedToFloat_arrL32( reference_power_fx, DirAC_mem.reference_power, DirAC_mem.reference_power_q, hSpatParamRendCom->num_freq_bands ); + IF( hDirACRend->masa_stereo_type_detect ) + { + hDirACRend->masa_stereo_type_detect->subtract_power_y = fixedToFloat_32( hDirACRend->masa_stereo_type_detect->subtract_power_y_fx, hDirACRend->masa_stereo_type_detect->q_subtract_power_y ); + } + } + ELSE + { + SWITCH( nchan_transport ) + { + case 11: + case 8: + case 6: + case 4: + fixedToFloat_arrL32( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx, hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f, hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, i_mult( i_mult( 2, hSpatParamRendCom->subframe_nbslots[subframe_idx] ), i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_diff ) ) ); + fixedToFloat_arrL32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_diff ) ); + me2f_buf( hDirACRend->proto_frame_f_fx, hDirACRend->proto_frame_f_q, hDirACRend->proto_frame_f, i_mult( 2, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_diff ) ) ); + fixedToFloat_arrL32( reference_power_fx, DirAC_mem.reference_power, DirAC_mem.reference_power_q, hSpatParamRendCom->num_freq_bands ); + BREAK; + case 2: + IF( hDirACRend->hOutSetup.is_loudspeaker_setup ) { - ivas_jbm_dec_get_adapted_linear_interpolator( n_samples_to_render, n_samples_to_render, st_ivas->hIsmRendererData->interpolator_fx ); - - interp_offset = 0; + fixedToFloat_arrL32( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx, hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f, hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, i_mult( hSpatParamRendCom->subframe_nbslots[subframe_idx], i_mult( 6, hSpatParamRendCom->num_freq_bands ) ) ); + fixedToFloat_arrL32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, i_mult( 3, hSpatParamRendCom->num_freq_bands ) ); } - for ( i = 0; i < num_objects; i++ ) + ELSE { - /* Combined rotation: rotate the object positions depending the head and external orientations */ - if ( st_ivas->hCombinedOrientationData != NULL && st_ivas->hCombinedOrientationData->enableCombinedOrientation[0] == 1 ) + fixedToFloat_arrL32( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx, hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f, hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, i_mult( hSpatParamRendCom->subframe_nbslots[subframe_idx], i_mult( 4, hSpatParamRendCom->num_freq_bands ) ) ); + fixedToFloat_arrL32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, i_mult( 2, hSpatParamRendCom->num_freq_bands ) ); + IF( hDirACRend->masa_stereo_type_detect ) { - rotateAziEle( st_ivas->hIsmMetaData[i]->azimuth, st_ivas->hIsmMetaData[i]->elevation, &az1, &el1, st_ivas->hCombinedOrientationData->Rmat[0], st_ivas->hIntSetup.is_planar_setup ); - if ( st_ivas->hEFAPdata != NULL ) - { - efap_determine_gains( st_ivas->hEFAPdata, st_ivas->hIsmRendererData->gains[i], az1, el1, EFAP_MODE_EFAP ); - } + hDirACRend->masa_stereo_type_detect->subtract_power_y = fixedToFloat_32( hDirACRend->masa_stereo_type_detect->subtract_power_y_fx, hDirACRend->masa_stereo_type_detect->q_subtract_power_y ); } + } + me2f_buf( hDirACRend->proto_frame_f_fx, hDirACRend->proto_frame_f_q, hDirACRend->proto_frame_f, i_mult( 6, hSpatParamRendCom->num_freq_bands ) ); + fixedToFloat_arrL32( reference_power_fx, DirAC_mem.reference_power, DirAC_mem.reference_power_q, hSpatParamRendCom->num_freq_bands ); + BREAK; + case 1: + fixedToFloat_arrL32( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx, hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f, hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, i_mult( hSpatParamRendCom->subframe_nbslots[subframe_idx], i_mult( 2, hSpatParamRendCom->num_freq_bands ) ) ); + fixedToFloat_arrL32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, hSpatParamRendCom->num_freq_bands ); + me2f_buf( hDirACRend->proto_frame_f_fx, hDirACRend->proto_frame_f_q, hDirACRend->proto_frame_f, i_mult( 2, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_protos_diff ) ) ); + fixedToFloat_arrL32( reference_power_fx, DirAC_mem.reference_power, DirAC_mem.reference_power_q, hSpatParamRendCom->num_freq_bands ); + BREAK; + } + } - lfe_index = 0; - for ( j = 0, j2 = 0; j < nchan_out_woLFE; j++, j2++ ) - { - if ( ( st_ivas->hIntSetup.num_lfe > 0 ) && ( st_ivas->hIntSetup.index_lfe[lfe_index] == j ) ) - { - ( lfe_index < ( st_ivas->hIntSetup.num_lfe - 1 ) ) ? ( lfe_index++, j2++ ) : j2++; - } - gain = st_ivas->hIsmRendererData->gains[i][j]; - prev_gain = st_ivas->hIsmRendererData->prev_gains[i][j]; - if ( fabsf( gain ) > 0.0f || fabsf( prev_gain ) > 0.0f ) - { - float *tc_re, *tc_im; - float *w1, w2; - w1 = &st_ivas->hIsmRendererData->interpolator[interp_offset]; - tc_re = pppQMfFrame_ts_re[nchan_transport + i][0]; - tc_im = pppQMfFrame_ts_im[nchan_transport + i][0]; - for ( k = 0; k < n_slots_to_render; k++ ) - { - float g; - w2 = 1.0f - *w1; - g = ( *w1 * gain + w2 * prev_gain ); + IF( EQ_16( hDirAC->hConfig->dec_param_estim, TRUE ) ) + { + FOR( i = 0; i < DIRAC_NO_COL_AVG_DIFF; i++ ) + { + fixedToFloat_arrL32( hDirACRend->buffer_intensity_real_fx[0][i], hDirACRend->buffer_intensity_real[0][i], hDirACRend->q_buffer_intensity_real[i], hDirAC->band_grouping[hDirAC->hConfig->enc_param_start_band] ); + fixedToFloat_arrL32( hDirACRend->buffer_intensity_real_fx[1][i], hDirACRend->buffer_intensity_real[1][i], hDirACRend->q_buffer_intensity_real[i], hDirAC->band_grouping[hDirAC->hConfig->enc_param_start_band] ); + fixedToFloat_arrL32( hDirACRend->buffer_intensity_real_fx[2][i], hDirACRend->buffer_intensity_real[2][i], hDirACRend->q_buffer_intensity_real[i], hDirAC->band_grouping[hDirAC->hConfig->enc_param_start_band] ); + fixedToFloat_arrL32( &hDirACRend->buffer_energy_fx[i * num_freq_bands], &hDirACRend->buffer_energy[i * num_freq_bands], hDirACRend->q_buffer_energy[i], hDirAC->band_grouping[hDirAC->hConfig->enc_param_start_band] ); + } + FOR( slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[subframe_idx]; slot_idx++ ) + { + md_idx = hSpatParamRendCom->render_to_md_map[add( hSpatParamRendCom->slots_rendered, slot_idx )]; + fixedToFloat_arrL32( hSpatParamRendCom->diffuseness_vector_fx[md_idx], hSpatParamRendCom->diffuseness_vector[md_idx], Q30, hDirAC->band_grouping[hDirAC->hConfig->enc_param_start_band] ); + } + } - for ( l = 0; l < hSpatParamRendCom->num_freq_bands; l++ ) - { - Cldfb_RealBuffer[j2][0][k * hSpatParamRendCom->num_freq_bands + l] += g * *( tc_re++ ); - Cldfb_ImagBuffer[j2][0][k * hSpatParamRendCom->num_freq_bands + l] += g * *( tc_im++ ); - } - w1 += hSpatParamRendCom->num_freq_bands; - } - } - /* update here only in case of head rotation */ - if ( st_ivas->hCombinedOrientationData != NULL && st_ivas->hCombinedOrientationData->enableCombinedOrientation[0] == 1 ) - { - st_ivas->hIsmRendererData->prev_gains[i][j] = gain; - } - } - } - } + IF( EQ_16( hDirACRend->proto_signal_decorr_on, 1 ) ) + { + IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) + { + fixedToFloat_arrL( onset_filter_fx, DirAC_mem.onset_filter, DirAC_mem.q_onset_filter, hSpatParamRendCom->num_freq_bands ); + fixedToFloat_arrL( onset_filter_subframe_fx, DirAC_mem.onset_filter + hSpatParamRendCom->num_freq_bands, DirAC_mem.q_onset_filter, hSpatParamRendCom->num_freq_bands ); } + ELSE + { + fixedToFloat_arrL( onset_filter_fx, DirAC_mem.onset_filter, DirAC_mem.q_onset_filter, hSpatParamRendCom->num_freq_bands * hDirACRend->num_outputs_diff ); + me2f_buf( DirAC_mem.frame_dec_f_fx, 31 - DirAC_mem.frame_dec_f_q, DirAC_mem.frame_dec_f, DirAC_mem.frame_dec_f_len ); - /* Perform binaural rendering */ - ivas_binRenderer( st_ivas->hBinRenderer, - st_ivas->hCombinedOrientationData, - hSpatParamRendCom->subframe_nbslots[subframe_idx], - Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer, Cldfb_ImagBuffer ); + hDirACRend->proto_frame_dec_f = DirAC_mem.frame_dec_f; + } + } + ELSE + { + IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) + { + fixedToFloat_arrL( onset_filter_fx, DirAC_mem.onset_filter, DirAC_mem.q_onset_filter, hSpatParamRendCom->num_freq_bands ); + } + ELSE + { + hDirACRend->proto_frame_dec_f = hDirACRend->proto_frame_f; + } + } + IF( L_or( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_PSD_LS ), EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_PSD_SHD ) ) ) + { + if ( hDirACRend->h_output_synthesis_psd_params.max_band_decorr != 0 ) + { + DIRAC_OUTPUT_SYNTHESIS_STATE *state = &( hDirACRend->h_output_synthesis_psd_state ); + me2f_buf( state->proto_power_diff_smooth_fx, + 31 - state->proto_power_diff_smooth_q, + state->proto_power_diff_smooth, + state->proto_power_diff_smooth_len ); + me2f_buf( state->proto_diffuse_buffer_f_fx, + 31 - state->proto_diffuse_buffer_f_q, + state->proto_diffuse_buffer_f, + state->proto_diffuse_buffer_f_len ); + } + } - /* Inverse CLDFB*/ - for (ch = 0; ch < st_ivas->hDecoderConfig->nchan_out; ch++) + if ( hDirAC->hConfig->dec_param_estim == FALSE && hodirac_flag ) + { + if ( hDirACRend->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD ) { - /* open CLDFB buffer up to CLDFB_NO_CHANNELS_MAX bands for 48kHz */ - float *RealBuffer[MAX_PARAM_SPATIAL_SUBFRAMES]; - float *ImagBuffer[MAX_PARAM_SPATIAL_SUBFRAMES]; - for (i = 0; i < hSpatParamRendCom->subframe_nbslots[subframe_idx]; i++) + fixedToFloat_arrL( h_dirac_output_synthesis_state->direct_power_factor_fx, h_dirac_output_synthesis_state->direct_power_factor, h_dirac_output_synthesis_state->direct_power_factor_q, 2 * hSpatParamRendCom->num_freq_bands ); + fixedToFloat_arrL( h_dirac_output_synthesis_state->diffuse_power_factor_fx, h_dirac_output_synthesis_state->diffuse_power_factor, h_dirac_output_synthesis_state->diffuse_power_factor_q, 2 * hSpatParamRendCom->num_freq_bands ); + } + else + { + FOR( i = 0; i < hSpatParamRendCom->num_freq_bands; i++ ) { - RealBuffer[i] = Cldfb_RealBuffer_Binaural[ch][i]; - ImagBuffer[i] = Cldfb_ImagBuffer_Binaural[ch][i]; + hDirACRend->h_output_synthesis_psd_state.direct_power_factor[i] = me2f( hDirACRend->h_output_synthesis_psd_state.direct_power_factor_fx[i], 31 - hDirACRend->h_output_synthesis_psd_state.direct_power_factor_q ); + hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor[i] = me2f( hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_fx[i], 31 - hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_q ); } - cldfbSynthesis_ivas( RealBuffer, ImagBuffer, &( output_f[ch][index_slot * hSpatParamRendCom->num_freq_bands] ), hSpatParamRendCom->num_freq_bands * hSpatParamRendCom->subframe_nbslots[subframe_idx], st_ivas->cldfbSynDec[ch] ); } } - else if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) + else if ( hDirAC->hConfig->dec_param_estim == TRUE ) { - for ( ch = 0; ch < hDirACRend->hOutSetup.nchan_out_woLFE; ch++ ) + if ( hDirACRend->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD ) { - for ( slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[subframe_idx]; slot_idx++ ) + FOR( i = 0; i < hSpatParamRendCom->num_freq_bands; i++ ) { - mvr2r( Cldfb_RealBuffer[ch][slot_idx], pppQMfFrame_ts_re[ch][slot_idx], hSpatParamRendCom->num_freq_bands ); - mvr2r( Cldfb_ImagBuffer[ch][slot_idx], pppQMfFrame_ts_im[ch][slot_idx], hSpatParamRendCom->num_freq_bands ); + hDirACRend->h_output_synthesis_psd_state.direct_power_factor[i] = me2f( hDirACRend->h_output_synthesis_psd_state.direct_power_factor_fx[i], 31 - h_dirac_output_synthesis_state->direct_power_factor_q ); + hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor[i] = me2f( hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_fx[i], 31 - h_dirac_output_synthesis_state->diffuse_power_factor_q ); + } + fixedToFloat_arrL( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx, h_dirac_output_synthesis_state->cy_cross_dir_smooth, h_dirac_output_synthesis_state->q_cy_cross_dir_smooth, (num_channels_dir) *hSpatParamRendCom->num_freq_bands ); + } + else + { + FOR( i = 0; i < hSpatParamRendCom->num_freq_bands; i++ ) + { + hDirACRend->h_output_synthesis_psd_state.direct_power_factor[i] = fix_to_float( hDirACRend->h_output_synthesis_psd_state.direct_power_factor_fx[i], hDirACRend->h_output_synthesis_psd_state.direct_power_factor_q ); + hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor[i] = fix_to_float( hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_fx[i], hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_q ); } } } - else + + if ( h_dirac_output_synthesis_params->use_onset_filters && ( hDirAC->hConfig->dec_param_estim != TRUE && hDirACRend->synthesisConf != DIRAC_SYNTHESIS_GAIN_SHD ) ) { - float *RealBuffer[MAX_PARAM_SPATIAL_SUBFRAMES]; - float *ImagBuffer[MAX_PARAM_SPATIAL_SUBFRAMES]; - int16_t outchannels; + fixedToFloat_arrL( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx, h_dirac_output_synthesis_state->cy_auto_diff_smooth, h_dirac_output_synthesis_state->q_cy_auto_diff_smooth, hDirACRend->num_outputs_diff * hSpatParamRendCom->num_freq_bands ); + } - idx_in = 0; - idx_lfe = 0; + if ( hDirAC->hConfig->dec_param_estim == TRUE && hDirACRend->synthesisConf != DIRAC_SYNTHESIS_GAIN_SHD ) + { + fixedToFloat_arrL( h_dirac_output_synthesis_state->cy_auto_dir_smooth_fx, h_dirac_output_synthesis_state->cy_auto_dir_smooth, h_dirac_output_synthesis_state->q_cy_auto_dir_smooth, num_channels_dir * hSpatParamRendCom->num_freq_bands ); + fixedToFloat_arrL( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx, h_dirac_output_synthesis_state->cy_cross_dir_smooth, h_dirac_output_synthesis_state->q_cy_cross_dir_smooth, num_channels_dir * hSpatParamRendCom->num_freq_bands ); + fixedToFloat_arrL( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx, h_dirac_output_synthesis_state->cy_auto_diff_smooth, h_dirac_output_synthesis_state->q_cy_auto_diff_smooth, num_channels_dir * hSpatParamRendCom->num_freq_bands ); + } - outchannels = hDirACRend->hOutSetup.nchan_out_woLFE + hDirACRend->hOutSetup.num_lfe; - if ( hDirACRend->hOutSetup.separateChannelEnabled && ( hDirACRend->hOutSetup.output_config == IVAS_AUDIO_CONFIG_5_1 || - hDirACRend->hOutSetup.output_config == IVAS_AUDIO_CONFIG_7_1 || - hDirACRend->hOutSetup.output_config == IVAS_AUDIO_CONFIG_5_1_2 || - hDirACRend->hOutSetup.output_config == IVAS_AUDIO_CONFIG_5_1_4 || - hDirACRend->hOutSetup.output_config == IVAS_AUDIO_CONFIG_7_1_4 || - ( hDirACRend->hOutSetup.output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM && st_ivas->hLsSetupCustom->separate_ch_found ) ) ) + fixedToFloat_arr( hDirACRend->h_output_synthesis_psd_params.interpolator_fx, hDirACRend->h_output_synthesis_psd_params.interpolator, Q15, hSpatParamRendCom->subframe_nbslots[subframe_idx] ); + IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) + { + fixedToFloat_arrL( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_fx, hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth, hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth, size_ho ); + fixedToFloat_arrL( hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_fx, hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth, hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth, hDirACRend->num_outputs_diff * hDirACRend->h_output_synthesis_psd_params.max_band_decorr ); + fixedToFloat_arrL( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev, hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev, size_ho ); + fixedToFloat_arrL( hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev, hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth_prev, hDirACRend->num_outputs_diff * hDirACRend->h_output_synthesis_psd_params.max_band_decorr ); + + hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_q = hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev; + hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_q = hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth_prev; + fixedToFloat_arrL( hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_fx, hDirACRend->h_output_synthesis_psd_state.gains_dir_prev, hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_q, size ); + fixedToFloat_arrL( hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_fx, hDirACRend->h_output_synthesis_psd_state.gains_diff_prev, hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_q, hDirACRend->num_outputs_diff * hDirACRend->h_output_synthesis_psd_params.max_band_decorr ); + } + ELSE + { + fixedToFloat_arrL( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev, q_reference_power_smooth, hSpatParamRendCom->num_freq_bands ); + + IF( hDirACRend->masa_stereo_type_detect != NULL ) { - outchannels++; + hDirACRend->masa_stereo_type_detect->subtract_target_ratio_db = fixedToFloat( hDirACRend->masa_stereo_type_detect->subtract_target_ratio_db_fx, Q21 ); + + hDirACRend->masa_stereo_type_detect->target_power_y_smooth = fixedToFloat( hDirACRend->masa_stereo_type_detect->target_power_y_smooth_fx, hDirACRend->masa_stereo_type_detect->q_target_power_y_smooth ); + hDirACRend->masa_stereo_type_detect->subtract_power_y_smooth = fixedToFloat( hDirACRend->masa_stereo_type_detect->subtract_power_y_smooth_fx, hDirACRend->masa_stereo_type_detect->q_subtract_power_y ); + hDirACRend->masa_stereo_type_detect->subtract_power_y = fixedToFloat( hDirACRend->masa_stereo_type_detect->subtract_power_y_fx, hDirACRend->masa_stereo_type_detect->q_subtract_power_y ); } - if ( hDirACRend->hOutSetup.separateChannelEnabled && hDirACRend->hOutSetup.output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM ) + fixedToFloat_arrL( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_fx, hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth, hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth, size ); + fixedToFloat_arrL( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_fx, hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth, hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth, size_ho ); + fixedToFloat_arrL( hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_fx, hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth, hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth, size ); + fixedToFloat_arrL( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_prev, hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth_prev, size ); + fixedToFloat_arrL( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev, hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev, size_ho ); + fixedToFloat_arrL( hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev, hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth_prev, hSpatParamRendCom->num_freq_bands * hDirACRend->hOutSetup.nchan_out_woLFE ); + + fixedToFloat_arrL( hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_fx, hDirACRend->h_output_synthesis_psd_state.gains_dir_prev, hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_q, size ); + fixedToFloat_arrL( hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_fx, hDirACRend->h_output_synthesis_psd_state.gains_diff_prev, hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_q, hSpatParamRendCom->num_freq_bands * hDirACRend->hOutSetup.nchan_out_woLFE ); + + fixedToFloat_arrL( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, hDirACRend->num_protos_dir * hSpatParamRendCom->num_freq_bands ); + fixedToFloat_arrL( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q, hDirACRend->num_protos_dir * hSpatParamRendCom->num_freq_bands ); + fixedToFloat_arrL( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth, hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_q, hDirACRend->h_output_synthesis_psd_params.max_band_decorr * hDirACRend->hOutSetup.nchan_out_woLFE ); + IF( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev != 0 ) { - float tmp_separated[L_FRAME48k / MAX_PARAM_SPATIAL_SUBFRAMES]; - float tmp_lfe[L_FRAME48k / MAX_PARAM_SPATIAL_SUBFRAMES]; - const int16_t subframe_start_sample = index_slot * hSpatParamRendCom->num_freq_bands; - const int16_t num_samples_subframe = hSpatParamRendCom->num_freq_bands * hSpatParamRendCom->subframe_nbslots[subframe_idx]; + fixedToFloat_arrL( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev, hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_q, hDirACRend->h_output_synthesis_psd_params.max_band_decorr * hDirACRend->hOutSetup.nchan_out_woLFE ); + } + } - /* Move the separated and the LFE channels to temporary variables as spatial synthesis may overwrite current channels */ - mvr2r( &( output_f[st_ivas->hOutSetup.separateChannelIndex][subframe_start_sample] ), tmp_separated, num_samples_subframe ); - mvr2r( &( output_f[LFE_CHANNEL][subframe_start_sample] ), tmp_lfe, num_samples_subframe ); - for ( ch = 0; ch < outchannels; ch++ ) - { - if ( ( hDirACRend->hOutSetup.num_lfe > 0 ) && ( hDirACRend->hOutSetup.index_lfe[idx_lfe] == ch ) ) - { - /* Move the LFE channel to the correct place */ - mvr2r( tmp_lfe, &( output_f[ch][subframe_start_sample] ), num_samples_subframe ); + if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) + { + for ( i = 0; i < st_ivas->hDecoderConfig->nchan_out; i++ ) + { + fixedToFloat_arrL( st_ivas->cldfbSynDec[i]->cldfb_state_fx, st_ivas->cldfbSynDec[i]->cldfb_state, st_ivas->cldfbSynDec[i]->Q_cldfb_state, st_ivas->cldfbSynDec[i]->p_filter_length ); + fixedToFloat_arrL( output_buf_fx[i], output_f[i], Q11, index_slot * hSpatParamRendCom->num_freq_bands + hSpatParamRendCom->num_freq_bands * hSpatParamRendCom->subframe_nbslots[subframe_idx] ); + } + } + else if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) + { + } + else + { + idx_lfe = 0; + idx_in = 0; + Word16 outchannels = add( hDirACRend->hOutSetup.nchan_out_woLFE, hDirACRend->hOutSetup.num_lfe ); - if ( idx_lfe < ( hDirACRend->hOutSetup.num_lfe - 1 ) ) - { - idx_lfe++; - } - } - else if ( ( st_ivas->hLsSetupCustom->separate_ch_found ) && ( hDirACRend->hOutSetup.separateChannelIndex == ch ) ) - { - /* Move the separated channel to the correct place. Thus, the separated channel is - * combined with the synthesized channels here when there is a matching channel. */ - mvr2r( tmp_separated, &( output_f[ch][subframe_start_sample] ), num_samples_subframe ); - } - else - { - /* open CLDFB buffer up to CLDFB_NO_CHANNELS_MAX bands for 48kHz */ - for ( i = 0; i < hSpatParamRendCom->subframe_nbslots[subframe_idx]; i++ ) - { - RealBuffer[i] = Cldfb_RealBuffer[idx_in][i]; - ImagBuffer[i] = Cldfb_ImagBuffer[idx_in][i]; - } - cldfbSynthesis_ivas( RealBuffer, ImagBuffer, &( output_f[ch][subframe_start_sample] ), num_samples_subframe, st_ivas->cldfbSynDec[idx_in] ); + IF( hDirACRend->hOutSetup.separateChannelEnabled && ( EQ_16( hDirACRend->hOutSetup.output_config, IVAS_AUDIO_CONFIG_5_1 ) || + EQ_16( hDirACRend->hOutSetup.output_config, IVAS_AUDIO_CONFIG_7_1 ) || + EQ_16( hDirACRend->hOutSetup.output_config, IVAS_AUDIO_CONFIG_5_1_2 ) || + EQ_16( hDirACRend->hOutSetup.output_config, IVAS_AUDIO_CONFIG_5_1_4 ) || + EQ_16( hDirACRend->hOutSetup.output_config, IVAS_AUDIO_CONFIG_7_1_4 ) || + ( EQ_16( hDirACRend->hOutSetup.output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) && st_ivas->hLsSetupCustom->separate_ch_found ) ) ) + { + outchannels = add( outchannels, 1 ); + } - if ( !st_ivas->hLsSetupCustom->separate_ch_found ) + IF( ( hDirACRend->hOutSetup.separateChannelEnabled && EQ_16( hDirACRend->hOutSetup.output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) ) ) + { + FOR( ch = 0; ch < outchannels; ch++ ) + { + IF( L_and( GT_16( hDirACRend->hOutSetup.num_lfe, 0 ), ( EQ_16( hDirACRend->hOutSetup.index_lfe[idx_lfe], ch ) ) ) ) + { + IF( LT_16( idx_lfe, sub( hDirACRend->hOutSetup.num_lfe, 1 ) ) ) { - /* Pan the separated channel and mix with the synthesized channels. Thus, the separated channel - * is combined with the synthesized channels here when there is no matching channel. */ - v_multc_acc( tmp_separated, st_ivas->hLsSetupCustom->separate_ch_gains[idx_in], &( output_f[ch][subframe_start_sample] ), num_samples_subframe ); + idx_lfe = add( idx_lfe, 1 ); } - - idx_in++; } } } - else + ELSE { - for ( ch = 0; ch < outchannels; ch++ ) + FOR( ch = 0; ch < outchannels; ch++ ) { - if ( ( hDirACRend->hOutSetup.num_lfe > 0 ) && ( hDirACRend->hOutSetup.index_lfe[idx_lfe] == ch ) ) + IF( L_and( GT_16( hDirACRend->hOutSetup.num_lfe, 0 ), ( EQ_16( hDirACRend->hOutSetup.index_lfe[idx_lfe], ch ) ) ) ) { - if (st_ivas->mc_mode == MC_MODE_MCMASA && !hDirACRend->hOutSetup.separateChannelEnabled) - { - for (i = 0; i < hSpatParamRendCom->subframe_nbslots[subframe_idx]; i++) - { - RealBuffer[i] = Cldfb_RealBuffer[MAX_OUTPUT_CHANNELS - 1][i]; - ImagBuffer[i] = Cldfb_ImagBuffer[MAX_OUTPUT_CHANNELS - 1][i]; - } - cldfbSynthesis_ivas( RealBuffer, ImagBuffer, &( output_f[ch][index_slot * hSpatParamRendCom->num_freq_bands] ), hSpatParamRendCom->num_freq_bands * hSpatParamRendCom->subframe_nbslots[subframe_idx], st_ivas->cldfbSynDec[hDirACRend->hOutSetup.nchan_out_woLFE + idx_lfe] ); - } - else if ( st_ivas->mc_mode == MC_MODE_MCMASA && hDirACRend->hOutSetup.separateChannelEnabled ) + IF( EQ_16( st_ivas->mc_mode, MC_MODE_MCMASA ) && !hDirACRend->hOutSetup.separateChannelEnabled ) { - /* LFE has been synthesized in the time domain, do nothing. */ - } - else - { - set_zero( &( output_f[ch][index_slot * hSpatParamRendCom->num_freq_bands] ), hSpatParamRendCom->subframe_nbslots[subframe_idx] * hSpatParamRendCom->num_freq_bands ); - } - if ( idx_lfe < ( hDirACRend->hOutSetup.num_lfe - 1 ) ) - { - idx_lfe++; + Word16 cldfbSynIdx = add( hDirACRend->hOutSetup.nchan_out_woLFE, idx_lfe ); + fixedToFloat_arrL( st_ivas->cldfbSynDec[cldfbSynIdx]->cldfb_state_fx, st_ivas->cldfbSynDec[cldfbSynIdx]->cldfb_state, st_ivas->cldfbSynDec[cldfbSynIdx]->Q_cldfb_state, st_ivas->cldfbSynDec[cldfbSynIdx]->p_filter_length ); } } - else if ( ( hDirACRend->hOutSetup.separateChannelEnabled ) && ( hDirACRend->hOutSetup.separateChannelIndex == ch ) ) + ELSE IF( ( hDirACRend->hOutSetup.separateChannelEnabled ) && EQ_16( hDirACRend->hOutSetup.separateChannelIndex, ch ) ) { - /* The separated channel is already set to output_f[hOutSetup.separateChannelIndex]. Thus, the separated - * channel is combined with the synthesized channels here. */ } - else + ELSE { - /* open CLDFB buffer up to CLDFB_NO_CHANNELS_MAX bands for 48kHz */ - for ( i = 0; i < hSpatParamRendCom->subframe_nbslots[subframe_idx]; i++ ) - { - RealBuffer[i] = Cldfb_RealBuffer[idx_in][i]; - ImagBuffer[i] = Cldfb_ImagBuffer[idx_in][i]; - } - cldfbSynthesis_ivas( RealBuffer, ImagBuffer, &( output_f[ch][index_slot * hSpatParamRendCom->num_freq_bands] ), hSpatParamRendCom->num_freq_bands * hSpatParamRendCom->subframe_nbslots[subframe_idx], st_ivas->cldfbSynDec[idx_in] ); - idx_in++; + fixedToFloat_arrL( st_ivas->cldfbSynDec[idx_in]->cldfb_state_fx, st_ivas->cldfbSynDec[idx_in]->cldfb_state, st_ivas->cldfbSynDec[idx_in]->Q_cldfb_state, st_ivas->cldfbSynDec[idx_in]->p_filter_length ); + idx_in = add( idx_in, 1 ); } } } - } - - hSpatParamRendCom->slots_rendered += hSpatParamRendCom->subframe_nbslots[subframe_idx]; - hSpatParamRendCom->subframes_rendered++; -#endif - -#ifdef IVAS_FLOAT_FIXED - /////////////////////////////////////////////////////// FIXED TO FLOAT ////////////////////////////////////////////////////////////////////////////////////////// - if (st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM) - { - for (i = 0; i < st_ivas->hDecoderConfig->nchan_out; i++) - { - fixedToFloat_arrL(output_buf_fx[i], output_f[i], Q11, index_slot * hSpatParamRendCom->num_freq_bands + hSpatParamRendCom->num_freq_bands * hSpatParamRendCom->subframe_nbslots[subframe_idx]); - } - } - else if (st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT) - { - for (ch = 0; ch < hDirACRend->hOutSetup.nchan_out_woLFE; ch++) - { - for (slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[subframe_idx]; slot_idx++) - { - fixedToFloat_arrL(pppQMfFrame_ts_re_fx[ch][slot_idx], pppQMfFrame_ts_re[ch][slot_idx], Q6, hSpatParamRendCom->num_freq_bands); - fixedToFloat_arrL(pppQMfFrame_ts_im_fx[ch][slot_idx], pppQMfFrame_ts_im[ch][slot_idx], Q6, hSpatParamRendCom->num_freq_bands); - } - } - } - else - { - Word16 outchannels = add(hDirACRend->hOutSetup.nchan_out_woLFE, hDirACRend->hOutSetup.num_lfe); - - IF(hDirACRend->hOutSetup.separateChannelEnabled && (hDirACRend->hOutSetup.output_config == IVAS_AUDIO_CONFIG_5_1 || - hDirACRend->hOutSetup.output_config == IVAS_AUDIO_CONFIG_7_1 || - hDirACRend->hOutSetup.output_config == IVAS_AUDIO_CONFIG_5_1_2 || - hDirACRend->hOutSetup.output_config == IVAS_AUDIO_CONFIG_5_1_4 || - hDirACRend->hOutSetup.output_config == IVAS_AUDIO_CONFIG_7_1_4 || - (hDirACRend->hOutSetup.output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM && st_ivas->hLsSetupCustom->separate_ch_found))) - { - outchannels = add(outchannels, 1); - } - if (!hDirACRend->hOutSetup.separateChannelEnabled || hDirACRend->hOutSetup.output_config != IVAS_AUDIO_CONFIG_LS_CUSTOM) + if ( !hDirACRend->hOutSetup.separateChannelEnabled || hDirACRend->hOutSetup.output_config != IVAS_AUDIO_CONFIG_LS_CUSTOM ) { Word16 tmp_lfe_idx = 0; - for (ch = 0; ch < outchannels; ch++) + for ( ch = 0; ch < outchannels; ch++ ) { - //fixedToFloat_arrL(output_buf_fx[i], output_f[i], Q11, index_slot * hSpatParamRendCom->num_freq_bands + hSpatParamRendCom->num_freq_bands * hSpatParamRendCom->subframe_nbslots[subframe_idx]); - IF((hDirACRend->hOutSetup.num_lfe > 0) && (EQ_16(hDirACRend->hOutSetup.index_lfe[tmp_lfe_idx], ch))) + // fixedToFloat_arrL(output_buf_fx[i], output_f[i], Q11, index_slot * hSpatParamRendCom->num_freq_bands + hSpatParamRendCom->num_freq_bands * hSpatParamRendCom->subframe_nbslots[subframe_idx]); + IF( ( hDirACRend->hOutSetup.num_lfe > 0 ) && ( EQ_16( hDirACRend->hOutSetup.index_lfe[tmp_lfe_idx], ch ) ) ) { - IF(st_ivas->mc_mode == MC_MODE_MCMASA && !hDirACRend->hOutSetup.separateChannelEnabled) + IF( st_ivas->mc_mode == MC_MODE_MCMASA && !hDirACRend->hOutSetup.separateChannelEnabled ) { // Fixed to float - fixedToFloat_arrL(output_buf_fx[ch], output_f[ch], Q11, hSpatParamRendCom->subframe_nbslots[subframe_idx] * hSpatParamRendCom->num_freq_bands + index_slot * hSpatParamRendCom->num_freq_bands); + fixedToFloat_arrL( output_buf_fx[ch], output_f[ch], Q11, hSpatParamRendCom->subframe_nbslots[subframe_idx] * hSpatParamRendCom->num_freq_bands + index_slot * hSpatParamRendCom->num_freq_bands ); } - ELSE IF(st_ivas->mc_mode == MC_MODE_MCMASA && hDirACRend->hOutSetup.separateChannelEnabled) + ELSE IF( st_ivas->mc_mode == MC_MODE_MCMASA && hDirACRend->hOutSetup.separateChannelEnabled ) { /* LFE has been synthesized in the time domain, do nothing. */ } ELSE { // Float to fixed. - fixedToFloat_arrL(output_buf_fx[ch], output_f[ch], Q11, hSpatParamRendCom->subframe_nbslots[subframe_idx] * hSpatParamRendCom->num_freq_bands + index_slot * hSpatParamRendCom->num_freq_bands); + fixedToFloat_arrL( output_buf_fx[ch], output_f[ch], Q11, hSpatParamRendCom->subframe_nbslots[subframe_idx] * hSpatParamRendCom->num_freq_bands + index_slot * hSpatParamRendCom->num_freq_bands ); } - IF(LT_16(tmp_lfe_idx, sub(hDirACRend->hOutSetup.num_lfe, 1))) + IF( LT_16( tmp_lfe_idx, sub( hDirACRend->hOutSetup.num_lfe, 1 ) ) ) { - tmp_lfe_idx = add(tmp_lfe_idx, 1); + tmp_lfe_idx = add( tmp_lfe_idx, 1 ); } } - ELSE IF((hDirACRend->hOutSetup.separateChannelEnabled) && EQ_16(hDirACRend->hOutSetup.separateChannelIndex, ch)) + ELSE IF( ( hDirACRend->hOutSetup.separateChannelEnabled ) && EQ_16( hDirACRend->hOutSetup.separateChannelIndex, ch ) ) { /* The separated channel is already set to output_f[hOutSetup.separateChannelIndex]. Thus, the separated * channel is combined with the synthesized channels here. */ @@ -5816,7 +5648,7 @@ void ivas_dirac_dec_render_sf_fx( ELSE { // Fixed to float - fixedToFloat_arrL(output_buf_fx[ch], output_f[ch], Q8, hSpatParamRendCom->num_freq_bands * hSpatParamRendCom->subframe_nbslots[subframe_idx] + index_slot * hSpatParamRendCom->num_freq_bands); + fixedToFloat_arrL(output_buf_fx[ch], output_f[ch], Q11, hSpatParamRendCom->num_freq_bands * hSpatParamRendCom->subframe_nbslots[subframe_idx] + index_slot * hSpatParamRendCom->num_freq_bands); } } } diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index e875c9dce..ebf6b23e2 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -1361,11 +1361,12 @@ ivas_error ivas_init_decoder_fx( } IF ( ( error = ivas_ls_custom_output_init_fx( st_ivas ) ) == IVAS_ERR_OK ) { +#ifndef IVAS_FLOAT_FIXED st_ivas->hOutSetup.ls_azimuth = st_ivas->hLsSetupCustom->ls_azimuth; st_ivas->hOutSetup.ls_elevation = st_ivas->hLsSetupCustom->ls_elevation; st_ivas->hIntSetup.ls_azimuth = st_ivas->hLsSetupCustom->ls_azimuth; st_ivas->hIntSetup.ls_elevation = st_ivas->hLsSetupCustom->ls_elevation; -#ifdef IVAS_FLOAT_FIXED +#else st_ivas->hOutSetup.ls_azimuth_fx = st_ivas->hLsSetupCustom->ls_azimuth_fx; st_ivas->hOutSetup.ls_elevation_fx = st_ivas->hLsSetupCustom->ls_elevation_fx; st_ivas->hIntSetup.ls_azimuth_fx = st_ivas->hLsSetupCustom->ls_azimuth_fx; @@ -1393,7 +1394,7 @@ ivas_error ivas_init_decoder_fx( /* check for a speaker at (0, 0) if minimum speaker count is available */ FOR ( i = 0; i < st_ivas->hOutSetup.nchan_out_woLFE; i++ ) { - IF ( st_ivas->hOutSetup.ls_azimuth[i] == 0.0f && st_ivas->hOutSetup.ls_elevation[i] == 0.0f ) + IF ( L_shr(st_ivas->hOutSetup.ls_azimuth_fx[i], Q22) == 0 && L_shr(st_ivas->hOutSetup.ls_elevation_fx[i], Q22) == 0 ) { st_ivas->hIntSetup.separateChannelIndex = i; st_ivas->hLsSetupCustom->separate_ch_found = 1; diff --git a/lib_dec/ivas_ism_renderer.c b/lib_dec/ivas_ism_renderer.c index 1b45dbe78..7c6eeeaa4 100644 --- a/lib_dec/ivas_ism_renderer.c +++ b/lib_dec/ivas_ism_renderer.c @@ -127,7 +127,7 @@ ivas_error ivas_ism_renderer_open_fx( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for ISM renderer\n" ) ); } - IF ( st_ivas->hIntSetup.is_loudspeaker_setup && st_ivas->hIntSetup.ls_azimuth != NULL && st_ivas->hIntSetup.ls_elevation != NULL && st_ivas->hEFAPdata == NULL ) + IF ( st_ivas->hIntSetup.is_loudspeaker_setup && st_ivas->hIntSetup.ls_azimuth_fx != NULL && st_ivas->hIntSetup.ls_elevation_fx != NULL && st_ivas->hEFAPdata == NULL ) { IF ( ( error = efap_init_data_fx( &( st_ivas->hEFAPdata ), st_ivas->hIntSetup.ls_azimuth_fx, st_ivas->hIntSetup.ls_elevation_fx, st_ivas->hIntSetup.nchan_out_woLFE, EFAP_MODE_EFAP ) ) != IVAS_ERR_OK ) { diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index d94f11435..6460c0c5d 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -95,17 +95,14 @@ static Word16 ceil_fx16( Word16 inp, Word16 Q ) *--------------------------------------------------------------------------*/ #ifdef IVAS_FLOAT_FIXED -ivas_error ivas_jbm_dec_tc( +ivas_error ivas_jbm_dec_tc_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - float *data /* o : transport channel signals */ + Word32 *data_fx ) { Word16 n, output_frame, nchan_out, i, j; - Decoder_State *st, **sts; /* used for bitstream handling */ - float *p_output[MAX_TRANSPORT_CHANNELS]; /* 'float' buffer for output synthesis */ -#ifdef IVAS_FLOAT_FIXED + Decoder_State *st; /* used for bitstream handling */ Word32 *p_output_fx[MAX_TRANSPORT_CHANNELS]; /* 'float' buffer for output synthesis */ -#endif Word16 nchan_remapped; Word16 nb_bits_metadata[MAX_SCE + 1]; Word32 output_Fs, ivas_total_brate; @@ -115,7 +112,6 @@ ivas_error ivas_jbm_dec_tc( Word32 ism_total_brate; Word16 s; - MCT_DEC_HANDLE hMCT; CPE_DEC_HANDLE hCPE; SCE_DEC_HANDLE hSCE; push_wmops( "ivas_jbm_dec_tc" ); @@ -125,21 +121,17 @@ ivas_error ivas_jbm_dec_tc( *----------------------------------------------------------------*/ output_Fs = st_ivas->hDecoderConfig->output_Fs; + move32(); nchan_out = st_ivas->hTcBuffer->nchan_transport_jbm; + move16(); output_config = st_ivas->hDecoderConfig->output_config; ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; + move32(); output_frame = (Word16) ( output_Fs / FRAMES_PER_SEC ); FOR( n = 0; n < MAX_TRANSPORT_CHANNELS; n++ ) { -#if 1 // TODO: To be removed later - p_output[n] = st_ivas->p_output_f[n]; - IF( p_output[n] != NULL ) - { - set_zero( p_output[n], L_FRAME48k ); - } -#endif p_output_fx[n] = st_ivas->p_output_fx[n]; IF( p_output_fx[n] != NULL ) { @@ -151,20 +143,17 @@ ivas_error ivas_jbm_dec_tc( { FOR( n = 0; n < ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); n++ ) { + set_zero_fx(st_ivas->p_output_fx[n], L_FRAME48k); st_ivas->hTcBuffer->tc_fx[n] = st_ivas->p_output_fx[n]; -#if 1 // TODO: To be removed later - set_zero(st_ivas->p_output_f[n], L_FRAME48k); - st_ivas->hTcBuffer->tc[n] = st_ivas->p_output_f[n]; -#ifndef MSAN_FIX - floatToFixed_arrL( st_ivas->hTcBuffer->tc[n], st_ivas->hTcBuffer->tc_fx[n], Q11, L_FRAME48k ); -#endif -#endif } #ifdef MSAN_FIX st_ivas->hTcBuffer->no_channels = ivas_get_nchan_buffers_dec(st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate); #endif } + Word16 ch; + + /*----------------------------------------------------------------* * Decoding + pre-rendering *----------------------------------------------------------------*/ @@ -180,7 +169,7 @@ ivas_error ivas_jbm_dec_tc( ELSE IF( st_ivas->ivas_format == STEREO_FORMAT ) { st_ivas->hCPE[0]->element_brate = ivas_total_brate; - Word16 q_output = 11; + Word16 q_output = 11; move16(); set32_fx( &p_output_fx[0][0], 0, L_FRAME48k ); set32_fx( &p_output_fx[1][0], 0, L_FRAME48k ); @@ -201,9 +190,8 @@ ivas_error ivas_jbm_dec_tc( hp20_fix32( p_output_fx[n], output_frame, st_ivas->mem_hp20_out_fx[n], output_Fs ); } - IF( st_ivas->renderer_type == RENDERER_MC && EQ_16( st_ivas->hDecoderConfig->nchan_out, 1 ) ) + IF( EQ_32( st_ivas->renderer_type, RENDERER_MC ) && EQ_16( st_ivas->hDecoderConfig->nchan_out, 1 ) ) { -#ifdef IVAS_FLOAT_FIXED s = sub( Q16, Q11 ); s = sub( s, find_guarded_bits_fx( st_ivas->nchan_transport ) ); FOR( i = 0; i < max( st_ivas->hDecoderConfig->nchan_out, st_ivas->nchan_transport ); ++i ) @@ -215,7 +203,6 @@ ivas_error ivas_jbm_dec_tc( { Scale_sig32( p_output_fx[i], output_frame, negate( s ) ); } -#endif } } ELSE IF( st_ivas->ivas_format == ISM_FORMAT ) @@ -231,10 +218,8 @@ ivas_error ivas_jbm_dec_tc( { return error; } - -#ifdef IVAS_FLOAT_FIXED Word16 Q_cngNoiseLevel[MAX_SCE]; - FOR( Word16 ch = 0; ch < 4; ch++ ) + FOR( ch = 0; ch < 4; ch++ ) { IF( st_ivas->hSCE[ch] != NULL ) { @@ -242,7 +227,6 @@ ivas_error ivas_jbm_dec_tc( } } ivas_ism_dtx_limit_noise_energy_for_near_silence_fx( st_ivas->hSCE, st_ivas->hISMDTX.sce_id_dtx, st_ivas->nchan_transport, Q_cngNoiseLevel ); -#endif // IVAS_FLOAT_FIXED } ELSE IF( st_ivas->ism_mode == ISM_MODE_PARAM ) { @@ -303,50 +287,11 @@ ivas_error ivas_jbm_dec_tc( { st = ( st_ivas->nSCE > 0 ) ? st_ivas->hSCE[0]->hCoreCoder[0] : st_ivas->hCPE[0]->hCoreCoder[0]; -#ifdef IVAS_FLOAT_FIXED - // Float to fix conversion ends here. - IF( ( error = ivas_masa_decode_fx( st_ivas, st, &nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) { return error; } - // Fix to float conversion starts here. - IF( st_ivas->hSpatParamRendCom != NULL ) - { - FOR( i = 0; i < st_ivas->hSpatParamRendCom->dirac_md_buffer_length; i++ ) - { - FOR( j = 0; j < st_ivas->hSpatParamRendCom->num_freq_bands; j++ ) - { - st_ivas->hSpatParamRendCom->energy_ratio1[i][j] = fix_to_float( st_ivas->hSpatParamRendCom->energy_ratio1_fx[i][j], 30 ); - st_ivas->hSpatParamRendCom->diffuseness_vector[i][j] = fix_to_float( st_ivas->hSpatParamRendCom->diffuseness_vector_fx[i][j], 30 ); - IF( EQ_32( st_ivas->hQMetaData->no_directions, 2 ) ) - { - st_ivas->hSpatParamRendCom->energy_ratio2[i][j] = fix_to_float( st_ivas->hSpatParamRendCom->energy_ratio2_fx[i][j], 30 ); - st_ivas->hSpatParamRendCom->spreadCoherence2[i][j] = fix_to_float( st_ivas->hSpatParamRendCom->spreadCoherence2_fx[i][j], 15 ); - } - st_ivas->hSpatParamRendCom->surroundingCoherence[i][j] = fix_to_float( st_ivas->hSpatParamRendCom->surroundingCoherence_fx[i][j], 15 ); - st_ivas->hSpatParamRendCom->spreadCoherence[i][j] = fix_to_float( st_ivas->hSpatParamRendCom->spreadCoherence_fx[i][j], 15 ); - } - } - } - st_ivas->hMasa->data.dir_decode_quality = fix16_to_float( st_ivas->hMasa->data.dir_decode_quality_fx, Q14 ); - IF( st_ivas->hSpatParamRendCom != NULL ) - { - FOR( i = 0; i < st_ivas->hSpatParamRendCom->numIsmDirections; i++ ) - { - FOR( Word16 block = 0; block < MAX_PARAM_SPATIAL_SUBFRAMES; block++ ) - { - FOR( Word16 b = 0; b < st_ivas->hSpatParamRendCom->num_freq_bands; b++ ) - { - st_ivas->hMasaIsmData->energy_ratio_ism[i][block][b] = fix_to_float( st_ivas->hMasaIsmData->energy_ratio_ism_fx[i][block][b], Q30 ); - } - } - } - } - // Fixed to float conversion ends here. -#endif - IF( output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) { ivas_jbm_dec_copy_masa_meta_to_buffer( st_ivas ); @@ -397,159 +342,10 @@ ivas_error ivas_jbm_dec_tc( } ELSE IF( GT_16( st_ivas->nCPE, 1 ) ) { -#ifdef IVAS_FLOAT_FIXED -#if 1 // Float to fix - - Word16 ch, nCPE, cpe_id; - Word16 l; - - nCPE = st_ivas->nCPE; - move16(); - hMCT = st_ivas->hMCT; - FOR( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) - { - hCPE = st_ivas->hCPE[cpe_id]; - sts = hCPE->hCoreCoder; - - - FOR( n = 0; n < CPE_CHANNELS; n++ ) - { - st = hCPE->hCoreCoder[n]; - IF( sts[n]->mct_chan_mode != MCT_CHAN_MODE_IGNORE ) - { - // u8bit to 16bit - FOR( l = 0; l < IGF_START_MX; l++ ) - { - sts[n]->hIGFDec->infoTCXNoise_evs[l] = (Word16) sts[n]->hIGFDec->infoTCXNoise[l]; - } - } - - //if ( st->hTcxDec && st->hTcxDec->conLastFrameLevel_e < 0 ) - //{ - // st->hTcxDec->conLastFrameLevel_e = 0; - //} - //if ( st->hTcxDec && st->hTcxDec->conNoiseLevelMemory_e[0] < 0 ) - //{ - // set16_fx( st->hTcxDec->conNoiseLevelMemory_e, 0, PLC_MIN_STAT_BUFF_SIZE ); - //} - IF( st->hTcxDec ) - st->hTcxDec->conNoiseLevelIndex = st->hTcxDec->NoiseLevelIndex_bfi; - IF( st->hTcxDec ) - st->hTcxDec->conCurrLevelIndex = st->hTcxDec->CurrLevelIndex_bfi; - /*cldfb struct*/ - - /*------------------fix-to-fix-start---------------------*/ - /*core_switching_post_dec*/ - if ( hCPE->hCoreCoder[n]->hHQ_core != NULL ) - { - hCPE->hCoreCoder[n]->hHQ_core->Q_old_postdec = 0; - hCPE->hCoreCoder[n]->hHQ_core->Q_old_wtda = 0; - } - } - } -#endif // Float to fix - if ( ( error = ivas_mct_dec_fx( st_ivas, p_output_fx, output_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) + IF ( ( error = ivas_mct_dec_fx( st_ivas, p_output_fx, output_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) { return error; } -#if 1 // Fix to float - FOR( cpe_id = 0; cpe_id < nCPE; cpe_id++ ) - { - hCPE = st_ivas->hCPE[cpe_id]; - sts = hCPE->hCoreCoder; - FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) - { - st = hCPE->hCoreCoder[ch]; - IF( sts[ch]->mct_chan_mode != MCT_CHAN_MODE_IGNORE ) - { - // 16bit to u8bit - FOR( l = 0; l < IGF_START_MX; l++ ) - { - sts[ch]->hIGFDec->infoTCXNoise[l] = (uint8_t) sts[ch]->hIGFDec->infoTCXNoise_evs[l]; - } - } - } - - FOR( n = 0; n < 2; n++ ) - { - st = hCPE->hCoreCoder[n]; - sts = hCPE->hCoreCoder; - - for ( int p = 0; p < 640; p++ ) - { - st->hHQ_core->old_outLB[p] = (float) st->hHQ_core->old_out_LB_fx[p] / ( 1u << st->Q_syn ); - } - - /*-------------------cldfb-start-------------------------*/ - - if ( sts[n]->cldfbAna != NULL ) - { - fixedToFloat_arrL( sts[n]->cldfbAna->cldfb_state_fx, sts[n]->cldfbAna->cldfb_state, 10, sts[n]->cldfbAna->cldfb_state_length ); - } - if ( sts[n]->cldfbSyn != NULL ) - { - fixedToFloat_arrL( sts[n]->cldfbSyn->cldfb_state_fx, sts[n]->cldfbSyn->cldfb_state, 4, sts[n]->cldfbSyn->p_filter_length ); - } - if ( sts[n]->cldfbBPF != NULL ) - { - fixedToFloat_arrL( sts[n]->cldfbBPF->cldfb_state_fx, sts[n]->cldfbBPF->cldfb_state, 11, sts[n]->cldfbBPF->cldfb_state_length ); - } - - /*-------------------cldfb-end---------------------------*/ - - IF( sts[n]->hHQ_core != NULL ) - { - fixedToFloat_arr( sts[n]->hHQ_core->old_out_fx, sts[n]->hHQ_core->old_out, 0, L_FRAME48k ); - } - - - /*------------------reset-code-start---------------------*/ - - /* reset WB BWE buffers */ - - IF( NE_16( sts[n]->last_extl, WB_BWE ) && EQ_16( sts[n]->extl, WB_BWE ) && sts[n]->hBWE_FD != NULL ) - { - - IF( NE_16( sts[n]->last_extl, SWB_BWE ) && NE_16( sts[n]->last_extl, FB_BWE ) ) - { - sts[n]->hBWE_FD->prev_mode = sts[n]->hBWE_FD->prev_mode; - } - sts[n]->hBWE_FD->prev_L_swb_norm = sts[n]->hBWE_FD->prev_L_swb_norm; - sts[n]->hBWE_FD->prev_flag = sts[n]->hBWE_FD->prev_flag; - } - - /*------------------reset-code-end-----------------------*/ - } - } - - - IF( st_ivas->hCPE[0]->hCoreCoder[0]->igf ) - { - IF( !hMCT->currBlockDataCnt ) - { - FOR( cpe_id = 0; cpe_id < nCPE; cpe_id++ ) - { - FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) - { - IF( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->igf ) - { - FOR( l = 0; l < IGF_START_MX; l++ ) - { - st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hIGFDec->infoTCXNoise[l] = (uint8_t) st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hIGFDec->infoTCXNoise_evs[l]; - } - } - } - } - } - } - - //IF( st_ivas->hLsSetUpConversion && st_ivas->hLsSetUpConversion->targetEnergyPrev ) - //me2f_buf( st_ivas->hLsSetUpConversion->targetEnergyPrev_fx[0], st_ivas->hLsSetUpConversion->te_prev_exp, st_ivas->hLsSetUpConversion->targetEnergyPrev[0], st_ivas->hLsSetUpConversion->sfbCnt ); - //IF( st_ivas->hLsSetUpConversion && st_ivas->hLsSetUpConversion->dmxEnergyPrev_fx ) - //me2f_buf( st_ivas->hLsSetUpConversion->dmxEnergyPrev_fx[0], st_ivas->hLsSetUpConversion->dmx_prev_exp, st_ivas->hLsSetUpConversion->dmxEnergyPrev[0], st_ivas->hLsSetUpConversion->sfbCnt ); - -#endif // Fix to float -#endif } /* TCs remapping */ @@ -557,26 +353,21 @@ ivas_error ivas_jbm_dec_tc( IF( st_ivas->sba_dirac_stereo_flag ) { nchan_remapped = nchan_out; + move16(); IF( EQ_16( st_ivas->ivas_format, SBA_FORMAT ) ) { -#ifdef IVAS_FLOAT_FIXED -#if 1 /*Float to Fixed changes */ FOR( i = 0; i < st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport; i++ ) { Scale_sig32( p_output_fx[i], output_frame, sub( Q14, Q11 ) ); } SPAR_DEC_HANDLE hSpar = st_ivas->hSpar; Word16 nchan_transport; - //num_bands_out = hSpar->hFbMixer->pFb->filterbank_num_bands; nchan_transport = hSpar->hMdDec->spar_md_cfg.nchan_transport; nchan_out = nchan_transport; - //Word16 num_out_ch; - //num_out_ch = hSpar->hMdDec->spar_md_cfg.num_umx_chs; + move16(); hSpar->hMdDec->Q_mixer_mat = 31; - //Word16 num_in_ch; - //num_in_ch = hSpar->hMdDec->spar_md_cfg.num_umx_chs; -#endif + move16(); ivas_agc_dec_process_fx( st_ivas->hSpar->hAgcDec, ( p_output_fx ), ( p_output_fx ), st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, output_frame ); IF( st_ivas->hSpar->hPCA != NULL ) @@ -585,18 +376,13 @@ ivas_error ivas_jbm_dec_tc( } ivas_spar_dec_gen_umx_mat_fx( st_ivas->hSpar->hMdDec, st_ivas->nchan_transport, IVAS_MAX_NUM_BANDS, st_ivas->bfi, ivas_get_spar_dec_md_num_subframes(st_ivas->sba_order, ivas_total_brate, st_ivas->last_active_ivas_total_brate)); -#endif } - -#ifdef IVAS_FLOAT_FIXED { Word16 q; - //float max_val = 0.0; - //int i_max_val_op; hCPE = st_ivas->hCPE[0]; hSCE = st_ivas->hSCE[0]; - //i_max_val_op = (int) max_val; - s = 0; + + s = 0; move16(); FOR( i = 0; i < 2; i++ ) { s = s_min( s, L_norm_arr( p_output_fx[i], L_FRAME48k ) - 11 ) /* Guard bits */; @@ -609,9 +395,12 @@ ivas_error ivas_jbm_dec_tc( IF( EQ_16( hCPE->hStereoDft->first_frame, 1 ) ) { hCPE->hStereoDft->q_smoothed_nrg = Q6; // hCPE->hStereoDft->q_dft; + move16(); hCPE->hStereoDft->q_ap_delay_mem_fx = hCPE->hStereoDft->q_dft; + move16(); } q = hCPE->hStereoDft->q_dft; + move16(); scale_sig32(hCPE->input_mem_BPF_fx[0], STEREO_DFT32MS_OVL_16k, sub(hCPE->hStereoDft->q_dft, Q11)); FOR( i = 0; i < CPE_CHANNELS; ++i ) { @@ -620,9 +409,9 @@ ivas_error ivas_jbm_dec_tc( } IF( hCPE->hCoreCoder[0] != NULL ) { - floatToFixed_arrL( &hCPE->hCoreCoder[0]->hHQ_core->old_outLB[0], &hCPE->hCoreCoder[0]->hHQ_core->old_outLB_fx[0], q, L_FRAME32k ); + Copy_Scale_sig_16_32(hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx, hCPE->hCoreCoder[0]->hHQ_core->old_outLB_fx,L_FRAME32k,q - hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda_LB); + Copy_Scale_sig_16_32(hCPE->hCoreCoder[0]->hHQ_core->old_out_fx, hCPE->hCoreCoder[0]->hHQ_core->oldOut_fx,L_FRAME48k,q - hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda); hCPE->hCoreCoder[0]->hHQ_core->q_old_outLB_fx = q; - floatToFixed_arrL( &hCPE->hCoreCoder[0]->hHQ_core->old_out[0], &hCPE->hCoreCoder[0]->hHQ_core->oldOut_fx[0], q, L_FRAME48k ); } IF( hCPE->hStereoDft != NULL ) { @@ -670,13 +459,13 @@ ivas_error ivas_jbm_dec_tc( hSCE->q_save_synth_fx = hCPE->hStereoDft->q_dft; } st_ivas->hSpar->hMdDec->Q_mixer_mat = 30; - FOR( int ii = 0; ii < CPE_CHANNELS; ii++ ) + FOR( Word16 ii = 0; ii < CPE_CHANNELS; ii++ ) { scale_sig32( hCPE->output_mem_fx[ii], NS2SA_fx2( st_ivas->hDecoderConfig->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); hCPE->q_output_mem_fx[ii] = hCPE->hStereoDft->q_dft; } #ifdef MSAN_FIX - FOR( int ii = 0; ii < CPE_CHANNELS; ii++ ) + FOR( Word16 ii = 0; ii < CPE_CHANNELS; ii++ ) { Scale_sig32( &hCPE->prev_synth_fx[ii][0], NS2SA( st_ivas->hDecoderConfig->output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ), hCPE->q_prev_synth_fx - 11 ); } @@ -708,8 +497,8 @@ ivas_error ivas_jbm_dec_tc( IF( hCPE->hCoreCoder[0] != NULL ) { - fixedToFloat_arrL( &hCPE->hCoreCoder[0]->hHQ_core->old_outLB_fx[0], &hCPE->hCoreCoder[0]->hHQ_core->old_outLB[0], q, L_FRAME32k ); - fixedToFloat_arrL( &hCPE->hCoreCoder[0]->hHQ_core->oldOut_fx[0], &hCPE->hCoreCoder[0]->hHQ_core->old_out[0], q, L_FRAME48k ); + Copy_Scale_sig_32_16( hCPE->hCoreCoder[0]->hHQ_core->old_outLB_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx, L_FRAME32k, hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda_LB - q ); + Copy_Scale_sig_32_16( hCPE->hCoreCoder[0]->hHQ_core->oldOut_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_fx, L_FRAME48k, hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda - q ); } IF( hCPE->hStereoDft != NULL ) { @@ -749,13 +538,12 @@ ivas_error ivas_jbm_dec_tc( hCPE->hStereoDft->q_ap_fade_mem_fx = Q11; } st_ivas->hSpar->hMdDec->Q_mixer_mat = 30; - for ( int ii = 0; ii < CPE_CHANNELS; ii++ ) + FOR ( Word16 ii = 0; ii < CPE_CHANNELS; ii++ ) { scale_sig32( hCPE->output_mem_fx[ii], NS2SA_fx2( st_ivas->hDecoderConfig->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); hCPE->q_output_mem_fx[ii] = Q11; } } -#endif } ELSE IF( st_ivas->ivas_format == MASA_FORMAT && ivas_total_brate < MASA_STEREO_MIN_BITRATE && ( ivas_total_brate > IVAS_SID_5k2 || ( ivas_total_brate <= IVAS_SID_5k2 && st_ivas->nCPE > 0 && st_ivas->hCPE[0]->nchan_out == 1 ) ) ) { @@ -772,43 +560,38 @@ ivas_error ivas_jbm_dec_tc( { nchan_remapped = ivas_sba_remapTCs_fx( p_output_fx, st_ivas, output_frame ); - IF( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) + IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) { num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( st_ivas->sba_analysis_order, ivas_total_brate, st_ivas->last_active_ivas_total_brate ); -#ifdef IVAS_FLOAT_FIXED -#if 1 - Word16 ch; + SPAR_DEC_HANDLE hSpar = st_ivas->hSpar; Word16 Q_p_output = 14; + move16(); Word16 nchan_transport; - //num_bands_out = hSpar->hFbMixer->pFb->filterbank_num_bands; + nchan_transport = hSpar->hMdDec->spar_md_cfg.nchan_transport; + move16(); nchan_out = nchan_transport; + move16(); FOR( ch = 0; ch < nchan_transport; ch++ ) { Scale_sig32( p_output_fx[ch], output_frame, sub( Q_p_output, Q11 ) ); } - //Word16 num_out_ch; - //num_out_ch = hSpar->hMdDec->spar_md_cfg.num_umx_chs; + hSpar->hMdDec->Q_mixer_mat = 31; - //Word16 num_in_ch; - //num_in_ch = hSpar->hMdDec->spar_md_cfg.num_umx_chs; -#endif + move16(); + ivas_sba_mix_matrix_determiner_fx( st_ivas->hSpar, p_output_fx, st_ivas->bfi, nchan_remapped, output_frame, num_md_sub_frames ); -#if 1 /*Fixed to float changes */ FOR( Word16 c = 0; c < nchan_transport; c++ ) { Scale_sig32( p_output_fx[c], output_frame, 11 ); } -#endif -#endif } - else if ( st_ivas->renderer_type != RENDERER_DISABLE ) + ELSE IF ( st_ivas->renderer_type != RENDERER_DISABLE ) { -#ifdef IVAS_FLOAT_FIXED Word16 size = st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport; - if ( st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport == 3 ) - size += 1; + IF ( st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport == 3 ) + size = add( size, 1 ); FOR( i = 0; i < size; i++ ) { @@ -816,20 +599,17 @@ ivas_error ivas_jbm_dec_tc( } ivas_spar_dec_agc_pca_fx( st_ivas, p_output_fx, output_frame ); -#endif } } - IF( st_ivas->ivas_format == MASA_FORMAT ) + IF( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) ) { -#ifdef IVAS_FLOAT_FIXED Word16 q_shift = 0; ivas_masa_prerender_fx( st_ivas, p_output_fx, &q_shift, output_frame, nchan_remapped ); FOR( i = 0; i < 2; i++ ) { Scale_sig32( p_output_fx[i], output_frame, negate( q_shift ) ); } -#endif } ELSE IF( st_ivas->ivas_format == SBA_FORMAT && ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) { @@ -868,23 +648,28 @@ ivas_error ivas_jbm_dec_tc( /* set ISM parameters and decode ISM metadata in OMASA format */ -#ifdef IVAS_FLOAT_FIXED - Word16 q_output = 11; + Word16 q_output = 11; move16(); // NOTE: the following is done to calculate the number of hIsmMetaData indices Word16 tmp_nchan_ism; - IF( st_ivas->ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ ) - tmp_nchan_ism = 1; - ELSE IF( st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ ) + IF(st_ivas->ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ) + { + tmp_nchan_ism = 1; + move16(); + } + ELSE IF(st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ) + { tmp_nchan_ism = 0; - ELSE + move16(); + } + ELSE{ tmp_nchan_ism = st_ivas->nchan_ism; - ///////////////////////////////////// Float to fix conversion starts here. /////////////////////////////////// + move16(); + } FOR( n = 0; n < tmp_nchan_ism; n++ ) { set32_fx( p_output_fx[n], 0, L_FRAME48k ); } - ///////////////////////////////////// Float to fix conversion ends here. /////////////////////////////////// /* MASA metadata decoding */ IF( ( error = ivas_masa_decode_fx( st_ivas, st_ivas->hCPE[0]->hCoreCoder[0], &nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) @@ -917,7 +702,7 @@ ivas_error ivas_jbm_dec_tc( } /* shifting both the channels from variable q_output to constant Q-factor (Q11) */ - FOR( int k = 0; k < output_frame; k++ ) + FOR( Word16 k = 0; k < output_frame; k++ ) { p_output_fx[0][k] = L_shr( p_output_fx[0][k], 11 - q_output ); move32(); @@ -959,39 +744,6 @@ ivas_error ivas_jbm_dec_tc( ivas_jbm_dec_copy_masa_meta_to_buffer( st_ivas ); } - //////////////////////////// Fix to float conversion starts here. /////////////////////////////////// - IF( st_ivas->hSpatParamRendCom != NULL ) - { - FOR( i = 0; i < st_ivas->hSpatParamRendCom->dirac_md_buffer_length; i++ ) - { - FOR( j = 0; j < st_ivas->hSpatParamRendCom->num_freq_bands; j++ ) - { - st_ivas->hSpatParamRendCom->energy_ratio1[i][j] = fix_to_float( st_ivas->hSpatParamRendCom->energy_ratio1_fx[i][j], 30 ); - st_ivas->hSpatParamRendCom->diffuseness_vector[i][j] = fix_to_float( st_ivas->hSpatParamRendCom->diffuseness_vector_fx[i][j], 30 ); - IF( EQ_32( st_ivas->hQMetaData->no_directions, 2 ) ) - { - st_ivas->hSpatParamRendCom->energy_ratio2[i][j] = fix_to_float( st_ivas->hSpatParamRendCom->energy_ratio2_fx[i][j], 30 ); - st_ivas->hSpatParamRendCom->spreadCoherence2[i][j] = fix_to_float( st_ivas->hSpatParamRendCom->spreadCoherence2_fx[i][j], 15 ); - } - st_ivas->hSpatParamRendCom->surroundingCoherence[i][j] = fix_to_float( st_ivas->hSpatParamRendCom->surroundingCoherence_fx[i][j], 15 ); - st_ivas->hSpatParamRendCom->spreadCoherence[i][j] = fix_to_float( st_ivas->hSpatParamRendCom->spreadCoherence_fx[i][j], 15 ); - } - } - } - st_ivas->hMasa->data.dir_decode_quality = fix16_to_float( st_ivas->hMasa->data.dir_decode_quality_fx, Q14 ); - IF( st_ivas->hSpatParamRendCom != NULL ) - { - FOR( i = 0; i < st_ivas->hSpatParamRendCom->numIsmDirections; i++ ) - { - FOR( Word16 block = 0; block < MAX_PARAM_SPATIAL_SUBFRAMES; block++ ) - { - FOR( Word16 b = 0; b < st_ivas->hSpatParamRendCom->num_freq_bands; b++ ) - { - st_ivas->hMasaIsmData->energy_ratio_ism[i][block][b] = fix_to_float( st_ivas->hMasaIsmData->energy_ratio_ism_fx[i][block][b], Q30 ); - } - } - } - } IF( NE_16( output_q, Q11 ) ) { FOR( n = 0; n < s_max( getNumChanSynthesis( st_ivas ), nchan_transport_ism + st_ivas->nchan_transport ); n++ ) @@ -999,29 +751,21 @@ ivas_error ivas_jbm_dec_tc( Scale_sig32( p_output_fx[n], output_frame, sub( Q11, output_q ) ); } } - /////////////////////////////////// Fixed to float conversion ends here. /////////////////////////////////// -#endif + } ELSE IF( st_ivas->ivas_format == SBA_ISM_FORMAT ) { - int16_t nchan_ism, sba_ch_idx; + Word16 nchan_ism, sba_ch_idx; set_s( nb_bits_metadata, 0, MAX_SCE + 1 ); nchan_ism = st_ivas->nchan_ism; IF( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { /* set ISM parameters and decode ISM metadata in OSBA format */ -#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 @@ -1031,12 +775,10 @@ ivas_error ivas_jbm_dec_tc( } /* SBA metadata decoding */ -#ifdef IVAS_FLOAT_FIXED IF( ( error = ivas_spar_dec_fx( st_ivas, nb_bits_metadata ) ) != IVAS_ERR_OK ) { return error; } -#endif IF( EQ_16( st_ivas->nchan_transport, CPE_CHANNELS ) && GE_16( st_ivas->nCPE, 1 ) ) { @@ -1044,7 +786,7 @@ ivas_error ivas_jbm_dec_tc( } /* core-decoding of transport channels */ - Word16 q_output = 11; + Word16 q_output = 11; move16(); IF( EQ_16( st_ivas->nSCE, 1 ) ) { @@ -1071,202 +813,40 @@ ivas_error ivas_jbm_dec_tc( } ELSE IF( GT_16( st_ivas->nCPE, 1 ) ) { -#ifdef IVAS_FLOAT_FIXED -#if 1 // Float to fix - Word16 ch, nCPE, cpe_id; - Word16 l; - - nCPE = st_ivas->nCPE; - move16(); - hMCT = st_ivas->hMCT; - FOR( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) + IF ( ( error = ivas_mct_dec_fx( st_ivas, p_output_fx, output_frame, nb_bits_metadata[0] + nb_bits_metadata[1] ) ) != IVAS_ERR_OK ) { - hCPE = st_ivas->hCPE[cpe_id]; - sts = hCPE->hCoreCoder; - - - FOR( n = 0; n < CPE_CHANNELS; n++ ) - { - st = hCPE->hCoreCoder[n]; - - IF( sts[n]->mct_chan_mode != MCT_CHAN_MODE_IGNORE ) - { - FOR( l = 0; l < IGF_START_MX; l++ ) - { - sts[n]->hIGFDec->infoTCXNoise_evs[l] = (Word16) sts[n]->hIGFDec->infoTCXNoise[l]; - } - } - //if ( st->hTcxDec && st->hTcxDec->conLastFrameLevel_e < 0 ) - //{ - // st->hTcxDec->conLastFrameLevel_e = 0; - //} - //if ( st->hTcxDec && st->hTcxDec->conNoiseLevelMemory_e[0] < 0 ) - //{ - // set16_fx( st->hTcxDec->conNoiseLevelMemory_e, 0, PLC_MIN_STAT_BUFF_SIZE ); - //} - IF( st->hTcxDec ) - st->hTcxDec->conNoiseLevelIndex = st->hTcxDec->NoiseLevelIndex_bfi; - IF( st->hTcxDec ) - st->hTcxDec->conCurrLevelIndex = st->hTcxDec->CurrLevelIndex_bfi; - - /*------------------fix-to-fix-start---------------------*/ - /*core_switching_post_dec*/ - if ( hCPE->hCoreCoder[n]->hHQ_core != NULL ) - { - hCPE->hCoreCoder[n]->hHQ_core->Q_old_postdec = 0; - hCPE->hCoreCoder[n]->hHQ_core->Q_old_wtda = 0; - } - } + return error; } + } + IF ( st_ivas->sba_dirac_stereo_flag ) + { + FOR( i = 0; i < st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport; i++ ) + { + Scale_sig32( p_output_fx[i + sba_ch_idx], output_frame, sub( Q14, Q11 ) ); + } + SPAR_DEC_HANDLE hSpar = st_ivas->hSpar; + Word16 nchan_transport; + nchan_transport = hSpar->hMdDec->spar_md_cfg.nchan_transport; move16(); + nchan_out = nchan_transport; move16(); + hSpar->hMdDec->Q_mixer_mat = 31; move16(); + ivas_agc_dec_process_fx( st_ivas->hSpar->hAgcDec, ( p_output_fx + sba_ch_idx ), ( p_output_fx + sba_ch_idx ), st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, output_frame ); -#endif // Float to fix - if ( ( error = ivas_mct_dec_fx( st_ivas, p_output_fx, output_frame, nb_bits_metadata[0] + nb_bits_metadata[1] ) ) != IVAS_ERR_OK ) + IF( st_ivas->hSpar->hPCA != NULL ) { - return error; + ivas_pca_dec_fx( st_ivas->hSpar->hPCA, output_frame, st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->hDecoderConfig->last_ivas_total_brate, st_ivas->bfi, &p_output_fx[sba_ch_idx] ); } -#if 1 // Fix to float - FOR( cpe_id = 0; cpe_id < nCPE; cpe_id++ ) + ivas_spar_dec_gen_umx_mat_fx( st_ivas->hSpar->hMdDec, st_ivas->nchan_transport, IVAS_MAX_NUM_BANDS, st_ivas->bfi, ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ) ); { - hCPE = st_ivas->hCPE[cpe_id]; - sts = hCPE->hCoreCoder; - FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) + Word16 q; + hCPE = st_ivas->hCPE[0]; + hSCE = st_ivas->hSCE[0]; + s = 0; move16(); + FOR( i = 0; i < 2; i++ ) { - st = hCPE->hCoreCoder[ch]; - IF( sts[ch]->mct_chan_mode != MCT_CHAN_MODE_IGNORE ) - { - // 16bit to u8bit - FOR( l = 0; l < IGF_START_MX; l++ ) - { - sts[ch]->hIGFDec->infoTCXNoise[l] = (uint8_t) sts[ch]->hIGFDec->infoTCXNoise_evs[l]; - } - } + s = s_min( s, L_norm_arr( p_output_fx[sba_ch_idx + i], L_FRAME48k ) - 11 /* Guard bits */ ); } - - FOR( n = 0; n < 2; n++ ) - { - st = hCPE->hCoreCoder[n]; - sts = hCPE->hCoreCoder; - - for ( int p = 0; p < 640; p++ ) - { - st->hHQ_core->old_outLB[p] = (float) st->hHQ_core->old_out_LB_fx[p] / ( 1u << st->Q_syn ); - } - - /*-------------------cldfb-start-------------------------*/ - - /*note : cldfb_size here signifies the original size which was assigned to cldfb_state_fx buffer not its current size*/ - - if ( sts[n]->cldfbAna != NULL ) - { - fixedToFloat_arrL( sts[n]->cldfbAna->cldfb_state_fx, sts[n]->cldfbAna->cldfb_state, 10, sts[n]->cldfbAna->cldfb_state_length ); - } - if ( sts[n]->cldfbSyn != NULL ) - { - fixedToFloat_arrL( sts[n]->cldfbSyn->cldfb_state_fx, sts[n]->cldfbSyn->cldfb_state, 4, sts[n]->cldfbSyn->p_filter_length ); - } - if ( sts[n]->cldfbBPF != NULL ) - { - fixedToFloat_arrL( sts[n]->cldfbBPF->cldfb_state_fx, sts[n]->cldfbBPF->cldfb_state, 11, sts[n]->cldfbBPF->cldfb_state_length ); - } - - /*-------------------cldfb-end---------------------------*/ - - IF( sts[n]->hHQ_core != NULL ) - { - fixedToFloat_arr( sts[n]->hHQ_core->old_out_fx, sts[n]->hHQ_core->old_out, 0, L_FRAME48k ); - } - /*------------------reset-code-start---------------------*/ - - - /* reset WB BWE buffers */ - - IF( NE_16( sts[n]->last_extl, WB_BWE ) && EQ_16( sts[n]->extl, WB_BWE ) && sts[n]->hBWE_FD != NULL ) - { - - IF( NE_16( sts[n]->last_extl, SWB_BWE ) && NE_16( sts[n]->last_extl, FB_BWE ) ) - { - sts[n]->hBWE_FD->prev_mode = sts[n]->hBWE_FD->prev_mode; - } - sts[n]->hBWE_FD->prev_L_swb_norm = sts[n]->hBWE_FD->prev_L_swb_norm; - sts[n]->hBWE_FD->prev_flag = sts[n]->hBWE_FD->prev_flag; - } - } - } - - - IF( st_ivas->hCPE[0]->hCoreCoder[0]->igf ) - { - IF( !hMCT->currBlockDataCnt ) - { - FOR( cpe_id = 0; cpe_id < nCPE; cpe_id++ ) - { - FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) - { - IF( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->igf ) - { - FOR( l = 0; l < IGF_START_MX; l++ ) - { - st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hIGFDec->infoTCXNoise[l] = (uint8_t) st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hIGFDec->infoTCXNoise_evs[l]; - } - } - } - } - } - } - - //IF( st_ivas->hLsSetUpConversion && st_ivas->hLsSetUpConversion->targetEnergyPrev ) - //me2f_buf( st_ivas->hLsSetUpConversion->targetEnergyPrev_fx[0], st_ivas->hLsSetUpConversion->te_prev_exp, st_ivas->hLsSetUpConversion->targetEnergyPrev[0], st_ivas->hLsSetUpConversion->sfbCnt ); - //IF( st_ivas->hLsSetUpConversion && st_ivas->hLsSetUpConversion->dmxEnergyPrev_fx ) - //me2f_buf( st_ivas->hLsSetUpConversion->dmxEnergyPrev_fx[0], st_ivas->hLsSetUpConversion->dmx_prev_exp, st_ivas->hLsSetUpConversion->dmxEnergyPrev[0], st_ivas->hLsSetUpConversion->sfbCnt ); - -#endif // Fix to float -#endif - } - - if ( st_ivas->sba_dirac_stereo_flag ) - { - FOR( i = 0; i < st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport; i++ ) - { - Scale_sig32( p_output_fx[i + sba_ch_idx], output_frame, sub( Q14, Q11 ) ); - } -#ifdef IVAS_FLOAT_FIXED -#if 1 /*Float to Fixed changes */ - SPAR_DEC_HANDLE hSpar = st_ivas->hSpar; - Word16 nchan_transport; - //num_bands_out = hSpar->hFbMixer->pFb->filterbank_num_bands; - nchan_transport = hSpar->hMdDec->spar_md_cfg.nchan_transport; - nchan_out = nchan_transport; - //Word16 num_out_ch; - //num_out_ch = hSpar->hMdDec->spar_md_cfg.num_umx_chs; - hSpar->hMdDec->Q_mixer_mat = 31; - //Word16 num_in_ch; - //num_in_ch = hSpar->hMdDec->spar_md_cfg.num_umx_chs; -#endif - ivas_agc_dec_process_fx( st_ivas->hSpar->hAgcDec, ( p_output_fx + sba_ch_idx ), ( p_output_fx + sba_ch_idx ), st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, output_frame ); - - IF( st_ivas->hSpar->hPCA != NULL ) - { - ivas_pca_dec_fx( st_ivas->hSpar->hPCA, output_frame, st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->hDecoderConfig->last_ivas_total_brate, st_ivas->bfi, &p_output_fx[sba_ch_idx] ); - } - -#ifndef IVAS_FLOAT_FIXED - ivas_spar_dec_gen_umx_mat( st_ivas->hSpar->hMdDec, st_ivas->nchan_transport, IVAS_MAX_NUM_BANDS, st_ivas->bfi, ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ) ); -#else - ivas_spar_dec_gen_umx_mat_fx( st_ivas->hSpar->hMdDec, st_ivas->nchan_transport, IVAS_MAX_NUM_BANDS, st_ivas->bfi, ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ) ); -#endif -#endif -#ifdef IVAS_FLOAT_FIXED - { - Word16 q; - hCPE = st_ivas->hCPE[0]; - hSCE = st_ivas->hSCE[0]; - s = 0; - FOR( i = 0; i < 2; i++ ) - { - s = s_min( s, L_norm_arr( p_output_fx[sba_ch_idx + i], L_FRAME48k ) - 11 /* Guard bits */ ); - } - FOR( i = 0; i < 2; i++ ) + FOR( i = 0; i < 2; i++ ) { Scale_sig32( p_output_fx[sba_ch_idx + i], L_FRAME48k, s ); } @@ -1277,7 +857,7 @@ ivas_error ivas_jbm_dec_tc( hCPE->hStereoDft->q_ap_delay_mem_fx = hCPE->hStereoDft->q_dft; } - q = hCPE->hStereoDft->q_dft; + q = hCPE->hStereoDft->q_dft; move16(); scale_sig32( hCPE->input_mem_BPF_fx[0], STEREO_DFT32MS_OVL_16k, sub( hCPE->hStereoDft->q_dft, Q11 ) ); FOR( i = 0; i < CPE_CHANNELS; ++i ) { @@ -1286,9 +866,9 @@ ivas_error ivas_jbm_dec_tc( } IF( hCPE->hCoreCoder[0] != NULL ) { - floatToFixed_arrL( &hCPE->hCoreCoder[0]->hHQ_core->old_outLB[0], &hCPE->hCoreCoder[0]->hHQ_core->old_outLB_fx[0], q, L_FRAME32k ); + Copy_Scale_sig_16_32( hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx, hCPE->hCoreCoder[0]->hHQ_core->old_outLB_fx, L_FRAME32k, q - hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda_LB ); + Copy_Scale_sig_16_32( hCPE->hCoreCoder[0]->hHQ_core->old_out_fx, hCPE->hCoreCoder[0]->hHQ_core->oldOut_fx, L_FRAME48k, q - hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda ); hCPE->hCoreCoder[0]->hHQ_core->q_old_outLB_fx = q; - floatToFixed_arrL( &hCPE->hCoreCoder[0]->hHQ_core->old_out[0], &hCPE->hCoreCoder[0]->hHQ_core->oldOut_fx[0], q, L_FRAME48k ); } IF( hCPE->hStereoDft != NULL ) { @@ -1305,7 +885,7 @@ ivas_error ivas_jbm_dec_tc( Scale_sig32( &hSCE->save_synth_fx[0], (Word16) ( hCPE->hCoreCoder[0]->output_Fs / FRAMES_PER_SEC ), hCPE->hStereoDft->q_dft - hSCE->q_save_synth_fx ); hSCE->q_save_synth_fx = hCPE->hStereoDft->q_dft; } - FOR( int ii = 0; ii < CPE_CHANNELS; ii++ ) + FOR( Word16 ii = 0; ii < CPE_CHANNELS; ii++ ) { scale_sig32( hCPE->output_mem_fx[ii], NS2SA_fx2( st_ivas->hDecoderConfig->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); hCPE->q_output_mem_fx[ii] = hCPE->hStereoDft->q_dft; @@ -1338,8 +918,9 @@ ivas_error ivas_jbm_dec_tc( IF( hCPE->hCoreCoder[0] != NULL ) { - fixedToFloat_arrL( &hCPE->hCoreCoder[0]->hHQ_core->old_outLB_fx[0], &hCPE->hCoreCoder[0]->hHQ_core->old_outLB[0], q, L_FRAME32k ); - fixedToFloat_arrL( &hCPE->hCoreCoder[0]->hHQ_core->oldOut_fx[0], &hCPE->hCoreCoder[0]->hHQ_core->old_out[0], q, L_FRAME48k ); + + Copy_Scale_sig_32_16( hCPE->hCoreCoder[0]->hHQ_core->old_outLB_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx, L_FRAME32k, hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda_LB - q ); + Copy_Scale_sig_32_16( hCPE->hCoreCoder[0]->hHQ_core->oldOut_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_fx, L_FRAME48k, hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda - q ); } IF( hCPE->hStereoDft != NULL ) { @@ -1354,7 +935,6 @@ ivas_error ivas_jbm_dec_tc( hCPE->q_output_mem_fx[ii] = Q11; } } -#endif } /* HP filtering */ @@ -1368,10 +948,6 @@ ivas_error ivas_jbm_dec_tc( IF( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) { num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ); - -#ifdef IVAS_FLOAT_FIXED -#if 1 - Word16 ch; SPAR_DEC_HANDLE hSpar = st_ivas->hSpar; Word16 Q_p_output = 14; Word16 nchan_transport; @@ -1382,20 +958,14 @@ ivas_error ivas_jbm_dec_tc( { Scale_sig32( p_output_fx[sba_ch_idx + ch], output_frame, sub( Q_p_output, Q11 ) ); } - //Word16 num_out_ch; - //num_out_ch = hSpar->hMdDec->spar_md_cfg.num_umx_chs; hSpar->hMdDec->Q_mixer_mat = 31; - //Word16 num_in_ch; - //num_in_ch = hSpar->hMdDec->spar_md_cfg.num_umx_chs; -#endif + ivas_sba_mix_matrix_determiner_fx( st_ivas->hSpar, &p_output_fx[sba_ch_idx], st_ivas->bfi, nchan_remapped, output_frame, num_md_sub_frames ); -#if 1 FOR( Word16 c = 0; c < nchan_transport; c++ ) { Scale_sig32( p_output_fx[sba_ch_idx + c], output_frame, Q11 ); } -#endif -#endif // IVAS_FLOAT_FIXED + } ELSE IF( st_ivas->renderer_type != RENDERER_DISABLE && EQ_16( st_ivas->sba_dirac_stereo_flag, 0 ) ) { @@ -1414,22 +984,18 @@ ivas_error ivas_jbm_dec_tc( IF( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) { /* loudness correction */ -#ifdef IVAS_FLOAT_FIXED ivas_dirac_dec_binaural_sba_gain_fx( &p_output_fx[sba_ch_idx], nchan_remapped, output_frame ); /*returns Q-1*/ FOR( i = 0; i < nchan_remapped; i++ ) { Scale_sig32( p_output_fx[i], output_frame, 1 ); } -#endif // IVAS_FLOAT_FIXED } ELSE IF( st_ivas->renderer_type == RENDERER_MONO_DOWNMIX && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { -#ifdef IVAS_FLOAT_FIXED ivas_mono_downmix_render_passive_fx( st_ivas, p_output_fx, output_frame ); Scale_sig32( p_output_fx[0], L_FRAME48k, sub( Q11, Q8 ) ); -#endif /* add W */ FOR( n = 0; n < nchan_out; n++ ) @@ -1445,166 +1011,13 @@ ivas_error ivas_jbm_dec_tc( IF( st_ivas->mc_mode == MC_MODE_MCT ) { /* LFE channel decoder */ -#ifdef IVAS_FLOAT_FIXED ivas_lfe_dec_fx( st_ivas->hLFE, st, output_frame, st_ivas->bfi, p_output_fx[LFE_CHANNEL] ); Scale_sig32( p_output_fx[LFE_CHANNEL], L_FRAME48k, sub( Q11, Q9 ) ); -#endif // IVAS_FLOAT_FIXED - -#ifdef IVAS_FLOAT_FIXED -#if 1 // Float to fix - - Word16 ch, nCPE, cpe_id; - Word16 l; - - nCPE = st_ivas->nCPE; - move16(); - hMCT = st_ivas->hMCT; - FOR( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) - { - hCPE = st_ivas->hCPE[cpe_id]; - sts = hCPE->hCoreCoder; - - - FOR( n = 0; n < CPE_CHANNELS; n++ ) - { - st = hCPE->hCoreCoder[n]; - - IF( sts[n]->mct_chan_mode != MCT_CHAN_MODE_IGNORE ) - { - // u8bit to 16bit - FOR( l = 0; l < IGF_START_MX; l++ ) - { - sts[n]->hIGFDec->infoTCXNoise_evs[l] = (Word16) sts[n]->hIGFDec->infoTCXNoise[l]; - } - } - //if ( st->hTcxDec && st->hTcxDec->conLastFrameLevel_e < 0 ) - //{ - // st->hTcxDec->conLastFrameLevel_e = 0; - //} - //if ( st->hTcxDec && st->hTcxDec->conNoiseLevelMemory_e[0] < 0 ) - //{ - // set16_fx( st->hTcxDec->conNoiseLevelMemory_e, 0, PLC_MIN_STAT_BUFF_SIZE ); - //} - IF( st->hTcxDec ) - st->hTcxDec->conNoiseLevelIndex = st->hTcxDec->NoiseLevelIndex_bfi; - IF( st->hTcxDec ) - st->hTcxDec->conCurrLevelIndex = st->hTcxDec->CurrLevelIndex_bfi; - /*cldfb struct*/ - - /*------------------fix-to-fix-start---------------------*/ - /*core_switching_post_dec*/ - if ( hCPE->hCoreCoder[n]->hHQ_core != NULL ) - { - hCPE->hCoreCoder[n]->hHQ_core->Q_old_postdec = 0; - hCPE->hCoreCoder[n]->hHQ_core->Q_old_wtda = 0; - } - } - } -#endif // Float to fix IF( ( error = ivas_mct_dec_fx( st_ivas, p_output_fx, output_frame, 0 ) ) != IVAS_ERR_OK ) { return error; } -#if 1 // Fix to float - FOR( cpe_id = 0; cpe_id < nCPE; cpe_id++ ) - { - hCPE = st_ivas->hCPE[cpe_id]; - sts = hCPE->hCoreCoder; - FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) - { - st = hCPE->hCoreCoder[ch]; - IF( sts[ch]->mct_chan_mode != MCT_CHAN_MODE_IGNORE ) - { - // 16bit to u8bit - FOR( l = 0; l < IGF_START_MX; l++ ) - { - sts[ch]->hIGFDec->infoTCXNoise[l] = (uint8_t) sts[ch]->hIGFDec->infoTCXNoise_evs[l]; - } - } - } - - FOR( n = 0; n < 2; n++ ) - { - st = hCPE->hCoreCoder[n]; - sts = hCPE->hCoreCoder; - - for ( int p = 0; p < 640; p++ ) - { - st->hHQ_core->old_outLB[p] = (float) st->hHQ_core->old_out_LB_fx[p] / ( 1u << st->Q_syn ); - } - - /*-------------------cldfb-start-------------------------*/ - - /*note : cldfb_size here signifies the original size which was assigned to cldfb_state_fx buffer not its current size*/ - - if ( sts[n]->cldfbAna != NULL ) - { - fixedToFloat_arrL( sts[n]->cldfbAna->cldfb_state_fx, sts[n]->cldfbAna->cldfb_state, 10, sts[n]->cldfbAna->cldfb_state_length ); - } - if ( sts[n]->cldfbSyn != NULL ) - { - fixedToFloat_arrL( sts[n]->cldfbSyn->cldfb_state_fx, sts[n]->cldfbSyn->cldfb_state, 4, sts[n]->cldfbSyn->p_filter_length ); - } - if ( sts[n]->cldfbBPF != NULL ) - { - fixedToFloat_arrL( sts[n]->cldfbBPF->cldfb_state_fx, sts[n]->cldfbBPF->cldfb_state, 11, sts[n]->cldfbBPF->cldfb_state_length ); - } - - /*-------------------cldfb-end---------------------------*/ - - IF( sts[n]->hHQ_core != NULL ) - { - fixedToFloat_arr( sts[n]->hHQ_core->old_out_fx, sts[n]->hHQ_core->old_out, 0, L_FRAME48k ); - } - - /*------------------reset-code-start---------------------*/ - - - /* reset WB BWE buffers */ - - IF( NE_16( sts[n]->last_extl, WB_BWE ) && EQ_16( sts[n]->extl, WB_BWE ) && sts[n]->hBWE_FD != NULL ) - { - - IF( NE_16( sts[n]->last_extl, SWB_BWE ) && NE_16( sts[n]->last_extl, FB_BWE ) ) - { - sts[n]->hBWE_FD->prev_mode = sts[n]->hBWE_FD->prev_mode; - } - sts[n]->hBWE_FD->prev_L_swb_norm = sts[n]->hBWE_FD->prev_L_swb_norm; - sts[n]->hBWE_FD->prev_flag = sts[n]->hBWE_FD->prev_flag; - } - } - } - - - IF( st_ivas->hCPE[0]->hCoreCoder[0]->igf ) - { - IF( !hMCT->currBlockDataCnt ) - { - FOR( cpe_id = 0; cpe_id < nCPE; cpe_id++ ) - { - FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) - { - IF( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->igf ) - { - FOR( l = 0; l < IGF_START_MX; l++ ) - { - st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hIGFDec->infoTCXNoise[l] = (uint8_t) st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hIGFDec->infoTCXNoise_evs[l]; - } - } - } - } - } - } - - //IF( st_ivas->hLsSetUpConversion && st_ivas->hLsSetUpConversion->targetEnergyPrev ) - //me2f_buf( st_ivas->hLsSetUpConversion->targetEnergyPrev_fx[0], st_ivas->hLsSetUpConversion->te_prev_exp, st_ivas->hLsSetUpConversion->targetEnergyPrev[0], st_ivas->hLsSetUpConversion->sfbCnt ); - //IF( st_ivas->hLsSetUpConversion && st_ivas->hLsSetUpConversion->dmxEnergyPrev_fx ) - //me2f_buf( st_ivas->hLsSetUpConversion->dmxEnergyPrev_fx[0], st_ivas->hLsSetUpConversion->dmx_prev_exp, st_ivas->hLsSetUpConversion->dmxEnergyPrev[0], st_ivas->hLsSetUpConversion->sfbCnt ); - -#endif // Fix to float -#endif - /* HP filtering */ FOR( n = 0; n < st_ivas->nchan_transport; n++ ) { @@ -1626,7 +1039,6 @@ ivas_error ivas_jbm_dec_tc( { IF( st_ivas->renderer_type == RENDERER_MC ) { -#ifdef IVAS_FLOAT_FIXED s = sub( Q16, Q11 ); s = sub( s, find_guarded_bits_fx( st_ivas->nchan_transport ) ); FOR( i = 0; i < max( st_ivas->hDecoderConfig->nchan_out, st_ivas->nchan_transport ); ++i ) @@ -1638,7 +1050,6 @@ ivas_error ivas_jbm_dec_tc( { Scale_sig32( p_output_fx[i], output_frame, negate( s ) ); } -#endif } ELSE IF( st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) { @@ -1655,156 +1066,10 @@ ivas_error ivas_jbm_dec_tc( ivas_mc_paramupmix_dec_read_BS( st_ivas, st, st_ivas->hMCParamUpmix, &nb_bits_metadata[0] ); -#ifdef IVAS_FLOAT_FIXED -#if 1 // Float to fix - - Word16 ch, nCPE, cpe_id; - Word16 l; - - nCPE = st_ivas->nCPE; - move16(); - hMCT = st_ivas->hMCT; - FOR( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) - { - hCPE = st_ivas->hCPE[cpe_id]; - sts = hCPE->hCoreCoder; - - - FOR( n = 0; n < CPE_CHANNELS; n++ ) - { - st = hCPE->hCoreCoder[n]; - - IF( sts[n]->mct_chan_mode != MCT_CHAN_MODE_IGNORE ) - { - // u8bit to 16bit - FOR( l = 0; l < IGF_START_MX; l++ ) - { - sts[n]->hIGFDec->infoTCXNoise_evs[l] = (Word16) sts[n]->hIGFDec->infoTCXNoise[l]; - } - } - //if ( st->hTcxDec && st->hTcxDec->conLastFrameLevel_e < 0 ) - //{ - // st->hTcxDec->conLastFrameLevel_e = 0; - //} - //if ( st->hTcxDec && st->hTcxDec->conNoiseLevelMemory_e[0] < 0 ) - //{ - // set16_fx( st->hTcxDec->conNoiseLevelMemory_e, 0, PLC_MIN_STAT_BUFF_SIZE ); - //} - IF( st->hTcxDec ) - st->hTcxDec->conNoiseLevelIndex = st->hTcxDec->NoiseLevelIndex_bfi; - IF( st->hTcxDec ) - st->hTcxDec->conCurrLevelIndex = st->hTcxDec->CurrLevelIndex_bfi; - - /*------------------fix-to-fix-start---------------------*/ - /*core_switching_post_dec*/ - if ( hCPE->hCoreCoder[n]->hHQ_core != NULL ) - { - hCPE->hCoreCoder[n]->hHQ_core->Q_old_postdec = 0; - hCPE->hCoreCoder[n]->hHQ_core->Q_old_wtda = 0; - } - } - } -#endif // Float to fix - if ( ( error = ivas_mct_dec_fx( st_ivas, p_output_fx, output_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) + IF ( ( error = ivas_mct_dec_fx( st_ivas, p_output_fx, output_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) { return error; } -#if 1 // Fix to float - FOR( cpe_id = 0; cpe_id < nCPE; cpe_id++ ) - { - hCPE = st_ivas->hCPE[cpe_id]; - sts = hCPE->hCoreCoder; - FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) - { - st = hCPE->hCoreCoder[ch]; - IF( sts[ch]->mct_chan_mode != MCT_CHAN_MODE_IGNORE ) - { - // 16bit to u8bit - FOR( l = 0; l < IGF_START_MX; l++ ) - { - sts[ch]->hIGFDec->infoTCXNoise[l] = (uint8_t) sts[ch]->hIGFDec->infoTCXNoise_evs[l]; - } - } - } - - FOR( n = 0; n < 2; n++ ) - { - st = hCPE->hCoreCoder[n]; - sts = hCPE->hCoreCoder; - for ( int p = 0; p < 640; p++ ) - { - st->hHQ_core->old_outLB[p] = (float) st->hHQ_core->old_out_LB_fx[p] / ( 1u << st->Q_syn ); - } - - /*-------------------cldfb-start-------------------------*/ - /*note : cldfb_size here signifies the original size which was assigned to cldfb_state_fx buffer not its current size*/ - if ( sts[n]->cldfbAna != NULL ) - { - fixedToFloat_arrL( sts[n]->cldfbAna->cldfb_state_fx, sts[n]->cldfbAna->cldfb_state, 10, sts[n]->cldfbAna->cldfb_state_length ); - } - if ( sts[n]->cldfbSyn != NULL ) - { - fixedToFloat_arrL( sts[n]->cldfbSyn->cldfb_state_fx, sts[n]->cldfbSyn->cldfb_state, 4, sts[n]->cldfbSyn->p_filter_length ); - } - if ( sts[n]->cldfbBPF != NULL ) - { - fixedToFloat_arrL( sts[n]->cldfbBPF->cldfb_state_fx, sts[n]->cldfbBPF->cldfb_state, 11, sts[n]->cldfbBPF->cldfb_state_length ); - } - - /*-------------------cldfb-end---------------------------*/ - - IF( sts[n]->hHQ_core != NULL ) - { - fixedToFloat_arr( sts[n]->hHQ_core->old_out_fx, sts[n]->hHQ_core->old_out, 0, L_FRAME48k ); - } - - /*------------------reset-code-start---------------------*/ - - - /* reset WB BWE buffers */ - - IF( NE_16( sts[n]->last_extl, WB_BWE ) && EQ_16( sts[n]->extl, WB_BWE ) && sts[n]->hBWE_FD != NULL ) - { - - IF( NE_16( sts[n]->last_extl, SWB_BWE ) && NE_16( sts[n]->last_extl, FB_BWE ) ) - { - sts[n]->hBWE_FD->prev_mode = sts[n]->hBWE_FD->prev_mode; - } - sts[n]->hBWE_FD->prev_L_swb_norm = sts[n]->hBWE_FD->prev_L_swb_norm; - sts[n]->hBWE_FD->prev_flag = sts[n]->hBWE_FD->prev_flag; - } - } - } - - - IF( st_ivas->hCPE[0]->hCoreCoder[0]->igf ) - { - IF( !hMCT->currBlockDataCnt ) - { - FOR( cpe_id = 0; cpe_id < nCPE; cpe_id++ ) - { - FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) - { - IF( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->igf ) - { - FOR( l = 0; l < IGF_START_MX; l++ ) - { - st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hIGFDec->infoTCXNoise[l] = (uint8_t) st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hIGFDec->infoTCXNoise_evs[l]; - } - } - } - } - } - } - - //IF( st_ivas->hLsSetUpConversion && st_ivas->hLsSetUpConversion->targetEnergyPrev ) - //me2f_buf( st_ivas->hLsSetUpConversion->targetEnergyPrev_fx[0], st_ivas->hLsSetUpConversion->te_prev_exp, st_ivas->hLsSetUpConversion->targetEnergyPrev[0], st_ivas->hLsSetUpConversion->sfbCnt ); - //IF( st_ivas->hLsSetUpConversion && st_ivas->hLsSetUpConversion->dmxEnergyPrev_fx ) - //me2f_buf( st_ivas->hLsSetUpConversion->dmxEnergyPrev_fx[0], st_ivas->hLsSetUpConversion->dmx_prev_exp, st_ivas->hLsSetUpConversion->dmxEnergyPrev[0], st_ivas->hLsSetUpConversion->sfbCnt ); - -#endif // Fix to float -#endif - /* HP filtering */ FOR( n = 0; n < st_ivas->nchan_transport; n++ ) { @@ -1825,7 +1090,6 @@ ivas_error ivas_jbm_dec_tc( IF( output_config == IVAS_AUDIO_CONFIG_MONO || output_config == IVAS_AUDIO_CONFIG_STEREO ) { -#ifdef IVAS_FLOAT_FIXED s = sub( Q16, Q11 ); Word16 nchan_transport; nchan_transport = audioCfg2channels( IVAS_AUDIO_CONFIG_5_1_2 ); @@ -1839,7 +1103,6 @@ ivas_error ivas_jbm_dec_tc( { Scale_sig32( p_output_fx[i], output_frame, negate( s ) ); } -#endif } } } @@ -1864,157 +1127,10 @@ ivas_error ivas_jbm_dec_tc( } ELSE IF( st_ivas->nCPE > 1 ) { -#ifdef IVAS_FLOAT_FIXED -#if 1 // Float to fix - - Word16 ch, nCPE, cpe_id; - Word16 l; - - nCPE = st_ivas->nCPE; - move16(); - hMCT = st_ivas->hMCT; - FOR( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) - { - hCPE = st_ivas->hCPE[cpe_id]; - sts = hCPE->hCoreCoder; - - - FOR( n = 0; n < CPE_CHANNELS; n++ ) - { - st = hCPE->hCoreCoder[n]; - IF( sts[n]->mct_chan_mode != MCT_CHAN_MODE_IGNORE ) - { - // u8bit to 16bit - FOR( l = 0; l < IGF_START_MX; l++ ) - { - sts[n]->hIGFDec->infoTCXNoise_evs[l] = (Word16) sts[n]->hIGFDec->infoTCXNoise[l]; - } - } - //if ( st->hTcxDec && st->hTcxDec->conLastFrameLevel_e < 0 ) - //{ - // st->hTcxDec->conLastFrameLevel_e = 0; - //} - //if ( st->hTcxDec && st->hTcxDec->conNoiseLevelMemory_e[0] < 0 ) - //{ - // set16_fx( st->hTcxDec->conNoiseLevelMemory_e, 0, PLC_MIN_STAT_BUFF_SIZE ); - //} - IF( st->hTcxDec ) - st->hTcxDec->conNoiseLevelIndex = st->hTcxDec->NoiseLevelIndex_bfi; - IF( st->hTcxDec ) - st->hTcxDec->conCurrLevelIndex = st->hTcxDec->CurrLevelIndex_bfi; - - /*cldfb struct*/ - - /*------------------fix-to-fix-start---------------------*/ - /*core_switching_post_dec*/ - if ( hCPE->hCoreCoder[n]->hHQ_core != NULL ) - { - hCPE->hCoreCoder[n]->hHQ_core->Q_old_postdec = 0; - hCPE->hCoreCoder[n]->hHQ_core->Q_old_wtda = 0; - } - } - } -#endif // Float to fix - if ( ( error = ivas_mct_dec_fx( st_ivas, p_output_fx, output_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) + IF ( ( error = ivas_mct_dec_fx( st_ivas, p_output_fx, output_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) { return error; } -#if 1 // Fix to float - FOR( cpe_id = 0; cpe_id < nCPE; cpe_id++ ) - { - hCPE = st_ivas->hCPE[cpe_id]; - sts = hCPE->hCoreCoder; - FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) - { - st = hCPE->hCoreCoder[ch]; - IF( sts[ch]->mct_chan_mode != MCT_CHAN_MODE_IGNORE ) - { - // 16bit to u8bit - FOR( l = 0; l < IGF_START_MX; l++ ) - { - sts[ch]->hIGFDec->infoTCXNoise[l] = (uint8_t) sts[ch]->hIGFDec->infoTCXNoise_evs[l]; - } - } - } - - FOR( n = 0; n < 2; n++ ) - { - st = hCPE->hCoreCoder[n]; - sts = hCPE->hCoreCoder; - for ( int p = 0; p < 640; p++ ) - { - st->hHQ_core->old_outLB[p] = (float) st->hHQ_core->old_out_LB_fx[p] / ( 1u << st->Q_syn ); - } - - /*-------------------cldfb-start-------------------------*/ - - /*note : cldfb_size here signifies the original size which was assigned to cldfb_state_fx buffer not its current size*/ - - if ( sts[n]->cldfbAna != NULL ) - { - fixedToFloat_arrL( sts[n]->cldfbAna->cldfb_state_fx, sts[n]->cldfbAna->cldfb_state, 10, sts[n]->cldfbAna->cldfb_state_length ); - } - if ( sts[n]->cldfbSyn != NULL ) - { - fixedToFloat_arrL( sts[n]->cldfbSyn->cldfb_state_fx, sts[n]->cldfbSyn->cldfb_state, 4, sts[n]->cldfbSyn->p_filter_length ); - } - if ( sts[n]->cldfbBPF != NULL ) - { - fixedToFloat_arrL( sts[n]->cldfbBPF->cldfb_state_fx, sts[n]->cldfbBPF->cldfb_state, 11, sts[n]->cldfbBPF->cldfb_state_length ); - } - - /*-------------------cldfb-end---------------------------*/ - - IF( sts[n]->hHQ_core != NULL ) - { - fixedToFloat_arr( sts[n]->hHQ_core->old_out_fx, sts[n]->hHQ_core->old_out, 0, L_FRAME48k ); - } - - /*------------------reset-code-start---------------------*/ - - /* reset WB BWE buffers */ - - IF( NE_16( sts[n]->last_extl, WB_BWE ) && EQ_16( sts[n]->extl, WB_BWE ) && sts[n]->hBWE_FD != NULL ) - { - - IF( NE_16( sts[n]->last_extl, SWB_BWE ) && NE_16( sts[n]->last_extl, FB_BWE ) ) - { - sts[n]->hBWE_FD->prev_mode = sts[n]->hBWE_FD->prev_mode; - } - sts[n]->hBWE_FD->prev_L_swb_norm = sts[n]->hBWE_FD->prev_L_swb_norm; - sts[n]->hBWE_FD->prev_flag = sts[n]->hBWE_FD->prev_flag; - } - } - } - - - IF( st_ivas->hCPE[0]->hCoreCoder[0]->igf ) - { - IF( !hMCT->currBlockDataCnt ) - { - FOR( cpe_id = 0; cpe_id < nCPE; cpe_id++ ) - { - FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) - { - IF( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->igf ) - { - FOR( l = 0; l < IGF_START_MX; l++ ) - { - st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hIGFDec->infoTCXNoise[l] = (uint8_t) st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hIGFDec->infoTCXNoise_evs[l]; - } - } - } - } - } - } - - //IF( st_ivas->hLsSetUpConversion && st_ivas->hLsSetUpConversion->targetEnergyPrev ) - //me2f_buf( st_ivas->hLsSetUpConversion->targetEnergyPrev_fx[0], st_ivas->hLsSetUpConversion->te_prev_exp, st_ivas->hLsSetUpConversion->targetEnergyPrev[0], st_ivas->hLsSetUpConversion->sfbCnt ); - //IF( st_ivas->hLsSetUpConversion && st_ivas->hLsSetUpConversion->dmxEnergyPrev_fx ) - //me2f_buf( st_ivas->hLsSetUpConversion->dmxEnergyPrev_fx[0], st_ivas->hLsSetUpConversion->dmx_prev_exp, st_ivas->hLsSetUpConversion->dmxEnergyPrev[0], st_ivas->hLsSetUpConversion->sfbCnt ); - -#endif // Fix to float -#endif } /* HP filtering */ @@ -2026,7 +1142,6 @@ ivas_error ivas_jbm_dec_tc( /* Rendering */ IF( output_config == IVAS_AUDIO_CONFIG_MONO || output_config == IVAS_AUDIO_CONFIG_STEREO ) { -#ifdef IVAS_FLOAT_FIXED s = sub( Q16, Q11 ); s = sub( s, find_guarded_bits_fx( st_ivas->nchan_transport ) ); FOR( i = 0; i < max( st_ivas->hDecoderConfig->nchan_out, st_ivas->nchan_transport ); ++i ) @@ -2038,7 +1153,6 @@ ivas_error ivas_jbm_dec_tc( { Scale_sig32( p_output_fx[i], output_frame, negate( s ) ); } -#endif } } ELSE IF( st_ivas->mc_mode == MC_MODE_MCMASA ) @@ -2049,7 +1163,6 @@ ivas_error ivas_jbm_dec_tc( } /* read McMASA parameters from the bitstream */ -#ifdef IVAS_FLOAT_FIXED IF( ( error = ivas_masa_decode_fx( st_ivas, st, &nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) { @@ -2090,7 +1203,6 @@ ivas_error ivas_jbm_dec_tc( } } // Fixed to float conversion ends here. -#endif IF( st_ivas->hOutSetup.separateChannelEnabled ) { /* Decode the transport audio signals */ @@ -2110,14 +1222,13 @@ ivas_error ivas_jbm_dec_tc( n = LFE_CHANNEL - 1; /* Decode the separated channel to output[n] to be combined with the synthesized channels */ -#ifdef IVAS_FLOAT_FIXED + set32_fx( p_output_fx[n], 0, L_FRAME48k ); IF( ( error = ivas_sce_dec_fx( st_ivas, 0, &p_output_fx[n], output_frame, 0 ) ) != IVAS_ERR_OK ) { return error; } -#endif // IVAS_FLOAT_FIXED /* Delay the separated channel to sync with CLDFB delay of the DirAC synthesis, and synthesize the LFE signal. */ IF( output_config == IVAS_AUDIO_CONFIG_5_1 || output_config == IVAS_AUDIO_CONFIG_7_1 || output_config == IVAS_AUDIO_CONFIG_5_1_4 || output_config == IVAS_AUDIO_CONFIG_7_1_4 || @@ -2125,7 +1236,7 @@ ivas_error ivas_jbm_dec_tc( { ivas_lfe_synth_with_filters_fx( st_ivas->hMasa->hMasaLfeSynth, p_output_fx, output_frame, n, LFE_CHANNEL ); } - ELSE IF( output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM && st_ivas->hOutSetup.num_lfe == 0 ) + ELSE IF( output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM && EQ_16( st_ivas->hOutSetup.num_lfe, 0 ) ) { /* Delay the separated channel to sync with the DirAC rendering */ delay_signal_fx(p_output_fx[n], output_frame, st_ivas->hMasa->hMasaLfeSynth->delayBuffer_syncDirAC_fx, st_ivas->hMasa->hMasaLfeSynth->delayBuffer_syncDirAC_size ); @@ -2133,8 +1244,7 @@ ivas_error ivas_jbm_dec_tc( } ELSE { -#ifdef IVAS_FLOAT_FIXED - Word16 q_output = 11; + Word16 q_output = 11; move16(); IF( EQ_16( st_ivas->nSCE, 1 ) ) { set32_fx( p_output_fx[0], 0, L_FRAME48k ); @@ -2157,19 +1267,14 @@ ivas_error ivas_jbm_dec_tc( Scale_sig32( p_output_fx[1], output_frame, sub( Q11, q_output ) ); } } -#endif // IVAS_FLOAT_FIXED } IF( NE_16( st_ivas->sba_dirac_stereo_flag, 0 ) ) /* use the flag to trigger the DFT upmix */ { -#ifdef IVAS_FLOAT_FIXED Word16 q; - //float max_val = 0.0; - //int i_max_val_op; hCPE = st_ivas->hCPE[0]; hSCE = st_ivas->hSCE[0]; - //i_max_val_op = (int) max_val; - s = 0; + s = 0; move16(); FOR( i = 0; i < 2; i++ ) { s = s_min( s, L_norm_arr( p_output_fx[i], L_FRAME48k ) - 11 /* Guard bits */ ); @@ -2195,9 +1300,9 @@ ivas_error ivas_jbm_dec_tc( IF( hCPE->hCoreCoder[0] != NULL ) { - floatToFixed_arrL( &hCPE->hCoreCoder[0]->hHQ_core->old_outLB[0], &hCPE->hCoreCoder[0]->hHQ_core->old_outLB_fx[0], q, L_FRAME32k ); + Copy_Scale_sig_16_32( hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx, hCPE->hCoreCoder[0]->hHQ_core->old_outLB_fx, L_FRAME32k, q - hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda_LB ); + Copy_Scale_sig_16_32( hCPE->hCoreCoder[0]->hHQ_core->old_out_fx, hCPE->hCoreCoder[0]->hHQ_core->oldOut_fx, L_FRAME48k, q - hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda ); hCPE->hCoreCoder[0]->hHQ_core->q_old_outLB_fx = q; - floatToFixed_arrL( &hCPE->hCoreCoder[0]->hHQ_core->old_out[0], &hCPE->hCoreCoder[0]->hHQ_core->oldOut_fx[0], q, L_FRAME48k ); } IF( hCPE->hStereoDft != NULL ) { @@ -2217,7 +1322,7 @@ ivas_error ivas_jbm_dec_tc( Scale_sig32( &hSCE->save_synth_fx[0], (Word16) ( hCPE->hCoreCoder[0]->output_Fs / FRAMES_PER_SEC ), hCPE->hStereoDft->q_dft - hSCE->q_save_synth_fx ); hSCE->q_save_synth_fx = hCPE->hStereoDft->q_dft; } - FOR( int ii = 0; ii < CPE_CHANNELS; ii++ ) + FOR( Word16 ii = 0; ii < CPE_CHANNELS; ii++ ) { scale_sig32( hCPE->output_mem_fx[ii], NS2SA_fx2( st_ivas->hDecoderConfig->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); hCPE->q_output_mem_fx[ii] = hCPE->hStereoDft->q_dft; @@ -2249,27 +1354,24 @@ ivas_error ivas_jbm_dec_tc( IF( hCPE->hCoreCoder[0] != NULL ) { - fixedToFloat_arrL( &hCPE->hCoreCoder[0]->hHQ_core->old_outLB_fx[0], &hCPE->hCoreCoder[0]->hHQ_core->old_outLB[0], q, L_FRAME32k ); - fixedToFloat_arrL( &hCPE->hCoreCoder[0]->hHQ_core->oldOut_fx[0], &hCPE->hCoreCoder[0]->hHQ_core->old_out[0], q, L_FRAME48k ); + Copy_Scale_sig_32_16( hCPE->hCoreCoder[0]->hHQ_core->old_outLB_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx, L_FRAME32k, hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda_LB - q ); + Copy_Scale_sig_32_16( hCPE->hCoreCoder[0]->hHQ_core->oldOut_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_fx, L_FRAME48k, hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda - q ); } IF( hCPE->hStereoDft != NULL ) { scale_sig32( hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA( 16000, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); scale_sig32( hCPE->hStereoDft->ap_delay_mem_fx, NS2SA( 16000, DELAY_BWE_TOTAL_NS ), sub( Q11, hCPE->hStereoDft->q_ap_fade_mem_fx ) ); hCPE->hStereoDft->q_ap_fade_mem_fx = Q11; - - //fixedToFloat_arrL( &hCPE->hStereoDft->td_gain_fx[0], &hCPE->hStereoDft->td_gain[0], Q31, sizeof( hCPE->hStereoDft->td_gain_fx ) / sizeof( hCPE->hStereoDft->td_gain_fx[0] ) ); } IF( st_ivas->hSpar != NULL ) { - st_ivas->hSpar->hMdDec->Q_mixer_mat = 31; - FOR( int ii = 0; ii < CPE_CHANNELS; ii++ ) + st_ivas->hSpar->hMdDec->Q_mixer_mat = 31; move16(); + FOR( Word16 ii = 0; ii < CPE_CHANNELS; ii++ ) { scale_sig32( hCPE->output_mem_fx[ii], NS2SA_fx2( st_ivas->hDecoderConfig->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); - hCPE->q_output_mem_fx[ii] = Q11; + hCPE->q_output_mem_fx[ii] = Q11; move16(); } } -#endif } /* HP filtering */ @@ -2285,181 +1387,43 @@ ivas_error ivas_jbm_dec_tc( } } - FOR( Word16 ch = 0; ch < 12; ch++ ) IF(p_output[ch]) - { - fixedToFloat_arrL( p_output_fx[ch], p_output[ch], Q11, L_FRAME48k ); - } - /*----------------------------------------------------------------* * Write IVAS transport channels *----------------------------------------------------------------*/ - if ( st_ivas->hDecoderConfig->Opt_tsm == 1 ) + IF ( EQ_16( st_ivas->hDecoderConfig->Opt_tsm, 1 ) ) { - ivas_syn_output_f( p_output, output_frame, st_ivas->hTcBuffer->nchan_transport_jbm, data ); + ivas_syn_output_f_fx(p_output_fx, output_frame, st_ivas->hTcBuffer->nchan_transport_jbm, data_fx ); } - else + ELSE { /* directly copy to tc buffers */ -#ifdef IVAS_FLOAT_FIXED /*note : the q of cldfb buffers (imag/real) are needed to be Q_p_output - 5 here 6 is taken for that*/ - /*------------------------flt 2 fix----------------------*/ - Word16 Q_tc = 11; - DECODER_TC_BUFFER_HANDLE hTcBuffer = st_ivas->hTcBuffer; - Word16 n_ch_full_copy_temp = s_min( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full ); - Word16 n_ch_cldfb_tmp = hTcBuffer->nchan_transport_jbm - hTcBuffer->nchan_buffer_full; - if ( st_ivas->hParamIsmDec != NULL ) - { - f2me_16( st_ivas->hParamIsmDec->hParamIsm->last_dmx_gain, &st_ivas->hParamIsmDec->hParamIsm->last_dmx_gain_fx, &st_ivas->hParamIsmDec->hParamIsm->last_dmx_gain_e ); - } - // cldfb_state - - for ( int ch = 0; ch < n_ch_cldfb_tmp; ch++ ) - { - Word16 cldfb_size = st_ivas->cldfbAnaDec[ch]->cldfb_size; - for ( int lp = 0; lp < cldfb_size; lp++ ) - { - st_ivas->cldfbAnaDec[ch]->cldfb_state_fx[lp] = floatToFixed( st_ivas->cldfbAnaDec[ch]->cldfb_state[lp], Q_tc ); - } - } - // cldfb - Word16 num_freq_bands = 0; - - if ( st_ivas->ivas_format == ISM_FORMAT ) - { - if ( st_ivas->hSpatParamRendCom != NULL ) - { - num_freq_bands = st_ivas->hSpatParamRendCom->num_freq_bands; - } - for ( int lp = 0; lp < n_ch_cldfb_tmp; lp++ ) - { - Word16 length = 15 * num_freq_bands * n_ch_cldfb_tmp + num_freq_bands * ( n_ch_cldfb_tmp - 1 ) + st_ivas->cldfbAnaDec[lp]->no_channels; - for ( i = 0; i < length; i++ ) - { - st_ivas->hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc_fx[i] = - floatToFixed( st_ivas->hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc[i], 6 ); - st_ivas->hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc_fx[i] = - floatToFixed( st_ivas->hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc[i], 6 ); - } - } - } - else if ( st_ivas->ivas_format == MC_FORMAT ) - { - if ( st_ivas->hParamMC != NULL ) - { - num_freq_bands = st_ivas->hParamMC->num_freq_bands; - } - for ( int lp = 0; lp < n_ch_cldfb_tmp; lp++ ) - { - Word16 length = 15 * num_freq_bands * n_ch_cldfb_tmp + num_freq_bands * ( n_ch_cldfb_tmp - 1 ) + st_ivas->cldfbAnaDec[lp]->no_channels; - for ( Word16 lp2 = 0; lp2 < length; lp2++ ) - { - st_ivas->hParamMC->Cldfb_RealBuffer_tc_fx[lp2] = - floatToFixed( st_ivas->hParamMC->Cldfb_RealBuffer_tc[lp2], 6 ); - st_ivas->hParamMC->Cldfb_ImagBuffer_tc_fx[lp2] = - floatToFixed( st_ivas->hParamMC->Cldfb_ImagBuffer_tc[lp2], 6 ); - } - } - } - - /*------------------------flt 2 fix----------------------*/ - for ( int lp = 0; lp < n_ch_cldfb_tmp; lp++ ) - { - floatToFixed_arrL( p_output[lp], p_output_fx[lp], 11, 960 ); - } ivas_jbm_dec_copy_tc_no_tsm_fx( st_ivas, p_output_fx, output_frame ); - /*------------------------fix 2 flt----------------------*/ - // cldfb_state - for ( int lp = 0; lp < n_ch_cldfb_tmp; lp++ ) - { - fixedToFloat_arrL( p_output_fx[lp], p_output[lp], 11, 960 ); - } - - for ( int ch = 0; ch < n_ch_cldfb_tmp; ch++ ) - { - Word16 cldfb_size = st_ivas->cldfbAnaDec[ch]->cldfb_size; - for ( int lp = 0; lp < cldfb_size; lp++ ) - { - st_ivas->cldfbAnaDec[ch]->cldfb_state[lp] = fixedToFloat( st_ivas->cldfbAnaDec[ch]->cldfb_state_fx[lp], Q_tc ); - } - } - if ( st_ivas->ivas_format == ISM_FORMAT ) - { - if ( st_ivas->hSpatParamRendCom != NULL ) - { - num_freq_bands = st_ivas->hSpatParamRendCom->num_freq_bands; - } - for ( int lp = 0; lp < n_ch_cldfb_tmp; lp++ ) - { - Word16 length = 15 * num_freq_bands * n_ch_cldfb_tmp + num_freq_bands * ( n_ch_cldfb_tmp - 1 ) + st_ivas->cldfbAnaDec[lp]->no_channels; - for ( Word16 lp2 = 0; lp2 < length; lp2++ ) - { - st_ivas->hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc[lp2] = - fixedToFloat( st_ivas->hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc_fx[lp2], 6 ); - st_ivas->hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc[lp2] = - fixedToFloat( st_ivas->hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc_fx[lp2], 6 ); - } - } - } - else if ( st_ivas->ivas_format == MC_FORMAT ) - { - if ( st_ivas->hParamMC != NULL ) - { - num_freq_bands = st_ivas->hParamMC->num_freq_bands; - } - for ( int lp = 0; lp < n_ch_cldfb_tmp; lp++ ) - { - Word16 length = 15 * num_freq_bands * n_ch_cldfb_tmp + num_freq_bands * ( n_ch_cldfb_tmp - 1 ) + st_ivas->cldfbAnaDec[lp]->no_channels; - for ( Word16 lp2 = 0; lp2 < length; lp2++ ) - { - st_ivas->hParamMC->Cldfb_RealBuffer_tc[lp2] = - fixedToFloat( st_ivas->hParamMC->Cldfb_RealBuffer_tc_fx[lp2], 6 ); - st_ivas->hParamMC->Cldfb_ImagBuffer_tc[lp2] = - fixedToFloat( st_ivas->hParamMC->Cldfb_ImagBuffer_tc_fx[lp2], 6 ); - } - } - } - - if ( st_ivas->hParamIsmDec != NULL ) - { - st_ivas->hParamIsmDec->hParamIsm->last_dmx_gain = me2f_16( st_ivas->hParamIsmDec->hParamIsm->last_dmx_gain_fx, st_ivas->hParamIsmDec->hParamIsm->last_dmx_gain_e ); - } - - IF( st_ivas->hDecoderConfig->Opt_tsm ) - { - FOR( int lp = 0; lp < n_ch_full_copy_temp; lp++ ) - { - fixedToFloat_arrL( st_ivas->hTcBuffer->tc_fx[lp], st_ivas->hTcBuffer->tc[lp], Q_tc, hTcBuffer->n_samples_buffered ); - } - } - /*------------------------fix 2 flt----------------------*/ -#endif } /*----------------------------------------------------------------* * Common updates *----------------------------------------------------------------*/ - if ( !st_ivas->bfi ) /* do not update if first frame(s) are lost or NO_DATA */ + IF ( !st_ivas->bfi ) /* do not update if first frame(s) are lost or NO_DATA */ { - st_ivas->hDecoderConfig->last_ivas_total_brate = ivas_total_brate; + st_ivas->hDecoderConfig->last_ivas_total_brate = ivas_total_brate; move32(); st_ivas->last_active_ivas_total_brate = ( ivas_total_brate <= IVAS_SID_5k2 ) ? st_ivas->last_active_ivas_total_brate : ivas_total_brate; } - if ( st_ivas->ini_frame < MAX_FRAME_COUNTER && !( st_ivas->bfi && st_ivas->ini_frame == 0 ) ) /* keep "st_ivas->ini_frame = 0" until first good received frame */ + IF ( st_ivas->ini_frame < MAX_FRAME_COUNTER && !( st_ivas->bfi && st_ivas->ini_frame == 0 ) ) /* keep "st_ivas->ini_frame = 0" until first good received frame */ { - st_ivas->ini_frame++; + st_ivas->ini_frame = add( st_ivas->ini_frame, 1 ); } - if ( st_ivas->ini_active_frame < MAX_FRAME_COUNTER && !( st_ivas->bfi && st_ivas->ini_frame == 0 ) && ivas_total_brate > IVAS_SID_5k2 ) /* needed in MASA decoder in case the first active frame is BFI, and there were SID-frames decoded before */ + IF ( st_ivas->ini_active_frame < MAX_FRAME_COUNTER && !( st_ivas->bfi && st_ivas->ini_frame == 0 ) && ivas_total_brate > IVAS_SID_5k2 ) /* needed in MASA decoder in case the first active frame is BFI, and there were SID-frames decoded before */ { - st_ivas->ini_active_frame++; + st_ivas->ini_active_frame = add( st_ivas->ini_active_frame, 1 ); } st_ivas->last_ivas_format = st_ivas->ivas_format; - - pop_wmops(); return IVAS_ERR_OK; diff --git a/lib_dec/ivas_ls_custom_dec.c b/lib_dec/ivas_ls_custom_dec.c index 7c35700f2..25a0cec62 100644 --- a/lib_dec/ivas_ls_custom_dec.c +++ b/lib_dec/ivas_ls_custom_dec.c @@ -119,10 +119,10 @@ void ivas_ls_custom_setup( } hOutSetup->ls_azimuth_fx = hLsSetupCustom->ls_azimuth_fx; hOutSetup->ls_elevation_fx = hLsSetupCustom->ls_elevation_fx; -#endif +#else hOutSetup->ls_azimuth = hLsSetupCustom->ls_azimuth; hOutSetup->ls_elevation = hLsSetupCustom->ls_elevation; - +#endif hOutSetup->num_lfe = hLsSetupCustom->num_lfe; hOutSetup->index_lfe[0] = hLsSetupCustom->lfe_idx[0]; /* IVAS_OUTPUT_SETUP only supports 1 LFE */ diff --git a/lib_dec/ivas_mc_param_dec.c b/lib_dec/ivas_mc_param_dec.c index c55f1b039..0cb463858 100644 --- a/lib_dec/ivas_mc_param_dec.c +++ b/lib_dec/ivas_mc_param_dec.c @@ -235,7 +235,7 @@ ivas_error ivas_param_mc_dec_open_fx( if ( output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM ) { st_ivas->hIntSetup.nchan_out_woLFE = st_ivas->hLsSetupCustom->num_spk; -#if 1/*TODO: To be removed later*/ +#if 0/*TODO: To be removed later*/ st_ivas->hIntSetup.ls_azimuth = st_ivas->hLsSetupCustom->ls_azimuth; st_ivas->hIntSetup.ls_elevation = st_ivas->hLsSetupCustom->ls_elevation; #endif diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index 7be244980..183e03395 100644 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -53,7 +53,9 @@ * Local function prototypes *-----------------------------------------------------------------------*/ +#ifdef IVAS_FLOAT_FIXED static ivas_error ivas_mc_dec_reconfig( Decoder_Struct *st_ivas, uint16_t *nSamplesRendered, int16_t *data ); +#endif /*--------------------------------------------------------------------------* diff --git a/lib_dec/ivas_mdct_core_dec.c b/lib_dec/ivas_mdct_core_dec.c index 865381ef1..e04332462 100644 --- a/lib_dec/ivas_mdct_core_dec.c +++ b/lib_dec/ivas_mdct_core_dec.c @@ -93,7 +93,7 @@ void mdct_read_IGF_bits_fx( return; } #endif - +#ifndef IVAS_FLOAT_FIXED void mdct_read_IGF_bits( Decoder_State *st, /* i/o: Decoder state handle */ Decoder_State *st0 /* i : pointer to handle where bitstream is read */ @@ -127,7 +127,7 @@ void mdct_read_IGF_bits( return; } - +#endif /*-----------------------------------------------------------------* * Function dec_prm_tcx_sidebits() diff --git a/lib_dec/ivas_out_setup_conversion.c b/lib_dec/ivas_out_setup_conversion.c index 7b3202d6a..0510723e9 100644 --- a/lib_dec/ivas_out_setup_conversion.c +++ b/lib_dec/ivas_out_setup_conversion.c @@ -329,7 +329,7 @@ static void get_custom_ls_conversion_matrix_fx( { /* Set the values of hLsSetUpConversion->dmxMtx to EFAP gains, skipping LFE */ /*angles float2fix conversion: to be removed*/ - efap_determine_gains_fx( hEFAPdata, tmp_gains, L_shl((Word32)hTransSetup.ls_azimuth[ch_in_woLFE], Q22), L_shl((Word32)hTransSetup.ls_elevation[ch_in_woLFE], Q22), EFAP_MODE_EFAP ); + efap_determine_gains_fx( hEFAPdata, tmp_gains, hTransSetup.ls_azimuth_fx[ch_in_woLFE], hTransSetup.ls_elevation_fx[ch_in_woLFE], EFAP_MODE_EFAP ); FOR( ( ch_out = 0, ch_out_woLFE = 0 ); ch_out < nchan_out; ( ch_out++, ch_out_woLFE++ ) ) { diff --git a/lib_dec/ivas_sce_dec_fx.c b/lib_dec/ivas_sce_dec_fx.c index 139edc693..b448f259f 100644 --- a/lib_dec/ivas_sce_dec_fx.c +++ b/lib_dec/ivas_sce_dec_fx.c @@ -236,27 +236,14 @@ ivas_error ivas_sce_dec_fx( /*----------------------------------------------------------------* * Decoder *----------------------------------------------------------------*/ -#ifndef TO_BE_REMOVED_CONVERSION - if (st->hHQ_core != NULL) - { - floatToFixed_arr(st->hHQ_core->old_out, st->hHQ_core->old_out_fx, st->hHQ_core->Q_old_wtda, L_FRAME48k); - floatToFixed_arr(st->hHQ_core->old_outLB, st->hHQ_core->old_out_LB_fx, st->hHQ_core->Q_old_wtda_LB, L_FRAME32k); - floatToFixed_arrL(st->hHQ_core->old_outLB, st->hHQ_core->old_outLB_fx, 11, L_FRAME32k); - } -#endif - set32_fx(output[0], 0, L_FRAME48k); + + set32_fx( output[0], 0, L_FRAME48k ); IF( ( error = ivas_core_dec( st_ivas, hSCE, NULL, NULL, 1, output, outputHB, NULL, st_ivas->sba_dirac_stereo_flag ) ) != IVAS_ERR_OK ) { return error; } - IF ( st->hHQ_core != NULL ) - { - fixedToFloat_arr( st->hHQ_core->old_out_fx, st->hHQ_core->old_out, st->hHQ_core->Q_old_wtda, L_FRAME48k ); - fixedToFloat_arr( st->hHQ_core->old_out_LB_fx, st->hHQ_core->old_outLB, st->hHQ_core->Q_old_wtda_LB, L_FRAME32k ); - } - IF( st_ivas->sba_dirac_stereo_flag && ( GT_32( st->core_brate, SID_2k40 ) || EQ_16( st->cng_type, LP_CNG ) ) ) { /* skip addition of ACELP BWE for now, will be done after upmix */ diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index 7bbf1b85a..40f8de567 100644 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -2915,9 +2915,6 @@ void ivas_spar_dec_upmixer_sf_fx( ) { /*TODO: To be removed later--------------------------------------------------------*/ - float *cldfb_in_ts_re[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS][CLDFB_NO_COL_MAX]; - float *cldfb_in_ts_im[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS][CLDFB_NO_COL_MAX]; - float Pcm_tmp[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS][L_FRAME48k]; float output[MAX_OUTPUT_CHANNELS][L_FRAME48k]; float *p_output[MAX_OUTPUT_CHANNELS]; /*---------------------------------------------------------------------------*/ @@ -3011,14 +3008,8 @@ void ivas_spar_dec_upmixer_sf_fx( { FOR ( ts = 0; ts < MAX_PARAM_SPATIAL_SUBFRAMES; ts++ ) { - /*TODO:To be removed when ivas_dirac_dec_render_sf is integerated*/ - cldfb_in_ts_re[in_ch][ts] = &Pcm_tmp[in_ch][ts * num_cldfb_bands]; - cldfb_in_ts_im[in_ch][ts] = &Pcm_tmp[in_ch][ts * num_cldfb_bands + 4 * num_cldfb_bands]; - /****************************************************************/ -#ifdef IVAS_FLOAT_FIXED cldfb_in_ts_re_fx[in_ch][ts] = &Pcm_tmp_fx[in_ch][ts * num_cldfb_bands]; cldfb_in_ts_im_fx[in_ch][ts] = &Pcm_tmp_fx[in_ch][ts * num_cldfb_bands + 4 * num_cldfb_bands]; -#endif } } } @@ -3028,14 +3019,8 @@ void ivas_spar_dec_upmixer_sf_fx( { FOR ( ts = 0; ts < MAX_PARAM_SPATIAL_SUBFRAMES; ts++ ) { - /*TODO:To be removed when ivas_dirac_dec_render_sf is integerated*/ - cldfb_in_ts_re[in_ch][ts] = &Pcm_tmp[in_ch][ts * num_cldfb_bands]; - cldfb_in_ts_im[in_ch][ts] = &Pcm_tmp[in_ch][ts * num_cldfb_bands + 4 * num_cldfb_bands]; - /****************************************************************/ -#ifdef IVAS_FLOAT_FIXED cldfb_in_ts_re_fx[in_ch][ts] = &Pcm_tmp_fx[in_ch][ts * num_cldfb_bands]; cldfb_in_ts_im_fx[in_ch][ts] = &Pcm_tmp_fx[in_ch][ts * num_cldfb_bands + 4 * num_cldfb_bands]; -#endif } } } @@ -3204,36 +3189,6 @@ void ivas_spar_dec_upmixer_sf_fx( } } -#ifdef IVAS_FLOAT_FIXED /*Fixed to float */ - IF(NE_16(hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_FOA)) - { - FOR(in_ch = 0; in_ch < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; in_ch++) - { - FOR(ts = 0; ts < hSpar->subframe_nbslots[hSpar->subframes_rendered]; ts++) - { - FOR(i = 0; i < CLDFB_NO_CHANNELS_MAX; i++) - { - cldfb_in_ts_re[in_ch][ts][i] = (float)(cldfb_in_ts_re_fx[in_ch][ts][i]) / (float)(1LL << 6); /*Resultant q is 6*/ - cldfb_in_ts_im[in_ch][ts][i] = (float)(cldfb_in_ts_im_fx[in_ch][ts][i]) / (float)(1LL << 6); /*Resultant q is 6*/ - } - } - } - } - ELSE - { - FOR ( in_ch = 0; in_ch < numch_in; in_ch++ ) - { - FOR ( ts = 0; ts < hSpar->subframe_nbslots[hSpar->subframes_rendered]; ts++ ) - { - FOR ( i = 0; i < CLDFB_NO_CHANNELS_MAX; i++ ) - { - cldfb_in_ts_re[in_ch][ts][i] = (float) ( cldfb_in_ts_re_fx[in_ch][ts][i] ) / (float) ( 1LL << 6 ); /*Resultant q is 6*/ - cldfb_in_ts_im[in_ch][ts][i] = (float) ( cldfb_in_ts_im_fx[in_ch][ts][i] ) / (float) ( 1LL << 6 ); /*Resultant q is 6*/ - } - } - } - } -#endif IF ( NE_16(hDecoderConfig->output_config , IVAS_AUDIO_CONFIG_FOA) && NE_16(hDecoderConfig->output_config , IVAS_AUDIO_CONFIG_STEREO) && NE_16(hDecoderConfig->output_config , IVAS_AUDIO_CONFIG_MONO) ) { FOR( Word16 ch = 0; ch < add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ); ch++ ) @@ -3242,14 +3197,10 @@ void ivas_spar_dec_upmixer_sf_fx( p_output[ch] = output[ch]; } #ifdef MSAN_FIX - ivas_dirac_dec_render_sf_fx( st_ivas, p_output, output_fx, nchan_internal, cldfb_in_ts_re, cldfb_in_ts_im ); + ivas_dirac_dec_render_sf_fx( st_ivas, p_output, output_fx, nchan_internal, cldfb_in_ts_re_fx, cldfb_in_ts_im_fx ); #else - ivas_dirac_dec_render_sf_fx( st_ivas, p_output, nchan_internal, cldfb_in_ts_re, cldfb_in_ts_im ); + ivas_dirac_dec_render_sf_fx( st_ivas, p_output, nchan_internal, cldfb_in_ts_re_fx, cldfb_in_ts_im_fx ); #endif // MSAN_FIX - FOR( Word16 ch = 0; ch < add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ); ch++ ) - { - floatToFixed_arrL( output[ch], output_fx[ch], Q11, out_len ); - } /*TODO: To be removed later when ivas_dirac_dec_render_sf is integerated*/ FOR( out_ch = 0; out_ch < numch_out_dirac; out_ch++ ) { @@ -3262,39 +3213,6 @@ void ivas_spar_dec_upmixer_sf_fx( } } } -#ifdef MSAN_FIX - IF(NE_16(hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_FOA)) - { - FOR(out_ch = 0; out_ch < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; out_ch++) - { - FOR(ts = 0; ts < hSpar->subframe_nbslots[hSpar->subframes_rendered]; ts++) - { - floatToFixed_arrL(cldfb_in_ts_re[out_ch][ts], cldfb_in_ts_re_fx[out_ch][ts], Q6, num_cldfb_bands); - floatToFixed_arrL(cldfb_in_ts_im[out_ch][ts], cldfb_in_ts_im_fx[out_ch][ts], Q6, num_cldfb_bands); - } - } - } - ELSE - { - FOR( out_ch = 0; out_ch < st_ivas->hOutSetup.nchan_out_woLFE; out_ch++ ) - { - FOR( ts = 0; ts < hSpar->subframe_nbslots[hSpar->subframes_rendered]; ts++ ) - { - floatToFixed_arrL( cldfb_in_ts_re[out_ch][ts], cldfb_in_ts_re_fx[out_ch][ts], Q6, num_cldfb_bands ); - floatToFixed_arrL( cldfb_in_ts_im[out_ch][ts], cldfb_in_ts_im_fx[out_ch][ts], Q6, num_cldfb_bands ); - } - } - } -#else - FOR( out_ch = 0; out_ch < numch_out_dirac; out_ch++ ) - { - FOR( ts = 0; ts < hSpar->subframe_nbslots[hSpar->subframes_rendered]; ts++ ) - { - floatToFixed_arrL( cldfb_in_ts_re[out_ch][ts], cldfb_in_ts_re_fx[out_ch][ts], Q6, 60 ); - floatToFixed_arrL( cldfb_in_ts_im[out_ch][ts], cldfb_in_ts_im_fx[out_ch][ts], Q6, 60 ); - } - } -#endif /*------------------------------------------------------------------ends*/ IF ( st_ivas->hDirAC != NULL ) { diff --git a/lib_dec/ivas_stereo_dft_dec_fx.c b/lib_dec/ivas_stereo_dft_dec_fx.c index 95f6d119b..0aa7f0f61 100644 --- a/lib_dec/ivas_stereo_dft_dec_fx.c +++ b/lib_dec/ivas_stereo_dft_dec_fx.c @@ -145,7 +145,7 @@ void stereo_dft_dec_reset_fx( move16(); bass_psfilter_init_fx( hStereoDft->hBpf ); - tcxltp_dec_init( hStereoDft->hTcxLtpDec, 0, MODE1, IVAS_CPE_DFT, PIT_MAX, 12800 ); + tcxltp_dec_init_fx( hStereoDft->hTcxLtpDec, 0, MODE1, IVAS_CPE_DFT, PIT_MAX, 12800 ); hStereoDft->reverb_flag = 0; move16(); @@ -3351,11 +3351,11 @@ void stereo_dft_dec_read_BS_fx( /* read number of bands in the bitstream - depends on the audio bandwidth and not to output_Fs */ IF( hStereoDft->frame_sid ) { - NFFT_inner = mult( inner_frame_tbl[bwidth], divide1616( STEREO_DFT32MS_N_MAX, L_FRAME48k ) ); + NFFT_inner = mult_r( inner_frame_tbl[bwidth], divide1616( STEREO_DFT32MS_N_MAX, L_FRAME48k ) ); } ELSE { - NFFT_inner = mult( inner_frame_tbl[st->bwidth], divide1616( STEREO_DFT32MS_N_MAX, L_FRAME48k ) ); + NFFT_inner = mult_r( inner_frame_tbl[st->bwidth], divide1616( STEREO_DFT32MS_N_MAX, L_FRAME48k ) ); } /* Use coarse band partition in inactive frames */ diff --git a/lib_dec/ivas_stereo_mdct_core_dec_fx.c b/lib_dec/ivas_stereo_mdct_core_dec_fx.c index 207232428..99534d9b9 100644 --- a/lib_dec/ivas_stereo_mdct_core_dec_fx.c +++ b/lib_dec/ivas_stereo_mdct_core_dec_fx.c @@ -287,7 +287,7 @@ void stereo_mdct_core_dec_fx( { L_spec[ch] = idiv1616(sts[ch]->hTcxCfg->tcx_coded_lines, nSubframes[ch]); - init_tcx_info( sts[ch], sts[ch]->L_frame / nSubframes[ch], sts[ch]->hTcxDec->L_frameTCX / nSubframes[ch], k, bfi, &tcx_offset[ch], &tcx_offsetFB[ch], &L_frame[ch], &L_frameTCX[ch], &left_rect[ch], &L_spec[ch] ); + init_tcx_info_fx( sts[ch], sts[ch]->L_frame / nSubframes[ch], sts[ch]->hTcxDec->L_frameTCX / nSubframes[ch], k, bfi, &tcx_offset[ch], &tcx_offsetFB[ch], &L_frame[ch], &L_frameTCX[ch], &left_rect[ch], &L_spec[ch] ); } } diff --git a/lib_dec/ivas_stereo_switching_dec.c b/lib_dec/ivas_stereo_switching_dec.c index 55f04691e..b8a5cc5c0 100644 --- a/lib_dec/ivas_stereo_switching_dec.c +++ b/lib_dec/ivas_stereo_switching_dec.c @@ -176,10 +176,6 @@ static ivas_error allocate_CoreCoder_TCX_fx( } tcxltp_dec_init_fx( st->hTcxLtpDec, 0, st->last_codec_mode, st->element_mode, st->pit_max, st->sr_core ); - -#if 1 // TODO: TO be removed later - tcxltp_dec_init( st->hTcxLtpDec, 0, st->last_codec_mode, st->element_mode, st->pit_max, st->sr_core ); -#endif } /* allocate HQ structure */ @@ -203,9 +199,6 @@ static ivas_error allocate_CoreCoder_TCX_fx( st->igf = 0; move16(); init_igf_dec( st->hIGFDec ); -#if 1 // TODO: TO be removed later - init_igf_dec_flt( st->hIGFDec ); -#endif } IF ( st->hTonalMDCTConc == NULL ) @@ -3156,7 +3149,7 @@ void stereo_switching_dec( sts[1]->last_coder_type = sts[0]->last_coder_type; #ifndef IVAS_FLOAT_CONV_TO_BE_REMOVED - mvr2r( sts[0]->hHQ_core->old_out, sts[1]->hHQ_core->old_out, L_FRAME48k ); + //mvr2r( sts[0]->hHQ_core->old_out, sts[1]->hHQ_core->old_out, L_FRAME48k ); //mvr2r( sts[0]->hTcxDec->old_syn_Overl_float, sts[1]->hTcxDec->old_syn_Overl_float, 256 ); #endif #ifndef IVAS_FLOAT_FIXED diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 7fe92402c..97c00f323 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -79,6 +79,10 @@ struct IVAS_DEC Word16 tsm_max_scaling; float tsm_quality; float *apaExecBuffer; /* Buffer for APA scaling */ + +#ifdef IVAS_FLOAT_FIXED + Word32 *apaExecBuffer_fx; /* Buffer for APA scaling */ +#endif PCMDSP_APA_HANDLE hTimeScaler; bool needNewFrame; bool hasBeenFedFrame; @@ -105,7 +109,7 @@ static ivas_error input_format_API_to_internal( IVAS_DEC_INPUT_FORMAT input_form static void init_decoder_config( DECODER_CONFIG_HANDLE hDecoderConfig ); static ivas_error IVAS_DEC_VoIP_reconfigure( IVAS_DEC_HANDLE hIvasDec, const UWord16 nTransportChannels, const UWord16 l_ts ); static ivas_error IVAS_DEC_Setup( IVAS_DEC_HANDLE hIvasDec, UWord16 *nTcBufferGranularity, UWord8 *nTransportChannels, UWord8 *nOutChannels, UWord16 *nSamplesRendered, Word16 *data ); -static ivas_error IVAS_DEC_GetTcSamples( IVAS_DEC_HANDLE hIvasDec, float *pcmBuf, Word16 *nOutSamples ); +static ivas_error IVAS_DEC_GetTcSamples( IVAS_DEC_HANDLE hIvasDec, float *pcmBuf, Word32 *pcmBuf_fx, Word16 *nOutSamples ); static ivas_error IVAS_DEC_RendererFeedTcSamples( IVAS_DEC_HANDLE hIvasDec, const Word16 nSamplesForRendering, Word16 *nSamplesResidual, float *pcmBuf ); static ivas_error IVAS_DEC_GetRenderedSamples( IVAS_DEC_HANDLE hIvasDec, const UWord16 nSamplesForRendering, UWord16 *nSamplesRendered, UWord16 *nSamplesAvailableNext, Word16 *pcmBuf ); static ivas_error IVAS_DEC_GetBufferedNumberOfSamples( IVAS_DEC_HANDLE hIvasDec, Word16 *nSamplesBuffered ); @@ -143,6 +147,9 @@ ivas_error IVAS_DEC_Open( hIvasDec = *phIvasDec; hIvasDec->hVoIP = NULL; hIvasDec->apaExecBuffer = NULL; +#ifdef IVAS_FLOAT_FIXED + hIvasDec->apaExecBuffer_fx = NULL; +#endif hIvasDec->hTimeScaler = NULL; hIvasDec->tsm_scale = 100; hIvasDec->tsm_max_scaling = 0; @@ -297,6 +304,12 @@ void IVAS_DEC_Close( { free( ( *phIvasDec )->apaExecBuffer ); } +#ifdef IVAS_FLOAT_FIXED + IF( ( *phIvasDec )->apaExecBuffer_fx != NULL ) + { + free( ( *phIvasDec )->apaExecBuffer_fx ); + } +#endif free( *phIvasDec ); *phIvasDec = NULL; phIvasDec = NULL; @@ -918,7 +931,7 @@ ivas_error IVAS_DEC_GetSamples( } /* IVAS decoder */ - IF( ( error = IVAS_DEC_GetTcSamples( hIvasDec, hIvasDec->apaExecBuffer, &nOutSamplesElse ) ) != IVAS_ERR_OK ) + IF( ( error = IVAS_DEC_GetTcSamples( hIvasDec, hIvasDec->apaExecBuffer, hIvasDec->apaExecBuffer_fx, &nOutSamplesElse ) ) != IVAS_ERR_OK ) { return error; } @@ -1059,6 +1072,7 @@ static ivas_error IVAS_DEC_Setup( static ivas_error IVAS_DEC_GetTcSamples( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ float *pcmBuf, /* i/o: buffer for decoded PCM output. The memory must already be allocated and be able to hold the expected number of output samples, based on frame size and number of output channels */ + Word32 *pcmBuf_fx, /* i/o: buffer for decoded PCM output. The memory must already be allocated and be able to hold the expected number of output samples, based on frame size and number of output channels */ Word16 *nOutSamples /* o : number of samples per channel written to output buffer */ ) { @@ -1081,17 +1095,334 @@ static ivas_error IVAS_DEC_GetTcSamples( return error; } } - ELSE IF( EQ_16( (Word16) hIvasDec->mode, IVAS_DEC_MODE_IVAS ) ) + ELSE IF(EQ_16((Word16)hIvasDec->mode, IVAS_DEC_MODE_IVAS)) { /* run the main IVAS decoding routine */ - IF( ( error = ivas_jbm_dec_tc( st_ivas, pcmBuf ) ) != IVAS_ERR_OK ) + /*------------------------flt 2 fix----------------------*/ + Word16 l, n; + Decoder_State *st, **sts; /* used for bitstream handling */ + MCT_DEC_HANDLE hMCT; + Word16 ch, nCPE, cpe_id; + nCPE = st_ivas->nCPE; + Word16 Q_tc = 11; + DECODER_TC_BUFFER_HANDLE hTcBuffer = st_ivas->hTcBuffer; + Word16 n_ch_cldfb_tmp = hTcBuffer->nchan_transport_jbm - hTcBuffer->nchan_buffer_full; + hMCT = st_ivas->hMCT; + Word16 num_freq_bands = 0; + /* Float to Fixed */ + + Word16 n_ch_full_copy_temp = s_min(hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full); + IF(pcmBuf != NULL) + { + floatToFixed_arrL(pcmBuf, pcmBuf_fx, 11, (Word16)(st_ivas->hTcBuffer->nchan_transport_jbm * st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC)); + } + + IF(EQ_16(st_ivas->hDecoderConfig->Opt_tsm, 0)) { + FOR( n = 0; n < ivas_get_nchan_buffers_dec_ivas_fx(st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate); n++) + { + set_zero(st_ivas->p_output_f[n], L_FRAME48k); + st_ivas->hTcBuffer->tc[n] = st_ivas->p_output_f[n]; + } + } + + +#if 1 + CPE_DEC_HANDLE hCPE; + IF(((st_ivas->mc_mode == MC_MODE_PARAMUPMIX) || (st_ivas->mc_mode == MC_MODE_MCT) || st_ivas->ivas_format == SBA_ISM_FORMAT || (st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == MASA_FORMAT) || st_ivas->mc_mode == MC_MODE_PARAMMC) && (GT_16(st_ivas->nCPE, 1))) { + + nCPE = st_ivas->nCPE; + move16(); + hMCT = st_ivas->hMCT; + FOR(cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++) + { + hCPE = st_ivas->hCPE[cpe_id]; + sts = hCPE->hCoreCoder; + + + FOR(n = 0; n < CPE_CHANNELS; n++) + { + st = hCPE->hCoreCoder[n]; + IF(sts[n]->mct_chan_mode != MCT_CHAN_MODE_IGNORE) + { + // u8bit to 16bit + FOR(l = 0; l < IGF_START_MX; l++) + { + sts[n]->hIGFDec->infoTCXNoise_evs[l] = (Word16)sts[n]->hIGFDec->infoTCXNoise[l]; + } + } + IF(st->hTcxDec) + st->hTcxDec->conNoiseLevelIndex = st->hTcxDec->NoiseLevelIndex_bfi; + IF(st->hTcxDec) + st->hTcxDec->conCurrLevelIndex = st->hTcxDec->CurrLevelIndex_bfi; + + /*cldfb struct*/ + + /*------------------fix-to-fix-start---------------------*/ + /*core_switching_post_dec*/ + IF(hCPE->hCoreCoder[n]->hHQ_core != NULL) + { + hCPE->hCoreCoder[n]->hHQ_core->Q_old_postdec = 0; + hCPE->hCoreCoder[n]->hHQ_core->Q_old_wtda = 0; + } + } + } + } + + IF( NE_16( st_ivas->hDecoderConfig->Opt_tsm, 1) ) { + + IF (st_ivas->hParamIsmDec != NULL) + { + f2me_16(st_ivas->hParamIsmDec->hParamIsm->last_dmx_gain, &st_ivas->hParamIsmDec->hParamIsm->last_dmx_gain_fx, &st_ivas->hParamIsmDec->hParamIsm->last_dmx_gain_e); + } + // cldfb_state + + FOR ( ch = 0; ch < n_ch_cldfb_tmp; ch++) + { + Word16 cldfb_size = st_ivas->cldfbAnaDec[ch]->cldfb_size; + FOR (Word16 lp = 0; lp < cldfb_size; lp++) + { + st_ivas->cldfbAnaDec[ch]->cldfb_state_fx[lp] = floatToFixed(st_ivas->cldfbAnaDec[ch]->cldfb_state[lp], Q_tc); + } + } + // cldfb + + + IF (st_ivas->ivas_format == ISM_FORMAT) + { + IF (st_ivas->hSpatParamRendCom != NULL) + { + num_freq_bands = st_ivas->hSpatParamRendCom->num_freq_bands; + } + FOR (Word16 lp = 0; lp < n_ch_cldfb_tmp; lp++) + { + Word16 length = 15 * num_freq_bands * n_ch_cldfb_tmp + num_freq_bands * (n_ch_cldfb_tmp - 1) + st_ivas->cldfbAnaDec[lp]->no_channels; + FOR (Word16 i = 0; i < length; i++) + { + st_ivas->hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc_fx[i] = + floatToFixed(st_ivas->hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc[i], 6); + st_ivas->hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc_fx[i] = + floatToFixed(st_ivas->hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc[i], 6); + } + } + } + ELSE IF(st_ivas->ivas_format == MC_FORMAT) + { + IF(st_ivas->hParamMC != NULL) + { + num_freq_bands = st_ivas->hParamMC->num_freq_bands; + } + FOR(Word16 lp = 0; lp < n_ch_cldfb_tmp; lp++) + { + Word16 length = 15 * num_freq_bands * n_ch_cldfb_tmp + num_freq_bands * (n_ch_cldfb_tmp - 1) + st_ivas->cldfbAnaDec[lp]->no_channels; + FOR(Word16 lp2 = 0; lp2 < length; lp2++) + { + st_ivas->hParamMC->Cldfb_RealBuffer_tc_fx[lp2] = + floatToFixed(st_ivas->hParamMC->Cldfb_RealBuffer_tc[lp2], 6); + st_ivas->hParamMC->Cldfb_ImagBuffer_tc_fx[lp2] = + floatToFixed(st_ivas->hParamMC->Cldfb_ImagBuffer_tc[lp2], 6); + } + } + } + } +#endif + + /* Function call: ivas_jbm_dec_tc function */ + IF((error = ivas_jbm_dec_tc_fx(st_ivas, pcmBuf_fx)) != IVAS_ERR_OK) { return error; } +#if 1 + /* Fixed to Float */ + IF(pcmBuf != NULL) + { + fixedToFloat_arrL(pcmBuf_fx, pcmBuf, 11, (Word16)(st_ivas->hTcBuffer->nchan_transport_jbm * st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC)); + } + + FOR(n = 0; n < MAX_TRANSPORT_CHANNELS; n++) { + IF(st_ivas->p_output_f[n] != NULL) + { + fixedToFloat_arrL(st_ivas->p_output_fx[n], st_ivas->p_output_f[n], 11, L_FRAME48k); + } + } + + IF( NE_16( st_ivas->hDecoderConfig->Opt_tsm, 1 ) ) + { + FOR(Word16 lp = 0; lp < n_ch_full_copy_temp; lp++) + { + fixedToFloat_arrL(st_ivas->hTcBuffer->tc_fx[lp], st_ivas->hTcBuffer->tc[lp], Q11, st_ivas->hTcBuffer->n_samples_buffered); + } + + FOR( ch = 0; ch < n_ch_cldfb_tmp; ch++) + { + Word16 cldfb_size = st_ivas->cldfbAnaDec[ch]->cldfb_size; + FOR(Word16 lp = 0; lp < cldfb_size; lp++) + { + st_ivas->cldfbAnaDec[ch]->cldfb_state[lp] = fixedToFloat(st_ivas->cldfbAnaDec[ch]->cldfb_state_fx[lp], Q_tc); + } + } + IF(st_ivas->ivas_format == ISM_FORMAT) + { + IF(st_ivas->hSpatParamRendCom != NULL) + { + num_freq_bands = st_ivas->hSpatParamRendCom->num_freq_bands; + } + FOR(Word16 lp = 0; lp < n_ch_cldfb_tmp; lp++) + { + Word16 length = 15 * num_freq_bands * n_ch_cldfb_tmp + num_freq_bands * (n_ch_cldfb_tmp - 1) + st_ivas->cldfbAnaDec[lp]->no_channels; + FOR(Word16 lp2 = 0; lp2 < length; lp2++) + { + st_ivas->hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc[lp2] = + fixedToFloat(st_ivas->hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc_fx[lp2], 6); + st_ivas->hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc[lp2] = + fixedToFloat(st_ivas->hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc_fx[lp2], 6); + } + } + } + ELSE IF(st_ivas->ivas_format == MC_FORMAT) + { + IF(st_ivas->hParamMC != NULL) + { + num_freq_bands = st_ivas->hParamMC->num_freq_bands; + } + FOR(Word16 lp = 0; lp < n_ch_cldfb_tmp; lp++) + { + Word16 length = 15 * num_freq_bands * n_ch_cldfb_tmp + num_freq_bands * (n_ch_cldfb_tmp - 1) + st_ivas->cldfbAnaDec[lp]->no_channels; + FOR(Word16 lp2 = 0; lp2 < length; lp2++) + { + st_ivas->hParamMC->Cldfb_RealBuffer_tc[lp2] = + fixedToFloat(st_ivas->hParamMC->Cldfb_RealBuffer_tc_fx[lp2], 6); + st_ivas->hParamMC->Cldfb_ImagBuffer_tc[lp2] = + fixedToFloat(st_ivas->hParamMC->Cldfb_ImagBuffer_tc_fx[lp2], 6); + } + } + } + + IF(st_ivas->hParamIsmDec != NULL) + { + st_ivas->hParamIsmDec->hParamIsm->last_dmx_gain = me2f_16(st_ivas->hParamIsmDec->hParamIsm->last_dmx_gain_fx, st_ivas->hParamIsmDec->hParamIsm->last_dmx_gain_e); + } + /*------------------------fix 2 flt----------------------*/ + } + hIvasDec->isInitialized = true; /* Initialization done in ivas_dec() */ - } + IF((st_ivas->ivas_format == MASA_FORMAT && st_ivas->hQMetaData != NULL) || (st_ivas->ivas_format == MASA_ISM_FORMAT)) + { + // Fix to float conversion starts here. + IF(st_ivas->hSpatParamRendCom != NULL) + { + FOR(Word16 i = 0; i < st_ivas->hSpatParamRendCom->dirac_md_buffer_length; i++) + { + FOR(Word16 j = 0; j < st_ivas->hSpatParamRendCom->num_freq_bands; j++) + { + st_ivas->hSpatParamRendCom->energy_ratio1[i][j] = fix_to_float(st_ivas->hSpatParamRendCom->energy_ratio1_fx[i][j], 30); + st_ivas->hSpatParamRendCom->diffuseness_vector[i][j] = fix_to_float(st_ivas->hSpatParamRendCom->diffuseness_vector_fx[i][j], 30); + IF(EQ_32(st_ivas->hQMetaData->no_directions, 2)) + { + st_ivas->hSpatParamRendCom->energy_ratio2[i][j] = fix_to_float(st_ivas->hSpatParamRendCom->energy_ratio2_fx[i][j], 30); + st_ivas->hSpatParamRendCom->spreadCoherence2[i][j] = fix_to_float(st_ivas->hSpatParamRendCom->spreadCoherence2_fx[i][j], 15); + } + st_ivas->hSpatParamRendCom->surroundingCoherence[i][j] = fix_to_float(st_ivas->hSpatParamRendCom->surroundingCoherence_fx[i][j], 15); + st_ivas->hSpatParamRendCom->spreadCoherence[i][j] = fix_to_float(st_ivas->hSpatParamRendCom->spreadCoherence_fx[i][j], 15); + } + } + } + st_ivas->hMasa->data.dir_decode_quality = fix16_to_float(st_ivas->hMasa->data.dir_decode_quality_fx, Q14); + IF(st_ivas->hSpatParamRendCom != NULL) + { + FOR(Word16 i = 0; i < st_ivas->hSpatParamRendCom->numIsmDirections; i++) + { + FOR(Word16 block = 0; block < MAX_PARAM_SPATIAL_SUBFRAMES; block++) + { + FOR(Word16 b = 0; b < st_ivas->hSpatParamRendCom->num_freq_bands; b++) + { + st_ivas->hMasaIsmData->energy_ratio_ism[i][block][b] = fix_to_float(st_ivas->hMasaIsmData->energy_ratio_ism_fx[i][block][b], Q30); + } + } + } + } + } + + IF(((st_ivas->mc_mode == MC_MODE_PARAMUPMIX) || (st_ivas->mc_mode == MC_MODE_MCT) || st_ivas->ivas_format == SBA_ISM_FORMAT || (st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == MASA_FORMAT) || st_ivas->mc_mode == MC_MODE_PARAMMC) && (GT_16(st_ivas->nCPE, 1))) { + FOR(cpe_id = 0; cpe_id < nCPE; cpe_id++) + { + hCPE = st_ivas->hCPE[cpe_id]; + sts = hCPE->hCoreCoder; + FOR(ch = 0; ch < CPE_CHANNELS; ch++) + { + st = hCPE->hCoreCoder[ch]; + IF(sts[ch]->mct_chan_mode != MCT_CHAN_MODE_IGNORE) + { + // 16bit to u8bit + FOR(l = 0; l < IGF_START_MX; l++) + { + sts[ch]->hIGFDec->infoTCXNoise[l] = (UWord8) sts[ch]->hIGFDec->infoTCXNoise_evs[l]; + } + } + } + + FOR(n = 0; n < 2; n++) + { + st = hCPE->hCoreCoder[n]; + sts = hCPE->hCoreCoder; + + /*-------------------cldfb-start-------------------------*/ + /*note : cldfb_size here signifies the original size which was assigned to cldfb_state_fx buffer not its current size*/ + IF (sts[n]->cldfbAna != NULL) + { + fixedToFloat_arrL(sts[n]->cldfbAna->cldfb_state_fx, sts[n]->cldfbAna->cldfb_state, 10, sts[n]->cldfbAna->cldfb_state_length); + } + IF (sts[n]->cldfbSyn != NULL) + { + fixedToFloat_arrL(sts[n]->cldfbSyn->cldfb_state_fx, sts[n]->cldfbSyn->cldfb_state, 4, sts[n]->cldfbSyn->p_filter_length); + } + IF (sts[n]->cldfbBPF != NULL) + { + fixedToFloat_arrL(sts[n]->cldfbBPF->cldfb_state_fx, sts[n]->cldfbBPF->cldfb_state, 11, sts[n]->cldfbBPF->cldfb_state_length); + } + + /*-------------------cldfb-end---------------------------*/ + + /* reset WB BWE buffers */ + + IF(NE_16(sts[n]->last_extl, WB_BWE) && EQ_16(sts[n]->extl, WB_BWE) && sts[n]->hBWE_FD != NULL) + { + + IF(NE_16(sts[n]->last_extl, SWB_BWE) && NE_16(sts[n]->last_extl, FB_BWE)) + { + sts[n]->hBWE_FD->prev_mode = sts[n]->hBWE_FD->prev_mode; + } + sts[n]->hBWE_FD->prev_L_swb_norm = sts[n]->hBWE_FD->prev_L_swb_norm; + sts[n]->hBWE_FD->prev_flag = sts[n]->hBWE_FD->prev_flag; + } + } + } + + + IF(st_ivas->hCPE[0]->hCoreCoder[0]->igf) + { + IF(!hMCT->currBlockDataCnt) + { + FOR(cpe_id = 0; cpe_id < nCPE; cpe_id++) + { + FOR(ch = 0; ch < CPE_CHANNELS; ch++) + { + IF(st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->igf) + { + FOR(l = 0; l < IGF_START_MX; l++) + { + st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hIGFDec->infoTCXNoise[l] = (UWord8)st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hIGFDec->infoTCXNoise_evs[l]; + } + } + } + } + } + } + } +#endif // fixed to float + + } IF( hIvasDec->hasBeenFedFirstGoodFrame ) { hIvasDec->hasDecodedFirstGoodFrame = true; @@ -1393,6 +1724,10 @@ ivas_error IVAS_DEC_GetObjectMetadata( metadata->non_diegetic_flag = hIsmMeta->non_diegetic_flag; } +#ifdef IVAS_FLOAT_FIXED + metadata->azimuth_fx = floatToFixed(metadata->azimuth,Q22); + metadata->elevation_fx = floatToFixed(metadata->elevation,Q22); +#endif return IVAS_ERR_OK; } @@ -3131,6 +3466,15 @@ static ivas_error IVAS_DEC_VoIP_reconfigure( } set_zero( hIvasDec->apaExecBuffer, apa_buffer_size * nTransportChannels ); + +#ifdef IVAS_FLOAT_FIXED + IF( ( hIvasDec->apaExecBuffer_fx = malloc( sizeof( Word32 ) * apa_buffer_size * nTransportChannels ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate VoIP handle" ); + } + + set_zero_fx( hIvasDec->apaExecBuffer_fx, apa_buffer_size * nTransportChannels ); +#endif } } ELSE @@ -3148,6 +3492,15 @@ static ivas_error IVAS_DEC_VoIP_reconfigure( return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate VoIP handle" ); } set_zero( hIvasDec->apaExecBuffer, apa_buffer_size * nTransportChannels ); + +#ifdef IVAS_FLOAT_FIXED + free( hIvasDec->apaExecBuffer_fx ); + IF( ( hIvasDec->apaExecBuffer_fx = malloc( sizeof( Word32 ) * apa_buffer_size * nTransportChannels ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate VoIP handle" ); + } + set_zero_fx( hIvasDec->apaExecBuffer_fx, apa_buffer_size * nTransportChannels ); +#endif } /* realloc apa_exe_buffer */ } diff --git a/lib_dec/peak_vq_dec.c b/lib_dec/peak_vq_dec.c index b48e384df..56cb50050 100644 --- a/lib_dec/peak_vq_dec.c +++ b/lib_dec/peak_vq_dec.c @@ -48,13 +48,21 @@ * Local function prototypes *------------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED static void dequant_peaks( Decoder_State *st, float *vect_out, const float *peak_gain ); +#endif +#ifndef IVAS_FLOAT_FIXED static int16_t hvq_dec_pos( Decoder_State *st, int16_t *pos_vec, const int16_t length, const int16_t num_peaks ); +#endif +#ifndef IVAS_FLOAT_FIXED static int16_t sparse_dec_pos( Decoder_State *st, int16_t *out, const int16_t length ); +#endif +#ifndef IVAS_FLOAT_FIXED static void peak_vq_dec( Decoder_State *st, float *coefs_out, const int32_t core_brate, const int16_t num_bits, const int16_t *ynrm, int16_t *R, int16_t *vq_peak_idx, int16_t *Npeaks, const int16_t core ); +#endif /*-------------------------------------------------------------------------- @@ -63,6 +71,7 @@ static void peak_vq_dec( Decoder_State *st, float *coefs_out, const int32_t core * HVQ decoder *--------------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED void hvq_dec( Decoder_State *st, /* i/o: decoder state structure */ const int16_t num_bits, /* i : Number of available bits */ @@ -94,6 +103,7 @@ void hvq_dec( return; } +#endif /*-------------------------------------------------------------------------- @@ -102,6 +112,7 @@ void hvq_dec( * Vector de-quantization of MDCT peaks *--------------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED static void peak_vq_dec( Decoder_State *st, /* i/o: decoder state structure */ float *coefs_out, /* o : Output coefficient vector */ @@ -343,6 +354,7 @@ static void peak_vq_dec( return; } +#endif /*-------------------------------------------------------------------------- * dequant_peaks() @@ -350,6 +362,7 @@ static void peak_vq_dec( * Reads codebook vector and scales peak *--------------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED static void dequant_peaks( Decoder_State *st, /* i/o: decoder state structure */ float *vect_out, /* o : Quantized vector */ @@ -402,6 +415,7 @@ static void dequant_peaks( return; } +#endif /*-------------------------------------------------------------------------- * hvq_dec_pos() @@ -409,6 +423,7 @@ static void dequant_peaks( * HVQ decode peak positions *--------------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED static int16_t hvq_dec_pos( Decoder_State *st, /* i/o: decoder state structure */ int16_t *pos_vec, /* o : decoded peak positions */ @@ -483,7 +498,9 @@ static int16_t hvq_dec_pos( return num_bits; } +#endif +#ifndef IVAS_FLOAT_FIXED /*-------------------------------------------------------------------------- * sparse_dec_pos() * @@ -540,3 +557,4 @@ static int16_t sparse_dec_pos( return bits; } +#endif diff --git a/lib_dec/stat_dec.h b/lib_dec/stat_dec.h index 45b8bbcfc..eb4aeca2f 100644 --- a/lib_dec/stat_dec.h +++ b/lib_dec/stat_dec.h @@ -1324,23 +1324,23 @@ typedef struct hq_nbfec_structure typedef struct hq_dec_structure { +#ifndef IVAS_FLOAT_FIXED float old_out[L_FRAME48k]; /* HQ core - previous synthesis for OLA */ -#ifdef IVAS_FLOAT_FIXED - Word32 oldOut_fx[L_FRAME48k]; /* HQ core - previous synthesis for OLA */ #endif + Word32 oldOut_fx[L_FRAME48k]; /* HQ core - previous synthesis for OLA */ Word16 old_out_fx[L_FRAME48k]; /* HQ core - previous synthesis for OLA */ Word16 Q_old_out; #ifdef IVAS_FLOAT_FIXED Word16 exp_old_out; #endif +#ifndef IVAS_FLOAT_FIXED float old_outLB[L_FRAME32k]; - Word16 old_out_LB_fx[L_FRAME32k]; /* HQ core - previous synthesis for OLA for Low Band */ - Word16 Q_old_outLB; -#ifdef IVAS_FLOAT_FIXED - Word32 old_outLB_fx[L_FRAME32k]; - Word16 q_old_outLB_fx; #endif + Word16 old_out_LB_fx[L_FRAME32k]; /* HQ core - previous synthesis for OLA for Low Band */ + Word16 Q_old_outLB; + Word32 old_outLB_fx[L_FRAME32k]; + Word16 q_old_outLB_fx; Word16 Q_old_wtda_LB; Word16 Q_old_wtda; diff --git a/lib_rend/ivas_dirac_output_synthesis_dec.c b/lib_rend/ivas_dirac_output_synthesis_dec.c index 67f70250c..a24ade9d3 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec.c @@ -407,12 +407,13 @@ ivas_error ivas_dirac_dec_output_synthesis_open_fx( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis\n" ) ); } + set32_fx( dirac_output_synthesis_state->reference_power_smooth_prev_fx, 0, hSpatParamRendCom->num_freq_bands ); + dirac_output_synthesis_state->reference_power_smooth_prev_q = Q31; + IF( ( dirac_output_synthesis_state->direction_smoothness_prev_fx = (Word32 *) malloc( hSpatParamRendCom->num_freq_bands * sizeof( Word32 ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis\n" ) ); } - set32_fx( dirac_output_synthesis_state->reference_power_smooth_prev_fx, 0, hSpatParamRendCom->num_freq_bands ); - dirac_output_synthesis_state->reference_power_smooth_prev_q = Q31; set32_fx( dirac_output_synthesis_state->direction_smoothness_prev_fx, 0, hSpatParamRendCom->num_freq_bands ); /*TODO : remove float code*/ @@ -6787,4 +6788,4 @@ static void normalizePanningGains( return; } -#endif \ No newline at end of file +#endif diff --git a/lib_rend/ivas_dirac_rend.c b/lib_rend/ivas_dirac_rend.c index ef12aa814..22d904986 100644 --- a/lib_rend/ivas_dirac_rend.c +++ b/lib_rend/ivas_dirac_rend.c @@ -1539,6 +1539,9 @@ ivas_error ivas_dirac_alloc_mem( hDirACRend->h_output_synthesis_psd_state.direct_responses_square_q = Q31; hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx = hDirAC_mem->proto_power_smooth_fx; hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q = Q31; + hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q = Q31; + hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_q = Q31; + hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_q = Q31; set_s( hDirACRend->q_buffer_energy, Q31, CLDFB_NO_CHANNELS_MAX ); set_s( hDirACRend->q_buffer_intensity_real, Q31, CLDFB_NO_CHANNELS_MAX ); #endif @@ -1779,6 +1782,7 @@ ivas_error ivas_dirac_alloc_mem( #ifdef MSAN_FIX set_zero( hDirAC_mem->onset_filter, num_outputs_diff * num_freq_bands); set_zero_fx( hDirAC_mem->onset_filter_fx, num_outputs_diff * num_freq_bands ); + hDirAC_mem->q_onset_filter = Q31; #endif hDirAC_mem->onset_filter_len = 2 * num_freq_bands; #endif @@ -1817,6 +1821,7 @@ ivas_error ivas_dirac_alloc_mem( #ifdef MSAN_FIX set_zero( hDirAC_mem->onset_filter, 2 * num_freq_bands ); set_zero_fx( hDirAC_mem->onset_filter_fx, 2 * num_freq_bands ); + hDirAC_mem->q_onset_filter = Q31; #endif hDirAC_mem->onset_filter_len = 2 * num_freq_bands; #endif @@ -6528,4 +6533,4 @@ void ivas_masa_ext_dirac_render_fx( return; } -#endif \ No newline at end of file +#endif diff --git a/lib_rend/ivas_objectRenderer.c b/lib_rend/ivas_objectRenderer.c index ba2b6e575..9f461a590 100644 --- a/lib_rend/ivas_objectRenderer.c +++ b/lib_rend/ivas_objectRenderer.c @@ -1628,6 +1628,10 @@ ivas_error ivas_td_binaural_renderer_ext_fx( num_src = 1; transport_config = IVAS_AUDIO_CONFIG_ISM1; hIsmMetaData[0] = &hIsmMetaDataFrame; +#ifdef IVAS_FLOAT_FIXED + hIsmMetaData[0]->azimuth_fx = currentPos->azimuth_fx; + hIsmMetaData[0]->elevation_fx = currentPos->elevation_fx; +#endif // IVAS_FLOAT_FIXED hIsmMetaData[0]->azimuth = currentPos->azimuth; hIsmMetaData[0]->elevation = currentPos->elevation; hIsmMetaData[0]->yaw = currentPos->yaw; @@ -1736,7 +1740,7 @@ ivas_error ivas_td_binaural_renderer_ext_fx( { for (j = 0; j < L_FRAME48k; j++) { - output[ch][j] = (Word32)output_fl[ch][j] * (1 << (exp)); + output[ch][j] = (Word32)(output_fl[ch][j] * (1 << (exp))); } } #endif diff --git a/lib_rend/ivas_output_init.c b/lib_rend/ivas_output_init.c index 3494c4266..bc3fb87dc 100644 --- a/lib_rend/ivas_output_init.c +++ b/lib_rend/ivas_output_init.c @@ -240,10 +240,6 @@ void ivas_output_init( ELSE { /* Set default values for all other than custom LS setup */ - // To be removed later:->Floating-point pointer assignments-------- - hOutSetup->ls_azimuth = NULL; - hOutSetup->ls_elevation = NULL; - //--------------------------------------------------------ends here hOutSetup->ls_azimuth_fx = NULL; hOutSetup->ls_elevation_fx = NULL; hOutSetup->num_lfe = 0; @@ -258,10 +254,6 @@ void ivas_output_init( BREAK; case IVAS_AUDIO_CONFIG_STEREO: hOutSetup->is_loudspeaker_setup = 1; - // To be removed later:->Floating-point pointer assignments-------- - hOutSetup->ls_azimuth = ls_azimuth_CICP2; - hOutSetup->ls_elevation = ls_elevation_CICP2; - //---------------------------------------------------------ends here hOutSetup->ls_azimuth_fx = ls_azimuth_CICP2_fx; hOutSetup->ls_elevation_fx = ls_elevation_CICP2_fx; BREAK; @@ -278,10 +270,6 @@ void ivas_output_init( hOutSetup->num_lfe = 1; hOutSetup->index_lfe[0] = 3; hOutSetup->is_loudspeaker_setup = 1; - // To be removed later:->Floating-point pointer assignments-------- - hOutSetup->ls_azimuth = ls_azimuth_CICP6; - hOutSetup->ls_elevation = ls_elevation_CICP6; - //---------------------------------------------------------ends here hOutSetup->ls_azimuth_fx = ls_azimuth_CICP6_fx; hOutSetup->ls_elevation_fx = ls_elevation_CICP6_fx; hOutSetup->is_planar_setup = 1; @@ -290,10 +278,6 @@ void ivas_output_init( hOutSetup->num_lfe = 1; hOutSetup->index_lfe[0] = 3; hOutSetup->is_loudspeaker_setup = 1; - // To be removed later:->Floating-point pointer assignments-------- - hOutSetup->ls_azimuth = ls_azimuth_CICP12; - hOutSetup->ls_elevation = ls_elevation_CICP12; - //---------------------------------------------------------ends here hOutSetup->ls_azimuth_fx = ls_azimuth_CICP12_fx; hOutSetup->ls_elevation_fx = ls_elevation_CICP12_fx; hOutSetup->is_planar_setup = 1; @@ -302,10 +286,6 @@ void ivas_output_init( hOutSetup->num_lfe = 1; hOutSetup->index_lfe[0] = 3; hOutSetup->is_loudspeaker_setup = 1; - // To be removed later:->Floating-point pointer assignments-------- - hOutSetup->ls_azimuth = ls_azimuth_CICP14; - hOutSetup->ls_elevation = ls_elevation_CICP14; - //---------------------------------------------------------ends here hOutSetup->ls_azimuth_fx = ls_azimuth_CICP14_fx; hOutSetup->ls_elevation_fx = ls_elevation_CICP14_fx; hOutSetup->is_planar_setup = 0; @@ -314,10 +294,6 @@ void ivas_output_init( hOutSetup->num_lfe = 1; hOutSetup->index_lfe[0] = 3; hOutSetup->is_loudspeaker_setup = 1; - // To be removed later:->Floating-point pointer assignments-------- - hOutSetup->ls_azimuth = ls_azimuth_CICP16; - hOutSetup->ls_elevation = ls_elevation_CICP16; - //---------------------------------------------------------ends here hOutSetup->ls_azimuth_fx = ls_azimuth_CICP16_fx; hOutSetup->ls_elevation_fx = ls_elevation_CICP16_fx; hOutSetup->is_planar_setup = 0; @@ -326,10 +302,6 @@ void ivas_output_init( hOutSetup->num_lfe = 1; hOutSetup->index_lfe[0] = 3; hOutSetup->is_loudspeaker_setup = 1; - // To be removed later:->Floating-point pointer assignments-------- - hOutSetup->ls_azimuth = ls_azimuth_CICP19; - hOutSetup->ls_elevation = ls_elevation_CICP19; - //---------------------------------------------------------ends here hOutSetup->ls_azimuth_fx = ls_azimuth_CICP19_fx; hOutSetup->ls_elevation_fx = ls_elevation_CICP19_fx; hOutSetup->is_planar_setup = 0; diff --git a/lib_rend/ivas_rotation.c b/lib_rend/ivas_rotation.c index c2d84fab9..d5e8ee954 100644 --- a/lib_rend/ivas_rotation.c +++ b/lib_rend/ivas_rotation.c @@ -1131,10 +1131,11 @@ void rotateFrame_sd( ch_in_woLFE = ( ch_in >= index_lfe ) ? sub( ch_in, 1 ) : ch_in; /* gains for previous subframe rotation */ - rotateAziEle_fx( (Word16) hTransSetup.ls_azimuth[ch_in_woLFE], (Word16) hTransSetup.ls_elevation[ch_in_woLFE], &azimuth, &elevation, hCombinedOrientationData->Rmat_prev_fx, hTransSetup.is_planar_setup ); + rotateAziEle_fx((Word16)L_shr(hTransSetup.ls_azimuth_fx[ch_in_woLFE], Q22), (Word16)L_shr(hTransSetup.ls_elevation_fx[ch_in_woLFE], Q22), &azimuth, &elevation, hCombinedOrientationData->Rmat_prev_fx, hTransSetup.is_planar_setup); + test(); test(); - IF( hEFAPdata != NULL && ( hTransSetup.ls_azimuth[ch_in_woLFE] != azimuth || hTransSetup.ls_elevation[ch_in_woLFE] != elevation ) ) + IF( hEFAPdata != NULL && ((Word16)L_shr(hTransSetup.ls_azimuth_fx[ch_in_woLFE], Q22) != azimuth || (Word16)L_shr(hTransSetup.ls_elevation_fx[ch_in_woLFE], Q22) != elevation ) ) { azimuth_fx = L_shl( (Word32) azimuth, Q22 ); elevation_fx = L_shl( (Word32) elevation, Q22 ); @@ -1156,9 +1157,9 @@ void rotateFrame_sd( } /* gains for current subframe rotation */ - rotateAziEle_fx( (Word16) hTransSetup.ls_azimuth[ch_in_woLFE], (Word16) hTransSetup.ls_elevation[ch_in_woLFE], &azimuth, &elevation, hCombinedOrientationData->Rmat_fx[hCombinedOrientationData->subframe_idx], hTransSetup.is_planar_setup ); + rotateAziEle_fx((Word16)L_shr(hTransSetup.ls_azimuth_fx[ch_in_woLFE], Q22), (Word16)L_shr(hTransSetup.ls_elevation_fx[ch_in_woLFE], Q22), &azimuth, &elevation, hCombinedOrientationData->Rmat_fx[hCombinedOrientationData->subframe_idx], hTransSetup.is_planar_setup); - IF( hEFAPdata != NULL && ( hTransSetup.ls_azimuth[ch_in_woLFE] != azimuth || hTransSetup.ls_elevation[ch_in_woLFE] != elevation ) ) + IF( hEFAPdata != NULL && ((Word16)L_shr(hTransSetup.ls_azimuth_fx[ch_in_woLFE], Q22) != azimuth || (Word16)L_shr(hTransSetup.ls_elevation_fx[ch_in_woLFE], Q22) != elevation ) ) { azimuth_fx = L_shl( (Word32) azimuth, Q22 ); @@ -1696,7 +1697,7 @@ void rotateFrame_sd_cldfb_fixed( isPlanar = 1; FOR( n = 0; n < nInChannels; n++ ) { - IF( hOutputSetup->ls_elevation[n] != 0 ) + IF( hOutputSetup->ls_elevation_fx[n] != 0 ) { isPlanar = 0; BREAK; @@ -1706,9 +1707,8 @@ void rotateFrame_sd_cldfb_fixed( /* rotation of Euler angles */ FOR( n = 0; n < nInChannels; n++ ) { - // rotateAziEle( hOutputSetup->ls_azimuth[n], hOutputSetup->ls_elevation[n], &azimuth, &elevation, Rmat, isPlanar ); - rotateAziEle_fx( (Word16) hOutputSetup->ls_azimuth[n], (Word16) hOutputSetup->ls_elevation[n], &azimuth, &elevation, Rmat_fx, isPlanar ); - IF( hEFAPdata != NULL && ( hOutputSetup->ls_azimuth[n] != azimuth || hOutputSetup->ls_elevation[n] != elevation ) ) + rotateAziEle_fx((Word16)L_shr(hOutputSetup->ls_azimuth_fx[n], Q22), (Word16)L_shr(hOutputSetup->ls_elevation_fx[n], Q22), &azimuth, &elevation, Rmat_fx, isPlanar); + IF( hEFAPdata != NULL && ((Word16)L_shr(hOutputSetup->ls_azimuth_fx[n], Q22) != azimuth || (Word16)L_shr(hOutputSetup->ls_elevation_fx[n], Q22) != elevation ) ) { // efap_determine_gains( hEFAPdata, gains[n], azimuth, elevation, EFAP_MODE_EFAP ); efap_determine_gains_fx( hEFAPdata, gains_fx[n], L_shl( azimuth, Q22 ), L_shl( elevation, Q22 ), EFAP_MODE_EFAP ); @@ -3361,7 +3361,7 @@ void SHrotmatgen_fx( sql2mm2 = square_root30_q12[sub( imult1616(l, l), imult1616(m, m))]; sqdabsm = square_root30_q12[imult1616(add(1, d), imult1616(sub(add( l, absm), 1), add(l, absm)))]; - sqlabsm = square_root30_q12[imult1616( sub( l, sub( absm, 1 ) ), sub( l, absm ) )]; + sqlabsm = square_root30_q12[imult1616( sub( l, add( absm, 1 ) ), sub( l, absm ) )]; FOR ( n = -l; n <= l; n++ ) { diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index f469a5fe5..bc48b7d3f 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -58,12 +58,8 @@ typedef struct ivas_output_setup_structure Word16 num_lfe; Word16 index_lfe[1]; - const float *ls_azimuth; - const float *ls_elevation; -#ifdef IVAS_FLOAT_FIXED const Word32 *ls_azimuth_fx; const Word32 *ls_elevation_fx; -#endif UWord8 separateChannelEnabled; Word16 separateChannelIndex; @@ -319,6 +315,7 @@ typedef struct dirac_dec_stack_mem Word16 reference_power_len; Word32 *onset_filter_fx; Word16 onset_filter_len; + Word16 q_onset_filter; #endif } DIRAC_DEC_STACK_MEM, *DIRAC_DEC_STACK_MEM_HANDLE; @@ -2418,9 +2415,9 @@ typedef struct ivas_omasa_ana_data_structure #ifndef IVAS_FLOAT_FIXED float ism_azimuth[MAX_NUM_OBJECTS]; float ism_elevation[MAX_NUM_OBJECTS]; + float energy[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; #endif - float energy[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; #ifdef IVAS_FLOAT_FIXED Word32 **direction_vector_m_fx[DIRAC_NUM_DIMS]; /* Average direction vector */ Word16 direction_vector_m_q; /* Average direction vector */ diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index ce3c64321..eabff932b 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -2119,11 +2119,16 @@ static void initRendInputBase( } +#ifdef IVAS_FLOAT_FIXED static IVAS_ISM_METADATA defaultObjectPosition( void ) { IVAS_ISM_METADATA pos; + pos.azimuth_fx = 0; + pos.elevation_fx = 0; + +#if 1/*TODO: To be removed*/ pos.azimuth = 0.0f; pos.elevation = 0.0f; pos.radius = 1.0f; @@ -2132,10 +2137,29 @@ static IVAS_ISM_METADATA defaultObjectPosition( pos.yaw = 0.0f; pos.pitch = 0.0f; pos.non_diegetic_flag = 0; +#endif return pos; } +#else +static IVAS_ISM_METADATA defaultObjectPosition( + void ) +{ + IVAS_ISM_METADATA pos; + + pos.azimuth = 0.0f; + pos.elevation = 0.0f; + pos.radius = 1.0f; + pos.spread = 0.0f; + pos.gainFactor = 1.0f; + pos.yaw = 0.0f; + pos.pitch = 0.0f; + pos.non_diegetic_flag = 0; + + return pos; +} +#endif // DEBUG static int8_t checkObjectPositionChanged( IVAS_ISM_METADATA *currentPos, @@ -4509,9 +4533,6 @@ static ivas_error initSbaPanGainsForMcOut( SWITCH( outConfig ) { case IVAS_AUDIO_CONFIG_MONO: - hOutSetup.ls_azimuth = ls_azimuth_CICP1; - hOutSetup.ls_elevation = ls_elevation_CICP1; - hOutSetup.ls_azimuth_fx = ls_azimuth_CICP1_fx; hOutSetup.ls_elevation_fx = ls_elevation_CICP1_fx; ivas_output_init( &hOutSetup, outConfig ); @@ -5235,7 +5256,11 @@ ivas_error IVAS_REND_Open( hIvasRend->inputsIsm[i].tdRendWrapper.hBinRendererTd = NULL; hIvasRend->inputsIsm[i].bufferData = NULL; hIvasRend->inputsIsm[i].nonDiegeticPan = nonDiegeticPan; +#ifndef IVAS_FLOAT_FIXED hIvasRend->inputsIsm[i].nonDiegeticPanGain = nonDiegeticPanGain; +#else + hIvasRend->inputsIsm[i].nonDiegeticPanGain_fx = floatToFixed_32( nonDiegeticPanGain, Q31 ); +#endif // !IVAS_FLOAT_FIXED hIvasRend->inputsIsm[i].hOMasa = NULL; #ifdef IVAS_FLOAT_FIXED hIvasRend->inputsIsm[i].bufferData_fx = NULL; @@ -6237,7 +6262,66 @@ ivas_error IVAS_REND_AddInput_fx( * * Note: this will reset any custom LFE routing set for the input *-------------------------------------------------------------------*/ +#ifdef IVAS_FLOAT_FIXED +ivas_error IVAS_REND_ConfigureCustomInputLoudspeakerLayout( + IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + const IVAS_REND_InputId inputId, /* i : ID of the input */ + const IVAS_CUSTOM_LS_DATA layout /* i : custom loudspeaker layout for input */ +) +{ + input_mc *inputMc; + ivas_error error; + + /* Validate function arguments */ + IF (hIvasRend == NULL) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + IF((error = validateCustomLsLayout_fx(layout)) != IVAS_ERR_OK) + { + return error; + } + + IF ((error = getInputById(hIvasRend, inputId, (void **)&inputMc)) != IVAS_ERR_OK) + { + return error; + } + + IF (inputMc->base.inConfig != IVAS_AUDIO_CONFIG_LS_CUSTOM) + { + /* Specifying details of custom speaker layout only makes sense if input config is set to custom speaker layout */ + return IVAS_ERR_INVALID_INPUT_FORMAT; + } + + /* Re-initialize panning gains for the MC input, This includes re-initializing LFE handling + * for the new input layout, which means custom LFE handling is overwritten, if previously + * set for the MC input. */ + inputMc->customLsInput = makeCustomLsSetup(layout); + + inputMc->lfeRouting = defaultLfeRouting(inputMc->base.inConfig, inputMc->customLsInput, hIvasRend->outputConfig, *inputMc->base.ctx.pCustomLsOut); + IF ((error = initEfap(&inputMc->efapInWrapper, inputMc->base.inConfig, &inputMc->customLsInput)) != IVAS_ERR_OK) + { + return error; + } + + IF (EQ_16(hIvasRend->outputConfig , IVAS_AUDIO_CONFIG_BINAURAL) || EQ_16(hIvasRend->outputConfig , IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR) || EQ_16(hIvasRend->outputConfig , IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB)) + { + IF ((error = initMcBinauralRendering(inputMc, inputMc->base.inConfig, hIvasRend->outputConfig, hIvasRend->hRendererConfig, FALSE)) != IVAS_ERR_OK) + { + return error; + } + } + + IF ((error = updateMcPanGains(inputMc, hIvasRend->outputConfig)) != IVAS_ERR_OK) + { + return error; + } + + return IVAS_ERR_OK; +} +#else ivas_error IVAS_REND_ConfigureCustomInputLoudspeakerLayout( IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ const IVAS_REND_InputId inputId, /* i : ID of the input */ @@ -6303,7 +6387,7 @@ ivas_error IVAS_REND_ConfigureCustomInputLoudspeakerLayout( return IVAS_ERR_OK; } - +#endif /*-------------------------------------------------------------------* * IVAS_REND_SetInputGain() @@ -7073,7 +7157,26 @@ ivas_error IVAS_REND_FeedInputObjectMetadata( * * *-------------------------------------------------------------------*/ +#ifdef IVAS_FLOAT_FIXED +ivas_error IVAS_REND_FeedInputObjectMetadataToOMasa( + IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + const Word16 inputIndex, /* i : Index of the input */ + const IVAS_ISM_METADATA objectPosition /* i : object position struct */ +) +{ + /* Validate function arguments */ + IF (hIvasRend == NULL) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + /* Set position to OMasa struct */ + hIvasRend->inputsIsm->hOMasa->ism_azimuth_fx[inputIndex] = floatToFixed(objectPosition.azimuth, Q22); + hIvasRend->inputsIsm->hOMasa->ism_elevation_fx[inputIndex] = floatToFixed(objectPosition.elevation, Q22); + return IVAS_ERR_OK; +} +#else ivas_error IVAS_REND_FeedInputObjectMetadataToOMasa( IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ const int16_t inputIndex, /* i : Index of the input */ @@ -7097,7 +7200,7 @@ ivas_error IVAS_REND_FeedInputObjectMetadataToOMasa( return IVAS_ERR_OK; } - +#endif /*-------------------------------------------------------------------* * IVAS_REND_FeedInputMasaMetadata() @@ -7181,7 +7284,52 @@ ivas_error IVAS_REND_FeedInputMasaMetadata( * * *-------------------------------------------------------------------*/ +#ifdef IVAS_FLOAT_FIXED +ivas_error IVAS_REND_InitConfig( + IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + const AUDIO_CONFIG outAudioConfig /* i : output audioConfig */ +) +{ + ivas_error error; + bool rendererConfigEnabled; + + rendererConfigEnabled = (getAudioConfigType(outAudioConfig) == IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL); + + IF (rendererConfigEnabled) + { + hIvasRend->rendererConfigEnabled = 1; + } + ELSE + { + hIvasRend->rendererConfigEnabled = 0; + } + IF (rendererConfigEnabled) + { + IF ((error = ivas_render_config_open(&(hIvasRend->hRendererConfig))) != IVAS_ERR_OK) + { + return error; + } +#ifdef IVAS_FLOAT_FIXED + IF((error = ivas_render_config_init_from_rom_fx(&hIvasRend->hRendererConfig)) != IVAS_ERR_OK) + { + return error; + } +//#else + IF ((error = ivas_render_config_init_from_rom(&hIvasRend->hRendererConfig)) != IVAS_ERR_OK) + { + return error; + } +#endif + } + ELSE + { + hIvasRend->hRendererConfig = NULL; + } + + return IVAS_ERR_OK; +} +#else ivas_error IVAS_REND_InitConfig( IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ const AUDIO_CONFIG outAudioConfig /* i : output audioConfig */ @@ -7227,6 +7375,7 @@ ivas_error IVAS_REND_InitConfig( return IVAS_ERR_OK; } +#endif #ifndef IVAS_FLOAT_FIXED /*-------------------------------------------------------------------* @@ -7395,7 +7544,82 @@ int16_t IVAS_REND_FeedRenderConfig( * * *-------------------------------------------------------------------*/ +#ifdef IVAS_FLOAT_FIXED +ivas_error IVAS_REND_SetHeadRotation( + IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + const IVAS_QUATERNION headRot, /* i : head orientations for next rendering call */ + const IVAS_VECTOR3 Pos, /* i : listener positions for next rendering call */ + const Word16 sf_idx /* i : subframe index */ +) +{ + Word16 i; + IVAS_QUATERNION rotQuat; + ivas_error error; + + /* Validate function arguments */ + IF (hIvasRend == NULL) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + IF (getAudioConfigType(hIvasRend->outputConfig) != IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL) + { + /* Head rotation can be set only with binaural output */ + return IVAS_ERR_INVALID_OUTPUT_FORMAT; + } + + hIvasRend->headRotData.headRotEnabled = 1; + + /* reconfigure binaural rendering to allocate the necessary renderers and free unused ones */ + FOR (i = 0; i < RENDERER_MAX_MC_INPUTS; ++i) + { + IF (hIvasRend->inputsMc[i].base.inConfig != IVAS_AUDIO_CONFIG_INVALID) + { + IF ((error = initMcBinauralRendering(&hIvasRend->inputsMc[i], hIvasRend->inputsMc[i].base.inConfig, hIvasRend->outputConfig, hIvasRend->hRendererConfig, TRUE)) != IVAS_ERR_OK) + { + return error; + } + } + } + + /* check for Euler angle signaling */ + IF(EQ_32(headRot.w_fx, -1610612736 /* -3.0f in Q29 */)) + { + Euler2Quat_fx(deg2rad_fx(headRot.x_fx), deg2rad_fx(headRot.y_fx), deg2rad_fx(headRot.z_fx), &rotQuat); + } + ELSE + { + rotQuat = headRot; + } + + Word32 updateRate_fx = 1677721600; // value is 200 in Q23 + rotQuat.w_fx = L_shl(rotQuat.w_fx, Q29 - rotQuat.q_fact); + rotQuat.x_fx = L_shl(rotQuat.x_fx, Q29 - rotQuat.q_fact); + rotQuat.y_fx = L_shl(rotQuat.y_fx, Q29 - rotQuat.q_fact); + rotQuat.z_fx = L_shl(rotQuat.z_fx, Q29 - rotQuat.q_fact); + hIvasRend->headRotData.hOrientationTracker->refRot.w_fx = L_shl(hIvasRend->headRotData.hOrientationTracker->refRot.w_fx, Q29 - hIvasRend->headRotData.hOrientationTracker->refRot.q_fact); + hIvasRend->headRotData.hOrientationTracker->refRot.x_fx = L_shl(hIvasRend->headRotData.hOrientationTracker->refRot.x_fx, Q29 - hIvasRend->headRotData.hOrientationTracker->refRot.q_fact); + hIvasRend->headRotData.hOrientationTracker->refRot.y_fx = L_shl(hIvasRend->headRotData.hOrientationTracker->refRot.y_fx, Q29 - hIvasRend->headRotData.hOrientationTracker->refRot.q_fact); + hIvasRend->headRotData.hOrientationTracker->refRot.z_fx = L_shl(hIvasRend->headRotData.hOrientationTracker->refRot.z_fx, Q29 - hIvasRend->headRotData.hOrientationTracker->refRot.q_fact); + hIvasRend->headRotData.hOrientationTracker->absAvgRot.w_fx = L_shl(hIvasRend->headRotData.hOrientationTracker->absAvgRot.w_fx, Q29 - hIvasRend->headRotData.hOrientationTracker->absAvgRot.q_fact); + hIvasRend->headRotData.hOrientationTracker->absAvgRot.x_fx = L_shl(hIvasRend->headRotData.hOrientationTracker->absAvgRot.x_fx, Q29 - hIvasRend->headRotData.hOrientationTracker->absAvgRot.q_fact); + hIvasRend->headRotData.hOrientationTracker->absAvgRot.y_fx = L_shl(hIvasRend->headRotData.hOrientationTracker->absAvgRot.y_fx, Q29 - hIvasRend->headRotData.hOrientationTracker->absAvgRot.q_fact); + hIvasRend->headRotData.hOrientationTracker->absAvgRot.z_fx = L_shl(hIvasRend->headRotData.hOrientationTracker->absAvgRot.z_fx, Q29 - hIvasRend->headRotData.hOrientationTracker->absAvgRot.q_fact); + + hIvasRend->headRotData.hOrientationTracker->refRot.q_fact = Q29; + hIvasRend->headRotData.hOrientationTracker->absAvgRot.q_fact = Q29; + rotQuat.q_fact = Q29; + + IF((error = ivas_orient_trk_Process_fx(hIvasRend->headRotData.hOrientationTracker, rotQuat, updateRate_fx, &hIvasRend->headRotData.headPositions[sf_idx])) != IVAS_ERR_OK) + { + return error; + } + + hIvasRend->headRotData.Pos[sf_idx] = Pos; + return IVAS_ERR_OK; +} +#else ivas_error IVAS_REND_SetHeadRotation( IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ const IVAS_QUATERNION headRot, /* i : head orientations for next rendering call */ @@ -7487,14 +7711,48 @@ ivas_error IVAS_REND_SetHeadRotation( return IVAS_ERR_OK; } - +#endif /*-------------------------------------------------------------------* * IVAS_REND_DisableHeadRotation() * * *-------------------------------------------------------------------*/ +#ifdef IVAS_FLOAT_FIXED +ivas_error IVAS_REND_DisableHeadRotation( + IVAS_REND_HANDLE hIvasRend /* i/o: Renderer handle */ +) +{ + Word16 i; + ivas_error error; + + /* Validate function arguments */ + IF (hIvasRend == NULL) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + hIvasRend->headRotData.headRotEnabled = 0; + + /* reconfigure binaural rendering to allocate the necessary renderers and free unused ones */ + IF (getAudioConfigType(hIvasRend->outputConfig) == IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL) + { + FOR (i = 0; i < RENDERER_MAX_MC_INPUTS; ++i) + { + IF (hIvasRend->inputsMc[i].base.inConfig != IVAS_AUDIO_CONFIG_INVALID) + { + IF ((error = initMcBinauralRendering(&hIvasRend->inputsMc[i], hIvasRend->inputsMc[i].base.inConfig, hIvasRend->outputConfig, hIvasRend->hRendererConfig, TRUE)) != IVAS_ERR_OK) + { + + return error; + } + } + } + } + return IVAS_ERR_OK; +} +#else ivas_error IVAS_REND_DisableHeadRotation( IVAS_REND_HANDLE hIvasRend /* i/o: Renderer handle */ ) @@ -7528,7 +7786,7 @@ ivas_error IVAS_REND_DisableHeadRotation( return IVAS_ERR_OK; } - +#endif /*-------------------------------------------------------------------* * IVAS_REND_SetOrientationTrackingMode() @@ -8581,6 +8839,41 @@ static ivas_error rotateFrameSba( #endif +#ifdef IVAS_FLOAT_FIXED +static ivas_error renderIsmToBinaural( + const input_ism *ismInput, + IVAS_REND_AudioBuffer outAudio ) +{ + Word32 tmpTDRendBuffer[MAX_OUTPUT_CHANNELS][L_FRAME48k]; + ivas_error error; + Word16 ism_md_subframe_update_ext; + + push_wmops( "renderIsmToBinaural" ); + /* Metadata Delay to sync with audio delay converted from ms to 5ms (1000/50/4) subframe index */ + ism_md_subframe_update_ext = (Word16) roundf( ismInput->ism_metadata_delay_ms / ( 1000 / FRAMES_PER_SEC / MAX_PARAM_SPATIAL_SUBFRAMES ) );/*To be cleaned up later*/ + copyBufferTo2dArray_fx( ismInput->base.inputBuffer, tmpTDRendBuffer ); + + IF ( ( error = ivas_td_binaural_renderer_ext_fx( &ismInput->tdRendWrapper, ismInput->base.inConfig, NULL, ismInput->base.ctx.pCombinedOrientationData, &ismInput->currentPos, ismInput->hReverb, ism_md_subframe_update_ext, + *ismInput->base.ctx.pOutSampleRate, outAudio.config.numSamplesPerChannel, tmpTDRendBuffer ,*outAudio.pq_fact) ) != IVAS_ERR_OK ) + { + return error; + } + + IF( ismInput->hReverb != NULL ) + { + FOR ( int i = 0; i < outAudio.config.numChannels; i++ ) + { + FOR ( int j = 0; j < outAudio.config.numSamplesPerChannel; j++ ) + tmpTDRendBuffer[i][j] = L_shl( tmpTDRendBuffer[i][j], 2 ); + } + } + accumulate2dArrayToBuffer_fx( tmpTDRendBuffer, &outAudio ); + + pop_wmops(); + + return IVAS_ERR_OK; +} +#else static ivas_error renderIsmToBinaural( const input_ism *ismInput, IVAS_REND_AudioBuffer outAudio ) @@ -8607,6 +8900,7 @@ static ivas_error renderIsmToBinaural( return IVAS_ERR_OK; } +#endif // IVAS_FLOAT_FIXED #ifdef IVAS_FLOAT_FIXED static Word16 getNumSubframesInBuffer( @@ -8985,6 +9279,41 @@ static ivas_error renderIsmToBinauralRoom( } #endif +#ifdef IVAS_FLOAT_FIXED +static ivas_error renderIsmToBinauralReverb( + input_ism *ismInput, + IVAS_REND_AudioBuffer outAudio ) +{ + Word32 tmpRendBuffer_fx[MAX_OUTPUT_CHANNELS][L_FRAME48k]; + ivas_error error; + Word16 ism_md_subframe_update_ext; + + push_wmops( "renderIsmToBinauralRoom" ); + + /* Metadata Delay to sync with audio delay converted from ms to 5ms (1000/50/4) subframe index */ + ism_md_subframe_update_ext = (Word16) roundf( ismInput->ism_metadata_delay_ms / ( 1000 / FRAMES_PER_SEC / MAX_PARAM_SPATIAL_SUBFRAMES ) );/*ism_metadata_delay_ms :To be replaced later*/ + + copyBufferTo2dArray_fx( ismInput->base.inputBuffer, tmpRendBuffer_fx ); + + IF ( ( error = ivas_td_binaural_renderer_ext_fx( &ismInput->tdRendWrapper, ismInput->base.inConfig, NULL, ismInput->base.ctx.pCombinedOrientationData, &ismInput->currentPos, ismInput->hReverb, ism_md_subframe_update_ext, *ismInput->base.ctx.pOutSampleRate, outAudio.config.numSamplesPerChannel, tmpRendBuffer_fx , *outAudio.pq_fact) ) != IVAS_ERR_OK ) + { + return error; + } + + IF( ismInput->hReverb != NULL ) + { + FOR ( int i = 0; i < outAudio.config.numChannels; i++ ) + { + FOR ( int j = 0; j < outAudio.config.numSamplesPerChannel; j++ ) + tmpRendBuffer_fx[i][j] = L_shl( tmpRendBuffer_fx[i][j], 2 ); + } + } + accumulate2dArrayToBuffer_fx( tmpRendBuffer_fx, &outAudio ); + pop_wmops(); + + return IVAS_ERR_OK; +} +#else static ivas_error renderIsmToBinauralReverb( input_ism *ismInput, IVAS_REND_AudioBuffer outAudio ) @@ -9011,6 +9340,7 @@ static ivas_error renderIsmToBinauralReverb( return IVAS_ERR_OK; } +#endif #ifdef IVAS_FLOAT_FIXED static ivas_error renderIsmToMc( @@ -9404,6 +9734,85 @@ static void renderIsmToMasa( } #endif +#ifdef IVAS_FLOAT_FIXED +static ivas_error renderInputIsm( + input_ism *ismInput, + const AUDIO_CONFIG outConfig, + const IVAS_REND_AudioBuffer outAudio ) +{ + ivas_error error; + IVAS_REND_AudioBuffer inAudio; + Word16 exp = 8; + move16(); + + error = IVAS_ERR_OK; + inAudio = ismInput->base.inputBuffer; + + IF ( NE_32(ismInput->base.numNewSamplesPerChannel , outAudio.config.numSamplesPerChannel) ) + { + return IVAS_ERROR( IVAS_ERR_INVALID_BUFFER_SIZE, "Mismatch between the number of input samples vs number of requested output samples - currently not allowed" ); + } + ismInput->base.numNewSamplesPerChannel = 0; + + + /* Apply input gain to new audio */ + v_multc_fixed( inAudio.data_fx, ismInput->base.gain_fx, inAudio.data_fx, imult1616(inAudio.config.numSamplesPerChannel , inAudio.config.numChannels) ); + /* set combined orientation subframe info to start info */ + ivas_combined_orientation_set_to_start_index( *ismInput->base.ctx.pCombinedOrientationData ); + + scale_sig32( ismInput->base.inputBuffer.data_fx, imult1616( inAudio.config.numSamplesPerChannel, inAudio.config.numChannels ), 1 ); + + SWITCH ( getAudioConfigType( outConfig ) ) + { + case IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED: + error = renderIsmToMc( ismInput, outAudio ); + exp = Q8; + BREAK; + case IVAS_REND_AUDIO_CONFIG_TYPE_AMBISONICS: + error = renderIsmToSba( ismInput, outConfig, outAudio ); + exp = Q8; + BREAK; + case IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL: + switch ( outConfig ) + { + case IVAS_AUDIO_CONFIG_BINAURAL: + error = renderIsmToBinaural( ismInput, outAudio ); + exp = *outAudio.pq_fact; + BREAK; + case IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR: + error = renderIsmToBinauralRoom( ismInput, outAudio, &exp ); + BREAK; + case IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB: + error = renderIsmToBinauralReverb( ismInput, outAudio ); + exp = *outAudio.pq_fact; + BREAK; + default: + return IVAS_ERR_INVALID_OUTPUT_FORMAT; + } + BREAK; + case IVAS_REND_AUDIO_CONFIG_TYPE_MASA: + renderIsmToMasa( ismInput, outAudio, &exp ); + FOR( Word16 block_m_idx = 0; block_m_idx < MAX_PARAM_SPATIAL_SUBFRAMES; block_m_idx++ ) + { + ismInput->hOMasa->energy_e[block_m_idx]= 31- ismInput->hOMasa->energy_q; + } + BREAK; + default: + return IVAS_ERR_INVALID_OUTPUT_FORMAT; + } + + /* Check error here to keep switch statement more compact */ + IF ( error != IVAS_ERR_OK ) + { + return error; + } + + ismInput->firstFrameRendered = TRUE; + + *outAudio.pq_fact = exp; + return error; +} +#else static ivas_error renderInputIsm( input_ism *ismInput, const AUDIO_CONFIG outConfig, @@ -9544,19 +9953,20 @@ static ivas_error renderInputIsm( return error; } +#endif // IVAS_FLOAT_FIXED #ifdef IVAS_FLOAT_FIXED static ivas_error renderActiveInputsIsm( IVAS_REND_HANDLE hIvasRend, IVAS_REND_AudioBuffer outAudio ) { - int16_t i; + Word16 i; input_ism *pCurrentInput; ivas_error error; Word16 input_q = *outAudio.pq_fact; for ( i = 0, pCurrentInput = hIvasRend->inputsIsm; i < RENDERER_MAX_ISM_INPUTS; ++i, ++pCurrentInput ) { - if ( pCurrentInput->base.inConfig == IVAS_AUDIO_CONFIG_INVALID ) + IF ( pCurrentInput->base.inConfig == IVAS_AUDIO_CONFIG_INVALID ) { /* Skip inactive inputs */ continue; @@ -9566,11 +9976,22 @@ static ivas_error renderActiveInputsIsm( { return error; } + FOR(Word16 j = 0; j < outAudio.config.numSamplesPerChannel * outAudio.config.numChannels; ++j ) + { + outAudio.data_fx[j] = L_shl( outAudio.data_fx[j], sub( input_q , ( *outAudio.pq_fact ) ) ); + } + *outAudio.pq_fact = input_q; } - for ( i = 0; i < outAudio.config.numSamplesPerChannel * outAudio.config.numChannels; ++i ) + FOR( Word16 j = 0; j < outAudio.config.numSamplesPerChannel * outAudio.config.numChannels; ++j ) { - outAudio.data_fx[i] = (Word32) ( outAudio.data[i] * ( 1 << ( input_q - 1 ) ) ); + outAudio.data_fx[j] = L_shr( outAudio.data_fx[j], 1); } +#if 1/*To be removed later when dependency on data is removed*/ + FOR( Word16 j = 0; j < outAudio.config.numSamplesPerChannel * outAudio.config.numChannels; ++j ) + { + outAudio.data[j] = fixedToFloat( outAudio.data_fx[j], input_q - 1 ); + } +#endif return IVAS_ERR_OK; } #else @@ -11905,6 +12326,95 @@ ivas_error IVAS_REND_GetMasaMetadata( * Merge MASA metadata from two formats *---------------------------------------------------------------------*/ +#ifdef IVAS_FLOAT_FIXED +ivas_error IVAS_REND_MergeMasaMetadata( + IVAS_REND_HANDLE hIvasRend, /* i/o: IVAS renderer handle */ + MASA_DECODER_EXT_OUT_META_HANDLE *hMasaExtOutMeta, /* o : pointer to handle, which will be set to point to merged metadata */ + const IVAS_REND_AudioConfigType inputType1, /* i : Input type 1 */ + const IVAS_REND_AudioConfigType inputType2 /* i : Input type 2 */ +) +{ + MASA_DECODER_EXT_OUT_META_HANDLE inMeta2; + Word32( *inEne1_fx )[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; + Word32( *inEne2_fx )[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; + Word16 *inEne1_e; + Word16 *inEne2_e; + + if ( hIvasRend == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + /* Input1 metadata and energy */ + if ( inputType1 == IVAS_REND_AUDIO_CONFIG_TYPE_OBJECT_BASED ) + { + *hMasaExtOutMeta = hIvasRend->inputsIsm->hOMasa->hMasaOut; + inEne1_fx = &( hIvasRend->inputsIsm->hOMasa->energy_fx ); + inEne1_e = ( hIvasRend->inputsIsm->hOMasa->energy_e ); + } + else if ( inputType1 == IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED ) + { + *hMasaExtOutMeta = hIvasRend->inputsMc->hMcMasa->hMasaOut; + inEne1_fx = &( hIvasRend->inputsMc->hMcMasa->energy_fx ); + inEne1_e = ( hIvasRend->inputsMc->hMcMasa->energy_exp ); + } + else if ( inputType1 == IVAS_REND_AUDIO_CONFIG_TYPE_AMBISONICS ) + { + *hMasaExtOutMeta = hIvasRend->inputsSba->hDirAC->hMasaOut; + inEne1_fx = &( hIvasRend->inputsSba->hDirAC->energy_fx ); + inEne1_e = ( hIvasRend->inputsSba->hDirAC->energy_exp ); + } + else if ( inputType1 == IVAS_REND_AUDIO_CONFIG_TYPE_MASA ) + { + *hMasaExtOutMeta = hIvasRend->inputsMasa->hMasaPrerend->hMasaOut; + inEne1_fx = &( hIvasRend->inputsMasa->hMasaPrerend->energy_fx ); + inEne1_e = ( hIvasRend->inputsMasa->hMasaPrerend->energy_e ); + } + else + { + return IVAS_ERR_NOT_SUPPORTED_OPTION; + } + + /* Input2 metadata and energy */ + if ( inputType2 == IVAS_REND_AUDIO_CONFIG_TYPE_OBJECT_BASED ) + { + inMeta2 = hIvasRend->inputsIsm->hOMasa->hMasaOut; + inEne2_fx = &( hIvasRend->inputsIsm->hOMasa->energy_fx ); + inEne2_e = ( hIvasRend->inputsIsm->hOMasa->energy_e ); + } + else if ( inputType2 == IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED ) + { + inMeta2 = hIvasRend->inputsMc->hMcMasa->hMasaOut; + inEne2_fx = &( hIvasRend->inputsMc->hMcMasa->energy_fx ); + inEne2_e = ( hIvasRend->inputsMc->hMcMasa->energy_exp ); + } + else if ( inputType2 == IVAS_REND_AUDIO_CONFIG_TYPE_AMBISONICS ) + { + inMeta2 = hIvasRend->inputsSba->hDirAC->hMasaOut; + inEne2_fx = &( hIvasRend->inputsSba->hDirAC->energy_fx ); + inEne2_e = ( hIvasRend->inputsSba->hDirAC->energy_exp ); + } + else if ( inputType2 == IVAS_REND_AUDIO_CONFIG_TYPE_MASA ) + { + inMeta2 = hIvasRend->inputsMasa->hMasaPrerend->hMasaOut; + inEne2_fx = &( hIvasRend->inputsMasa->hMasaPrerend->energy_fx ); + inEne2_e = ( hIvasRend->inputsMasa->hMasaPrerend->energy_e ); + } + else + { + return IVAS_ERR_NOT_SUPPORTED_OPTION; + } + + /* Merge metadata */ + ivas_prerend_merge_masa_metadata_fx( *hMasaExtOutMeta, *hMasaExtOutMeta, inputType1, *inEne1_fx, inEne1_e, inMeta2, inputType2, *inEne2_fx, inEne2_e ); + + + ( *hMasaExtOutMeta )->descriptiveMeta.numberOfChannels = hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_MASA1 ? 0u : 1u; + + return IVAS_ERR_OK; +} + +#else ivas_error IVAS_REND_MergeMasaMetadata( IVAS_REND_HANDLE hIvasRend, /* i/o: IVAS renderer handle */ MASA_DECODER_EXT_OUT_META_HANDLE *hMasaExtOutMeta, /* o : pointer to handle, which will be set to point to merged metadata */ @@ -12075,7 +12585,7 @@ ivas_error IVAS_REND_MergeMasaMetadata( return IVAS_ERR_OK; } - +#endif // IVAS_FLOAT_FIXED /*---------------------------------------------------------------------* * IVAS_REND_SetTotalNumberOfObjects( ) @@ -12134,7 +12644,6 @@ ivas_error IVAS_REND_SetIsmMetadataDelay( { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } - for ( i = 0; i < RENDERER_MAX_ISM_INPUTS; ++i ) { hIvasRend->inputsIsm[i].ism_metadata_delay_ms = sync_md_delay; @@ -12503,10 +13012,6 @@ static ivas_error ivas_masa_ext_rend_dirac_rend_init( /* Copy from ivas_ls_custom_setup */ hDirACRend->hOutSetup.nchan_out_woLFE = inputMasa->base.ctx.pCustomLsOut->num_spk; move16(); -#if 1 /*TODO: To be removed later(floating buffer init)*/ - hDirACRend->hOutSetup.ls_azimuth = inputMasa->base.ctx.pCustomLsOut->ls_azimuth; - hDirACRend->hOutSetup.ls_elevation = inputMasa->base.ctx.pCustomLsOut->ls_elevation; -#endif hDirACRend->hOutSetup.ls_azimuth_fx = inputMasa->base.ctx.pCustomLsOut->ls_azimuth_fx; hDirACRend->hOutSetup.ls_elevation_fx = inputMasa->base.ctx.pCustomLsOut->ls_elevation_fx; @@ -12524,7 +13029,7 @@ static ivas_error ivas_masa_ext_rend_dirac_rend_init( nchan_out_woLFE = hDirACRend->hOutSetup.nchan_out_woLFE; move16(); - IF( hDirACRend->hOutSetup.ls_azimuth != NULL && hDirACRend->hOutSetup.ls_elevation != NULL ) + IF( hDirACRend->hOutSetup.ls_azimuth_fx != NULL && hDirACRend->hOutSetup.ls_elevation_fx != NULL ) { Copy32( hDirACRend->hOutSetup.ls_azimuth_fx, ls_azimuth_fx, nchan_out_woLFE ); Copy32( hDirACRend->hOutSetup.ls_elevation_fx, ls_elevation_fx, nchan_out_woLFE ); @@ -12850,6 +13355,9 @@ static ivas_error ivas_masa_ext_rend_dirac_rend_init( IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) { hDirACRend->proto_frame_f = NULL; +#if 1 /*TODO :To be removed later(after dependecy on buffer_energyis completely removed)*/ + hDirACRend->proto_frame_f_fx = NULL; +#endif } ELSE { @@ -12870,6 +13378,7 @@ static ivas_error ivas_masa_ext_rend_dirac_rend_init( #if 1 /*TODO :To be removed later(after dependecy on buffer_energyis completely removed)*/ hDirACRend->buffer_energy = NULL; #endif + hDirACRend->buffer_energy_fx = NULL; FOR( i = 0; i < DIRAC_NUM_DIMS; i++ ) { diff --git a/lib_util/ism_file_reader.c b/lib_util/ism_file_reader.c index 48e870ac3..768398b8d 100644 --- a/lib_util/ism_file_reader.c +++ b/lib_util/ism_file_reader.c @@ -34,6 +34,9 @@ #include "cmdl_tools.h" #include #include +#ifdef IVAS_FLOAT_FIXED +#include "prot_fx2.h" +#endif // IVAS_FLOAT_FIXED #define META_LINE_LENGTH 200 /* max number of characters at one line of metadata input/output file */ #define NUM_ISM_METADATA_PER_LINE 8 /* Number of ISM metadata per line in a metadata file */ @@ -147,6 +150,10 @@ ivas_error IsmFileReader_readNextFrame( /* Invalid number of metadata parameters (2-7 supported) */ return IVAS_ERR_ISM_FILE_READER_INVALID_METADATA_FORMAT; } +#ifdef IVAS_FLOAT_FIXED + ismMetadata->azimuth_fx = floatToFixed( meta_prm[0], Q22 ); + ismMetadata->elevation_fx = floatToFixed( meta_prm[1], Q22 ); +#endif // IVAS_FLOAT_FIXED ismMetadata->azimuth = meta_prm[0]; ismMetadata->elevation = meta_prm[1]; -- GitLab