diff --git a/lib_com/bitstream.c b/lib_com/bitstream.c index 1b1046b27fd6f227f47eeabeb9d4ba92ea31893e..0998a71ffe4ac0951cf1f601be965ded56827105 100644 --- a/lib_com/bitstream.c +++ b/lib_com/bitstream.c @@ -2438,6 +2438,48 @@ void mdct_switching_dec( * Simulate packet losses by reading FEC pattern from external file *-------------------------------------------------------------------*/ +#ifdef IVAS_FLOAT_FIXED +Decoder_State **reset_elements( + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +) +{ + Word16 k, n; + Decoder_State **sts = NULL; /* to avoid compilation warning */ + + FOR ( k = 0; k < st_ivas->nSCE; k++ ) + { + sts = st_ivas->hSCE[k]->hCoreCoder; + + sts[0]->bfi = 0; + sts[0]->BER_detect = 0; + sts[0]->mdct_sw_enable = 0; + sts[0]->mdct_sw = 0; + + move16(); move16(); move16(); move16(); + + reset_indices_dec( sts[0] ); + } + + FOR ( k = 0; k < st_ivas->nCPE; k++ ) + { + sts = st_ivas->hCPE[k]->hCoreCoder; + + FOR ( n = 0; n < CPE_CHANNELS; n++ ) + { + sts[n]->bfi = 0; + sts[n]->BER_detect = 0; + sts[n]->mdct_sw_enable = 0; + sts[n]->mdct_sw = 0; + + move16(); move16(); move16(); move16(); + + reset_indices_dec( sts[n] ); + } + } + + return sts; /* return last decoder state */ +} +#else Decoder_State **reset_elements( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ) @@ -2474,7 +2516,7 @@ Decoder_State **reset_elements( return sts; /* return last decoder state */ } - +#endif /*-------------------------------------------------------------------* * ivas_set_bitstream_pointers() diff --git a/lib_com/ivas_ism_com.c b/lib_com/ivas_ism_com.c index b3b8b0b34a512871a4ce341c8be885bc45d3f7f0..ed0a260b008a984e98aad25b5ce82f56aa584a7e 100644 --- a/lib_com/ivas_ism_com.c +++ b/lib_com/ivas_ism_com.c @@ -1024,6 +1024,7 @@ void ivas_param_ism_config_fx( } hParamIsm->last_dmx_gain_fx = (Word16) 16384; + hParamIsm->last_dmx_gain_e = 1; move16(); set16_fx( hParamIsm->last_cardioid_left_fx, (Word16) 16384, MAX_NUM_OBJECTS ); diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 4bb9dcaa4c92b3b001e7717a9a6e5ce2dce382cc..c902cac9bfda997c51cb807c11bda5c1bcc0ef64 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -353,11 +353,19 @@ ivas_error ivas_dec( int16_t *data /* o : output synthesis signal */ ); +#ifndef IVAS_FLOAT_FIXED ivas_error ivas_dec_setup( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ uint16_t *nSamplesRendered, /* o : number of samples flushed from the previous frame (JBM) */ int16_t *data /* o : output synthesis signal */ ); +#else +ivas_error ivas_dec_setup( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + UWord16 *nSamplesRendered, /* o : number of samples flushed from the previous frame (JBM) */ + Word16 *data /* o : output synthesis signal */ +); +#endif #ifndef IVAS_FLOAT_FIXED ivas_error create_sce_dec( @@ -464,9 +472,15 @@ ivas_error ivas_mct_dec( ); /*! r: number of channels to be synthesised */ +#ifdef IVAS_FLOAT_FIXED Word16 getNumChanSynthesis( Decoder_Struct *st_ivas /* i : IVAS decoder structure */ ); +#else +int16_t getNumChanSynthesis( + Decoder_Struct *st_ivas /* i : IVAS decoder structure */ +); +#endif void copy_decoder_config( Decoder_Struct *st_ivas, /* i : IVAS decoder structure */ @@ -1318,11 +1332,19 @@ void ivas_ism_dec_digest_tc( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ); +#ifdef IVAS_FLOAT_FIXED +void ivas_param_ism_dec_digest_tc( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const UWord16 nCldfbSlots, /* i : number of CLFBS slots in the transport channels */ + Word32 *transport_channels_f[] /* i : synthesized core-coder transport channels/DirAC output */ +); +#else void ivas_param_ism_dec_digest_tc( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ const uint16_t nCldfbSlots, /* i : number of CLFBS slots in the transport channels */ float *transport_channels_f[] /* i : synthesized core-coder transport channels/DirAC output */ ); +#endif // IVAS_FLOAT_FIXED void ivas_ism_param_dec_tc_gain_ajust( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ @@ -4163,14 +4185,14 @@ ivas_error ivas_cldfb_dec_reconfig_fx( Word16 numCldfbAnalyses_old, /* i : number of CLDFB analysis instances in previous frame */ const Word16 numCldfbSyntheses_old /* i : number of CLDFB synthesis instances in previous frame */ ); -#endif // IVAS_FLOAT_FIXED - +#else ivas_error ivas_cldfb_dec_reconfig( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const int16_t nchan_transport_old, /* i : number of TCs in previous frame */ int16_t numCldfbAnalyses_old, /* i : number of CLDFB analysis instances in previous frame */ const int16_t numCldfbSyntheses_old /* i : number of CLDFB synthesis instances in previous frame */ ); +#endif /*! r: Ambisonic (SBA) order */ int16_t ivas_sba_get_order( @@ -6801,6 +6823,7 @@ ivas_error ivas_ls_custom_open( LSSETUP_CUSTOM_HANDLE *hLsSetupCustom /* o : Custom loudspeaker setup handle */ ); +#ifndef IVAS_FLOAT_FIXED ivas_error ivas_ls_custom_output_init( Decoder_Struct *st_ivas /* i/o: IVAS decoder handle */ ); @@ -6809,6 +6832,7 @@ void ivas_ls_custom_setup( IVAS_OUTPUT_SETUP_HANDLE hOutSetup, /* o : IVAS output setup handle */ LSSETUP_CUSTOM_STRUCT *hLsSetupCustom /* i : Custom loudspeaker setup handle */ ); +#endif /*----------------------------------------------------------------------------------* diff --git a/lib_dec/ivas_corecoder_dec_reconfig.c b/lib_dec/ivas_corecoder_dec_reconfig.c index 8d0f2014a6a3850a1bcf9cb5bade5c835b94dc81..5646c71c1aa55f240ca62423a5fb1cfb3ccaaeac 100644 --- a/lib_dec/ivas_corecoder_dec_reconfig.c +++ b/lib_dec/ivas_corecoder_dec_reconfig.c @@ -1011,8 +1011,7 @@ ivas_error ivas_cldfb_dec_reconfig_fx( } return IVAS_ERR_OK; } -#endif // IVAS_FLOAT_FIXED - +#else ivas_error ivas_cldfb_dec_reconfig( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const int16_t nchan_transport_old, /* i : number of TCs in previous frame */ @@ -1095,3 +1094,4 @@ ivas_error ivas_cldfb_dec_reconfig( return IVAS_ERR_OK; } +#endif // IVAS_FLOAT_FIXED diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index 612d7b82db7e3f9a495644a7b935cbc17f16d5b7..ee995a291a3e1410cc9192a1f562167725466599 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -3588,8 +3588,6 @@ 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 ); - - floatToFixed_arrL( hDirACRend->stack_mem.onset_filter, hDirACRend->stack_mem.onset_filter_fx, Q30, ( hDirACRend->synthesisConf != DIRAC_SYNTHESIS_GAIN_SHD ) ? hDirACRend->num_outputs_diff * hSpatParamRendCom->num_freq_bands : 2 * hSpatParamRendCom->num_freq_bands ); } if ( hDirAC->hConfig->dec_param_estim == TRUE && hDirACRend->synthesisConf != DIRAC_SYNTHESIS_GAIN_SHD ) @@ -3699,8 +3697,6 @@ void ivas_dirac_dec_render_sf_fx( 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 ); @@ -4208,13 +4204,9 @@ void ivas_dirac_dec_render_sf_fx( hDirACRend->h_freq_domain_decorr_ap_params, hDirACRend->h_freq_domain_decorr_ap_state ); - 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 - DirAC_mem.q_onset_filter = sub( add( DirAC_mem.q_onset_filter, Q30 ), Q31 ); + v_multc_fixed( onset_filter_fx, 536870912 /* 0.25f in Q31 */, onset_filter_fx, hSpatParamRendCom->num_freq_bands ); - v_add_fixed( onset_filter_fx, onset_filter_subframe_fx, onset_filter_subframe_fx, hSpatParamRendCom->num_freq_bands, 0 ); // Q30 + v_add_fixed( onset_filter_fx, onset_filter_subframe_fx, onset_filter_subframe_fx, hSpatParamRendCom->num_freq_bands, 0 ); /* Q31 */ p_onset_filter_fx = onset_filter_subframe_fx; } ELSE @@ -4243,19 +4235,13 @@ void ivas_dirac_dec_render_sf_fx( hDirACRend->proto_frame_dec_f_len = DirAC_mem.frame_dec_f_len; move16(); p_onset_filter_fx = onset_filter_fx; - - scale_sig32( onset_filter_fx, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_diff ), -1 ); - DirAC_mem.q_onset_filter = Q30; - move16(); } } ELSE { IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) { - set_l( onset_filter_subframe_fx, ONE_IN_Q30, hSpatParamRendCom->num_freq_bands ); - DirAC_mem.q_onset_filter = Q30; - move16(); + set32_fx( onset_filter_subframe_fx, ONE_IN_Q31, hSpatParamRendCom->num_freq_bands ); p_onset_filter_fx = onset_filter_subframe_fx; } ELSE @@ -4308,10 +4294,6 @@ void ivas_dirac_dec_render_sf_fx( h_dirac_output_synthesis_state->diffuse_power_factor_q = Q31; move16(); - scale_sig32( h_dirac_output_synthesis_state->diffuse_responses_square_fx, num_channels_dir, sub( Q31, h_dirac_output_synthesis_state->diffuse_responses_square_q ) ); - h_dirac_output_synthesis_state->diffuse_responses_square_q = Q31; - move16(); - exp = getScaleFactor32( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx, i_mult( num_channels_dir, hSpatParamRendCom->num_freq_bands ) ); scale_sig32( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx, i_mult( num_channels_dir, hSpatParamRendCom->num_freq_bands ), exp ); h_dirac_output_synthesis_state->q_cy_auto_diff_smooth = add( h_dirac_output_synthesis_state->q_cy_auto_diff_smooth, exp ); @@ -4335,10 +4317,6 @@ void ivas_dirac_dec_render_sf_fx( h_dirac_output_synthesis_state->direct_responses_square_q = Q31; move16(); - scale_sig32( h_dirac_output_synthesis_state->diffuse_responses_square_fx, num_channels_dir, sub( Q31, h_dirac_output_synthesis_state->diffuse_responses_square_q ) ); - h_dirac_output_synthesis_state->diffuse_responses_square_q = Q31; - move16(); - exp = getScaleFactor32( h_dirac_output_synthesis_state->cy_auto_dir_smooth_fx, i_mult( num_channels_dir, hSpatParamRendCom->num_freq_bands ) ); scale_sig32( h_dirac_output_synthesis_state->cy_auto_dir_smooth_fx, i_mult( num_channels_dir, hSpatParamRendCom->num_freq_bands ), exp ); h_dirac_output_synthesis_state->q_cy_auto_dir_smooth = add( h_dirac_output_synthesis_state->q_cy_auto_dir_smooth, exp ); @@ -4618,10 +4596,6 @@ void ivas_dirac_dec_render_sf_fx( { 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 ) ); - } exp = L_norm_arr( reference_power_smooth_fx, hSpatParamRendCom->num_freq_bands ); scale_sig32( reference_power_smooth_fx, hSpatParamRendCom->num_freq_bands, exp ); @@ -5183,12 +5157,9 @@ void ivas_dirac_dec_render_sf_fx( { 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 ); hDirACRend->proto_frame_dec_f = DirAC_mem.frame_dec_f; @@ -5198,7 +5169,6 @@ void ivas_dirac_dec_render_sf_fx( { 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 { @@ -5284,8 +5254,6 @@ void ivas_dirac_dec_render_sf_fx( } 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 ) { 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 ); diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 826f7c883adbe271701fd180968a9af8c510b9dc..a6900e22e84bb357c81c515861819276b9a1e21c 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -48,12 +48,17 @@ #define IVAS_FLOAT_FIXED_TO_BE_REMOVED #endif // IVAS_FLOAT_FIXED +#define IVAS_FLOAT_FIXED_TO_BE_REMOVED /*-------------------------------------------------------------------* * Local function prototypes *-------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED +static ivas_error ivas_read_format( Decoder_Struct *st_ivas, int16_t *num_bits_read ); +#else static ivas_error ivas_read_format( Decoder_Struct *st_ivas, Word16 *num_bits_read ); +#endif static ivas_error doSanityChecks_IVAS( Decoder_Struct *st_ivas ); @@ -65,6 +70,7 @@ static ivas_error doSanityChecks_IVAS( Decoder_Struct *st_ivas ); * IVAS decoder setup *-------------------------------------------------------------------*/ +#ifdef IVAS_FLOAT_FIXED ivas_error ivas_dec_setup( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ UWord16 *nSamplesRendered, /* o : number of samples flushed from the previous frame (JBM) */ @@ -90,6 +96,9 @@ ivas_error ivas_dec_setup( ivas_read_format( st_ivas, &num_bits_read ); + Word16 SrcInd[MAX_NUM_TDREND_CHANNELS]; + Word16 num_src = 0; + /*-------------------------------------------------------------------* * Read other signling (ISM/MC mode, number of channels, etc.) *-------------------------------------------------------------------*/ @@ -122,11 +131,7 @@ ivas_error ivas_dec_setup( st_ivas->nchan_ism = nchan_ism; -#ifdef IVAS_FLOAT_FIXED IF ( ( error = ivas_ism_dec_config_fx( st_ivas, st_ivas->ism_mode, nSamplesRendered, data ) ) != IVAS_ERR_OK ) -#else - IF ( ( error = ivas_ism_dec_config( st_ivas, st_ivas->ism_mode, nSamplesRendered, data ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -146,11 +151,7 @@ ivas_error ivas_dec_setup( num_bits_read = add(num_bits_read, SBA_ORDER_BITS); IF ( GT_16(st_ivas->ini_frame , 0) && NE_32(ivas_total_brate, st_ivas->last_active_ivas_total_brate) && GT_32(ivas_total_brate, IVAS_SID_5k2 )) { -#ifndef IVAS_FLOAT_FIXED - IF ( ( error = ivas_sba_dec_reconfigure( st_ivas, nSamplesRendered, data ) ) != IVAS_ERR_OK ) -#else IF ( ( error = ivas_sba_dec_reconfigure_fx( st_ivas, nSamplesRendered, data ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -159,11 +160,7 @@ ivas_error ivas_dec_setup( { /* set Ambisonic (SBA) order used for analysis and coding */ st_ivas->sba_analysis_order = ivas_sba_get_analysis_order( ivas_total_brate, st_ivas->sba_order ); -#ifdef IVAS_FLOAT_FIXED ivas_sba_config_fx( ivas_total_brate, st_ivas->sba_analysis_order, -1, &( st_ivas->nchan_transport ), st_ivas->sba_planar, &st_ivas->nSCE, &st_ivas->nCPE, &st_ivas->element_mode_init ); -#else - ivas_sba_config(ivas_total_brate, st_ivas->sba_analysis_order, -1, &(st_ivas->nchan_transport), st_ivas->sba_planar, &st_ivas->nSCE, &st_ivas->nCPE, &st_ivas->element_mode_init); -#endif } } ELSE IF ( st_ivas->ivas_format == MASA_FORMAT ) @@ -192,192 +189,17 @@ ivas_error ivas_dec_setup( } ELSE { - -#ifdef IVAS_FLOAT_FIXED - Word16 n_samples_granularity; - - n_samples_granularity = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); - DECODER_TC_BUFFER_HANDLE hTcBuffer; - hTcBuffer = st_ivas->hTcBuffer; - DECODER_CONFIG_HANDLE hDecoderConfig=NULL; - Word16 numch_out_dirac=0; - SPAR_DEC_HANDLE hSpar = NULL; - Word16 numch_in; - IF( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) || EQ_16( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) ) - { - IF( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) && NE_16( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) ) - { - IF( LT_16( n_samples_granularity, st_ivas->hTcBuffer->n_samples_granularity ) ) - { - if ( st_ivas->hSbaIsmData ) - { - for ( Word16 ch_idx = 0; ch_idx < st_ivas->hSbaIsmData->delayBuffer_nchan; ch_idx++ ) - { - floatToFixed_arr32( st_ivas->hSbaIsmData->delayBuffer[ch_idx], st_ivas->hSbaIsmData->delayBuffer_fx[ch_idx], Q11, st_ivas->hSbaIsmData->delayBuffer_size ); - } - } - hSpar = st_ivas->hSpar; - //uint16_t nchan_internal; - //nchan_internal = ivas_sba_get_nchan_metadata( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); - hDecoderConfig = st_ivas->hDecoderConfig; - numch_out_dirac = hDecoderConfig->nchan_out; - IF( hSpar ) - { - //numch_out = hSpar->hFbMixer->fb_cfg->num_out_chans; - numch_in = hSpar->hFbMixer->fb_cfg->num_in_chans; - //num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ); - for ( Word16 in_ch = 0; in_ch < numch_in; in_ch++ ) - { - for ( Word16 i = 0; i < st_ivas->cldfbAnaDec[in_ch]->p_filter_length - st_ivas->cldfbAnaDec[in_ch]->no_channels; i++ ) - { - st_ivas->cldfbAnaDec[in_ch]->cldfb_state_fx[i] = (Word32) ( st_ivas->cldfbAnaDec[in_ch]->cldfb_state[i] * ( 1LL << ( Q11 ) ) ); - } - } - FOR( Word16 out_ch = 0; out_ch < numch_out_dirac; out_ch++ ) - { - IF( st_ivas->cldfbSynDec[out_ch] ) - { - FOR( Word16 i = 0; i < st_ivas->cldfbSynDec[out_ch]->p_filter_length; i++ ) - { - st_ivas->cldfbSynDec[out_ch]->cldfb_state_fx[i] = float_to_fix( st_ivas->cldfbSynDec[out_ch]->cldfb_state[i], Q11 ); - } - } - } - } - Word16 n_tc; - if ( st_ivas->ivas_format == MASA_ISM_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) - n_tc = st_ivas->nchan_ism; - else - n_tc = st_ivas->hTcBuffer->nchan_transport_internal; - for ( int ch = 0; ch < n_tc; ch++ ) - { - floatToFixed_arrL( st_ivas->hTcBuffer->tc[ch], st_ivas->hTcBuffer->tc_fx[ch], Q11, L_FRAME48k ); - } - } - } - } - - IF ( ( error = ivas_masa_dec_reconfigure_fx( st_ivas, nSamplesRendered, data ) ) != IVAS_ERR_OK ) -#else - IF ( ( error = ivas_masa_dec_reconfigure( st_ivas, nSamplesRendered, data ) ) != IVAS_ERR_OK ) -#endif - { + IF ( ( error = ivas_masa_dec_reconfigure_fx( st_ivas, nSamplesRendered, data ) ) != IVAS_ERR_OK ) { return error; } -#ifdef IVAS_FLOAT_FIXED - //local flt2fix: to be removed - if (hTcBuffer->tc_buffer) - fixedToFloat_arrL(hTcBuffer->tc_buffer_fx, hTcBuffer->tc_buffer, Q11, hTcBuffer->tc_buff_len); - IF(hSpar) - { - numch_in = hSpar->hFbMixer->fb_cfg->num_in_chans; - FOR(Word16 in_ch = 0; in_ch < numch_in; in_ch++) - { - FOR(Word16 i = 0; i < st_ivas->cldfbAnaDec[in_ch]->p_filter_length - st_ivas->cldfbAnaDec[in_ch]->no_channels; i++) - { - st_ivas->cldfbAnaDec[in_ch]->cldfb_state[i] = ((float)(st_ivas->cldfbAnaDec[in_ch]->cldfb_state_fx[i]) / (1LL << (Q11))); /*Rounding off*/ - } - } - FOR(Word16 out_ch = 0; out_ch < numch_out_dirac; out_ch++) - { - IF(st_ivas->cldfbSynDec[out_ch]) - { - FOR(Word16 i = 0; i < st_ivas->cldfbSynDec[out_ch]->p_filter_length; i++) - { - st_ivas->cldfbSynDec[out_ch]->cldfb_state[i] = ((float)(st_ivas->cldfbSynDec[out_ch]->cldfb_state_fx[i]) / (float)(1LL << (Q11))); - } - } - } - } - //local fix2flt end -#endif } } ELSE { -#ifdef IVAS_FLOAT_FIXED - //////////////// Cleanup changes: float to fixed ////////////////// - Word16 SrcInd[MAX_NUM_TDREND_CHANNELS]; - Word16 num_src = 0; - Word16 i; - - Word16 old_ism_mode = ivas_omasa_ism_mode_select(st_ivas->hDecoderConfig->last_ivas_total_brate, st_ivas->nchan_ism); - Word16 new_ism_mode = ivas_omasa_ism_mode_select(st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_ism); - if (old_ism_mode != new_ism_mode && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC) - { - // Float to fix conversions for ivas_td_binaural_open_fx - if (st_ivas->ism_mode == ISM_MASA_MODE_DISC) - { - FOR(i = 0; i < 4; i++) - { - st_ivas->hRenderConfig->directivity_fx[i * 3] = (Word16)floatToFixed(st_ivas->hRenderConfig->directivity[i * 3], 6); - st_ivas->hRenderConfig->directivity_fx[i * 3 + 1] = (Word16)floatToFixed(st_ivas->hRenderConfig->directivity[i * 3 + 1], 6); - st_ivas->hRenderConfig->directivity_fx[i * 3 + 2] = (Word16)floatToFixed(st_ivas->hRenderConfig->directivity[i * 3 + 2], 15); - } - } - // Float to fix conversions for ivas_cldfb_dec_reconfig_fx - FOR(i = 0; i < 16; i++) - { - IF(st_ivas->cldfbAnaDec[i]) - floatToFixed_arrL(st_ivas->cldfbAnaDec[i]->cldfb_state, st_ivas->cldfbAnaDec[i]->cldfb_state_fx, 11, sub(st_ivas->cldfbAnaDec[i]->p_filter_length, st_ivas->cldfbAnaDec[i]->no_channels)); - } - IF(st_ivas->hSpar) - { - st_ivas->hSpar->hFbMixer->cldfb_cross_fade_q = Q_factor_arr(st_ivas->hSpar->hFbMixer->cldfb_cross_fade, 16); - floatToFixed_arr(st_ivas->hSpar->hFbMixer->cldfb_cross_fade, st_ivas->hSpar->hFbMixer->cldfb_cross_fade_fx, st_ivas->hSpar->hFbMixer->cldfb_cross_fade_q, 16); - } - IF(st_ivas->cldfbSynDec[0]) - { - floatToFixed_arrL(st_ivas->cldfbSynDec[0]->cldfb_state, st_ivas->cldfbSynDec[0]->cldfb_state_fx, Q11, sub(st_ivas->cldfbSynDec[0]->p_filter_length, st_ivas->cldfbSynDec[0]->no_channels)); - } - } - //////////////////////////////////////////////////////////////// - IF( ( error = ivas_omasa_dec_config_fx( st_ivas, nSamplesRendered, &num_src, SrcInd, data ) ) != IVAS_ERR_OK ) { return error; } - - //////////////// Cleanup changes: float to fixed /////////////// - IF( NE_16( new_ism_mode, old_ism_mode ) && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC ) - { - // Cleanup changes for ivas_td_binaural_open: fixed to float - IF( EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) ) - { - Word16 nchan_rend = num_src; - IF( EQ_16( st_ivas->ivas_format, MC_FORMAT ) && NE_16( st_ivas->transport_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) ) - { - nchan_rend--; /* Skip LFE channel -- added to the others */ - } - FOR( Word16 nS = 0; nS < nchan_rend; nS++ ) - { - TDREND_SRC_t *Src_p = st_ivas->hBinRendererTd->Sources[SrcInd[nS]]; - IF( Src_p->SrcSpatial_p != NULL ) - { - Src_p->SrcSpatial_p->q_Pos_p = Q31; - } - TDREND_SRC_SPATIAL_t *SrcSpatial_p = st_ivas->hBinRendererTd->Sources[nS]->SrcSpatial_p; - SrcSpatial_p->q_Pos_p = Q31; - } - } - // Cleanup changes for ivas_cldfb_dec_reconfig_fx: fixed to float - FOR( i = 0; i < 16; i++ ) - { - IF( st_ivas->cldfbAnaDec[i] ) - fixedToFloat_arrL( st_ivas->cldfbAnaDec[i]->cldfb_state_fx, st_ivas->cldfbAnaDec[i]->cldfb_state, 11, sub( st_ivas->cldfbAnaDec[i]->p_filter_length, st_ivas->cldfbAnaDec[i]->no_channels ) ); - } - IF( st_ivas->cldfbSynDec[0] ) - { - fixedToFloat_arrL( st_ivas->cldfbSynDec[0]->cldfb_state_fx, st_ivas->cldfbSynDec[0]->cldfb_state, Q11, sub( st_ivas->cldfbSynDec[0]->p_filter_length, st_ivas->cldfbSynDec[0]->no_channels ) ); - } - } - //////////////////////////////////////////////////////////////// -#else - IF( ( error = ivas_omasa_dec_config( st_ivas, nSamplesRendered, data ) ) != IVAS_ERR_OK ) - { - return error; - } -#endif } } } @@ -395,89 +217,10 @@ ivas_error ivas_dec_setup( /* reconfigure in case a change of operation mode is detected */ IF ( ( GT_32(ivas_total_brate, IVAS_SID_5k2) && NE_32(ivas_total_brate, st_ivas->hDecoderConfig->last_ivas_total_brate )) || EQ_16( st_ivas->ini_active_frame, 0 ) ) { -#ifdef IVAS_FLOAT_FIXED - //////////////// Cleanup changes: float to fixed ////////////////// - Word16 SrcInd[MAX_NUM_TDREND_CHANNELS]; - Word16 num_src = 0; - Word16 i; - - Word16 old_ism_mode = ivas_omasa_ism_mode_select( st_ivas->hDecoderConfig->last_ivas_total_brate, st_ivas->nchan_ism ); - Word16 new_ism_mode = ivas_omasa_ism_mode_select( st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_ism ); - if ( old_ism_mode != new_ism_mode && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC ) - { - // Float to fix conversions for ivas_td_binaural_open_fx - if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC ) - { - FOR( i = 0; i < 4; i++ ) - { - st_ivas->hRenderConfig->directivity_fx[i * 3] = (Word16) floatToFixed( st_ivas->hRenderConfig->directivity[i * 3], 6 ); - st_ivas->hRenderConfig->directivity_fx[i * 3 + 1] = (Word16) floatToFixed( st_ivas->hRenderConfig->directivity[i * 3 + 1], 6 ); - st_ivas->hRenderConfig->directivity_fx[i * 3 + 2] = (Word16) floatToFixed( st_ivas->hRenderConfig->directivity[i * 3 + 2], 15 ); - } - } - // Float to fix conversions for ivas_cldfb_dec_reconfig_fx - FOR( i = 0; i < 16; i++ ) - { - IF( st_ivas->cldfbAnaDec[i] ) - floatToFixed_arrL( st_ivas->cldfbAnaDec[i]->cldfb_state, st_ivas->cldfbAnaDec[i]->cldfb_state_fx, 11, sub( st_ivas->cldfbAnaDec[i]->p_filter_length, st_ivas->cldfbAnaDec[i]->no_channels ) ); - } - IF( st_ivas->hSpar ) - { - st_ivas->hSpar->hFbMixer->cldfb_cross_fade_q = Q_factor_arr( st_ivas->hSpar->hFbMixer->cldfb_cross_fade, 16 ); - floatToFixed_arr( st_ivas->hSpar->hFbMixer->cldfb_cross_fade, st_ivas->hSpar->hFbMixer->cldfb_cross_fade_fx, st_ivas->hSpar->hFbMixer->cldfb_cross_fade_q, 16 ); - } - IF( st_ivas->cldfbSynDec[0] ) - { - floatToFixed_arrL( st_ivas->cldfbSynDec[0]->cldfb_state, st_ivas->cldfbSynDec[0]->cldfb_state_fx, Q11, sub( st_ivas->cldfbSynDec[0]->p_filter_length, st_ivas->cldfbSynDec[0]->no_channels ) ); - } - } - //////////////////////////////////////////////////////////////// - IF( ( error = ivas_omasa_dec_config_fx( st_ivas, nSamplesRendered, &num_src, SrcInd, data ) ) != IVAS_ERR_OK ) { return error; } - - //////////////// Cleanup changes: float to fixed /////////////// - IF( NE_16( new_ism_mode, old_ism_mode ) && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC ) - { - // Cleanup changes for ivas_td_binaural_open: fixed to float - IF( EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) ) - { - Word16 nchan_rend = num_src; - IF( EQ_16( st_ivas->ivas_format, MC_FORMAT ) && NE_16( st_ivas->transport_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) ) - { - nchan_rend--; /* Skip LFE channel -- added to the others */ - } - FOR( Word16 nS = 0; nS < nchan_rend; nS++ ) - { - TDREND_SRC_t *Src_p = st_ivas->hBinRendererTd->Sources[SrcInd[nS]]; - IF( Src_p->SrcSpatial_p != NULL ) - { - Src_p->SrcSpatial_p->q_Pos_p = Q31; - } - TDREND_SRC_SPATIAL_t *SrcSpatial_p = st_ivas->hBinRendererTd->Sources[nS]->SrcSpatial_p; - SrcSpatial_p->q_Pos_p = Q31; - } - } - // Cleanup changes for ivas_cldfb_dec_reconfig_fx: fixed to float - FOR( i = 0; i < 16; i++ ) - { - IF( st_ivas->cldfbAnaDec[i] ) - fixedToFloat_arrL( st_ivas->cldfbAnaDec[i]->cldfb_state_fx, st_ivas->cldfbAnaDec[i]->cldfb_state, 11, sub( st_ivas->cldfbAnaDec[i]->p_filter_length, st_ivas->cldfbAnaDec[i]->no_channels ) ); - } - IF( st_ivas->cldfbSynDec[0] ) - { - fixedToFloat_arrL( st_ivas->cldfbSynDec[0]->cldfb_state_fx, st_ivas->cldfbSynDec[0]->cldfb_state, Q11, sub( st_ivas->cldfbSynDec[0]->p_filter_length, st_ivas->cldfbSynDec[0]->no_channels ) ); - } - } - //////////////////////////////////////////////////////////////// -#else - IF( ( error = ivas_omasa_dec_config( st_ivas, nSamplesRendered, data ) ) != IVAS_ERR_OK ) - { - return error; - } -#endif } } } @@ -505,11 +248,7 @@ ivas_error ivas_dec_setup( IF ( GT_16(st_ivas->ini_frame, 0) && NE_32(ivas_total_brate, st_ivas->last_active_ivas_total_brate )) { -#ifndef IVAS_FLOAT_FIXED - IF ( ( error = ivas_sba_dec_reconfigure( st_ivas, nSamplesRendered, data ) ) != IVAS_ERR_OK ) -#else IF ( ( error = ivas_sba_dec_reconfigure_fx( st_ivas, nSamplesRendered, data ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -551,52 +290,10 @@ ivas_error ivas_dec_setup( num_bits_read = add(num_bits_read, MC_LS_SETUP_BITS); /* select MC format mode; reconfigure the MC format decoder */ - -#ifndef IVAS_FLOAT_FIXED - IF ( ( error = ivas_mc_dec_config( st_ivas, idx, nSamplesRendered, data ) ) != IVAS_ERR_OK ) - { - return error; - } -#else -#if 1 /*TODO: To be removed(Float to fixed conversion)*/ - IF(st_ivas->hTcBuffer) - FOR ( int ch = 0; ch < st_ivas->hTcBuffer->nchan_transport_internal; ch++ ) - { - floatToFixed_arrL( st_ivas->hTcBuffer->tc[ch], st_ivas->hTcBuffer->tc_fx[ch], Q11, L_FRAME48k ); - } - if ( st_ivas->mc_mode == MC_MODE_PARAMMC ) - { - if ( st_ivas->hParamMC ) - { - if ( st_ivas->hParamMC->diff_proto_info ) - FOR( Word16 i = 0; i < st_ivas->hParamMC->diff_proto_info->num_protos_diff; i++ ) - { - floatToFixed_arrL( st_ivas->hParamMC->diff_proto_info->proto_fac[i], st_ivas->hParamMC->diff_proto_info->proto_fac_fx[i], Q26, st_ivas->hParamMC->diff_proto_info->num_source_chan_diff[i] ); - } - } - } -#endif IF ( ( error = ivas_mc_dec_config_fx( st_ivas, idx, nSamplesRendered, data ) ) != IVAS_ERR_OK ) { return error; } -#if 1 - if ( st_ivas->mc_mode == MC_MODE_PARAMMC ) - { - if ( st_ivas->hParamMC ) - { - fixedToFloat_arrL( st_ivas->hParamMC->h_output_synthesis_params.proto_matrix_fx, st_ivas->hParamMC->h_output_synthesis_params.proto_matrix, 26, st_ivas->hParamMC->h_output_synthesis_params.proto_matrix_len ); - IF( st_ivas->hParamMC->diff_proto_info ) - FOR( Word16 i = 0; i < st_ivas->hParamMC->diff_proto_info->num_protos_diff; i++ ) - { - fixedToFloat_arrL( st_ivas->hParamMC->diff_proto_info->proto_fac_fx[i], st_ivas->hParamMC->diff_proto_info->proto_fac[i], 26, st_ivas->hParamMC->diff_proto_info->num_source_chan_diff[i] ); - } - if ( st_ivas->hParamMC->hoa_encoder_fx ) - fixedToFloat_arrL( st_ivas->hParamMC->hoa_encoder_fx, st_ivas->hParamMC->hoa_encoder, Q29, st_ivas->hTransSetup.nchan_out_woLFE * MAX_INTERN_CHANNELS ); - } - } -#endif -#endif } /*-------------------------------------------------------------------* @@ -678,11 +375,7 @@ ivas_error ivas_dec_setup( st_ivas->hDecoderConfig->ivas_total_brate = IVAS_24k4; } -#ifndef IVAS_FLOAT_FIXED - IF ( ( error = ivas_sba_dec_reconfigure( st_ivas, nSamplesRendered, data ) ) != IVAS_ERR_OK ) -#else IF ( ( error = ivas_sba_dec_reconfigure_fx( st_ivas, nSamplesRendered, data ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -728,11 +421,7 @@ ivas_error ivas_dec_setup( last_ism_mode = st_ivas->ism_mode; } -#ifdef IVAS_FLOAT_FIXED IF ( ( error = ivas_ism_dec_config_fx( st_ivas, last_ism_mode, nSamplesRendered, data ) ) != IVAS_ERR_OK ) -#else - if ( ( error = ivas_ism_dec_config( st_ivas, last_ism_mode, nSamplesRendered, data ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -751,11 +440,7 @@ ivas_error ivas_dec_setup( return IVAS_ERROR( error, "Sanity checks failed" ); } -#ifdef IVAS_FLOAT_FIXED IF ( ( error = ivas_init_decoder_fx( st_ivas ) ) != IVAS_ERR_OK ) -#else - IF ( ( error = ivas_init_decoder( st_ivas ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -780,155 +465,715 @@ ivas_error ivas_dec_setup( return error; } - - -/*-------------------------------------------------------------------* - * ivas_read_format() - * - * Read IVAS format signaling - *-------------------------------------------------------------------*/ - -static ivas_error ivas_read_format( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - Word16 *num_bits_read /* o : number of IVAS signaling bits read from the bitstream */ +#else +ivas_error ivas_dec_setup( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + uint16_t *nSamplesRendered, /* o : number of samples flushed from the previous frame (JBM) */ + int16_t *data /* o : output synthesis signal */ ) { - Word16 k, idx; - Word32 ivas_total_brate; + int16_t k, idx, num_bits_read; + int16_t nchan_ism, element_mode_flag; + Decoder_State *st; + int32_t ivas_total_brate; ivas_error error; error = IVAS_ERR_OK; + num_bits_read = 0; + element_mode_flag = 0; + ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; - *num_bits_read = 0; + /*-------------------------------------------------------------------* + * Read IVAS format + *-------------------------------------------------------------------*/ - IF ( !st_ivas->bfi && is_DTXrate( ivas_total_brate ) == 0 ) + ivas_read_format( st_ivas, &num_bits_read ); + + /*-------------------------------------------------------------------* + * Read other signling (ISM/MC mode, number of channels, etc.) + *-------------------------------------------------------------------*/ + + if ( is_DTXrate( ivas_total_brate ) == 0 ) { - /* read IVAS format */ - k = 0; - IF ( st_ivas->bit_stream[*num_bits_read] ) + /*-------------------------------------------------------------------* + * Read IVAS format related signaling: + * - in ISM : read number of objects + * - in SBA : read SBA planar flag and SBA order + * - in MASA : read number of TC + * - in MC : read LS setup + *-------------------------------------------------------------------*/ + + if ( st_ivas->ivas_format == STEREO_FORMAT ) { - k = 1; + element_mode_flag = 1; } - k <<= 1; - ( *num_bits_read )++; - - IF ( st_ivas->bit_stream[*num_bits_read] ) + else if ( st_ivas->ivas_format == ISM_FORMAT ) { - k += 1; + /* read the number of objects */ + st_ivas->nchan_transport = 1; + nchan_ism = 1; + k = (int16_t) ( ( ivas_total_brate / FRAMES_PER_SEC ) - 1 ); + while ( st_ivas->bit_stream[k] && nchan_ism < MAX_NUM_OBJECTS ) + { + nchan_ism++; + k--; + } + + st_ivas->nchan_ism = nchan_ism; + + if ( ( error = ivas_ism_dec_config( st_ivas, st_ivas->ism_mode, nSamplesRendered, data ) ) != IVAS_ERR_OK ) + { + return error; + } } - ( *num_bits_read )++; + else if ( st_ivas->ivas_format == SBA_FORMAT ) + { + /* read Ambisonic (SBA) planar flag */ + st_ivas->sba_planar = st_ivas->bit_stream[num_bits_read]; + num_bits_read += SBA_PLANAR_BITS; - SWITCH ( k ) + /* read Ambisonic (SBA) order */ + st_ivas->sba_order = st_ivas->bit_stream[num_bits_read + 1]; + st_ivas->sba_order += 2 * st_ivas->bit_stream[num_bits_read]; + + num_bits_read += SBA_ORDER_BITS; + if ( st_ivas->ini_frame > 0 && ivas_total_brate != st_ivas->last_active_ivas_total_brate && ivas_total_brate > IVAS_SID_5k2 ) + { + if ( ( error = ivas_sba_dec_reconfigure( st_ivas, nSamplesRendered, data ) ) != IVAS_ERR_OK ) + { + return error; + } + } + else + { + /* set Ambisonic (SBA) order used for analysis and coding */ + st_ivas->sba_analysis_order = ivas_sba_get_analysis_order( ivas_total_brate, st_ivas->sba_order ); + + ivas_sba_config( ivas_total_brate, st_ivas->sba_analysis_order, -1, &( st_ivas->nchan_transport ), st_ivas->sba_planar, &st_ivas->nSCE, &st_ivas->nCPE, &st_ivas->element_mode_init ); + } + } + else if ( st_ivas->ivas_format == MASA_FORMAT ) { - case 0: - st_ivas->ivas_format = STEREO_FORMAT; - BREAK; - case 1: - st_ivas->ivas_format = MC_FORMAT; - BREAK; - case 2: - st_ivas->ivas_format = ISM_FORMAT; + /* read number of MASA transport channels */ + if ( st_ivas->bit_stream[( ivas_total_brate / FRAMES_PER_SEC ) - 1] ) + { + st_ivas->nchan_transport = 2; + element_mode_flag = 1; + } + else + { + st_ivas->nchan_transport = 1; + } - IF ( ivas_total_brate >= IVAS_24k4 ) + if ( st_ivas->ini_frame > 0 ) + { + /* reconfigure in case a change of operation mode is detected */ + if ( ( ivas_total_brate > IVAS_SID_5k2 && ivas_total_brate != st_ivas->hDecoderConfig->last_ivas_total_brate ) || ( st_ivas->ini_active_frame == 0 ) ) { - IF ( st_ivas->bit_stream[*num_bits_read] ) + if ( st_ivas->last_ivas_format == MASA_FORMAT ) { - ( *num_bits_read )++; - IF ( st_ivas->bit_stream[*num_bits_read] ) + if ( st_ivas->ini_active_frame == 0 && ivas_total_brate != FRAME_NO_DATA && ivas_total_brate < MASA_STEREO_MIN_BITRATE && st_ivas->nCPE == 1 ) { - st_ivas->ivas_format = SBA_ISM_FORMAT; + st_ivas->hCPE[0]->nchan_out = 1; } - ELSE + else { - st_ivas->ivas_format = MASA_ISM_FORMAT; + + if ( ( error = ivas_masa_dec_reconfigure( st_ivas, nSamplesRendered, data ) ) != IVAS_ERR_OK ) + { + return error; + } } } + else + { + if ( ( error = ivas_omasa_dec_config( st_ivas, nSamplesRendered, data ) ) != IVAS_ERR_OK ) - ( *num_bits_read )++; - } - BREAK; - case 3: - IF ( st_ivas->bit_stream[*num_bits_read] ) - { - st_ivas->ivas_format = MASA_FORMAT; + { + return error; + } + } } - ELSE - { - st_ivas->ivas_format = SBA_FORMAT; - /* read Ambisonic (SBA) planar flag */ - st_ivas->sba_planar = st_ivas->bit_stream[( *num_bits_read ) + 1]; - + } + } + else if ( st_ivas->ivas_format == MASA_ISM_FORMAT ) + { + st_ivas->nchan_transport = 2; /* always 2 MASA transport channels */ + + /* for the DISC mode the number of objects are written at the end of the bitstream, in the MASA metadata */ + st_ivas->nchan_ism = 2 * st_ivas->bit_stream[ivas_total_brate / FRAMES_PER_SEC - 1] + st_ivas->bit_stream[ivas_total_brate / FRAMES_PER_SEC - 2] + 1; + st_ivas->ism_mode = ivas_omasa_ism_mode_select( ivas_total_brate, st_ivas->nchan_ism ); + + if ( st_ivas->ini_frame > 0 ) + { + /* reconfigure in case a change of operation mode is detected */ + if ( ( ivas_total_brate > IVAS_SID_5k2 && ivas_total_brate != st_ivas->hDecoderConfig->last_ivas_total_brate ) || ( st_ivas->ini_active_frame == 0 ) ) + { + if ( ( error = ivas_omasa_dec_config( st_ivas, nSamplesRendered, data ) ) != IVAS_ERR_OK ) + { + return error; + } + } + } + } + else if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) + { + /* the number of objects is written at the end of the bitstream, in the SBA metadata */ + st_ivas->nchan_ism = 2 * st_ivas->bit_stream[ivas_total_brate / FRAMES_PER_SEC - 1] + st_ivas->bit_stream[ivas_total_brate / FRAMES_PER_SEC - 2] + 1; + + if ( ivas_total_brate < IVAS_24k4 || ivas_total_brate >= IVAS_256k ) + { + /* read Ambisonic (SBA) planar flag */ + st_ivas->sba_planar = st_ivas->bit_stream[num_bits_read]; + num_bits_read += SBA_PLANAR_BITS; + } + + st_ivas->sba_order = st_ivas->bit_stream[num_bits_read + 1]; + st_ivas->sba_order += 2 * st_ivas->bit_stream[num_bits_read]; + num_bits_read += SBA_ORDER_BITS; + + /* read Ambisonic (SBA) order */ + if ( ivas_total_brate < IVAS_256k ) + { + st_ivas->sba_order = 3; + } + + if ( st_ivas->ini_frame > 0 && ivas_total_brate != st_ivas->last_active_ivas_total_brate ) + { + if ( ( error = ivas_sba_dec_reconfigure( st_ivas, nSamplesRendered, data ) ) != IVAS_ERR_OK ) + { + return error; + } + } + else + { + /* set Ambisonic (SBA) order used for analysis and coding */ + st_ivas->sba_analysis_order = ivas_sba_get_analysis_order( ivas_total_brate, st_ivas->sba_order ); + + ivas_sba_config( ivas_total_brate, st_ivas->sba_analysis_order, -1, &( st_ivas->nchan_transport ), st_ivas->sba_planar, &st_ivas->nSCE, &st_ivas->nCPE, &st_ivas->element_mode_init ); + + /*correct number of CPEs for discrete ISM coding*/ + if ( st_ivas->ini_frame > 0 && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + { + st_ivas->nCPE += ( st_ivas->nchan_ism + 1 ) >> 1; + } + } + + if ( ivas_total_brate >= IVAS_256k ) + { + st_ivas->ism_mode = ISM_SBA_MODE_DISC; + } + else + { + st_ivas->ism_mode = ISM_MODE_NONE; + } + } + else if ( st_ivas->ivas_format == MC_FORMAT ) + { + /* read MC configuration */ + idx = 0; + for ( k = 0; k < MC_LS_SETUP_BITS; k++ ) + { + if ( st_ivas->bit_stream[num_bits_read + k] ) + { + idx += 1 << ( MC_LS_SETUP_BITS - 1 - k ); + } + } + num_bits_read += MC_LS_SETUP_BITS; + + /* select MC format mode; reconfigure the MC format decoder */ + if ( ( error = ivas_mc_dec_config( st_ivas, idx, nSamplesRendered, data ) ) != IVAS_ERR_OK ) + { + return error; + } + } + + /*-------------------------------------------------------------------* + * Read element mode + *-------------------------------------------------------------------*/ + + if ( st_ivas->ini_frame == 0 && element_mode_flag ) + { + /* read stereo technology info */ + if ( ivas_total_brate < MIN_BRATE_MDCT_STEREO ) + { + /* 1 bit */ + if ( st_ivas->bit_stream[num_bits_read] ) + { + st_ivas->element_mode_init = 1 + IVAS_CPE_DFT; + } + else + { + st_ivas->element_mode_init = 0 + IVAS_CPE_DFT; + } + } + else + { + st_ivas->element_mode_init = IVAS_CPE_MDCT; + } + } + } + else if ( ivas_total_brate == IVAS_SID_5k2 ) + { + switch ( st_ivas->sid_format ) + { + case SID_DFT_STEREO: + st_ivas->element_mode_init = IVAS_CPE_DFT; + break; + case SID_MDCT_STEREO: + st_ivas->element_mode_init = IVAS_CPE_MDCT; + break; + case SID_ISM: + st_ivas->element_mode_init = IVAS_SCE; + break; + case SID_MASA_1TC: + st_ivas->element_mode_init = IVAS_SCE; + st_ivas->nchan_transport = 1; + break; + case SID_MASA_2TC: + if ( st_ivas->bit_stream[ivas_total_brate / FRAMES_PER_SEC - 1 - SID_FORMAT_NBITS] == 1 ) + { + st_ivas->element_mode_init = IVAS_CPE_MDCT; + } + else + { + st_ivas->element_mode_init = IVAS_CPE_DFT; + } + st_ivas->nchan_transport = 2; + break; + case SID_SBA_1TC: + st_ivas->element_mode_init = IVAS_SCE; + break; + case SID_SBA_2TC: + st_ivas->element_mode_init = IVAS_CPE_MDCT; + break; + } + + if ( st_ivas->ini_frame > 0 && st_ivas->ivas_format == SBA_FORMAT ) + { + int16_t nchan_transport_old, nchan_transport; + nchan_transport_old = st_ivas->nchan_transport; + nchan_transport = ( st_ivas->sid_format == SID_SBA_2TC ) ? 2 : 1; + + if ( ( nchan_transport_old != nchan_transport ) ) + { + /*Setting the default bitrate for the reconfig function*/ + if ( st_ivas->sid_format == SID_SBA_2TC ) + { + st_ivas->hDecoderConfig->ivas_total_brate = IVAS_48k; + } + else + { + st_ivas->hDecoderConfig->ivas_total_brate = IVAS_24k4; + } + + if ( ( error = ivas_sba_dec_reconfigure( st_ivas, nSamplesRendered, data ) ) != IVAS_ERR_OK ) + { + return error; + } + + st_ivas->last_active_ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; + st_ivas->hDecoderConfig->ivas_total_brate = ivas_total_brate; + } + } + + if ( st_ivas->ivas_format == ISM_FORMAT ) + { + ISM_MODE last_ism_mode = st_ivas->ism_mode; + + /* read the number of objects */ + st_ivas->nchan_transport = 1; + nchan_ism = 1; + k = (int16_t) ( ( ivas_total_brate / FRAMES_PER_SEC ) - 1 ) - SID_FORMAT_NBITS; + while ( st_ivas->bit_stream[k] && nchan_ism < MAX_NUM_OBJECTS ) + { + nchan_ism++; + k--; + } + k--; + + if ( st_ivas->ini_frame > 0 && nchan_ism != st_ivas->nchan_ism ) + { + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "wrong number of objects signalled!" ); + } + + st_ivas->nchan_ism = nchan_ism; + + /* read ism_mode */ + st_ivas->ism_mode = ISM_MODE_DISC; + if ( nchan_ism > 2 ) + { + k -= nchan_ism; /* SID metadata flags */ + idx = st_ivas->bit_stream[k]; + st_ivas->ism_mode = (ISM_MODE) ( idx + 1 ); + } + + if ( st_ivas->ini_frame == 0 ) + { + last_ism_mode = st_ivas->ism_mode; + } + + if ( ( error = ivas_ism_dec_config( st_ivas, last_ism_mode, nSamplesRendered, data ) ) != IVAS_ERR_OK ) + { + return error; + } + } + } + + /*-------------------------------------------------------------------* + * Initialize decoder in the first good frame based on IVAS format + * and number of transport channels + *-------------------------------------------------------------------*/ + + if ( st_ivas->ini_frame == 0 && st_ivas->ivas_format != UNDEFINED_FORMAT ) + { + if ( ( error = doSanityChecks_IVAS( st_ivas ) ) != IVAS_ERR_OK ) + { + return IVAS_ERROR( error, "Sanity checks failed" ); + } + + if ( ( error = ivas_init_decoder( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } + } + + + /*----------------------------------------------------------------* + * Reset bitstream pointers + *----------------------------------------------------------------*/ + + ivas_set_bitstream_pointers( st_ivas ); + + reset_elements( st_ivas ); + + /* update bitstream buffer pointer -> take into account already read bits */ + if ( ( st_ivas->nSCE > 0 ) || ( st_ivas->nCPE > 0 ) ) + { + st = ( st_ivas->nSCE > 0 ) ? st_ivas->hSCE[0]->hCoreCoder[0] : st_ivas->hCPE[0]->hCoreCoder[0]; + st->next_bit_pos = num_bits_read; + st->total_brate = ACELP_8k00; /* only temporary initialization - this is needed for get_next_indice() in the frame following NO_DATA frame */ + } + + return error; +} + + +#endif + + + +// ivas_param_ism_dec +/*-------------------------------------------------------------------* + * ivas_read_format() + * + * Read IVAS format signaling + *-------------------------------------------------------------------*/ + +#ifdef IVAS_FLOAT_FIXED +static ivas_error ivas_read_format( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + Word16 *num_bits_read /* o : number of IVAS signaling bits read from the bitstream */ +) +{ + Word16 k, idx; + Word32 ivas_total_brate; + ivas_error error; + + error = IVAS_ERR_OK; + + ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; + move32(); + + *num_bits_read = 0; + move16(); + + IF ( !st_ivas->bfi && is_DTXrate( ivas_total_brate ) == 0 ) + { + /* read IVAS format */ + k = 0; + IF ( st_ivas->bit_stream[*num_bits_read] ) + { + k = 1; + } + k <<= 1; + ( *num_bits_read )++; + + IF ( st_ivas->bit_stream[*num_bits_read] ) + { + k += 1; + } + ( *num_bits_read )++; + + SWITCH ( k ) + { + case 0: + st_ivas->ivas_format = STEREO_FORMAT; + BREAK; + case 1: + st_ivas->ivas_format = MC_FORMAT; + BREAK; + case 2: + st_ivas->ivas_format = ISM_FORMAT; + + IF ( ivas_total_brate >= IVAS_24k4 ) + { + IF ( st_ivas->bit_stream[*num_bits_read] ) + { + ( *num_bits_read )++; + IF ( st_ivas->bit_stream[*num_bits_read] ) + { + st_ivas->ivas_format = SBA_ISM_FORMAT; + } + ELSE + { + st_ivas->ivas_format = MASA_ISM_FORMAT; + } + } + + ( *num_bits_read )++; + } + BREAK; + case 3: + IF ( st_ivas->bit_stream[*num_bits_read] ) + { + st_ivas->ivas_format = MASA_FORMAT; + } + ELSE + { + st_ivas->ivas_format = SBA_FORMAT; + /* read Ambisonic (SBA) planar flag */ + st_ivas->sba_planar = st_ivas->bit_stream[( *num_bits_read ) + 1]; + + /* read Ambisonic (SBA) order */ + st_ivas->sba_order = st_ivas->bit_stream[( *num_bits_read ) + 2 + SBA_PLANAR_BITS]; + st_ivas->sba_order += 2 * st_ivas->bit_stream[( *num_bits_read ) + 1 + SBA_PLANAR_BITS]; + IF ( st_ivas->sba_order == 0 ) + { + st_ivas->ivas_format = SBA_ISM_FORMAT; + } + } + ( *num_bits_read )++; + + BREAK; + } + } + ELSE IF ( EQ_16(st_ivas->bfi, 0) && ivas_total_brate == IVAS_SID_5k2 ) + { + /* read IVAS format in SID frame */ + idx = 0; + FOR ( k = 0; k < SID_FORMAT_NBITS; k++ ) + { + idx += st_ivas->bit_stream[k] << ( SID_FORMAT_NBITS - 1 - k ); + } + + ( *num_bits_read ) = add(*num_bits_read, SID_FORMAT_NBITS); + st_ivas->sid_format = idx; + + SWITCH ( idx ) + { + case SID_DFT_STEREO: + case SID_MDCT_STEREO: + st_ivas->ivas_format = STEREO_FORMAT; + BREAK; + case SID_ISM: + st_ivas->ivas_format = ISM_FORMAT; + + BREAK; + case SID_MULTICHANNEL: + st_ivas->ivas_format = MC_FORMAT; + BREAK; + case SID_SBA_1TC: + st_ivas->ivas_format = SBA_FORMAT; + st_ivas->element_mode_init = IVAS_SCE; + BREAK; + case SID_SBA_2TC: + st_ivas->ivas_format = SBA_FORMAT; + st_ivas->element_mode_init = IVAS_CPE_MDCT; + BREAK; + case SID_MASA_1TC: + st_ivas->ivas_format = MASA_FORMAT; + st_ivas->element_mode_init = IVAS_SCE; + BREAK; + case SID_MASA_2TC: + st_ivas->ivas_format = MASA_FORMAT; + IF ( st_ivas->bit_stream[ivas_total_brate / FRAMES_PER_SEC - 1] == 1 ) + { + st_ivas->element_mode_init = IVAS_CPE_MDCT; + } + ELSE + { + st_ivas->element_mode_init = IVAS_CPE_DFT; + } + BREAK; + default: + /* This should actually be impossible, since only 3 bits are read, so if this happens something is broken */ + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Invalid value %c found in SID format field.", st_ivas->sid_format ); + } + + IF ( st_ivas->ivas_format == SBA_FORMAT ) + { + IF ( st_ivas->sba_analysis_order == 0 ) + { + st_ivas->sba_analysis_order = SBA_FOA_ORDER; + } + } + + /* reset bitstream handle to avoid BER detection after reading the 2400 kbps for ch0 */ + st_ivas->bit_stream += ( *num_bits_read ); + ( *num_bits_read ) = 0; + } + ELSE + { + /* In SID/NO_DATA frames, use the previous frame IVAS format */ + } + + return error; +} +#else +static ivas_error ivas_read_format( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + int16_t *num_bits_read /* o : number of IVAS signaling bits read from the bitstream */ +) +{ + int16_t k, idx; + int32_t ivas_total_brate; + ivas_error error; + + error = IVAS_ERR_OK; + + ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; + + *num_bits_read = 0; + + if ( !st_ivas->bfi && is_DTXrate( ivas_total_brate ) == 0 ) + { + /* read IVAS format */ + k = 0; + if ( st_ivas->bit_stream[*num_bits_read] ) + { + k = 1; + } + k <<= 1; + ( *num_bits_read )++; + + if ( st_ivas->bit_stream[*num_bits_read] ) + { + k += 1; + } + ( *num_bits_read )++; + + switch ( k ) + { + case 0: + st_ivas->ivas_format = STEREO_FORMAT; + break; + case 1: + st_ivas->ivas_format = MC_FORMAT; + break; + case 2: + st_ivas->ivas_format = ISM_FORMAT; + + if ( ivas_total_brate >= IVAS_24k4 ) + { + if ( st_ivas->bit_stream[*num_bits_read] ) + { + ( *num_bits_read )++; + if ( st_ivas->bit_stream[*num_bits_read] ) + { + st_ivas->ivas_format = SBA_ISM_FORMAT; + } + else + { + st_ivas->ivas_format = MASA_ISM_FORMAT; + } + } + + ( *num_bits_read )++; + } + break; + case 3: + if ( st_ivas->bit_stream[*num_bits_read] ) + { + st_ivas->ivas_format = MASA_FORMAT; + } + else + { + st_ivas->ivas_format = SBA_FORMAT; + /* read Ambisonic (SBA) planar flag */ + st_ivas->sba_planar = st_ivas->bit_stream[( *num_bits_read ) + 1]; + /* read Ambisonic (SBA) order */ st_ivas->sba_order = st_ivas->bit_stream[( *num_bits_read ) + 2 + SBA_PLANAR_BITS]; st_ivas->sba_order += 2 * st_ivas->bit_stream[( *num_bits_read ) + 1 + SBA_PLANAR_BITS]; - IF ( st_ivas->sba_order == 0 ) + if ( st_ivas->sba_order == 0 ) { st_ivas->ivas_format = SBA_ISM_FORMAT; } } ( *num_bits_read )++; - BREAK; + break; } } - ELSE IF ( EQ_16(st_ivas->bfi, 0) && ivas_total_brate == IVAS_SID_5k2 ) + else if ( !st_ivas->bfi && ivas_total_brate == IVAS_SID_5k2 ) { /* read IVAS format in SID frame */ idx = 0; - FOR ( k = 0; k < SID_FORMAT_NBITS; k++ ) + for ( k = 0; k < SID_FORMAT_NBITS; k++ ) { idx += st_ivas->bit_stream[k] << ( SID_FORMAT_NBITS - 1 - k ); } - ( *num_bits_read ) = add(*num_bits_read, SID_FORMAT_NBITS); + ( *num_bits_read ) += SID_FORMAT_NBITS; st_ivas->sid_format = idx; - SWITCH ( idx ) + switch ( idx ) { case SID_DFT_STEREO: case SID_MDCT_STEREO: st_ivas->ivas_format = STEREO_FORMAT; - BREAK; + break; case SID_ISM: st_ivas->ivas_format = ISM_FORMAT; - BREAK; + break; case SID_MULTICHANNEL: st_ivas->ivas_format = MC_FORMAT; - BREAK; + break; case SID_SBA_1TC: st_ivas->ivas_format = SBA_FORMAT; st_ivas->element_mode_init = IVAS_SCE; - BREAK; + break; case SID_SBA_2TC: st_ivas->ivas_format = SBA_FORMAT; st_ivas->element_mode_init = IVAS_CPE_MDCT; - BREAK; + break; case SID_MASA_1TC: st_ivas->ivas_format = MASA_FORMAT; st_ivas->element_mode_init = IVAS_SCE; - BREAK; + break; case SID_MASA_2TC: st_ivas->ivas_format = MASA_FORMAT; - IF ( st_ivas->bit_stream[ivas_total_brate / FRAMES_PER_SEC - 1] == 1 ) + if ( st_ivas->bit_stream[ivas_total_brate / FRAMES_PER_SEC - 1] == 1 ) { st_ivas->element_mode_init = IVAS_CPE_MDCT; } - ELSE + else { st_ivas->element_mode_init = IVAS_CPE_DFT; } - BREAK; + break; default: /* This should actually be impossible, since only 3 bits are read, so if this happens something is broken */ return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Invalid value %c found in SID format field.", st_ivas->sid_format ); } - IF ( st_ivas->ivas_format == SBA_FORMAT ) + if ( st_ivas->ivas_format == SBA_FORMAT ) { - IF ( st_ivas->sba_analysis_order == 0 ) + if ( st_ivas->sba_analysis_order == 0 ) { st_ivas->sba_analysis_order = SBA_FOA_ORDER; } @@ -938,7 +1183,7 @@ static ivas_error ivas_read_format( st_ivas->bit_stream += ( *num_bits_read ); ( *num_bits_read ) = 0; } - ELSE + else { /* In SID/NO_DATA frames, use the previous frame IVAS format */ } @@ -946,6 +1191,8 @@ static ivas_error ivas_read_format( return error; } +#endif + /*-------------------------------------------------------------------* * getNumChanSynthesis() @@ -955,6 +1202,8 @@ static ivas_error ivas_read_format( *-------------------------------------------------------------------*/ /*! r: number of channels to be synthesised */ + +#ifdef IVAS_FLOAT_FIXED Word16 getNumChanSynthesis( Decoder_Struct *st_ivas /* i : IVAS decoder structure */ ) @@ -986,7 +1235,39 @@ Word16 getNumChanSynthesis( return n; } +#else +int16_t getNumChanSynthesis( + Decoder_Struct *st_ivas /* i : IVAS decoder structure */ +) +{ + int16_t n; + + n = st_ivas->nSCE + CPE_CHANNELS * st_ivas->nCPE; + + if ( st_ivas->sba_dirac_stereo_flag ) + { + n = CPE_CHANNELS; + } + else if ( ( st_ivas->hMCT != NULL || st_ivas->ivas_format == SBA_FORMAT ) && st_ivas->ivas_format != SBA_ISM_FORMAT ) + { + n = st_ivas->nchan_transport; + } + else if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) + { + if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + { + n = st_ivas->nchan_transport + st_ivas->nchan_ism; + } + else + { + n = st_ivas->nchan_transport; + } + } + + return n; +} +#endif /*-------------------------------------------------------------------* * copy_decoder_config() @@ -994,6 +1275,33 @@ Word16 getNumChanSynthesis( * Copy IVAS configuration structure to the CoreCoder state structure *-------------------------------------------------------------------*/ +#ifdef IVAS_FLOAT_FIXED +void copy_decoder_config( + Decoder_Struct *st_ivas, /* i : IVAS decoder structure */ + Decoder_State *st /* o : decoder state structure */ +) +{ + st->output_Fs = st_ivas->hDecoderConfig->output_Fs; + move32(); + st->Opt_AMR_WB = st_ivas->hDecoderConfig->Opt_AMR_WB; + move16(); + st->codec_mode = st_ivas->codec_mode; + move16(); + st->ini_frame = st_ivas->ini_frame; + move16(); + + st->bfi = st_ivas->bfi; + move16(); + + st->writeFECoffset = st_ivas->writeFECoffset; + move16(); + + st->element_mode = st_ivas->element_mode_init; + move16(); + + return; +} +#else void copy_decoder_config( Decoder_Struct *st_ivas, /* i : IVAS decoder structure */ Decoder_State *st /* o : decoder state structure */ @@ -1013,6 +1321,7 @@ void copy_decoder_config( return; } +#endif /*-------------------------------------------------------------------* * ivas_init_decoder_front() @@ -1020,7 +1329,7 @@ void copy_decoder_config( * Set decoder parameters to initial values *-------------------------------------------------------------------*/ #ifdef IVAS_FLOAT_FIXED -ivas_error ivas_init_decoder_front_fx( +ivas_error ivas_init_decoder_front( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ) { @@ -1033,16 +1342,21 @@ ivas_error ivas_init_decoder_front_fx( *-----------------------------------------------------------------*/ st_ivas->nSCE = 0; + move16(); st_ivas->nCPE = 0; + move16(); st_ivas->nchan_transport = -1; + move16(); st_ivas->ism_mode = ISM_MODE_NONE; st_ivas->mc_mode = MC_MODE_NONE; st_ivas->sba_dirac_stereo_flag = 0; + move32(); /* HRTF binauralization latency in ns */ st_ivas->binaural_latency_ns = 0; + move32(); /*-------------------------------------------------------------------* * Allocate and initialize Custom loudspeaker layout handle @@ -1081,7 +1395,6 @@ ivas_error ivas_init_decoder_front_fx( return error; } } - /*-------------------------------------------------------------------* * Allocate and initialize external orientation handle *--------------------------------------------------------------------*/ @@ -1093,7 +1406,7 @@ ivas_error ivas_init_decoder_front_fx( return error; } #ifdef IVAS_FLOAT_FIXED_TO_BE_REMOVED - for ( Word16 i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) + FOR ( Word16 i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) { st_ivas->hExtOrientationData->Quaternions[i].w = fixedToFloat_32( st_ivas->hExtOrientationData->Quaternions[i].w_fx, st_ivas->hExtOrientationData->Quaternions[i].q_fact ); st_ivas->hExtOrientationData->Quaternions[i].x = fixedToFloat_32( st_ivas->hExtOrientationData->Quaternions[i].x_fx, st_ivas->hExtOrientationData->Quaternions[i].q_fact ); @@ -1115,7 +1428,7 @@ ivas_error ivas_init_decoder_front_fx( return error; } #ifdef IVAS_FLOAT_FIXED_TO_BE_REMOVED - for ( Word16 i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) + FOR ( Word16 i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) { st_ivas->hCombinedOrientationData->Quaternions[i].w = fixedToFloat_32( st_ivas->hCombinedOrientationData->Quaternions[i].w_fx, st_ivas->hCombinedOrientationData->Quaternions[i].q_fact ); st_ivas->hCombinedOrientationData->Quaternions[i].x = fixedToFloat_32( st_ivas->hCombinedOrientationData->Quaternions[i].x_fx, st_ivas->hCombinedOrientationData->Quaternions[i].q_fact ); @@ -1174,6 +1487,7 @@ ivas_error ivas_init_decoder_front_fx( } #ifdef IVAS_FLOAT_FIXED_TO_BE_REMOVED + /*FLOAT CODE*/ IF ( ( error = ivas_render_config_init_from_rom( &st_ivas->hRenderConfig ) ) != IVAS_ERR_OK ) { return error; @@ -1212,9 +1526,9 @@ ivas_error ivas_init_decoder_front( * Allocate and initialize Custom loudspeaker layout handle *--------------------------------------------------------------------*/ - IF ( st_ivas->hDecoderConfig->Opt_LsCustom ) + if ( st_ivas->hDecoderConfig->Opt_LsCustom ) { - IF ( ( error = ivas_ls_custom_open( &( st_ivas->hLsSetupCustom ) ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_ls_custom_open( &( st_ivas->hLsSetupCustom ) ) ) != IVAS_ERR_OK ) { return error; } @@ -1224,13 +1538,13 @@ ivas_error ivas_init_decoder_front( * Allocate and initialize Head-Tracking handle *--------------------------------------------------------------------*/ - IF( st_ivas->hDecoderConfig->Opt_Headrotation ) + if ( st_ivas->hDecoderConfig->Opt_Headrotation ) { - IF( ( error = ivas_headTrack_open( &( st_ivas->hHeadTrackData ) ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_headTrack_open( &( st_ivas->hHeadTrackData ) ) ) != IVAS_ERR_OK ) { return error; } - IF( ( error = ivas_orient_trk_SetTrackingType( st_ivas->hHeadTrackData->OrientationTracker, st_ivas->hDecoderConfig->orientation_tracking ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_orient_trk_SetTrackingType( st_ivas->hHeadTrackData->OrientationTracker, st_ivas->hDecoderConfig->orientation_tracking ) ) != IVAS_ERR_OK ) { return error; } @@ -1240,9 +1554,9 @@ ivas_error ivas_init_decoder_front( * Allocate and initialize external orientation handle *--------------------------------------------------------------------*/ - IF ( st_ivas->hDecoderConfig->Opt_ExternalOrientation ) + if ( st_ivas->hDecoderConfig->Opt_ExternalOrientation ) { - IF ( ( error = ivas_external_orientation_open( &( st_ivas->hExtOrientationData ), st_ivas->hDecoderConfig->render_framesize ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_external_orientation_open( &( st_ivas->hExtOrientationData ), st_ivas->hDecoderConfig->render_framesize ) ) != IVAS_ERR_OK ) { return error; } @@ -1252,9 +1566,9 @@ ivas_error ivas_init_decoder_front( * Allocate and initialize combined orientation handle *--------------------------------------------------------------------*/ - IF ( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation ) + if ( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation ) { - IF ( ( error = ivas_combined_orientation_open( &( st_ivas->hCombinedOrientationData ), st_ivas->hDecoderConfig->output_Fs, st_ivas->hDecoderConfig->render_framesize ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_combined_orientation_open( &( st_ivas->hCombinedOrientationData ), st_ivas->hDecoderConfig->output_Fs, st_ivas->hDecoderConfig->render_framesize ) ) != IVAS_ERR_OK ) { return error; } @@ -1264,19 +1578,18 @@ ivas_error ivas_init_decoder_front( * Allocate HRTF binary handle *--------------------------------------------------------------------*/ - IF ( st_ivas->hDecoderConfig->Opt_HRTF_binary ) + if ( st_ivas->hDecoderConfig->Opt_HRTF_binary ) { if ( ( error = ivas_HRTF_binary_open( &( st_ivas->hHrtfTD ) ) ) != IVAS_ERR_OK ) { return error; } - if ( ( error = ivas_HRTF_CRend_binary_open( &( st_ivas->hSetOfHRTF ) ) ) != IVAS_ERR_OK ) { return error; } - IF ( ( error = ivas_HRTF_fastconv_binary_open( &st_ivas->hHrtfFastConv ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_HRTF_fastconv_binary_open( &st_ivas->hHrtfFastConv ) ) != IVAS_ERR_OK ) { return error; } @@ -1291,15 +1604,15 @@ ivas_error ivas_init_decoder_front( * Allocate and initialize Binaural Renderer configuration handle *--------------------------------------------------------------------*/ - IF ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB + if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) { - IF ( ( error = ivas_render_config_open( &( st_ivas->hRenderConfig ) ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_render_config_open( &( st_ivas->hRenderConfig ) ) ) != IVAS_ERR_OK ) { return error; } - IF ( ( error = ivas_render_config_init_from_rom( &st_ivas->hRenderConfig ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_render_config_init_from_rom( &st_ivas->hRenderConfig ) ) != IVAS_ERR_OK ) { return error; } @@ -1307,8 +1620,11 @@ ivas_error ivas_init_decoder_front( return error; } + #endif + + /*-------------------------------------------------------------------* * ivas_init_decoder() * @@ -1404,25 +1720,11 @@ ivas_error ivas_init_decoder_fx( IF ( output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM ) { - FOR(int ind = 0; ind < MAX_OUTPUT_CHANNELS; ind++) - { - st_ivas->hLsSetupCustom->ls_azimuth_fx[ind] = (Word32)(st_ivas->hLsSetupCustom->ls_azimuth[ind] * (1 << 22)); - st_ivas->hLsSetupCustom->ls_elevation_fx[ind] = (Word32)(st_ivas->hLsSetupCustom->ls_elevation[ind] * (1 << 22)); - } 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; -//#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; st_ivas->hIntSetup.ls_elevation_fx = st_ivas->hLsSetupCustom->ls_elevation_fx; -//#endif - } ELSE { @@ -1447,7 +1749,9 @@ ivas_error ivas_init_decoder_fx( 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; + move16(); st_ivas->hLsSetupCustom->separate_ch_found = 1; + move16(); BREAK; } } @@ -1460,12 +1764,13 @@ ivas_error ivas_init_decoder_fx( * Allocate and initialize SCE/CPE and other handles *-----------------------------------------------------------------*/ - IF ( st_ivas->ivas_format == MONO_FORMAT ) + IF ( EQ_32( st_ivas->ivas_format, MONO_FORMAT ) ) { st_ivas->nSCE = 1; /* in mono, there is always only one SCE */ st_ivas->nCPE = 0; st_ivas->nchan_transport = 1; sce_id = 0; + move16(); move16(); move16(); move16(); IF ( ( error = create_sce_dec( st_ivas, sce_id, ivas_total_brate ) ) != IVAS_ERR_OK ) { @@ -1482,13 +1787,14 @@ ivas_error ivas_init_decoder_fx( st_ivas->nSCE = 0; st_ivas->nCPE = 1; /* in stereo, there is always only one CPE */ cpe_id = 0; + move16(); move16(); move16(); move16(); move16(); IF ( ( error = create_cpe_dec( st_ivas, cpe_id, ivas_total_brate ) ) != IVAS_ERR_OK ) { return error; } - for ( n = 0; n < st_ivas->nchan_transport; n++ ) + FOR ( n = 0; n < st_ivas->nchan_transport; n++ ) { reset_indices_dec( st_ivas->hCPE[cpe_id]->hCoreCoder[n] ); } @@ -1496,10 +1802,6 @@ ivas_error ivas_init_decoder_fx( /* init EFAP for custom LS output and set hTransSetup */ IF ( output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM ) { - /*float2fix block: to be removed*/ - //( (float *) st_ivas->hOutSetup.ls_azimuth, (Word32 *) st_ivas->hOutSetup.ls_azimuth_fx, Q22, st_ivas->hOutSetup.nchan_out_woLFE ); - //floatToFixed_arrL( (float *) st_ivas->hOutSetup.ls_elevation, (Word32 *) st_ivas->hOutSetup.ls_elevation_fx, Q22, st_ivas->hOutSetup.nchan_out_woLFE ); - /*float2fix block end*/ IF ( ( error = efap_init_data_fx( &( st_ivas->hEFAPdata ), st_ivas->hOutSetup.ls_azimuth_fx, st_ivas->hOutSetup.ls_elevation_fx, st_ivas->hOutSetup.nchan_out_woLFE, EFAP_MODE_EFAP ) ) != IVAS_ERR_OK ) { return error; @@ -1517,10 +1819,13 @@ ivas_error ivas_init_decoder_fx( st_ivas->ism_extmeta_active = -1; st_ivas->ism_extmeta_cnt = 0; + move16(); move16(); move16(); move16(); IF ( st_ivas->ism_mode == ISM_MODE_PARAM ) { st_ivas->nchan_transport = MAX_PARAM_ISM_WAVE; + move16(); st_ivas->nSCE = MAX_PARAM_ISM_WAVE; + move16(); IF ( ( error = ivas_param_ism_dec_open_fx( st_ivas ) ) != IVAS_ERR_OK ) { @@ -1546,20 +1851,21 @@ ivas_error ivas_init_decoder_fx( } st_ivas->hISMDTX.sce_id_dtx = 0; + move16(); - IF ( st_ivas->ism_mode == ISM_MODE_PARAM ) + IF ( EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) ) { st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->seed2 = st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->seed3; } - else if ( st_ivas->ism_mode == ISM_MODE_DISC ) + ELSE IF ( EQ_32( st_ivas->ism_mode, ISM_MODE_DISC ) ) { - for ( sce_id = 0; sce_id < st_ivas->nSCE; ++sce_id ) + FOR ( sce_id = 0; sce_id < st_ivas->nSCE; ++sce_id ) { st_ivas->hSCE[sce_id]->hCoreCoder[0]->hFdCngDec->hFdCngCom->seed2 = 2 + sce_id; } } } - ELSE IF ( st_ivas->ivas_format == SBA_FORMAT ) + ELSE IF ( EQ_32( st_ivas->ivas_format, SBA_FORMAT ) ) { IF ( ( error = ivas_qmetadata_open( &( st_ivas->hQMetaData ) ) ) != IVAS_ERR_OK ) { @@ -1577,17 +1883,13 @@ ivas_error ivas_init_decoder_fx( IF ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_DEC && st_ivas->hOutSetup.is_loudspeaker_setup ) { - /*float2fix block: to be removed*/ - //floatToFixed_arrL((float *)st_ivas->hOutSetup.ls_azimuth, (Word32 *)st_ivas->hOutSetup.ls_azimuth_fx, Q22, st_ivas->hIntSetup.ambisonics_order); - //floatToFixed_arrL((float *)st_ivas->hOutSetup.ls_elevation, (Word32 *)st_ivas->hOutSetup.ls_elevation_fx, Q22, st_ivas->hIntSetup.ambisonics_order); - /*float2fix end*/ IF ( ( error = ivas_sba_get_hoa_dec_matrix_fx( st_ivas->hOutSetup, &st_ivas->hoa_dec_mtx, st_ivas->hIntSetup.ambisonics_order ) ) != IVAS_ERR_OK ) { return error; } } - IF ( ( error = ivas_dirac_sba_config( st_ivas->hQMetaData, &st_ivas->element_mode_init, ivas_total_brate, st_ivas->sba_analysis_order, ivas_get_hodirac_flag( ivas_total_brate, st_ivas->sba_analysis_order ) ? IVAS_MAX_NUM_BANDS : ( IVAS_MAX_NUM_BANDS - SPAR_DIRAC_SPLIT_START_BAND ),st_ivas->ivas_format ) ) != IVAS_ERR_OK ) + IF ( ( error = ivas_dirac_sba_config_fx( st_ivas->hQMetaData, &st_ivas->element_mode_init, ivas_total_brate, st_ivas->sba_analysis_order, ivas_get_hodirac_flag( ivas_total_brate, st_ivas->sba_analysis_order ) ? IVAS_MAX_NUM_BANDS : ( IVAS_MAX_NUM_BANDS - SPAR_DIRAC_SPLIT_START_BAND ),st_ivas->ivas_format ) ) != IVAS_ERR_OK ) { return error; } @@ -1614,7 +1916,7 @@ ivas_error ivas_init_decoder_fx( st_ivas->hQMetaData->numTwoDirBands = (UWord8) st_ivas->hQMetaData->q_direction[0].cfg.nbands; } - ivas_dirac_config_bands( band_grouping, IVAS_MAX_NUM_BANDS, (Word16) ( st_ivas->hDecoderConfig->output_Fs * INV_CLDFB_BANDWIDTH + 0.5f ), + ivas_dirac_config_bands_fx( band_grouping, IVAS_MAX_NUM_BANDS, (Word16) ( st_ivas->hDecoderConfig->output_Fs * INV_CLDFB_BANDWIDTH + 0.5f ), st_ivas->hSpar->dirac_to_spar_md_bands, st_ivas->hQMetaData->useLowerBandRes, st_ivas->hSpar->enc_param_start_band, 0 ); } st_ivas->sba_dirac_stereo_flag = ivas_get_sba_dirac_stereo_flag( st_ivas ); @@ -1670,6 +1972,7 @@ ivas_error ivas_init_decoder_fx( /* if we start in ISM_MODE_NONE in MASA_ISM, that appears as normal MASA, but we may change to a mode with ISMs */ st_ivas->ism_extmeta_active = -1; st_ivas->ism_extmeta_cnt = 0; + move16(); move16(); IF ( ( error = ivas_qmetadata_open( &( st_ivas->hQMetaData ) ) ) != IVAS_ERR_OK ) { return error; @@ -1718,7 +2021,9 @@ ivas_error ivas_init_decoder_fx( { Word32 temp_brate[MAX_SCE]; st_ivas->ism_extmeta_active = -1; + move16(); st_ivas->ism_extmeta_cnt = 0; + move16(); st_ivas->sba_dirac_stereo_flag = ivas_get_sba_dirac_stereo_flag( st_ivas ); @@ -1734,10 +2039,6 @@ ivas_error ivas_init_decoder_fx( IF ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_DEC && st_ivas->hOutSetup.is_loudspeaker_setup ) { - /*float2fix block: to be removed*/ - //floatToFixed_arrL((float *)st_ivas->hOutSetup.ls_azimuth, (Word32 *)st_ivas->hOutSetup.ls_azimuth_fx, Q22, st_ivas->hIntSetup.ambisonics_order); - //floatToFixed_arrL((float *)st_ivas->hOutSetup.ls_elevation, (Word32 *)st_ivas->hOutSetup.ls_elevation_fx, Q22, st_ivas->hIntSetup.ambisonics_order); - /*float2fix end*/ IF ( ( error = ivas_sba_get_hoa_dec_matrix_fx( st_ivas->hOutSetup, &st_ivas->hoa_dec_mtx, st_ivas->hIntSetup.ambisonics_order ) ) != IVAS_ERR_OK ) { return error; @@ -1963,7 +2264,7 @@ ivas_error ivas_init_decoder_fx( } } - IF ( ( error = create_mct_dec( st_ivas ) ) != IVAS_ERR_OK ) + IF ( ( error = create_mct_dec_fx( st_ivas ) ) != IVAS_ERR_OK ) { return error; } @@ -1986,14 +2287,14 @@ ivas_error ivas_init_decoder_fx( st_ivas->nSCE = 0; st_ivas->nCPE = MC_PARAMUPMIX_MAX_TRANSPORT_CHANS / CPE_CHANNELS; st_ivas->nchan_transport = MC_PARAMUPMIX_MAX_TRANSPORT_CHANS; - + move16(); move16(); move16(); IF ( ( error = ivas_mc_paramupmix_dec_open( st_ivas ) ) != IVAS_ERR_OK ) { return error; } st_ivas->element_mode_init = IVAS_CPE_MDCT; - + move16(); FOR ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) { IF ( ( error = create_cpe_dec( st_ivas, cpe_id, ( ivas_total_brate / ( st_ivas->nchan_transport - 1 ) * CPE_CHANNELS ) ) ) != IVAS_ERR_OK ) @@ -2007,7 +2308,7 @@ ivas_error ivas_init_decoder_fx( } } - IF ( ( error = create_mct_dec( st_ivas ) ) != IVAS_ERR_OK ) + IF ( ( error = create_mct_dec_fx( st_ivas ) ) != IVAS_ERR_OK ) { return error; } @@ -2017,58 +2318,18 @@ ivas_error ivas_init_decoder_fx( /* init EFAP for custom LS setup */ IF ( output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM ) { - /*float2fix block: to be removed*/ - floatToFixed_arrL(st_ivas->hLsSetupCustom->ls_azimuth, st_ivas->hLsSetupCustom->ls_azimuth_fx, Q22, st_ivas->hLsSetupCustom->num_spk); - floatToFixed_arrL(st_ivas->hLsSetupCustom->ls_elevation, st_ivas->hLsSetupCustom->ls_elevation_fx, Q22, st_ivas->hLsSetupCustom->num_spk); - /*float2fix block end*/ IF ( ( error = efap_init_data_fx( &( st_ivas->hEFAPdata ), st_ivas->hLsSetupCustom->ls_azimuth_fx, st_ivas->hLsSetupCustom->ls_elevation_fx, st_ivas->hLsSetupCustom->num_spk, EFAP_MODE_EFAP ) ) != IVAS_ERR_OK ) { return error; } } -#ifdef IVAS_FLOAT_FIXED IF( ( error = ivas_param_mc_dec_open_fx( st_ivas ) ) != IVAS_ERR_OK ) { return error; } st_ivas->hParamMC->proto_matrix_int_e = 0; -#if 1/*Fixed to float conversions*/ - PARAM_MC_DEC_HANDLE hParamMC; - hParamMC = st_ivas->hParamMC; - Word16 nchan_out_transport, nchan_out_cov; - MC_LS_SETUP mc_ls_setup; - Word16 nchan_transport; - mc_ls_setup = ivas_mc_map_output_config_to_mc_ls_setup( st_ivas->transport_config ); - st_ivas->nchan_transport = ivas_param_mc_getNumTransportChannels( ivas_total_brate, mc_ls_setup ); - nchan_transport = st_ivas->nchan_transport; - nchan_out_transport = st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe; - if ( hParamMC->synthesis_conf == PARAM_MC_SYNTH_LS_CONV_COV || hParamMC->synthesis_conf == PARAM_MC_SYNTH_MONO_STEREO ) - { - nchan_out_cov = st_ivas->hOutSetup.nchan_out_woLFE + st_ivas->hOutSetup.num_lfe; - } - else - { - nchan_out_cov = nchan_out_transport; - } - if ( hParamMC ) - { - fixedToFloat_arrL( hParamMC->h_output_synthesis_params.proto_matrix_fx, hParamMC->h_output_synthesis_params.proto_matrix, 26, nchan_transport * nchan_out_cov ); - FOR( i = 0; i < hParamMC->diff_proto_info->num_protos_diff; i++ ) - { - fixedToFloat_arrL( hParamMC->diff_proto_info->proto_fac_fx[i], hParamMC->diff_proto_info->proto_fac[i], 26, hParamMC->diff_proto_info->num_source_chan_diff[i] ); - } - if ( hParamMC->hoa_encoder_fx ) - fixedToFloat_arrL( hParamMC->hoa_encoder_fx, hParamMC->hoa_encoder, Q29, st_ivas->hTransSetup.nchan_out_woLFE * MAX_INTERN_CHANNELS ); - } -#endif // 1 -#else - IF ( ( error = ivas_param_mc_dec_open( st_ivas ) ) != IVAS_ERR_OK ) - { - return error; - } -#endif - + move16(); FOR ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) { IF ( ( error = create_cpe_dec( st_ivas, cpe_id, ivas_total_brate / ( st_ivas->nSCE + st_ivas->nCPE ) ) ) != IVAS_ERR_OK ) @@ -2084,7 +2345,7 @@ ivas_error ivas_init_decoder_fx( IF ( GT_16(st_ivas->nCPE, 1 )) { - IF ( ( error = create_mct_dec( st_ivas ) ) != IVAS_ERR_OK ) + IF ( ( error = create_mct_dec_fx( st_ivas ) ) != IVAS_ERR_OK ) { return error; } @@ -2144,13 +2405,6 @@ ivas_error ivas_init_decoder_fx( } set16_fx( st_ivas->hLsSetupCustom->separate_ch_gains_fx, inv_sqr, st_ivas->hLsSetupCustom->num_spk ); } - ELSE - { -#ifndef IVAS_FLOAT_FIXED - /*TODO/observation : not hit by decoder tests*/ - vbap_determine_gains( st_ivas->hVBAPdata, st_ivas->hLsSetupCustom->separate_ch_gains, 0, 0, 0 ); -#endif - } } @@ -2224,12 +2478,11 @@ ivas_error ivas_init_decoder_fx( FOR ( i = 0; i < n; i++ ) { - IF((st_ivas->mem_hp20_out_fx[i] = (Word32 *)malloc((L_HP20_MEM + 2) * sizeof(Word32))) == NULL) - { - return (IVAS_ERROR(IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HP20 filter memory\n")); - } - - set32_fx(st_ivas->mem_hp20_out_fx[i], 0, L_HP20_MEM + 2); + IF((st_ivas->mem_hp20_out_fx[i] = (Word32 *)malloc((L_HP20_MEM + 2) * sizeof(Word32))) == NULL) + { + return (IVAS_ERROR(IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HP20 filter memory\n")); + } + set32_fx(st_ivas->mem_hp20_out_fx[i], 0, L_HP20_MEM + 2); } /*-------------------------------------------------------------------* @@ -2262,14 +2515,12 @@ ivas_error ivas_init_decoder_fx( } ELSE IF ( st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD ) { -#ifdef IVAS_FLOAT_FIXED Word16 SrcInd[MAX_NUM_TDREND_CHANNELS]; Word16 num_src; IF( ( error = ivas_td_binaural_open_fx( st_ivas, SrcInd, &num_src ) ) != IVAS_ERR_OK ) { return error; } -#if 1 // Cleanup changes for ivas_td_binaural_open: fixed to float Word16 nchan_rend = num_src; IF( EQ_16( st_ivas->ivas_format, MC_FORMAT ) && NE_16( st_ivas->transport_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) ) { @@ -2285,15 +2536,8 @@ ivas_error ivas_init_decoder_fx( TDREND_SRC_SPATIAL_t *SrcSpatial_p = st_ivas->hBinRendererTd->Sources[nS]->SrcSpatial_p; SrcSpatial_p->q_Pos_p = Q31; } -#endif -#else - IF ( ( error = ivas_td_binaural_open( st_ivas ) ) != IVAS_ERR_OK ) - { - return error; - } -#endif - IF ( st_ivas->hIntSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) + IF ( EQ_32( st_ivas->hIntSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) { IF ( ( error = ivas_reverb_open_fx( &st_ivas->hReverb, st_ivas->hDecoderConfig->output_config, NULL, st_ivas->hBinRendererTd->HrFiltSet_p->lr_energy_and_iac_fx, st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) { @@ -2373,14 +2617,12 @@ ivas_error ivas_init_decoder_fx( IF ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) { /* Allocate TD renderer for the objects in DISC mode */ -#ifdef IVAS_FLOAT_FIXED Word16 SrcInd[MAX_NUM_TDREND_CHANNELS]; Word16 num_src; IF((error = ivas_td_binaural_open_fx(st_ivas, SrcInd, &num_src)) != IVAS_ERR_OK) { return error; } -#if 1 // Cleanup changes for ivas_td_binaural_open: fixed to float Word16 nchan_rend = num_src; IF(EQ_16(st_ivas->ivas_format, MC_FORMAT) && NE_16(st_ivas->transport_config, IVAS_AUDIO_CONFIG_LS_CUSTOM)) { @@ -2396,13 +2638,6 @@ ivas_error ivas_init_decoder_fx( TDREND_SRC_SPATIAL_t *SrcSpatial_p = st_ivas->hBinRendererTd->Sources[nS]->SrcSpatial_p; SrcSpatial_p->q_Pos_p = Q31; } -#endif -#else - IF ( ( error = ivas_td_binaural_open( st_ivas ) ) != IVAS_ERR_OK ) - { - return error; - } -#endif /* Allocate 'hIsmRendererData' handle and memory for delay buffer within 'hMasaIsmData' */ IF ( ( error = ivas_omasa_separate_object_renderer_open( st_ivas ) ) != IVAS_ERR_OK ) @@ -2444,14 +2679,12 @@ ivas_error ivas_init_decoder_fx( IF ( ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ) && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { /* Allocate TD renderer for the objects in DISC mode */ -#ifdef IVAS_FLOAT_FIXED Word16 SrcInd[MAX_NUM_TDREND_CHANNELS]; Word16 num_src; IF((error = ivas_td_binaural_open_fx(st_ivas, SrcInd, &num_src)) != IVAS_ERR_OK) { return error; } -#if 1 // Cleanup changes for ivas_td_binaural_open: fixed to float Word16 nchan_rend = num_src; IF(EQ_16(st_ivas->ivas_format, MC_FORMAT) && NE_16(st_ivas->transport_config, IVAS_AUDIO_CONFIG_LS_CUSTOM)) { @@ -2467,13 +2700,6 @@ ivas_error ivas_init_decoder_fx( TDREND_SRC_SPATIAL_t *SrcSpatial_p = st_ivas->hBinRendererTd->Sources[nS]->SrcSpatial_p; SrcSpatial_p->q_Pos_p = Q31; } -#endif -#else - IF ( ( error = ivas_td_binaural_open( st_ivas ) ) != IVAS_ERR_OK ) - { - return error; - } -#endif } } @@ -2490,12 +2716,13 @@ ivas_error ivas_init_decoder_fx( { { /* Account for filterbank delay */ - binauralization_delay_ns += IVAS_FB_DEC_DELAY_NS; + binauralization_delay_ns = L_add( binauralization_delay_ns, IVAS_FB_DEC_DELAY_NS ); } } ELSE { binauralization_delay_ns = 0; + move32(); } } @@ -2659,25 +2886,23 @@ ivas_error ivas_init_decoder_fx( st_ivas->p_output_f[n] = NULL; st_ivas->p_output_fx[n] = NULL; } - - return error; } #else -ivas_error ivas_init_decoder( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -) -{ - Word16 i, n, k; - Word16 sce_id, cpe_id; - Word16 numCldfbAnalyses, numCldfbSyntheses; - Word16 granularity, n_channels_transport_jbm; - Word32 output_Fs, ivas_total_brate; - Word32 binauralization_delay_ns; +ivas_error ivas_init_decoder( + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +) +{ + int16_t i, n, k; + int16_t sce_id, cpe_id; + int16_t numCldfbAnalyses, numCldfbSyntheses; + int16_t granularity, n_channels_transport_jbm; + int32_t output_Fs, ivas_total_brate; + int32_t binauralization_delay_ns; AUDIO_CONFIG output_config; DECODER_CONFIG_HANDLE hDecoderConfig; ivas_error error; - Word32 ism_total_brate; + int32_t ism_total_brate; error = IVAS_ERR_OK; @@ -2693,18 +2918,18 @@ ivas_error ivas_init_decoder( * Set number of output channels for EXTERNAL output config. *-----------------------------------------------------------------*/ - IF ( output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) + if ( output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) { - IF ( st_ivas->ivas_format == SBA_ISM_FORMAT ) + if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) { hDecoderConfig->nchan_out = audioCfg2channels( IVAS_AUDIO_CONFIG_HOA3 ); hDecoderConfig->nchan_out += st_ivas->nchan_ism; } - ELSE IF ( st_ivas->ism_mode == ISM_MASA_MODE_DISC ) + else if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC ) { hDecoderConfig->nchan_out = st_ivas->nchan_transport + st_ivas->nchan_ism; } - ELSE IF ( !( st_ivas->ism_mode == ISM_MODE_PARAM ) ) + else if ( !( st_ivas->ism_mode == ISM_MODE_PARAM ) ) { hDecoderConfig->nchan_out = st_ivas->nchan_transport; } @@ -2720,7 +2945,7 @@ ivas_error ivas_init_decoder( ivas_output_init( &( st_ivas->hOutSetup ), output_config ); - IF ( st_ivas->ivas_format == SBA_ISM_FORMAT && output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) + if ( st_ivas->ivas_format == SBA_ISM_FORMAT && output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) { st_ivas->hOutSetup.ambisonics_order = SBA_HOA3_ORDER; st_ivas->intern_config = IVAS_AUDIO_CONFIG_7_1_4; @@ -2728,7 +2953,7 @@ ivas_error ivas_init_decoder( st_ivas->hOutSetup.nchan_out_woLFE = audioCfg2channels( st_ivas->intern_config ); } - IF ( st_ivas->ivas_format == SBA_ISM_FORMAT && output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) + if ( st_ivas->ivas_format == SBA_ISM_FORMAT && output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) { st_ivas->hOutSetup.ambisonics_order = SBA_HOA3_ORDER; st_ivas->intern_config = IVAS_AUDIO_CONFIG_HOA3; @@ -2737,12 +2962,12 @@ ivas_error ivas_init_decoder( } /* Only initialize transport setup if it is used */ - IF ( st_ivas->transport_config != IVAS_AUDIO_CONFIG_INVALID ) + if ( st_ivas->transport_config != IVAS_AUDIO_CONFIG_INVALID ) { ivas_output_init( &( st_ivas->hTransSetup ), st_ivas->transport_config ); } - IF ( st_ivas->ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_MCMASA ) + if ( st_ivas->ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_MCMASA ) { ivas_mcmasa_setNumTransportChannels( &( st_ivas->nchan_transport ), &( st_ivas->element_mode_init ), ivas_total_brate ); @@ -2751,9 +2976,9 @@ ivas_error ivas_init_decoder( ivas_renderer_select( st_ivas ); - IF ( output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM ) + if ( output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM ) { - IF ( ( error = ivas_ls_custom_output_init( st_ivas ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_ls_custom_output_init( st_ivas ) ) != IVAS_ERR_OK ) { return error; } @@ -2761,23 +2986,23 @@ ivas_error ivas_init_decoder( ivas_output_init( &( st_ivas->hIntSetup ), st_ivas->intern_config ); - IF ( st_ivas->ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_MCMASA ) + if ( st_ivas->ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_MCMASA ) { ivas_mcmasa_set_separate_channel_mode( &( st_ivas->hIntSetup.separateChannelEnabled ), &( st_ivas->hIntSetup.separateChannelIndex ), ivas_total_brate ); - IF ( st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM && st_ivas->hOutSetup.separateChannelEnabled ) + if ( st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM && st_ivas->hOutSetup.separateChannelEnabled ) { st_ivas->hLsSetupCustom->separate_ch_found = 0; - IF ( st_ivas->hOutSetup.nchan_out_woLFE >= MCMASA_MIN_SPEAKERS_SEPARATE_CENTER ) + if ( st_ivas->hOutSetup.nchan_out_woLFE >= MCMASA_MIN_SPEAKERS_SEPARATE_CENTER ) { /* check for a speaker at (0, 0) if minimum speaker count is available */ - FOR ( i = 0; i < st_ivas->hOutSetup.nchan_out_woLFE; i++ ) + 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 ( st_ivas->hOutSetup.ls_azimuth[i] == 0.0f && st_ivas->hOutSetup.ls_elevation[i] == 0.0f ) { st_ivas->hIntSetup.separateChannelIndex = i; st_ivas->hLsSetupCustom->separate_ch_found = 1; - BREAK; + break; } } } @@ -2789,21 +3014,21 @@ ivas_error ivas_init_decoder( * Allocate and initialize SCE/CPE and other handles *-----------------------------------------------------------------*/ - IF ( st_ivas->ivas_format == MONO_FORMAT ) + if ( st_ivas->ivas_format == MONO_FORMAT ) { st_ivas->nSCE = 1; /* in mono, there is always only one SCE */ st_ivas->nCPE = 0; st_ivas->nchan_transport = 1; sce_id = 0; - IF ( ( error = create_sce_dec( st_ivas, sce_id, ivas_total_brate ) ) != IVAS_ERR_OK ) + if ( ( error = create_sce_dec( st_ivas, sce_id, ivas_total_brate ) ) != IVAS_ERR_OK ) { return error; } reset_indices_dec( st_ivas->hSCE[sce_id]->hCoreCoder[0] ); } - ELSE IF ( st_ivas->ivas_format == STEREO_FORMAT ) + else if ( st_ivas->ivas_format == STEREO_FORMAT ) { st_ivas->nchan_transport = CPE_CHANNELS; st_ivas->intern_config = IVAS_AUDIO_CONFIG_STEREO; @@ -2812,7 +3037,7 @@ ivas_error ivas_init_decoder( st_ivas->nCPE = 1; /* in stereo, there is always only one CPE */ cpe_id = 0; - IF ( ( error = create_cpe_dec( st_ivas, cpe_id, ivas_total_brate ) ) != IVAS_ERR_OK ) + if ( ( error = create_cpe_dec( st_ivas, cpe_id, ivas_total_brate ) ) != IVAS_ERR_OK ) { return error; } @@ -2823,9 +3048,9 @@ ivas_error ivas_init_decoder( } /* init EFAP for custom LS output and set hTransSetup */ - IF ( output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM ) + if ( output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM ) { - IF ( ( error = efap_init_data( &( st_ivas->hEFAPdata ), st_ivas->hOutSetup.ls_azimuth, st_ivas->hOutSetup.ls_elevation, st_ivas->hOutSetup.nchan_out_woLFE, EFAP_MODE_EFAP ) ) != IVAS_ERR_OK ) + if ( ( error = efap_init_data( &( st_ivas->hEFAPdata ), st_ivas->hOutSetup.ls_azimuth, st_ivas->hOutSetup.ls_elevation, st_ivas->hOutSetup.nchan_out_woLFE, EFAP_MODE_EFAP ) ) != IVAS_ERR_OK ) { return error; } @@ -2833,34 +3058,34 @@ ivas_error ivas_init_decoder( ivas_output_init( &( st_ivas->hTransSetup ), IVAS_AUDIO_CONFIG_STEREO ); } } - ELSE IF ( st_ivas->ivas_format == ISM_FORMAT ) + else if ( st_ivas->ivas_format == ISM_FORMAT ) { - Word32 element_brate_tmp[MAX_NUM_OBJECTS]; + int32_t element_brate_tmp[MAX_NUM_OBJECTS]; st_ivas->nSCE = st_ivas->nchan_transport; /* "st_ivas->nchan_transport" is known from ivas_dec_setup */ st_ivas->nCPE = 0; st_ivas->ism_extmeta_active = -1; st_ivas->ism_extmeta_cnt = 0; - IF ( st_ivas->ism_mode == ISM_MODE_PARAM ) + if ( st_ivas->ism_mode == ISM_MODE_PARAM ) { st_ivas->nchan_transport = MAX_PARAM_ISM_WAVE; st_ivas->nSCE = MAX_PARAM_ISM_WAVE; - IF ( ( error = ivas_param_ism_dec_open( st_ivas ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_param_ism_dec_open( st_ivas ) ) != IVAS_ERR_OK ) { return error; } } - IF ( ( error = ivas_ism_metadata_dec_create( st_ivas, st_ivas->nSCE, element_brate_tmp ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_ism_metadata_dec_create( st_ivas, st_ivas->nSCE, element_brate_tmp ) ) != IVAS_ERR_OK ) { return error; } - FOR ( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ ) + for ( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ ) { - IF ( ( error = create_sce_dec( st_ivas, sce_id, element_brate_tmp[sce_id] ) ) != IVAS_ERR_OK ) + if ( ( error = create_sce_dec( st_ivas, sce_id, element_brate_tmp[sce_id] ) ) != IVAS_ERR_OK ) { return error; } @@ -2872,7 +3097,7 @@ ivas_error ivas_init_decoder( st_ivas->hISMDTX.sce_id_dtx = 0; - IF ( st_ivas->ism_mode == ISM_MODE_PARAM ) + if ( st_ivas->ism_mode == ISM_MODE_PARAM ) { st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->seed2 = st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->seed3; } @@ -2884,61 +3109,64 @@ ivas_error ivas_init_decoder( } } } - ELSE IF ( st_ivas->ivas_format == SBA_FORMAT ) + else if ( st_ivas->ivas_format == SBA_FORMAT ) { - IF ( ( error = ivas_qmetadata_open( &( st_ivas->hQMetaData ) ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_qmetadata_open( &( st_ivas->hQMetaData ) ) ) != IVAS_ERR_OK ) { return error; } - IF ( ( error = ivas_spar_dec_open( st_ivas, 0 ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_spar_dec_open( st_ivas, 0 ) ) != IVAS_ERR_OK ) { return error; } - IF ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_DEC && st_ivas->hOutSetup.is_loudspeaker_setup ) + if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_DEC && st_ivas->hOutSetup.is_loudspeaker_setup ) { - IF ( ( error = ivas_sba_get_hoa_dec_matrix( st_ivas->hOutSetup, &st_ivas->hoa_dec_mtx, st_ivas->hIntSetup.ambisonics_order ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_sba_get_hoa_dec_matrix( st_ivas->hOutSetup, &st_ivas->hoa_dec_mtx, st_ivas->hIntSetup.ambisonics_order ) ) != IVAS_ERR_OK ) { return error; } } - IF ( ( error = ivas_dirac_sba_config( st_ivas->hQMetaData, &st_ivas->element_mode_init, ivas_total_brate, st_ivas->sba_analysis_order, ivas_get_hodirac_flag( ivas_total_brate, st_ivas->sba_analysis_order ) ? IVAS_MAX_NUM_BANDS : ( IVAS_MAX_NUM_BANDS - SPAR_DIRAC_SPLIT_START_BAND ),st_ivas->ivas_format ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_dirac_sba_config( st_ivas->hQMetaData, &st_ivas->element_mode_init, ivas_total_brate, st_ivas->sba_analysis_order, ivas_get_hodirac_flag( ivas_total_brate, st_ivas->sba_analysis_order ) ? IVAS_MAX_NUM_BANDS : ( IVAS_MAX_NUM_BANDS - SPAR_DIRAC_SPLIT_START_BAND ) + , + st_ivas->ivas_format + ) ) != IVAS_ERR_OK ) { return error; } - IF ( hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_FOA && st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_STEREO && st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_MONO ) + if ( hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_FOA && st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_STEREO && st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_MONO ) { - IF ( ( error = ivas_dirac_dec_config( st_ivas, DIRAC_OPEN ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_dirac_dec_config( st_ivas, DIRAC_OPEN ) ) != IVAS_ERR_OK ) { return error; } st_ivas->hSpar->enc_param_start_band = st_ivas->hDirAC->hConfig->enc_param_start_band; } - ELSE + else { - Word16 band_grouping[IVAS_MAX_NUM_BANDS + 1]; + int16_t band_grouping[IVAS_MAX_NUM_BANDS + 1]; st_ivas->hSpar->enc_param_start_band = min( IVAS_MAX_NUM_BANDS, SPAR_DIRAC_SPLIT_START_BAND ); - IF ( ivas_get_hodirac_flag( ivas_total_brate, st_ivas->sba_analysis_order ) ) + if ( ivas_get_hodirac_flag( ivas_total_brate, st_ivas->sba_analysis_order ) ) { st_ivas->hSpar->enc_param_start_band = 0; - set_c( (Word8 *) st_ivas->hQMetaData->twoDirBands, (Word8) 1, st_ivas->hQMetaData->q_direction[0].cfg.nbands ); - st_ivas->hQMetaData->numTwoDirBands = (UWord8) st_ivas->hQMetaData->q_direction[0].cfg.nbands; + set_c( (int8_t *) st_ivas->hQMetaData->twoDirBands, (int8_t) 1, st_ivas->hQMetaData->q_direction[0].cfg.nbands ); + st_ivas->hQMetaData->numTwoDirBands = (uint8_t) st_ivas->hQMetaData->q_direction[0].cfg.nbands; } - ivas_dirac_config_bands( band_grouping, IVAS_MAX_NUM_BANDS, (Word16) ( st_ivas->hDecoderConfig->output_Fs * INV_CLDFB_BANDWIDTH + 0.5f ), + ivas_dirac_config_bands( band_grouping, IVAS_MAX_NUM_BANDS, (int16_t) ( st_ivas->hDecoderConfig->output_Fs * INV_CLDFB_BANDWIDTH + 0.5f ), st_ivas->hSpar->dirac_to_spar_md_bands, st_ivas->hQMetaData->useLowerBandRes, st_ivas->hSpar->enc_param_start_band, 0 ); } st_ivas->sba_dirac_stereo_flag = ivas_get_sba_dirac_stereo_flag( st_ivas ); - FOR ( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ ) + for ( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ ) { - IF ( ( error = create_sce_dec( st_ivas, sce_id, ivas_total_brate / st_ivas->nchan_transport ) ) != IVAS_ERR_OK ) + if ( ( error = create_sce_dec( st_ivas, sce_id, ivas_total_brate / st_ivas->nchan_transport ) ) != IVAS_ERR_OK ) { return error; } @@ -2946,23 +3174,23 @@ ivas_error ivas_init_decoder( reset_indices_dec( st_ivas->hSCE[sce_id]->hCoreCoder[0] ); } - FOR ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) + for ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) { - IF ( ( error = create_cpe_dec( st_ivas, cpe_id, ( ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS ) ) != IVAS_ERR_OK ) + if ( ( error = create_cpe_dec( st_ivas, cpe_id, ( ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS ) ) != IVAS_ERR_OK ) { return error; } - FOR ( n = 0; n < CPE_CHANNELS; n++ ) + for ( n = 0; n < CPE_CHANNELS; n++ ) { reset_indices_dec( st_ivas->hCPE[cpe_id]->hCoreCoder[n] ); } } /* create CPE element for DFT Stereo like upmix */ - IF ( st_ivas->sba_dirac_stereo_flag && st_ivas->nCPE == 0 ) + if ( st_ivas->sba_dirac_stereo_flag && st_ivas->nCPE == 0 ) { - IF ( ( error = create_cpe_dec( st_ivas, cpe_id, ivas_total_brate / ( st_ivas->nSCE + st_ivas->nCPE ) ) ) != IVAS_ERR_OK ) + if ( ( error = create_cpe_dec( st_ivas, cpe_id, ivas_total_brate / ( st_ivas->nSCE + st_ivas->nCPE ) ) ) != IVAS_ERR_OK ) { return error; } @@ -2971,9 +3199,9 @@ ivas_error ivas_init_decoder( st_ivas->hCPE[0]->hCoreCoder[1] = NULL; } - IF ( st_ivas->nCPE > 1 ) + if ( st_ivas->nCPE > 1 ) { - IF ( ( error = create_mct_dec( st_ivas ) ) != IVAS_ERR_OK ) + if ( ( error = create_mct_dec( st_ivas ) ) != IVAS_ERR_OK ) { return error; } @@ -2982,32 +3210,32 @@ ivas_error ivas_init_decoder( /* set CNA/CNG flags */ ivas_sba_set_cna_cng_flag( st_ivas ); } - ELSE IF ( st_ivas->ivas_format == MASA_FORMAT ) + else if ( st_ivas->ivas_format == MASA_FORMAT ) { /* if we start in ISM_MODE_NONE in MASA_ISM, that appears as normal MASA, but we may change to a mode with ISMs */ st_ivas->ism_extmeta_active = -1; st_ivas->ism_extmeta_cnt = 0; - IF ( ( error = ivas_qmetadata_open( &( st_ivas->hQMetaData ) ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_qmetadata_open( &( st_ivas->hQMetaData ) ) ) != IVAS_ERR_OK ) { return error; } - IF ( ( error = ivas_masa_dec_open( st_ivas ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_masa_dec_open( st_ivas ) ) != IVAS_ERR_OK ) { return error; } - IF ( st_ivas->renderer_type == RENDERER_DIRAC || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) + if ( st_ivas->renderer_type == RENDERER_DIRAC || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) { - IF ( ( error = ivas_dirac_dec_config( st_ivas, DIRAC_OPEN ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_dirac_dec_config( st_ivas, DIRAC_OPEN ) ) != IVAS_ERR_OK ) { return error; } } - FOR ( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ ) + for ( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ ) { - IF ( ( error = create_sce_dec( st_ivas, sce_id, ivas_total_brate / st_ivas->nchan_transport ) ) != IVAS_ERR_OK ) + if ( ( error = create_sce_dec( st_ivas, sce_id, ivas_total_brate / st_ivas->nchan_transport ) ) != IVAS_ERR_OK ) { return error; } @@ -3015,14 +3243,14 @@ ivas_error ivas_init_decoder( reset_indices_dec( st_ivas->hSCE[sce_id]->hCoreCoder[0] ); } - FOR ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) + for ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) { - IF ( ( error = create_cpe_dec( st_ivas, cpe_id, ( ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS ) ) != IVAS_ERR_OK ) + if ( ( error = create_cpe_dec( st_ivas, cpe_id, ( ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS ) ) != IVAS_ERR_OK ) { return error; } - FOR ( n = 0; n < CPE_CHANNELS; n++ ) + for ( n = 0; n < CPE_CHANNELS; n++ ) { reset_indices_dec( st_ivas->hCPE[cpe_id]->hCoreCoder[n] ); } @@ -3031,66 +3259,69 @@ ivas_error ivas_init_decoder( /* set CNA/CNG flags */ ivas_sba_set_cna_cng_flag( st_ivas ); } - ELSE IF ( st_ivas->ivas_format == SBA_ISM_FORMAT ) + else if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) { - Word32 temp_brate[MAX_SCE]; + int32_t temp_brate[MAX_SCE]; st_ivas->ism_extmeta_active = -1; st_ivas->ism_extmeta_cnt = 0; st_ivas->sba_dirac_stereo_flag = ivas_get_sba_dirac_stereo_flag( st_ivas ); - IF ( ( error = ivas_qmetadata_open( &( st_ivas->hQMetaData ) ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_qmetadata_open( &( st_ivas->hQMetaData ) ) ) != IVAS_ERR_OK ) { return error; } - IF ( ( error = ivas_spar_dec_open( st_ivas, 0 ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_spar_dec_open( st_ivas, 0 ) ) != IVAS_ERR_OK ) { return error; } - IF ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_DEC && st_ivas->hOutSetup.is_loudspeaker_setup ) + if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_DEC && st_ivas->hOutSetup.is_loudspeaker_setup ) { - IF ( ( error = ivas_sba_get_hoa_dec_matrix( st_ivas->hOutSetup, &st_ivas->hoa_dec_mtx, st_ivas->hIntSetup.ambisonics_order ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_sba_get_hoa_dec_matrix( st_ivas->hOutSetup, &st_ivas->hoa_dec_mtx, st_ivas->hIntSetup.ambisonics_order ) ) != IVAS_ERR_OK ) { return error; } } - IF ( ( error = ivas_dirac_sba_config( st_ivas->hQMetaData, &st_ivas->element_mode_init, ivas_total_brate, st_ivas->sba_analysis_order, ivas_get_hodirac_flag( ivas_total_brate, st_ivas->sba_analysis_order ) ? IVAS_MAX_NUM_BANDS : ( IVAS_MAX_NUM_BANDS - SPAR_DIRAC_SPLIT_START_BAND ), st_ivas->ivas_format ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_dirac_sba_config( st_ivas->hQMetaData, &st_ivas->element_mode_init, ivas_total_brate, st_ivas->sba_analysis_order, ivas_get_hodirac_flag( ivas_total_brate, st_ivas->sba_analysis_order ) ? IVAS_MAX_NUM_BANDS : ( IVAS_MAX_NUM_BANDS - SPAR_DIRAC_SPLIT_START_BAND ) + , + st_ivas->ivas_format + ) ) != IVAS_ERR_OK ) { return error; } - IF ( hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_FOA && st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_STEREO && st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_MONO ) + if ( hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_FOA && st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_STEREO && st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_MONO ) { - IF ( ( error = ivas_dirac_dec_config( st_ivas, DIRAC_OPEN ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_dirac_dec_config( st_ivas, DIRAC_OPEN ) ) != IVAS_ERR_OK ) { return error; } st_ivas->hSpar->enc_param_start_band = st_ivas->hDirAC->hConfig->enc_param_start_band; } - ELSE + else { - Word16 band_grouping[IVAS_MAX_NUM_BANDS + 1]; + int16_t band_grouping[IVAS_MAX_NUM_BANDS + 1]; st_ivas->hSpar->enc_param_start_band = min( IVAS_MAX_NUM_BANDS, SPAR_DIRAC_SPLIT_START_BAND ); - IF ( ivas_get_hodirac_flag( ivas_total_brate, st_ivas->sba_analysis_order ) ) + if ( ivas_get_hodirac_flag( ivas_total_brate, st_ivas->sba_analysis_order ) ) { st_ivas->hSpar->enc_param_start_band = 0; - set_c( (Word8 *) st_ivas->hQMetaData->twoDirBands, (Word8) 1, st_ivas->hQMetaData->q_direction[0].cfg.nbands ); - st_ivas->hQMetaData->numTwoDirBands = (UWord8) st_ivas->hQMetaData->q_direction[0].cfg.nbands; + set_c( (int8_t *) st_ivas->hQMetaData->twoDirBands, (int8_t) 1, st_ivas->hQMetaData->q_direction[0].cfg.nbands ); + st_ivas->hQMetaData->numTwoDirBands = (uint8_t) st_ivas->hQMetaData->q_direction[0].cfg.nbands; } - ivas_dirac_config_bands( band_grouping, IVAS_MAX_NUM_BANDS, (Word16) ( st_ivas->hDecoderConfig->output_Fs * INV_CLDFB_BANDWIDTH + 0.5f ), + ivas_dirac_config_bands( band_grouping, IVAS_MAX_NUM_BANDS, (int16_t) ( st_ivas->hDecoderConfig->output_Fs * INV_CLDFB_BANDWIDTH + 0.5f ), st_ivas->hSpar->dirac_to_spar_md_bands, st_ivas->hQMetaData->useLowerBandRes, st_ivas->hSpar->enc_param_start_band, 0 ); } - FOR ( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ ) + for ( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ ) { - IF ( ( error = create_sce_dec( st_ivas, sce_id, ivas_total_brate / st_ivas->nchan_transport ) ) != IVAS_ERR_OK ) + if ( ( error = create_sce_dec( st_ivas, sce_id, ivas_total_brate / st_ivas->nchan_transport ) ) != IVAS_ERR_OK ) { return error; } @@ -3098,29 +3329,29 @@ ivas_error ivas_init_decoder( reset_indices_dec( st_ivas->hSCE[sce_id]->hCoreCoder[0] ); } - IF ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { st_ivas->nCPE += ( st_ivas->nchan_ism + 1 ) >> 1; st_ivas->element_mode_init = IVAS_CPE_MDCT; } - FOR ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) + for ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) { - IF ( ( error = create_cpe_dec( st_ivas, cpe_id, ( ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS ) ) != IVAS_ERR_OK ) + if ( ( error = create_cpe_dec( st_ivas, cpe_id, ( ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS ) ) != IVAS_ERR_OK ) { return error; } - FOR ( n = 0; n < CPE_CHANNELS; n++ ) + for ( n = 0; n < CPE_CHANNELS; n++ ) { reset_indices_dec( st_ivas->hCPE[cpe_id]->hCoreCoder[n] ); } } /* create CPE element for DFT Stereo like upmix */ - IF ( st_ivas->sba_dirac_stereo_flag && st_ivas->nCPE == 0 ) + if ( st_ivas->sba_dirac_stereo_flag && st_ivas->nCPE == 0 ) { - IF ( ( error = create_cpe_dec( st_ivas, cpe_id, ivas_total_brate / ( st_ivas->nSCE + st_ivas->nCPE ) ) ) != IVAS_ERR_OK ) + if ( ( error = create_cpe_dec( st_ivas, cpe_id, ivas_total_brate / ( st_ivas->nSCE + st_ivas->nCPE ) ) ) != IVAS_ERR_OK ) { return error; } @@ -3129,22 +3360,22 @@ ivas_error ivas_init_decoder( st_ivas->hCPE[0]->hCoreCoder[1] = NULL; } - IF ( st_ivas->nCPE > 1 ) + if ( st_ivas->nCPE > 1 ) { - IF ( ( error = create_mct_dec( st_ivas ) ) != IVAS_ERR_OK ) + if ( ( error = create_mct_dec( st_ivas ) ) != IVAS_ERR_OK ) { return error; } } - IF ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { - IF ( ( error = ivas_ism_metadata_dec_create( st_ivas, st_ivas->nchan_ism, temp_brate ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_ism_metadata_dec_create( st_ivas, st_ivas->nchan_ism, temp_brate ) ) != IVAS_ERR_OK ) { return error; } - IF ( ( error = ivas_osba_data_open( st_ivas ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_osba_data_open( st_ivas ) ) != IVAS_ERR_OK ) { return error; } @@ -3153,52 +3384,52 @@ ivas_error ivas_init_decoder( /* set CNA/CNG flags */ ivas_sba_set_cna_cng_flag( st_ivas ); } - ELSE IF ( st_ivas->ivas_format == MASA_ISM_FORMAT ) + else if ( st_ivas->ivas_format == MASA_ISM_FORMAT ) { st_ivas->ism_extmeta_active = -1; st_ivas->ism_extmeta_cnt = 0; - IF ( ( error = ivas_qmetadata_open( &( st_ivas->hQMetaData ) ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_qmetadata_open( &( st_ivas->hQMetaData ) ) ) != IVAS_ERR_OK ) { return error; } k = 0; ism_total_brate = 0; - WHILE ( LT_16(k, SIZE_IVAS_BRATE_TBL) && NE_32(ivas_total_brate, ivas_brate_tbl[k] )) + while ( k < SIZE_IVAS_BRATE_TBL && ivas_total_brate != ivas_brate_tbl[k] ) { k++; } - IF ( st_ivas->ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ || st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ ) + if ( st_ivas->ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ || st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ ) { /* one separated object */ st_ivas->nSCE = 1; ism_total_brate = sep_object_brate[k - 2][0]; - IF ( ( error = create_sce_dec( st_ivas, 0, ism_total_brate ) ) != IVAS_ERR_OK ) + if ( ( error = create_sce_dec( st_ivas, 0, ism_total_brate ) ) != IVAS_ERR_OK ) { return error; } reset_indices_dec( st_ivas->hSCE[0]->hCoreCoder[0] ); - IF ( ( error = ivas_ism_metadata_dec_create( st_ivas, 1, NULL ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_ism_metadata_dec_create( st_ivas, 1, NULL ) ) != IVAS_ERR_OK ) { return error; } } - ELSE IF ( st_ivas->ism_mode == ISM_MASA_MODE_DISC ) + else if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC ) { - Word32 temp_brate[MAX_SCE]; + int32_t temp_brate[MAX_SCE]; st_ivas->nSCE = st_ivas->nchan_ism; /* number of objects */ - FOR ( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ ) + for ( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ ) { temp_brate[sce_id] = sep_object_brate[k - 2][st_ivas->nSCE - 1]; ism_total_brate += temp_brate[sce_id]; - IF ( ( error = create_sce_dec( st_ivas, sce_id, temp_brate[sce_id] ) ) != IVAS_ERR_OK ) + if ( ( error = create_sce_dec( st_ivas, sce_id, temp_brate[sce_id] ) ) != IVAS_ERR_OK ) { return error; } @@ -3206,48 +3437,48 @@ ivas_error ivas_init_decoder( reset_indices_dec( st_ivas->hSCE[sce_id]->hCoreCoder[0] ); } - IF ( ( error = ivas_ism_metadata_dec_create( st_ivas, st_ivas->nchan_ism, temp_brate ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_ism_metadata_dec_create( st_ivas, st_ivas->nchan_ism, temp_brate ) ) != IVAS_ERR_OK ) { return error; } } - IF ( ( error = ivas_masa_dec_open( st_ivas ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_masa_dec_open( st_ivas ) ) != IVAS_ERR_OK ) { return error; } - IF ( ( error = ivas_omasa_data_open( st_ivas ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_omasa_data_open( st_ivas ) ) != IVAS_ERR_OK ) { return error; } - IF ( st_ivas->renderer_type == RENDERER_DIRAC || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) + if ( st_ivas->renderer_type == RENDERER_DIRAC || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) { - IF ( ( error = ivas_dirac_dec_config( st_ivas, DIRAC_OPEN ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_dirac_dec_config( st_ivas, DIRAC_OPEN ) ) != IVAS_ERR_OK ) { return error; } } - IF ( ( error = create_cpe_dec( st_ivas, 0, ivas_total_brate - ism_total_brate ) ) != IVAS_ERR_OK ) + if ( ( error = create_cpe_dec( st_ivas, 0, ivas_total_brate - ism_total_brate ) ) != IVAS_ERR_OK ) { return error; } - FOR ( n = 0; n < CPE_CHANNELS; n++ ) + for ( n = 0; n < CPE_CHANNELS; n++ ) { reset_indices_dec( st_ivas->hCPE[0]->hCoreCoder[n] ); } } - ELSE IF ( st_ivas->ivas_format == MC_FORMAT ) + else if ( st_ivas->ivas_format == MC_FORMAT ) { - IF ( st_ivas->mc_mode == MC_MODE_MCT ) + if ( st_ivas->mc_mode == MC_MODE_MCT ) { /* init EFAP for custom LS setup */ - IF ( output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM ) + if ( output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM ) { - IF ( ( error = efap_init_data( &( st_ivas->hEFAPdata ), st_ivas->hLsSetupCustom->ls_azimuth, st_ivas->hLsSetupCustom->ls_elevation, st_ivas->hLsSetupCustom->num_spk, EFAP_MODE_EFAP ) ) != IVAS_ERR_OK ) + if ( ( error = efap_init_data( &( st_ivas->hEFAPdata ), st_ivas->hLsSetupCustom->ls_azimuth, st_ivas->hLsSetupCustom->ls_elevation, st_ivas->hLsSetupCustom->num_spk, EFAP_MODE_EFAP ) ) != IVAS_ERR_OK ) { return error; } @@ -3259,30 +3490,30 @@ ivas_error ivas_init_decoder( st_ivas->element_mode_init = IVAS_CPE_MDCT; - FOR ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) + for ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) { - IF ( ( error = create_cpe_dec( st_ivas, cpe_id, ( ivas_total_brate / ( st_ivas->nchan_transport - 1 ) * CPE_CHANNELS ) ) ) != IVAS_ERR_OK ) + if ( ( error = create_cpe_dec( st_ivas, cpe_id, ( ivas_total_brate / ( st_ivas->nchan_transport - 1 ) * CPE_CHANNELS ) ) ) != IVAS_ERR_OK ) { return error; } - FOR ( n = 0; n < CPE_CHANNELS; n++ ) + for ( n = 0; n < CPE_CHANNELS; n++ ) { reset_indices_dec( st_ivas->hCPE[cpe_id]->hCoreCoder[n] ); } } - IF ( ( error = create_mct_dec( st_ivas ) ) != IVAS_ERR_OK ) + if ( ( error = create_mct_dec( st_ivas ) ) != IVAS_ERR_OK ) { return error; } } - ELSE IF ( st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) + else if ( st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) { /* init EFAP for custom LS setup */ - IF ( output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM ) + if ( output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM ) { - IF ( ( error = efap_init_data( &( st_ivas->hEFAPdata ), st_ivas->hLsSetupCustom->ls_azimuth, st_ivas->hLsSetupCustom->ls_elevation, st_ivas->hLsSetupCustom->num_spk, EFAP_MODE_EFAP ) ) != IVAS_ERR_OK ) + if ( ( error = efap_init_data( &( st_ivas->hEFAPdata ), st_ivas->hLsSetupCustom->ls_azimuth, st_ivas->hLsSetupCustom->ls_elevation, st_ivas->hLsSetupCustom->num_spk, EFAP_MODE_EFAP ) ) != IVAS_ERR_OK ) { return error; } @@ -3292,103 +3523,103 @@ ivas_error ivas_init_decoder( st_ivas->nCPE = MC_PARAMUPMIX_MAX_TRANSPORT_CHANS / CPE_CHANNELS; st_ivas->nchan_transport = MC_PARAMUPMIX_MAX_TRANSPORT_CHANS; - IF ( ( error = ivas_mc_paramupmix_dec_open( st_ivas ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_mc_paramupmix_dec_open( st_ivas ) ) != IVAS_ERR_OK ) { return error; } st_ivas->element_mode_init = IVAS_CPE_MDCT; - FOR ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) + for ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) { - IF ( ( error = create_cpe_dec( st_ivas, cpe_id, ( ivas_total_brate / ( st_ivas->nchan_transport - 1 ) * CPE_CHANNELS ) ) ) != IVAS_ERR_OK ) + if ( ( error = create_cpe_dec( st_ivas, cpe_id, ( ivas_total_brate / ( st_ivas->nchan_transport - 1 ) * CPE_CHANNELS ) ) ) != IVAS_ERR_OK ) { return error; } - FOR ( n = 0; n < CPE_CHANNELS; n++ ) + for ( n = 0; n < CPE_CHANNELS; n++ ) { reset_indices_dec( st_ivas->hCPE[cpe_id]->hCoreCoder[n] ); } } - IF ( ( error = create_mct_dec( st_ivas ) ) != IVAS_ERR_OK ) + if ( ( error = create_mct_dec( st_ivas ) ) != IVAS_ERR_OK ) { return error; } } - ELSE IF ( st_ivas->mc_mode == MC_MODE_PARAMMC ) + else if ( st_ivas->mc_mode == MC_MODE_PARAMMC ) { /* init EFAP for custom LS setup */ - IF ( output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM ) + if ( output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM ) { - IF ( ( error = efap_init_data( &( st_ivas->hEFAPdata ), st_ivas->hLsSetupCustom->ls_azimuth, st_ivas->hLsSetupCustom->ls_elevation, st_ivas->hLsSetupCustom->num_spk, EFAP_MODE_EFAP ) ) != IVAS_ERR_OK ) + if ( ( error = efap_init_data( &( st_ivas->hEFAPdata ), st_ivas->hLsSetupCustom->ls_azimuth, st_ivas->hLsSetupCustom->ls_elevation, st_ivas->hLsSetupCustom->num_spk, EFAP_MODE_EFAP ) ) != IVAS_ERR_OK ) { return error; } } - IF ( ( error = ivas_param_mc_dec_open( st_ivas ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_param_mc_dec_open( st_ivas ) ) != IVAS_ERR_OK ) { return error; } - FOR ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) + for ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) { - IF ( ( error = create_cpe_dec( st_ivas, cpe_id, ivas_total_brate / ( st_ivas->nSCE + st_ivas->nCPE ) ) ) != IVAS_ERR_OK ) + if ( ( error = create_cpe_dec( st_ivas, cpe_id, ivas_total_brate / ( st_ivas->nSCE + st_ivas->nCPE ) ) ) != IVAS_ERR_OK ) { return error; } - FOR ( n = 0; n < CPE_CHANNELS; n++ ) + for ( n = 0; n < CPE_CHANNELS; n++ ) { reset_indices_dec( st_ivas->hCPE[cpe_id]->hCoreCoder[n] ); } } - IF ( GT_16(st_ivas->nCPE, 1 )) + if ( st_ivas->nCPE > 1 ) { - IF ( ( error = create_mct_dec( st_ivas ) ) != IVAS_ERR_OK ) + if ( ( error = create_mct_dec( st_ivas ) ) != IVAS_ERR_OK ) { return error; } } } - ELSE IF ( st_ivas->mc_mode == MC_MODE_MCMASA ) + else if ( st_ivas->mc_mode == MC_MODE_MCMASA ) { - Word32 brate_sce, brate_cpe; + int32_t brate_sce, brate_cpe; ivas_mcmasa_setNumTransportChannels( &( st_ivas->nchan_transport ), &( st_ivas->element_mode_init ), ivas_total_brate ); - IF ( ( error = ivas_qmetadata_open( &( st_ivas->hQMetaData ) ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_qmetadata_open( &( st_ivas->hQMetaData ) ) ) != IVAS_ERR_OK ) { return error; } - IF ( ( error = ivas_masa_dec_open( st_ivas ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_masa_dec_open( st_ivas ) ) != IVAS_ERR_OK ) { return error; } st_ivas->sba_dirac_stereo_flag = ivas_get_sba_dirac_stereo_flag( st_ivas ); - IF ( st_ivas->renderer_type != RENDERER_DISABLE && st_ivas->renderer_type != RENDERER_MCMASA_MONO_STEREO ) + if ( st_ivas->renderer_type != RENDERER_DISABLE && st_ivas->renderer_type != RENDERER_MCMASA_MONO_STEREO ) { - IF ( ( error = ivas_dirac_dec_config( st_ivas, DIRAC_OPEN ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_dirac_dec_config( st_ivas, DIRAC_OPEN ) ) != IVAS_ERR_OK ) { return error; } } - IF ( st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM && st_ivas->hOutSetup.separateChannelEnabled && !st_ivas->hLsSetupCustom->separate_ch_found ) + if ( st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM && st_ivas->hOutSetup.separateChannelEnabled && !st_ivas->hLsSetupCustom->separate_ch_found ) { /* If no speaker matching the separated channel, compute panning gains for the separated channel. */ - IF ( st_ivas->hVBAPdata == NULL ) + if ( st_ivas->hVBAPdata == NULL ) { /* Distribute signal to all channels if VBAP is not properly initialized. */ set_f( st_ivas->hLsSetupCustom->separate_ch_gains, inv_sqrt( st_ivas->hLsSetupCustom->num_spk ), st_ivas->hLsSetupCustom->num_spk ); } - ELSE + else { vbap_determine_gains( st_ivas->hVBAPdata, st_ivas->hLsSetupCustom->separate_ch_gains, 0, 0, 0 ); } @@ -3396,9 +3627,9 @@ ivas_error ivas_init_decoder( ivas_mcmasa_split_brate( st_ivas->hOutSetup.separateChannelEnabled, ivas_total_brate, st_ivas->nSCE, st_ivas->nCPE, &brate_sce, &brate_cpe ); - FOR ( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ ) + for ( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ ) { - IF ( ( error = create_sce_dec( st_ivas, sce_id, brate_sce ) ) != IVAS_ERR_OK ) + if ( ( error = create_sce_dec( st_ivas, sce_id, brate_sce ) ) != IVAS_ERR_OK ) { return error; } @@ -3406,25 +3637,25 @@ ivas_error ivas_init_decoder( reset_indices_dec( st_ivas->hSCE[sce_id]->hCoreCoder[0] ); } - FOR ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) + for ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) { st_ivas->element_mode_init = IVAS_CPE_MDCT; /* element_mode_init was IVAS_SCE for SCE initialization */ - IF ( ( error = create_cpe_dec( st_ivas, cpe_id, brate_cpe ) ) != IVAS_ERR_OK ) + if ( ( error = create_cpe_dec( st_ivas, cpe_id, brate_cpe ) ) != IVAS_ERR_OK ) { return error; } - FOR ( n = 0; n < CPE_CHANNELS; n++ ) + for ( n = 0; n < CPE_CHANNELS; n++ ) { reset_indices_dec( st_ivas->hCPE[cpe_id]->hCoreCoder[n] ); } } /* create CPE element for DFT Stereo like upmix */ - IF ( st_ivas->sba_dirac_stereo_flag ) + if ( st_ivas->sba_dirac_stereo_flag ) { - IF ( ( error = create_cpe_dec( st_ivas, cpe_id, ivas_total_brate / ( st_ivas->nSCE + st_ivas->nCPE ) ) ) != IVAS_ERR_OK ) + if ( ( error = create_cpe_dec( st_ivas, cpe_id, ivas_total_brate / ( st_ivas->nSCE + st_ivas->nCPE ) ) ) != IVAS_ERR_OK ) { return error; } @@ -3434,7 +3665,7 @@ ivas_error ivas_init_decoder( } /* set CNA/CNG flags */ - IF ( EQ_16(st_ivas->nchan_transport, 1) && ( ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) ) + if ( st_ivas->nchan_transport == 1 && ( ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) ) { st_ivas->hSCE[0]->hCoreCoder[0]->cna_dirac_flag = 1; st_ivas->hSCE[0]->hCoreCoder[0]->cng_sba_flag = 1; @@ -3450,21 +3681,21 @@ ivas_error ivas_init_decoder( /* set number of output channels used for synthesis/decoding */ n = getNumChanSynthesis( st_ivas ); - IF ( GT_16(n, 0 )) + if ( n > 0 ) { - IF ( ( st_ivas->mem_hp20_out = (float **) malloc( n * sizeof( float * ) ) ) == NULL ) + if ( ( st_ivas->mem_hp20_out = (float **) malloc( n * sizeof( float * ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HP20 filter memory\n" ) ); } } - ELSE + else { st_ivas->mem_hp20_out = NULL; } - FOR ( i = 0; i < n; i++ ) + for ( i = 0; i < n; i++ ) { - IF ( ( st_ivas->mem_hp20_out[i] = (float *) malloc( L_HP20_MEM * sizeof( float ) ) ) == NULL ) + if ( ( st_ivas->mem_hp20_out[i] = (float *) malloc( L_HP20_MEM * sizeof( float ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HP20 filter memory\n" ) ); } @@ -3476,41 +3707,41 @@ ivas_error ivas_init_decoder( * Allocate and initialize rendering handles *--------------------------------------------------------------------*/ - IF ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) + if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) { - IF ( ( error = ivas_binRenderer_open( st_ivas ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_binRenderer_open( st_ivas ) ) != IVAS_ERR_OK ) { return error; } } /* ParamISM is handled separately from other common config */ - ELSE IF ( st_ivas->ivas_format == ISM_FORMAT && st_ivas->ism_mode == ISM_MODE_PARAM && ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) ) + else if ( st_ivas->ivas_format == ISM_FORMAT && st_ivas->ism_mode == ISM_MODE_PARAM && ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) ) { - IF ( st_ivas->renderer_type != RENDERER_STEREO_PARAMETRIC ) + if ( st_ivas->renderer_type != RENDERER_STEREO_PARAMETRIC ) { - IF ( ( error = ivas_dirac_dec_binaural_copy_hrtfs( &st_ivas->hHrtfParambin ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_dirac_dec_binaural_copy_hrtfs( &st_ivas->hHrtfParambin ) ) != IVAS_ERR_OK ) { return error; } } - IF ( ( error = ivas_dirac_dec_init_binaural_data( st_ivas, st_ivas->hHrtfParambin ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_dirac_dec_init_binaural_data( st_ivas, st_ivas->hHrtfParambin ) ) != IVAS_ERR_OK ) { return error; } } - ELSE IF ( st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD ) + else if ( st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD ) { - IF ( ( error = ivas_td_binaural_open( st_ivas ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_td_binaural_open( st_ivas ) ) != IVAS_ERR_OK ) { return error; } - IF ( st_ivas->hIntSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) + if ( st_ivas->hIntSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) { - IF ( ( error = ivas_reverb_open( &st_ivas->hReverb, st_ivas->hDecoderConfig->output_config, NULL, st_ivas->hBinRendererTd->HrFiltSet_p->lr_energy_and_iac, st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_reverb_open( &st_ivas->hReverb, st_ivas->hDecoderConfig->output_config, NULL, st_ivas->hBinRendererTd->HrFiltSet_p->lr_energy_and_iac, st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) { return error; } @@ -3519,36 +3750,36 @@ ivas_error ivas_init_decoder( granularity = NS2SA( st_ivas->hDecoderConfig->output_Fs, FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ); n_channels_transport_jbm = ivas_jbm_dec_get_num_tc_channels( st_ivas ); - IF ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, TC_BUFFER_MODE_RENDERER, n_channels_transport_jbm, n_channels_transport_jbm, n_channels_transport_jbm, granularity ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, TC_BUFFER_MODE_RENDERER, n_channels_transport_jbm, n_channels_transport_jbm, n_channels_transport_jbm, granularity ) ) != IVAS_ERR_OK ) { return error; } } - ELSE IF ( st_ivas->renderer_type == RENDERER_MC ) + else if ( st_ivas->renderer_type == RENDERER_MC ) { - IF ( ( error = ivas_ls_setup_conversion_open( st_ivas ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_ls_setup_conversion_open( st_ivas ) ) != IVAS_ERR_OK ) { return error; } } - ELSE IF ( st_ivas->renderer_type == RENDERER_MONO_DOWNMIX ) + else if ( st_ivas->renderer_type == RENDERER_MONO_DOWNMIX ) { - IF ( ( error = ivas_mono_dmx_renderer_open( st_ivas ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_mono_dmx_renderer_open( st_ivas ) ) != IVAS_ERR_OK ) { return error; } } - ELSE IF ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) + else if ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) { - IF ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM && st_ivas->ivas_format == MC_FORMAT && ( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation ) ) + if ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM && st_ivas->ivas_format == MC_FORMAT && ( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation ) ) { - IF ( ( error = efap_init_data( &( st_ivas->hEFAPdata ), st_ivas->hIntSetup.ls_azimuth, st_ivas->hIntSetup.ls_elevation, st_ivas->hIntSetup.nchan_out_woLFE, EFAP_MODE_EFAP ) ) != IVAS_ERR_OK ) + if ( ( error = efap_init_data( &( st_ivas->hEFAPdata ), st_ivas->hIntSetup.ls_azimuth, st_ivas->hIntSetup.ls_elevation, st_ivas->hIntSetup.nchan_out_woLFE, EFAP_MODE_EFAP ) ) != IVAS_ERR_OK ) { return error; } } - IF ( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, + if ( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) { return error; @@ -3556,58 +3787,58 @@ ivas_error ivas_init_decoder( st_ivas->binaural_latency_ns = st_ivas->hCrendWrapper->binaural_latency_ns; - IF ( ( st_ivas->ivas_format == MC_FORMAT ) && ( st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) ) + if ( ( st_ivas->ivas_format == MC_FORMAT ) && ( st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) ) { granularity = NS2SA( output_Fs, CLDFB_SLOT_NS ); n_channels_transport_jbm = ivas_jbm_dec_get_num_tc_channels( st_ivas ); - IF ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, TC_BUFFER_MODE_RENDERER, n_channels_transport_jbm, MC_PARAMUPMIX_MAX_INPUT_CHANS, MC_PARAMUPMIX_MAX_INPUT_CHANS, granularity ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, TC_BUFFER_MODE_RENDERER, n_channels_transport_jbm, MC_PARAMUPMIX_MAX_INPUT_CHANS, MC_PARAMUPMIX_MAX_INPUT_CHANS, granularity ) ) != IVAS_ERR_OK ) { return error; } } - ELSE + else { granularity = NS2SA( st_ivas->hDecoderConfig->output_Fs, FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ); n_channels_transport_jbm = ivas_jbm_dec_get_num_tc_channels( st_ivas ); - IF ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, TC_BUFFER_MODE_RENDERER, n_channels_transport_jbm, n_channels_transport_jbm, n_channels_transport_jbm, granularity ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, TC_BUFFER_MODE_RENDERER, n_channels_transport_jbm, n_channels_transport_jbm, n_channels_transport_jbm, granularity ) ) != IVAS_ERR_OK ) { return error; } } } - IF ( st_ivas->ivas_format == MASA_ISM_FORMAT ) + if ( st_ivas->ivas_format == MASA_ISM_FORMAT ) { - IF ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) + if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) { /* Allocate TD renderer for the objects in DISC mode */ - IF ( ( error = ivas_td_binaural_open( st_ivas ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_td_binaural_open( st_ivas ) ) != IVAS_ERR_OK ) { return error; } /* Allocate 'hIsmRendererData' handle and memory for delay buffer within 'hMasaIsmData' */ - IF ( ( error = ivas_omasa_separate_object_renderer_open( st_ivas ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_omasa_separate_object_renderer_open( st_ivas ) ) != IVAS_ERR_OK ) { return error; } } - IF ( st_ivas->renderer_type == RENDERER_DIRAC && ( st_ivas->ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ || st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ || st_ivas->ism_mode == ISM_MASA_MODE_DISC ) ) + if ( st_ivas->renderer_type == RENDERER_DIRAC && ( st_ivas->ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ || st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ || st_ivas->ism_mode == ISM_MASA_MODE_DISC ) ) { /* Allocate 'hIsmRendererData' handle and memory for delay buffer within 'hMasaIsmData' */ - IF ( ( error = ivas_omasa_separate_object_renderer_open( st_ivas ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_omasa_separate_object_renderer_open( st_ivas ) ) != IVAS_ERR_OK ) { return error; } } } - IF ( ( st_ivas->ivas_format == ISM_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) && + if ( ( st_ivas->ivas_format == ISM_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) && ( st_ivas->ism_mode == ISM_MODE_DISC || st_ivas->ism_mode == ISM_SBA_MODE_DISC ) && ( st_ivas->renderer_type == RENDERER_TD_PANNING || st_ivas->renderer_type == RENDERER_NON_DIEGETIC_DOWNMIX || @@ -3619,18 +3850,18 @@ ivas_error ivas_init_decoder( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) ) { - IF ( ( error = ivas_ism_renderer_open( st_ivas ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_ism_renderer_open( st_ivas ) ) != IVAS_ERR_OK ) { return error; } } - IF ( st_ivas->ivas_format == SBA_ISM_FORMAT ) + if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) { - IF ( ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ) && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + if ( ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ) && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { /* Allocate TD renderer for the objects in DISC mode */ - IF ( ( error = ivas_td_binaural_open( st_ivas ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_td_binaural_open( st_ivas ) ) != IVAS_ERR_OK ) { return error; } @@ -3641,25 +3872,25 @@ ivas_error ivas_init_decoder( * LFE handles for rendering after rendering to adjust LFE delay to binaural filter delay *-----------------------------------------------------------------*/ - IF ( st_ivas->mc_mode == MC_MODE_MCT || st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) + if ( st_ivas->mc_mode == MC_MODE_MCT || st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) { binauralization_delay_ns = st_ivas->binaural_latency_ns; - IF ( st_ivas->hBinRenderer != NULL ) + if ( st_ivas->hBinRenderer != NULL ) { - IF ( st_ivas->hBinRenderer->render_lfe ) + if ( st_ivas->hBinRenderer->render_lfe ) { { /* Account for filterbank delay */ binauralization_delay_ns += IVAS_FB_DEC_DELAY_NS; } } - ELSE + else { binauralization_delay_ns = 0; } } - IF ( ( error = ivas_create_lfe_dec( &st_ivas->hLFE, output_Fs, binauralization_delay_ns ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_create_lfe_dec( &st_ivas->hLFE, output_Fs, binauralization_delay_ns ) ) != IVAS_ERR_OK ) { return error; } @@ -3674,32 +3905,32 @@ ivas_error ivas_init_decoder( ivas_init_dec_get_num_cldfb_instances( st_ivas, &numCldfbAnalyses, &numCldfbSyntheses ); - FOR ( i = 0; i < numCldfbAnalyses; i++ ) + for ( i = 0; i < numCldfbAnalyses; i++ ) { - IF ( ( error = openCldfb_ivas( &( st_ivas->cldfbAnaDec[i] ), CLDFB_ANALYSIS, output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) + if ( ( error = openCldfb( &( st_ivas->cldfbAnaDec[i] ), CLDFB_ANALYSIS, output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) { return error; } } - FOR ( ; i < MAX_INTERN_CHANNELS; i++ ) + for ( ; i < MAX_INTERN_CHANNELS; i++ ) { st_ivas->cldfbAnaDec[i] = NULL; } - FOR ( i = 0; i < numCldfbSyntheses; i++ ) + for ( i = 0; i < numCldfbSyntheses; i++ ) { - IF ( ( error = openCldfb_ivas( &( st_ivas->cldfbSynDec[i] ), CLDFB_SYNTHESIS, output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) + if ( ( error = openCldfb( &( st_ivas->cldfbSynDec[i] ), CLDFB_SYNTHESIS, output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) { return error; } } - FOR ( ; i < MAX_OUTPUT_CHANNELS; i++ ) + for ( ; i < MAX_OUTPUT_CHANNELS; i++ ) { st_ivas->cldfbSynDec[i] = NULL; } /* CLDFB Interpolation weights */ - IF ( ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) && !st_ivas->sba_dirac_stereo_flag && st_ivas->hDecoderConfig->nchan_out != 1 ) + if ( ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) && !st_ivas->sba_dirac_stereo_flag && st_ivas->hDecoderConfig->nchan_out != 1 ) { ivas_spar_get_cldfb_gains( st_ivas->hSpar, st_ivas->cldfbAnaDec[0], st_ivas->cldfbSynDec[0], hDecoderConfig ); } @@ -3708,7 +3939,7 @@ ivas_error ivas_init_decoder( * Allocate and initialize limiter struct *-----------------------------------------------------------------*/ - IF ( ( error = ivas_limiter_open( &st_ivas->hLimiter, hDecoderConfig->nchan_out, output_Fs ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_limiter_open( &st_ivas->hLimiter, hDecoderConfig->nchan_out, output_Fs ) ) != IVAS_ERR_OK ) { return error; } @@ -3717,32 +3948,32 @@ ivas_error ivas_init_decoder( * Allocate and initialize JBM struct + buffer *-----------------------------------------------------------------*/ - IF ( st_ivas->hTcBuffer == NULL ) + if ( st_ivas->hTcBuffer == NULL ) { /* no module has yet open the TC buffer, open a default one */ n_channels_transport_jbm = ivas_jbm_dec_get_num_tc_channels( st_ivas ); - IF ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, ivas_jbm_dec_get_tc_buffer_mode( st_ivas ), n_channels_transport_jbm, n_channels_transport_jbm, n_channels_transport_jbm, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, ivas_jbm_dec_get_tc_buffer_mode( st_ivas ), n_channels_transport_jbm, n_channels_transport_jbm, n_channels_transport_jbm, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK ) { return error; } } - IF ( st_ivas->hTcBuffer == NULL ) + if ( st_ivas->hTcBuffer == NULL ) { /* we need the handle anyway, but without the buffer*/ - IF ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, TC_BUFFER_MODE_NONE, 0, 0, 0, 1 ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, TC_BUFFER_MODE_NONE, 0, 0, 0, 1 ) ) != IVAS_ERR_OK ) { return error; } } - IF ( st_ivas->hJbmMetadata == NULL ) + if ( st_ivas->hJbmMetadata == NULL ) { - IF ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) + if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) { - IF ( ( error = ivas_jbm_dec_metadata_open( st_ivas ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_jbm_dec_metadata_open( st_ivas ) ) != IVAS_ERR_OK ) { return error; } @@ -3753,16 +3984,16 @@ ivas_error ivas_init_decoder( * Allocate floating-point output audio buffers *-----------------------------------------------------------------*/ - FOR ( n = 0; n < ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); n++ ) + for ( n = 0; n < ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); n++ ) { /* note: these are intra-frame heap memories */ - IF ( ( st_ivas->p_output_f[n] = (float *) malloc( ( 48000 / FRAMES_PER_SEC ) * sizeof( float ) ) ) == NULL ) + if ( ( st_ivas->p_output_f[n] = (float *) malloc( ( 48000 / FRAMES_PER_SEC ) * sizeof( float ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for floating-point output audio buffer!\n" ) ); } } - FOR ( ; n < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; n++ ) + for ( ; n < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; n++ ) { st_ivas->p_output_f[n] = NULL; } @@ -3770,6 +4001,7 @@ ivas_error ivas_init_decoder( return error; } + #endif /*------------------------------------------------------------------------- @@ -3777,12 +4009,20 @@ ivas_error ivas_init_decoder( * * Close core decoder handles *-------------------------------------------------------------------------*/ -#ifndef IVAS_FLOAT_FIXED -void destroy_core_dec( + +#ifdef IVAS_FLOAT_FIXED +void destroy_core_dec_fx( DEC_CORE_HANDLE hCoreCoder /* i/o: core decoder structure */ ) { - destroy_cldfb_decoder_flt( hCoreCoder ); + IF( EQ_16( hCoreCoder->element_mode, EVS_MONO ) ) + { + destroy_cldfb_decoder_fx( hCoreCoder ); + } + ELSE + { + destroy_cldfb_decoder_ivas_fx( hCoreCoder ); + } IF ( hCoreCoder->hGSCDec != NULL ) { @@ -3913,140 +4153,133 @@ void destroy_core_dec( return; } #else -void destroy_core_dec_fx( +void destroy_core_dec( DEC_CORE_HANDLE hCoreCoder /* i/o: core decoder structure */ ) { - IF( EQ_16( hCoreCoder->element_mode, EVS_MONO ) ) - { - destroy_cldfb_decoder_fx( hCoreCoder ); - } - ELSE - { - destroy_cldfb_decoder_ivas_fx( hCoreCoder ); - } + destroy_cldfb_decoder( hCoreCoder ); - IF ( hCoreCoder->hGSCDec != NULL ) + if ( hCoreCoder->hGSCDec != NULL ) { free( hCoreCoder->hGSCDec ); hCoreCoder->hGSCDec = NULL; } - IF ( hCoreCoder->hPFstat != NULL ) + if ( hCoreCoder->hPFstat != NULL ) { free( hCoreCoder->hPFstat ); hCoreCoder->hPFstat = NULL; } - IF ( hCoreCoder->hMusicPF != NULL ) + if ( hCoreCoder->hMusicPF != NULL ) { free( hCoreCoder->hMusicPF ); hCoreCoder->hMusicPF = NULL; } - IF ( hCoreCoder->hBPF != NULL ) + if ( hCoreCoder->hBPF != NULL ) { free( hCoreCoder->hBPF ); hCoreCoder->hBPF = NULL; } - IF ( hCoreCoder->hBWE_zero != NULL ) + if ( hCoreCoder->hBWE_zero != NULL ) { free( hCoreCoder->hBWE_zero ); hCoreCoder->hBWE_zero = NULL; } - IF ( hCoreCoder->hTdCngDec != NULL ) + if ( hCoreCoder->hTdCngDec != NULL ) { free( hCoreCoder->hTdCngDec ); hCoreCoder->hTdCngDec = NULL; } - IF ( hCoreCoder->hSC_VBR != NULL ) + if ( hCoreCoder->hSC_VBR != NULL ) { free( hCoreCoder->hSC_VBR ); hCoreCoder->hSC_VBR = NULL; } - IF ( hCoreCoder->hAmrwb_IO != NULL ) + if ( hCoreCoder->hAmrwb_IO != NULL ) { free( hCoreCoder->hAmrwb_IO ); hCoreCoder->hAmrwb_IO = NULL; } - IF ( hCoreCoder->hBWE_TD != NULL ) + if ( hCoreCoder->hBWE_TD != NULL ) { free( hCoreCoder->hBWE_TD ); hCoreCoder->hBWE_TD = NULL; } - IF ( hCoreCoder->hBWE_FD != NULL ) + if ( hCoreCoder->hBWE_FD != NULL ) { free( hCoreCoder->hBWE_FD ); hCoreCoder->hBWE_FD = NULL; } - IF ( hCoreCoder->hBWE_FD_HR != NULL ) + if ( hCoreCoder->hBWE_FD_HR != NULL ) { free( hCoreCoder->hBWE_FD_HR ); hCoreCoder->hBWE_FD_HR = NULL; } - IF ( hCoreCoder->hWIDec != NULL ) + if ( hCoreCoder->hWIDec != NULL ) { free( hCoreCoder->hWIDec ); hCoreCoder->hWIDec = NULL; } - IF ( hCoreCoder->hTECDec != NULL ) + if ( hCoreCoder->hTECDec != NULL ) { free( hCoreCoder->hTECDec ); hCoreCoder->hTECDec = NULL; } - IF ( hCoreCoder->hTcxLtpDec != NULL ) + if ( hCoreCoder->hTcxLtpDec != NULL ) { free( hCoreCoder->hTcxLtpDec ); hCoreCoder->hTcxLtpDec = NULL; } - IF ( hCoreCoder->hTcxDec != NULL ) + if ( hCoreCoder->hTcxDec != NULL ) { free( hCoreCoder->hTcxDec ); hCoreCoder->hTcxDec = NULL; } - IF ( hCoreCoder->hTcxCfg != NULL ) + if ( hCoreCoder->hTcxCfg != NULL ) { free( hCoreCoder->hTcxCfg ); hCoreCoder->hTcxCfg = NULL; } - IF ( hCoreCoder->hTonalMDCTConc != NULL ) + if ( hCoreCoder->hTonalMDCTConc != NULL ) { free( hCoreCoder->hTonalMDCTConc ); hCoreCoder->hTonalMDCTConc = NULL; } - IF ( hCoreCoder->hIGFDec != NULL ) + if ( hCoreCoder->hIGFDec != NULL ) { free( hCoreCoder->hIGFDec ); hCoreCoder->hIGFDec = NULL; } - IF ( hCoreCoder->hPlcInfo != NULL ) + if ( hCoreCoder->hPlcInfo != NULL ) { free( hCoreCoder->hPlcInfo ); hCoreCoder->hPlcInfo = NULL; } - IF ( hCoreCoder->hHQ_core != NULL ) + if ( hCoreCoder->hHQ_core != NULL ) { free( hCoreCoder->hHQ_core ); hCoreCoder->hHQ_core = NULL; } - IF ( hCoreCoder->hHQ_nbfec != NULL ) + if ( hCoreCoder->hHQ_nbfec != NULL ) { free( hCoreCoder->hHQ_nbfec ); hCoreCoder->hHQ_nbfec = NULL; @@ -4054,6 +4287,7 @@ void destroy_core_dec_fx( return; } + #endif /*------------------------------------------------------------------------- @@ -4061,7 +4295,8 @@ void destroy_core_dec_fx( * * NULL initialization of handles *-------------------------------------------------------------------------*/ -#ifndef IVAS_FLOAT_FIXED + +#ifdef IVAS_FLOAT_FIXED void ivas_initialize_handles_dec( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ) @@ -4091,7 +4326,7 @@ void ivas_initialize_handles_dec( } st_ivas->bit_stream = NULL; - st_ivas->mem_hp20_out = NULL; + st_ivas->mem_hp20_out_fx = NULL; st_ivas->hLimiter = NULL; /* ISM metadata handles */ @@ -4146,7 +4381,10 @@ void ivas_initialize_handles_dec( /* floating-point output audio buffers */ FOR ( i = 0; i < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; i++ ) { +#ifdef IVAS_FLOAT_FIXED_TO_BE_REMOVED st_ivas->p_output_f[i] = NULL; +#endif + st_ivas->p_output_fx[i] = NULL; } return; @@ -4156,36 +4394,49 @@ void ivas_initialize_handles_dec( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ) { - Word16 i; + int16_t i; - FOR ( i = 0; i < MAX_INTERN_CHANNELS; i++ ) + for ( i = 0; i < MAX_INTERN_CHANNELS; i++ ) { st_ivas->cldfbAnaDec[i] = NULL; } - FOR ( i = 0; i < MAX_OUTPUT_CHANNELS; i++ ) + for ( i = 0; i < MAX_OUTPUT_CHANNELS; i++ ) { st_ivas->cldfbSynDec[i] = NULL; } /* SCE handles */ - FOR ( i = 0; i < MAX_SCE; i++ ) + for ( i = 0; i < MAX_SCE; i++ ) { st_ivas->hSCE[i] = NULL; } /* CPE handles */ - FOR ( i = 0; i < MAX_CPE; i++ ) + for ( i = 0; i < MAX_CPE; i++ ) { st_ivas->hCPE[i] = NULL; } st_ivas->bit_stream = NULL; - st_ivas->mem_hp20_out_fx = NULL; + st_ivas->mem_hp20_out = NULL; st_ivas->hLimiter = NULL; /* ISM metadata handles */ - FOR ( i = 0; i < MAX_NUM_OBJECTS; i++ ) + + ivas_ism_metadata_close( st_ivas->hIsmMetaData, 0 ); + + /* ISM renderer handle */ + ivas_ism_renderer_close( &( st_ivas->hIsmRendererData ) ); + + /* DirAC handle */ + if( st_ivas->ivas_format == ISM_FORMAT ) + { + ivas_param_ism_dec_close( &( st_ivas->hParamIsmDec ), &( st_ivas->hSpatParamRendCom ), st_ivas->hDecoderConfig->output_config ); + } + ELSE + + for ( i = 0; i < MAX_NUM_OBJECTS; i++ ) { st_ivas->hIsmMetaData[i] = NULL; } @@ -4234,24 +4485,24 @@ void ivas_initialize_handles_dec( st_ivas->hJbmMetadata = NULL; /* floating-point output audio buffers */ - FOR ( i = 0; i < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; i++ ) + for ( i = 0; i < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; i++ ) { -#ifdef IVAS_FLOAT_FIXED_TO_BE_REMOVED st_ivas->p_output_f[i] = NULL; -#endif - st_ivas->p_output_fx[i] = NULL; } return; } + #endif + /*------------------------------------------------------------------------- * ivas_destroy_dec() * * Close IVAS decoder handles *-------------------------------------------------------------------------*/ -#ifndef IVAS_FLOAT_FIXED + +#ifdef IVAS_FLOAT_FIXED void ivas_destroy_dec( Decoder_Struct *st_ivas /* i/o: IVAS decoder handle */ ) @@ -4302,16 +4553,17 @@ void ivas_destroy_dec( } /* HP20 filter handles */ - IF(st_ivas->mem_hp20_out != NULL) + IF( st_ivas->mem_hp20_out_fx != NULL ) { - FOR(i = 0; i < getNumChanSynthesis(st_ivas); i++) + FOR( i = 0; i < getNumChanSynthesis( st_ivas ); i++ ) { - free(st_ivas->mem_hp20_out[i]); - st_ivas->mem_hp20_out[i] = NULL; + free( st_ivas->mem_hp20_out_fx[i] ); + st_ivas->mem_hp20_out_fx[i] = NULL; } - free(st_ivas->mem_hp20_out); - st_ivas->mem_hp20_out = NULL; + free( st_ivas->mem_hp20_out_fx ); + st_ivas->mem_hp20_out_fx = NULL; } + /* ISM metadata handles */ ivas_ism_metadata_close( st_ivas->hIsmMetaData, 0 ); @@ -4321,13 +4573,13 @@ void ivas_destroy_dec( /* DirAC handle */ IF ( st_ivas->ivas_format == ISM_FORMAT ) { - ivas_param_ism_dec_close( &( st_ivas->hParamIsmDec ), &( st_ivas->hSpatParamRendCom ), st_ivas->hDecoderConfig->output_config ); + ivas_param_ism_dec_close_fx( &( st_ivas->hParamIsmDec ), &( st_ivas->hSpatParamRendCom ), st_ivas->hDecoderConfig->output_config ); } ELSE { - ivas_dirac_rend_close( &( st_ivas->hDirACRend ) ); - ivas_spat_hSpatParamRendCom_close(&(st_ivas->hSpatParamRendCom)); - ivas_dirac_dec_close(&(st_ivas->hDirAC)); + ivas_dirac_rend_close_fx(&(st_ivas->hDirACRend)); + ivas_spat_hSpatParamRendCom_close_fx( &( st_ivas->hSpatParamRendCom ) ); + ivas_dirac_dec_close_fx( &( st_ivas->hDirAC ) ); } /* SPAR handle */ @@ -4341,8 +4593,8 @@ void ivas_destroy_dec( } /* MASA decoder structure */ - ivas_masa_dec_close( &( st_ivas->hMasa ) ); + ivas_masa_dec_close_fx( &( st_ivas->hMasa ) ); /* Qmetadata handle */ ivas_qmetadata_close( &st_ivas->hQMetaData ); @@ -4350,22 +4602,21 @@ void ivas_destroy_dec( ivas_mct_dec_close( &st_ivas->hMCT ); /* LFE handle */ - ivas_lfe_dec_close( &( st_ivas->hLFE ) ); + ivas_lfe_dec_close_fx( &( st_ivas->hLFE ) ); /* Param-Upmix MC handle */ ivas_mc_paramupmix_dec_close( &( st_ivas->hMCParamUpmix ) ); /* Parametric MC handle */ - ivas_param_mc_dec_close( &st_ivas->hParamMC ); + ivas_param_mc_dec_close_fx( &st_ivas->hParamMC ); /* EFAP handle */ efap_free_data( &st_ivas->hEFAPdata ); /* VBAP handle */ - vbap_free_data( &( st_ivas->hVBAPdata ) ); - + vbap_free_data_fx(&(st_ivas->hVBAPdata)); /* Fastconv binaural renderer handle */ - ivas_binRenderer_close( &st_ivas->hBinRenderer ); + ivas_binRenderer_close_fx( &st_ivas->hBinRenderer ); /* Parametric binaural renderer handle */ ivas_dirac_dec_close_binaural_data( &st_ivas->hDiracDecBin ); @@ -4378,8 +4629,8 @@ void ivas_destroy_dec( ivas_reverb_close( &st_ivas->hReverb ); /* LS config converter handle */ - ivas_ls_setup_conversion_close( &st_ivas->hLsSetUpConversion ); + ivas_ls_setup_conversion_close_fx( &st_ivas->hLsSetUpConversion ); /* Custom LS configuration handle */ IF ( st_ivas->hLsSetupCustom != NULL ) { @@ -4391,11 +4642,11 @@ void ivas_destroy_dec( ivas_mono_dmx_renderer_close( &st_ivas->hMonoDmxRenderer ); /* OSBA structure */ - ivas_osba_data_close( &st_ivas->hSbaIsmData ); - /* OMASA structure */ - ivas_omasa_data_close( &st_ivas->hMasaIsmData ); + ivas_osba_data_close_fx( &st_ivas->hSbaIsmData ); + /* OMASA structure */ + ivas_omasa_data_close_fx( &st_ivas->hMasaIsmData ); /* Head track data handle */ ivas_headTrack_close( &st_ivas->hHeadTrackData ); @@ -4408,25 +4659,28 @@ void ivas_destroy_dec( /* Time Domain binaural renderer handle */ IF ( st_ivas->hBinRendererTd != NULL ) { - ivas_td_binaural_close( &st_ivas->hBinRendererTd ); + ivas_td_binaural_close_fx( &st_ivas->hBinRendererTd ); } ELSE IF ( st_ivas->hHrtfTD != NULL ) { +#ifdef IVAS_FLOAT_FIXED_TO_BE_REMOVED BSplineModelEvalDealloc( &st_ivas->hHrtfTD->ModelParams, &st_ivas->hHrtfTD->ModelEval ); - ivas_HRTF_binary_close( &st_ivas->hHrtfTD ); +#endif + BSplineModelEvalDealloc_fx( &st_ivas->hHrtfTD->ModelParams, &st_ivas->hHrtfTD->ModelEval ); + ivas_HRTF_binary_close_fx( &st_ivas->hHrtfTD ); } /* CRend binaural renderer handle */ - ivas_HRTF_CRend_binary_close( &st_ivas->hSetOfHRTF ); + ivas_HRTF_CRend_binary_close_fx( &st_ivas->hSetOfHRTF ); /* Fastconv HRTF memories */ ivas_binaural_hrtf_close( &st_ivas->hHrtfFastConv ); /* Fastconv HRTF filters */ - ivas_HRTF_fastconv_binary_close( &st_ivas->hHrtfFastConv ); + ivas_HRTF_fastconv_binary_close_fx( &st_ivas->hHrtfFastConv ); /* Parametric binauralizer HRTF filters */ - ivas_HRTF_parambin_binary_close(&st_ivas->hHrtfParambin); + ivas_HRTF_parambin_binary_close_fx( &st_ivas->hHrtfParambin ); /* Config. Renderer */ ivas_render_config_close( &( st_ivas->hRenderConfig ) ); @@ -4451,11 +4705,19 @@ void ivas_destroy_dec( /* floating-point output audio buffers */ FOR ( i = 0; i < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; i++ ) { + +#ifdef IVAS_FLOAT_FIXED_TO_BE_REMOVED IF ( st_ivas->p_output_f[i] != NULL ) { free( st_ivas->p_output_f[i] ); st_ivas->p_output_f[i] = NULL; } +#endif + IF(st_ivas->p_output_fx[i] != NULL) + { + free(st_ivas->p_output_fx[i]); + st_ivas->p_output_fx[i] = NULL; + } } /* main IVAS handle */ @@ -4464,33 +4726,33 @@ void ivas_destroy_dec( return; } #else -void ivas_destroy_dec_fx( +void ivas_destroy_dec( Decoder_Struct *st_ivas /* i/o: IVAS decoder handle */ ) { - Word16 i; + int16_t i; /* CLDFB handles */ - FOR ( i = 0; i < MAX_INTERN_CHANNELS; i++ ) + for ( i = 0; i < MAX_INTERN_CHANNELS; i++ ) { - IF ( st_ivas->cldfbAnaDec[i] != NULL ) + if ( st_ivas->cldfbAnaDec[i] != NULL ) { - deleteCldfb_ivas_fx( &( st_ivas->cldfbAnaDec[i] ) ); + deleteCldfb( &( st_ivas->cldfbAnaDec[i] ) ); } } - FOR ( i = 0; i < MAX_OUTPUT_CHANNELS; i++ ) + for ( i = 0; i < MAX_OUTPUT_CHANNELS; i++ ) { - IF ( st_ivas->cldfbSynDec[i] != NULL ) + if ( st_ivas->cldfbSynDec[i] != NULL ) { - deleteCldfb_ivas_fx( &( st_ivas->cldfbSynDec[i] ) ); + deleteCldfb( &( st_ivas->cldfbSynDec[i] ) ); } } /* SCE handles */ - FOR ( i = 0; i < MAX_SCE; i++ ) + for ( i = 0; i < MAX_SCE; i++ ) { - IF ( st_ivas->hSCE[i] != NULL ) + if ( st_ivas->hSCE[i] != NULL ) { destroy_sce_dec( st_ivas->hSCE[i] ); st_ivas->hSCE[i] = NULL; @@ -4498,12 +4760,12 @@ void ivas_destroy_dec_fx( } /* CPE handles */ - FOR ( i = 0; i < MAX_CPE; i++ ) + for ( i = 0; i < MAX_CPE; i++ ) { - IF ( st_ivas->hCPE[i] != NULL ) + if ( st_ivas->hCPE[i] != NULL ) { /* set pointer to NULL as core coder already deallocated in destroy_sce_dec() */ - IF ( st_ivas->sba_dirac_stereo_flag && st_ivas->nchan_transport == 1 ) + if ( st_ivas->sba_dirac_stereo_flag && st_ivas->nchan_transport == 1 ) { st_ivas->hCPE[i]->hCoreCoder[0] = NULL; st_ivas->hCPE[i]->hCoreCoder[1] = NULL; @@ -4514,16 +4776,17 @@ void ivas_destroy_dec_fx( } /* HP20 filter handles */ - IF( st_ivas->mem_hp20_out_fx != NULL ) + if ( st_ivas->mem_hp20_out != NULL ) { - FOR( i = 0; i < getNumChanSynthesis( st_ivas ); i++ ) + for ( i = 0; i < getNumChanSynthesis( st_ivas ); i++ ) { - free( st_ivas->mem_hp20_out_fx[i] ); - st_ivas->mem_hp20_out_fx[i] = NULL; + free( st_ivas->mem_hp20_out[i] ); + st_ivas->mem_hp20_out[i] = NULL; } - free( st_ivas->mem_hp20_out_fx ); - st_ivas->mem_hp20_out_fx = NULL; + free( st_ivas->mem_hp20_out ); + st_ivas->mem_hp20_out = NULL; } + /* ISM metadata handles */ ivas_ism_metadata_close( st_ivas->hIsmMetaData, 0 ); @@ -4531,29 +4794,29 @@ void ivas_destroy_dec_fx( ivas_ism_renderer_close( &( st_ivas->hIsmRendererData ) ); /* DirAC handle */ - IF ( st_ivas->ivas_format == ISM_FORMAT ) + if ( st_ivas->ivas_format == ISM_FORMAT ) { - ivas_param_ism_dec_close_fx( &( st_ivas->hParamIsmDec ), &( st_ivas->hSpatParamRendCom ), st_ivas->hDecoderConfig->output_config ); + ivas_param_ism_dec_close( &( st_ivas->hParamIsmDec ), &( st_ivas->hSpatParamRendCom ), st_ivas->hDecoderConfig->output_config ); } - ELSE + else { - ivas_dirac_rend_close_fx(&(st_ivas->hDirACRend)); - ivas_spat_hSpatParamRendCom_close_fx( &( st_ivas->hSpatParamRendCom ) ); - ivas_dirac_dec_close_fx( &( st_ivas->hDirAC ) ); + ivas_dirac_rend_close( &( st_ivas->hDirACRend ) ); + ivas_spat_hSpatParamRendCom_close( &( st_ivas->hSpatParamRendCom ) ); + ivas_dirac_dec_close( &( st_ivas->hDirAC ) ); } /* SPAR handle */ ivas_spar_dec_close( &( st_ivas->hSpar ), st_ivas->hDecoderConfig->output_Fs, 0 ); /* HOA decoder matrix */ - IF ( st_ivas->hoa_dec_mtx != NULL ) + if ( st_ivas->hoa_dec_mtx != NULL ) { free( st_ivas->hoa_dec_mtx ); st_ivas->hoa_dec_mtx = NULL; } /* MASA decoder structure */ - ivas_masa_dec_close_fx( &( st_ivas->hMasa ) ); + ivas_masa_dec_close( &( st_ivas->hMasa ) ); /* Qmetadata handle */ ivas_qmetadata_close( &st_ivas->hQMetaData ); @@ -4562,22 +4825,23 @@ void ivas_destroy_dec_fx( ivas_mct_dec_close( &st_ivas->hMCT ); /* LFE handle */ - ivas_lfe_dec_close_fx( &( st_ivas->hLFE ) ); + ivas_lfe_dec_close( &( st_ivas->hLFE ) ); /* Param-Upmix MC handle */ ivas_mc_paramupmix_dec_close( &( st_ivas->hMCParamUpmix ) ); /* Parametric MC handle */ - ivas_param_mc_dec_close_fx( &st_ivas->hParamMC ); + ivas_param_mc_dec_close( &st_ivas->hParamMC ); /* EFAP handle */ efap_free_data( &st_ivas->hEFAPdata ); /* VBAP handle */ - vbap_free_data_fx(&(st_ivas->hVBAPdata)); + vbap_free_data( &( st_ivas->hVBAPdata ) ); /* Fastconv binaural renderer handle */ - ivas_binRenderer_close_fx( &st_ivas->hBinRenderer ); + ivas_binRenderer_close( &st_ivas->hBinRenderer ); + /* Parametric binaural renderer handle */ ivas_dirac_dec_close_binaural_data( &st_ivas->hDiracDecBin ); @@ -4590,10 +4854,10 @@ void ivas_destroy_dec_fx( ivas_reverb_close( &st_ivas->hReverb ); /* LS config converter handle */ - ivas_ls_setup_conversion_close_fx( &st_ivas->hLsSetUpConversion ); + ivas_ls_setup_conversion_close( &st_ivas->hLsSetUpConversion ); /* Custom LS configuration handle */ - IF ( st_ivas->hLsSetupCustom != NULL ) + if ( st_ivas->hLsSetupCustom != NULL ) { free( st_ivas->hLsSetupCustom ); st_ivas->hLsSetupCustom = NULL; @@ -4603,10 +4867,10 @@ void ivas_destroy_dec_fx( ivas_mono_dmx_renderer_close( &st_ivas->hMonoDmxRenderer ); /* OSBA structure */ - ivas_osba_data_close_fx( &st_ivas->hSbaIsmData ); + ivas_osba_data_close( &st_ivas->hSbaIsmData ); /* OMASA structure */ - ivas_omasa_data_close_fx( &st_ivas->hMasaIsmData ); + ivas_omasa_data_close( &st_ivas->hMasaIsmData ); /* Head track data handle */ ivas_headTrack_close( &st_ivas->hHeadTrackData ); @@ -4618,30 +4882,28 @@ void ivas_destroy_dec_fx( ivas_combined_orientation_close( &st_ivas->hCombinedOrientationData ); /* Time Domain binaural renderer handle */ - IF ( st_ivas->hBinRendererTd != NULL ) + if ( st_ivas->hBinRendererTd != NULL ) { - ivas_td_binaural_close_fx( &st_ivas->hBinRendererTd ); + ivas_td_binaural_close( &st_ivas->hBinRendererTd ); } - ELSE IF ( st_ivas->hHrtfTD != NULL ) + else if ( st_ivas->hHrtfTD != NULL ) { -#ifdef IVAS_FLOAT_FIXED_TO_BE_REMOVED BSplineModelEvalDealloc( &st_ivas->hHrtfTD->ModelParams, &st_ivas->hHrtfTD->ModelEval ); -#endif - BSplineModelEvalDealloc_fx( &st_ivas->hHrtfTD->ModelParams, &st_ivas->hHrtfTD->ModelEval ); - ivas_HRTF_binary_close_fx( &st_ivas->hHrtfTD ); + + ivas_HRTF_binary_close( &st_ivas->hHrtfTD ); } /* CRend binaural renderer handle */ - ivas_HRTF_CRend_binary_close_fx( &st_ivas->hSetOfHRTF ); + ivas_HRTF_CRend_binary_close( &st_ivas->hSetOfHRTF ); /* Fastconv HRTF memories */ ivas_binaural_hrtf_close( &st_ivas->hHrtfFastConv ); /* Fastconv HRTF filters */ - ivas_HRTF_fastconv_binary_close_fx( &st_ivas->hHrtfFastConv ); + ivas_HRTF_fastconv_binary_close( &st_ivas->hHrtfFastConv ); /* Parametric binauralizer HRTF filters */ - ivas_HRTF_parambin_binary_close_fx( &st_ivas->hHrtfParambin ); + ivas_HRTF_parambin_binary_close( &st_ivas->hHrtfParambin ); /* Config. Renderer */ ivas_render_config_close( &( st_ivas->hRenderConfig ) ); @@ -4649,55 +4911,255 @@ void ivas_destroy_dec_fx( /* Limiter struct */ ivas_limiter_close( &( st_ivas->hLimiter ) ); - IF ( st_ivas->hDecoderConfig != NULL ) + if ( st_ivas->hDecoderConfig != NULL ) { free( st_ivas->hDecoderConfig ); st_ivas->hDecoderConfig = NULL; } - ivas_jbm_dec_tc_buffer_close( &st_ivas->hTcBuffer ); + ivas_jbm_dec_tc_buffer_close( &st_ivas->hTcBuffer ); + + if ( st_ivas->hJbmMetadata != NULL ) + { + free( st_ivas->hJbmMetadata ); + st_ivas->hJbmMetadata = NULL; + } + + /* floating-point output audio buffers */ + for ( i = 0; i < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; i++ ) + { + if ( st_ivas->p_output_f[i] != NULL ) + { + free( st_ivas->p_output_f[i] ); + st_ivas->p_output_f[i] = NULL; + } + } + + /* main IVAS handle */ + free( st_ivas ); + + return; +} + +#endif + + +/*-------------------------------------------------------------------* + * ivas_init_dec_get_num_cldfb_instances() + * + * Return number of CLDFB analysis & synthesis instances + *-------------------------------------------------------------------*/ + +/*! r: number of cldfb instances */ +#ifdef IVAS_FLOAT_FIXED +void ivas_init_dec_get_num_cldfb_instances( + Decoder_Struct *st_ivas, /* i : IVAS decoder structure */ + Word16 *numCldfbAnalyses, /* o : number of needed CLDFB analysis instances */ + Word16 *numCldfbSyntheses /* o : number of needed CLDFB synthesis instances */ +) +{ + IVAS_FORMAT ivas_format; + *numCldfbAnalyses = st_ivas->nchan_transport; + *numCldfbSyntheses = st_ivas->hDecoderConfig->nchan_out; + + ivas_format = ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_MODE_NONE ) ? SBA_FORMAT : st_ivas->ivas_format; /* treat ISM_SBA_MODE_NONE just like SBA_FORMAT */ + + SWITCH ( st_ivas->renderer_type ) + { + case RENDERER_BINAURAL_PARAMETRIC: + case RENDERER_BINAURAL_PARAMETRIC_ROOM: + case RENDERER_STEREO_PARAMETRIC: + IF ( st_ivas->nchan_transport == 1 ) + { + *numCldfbAnalyses = st_ivas->nchan_transport + 1; + } + + IF ( st_ivas->mc_mode == MC_MODE_MCMASA && st_ivas->hOutSetup.separateChannelEnabled ) + { + *numCldfbAnalyses = st_ivas->nchan_transport + 1; + } + + IF ( ivas_format == SBA_ISM_FORMAT ) + { + IF ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + { + *numCldfbAnalyses += st_ivas->nchan_ism; + } + } + + IF ( ivas_format == MASA_ISM_FORMAT ) + { + IF ( st_ivas->ism_mode == ISM_MASA_MODE_DISC ) + { + *numCldfbAnalyses += st_ivas->nchan_ism; + } + ELSE IF ( st_ivas->ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ || st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ ) + { + *numCldfbAnalyses = st_ivas->nchan_transport + 1; + } + } + IF ( st_ivas->hDiracDecBin->useTdDecorr ) + { + *numCldfbAnalyses += 2; + } + BREAK; + case RENDERER_NON_DIEGETIC_DOWNMIX: + case RENDERER_MONO_DOWNMIX: + IF ( ivas_format == ISM_FORMAT || ivas_format == MASA_ISM_FORMAT || ivas_format == SBA_ISM_FORMAT ) + { + /* CLDFB not used in rendering */ + *numCldfbAnalyses = 0; + *numCldfbSyntheses = 0; + } + BREAK; + case RENDERER_DIRAC: + IF ( ivas_format == SBA_FORMAT ) + { + *numCldfbAnalyses = st_ivas->hSpar->hFbMixer->fb_cfg->num_in_chans; + + IF ( st_ivas->hOutSetup.is_loudspeaker_setup && st_ivas->renderer_type == RENDERER_DIRAC ) + { + *numCldfbSyntheses = st_ivas->hOutSetup.nchan_out_woLFE; + } + ELSE IF ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_FOA ) + { + *numCldfbSyntheses = st_ivas->hSpar->hFbMixer->fb_cfg->num_out_chans; + } + ELSE + { + *numCldfbSyntheses = MAX_OUTPUT_CHANNELS; + } + } + IF ( ivas_format != SBA_FORMAT ) + { + IF ( GT_16(st_ivas->nchan_transport, 2) && NE_16(st_ivas->sba_planar, 0) ) + { + *numCldfbAnalyses = add(st_ivas->nchan_transport, 1); + } + ELSE IF ( EQ_16(st_ivas->nchan_transport, 1) && st_ivas->hDirACRend->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD ) + { + *numCldfbAnalyses = add(st_ivas->nchan_transport, 1); + } + } + BREAK; + case RENDERER_MC_PARAMMC: + IF ( LE_16(st_ivas->hDecoderConfig->nchan_out, 2 )) + { + /* CLDFB not used in rendering */ + *numCldfbAnalyses = 0; + *numCldfbSyntheses = 0; + } + ELSE + { + *numCldfbSyntheses = param_mc_get_num_cldfb_syntheses( st_ivas ); + } + BREAK; + case RENDERER_PARAM_ISM: + /* Already correct with no exception */ + BREAK; + case RENDERER_DISABLE: + /* CLDFB not used */ + *numCldfbAnalyses = 0; + *numCldfbSyntheses = 0; + BREAK; + case RENDERER_MC: + case RENDERER_SBA_LINEAR_DEC: + case RENDERER_TD_PANNING: + case RENDERER_BINAURAL_OBJECTS_TD: + case RENDERER_MCMASA_MONO_STEREO: + case RENDERER_BINAURAL_MIXER_CONV: + case RENDERER_BINAURAL_MIXER_CONV_ROOM: + case RENDERER_BINAURAL_FASTCONV: + case RENDERER_BINAURAL_FASTCONV_ROOM: + case RENDERER_OSBA_STEREO: + case RENDERER_OSBA_AMBI: + case RENDERER_OSBA_LS: + IF ( ivas_format == SBA_FORMAT || ivas_format == SBA_ISM_FORMAT ) + { + IF ( NE_16(st_ivas->sba_dirac_stereo_flag, 0) ) + { + *numCldfbAnalyses = 0; + *numCldfbSyntheses = 0; + } + ELSE + { + *numCldfbAnalyses = st_ivas->hSpar->hFbMixer->fb_cfg->num_in_chans; + + IF ( st_ivas->hOutSetup.is_loudspeaker_setup && st_ivas->renderer_type == RENDERER_DIRAC ) + { + *numCldfbSyntheses = st_ivas->hOutSetup.nchan_out_woLFE; + } + ELSE IF ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_FOA ) + { + *numCldfbSyntheses = st_ivas->hSpar->hFbMixer->fb_cfg->num_out_chans; + } + ELSE + { + *numCldfbSyntheses = MAX_OUTPUT_CHANNELS; + } - IF ( st_ivas->hJbmMetadata != NULL ) - { - free( st_ivas->hJbmMetadata ); - st_ivas->hJbmMetadata = NULL; + IF ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) + { + *numCldfbAnalyses = st_ivas->nchan_ism + st_ivas->hSpar->hFbMixer->fb_cfg->num_in_chans; + } + } + } + ELSE IF ( st_ivas->mc_mode == MC_MODE_PARAMMC ) + { + /* do nothing for ParamMC */ + } + ELSE + { + /* CLDFB not used in rendering */ + *numCldfbAnalyses = 0; + *numCldfbSyntheses = 0; + } + BREAK; + case RENDERER_SBA_LINEAR_ENC: + IF ( st_ivas->mc_mode == MC_MODE_PARAMMC ) + { + *numCldfbSyntheses = param_mc_get_num_cldfb_syntheses( st_ivas ); + } + ELSE IF ( st_ivas->ism_mode == ISM_MODE_PARAM ) + { + *numCldfbSyntheses = st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe; + } + ELSE IF ( st_ivas->mc_mode == MC_MODE_MCMASA ) + { + *numCldfbAnalyses = st_ivas->nchan_transport; + *numCldfbSyntheses = st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe; + } + ELSE + { + /* CLDFB not used in rendering */ + *numCldfbAnalyses = 0; + *numCldfbSyntheses = 0; + } + BREAK; + default: + assert( 0 && "Renderer not handled for CLDFB reservation." ); } - /* floating-point output audio buffers */ - FOR ( i = 0; i < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; i++ ) + IF ( st_ivas->mc_mode == MC_MODE_PARAMUPMIX && st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_MONO && st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_STEREO ) { -#ifdef IVAS_FLOAT_FIXED_TO_BE_REMOVED - IF ( st_ivas->p_output_f[i] != NULL ) + IF ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) { - free( st_ivas->p_output_f[i] ); - st_ivas->p_output_f[i] = NULL; + *numCldfbAnalyses = max( MC_PARAMUPMIX_MAX_INPUT_CHANS, *numCldfbAnalyses ); } -#endif - IF(st_ivas->p_output_fx[i] != NULL) + ELSE { - free(st_ivas->p_output_fx[i]); - st_ivas->p_output_fx[i] = NULL; + *numCldfbAnalyses = max( MC_PARAMUPMIX_MIN_CLDFB, *numCldfbAnalyses ); } + *numCldfbSyntheses = max( MC_PARAMUPMIX_MIN_CLDFB, *numCldfbSyntheses ); } - /* main IVAS handle */ - free( st_ivas ); - return; } -#endif - -/*-------------------------------------------------------------------* - * ivas_init_dec_get_num_cldfb_instances() - * - * Return number of CLDFB analysis & synthesis instances - *-------------------------------------------------------------------*/ - -/*! r: number of cldfb instances */ +#else void ivas_init_dec_get_num_cldfb_instances( Decoder_Struct *st_ivas, /* i : IVAS decoder structure */ - Word16 *numCldfbAnalyses, /* o : number of needed CLDFB analysis instances */ - Word16 *numCldfbSyntheses /* o : number of needed CLDFB synthesis instances */ + int16_t *numCldfbAnalyses, /* o : number of needed CLDFB analysis instances */ + int16_t *numCldfbSyntheses /* o : number of needed CLDFB synthesis instances */ ) { IVAS_FORMAT ivas_format; @@ -4706,104 +5168,104 @@ void ivas_init_dec_get_num_cldfb_instances( ivas_format = ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_MODE_NONE ) ? SBA_FORMAT : st_ivas->ivas_format; /* treat ISM_SBA_MODE_NONE just like SBA_FORMAT */ - SWITCH ( st_ivas->renderer_type ) + switch ( st_ivas->renderer_type ) { case RENDERER_BINAURAL_PARAMETRIC: case RENDERER_BINAURAL_PARAMETRIC_ROOM: case RENDERER_STEREO_PARAMETRIC: - IF ( st_ivas->nchan_transport == 1 ) + if ( st_ivas->nchan_transport == 1 ) { *numCldfbAnalyses = st_ivas->nchan_transport + 1; } - IF ( st_ivas->mc_mode == MC_MODE_MCMASA && st_ivas->hOutSetup.separateChannelEnabled ) + if ( st_ivas->mc_mode == MC_MODE_MCMASA && st_ivas->hOutSetup.separateChannelEnabled ) { *numCldfbAnalyses = st_ivas->nchan_transport + 1; } - IF ( ivas_format == SBA_ISM_FORMAT ) + if ( ivas_format == SBA_ISM_FORMAT ) { - IF ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { *numCldfbAnalyses += st_ivas->nchan_ism; } } - IF ( ivas_format == MASA_ISM_FORMAT ) + if ( ivas_format == MASA_ISM_FORMAT ) { - IF ( st_ivas->ism_mode == ISM_MASA_MODE_DISC ) + if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC ) { *numCldfbAnalyses += st_ivas->nchan_ism; } - ELSE IF ( st_ivas->ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ || st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ ) + else if ( st_ivas->ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ || st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ ) { *numCldfbAnalyses = st_ivas->nchan_transport + 1; } } - IF ( st_ivas->hDiracDecBin->useTdDecorr ) + if ( st_ivas->hDiracDecBin->useTdDecorr ) { *numCldfbAnalyses += 2; } - BREAK; + break; case RENDERER_NON_DIEGETIC_DOWNMIX: case RENDERER_MONO_DOWNMIX: - IF ( ivas_format == ISM_FORMAT || ivas_format == MASA_ISM_FORMAT || ivas_format == SBA_ISM_FORMAT ) + if ( ivas_format == ISM_FORMAT || ivas_format == MASA_ISM_FORMAT || ivas_format == SBA_ISM_FORMAT ) { /* CLDFB not used in rendering */ *numCldfbAnalyses = 0; *numCldfbSyntheses = 0; } - BREAK; + break; case RENDERER_DIRAC: - IF ( ivas_format == SBA_FORMAT ) + if ( ivas_format == SBA_FORMAT ) { *numCldfbAnalyses = st_ivas->hSpar->hFbMixer->fb_cfg->num_in_chans; - IF ( st_ivas->hOutSetup.is_loudspeaker_setup && st_ivas->renderer_type == RENDERER_DIRAC ) + if ( st_ivas->hOutSetup.is_loudspeaker_setup && st_ivas->renderer_type == RENDERER_DIRAC ) { *numCldfbSyntheses = st_ivas->hOutSetup.nchan_out_woLFE; } - ELSE IF ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_FOA ) + else if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_FOA ) { *numCldfbSyntheses = st_ivas->hSpar->hFbMixer->fb_cfg->num_out_chans; } - ELSE + else { *numCldfbSyntheses = MAX_OUTPUT_CHANNELS; } } - IF ( ivas_format != SBA_FORMAT ) + if ( ivas_format != SBA_FORMAT ) { - IF ( GT_16(st_ivas->nchan_transport, 2) && NE_16(st_ivas->sba_planar, 0) ) + if ( st_ivas->nchan_transport > 2 && st_ivas->sba_planar ) { - *numCldfbAnalyses = add(st_ivas->nchan_transport, 1); + *numCldfbAnalyses = st_ivas->nchan_transport + 1; } - ELSE IF ( EQ_16(st_ivas->nchan_transport, 1) && st_ivas->hDirACRend->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD ) + else if ( st_ivas->nchan_transport == 1 && st_ivas->hDirACRend->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD ) { - *numCldfbAnalyses = add(st_ivas->nchan_transport, 1); + *numCldfbAnalyses = st_ivas->nchan_transport + 1; } } - BREAK; + break; case RENDERER_MC_PARAMMC: - IF ( LE_16(st_ivas->hDecoderConfig->nchan_out, 2 )) + if ( st_ivas->hDecoderConfig->nchan_out <= 2 ) { /* CLDFB not used in rendering */ *numCldfbAnalyses = 0; *numCldfbSyntheses = 0; } - ELSE + else { *numCldfbSyntheses = param_mc_get_num_cldfb_syntheses( st_ivas ); } - BREAK; + break; case RENDERER_PARAM_ISM: /* Already correct with no exception */ - BREAK; + break; case RENDERER_DISABLE: /* CLDFB not used */ *numCldfbAnalyses = 0; *numCldfbSyntheses = 0; - BREAK; + break; case RENDERER_MC: case RENDERER_SBA_LINEAR_DEC: case RENDERER_TD_PANNING: @@ -4816,79 +5278,79 @@ void ivas_init_dec_get_num_cldfb_instances( case RENDERER_OSBA_STEREO: case RENDERER_OSBA_AMBI: case RENDERER_OSBA_LS: - IF ( ivas_format == SBA_FORMAT || ivas_format == SBA_ISM_FORMAT ) + if ( ivas_format == SBA_FORMAT || ivas_format == SBA_ISM_FORMAT ) { - IF ( NE_16(st_ivas->sba_dirac_stereo_flag, 0) ) + if ( st_ivas->sba_dirac_stereo_flag ) { *numCldfbAnalyses = 0; *numCldfbSyntheses = 0; } - ELSE + else { *numCldfbAnalyses = st_ivas->hSpar->hFbMixer->fb_cfg->num_in_chans; - IF ( st_ivas->hOutSetup.is_loudspeaker_setup && st_ivas->renderer_type == RENDERER_DIRAC ) + if ( st_ivas->hOutSetup.is_loudspeaker_setup && st_ivas->renderer_type == RENDERER_DIRAC ) { *numCldfbSyntheses = st_ivas->hOutSetup.nchan_out_woLFE; } - ELSE IF ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_FOA ) + else if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_FOA ) { *numCldfbSyntheses = st_ivas->hSpar->hFbMixer->fb_cfg->num_out_chans; } - ELSE + else { *numCldfbSyntheses = MAX_OUTPUT_CHANNELS; } - IF ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) + if ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) { *numCldfbAnalyses = st_ivas->nchan_ism + st_ivas->hSpar->hFbMixer->fb_cfg->num_in_chans; } } } - ELSE IF ( st_ivas->mc_mode == MC_MODE_PARAMMC ) + else if ( st_ivas->mc_mode == MC_MODE_PARAMMC ) { /* do nothing for ParamMC */ } - ELSE + else { /* CLDFB not used in rendering */ *numCldfbAnalyses = 0; *numCldfbSyntheses = 0; } - BREAK; + break; case RENDERER_SBA_LINEAR_ENC: - IF ( st_ivas->mc_mode == MC_MODE_PARAMMC ) + if ( st_ivas->mc_mode == MC_MODE_PARAMMC ) { *numCldfbSyntheses = param_mc_get_num_cldfb_syntheses( st_ivas ); } - ELSE IF ( st_ivas->ism_mode == ISM_MODE_PARAM ) + else if ( st_ivas->ism_mode == ISM_MODE_PARAM ) { *numCldfbSyntheses = st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe; } - ELSE IF ( st_ivas->mc_mode == MC_MODE_MCMASA ) + else if ( st_ivas->mc_mode == MC_MODE_MCMASA ) { *numCldfbAnalyses = st_ivas->nchan_transport; *numCldfbSyntheses = st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe; } - ELSE + else { /* CLDFB not used in rendering */ *numCldfbAnalyses = 0; *numCldfbSyntheses = 0; } - BREAK; + break; default: assert( 0 && "Renderer not handled for CLDFB reservation." ); } - IF ( st_ivas->mc_mode == MC_MODE_PARAMUPMIX && st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_MONO && st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_STEREO ) + if ( st_ivas->mc_mode == MC_MODE_PARAMUPMIX && st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_MONO && st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_STEREO ) { - IF ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) + if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) { *numCldfbAnalyses = max( MC_PARAMUPMIX_MAX_INPUT_CHANS, *numCldfbAnalyses ); } - ELSE + else { *numCldfbAnalyses = max( MC_PARAMUPMIX_MIN_CLDFB, *numCldfbAnalyses ); } @@ -4898,6 +5360,8 @@ void ivas_init_dec_get_num_cldfb_instances( return; } +#endif + /*---------------------------------------------------------------------* * doSanityChecks_IVAS() @@ -4906,6 +5370,7 @@ void ivas_init_dec_get_num_cldfb_instances( * not in conflict with the IVAS format *---------------------------------------------------------------------*/ +#ifdef IVAS_FLOAT_FIXED static ivas_error doSanityChecks_IVAS( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ) @@ -4914,6 +5379,7 @@ static ivas_error doSanityChecks_IVAS( AUDIO_CONFIG output_config; output_Fs = st_ivas->hDecoderConfig->output_Fs; + move32(); output_config = st_ivas->hDecoderConfig->output_config; /*-----------------------------------------------------------------* @@ -5019,3 +5485,119 @@ static ivas_error doSanityChecks_IVAS( return IVAS_ERR_OK; } +#else +static ivas_error doSanityChecks_IVAS( + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +) +{ + int32_t output_Fs; + AUDIO_CONFIG output_config; + + output_Fs = st_ivas->hDecoderConfig->output_Fs; + output_config = st_ivas->hDecoderConfig->output_config; + + /*-----------------------------------------------------------------* + * Sanity checks + *-----------------------------------------------------------------*/ + + if ( output_Fs == 8000 ) + { + return IVAS_ERROR( IVAS_ERR_INVALID_SAMPLING_RATE, "8kHz output sampling rate is not supported in IVAS." ); + } + + assert( st_ivas->ivas_format != UNDEFINED_FORMAT && "\n IVAS format undefined" ); + assert( st_ivas->ivas_format != MONO_FORMAT && "\n Wrong IVAS format: MONO" ); + + /* Verify output configuration compatible with non-diegetic panning */ + if ( st_ivas->hDecoderConfig->Opt_non_diegetic_pan && ( st_ivas->ivas_format != MONO_FORMAT ) && ( st_ivas->transport_config != IVAS_AUDIO_CONFIG_ISM1 ) ) + { + return IVAS_ERROR( IVAS_ERR_INVALID_OUTPUT_FORMAT, "Error: Non-diegetic panning not supported in this IVAS format" ); + } + + /* Verify stereo output configuration */ + if ( st_ivas->ivas_format == STEREO_FORMAT ) + { + if ( output_config != IVAS_AUDIO_CONFIG_MONO && output_config != IVAS_AUDIO_CONFIG_STEREO && output_config != IVAS_AUDIO_CONFIG_5_1 && output_config != IVAS_AUDIO_CONFIG_7_1 && output_config != IVAS_AUDIO_CONFIG_5_1_2 && output_config != IVAS_AUDIO_CONFIG_5_1_4 && output_config != IVAS_AUDIO_CONFIG_7_1_4 && output_config != IVAS_AUDIO_CONFIG_LS_CUSTOM ) + { + return IVAS_ERROR( IVAS_ERR_INVALID_OUTPUT_FORMAT, "Wrong output configuration specified for Stereo!" ); + } + } + else if ( st_ivas->ivas_format == ISM_FORMAT ) + { + /* Verify ISM output configuration */ + if ( output_config == IVAS_AUDIO_CONFIG_INVALID ) + { + return IVAS_ERROR( IVAS_ERR_INVALID_OUTPUT_FORMAT, "Incorrect output configuration specified for ISM" ); + } + } + else if ( st_ivas->ivas_format == SBA_FORMAT ) + { + /* Verify SBA output coniguration */ + if ( output_config == IVAS_AUDIO_CONFIG_INVALID ) + { + return IVAS_ERROR( IVAS_ERR_INVALID_OUTPUT_FORMAT, "Incorrect output configuration specified for SBA" ); + } + } + else if ( st_ivas->ivas_format == MASA_FORMAT ) + { + if ( output_config == IVAS_AUDIO_CONFIG_INVALID ) + { + return IVAS_ERROR( IVAS_ERR_INVALID_OUTPUT_FORMAT, "Incorrect output configuration specified for MASA!" ); + } + } + else if ( st_ivas->ivas_format == MC_FORMAT ) + { + /* Verify MC output configuration */ + if ( output_config == IVAS_AUDIO_CONFIG_INVALID || output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) + { + return IVAS_ERROR( IVAS_ERR_INVALID_OUTPUT_FORMAT, "Incorrect output configuration specified for Multi-channel" ); + } + } + + + if ( st_ivas->hDecoderConfig->Opt_Headrotation ) + { + if ( !( output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB + ) ) + { + return IVAS_ERROR( IVAS_ERR_HEAD_ROTATION_NOT_SUPPORTED, "Wrong set-up: Head-rotation not supported in this configuration" ); + } + } + + if ( st_ivas->hDecoderConfig->Opt_ExternalOrientation ) + { + if ( !( output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) + { + return IVAS_ERROR( IVAS_ERR_EXT_ORIENTATION_NOT_SUPPORTED, "Wrong set-up: External orientation not supported in this configuration" ); + } + } + + if ( st_ivas->hDecoderConfig->Opt_dpid_on ) + { + if ( !( output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) + { + return IVAS_ERROR( IVAS_ERR_DIRECTIVITY_NOT_SUPPORTED, "Wrong set-up: Directivity is not supported in this output configuration." ); + } + } + + if ( st_ivas->hDecoderConfig->Opt_aeid_on ) + { + if ( output_config != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) + { + return IVAS_ERROR( IVAS_ERR_ACOUSTIC_ENVIRONMENT_NOT_SUPPORTED, "Wrong set-up: Acoustic environment is not supported in this output configuration." ); + } + } + + if ( st_ivas->ivas_format == MASA_ISM_FORMAT ) + { + if ( st_ivas->ism_mode != ISM_MASA_MODE_DISC && output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) + { + return IVAS_ERROR( IVAS_ERR_INVALID_OUTPUT_FORMAT, "Incorrect output configuration specified for combined MASA and ISM format" ); + } + } + + + return IVAS_ERR_OK; +} + +#endif \ No newline at end of file diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index 1dc4b95bd7b0f596818c9dc6caa9ce41fc1641e9..7811f5becb66d7d2b43002ec3b0d2c5d42fe69f8 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -1973,7 +1973,268 @@ void ivas_ism_dec_digest_tc( * * *-------------------------------------------------------------------------*/ +#ifdef IVAS_FLOAT_FIXED +void ivas_param_ism_dec_digest_tc( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const UWord16 nCldfbSlots, /* i : number of CLFBS slots in the transport channels */ + Word32 *transport_channels[] /* i : synthesized core-coder transport channels/DirAC output */ +) +{ + Word16 exp_ref_power = 31, exp_cx_diag = 31; + Word16 exp_real_tmp = 0, exp_imag_tmp = 0; + Word32 ref_power_fx[CLDFB_NO_CHANNELS_MAX]; + Word16 ref_power_e[CLDFB_NO_CHANNELS_MAX]; + Word32 cx_diag_fx[CLDFB_NO_CHANNELS_MAX][PARAM_ISM_MAX_DMX]; + Word16 cx_diag_e[CLDFB_NO_CHANNELS_MAX][PARAM_ISM_MAX_DMX]; + Word16 q_tc=13; + Word16 ch, nchan_transport, nchan_out, nchan_out_woLFE, i; + Word16 slot_idx, bin_idx; + Word32 ivas_total_brate; + Word16 output_frame; + /* Direct Response/EFAP Gains */ + Word32 direct_response_fx[MAX_NUM_OBJECTS][PARAM_ISM_MAX_CHAN] = { 0 }; + PARAM_ISM_DEC_HANDLE hParamIsmDec; + SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; + Word16 fade_len; + Word16 max_exp_ref_power, max_exp_cx_diag; + + /* Initialization */ + hParamIsmDec = st_ivas->hParamIsmDec; + assert( hParamIsmDec ); + hSpatParamRendCom = st_ivas->hSpatParamRendCom; + assert( hSpatParamRendCom ); + output_frame = imult1616(nCldfbSlots , hSpatParamRendCom->num_freq_bands); + fade_len = shr(output_frame , 2); + + nchan_transport = st_ivas->nchan_transport; + ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; + + hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc_exp = 23; + hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc_exp = 23; + IF ( EQ_16(st_ivas->hDecoderConfig->output_config , IVAS_AUDIO_CONFIG_EXTERNAL) ) + { + nchan_out = st_ivas->nchan_ism; + nchan_out_woLFE = nchan_out; + st_ivas->hDecoderConfig->nchan_out = nchan_out; + } + ELSE + { + nchan_out = st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe; + nchan_out_woLFE = st_ivas->hIntSetup.nchan_out_woLFE; + } + + push_wmops( "ivas_param_ism_dec" ); + + /* general setup */ + ivas_jbm_dec_get_adapted_linear_interpolator_fx( DEFAULT_JBM_CLDFB_TIMESLOTS, nCldfbSlots, hParamIsmDec->hParamIsmRendering->interpolator_fx ); + + ivas_dirac_dec_set_md_map_fx( st_ivas, nCldfbSlots ); + /* set buffers to zero */ + + FOR ( bin_idx = 0; bin_idx < CLDFB_NO_CHANNELS_MAX; bin_idx++ ) + { + set_zero_fx( cx_diag_fx[bin_idx], PARAM_ISM_MAX_DMX ); + set16_fx(cx_diag_e[bin_idx], 31,PARAM_ISM_MAX_DMX ); + } + set_zero_fx( ref_power_fx, CLDFB_NO_CHANNELS_MAX ); + set16_fx(ref_power_e,31, CLDFB_NO_CHANNELS_MAX ); + + /* Frame-level Processing */ + /* De-quantization */ + IF ( !( EQ_32(ivas_total_brate , IVAS_SID_5k2) || EQ_32(ivas_total_brate , FRAME_NO_DATA) ) ) + { + ivas_param_ism_dec_dequant_DOA_fx( hParamIsmDec, st_ivas->nchan_ism ); + ivas_param_ism_dec_dequant_powrat_fx( hParamIsmDec ); + st_ivas->hISMDTX.dtx_flag = 0; + } + ELSE + { + st_ivas->hISMDTX.dtx_flag = 1; + } + /* obtain the direct response using EFAP */ + IF ( !( EQ_16(st_ivas->hDecoderConfig->output_config , IVAS_AUDIO_CONFIG_EXTERNAL) ) ) + { + FOR( i = 0; i < st_ivas->nchan_ism; i++ ) + { + efap_determine_gains_fx( st_ivas->hEFAPdata, direct_response_fx[i], hParamIsmDec->azimuth_values_fx[i], hParamIsmDec->elevation_values_fx[i], EFAP_MODE_EFAP ); + } + } + ELSE + { + Word16 j; + + FOR ( i = 0; i < st_ivas->nchan_ism; i++ ) + { + FOR ( j = 0; j < nchan_out_woLFE; j++ ) + { + IF ( EQ_16(i , j) ) + { + direct_response_fx[i][j] = ONE_IN_Q30; + } + ELSE + { + direct_response_fx[i][j] = 0; + } + } + } + + FOR ( j = 0; j < nchan_out_woLFE; j++ ) + { + IF( GT_32( hParamIsmDec->azimuth_values_fx[j], 0 ) ) + { + hParamIsmDec->hParamIsmRendering->proto_matrix_fx[j] = 32767; + hParamIsmDec->hParamIsmRendering->proto_matrix_fx[nchan_out_woLFE + j] = 0; + } + ELSE + { + IF( LT_32( hParamIsmDec->azimuth_values_fx[j], 0 ) ) + { + hParamIsmDec->hParamIsmRendering->proto_matrix_fx[j] = 0; + hParamIsmDec->hParamIsmRendering->proto_matrix_fx[nchan_out_woLFE + j] = 32767; + } + ELSE /* == 0.0f */ + { + hParamIsmDec->hParamIsmRendering->proto_matrix_fx[j] = ONE_IN_Q14; + hParamIsmDec->hParamIsmRendering->proto_matrix_fx[nchan_out_woLFE + j] = ONE_IN_Q14; + } + } +#ifdef IVAS_FLOAT_FIXED_TO_BE_REMOVED + hParamIsmDec->hParamIsmRendering->proto_matrix[j] = fixedToFloat( hParamIsmDec->hParamIsmRendering->proto_matrix_fx[j], Q15 ); + hParamIsmDec->hParamIsmRendering->proto_matrix[nchan_out_woLFE + j] = fixedToFloat( hParamIsmDec->hParamIsmRendering->proto_matrix_fx[nchan_out_woLFE + j], Q15 ); +#endif + } + } + + IF ( st_ivas->hDecoderConfig->Opt_tsm ) + { + /*TODO : FhG to check*/ + ivas_ism_param_dec_tc_gain_ajust_fx( st_ivas, output_frame, fade_len, transport_channels , &q_tc); + FOR ( i = 0; i < 2; i++ ) + scale_sig32( transport_channels[i], output_frame, sub(Q13 , q_tc) ); + q_tc = 13; + } + + exp_ref_power = 31; + max_exp_ref_power = 0; + FOR ( ch = 0; ch < nchan_transport; ch++ ) + { + max_exp_cx_diag = 0; + exp_cx_diag = 31; + /* CLDFB Analysis */ + FOR ( slot_idx = 0; slot_idx < nCldfbSlots; slot_idx++ ) + { + IF ( st_ivas->hDecoderConfig->Opt_tsm ) + { + Word32 RealBuffer_fx[CLDFB_NO_CHANNELS_MAX]; + Word32 ImagBuffer_fx[CLDFB_NO_CHANNELS_MAX]; + q_tc = 13; + cldfbAnalysis_ts_fx_fixed_q( &( transport_channels[ch][hSpatParamRendCom->num_freq_bands * slot_idx] ), RealBuffer_fx, ImagBuffer_fx, hSpatParamRendCom->num_freq_bands, st_ivas->cldfbAnaDec[ch] ,&q_tc); + Copy32( RealBuffer_fx, &hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc_fx[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], hSpatParamRendCom->num_freq_bands ); + Copy32( ImagBuffer_fx, &hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc_fx[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], hSpatParamRendCom->num_freq_bands ); + hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc_exp = 23; + hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc_exp = 23; + } + Word16 scale_factor_real, scale_factor_imag; + + exp_real_tmp = hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc_exp; + exp_imag_tmp = hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc_exp; + scale_factor_real = getScaleFactor32( &hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc_fx[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], hSpatParamRendCom->num_freq_bands ); + scale_factor_imag = getScaleFactor32( &hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc_fx[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], hSpatParamRendCom->num_freq_bands ); + scale_sig32( &hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc_fx[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], hSpatParamRendCom->num_freq_bands, scale_factor_real ); + scale_sig32(&hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc_fx[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], hSpatParamRendCom->num_freq_bands, scale_factor_imag); + exp_real_tmp -= scale_factor_real; + exp_imag_tmp -= scale_factor_imag; + ivas_param_ism_collect_slot_fx( hParamIsmDec, + &hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc_fx[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], + exp_real_tmp, + &hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc_fx[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], + exp_imag_tmp, + ch, + ref_power_fx, &exp_ref_power, cx_diag_fx, &exp_cx_diag ); + + exp_real_tmp += scale_factor_real; + exp_imag_tmp += scale_factor_imag; + scale_sig32( &hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc_fx[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], hSpatParamRendCom->num_freq_bands, -scale_factor_real ); + scale_sig32( &hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc_fx[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], hSpatParamRendCom->num_freq_bands, -scale_factor_imag ); + max_exp_ref_power = s_max( max_exp_ref_power, exp_ref_power ); + max_exp_cx_diag = s_max( max_exp_cx_diag, exp_cx_diag ); + FOR( Word16 band_idx = 0; band_idx < hParamIsmDec->hParamIsm->nbands; band_idx++ ) + { + Word16 a = hParamIsmDec->hParamIsm->band_grouping[band_idx]; + Word16 b = hParamIsmDec->hParamIsm->band_grouping[band_idx + 1]; + FOR( bin_idx = a; bin_idx < b; bin_idx++ ) + { + cx_diag_e[bin_idx][ch] = exp_cx_diag; + ref_power_e[bin_idx] = exp_ref_power; + } + } + FOR( bin_idx = 0; bin_idx < CLDFB_NO_CHANNELS_MAX; bin_idx++ ) + { + cx_diag_fx[bin_idx][ch] = L_shl( cx_diag_fx[bin_idx][ch], cx_diag_e[bin_idx][ch] - max_exp_cx_diag ); + cx_diag_e[bin_idx][ch] = max_exp_cx_diag; + ref_power_fx[bin_idx] = L_shl( ref_power_fx[bin_idx], ref_power_e[bin_idx] - max_exp_ref_power ); + ref_power_e[bin_idx] = max_exp_ref_power; + } + exp_ref_power = max_exp_ref_power; + exp_cx_diag = max_exp_cx_diag; + } + } + /* Obtain Mixing Matrix on a frame-level */ +#if 1/*To avoid garbage values(garbage values giving wrong exponent in jbm_dec_render)*/ + FOR ( bin_idx = 0; bin_idx < CLDFB_NO_CHANNELS_MAX; bin_idx++ ) + { + set32_fx( hParamIsmDec->hParamIsmRendering->mixing_matrix_lin_fx[bin_idx], 0, PARAM_ISM_MAX_CHAN * PARAM_ISM_MAX_DMX ); + } +#else + FOR ( bin_idx = 0; bin_idx < hSpatParamRendCom->num_freq_bands; bin_idx++ ) + { + set32_fx( hParamIsmDec->hParamIsmRendering->mixing_matrix_lin_fx[bin_idx], 0, nchan_transport * nchan_out_woLFE ); + } +#endif +#if 1/*TODO : To be removed (Fixed to float) */ + float ref_power[CLDFB_NO_CHANNELS_MAX]; + float cx_diag[CLDFB_NO_CHANNELS_MAX][PARAM_ISM_MAX_DMX]; + float direct_response[MAX_NUM_OBJECTS][PARAM_ISM_MAX_CHAN]; + FOR( ch = 0; ch < nchan_transport; ch++ ) + { + fixedToFloat_arrL( st_ivas->cldfbAnaDec[ch]->cldfb_state_fx, st_ivas->cldfbAnaDec[ch]->cldfb_state, Q13, st_ivas->cldfbAnaDec[ch]->p_filter_length - st_ivas->cldfbAnaDec[ch]->no_channels ); + /* CLDFB Analysis */ + FOR( slot_idx = 0; slot_idx < nCldfbSlots; slot_idx++ ) + { + fixedToFloat_arrL( &hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc_fx[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], &hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], Q8, hSpatParamRendCom->num_freq_bands ); + fixedToFloat_arrL( &hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc_fx[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], &hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], Q8, hSpatParamRendCom->num_freq_bands ); + } + } + FOR ( bin_idx = 0; bin_idx < CLDFB_NO_CHANNELS_MAX; bin_idx++ ) + { + set_f( hParamIsmDec->hParamIsmRendering->mixing_matrix_lin[bin_idx], 0.0f, PARAM_ISM_MAX_CHAN * PARAM_ISM_MAX_DMX );/*To be removed when dependency on mixing_matrix_lin is removed*/ + } + FOR( Word16 band_idx = 0; band_idx < CLDFB_NO_CHANNELS_MAX; band_idx++ ) + { + FOR( bin_idx = 0; bin_idx < PARAM_ISM_MAX_DMX; bin_idx++ ) + { + cx_diag[band_idx][bin_idx] = me2f( cx_diag_fx[band_idx][bin_idx], cx_diag_e[band_idx][bin_idx] ); + } + ref_power[band_idx] = me2f( ref_power_fx[band_idx], max_exp_ref_power ); + } + IF ( st_ivas->hDecoderConfig->Opt_tsm ) + { + st_ivas->hParamIsmDec->hParamIsm->last_dmx_gain = fixedToFloat( st_ivas->hParamIsmDec->hParamIsm->last_dmx_gain_fx, 15 - st_ivas->hParamIsmDec->hParamIsm->last_dmx_gain_e ); + } + FOR( i = 0; i < st_ivas->nchan_ism; i++ ) + { + fixedToFloat_arrL( direct_response_fx[i], direct_response[i], Q30, PARAM_ISM_MAX_CHAN ); + } +#endif + /* Compute mixing matrix */ + ivas_param_ism_compute_mixing_matrix( st_ivas->nchan_ism, hParamIsmDec, st_ivas->hISMDTX, direct_response, nchan_transport, nchan_out_woLFE, cx_diag, ref_power, hParamIsmDec->hParamIsmRendering->mixing_matrix_lin ); + + pop_wmops(); + + return; +} +#else void ivas_param_ism_dec_digest_tc( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ const uint16_t nCldfbSlots, /* i : number of CLFBS slots in the transport channels */ @@ -1987,9 +2248,6 @@ void ivas_param_ism_dec_digest_tc( float ref_power[CLDFB_NO_CHANNELS_MAX]; float cx_diag[CLDFB_NO_CHANNELS_MAX][PARAM_ISM_MAX_DMX]; /* Direct Response/EFAP Gains */ -#ifdef IVAS_FLOAT_FIXED - Word32 direct_response_fx[MAX_NUM_OBJECTS][PARAM_ISM_MAX_CHAN]; -#endif float direct_response[MAX_NUM_OBJECTS][PARAM_ISM_MAX_CHAN]; PARAM_ISM_DEC_HANDLE hParamIsmDec; SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; @@ -2021,17 +2279,10 @@ void ivas_param_ism_dec_digest_tc( push_wmops( "ivas_param_ism_dec" ); /* general setup */ -#ifdef IVAS_FLOAT_FIXED - ivas_jbm_dec_get_adapted_linear_interpolator_fx( DEFAULT_JBM_CLDFB_TIMESLOTS, nCldfbSlots, hParamIsmDec->hParamIsmRendering->interpolator_fx ); -#else ivas_jbm_dec_get_adapted_linear_interpolator( DEFAULT_JBM_CLDFB_TIMESLOTS, nCldfbSlots, hParamIsmDec->hParamIsmRendering->interpolator ); -#endif -#ifdef IVAS_FLOAT_FIXED - ivas_dirac_dec_set_md_map_fx( st_ivas, nCldfbSlots ); -#else ivas_dirac_dec_set_md_map( st_ivas, nCldfbSlots ); -#endif + /* set buffers to zero */ for ( bin_idx = 0; bin_idx < CLDFB_NO_CHANNELS_MAX; bin_idx++ ) { @@ -2043,13 +2294,8 @@ void ivas_param_ism_dec_digest_tc( /* De-quantization */ if ( !( ivas_total_brate == IVAS_SID_5k2 || ivas_total_brate == FRAME_NO_DATA ) ) { -#ifdef IVAS_FLOAT_FIXED - ivas_param_ism_dec_dequant_DOA_fx( hParamIsmDec, st_ivas->nchan_ism ); - ivas_param_ism_dec_dequant_powrat_fx( hParamIsmDec ); -#else ivas_param_ism_dec_dequant_DOA( hParamIsmDec, st_ivas->nchan_ism ); ivas_param_ism_dec_dequant_powrat( hParamIsmDec ); -#endif // IVAS_FLOAT_FIXED st_ivas->hISMDTX.dtx_flag = 0; } else @@ -2060,22 +2306,10 @@ void ivas_param_ism_dec_digest_tc( /* obtain the direct response using EFAP */ if ( !( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) ) { -#ifdef IVAS_FLOAT_FIXED - FOR( i = 0; i < st_ivas->nchan_ism; i++ ) - { - efap_determine_gains_fx( st_ivas->hEFAPdata, direct_response_fx[i], hParamIsmDec->azimuth_values_fx[i], hParamIsmDec->elevation_values_fx[i], EFAP_MODE_EFAP ); - } - - FOR( i = 0; i < st_ivas->nchan_ism; i++ ) - { - fixedToFloat_arrL( direct_response_fx[i], direct_response[i], Q30, PARAM_ISM_MAX_CHAN ); - } -#else for ( i = 0; i < st_ivas->nchan_ism; i++ ) { efap_determine_gains( st_ivas->hEFAPdata, direct_response[i], hParamIsmDec->azimuth_values[i], hParamIsmDec->elevation_values[i], EFAP_MODE_EFAP ); } -#endif } else { @@ -2098,22 +2332,14 @@ void ivas_param_ism_dec_digest_tc( for ( j = 0; j < nchan_out_woLFE; j++ ) { -#ifdef IVAS_FLOAT_FIXED - IF( GT_32( hParamIsmDec->azimuth_values_fx[j], 0 ) ) -#else if ( hParamIsmDec->azimuth_values[j] > 0.0f ) -#endif { hParamIsmDec->hParamIsmRendering->proto_matrix[j] = 1.0f; hParamIsmDec->hParamIsmRendering->proto_matrix[nchan_out_woLFE + j] = 0.0f; } else { -#ifdef IVAS_FLOAT_FIXED - IF( LT_32( hParamIsmDec->azimuth_values_fx[j], 0 ) ) -#else if ( hParamIsmDec->azimuth_values[j] < 0.0f ) -#endif { hParamIsmDec->hParamIsmRendering->proto_matrix[j] = 0.0f; hParamIsmDec->hParamIsmRendering->proto_matrix[nchan_out_woLFE + j] = 1.0f; @@ -2144,42 +2370,12 @@ void ivas_param_ism_dec_digest_tc( float RealBuffer[CLDFB_NO_CHANNELS_MAX]; float ImagBuffer[CLDFB_NO_CHANNELS_MAX]; - cldfbAnalysis_ts_ivas( &( transport_channels_f[ch][hSpatParamRendCom->num_freq_bands * slot_idx] ), RealBuffer, ImagBuffer, hSpatParamRendCom->num_freq_bands, st_ivas->cldfbAnaDec[ch] ); + cldfbAnalysis_ts( &( transport_channels_f[ch][hSpatParamRendCom->num_freq_bands * slot_idx] ), RealBuffer, ImagBuffer, hSpatParamRendCom->num_freq_bands, st_ivas->cldfbAnaDec[ch] ); mvr2r( RealBuffer, &hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], hSpatParamRendCom->num_freq_bands ); mvr2r( ImagBuffer, &hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], hSpatParamRendCom->num_freq_bands ); } -#ifdef IVAS_FLOAT_FIXED - Word16 exp_real_tmp = 0, exp_imag_tmp = 0; - f2me_buf( &hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], &hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc_fx[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], &exp_real_tmp, hSpatParamRendCom->num_freq_bands ); - f2me_buf( &hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], &hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc_fx[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], &exp_imag_tmp, hSpatParamRendCom->num_freq_bands ); - Word32 ref_power_fx[CLDFB_NO_CHANNELS_MAX]; - Word32 cx_diag_fx[CLDFB_NO_CHANNELS_MAX][PARAM_ISM_MAX_DMX]; - Word16 exp_ref_power = 0, exp_cx_diag = 0; - f2me_buf( ref_power, ref_power_fx, &exp_ref_power, CLDFB_NO_CHANNELS_MAX ); - f2me_buf( (float *) cx_diag, (Word32 *) cx_diag_fx, &exp_cx_diag, CLDFB_NO_CHANNELS_MAX * PARAM_ISM_MAX_DMX ); - ivas_param_ism_collect_slot_fx( hParamIsmDec, - &hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc_fx[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], - exp_real_tmp, - &hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc_fx[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], - exp_imag_tmp, - ch, - ref_power_fx, &exp_ref_power, cx_diag_fx, &exp_cx_diag ); - - FOR( int band_idx = 0; band_idx < hParamIsmDec->hParamIsm->nbands; band_idx++ ) - { - Word16 a = hParamIsmDec->hParamIsm->band_grouping[band_idx]; - Word16 b = hParamIsmDec->hParamIsm->band_grouping[band_idx + 1]; - FOR( bin_idx = a; bin_idx < b; bin_idx++ ) - { - - cx_diag[bin_idx][ch] = me2f( cx_diag_fx[bin_idx][ch], exp_cx_diag ); - ref_power[bin_idx] = me2f( ref_power_fx[bin_idx], exp_ref_power ); - } - } -#else - ivas_param_ism_collect_slot(hParamIsmDec, &hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], &hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], ch, ref_power, cx_diag); -#endif + ivas_param_ism_collect_slot( hParamIsmDec, &hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], &hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], ch, ref_power, cx_diag ); } } @@ -2187,17 +2383,8 @@ void ivas_param_ism_dec_digest_tc( for ( bin_idx = 0; bin_idx < hSpatParamRendCom->num_freq_bands; bin_idx++ ) { set_f( hParamIsmDec->hParamIsmRendering->mixing_matrix_lin[bin_idx], 0.0f, nchan_transport * nchan_out_woLFE ); -#ifdef IVAS_FLOAT_FIXED - set32_fx(hParamIsmDec->hParamIsmRendering->mixing_matrix_lin_fx[bin_idx], 0, nchan_transport * nchan_out_woLFE); -#endif } -#ifdef IVAS_FLOAT_FIXED - /*to avoide garbage values*/ - for (bin_idx = 0; bin_idx < CLDFB_NO_CHANNELS_MAX; bin_idx++) - { - set_f(hParamIsmDec->hParamIsmRendering->mixing_matrix_lin[bin_idx], 0.0f, PARAM_ISM_MAX_CHAN * PARAM_ISM_MAX_DMX); - } -#endif + /* Compute mixing matrix */ ivas_param_ism_compute_mixing_matrix( st_ivas->nchan_ism, hParamIsmDec, st_ivas->hISMDTX, direct_response, nchan_transport, nchan_out_woLFE, cx_diag, ref_power, hParamIsmDec->hParamIsmRendering->mixing_matrix_lin ); @@ -2205,6 +2392,7 @@ void ivas_param_ism_dec_digest_tc( return; } +#endif // IVAS_FLOAT_FIXED /*-------------------------------------------------------------------------* diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index ad50220ce83e1ecb10f5c544ac07b04ba906b3e2..865d4d9065587c5d15c6c9d61aee0a06052369ee 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -56,8 +56,11 @@ * Local function prototypes *-----------------------------------------------------------------------*/ +#ifdef IVAS_FLOAT_FIXED +static void ivas_jbm_dec_copy_tc( Decoder_Struct *st_ivas, const Word16 nSamplesForRendering, Word16 *nSamplesResidual, Word32 *data, Word32 *tc_digest_f[], Word16 data_q); +#else static void ivas_jbm_dec_copy_tc( Decoder_Struct *st_ivas, const int16_t nSamplesForRendering, int16_t *nSamplesResidual, float *data, float *tc_digest_f[] ); - +#endif #ifndef IVAS_FLOAT_FIXED static void ivas_jbm_dec_tc_buffer_playout( Decoder_Struct *st_ivas, const uint16_t nSamplesAsked, uint16_t *nSamplesRendered, float *output[] ); #endif @@ -2081,78 +2084,131 @@ void ivas_jbm_dec_feed_tc_to_renderer( { float data_f[MAX_CLDFB_DIGEST_CHANNELS][MAX_JBM_L_FRAME48k] = { 0 }; /* 'float' buffer for transport channels that will be directly converted with the CLDFB */ float *p_data_f[MAX_CLDFB_DIGEST_CHANNELS]; - int16_t n, n_render_timeslots, i; +#ifdef IVAS_FLOAT_FIXED + Word32 data_f_fx[MAX_CLDFB_DIGEST_CHANNELS][MAX_JBM_L_FRAME48k] = { 0 }; /* 'float' buffer for transport channels that will be directly converted with the CLDFB */ + Word32 *p_data_f_fx[MAX_CLDFB_DIGEST_CHANNELS]; + Word32* data_fx; + data_fx = (Word32*)malloc(8640 * sizeof(Word32)); +#endif + Word16 n, n_render_timeslots, i; push_wmops( "ivas_jbm_dec_feed_tc_to_rendererer" ); - for ( n = 0; n < MAX_CLDFB_DIGEST_CHANNELS; n++ ) + FOR ( n = 0; n < MAX_CLDFB_DIGEST_CHANNELS; n++ ) { p_data_f[n] = &data_f[n][0]; +#ifdef IVAS_FLOAT_FIXED + p_data_f_fx[n] = &data_f_fx[n][0]; +#endif } - - if ( st_ivas->hDecoderConfig->Opt_tsm ) + IF ( st_ivas->hDecoderConfig->Opt_tsm ) { - ivas_jbm_dec_copy_tc( st_ivas, nSamplesForRendering, nSamplesResidual, data, p_data_f ); +#ifdef IVAS_FLOAT_FIXED +#if 1 + floatToFixed_arrL(data, data_fx, 11, s_min(3, st_ivas->hTcBuffer->nchan_transport_jbm)*2880); + Word16 temp = st_ivas->hTcBuffer->n_samples_buffered - st_ivas->hTcBuffer->n_samples_rendered; //Thsese values get updated in function + +#endif + ivas_jbm_dec_copy_tc( st_ivas, nSamplesForRendering, nSamplesResidual, data_fx, p_data_f_fx, 11); + +#if 1 //To-be-removed + Word16 ch; + FOR (ch = 0; ch < min( st_ivas->hTcBuffer->nchan_transport_jbm, st_ivas->hTcBuffer->nchan_buffer_full ); ch++ ) + { + fixedToFloat_arrL(st_ivas->hTcBuffer->tc_fx[ch], st_ivas->hTcBuffer->tc[ch], st_ivas->hTcBuffer->q_tc_fx, nSamplesForRendering + temp); + } + + if ( st_ivas->hTcBuffer->nchan_transport_jbm - st_ivas->hTcBuffer->nchan_buffer_full > 0 ) + { + for ( ; ch < st_ivas->hTcBuffer->nchan_transport_jbm; ch++ ) + { + fixedToFloat_arrL(p_data_f_fx[ch], p_data_f[ch], st_ivas->hTcBuffer->q_tc_fx, MAX_JBM_L_FRAME48k); + } + } + + free(data_fx); +#endif +#else + ivas_jbm_dec_copy_tc( st_ivas, nSamplesForRendering, nSamplesResidual, data, p_data_f ); +#endif } - else + ELSE { - *nSamplesResidual = 0; + *nSamplesResidual = 0; move16(); } - n_render_timeslots = st_ivas->hTcBuffer->n_samples_available / st_ivas->hTcBuffer->n_samples_granularity; + n_render_timeslots = idiv1616(st_ivas->hTcBuffer->n_samples_available, st_ivas->hTcBuffer->n_samples_granularity); - if ( st_ivas->hTcBuffer->tc_buffer_mode == TC_BUFFER_MODE_BUFFER ) + IF ( EQ_16(st_ivas->hTcBuffer->tc_buffer_mode, TC_BUFFER_MODE_BUFFER )) { ivas_jbm_dec_td_renderers_adapt_subframes( st_ivas ); - if ( ( st_ivas->ivas_format == MASA_FORMAT || st_ivas->ivas_format == MASA_ISM_FORMAT ) && st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) + test(); test(); + IF ( ( EQ_16(st_ivas->ivas_format, MASA_FORMAT) || EQ_16(st_ivas->ivas_format, MASA_ISM_FORMAT) ) && EQ_16(st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_EXTERNAL) ) { ivas_jbm_masa_sf_to_slot_map( st_ivas, n_render_timeslots ); } } - else if ( st_ivas->ivas_format == STEREO_FORMAT ) + ELSE IF ( EQ_16(st_ivas->ivas_format, STEREO_FORMAT )) { ivas_jbm_dec_td_renderers_adapt_subframes( st_ivas ); } - else if ( st_ivas->ivas_format == ISM_FORMAT ) + ELSE IF ( EQ_16(st_ivas->ivas_format, ISM_FORMAT )) { /* Rendering */ - if ( st_ivas->ism_mode == ISM_MODE_PARAM ) + IF ( EQ_16(st_ivas->ism_mode, ISM_MODE_PARAM )) { - if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) + test(); test(); + IF ( EQ_16(st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC) || EQ_16(st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM) || EQ_16(st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC )) { -#ifndef IVAS_FLOAT_FIXED - ivas_dirac_dec_set_md_map(st_ivas, n_render_timeslots); - - ivas_param_ism_params_to_masa_param_mapping(st_ivas); -#else ivas_dirac_dec_set_md_map_fx( st_ivas, n_render_timeslots ); ivas_param_ism_params_to_masa_param_mapping_fx( st_ivas ); -#endif } - else if ( st_ivas->renderer_type == RENDERER_PARAM_ISM || st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) + ELSE IF ( EQ_16(st_ivas->renderer_type, RENDERER_PARAM_ISM) || EQ_16(st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC )) { +#ifdef IVAS_FLOAT_FIXED + floatToFixed_arr32( p_data_f[0], p_data_f_fx[0], Q13, MAX_CLDFB_DIGEST_CHANNELS * MAX_JBM_L_FRAME48k ); +#if 1/*Float to fixed conversions*/ + IF( st_ivas->hDecoderConfig->Opt_tsm ) + { + /*TODO : FhG to check*/ + st_ivas->hParamIsmDec->hParamIsm->last_dmx_gain_fx = float_to_fix16( st_ivas->hParamIsmDec->hParamIsm->last_dmx_gain, 15 - st_ivas->hParamIsmDec->hParamIsm->last_dmx_gain_e ); + } + FOR( Word16 ch = 0; ch < MAX_INTERN_CHANNELS; ch++ ) + { + IF( st_ivas->cldfbAnaDec[ch] ) + floatToFixed_arr32( st_ivas->cldfbAnaDec[ch]->cldfb_state, st_ivas->cldfbAnaDec[ch]->cldfb_state_fx, Q13, st_ivas->cldfbAnaDec[ch]->p_filter_length - st_ivas->cldfbAnaDec[ch]->no_channels ); + } + FOR( Word16 ch = 0; ch < st_ivas->nchan_transport; ch++ ) + { + FOR( Word16 slot_idx = 0; slot_idx < n_render_timeslots; slot_idx++ ) + { + floatToFixed_arr32( &st_ivas->hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc[slot_idx * st_ivas->hSpatParamRendCom->num_freq_bands * st_ivas->nchan_transport + ch * st_ivas->hSpatParamRendCom->num_freq_bands], &st_ivas->hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc_fx[slot_idx * st_ivas->hSpatParamRendCom->num_freq_bands * st_ivas->nchan_transport + ch * st_ivas->hSpatParamRendCom->num_freq_bands], Q8, st_ivas->hSpatParamRendCom->num_freq_bands ); + floatToFixed_arr32( &st_ivas->hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc[slot_idx * st_ivas->hSpatParamRendCom->num_freq_bands * st_ivas->nchan_transport + ch * st_ivas->hSpatParamRendCom->num_freq_bands], &st_ivas->hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc_fx[slot_idx * st_ivas->hSpatParamRendCom->num_freq_bands * st_ivas->nchan_transport + ch * st_ivas->hSpatParamRendCom->num_freq_bands], Q8, st_ivas->hSpatParamRendCom->num_freq_bands ); + } + } +#endif + ivas_param_ism_dec_digest_tc( st_ivas, n_render_timeslots, p_data_f_fx ); + fixedToFloat_arrL( p_data_f_fx[0], p_data_f[0], Q13, MAX_CLDFB_DIGEST_CHANNELS * MAX_JBM_L_FRAME48k ); +#else ivas_param_ism_dec_digest_tc( st_ivas, n_render_timeslots, p_data_f ); +#endif } } - else /* ISM_MODE_DISC */ + ELSE /* ISM_MODE_DISC */ { ivas_ism_dec_digest_tc_fx( st_ivas ); } } - else if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == MASA_FORMAT ) + ELSE IF ( EQ_16(st_ivas->ivas_format, SBA_FORMAT) || EQ_16(st_ivas->ivas_format, MASA_FORMAT )) { #if 1 Word16 nchan_transport = 0; SPAR_DEC_HANDLE hSpar = st_ivas->hSpar; if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) { - //num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ); - //num_bands_out = hSpar->hFbMixer->pFb->filterbank_num_bands; nchan_transport = hSpar->hMdDec->spar_md_cfg.nchan_transport; - //num_out_ch = hSpar->hMdDec->spar_md_cfg.num_umx_chs; hSpar->hMdDec->Q_mixer_mat = 31; - //num_in_ch = hSpar->hMdDec->spar_md_cfg.num_umx_chs; IF( hSpar->hMdDec->td_decorr_flag && !( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) ) { @@ -2165,7 +2221,7 @@ void ivas_jbm_dec_feed_tc_to_renderer( move16(); } } - st_ivas->hTcBuffer->q_tc_fx = 14; + st_ivas->hTcBuffer->q_tc_fx = 11; for ( i = 0; i < ivas_sba_get_nchan_metadata( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ) + ch_sba_idx; i++ ) { floatToFixed_arrL( st_ivas->hTcBuffer->tc[i], st_ivas->hTcBuffer->tc_fx[i], st_ivas->hTcBuffer->q_tc_fx, min( nSamplesForRendering, (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ) ) ); @@ -2175,7 +2231,7 @@ void ivas_jbm_dec_feed_tc_to_renderer( if ( st_ivas->hDiracDecBin != NULL && ( st_ivas->hDiracDecBin->useTdDecorr ) ) { - st_ivas->hTcBuffer->q_tc_fx = 14; + st_ivas->hTcBuffer->q_tc_fx = 11; Word16 nSamplesLeftForTD, default_frame; default_frame = (Word16) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); nSamplesLeftForTD = nSamplesForRendering; @@ -2233,7 +2289,7 @@ void ivas_jbm_dec_feed_tc_to_renderer( if (st_ivas->hDiracDecBin != NULL && (st_ivas->hDiracDecBin->useTdDecorr)) { - st_ivas->hTcBuffer->q_tc_fx = 14; + st_ivas->hTcBuffer->q_tc_fx = 11; int16_t nSamplesLeftForTD, default_frame; default_frame = (int16_t)(st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC); nSamplesLeftForTD = nSamplesForRendering; @@ -2256,14 +2312,9 @@ void ivas_jbm_dec_feed_tc_to_renderer( ((st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC) && (nchan_transport == 1 && st_ivas->nchan_transport != 2 && st_ivas->hSCE[0]->hCoreCoder[0] != NULL && st_ivas->hSCE[0]->hCoreCoder[0]->cng_sba_flag))) { Decoder_State *st = st_ivas->hSCE[0]->hCoreCoder[0]; - //fixedToFloat_arrL(st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, st->hFdCngDec->hFdCngCom->olapBufferSynth2_flt, 15, st->hFdCngDec->hFdCngCom->fftlen); - //fixedToFloat_arrL(st->hFdCngDec->hFdCngCom->fftBuffer, st->hFdCngDec->hFdCngCom->fftBuffer_flt, 31 - st->hFdCngDec->hFdCngCom->fftBuffer_exp, st->hFdCngDec->hFdCngCom->fftlen); - - //fixedToFloat_arrL(st->hFdCngDec->hFdCngCom->exc_cng_32fx, st->hFdCngDec->hFdCngCom->exc_cng_flt, 31 - st->hFdCngDec->hFdCngCom->fftBuffer_exp - 9, st->hFdCngDec->hFdCngCom->frameSize); fixedToFloat_arrL(st_ivas->hTcBuffer->tc_fx[1], st_ivas->hTcBuffer->tc[1], 31 - st->hFdCngDec->hFdCngCom->fftBuffer_exp - 9, st->hFdCngDec->hFdCngCom->frameSize); } #endif - } else if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) { @@ -2282,7 +2333,18 @@ void ivas_jbm_dec_feed_tc_to_renderer( { for ( n = 0; n < st_ivas->nchan_ism; n++ ) { +#if 1 + st_ivas->hTcBuffer->q_tc_fx = 11; + floatToFixed_arrL( st_ivas->hTcBuffer->tc[n], st_ivas->hTcBuffer->tc_fx[n], st_ivas->hTcBuffer->q_tc_fx, st_ivas->hTcBuffer->n_samples_available ); + floatToFixed_arrL( st_ivas->hSbaIsmData->delayBuffer[n], st_ivas->hSbaIsmData->delayBuffer_fx[n], st_ivas->hTcBuffer->q_tc_fx, st_ivas->hSbaIsmData->delayBuffer_size ); + + delay_signal_fx( st_ivas->hTcBuffer->tc_fx[n], st_ivas->hTcBuffer->n_samples_available, st_ivas->hSbaIsmData->delayBuffer_fx[n], st_ivas->hSbaIsmData->delayBuffer_size ); + + fixedToFloat_arrL( st_ivas->hTcBuffer->tc_fx[n], st_ivas->hTcBuffer->tc[n], st_ivas->hTcBuffer->q_tc_fx, st_ivas->hTcBuffer->n_samples_available ); + fixedToFloat_arrL( st_ivas->hSbaIsmData->delayBuffer_fx[n], st_ivas->hSbaIsmData->delayBuffer[n], st_ivas->hTcBuffer->q_tc_fx, st_ivas->hSbaIsmData->delayBuffer_size ); +#else delay_signal_float( st_ivas->hTcBuffer->tc[n], st_ivas->hTcBuffer->n_samples_available, st_ivas->hSbaIsmData->delayBuffer[n], st_ivas->hSbaIsmData->delayBuffer_size ); +#endif } } @@ -2298,12 +2360,8 @@ void ivas_jbm_dec_feed_tc_to_renderer( SPAR_DEC_HANDLE hSpar = st_ivas->hSpar; if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) { - //num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ); - //num_bands_out = hSpar->hFbMixer->pFb->filterbank_num_bands; nchan_transport = hSpar->hMdDec->spar_md_cfg.nchan_transport; - //num_out_ch = hSpar->hMdDec->spar_md_cfg.num_umx_chs; hSpar->hMdDec->Q_mixer_mat = 31; - //num_in_ch = hSpar->hMdDec->spar_md_cfg.num_umx_chs; IF( hSpar->hMdDec->td_decorr_flag && !( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) ) { @@ -2316,7 +2374,7 @@ void ivas_jbm_dec_feed_tc_to_renderer( move16(); } } - st_ivas->hTcBuffer->q_tc_fx = 14; + st_ivas->hTcBuffer->q_tc_fx = 11; for ( i = 0; i < ivas_sba_get_nchan_metadata( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ) + ch_sba_idx; i++ ) { floatToFixed_arrL( st_ivas->hTcBuffer->tc[i], st_ivas->hTcBuffer->tc_fx[i], st_ivas->hTcBuffer->q_tc_fx, min( nSamplesForRendering, (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ) ) ); @@ -2326,7 +2384,7 @@ void ivas_jbm_dec_feed_tc_to_renderer( if ( st_ivas->hDiracDecBin != NULL && ( st_ivas->hDiracDecBin->useTdDecorr ) ) { - st_ivas->hTcBuffer->q_tc_fx = 14; + st_ivas->hTcBuffer->q_tc_fx = 11; Word16 nSamplesLeftForTD, default_frame; default_frame = (Word16) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); nSamplesLeftForTD = nSamplesForRendering; @@ -2384,7 +2442,7 @@ void ivas_jbm_dec_feed_tc_to_renderer( if ( st_ivas->hDiracDecBin != NULL && ( st_ivas->hDiracDecBin->useTdDecorr ) ) { - st_ivas->hTcBuffer->q_tc_fx = 14; + st_ivas->hTcBuffer->q_tc_fx = 11; int16_t nSamplesLeftForTD, default_frame; default_frame = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); nSamplesLeftForTD = nSamplesForRendering; @@ -2424,12 +2482,9 @@ void ivas_jbm_dec_feed_tc_to_renderer( SPAR_DEC_HANDLE hSpar = st_ivas->hSpar; if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) { - //num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ); - //num_bands_out = hSpar->hFbMixer->pFb->filterbank_num_bands; + nchan_transport = hSpar->hMdDec->spar_md_cfg.nchan_transport; - //num_out_ch = hSpar->hMdDec->spar_md_cfg.num_umx_chs; hSpar->hMdDec->Q_mixer_mat = 31; - //num_in_ch = hSpar->hMdDec->spar_md_cfg.num_umx_chs; IF( hSpar->hMdDec->td_decorr_flag && !( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) ) { @@ -2442,7 +2497,7 @@ void ivas_jbm_dec_feed_tc_to_renderer( move16(); } } - st_ivas->hTcBuffer->q_tc_fx = 14; + st_ivas->hTcBuffer->q_tc_fx = 11; for ( i = 0; i < ivas_sba_get_nchan_metadata( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ) + ch_sba_idx; i++ ) { floatToFixed_arrL( st_ivas->hTcBuffer->tc[i], st_ivas->hTcBuffer->tc_fx[i], st_ivas->hTcBuffer->q_tc_fx, min( nSamplesForRendering, (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ) ) ); @@ -2452,7 +2507,7 @@ void ivas_jbm_dec_feed_tc_to_renderer( if ( st_ivas->hDiracDecBin != NULL && ( st_ivas->hDiracDecBin->useTdDecorr ) ) { - st_ivas->hTcBuffer->q_tc_fx = 14; + st_ivas->hTcBuffer->q_tc_fx = 11; Word16 nSamplesLeftForTD, default_frame; default_frame = (Word16) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); nSamplesLeftForTD = nSamplesForRendering; @@ -2510,7 +2565,7 @@ void ivas_jbm_dec_feed_tc_to_renderer( if ( st_ivas->hDiracDecBin != NULL && ( st_ivas->hDiracDecBin->useTdDecorr ) ) { - st_ivas->hTcBuffer->q_tc_fx = 14; + st_ivas->hTcBuffer->q_tc_fx = 11; int16_t nSamplesLeftForTD, default_frame; default_frame = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); nSamplesLeftForTD = nSamplesForRendering; @@ -2549,12 +2604,8 @@ void ivas_jbm_dec_feed_tc_to_renderer( SPAR_DEC_HANDLE hSpar = st_ivas->hSpar; if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) { - //num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ); - //num_bands_out = hSpar->hFbMixer->pFb->filterbank_num_bands; nchan_transport = hSpar->hMdDec->spar_md_cfg.nchan_transport; - // num_out_ch = hSpar->hMdDec->spar_md_cfg.num_umx_chs; hSpar->hMdDec->Q_mixer_mat = 31; - //num_in_ch = hSpar->hMdDec->spar_md_cfg.num_umx_chs; IF( hSpar->hMdDec->td_decorr_flag && !( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) ) { @@ -2567,7 +2618,7 @@ void ivas_jbm_dec_feed_tc_to_renderer( move16(); } } - st_ivas->hTcBuffer->q_tc_fx = 14; + st_ivas->hTcBuffer->q_tc_fx = 11; for ( i = 0; i < ivas_sba_get_nchan_metadata( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ) + ch_sba_idx; i++ ) { floatToFixed_arrL( st_ivas->hTcBuffer->tc[i], st_ivas->hTcBuffer->tc_fx[i], st_ivas->hTcBuffer->q_tc_fx, min( nSamplesForRendering, (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ) ) ); @@ -2577,7 +2628,7 @@ void ivas_jbm_dec_feed_tc_to_renderer( if ( st_ivas->hDiracDecBin != NULL && ( st_ivas->hDiracDecBin->useTdDecorr ) ) { - st_ivas->hTcBuffer->q_tc_fx = 14; + st_ivas->hTcBuffer->q_tc_fx = 11; Word16 nSamplesLeftForTD, default_frame; default_frame = (Word16) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); nSamplesLeftForTD = nSamplesForRendering; @@ -2635,7 +2686,7 @@ void ivas_jbm_dec_feed_tc_to_renderer( if ( st_ivas->hDiracDecBin != NULL && ( st_ivas->hDiracDecBin->useTdDecorr ) ) { - st_ivas->hTcBuffer->q_tc_fx = 14; + st_ivas->hTcBuffer->q_tc_fx = 11; int16_t nSamplesLeftForTD, default_frame; default_frame = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); nSamplesLeftForTD = nSamplesForRendering; @@ -2657,10 +2708,7 @@ void ivas_jbm_dec_feed_tc_to_renderer( if ( ( ( st_ivas->ivas_format != SBA_FORMAT && st_ivas->ivas_format != SBA_ISM_FORMAT ) && st_ivas->nchan_transport == 1 && st_ivas->hSCE[0]->hCoreCoder[0] != NULL && st_ivas->hSCE[0]->hCoreCoder[0]->cna_dirac_flag ) || ( ( st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC ) && ( nchan_transport == 1 && st_ivas->nchan_transport != 2 && st_ivas->hSCE[0]->hCoreCoder[0] != NULL && st_ivas->hSCE[0]->hCoreCoder[0]->cng_sba_flag ) ) ) { - Decoder_State *st = st_ivas->hSCE[0]->hCoreCoder[0]; - //fixedToFloat_arrL(st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, st->hFdCngDec->hFdCngCom->olapBufferSynth2_flt, 15, st->hFdCngDec->hFdCngCom->fftlen); - - //fixedToFloat_arrL( st->hFdCngDec->hFdCngCom->exc_cng_32fx, st->hFdCngDec->hFdCngCom->exc_cng_flt, 31 - st->hFdCngDec->hFdCngCom->fftBuffer_exp - 9, st->hFdCngDec->hFdCngCom->frameSize ); + Decoder_State *st = st_ivas->hSCE[0]->hCoreCoder[0]; fixedToFloat_arrL( st_ivas->hTcBuffer->tc_fx[1], st_ivas->hTcBuffer->tc[1], 31 - st->hFdCngDec->hFdCngCom->fftBuffer_exp - 9, st->hFdCngDec->hFdCngCom->frameSize ); } #endif @@ -2677,9 +2725,7 @@ void ivas_jbm_dec_feed_tc_to_renderer( } else if ( st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) { - st_ivas->hTcBuffer->q_tc_fx = 11; - //for (int ch_idx = 0; ch_idx < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; ch_idx++) - //All transport channels retain same q11 function doesnt change ouptut q + st_ivas->hTcBuffer->q_tc_fx = 11; for (int ch_idx = 0; ch_idx < MAX_TRANSPORT_CHANNELS; ch_idx++) { floatToFixed_arrL(st_ivas->hTcBuffer->tc[ch_idx], st_ivas->hTcBuffer->tc_fx[ch_idx], st_ivas->hTcBuffer->q_tc_fx, L_FRAME48k); @@ -2694,7 +2740,6 @@ void ivas_jbm_dec_feed_tc_to_renderer( { #ifdef IVAS_FLOAT_FIXED Word16 cldfb_slots, j; - Word32 p_data_f_fx[MAX_CLDFB_DIGEST_CHANNELS][MAX_JBM_L_FRAME48k]; /* 'float' buffer for transport channels that will be directly converted with the CLDFB */ cldfb_slots = DEFAULT_JBM_CLDFB_TIMESLOTS; if (st_ivas->hDecoderConfig->Opt_tsm) { @@ -2788,12 +2833,8 @@ void ivas_jbm_dec_feed_tc_to_renderer( SPAR_DEC_HANDLE hSpar = st_ivas->hSpar; if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) { - //num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ); - //num_bands_out = hSpar->hFbMixer->pFb->filterbank_num_bands; nchan_transport = hSpar->hMdDec->spar_md_cfg.nchan_transport; - //num_out_ch = hSpar->hMdDec->spar_md_cfg.num_umx_chs; hSpar->hMdDec->Q_mixer_mat = 31; - //num_in_ch = hSpar->hMdDec->spar_md_cfg.num_umx_chs; IF( hSpar->hMdDec->td_decorr_flag && !( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) ) { @@ -2806,7 +2847,7 @@ void ivas_jbm_dec_feed_tc_to_renderer( move16(); } } - st_ivas->hTcBuffer->q_tc_fx = 14; + st_ivas->hTcBuffer->q_tc_fx = 11; for ( i = 0; i < ivas_sba_get_nchan_metadata( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ) + ch_sba_idx; i++ ) { floatToFixed_arrL( st_ivas->hTcBuffer->tc[i], st_ivas->hTcBuffer->tc_fx[i], st_ivas->hTcBuffer->q_tc_fx, min( nSamplesForRendering, (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ) ) ); @@ -2816,7 +2857,7 @@ void ivas_jbm_dec_feed_tc_to_renderer( if ( st_ivas->hDiracDecBin != NULL && ( st_ivas->hDiracDecBin->useTdDecorr ) ) { - st_ivas->hTcBuffer->q_tc_fx = 14; + st_ivas->hTcBuffer->q_tc_fx = 11; Word16 nSamplesLeftForTD, default_frame; default_frame = (Word16) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); nSamplesLeftForTD = nSamplesForRendering; @@ -2874,7 +2915,7 @@ void ivas_jbm_dec_feed_tc_to_renderer( if ( st_ivas->hDiracDecBin != NULL && ( st_ivas->hDiracDecBin->useTdDecorr ) ) { - st_ivas->hTcBuffer->q_tc_fx = 14; + st_ivas->hTcBuffer->q_tc_fx = 11; int16_t nSamplesLeftForTD, default_frame; default_frame = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); nSamplesLeftForTD = nSamplesForRendering; @@ -2896,12 +2937,9 @@ void ivas_jbm_dec_feed_tc_to_renderer( if (((st_ivas->ivas_format != SBA_FORMAT && st_ivas->ivas_format != SBA_ISM_FORMAT) && st_ivas->nchan_transport == 1 && st_ivas->hSCE[0]->hCoreCoder[0] != NULL && st_ivas->hSCE[0]->hCoreCoder[0]->cna_dirac_flag) || ((st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC) && (nchan_transport == 1 && st_ivas->nchan_transport != 2 && st_ivas->hSCE[0]->hCoreCoder[0] != NULL && st_ivas->hSCE[0]->hCoreCoder[0]->cng_sba_flag))) { - Decoder_State *st = st_ivas->hSCE[0]->hCoreCoder[0]; - //fixedToFloat_arrL(st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, st->hFdCngDec->hFdCngCom->olapBufferSynth2_flt, 15, st->hFdCngDec->hFdCngCom->fftlen); - - //fixedToFloat_arrL( st->hFdCngDec->hFdCngCom->exc_cng_32fx, st->hFdCngDec->hFdCngCom->exc_cng_flt, 31 - st->hFdCngDec->hFdCngCom->fftBuffer_exp - 9, st->hFdCngDec->hFdCngCom->frameSize ); + Decoder_State *st = st_ivas->hSCE[0]->hCoreCoder[0]; fixedToFloat_arrL( st_ivas->hTcBuffer->tc_fx[1], st_ivas->hTcBuffer->tc[1], 31 - st->hFdCngDec->hFdCngCom->fftBuffer_exp - 9, st->hFdCngDec->hFdCngCom->frameSize ); - } + } #endif } } @@ -6628,7 +6666,59 @@ Word16 ivas_jbm_dec_get_num_tc_channels_fx( * Copy interleaved transport chnannels to the correct buffers, update the TC * buffer handle *--------------------------------------------------------------------------*/ +#ifdef IVAS_FLOAT_FIXED +static void ivas_jbm_dec_copy_tc( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const Word16 nSamplesForRendering, /* i : number of samples to digest */ + Word16 *nSamplesResidual, /* o : number of samples that will be left for the next frame */ + Word32 *data, /* i : (interleaved) transport channel samples */ + Word32 *tc_digest_f[], /* o : samples that will be directly digested (e.g. by CLDFB) */ + Word16 data_q +) +{ + Word16 ch; + DECODER_TC_BUFFER_HANDLE hTcBuffer; + Word16 n_samples_still_available, m; + Word16 n_ch_full_copy; + Word16 n_ch_res_copy; + hTcBuffer = st_ivas->hTcBuffer; + n_samples_still_available = sub(hTcBuffer->n_samples_buffered, hTcBuffer->n_samples_rendered); + hTcBuffer->n_samples_buffered = add(add(n_samples_still_available, nSamplesForRendering), hTcBuffer->n_samples_discard); + hTcBuffer->n_samples_available = i_mult(hTcBuffer->n_samples_granularity, idiv1616( hTcBuffer->n_samples_buffered, hTcBuffer->n_samples_granularity )); + *nSamplesResidual = sub(hTcBuffer->n_samples_buffered, hTcBuffer->n_samples_available); + n_ch_full_copy = s_min( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full ); + n_ch_res_copy = sub(hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full); + + FOR ( ch = 0; ch < n_ch_full_copy; ch++ ) + { + set32_fx( hTcBuffer->tc_fx[ch], 0, hTcBuffer->n_samples_discard ); + Copy32( hTcBuffer->tc_fx[ch] + hTcBuffer->n_samples_rendered, hTcBuffer->tc_fx[ch] + hTcBuffer->n_samples_discard, n_samples_still_available ); + FOR ( m = 0; m < nSamplesForRendering; m++ ) + { + hTcBuffer->tc_fx[ch][n_samples_still_available + hTcBuffer->n_samples_discard + m] = data[m * st_ivas->hTcBuffer->nchan_transport_jbm + ch]; + } + } + + IF ( GT_16(n_ch_res_copy, 0 )) + { + FOR ( ; ch < hTcBuffer->nchan_transport_jbm; ch++ ) + { + Copy32( hTcBuffer->tc_fx[ch], tc_digest_f[ch], n_samples_still_available ); + FOR ( m = 0; m < nSamplesForRendering; m++ ) + { + tc_digest_f[ch][add(n_samples_still_available, m)] = data[add(imult1616(m, st_ivas->hTcBuffer->nchan_transport_jbm), ch)]; + } + Copy32( tc_digest_f[ch] + hTcBuffer->n_samples_available, hTcBuffer->tc_fx[ch], *nSamplesResidual ); + } + } + hTcBuffer->q_tc_fx = data_q; move16(); + hTcBuffer->n_samples_rendered = 0; move16(); + hTcBuffer->subframes_rendered = 0; move16(); + + return; +} +#else static void ivas_jbm_dec_copy_tc( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const int16_t nSamplesForRendering, /* i : number of samples to digest */ @@ -6679,7 +6769,7 @@ static void ivas_jbm_dec_copy_tc( return; } - +#endif /*--------------------------------------------------------------------------* * ivas_jbm_dec_get_render_granularity() @@ -7506,11 +7596,10 @@ void ivas_jbm_dec_tc_buffer_close( * * Close JBM transport channel buffer *--------------------------------------------------------------------------*/ - +#ifdef IVAS_FLOAT_FIXED void ivas_jbm_dec_td_renderers_adapt_subframes( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ) -#ifdef IVAS_FLOAT_FIXED { Word16 nMaxSlotsPerSubframe, nSlotsAvailable, tmp, exp, tmp1, tmp2, s1, s2; UWord16 nSlotsInLastSubframe, nSlotsInFirstSubframe; @@ -7539,7 +7628,6 @@ void ivas_jbm_dec_td_renderers_adapt_subframes( nSlotsAvailable -= nSlotsInFirstSubframe; } - // st_ivas->hTcBuffer->nb_subframes += (int16_t) ceilf( (float) nSlotsAvailable / (float) nMaxSlotsPerSubframe ); s1 = norm_s( nSlotsAvailable ) - 1; s2 = norm_s( nMaxSlotsPerSubframe ); @@ -7573,6 +7661,10 @@ void ivas_jbm_dec_td_renderers_adapt_subframes( return; } #else + +void ivas_jbm_dec_td_renderers_adapt_subframes( + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +) { int16_t nMaxSlotsPerSubframe, nSlotsAvailable; uint16_t nSlotsInLastSubframe, nSlotsInFirstSubframe; @@ -7610,8 +7702,6 @@ void ivas_jbm_dec_td_renderers_adapt_subframes( return; } #endif - - /*--------------------------------------------------------------------------* * ivas_jbm_dec_get_tc_buffer_mode() * @@ -8104,10 +8194,9 @@ static void ivas_jbm_dec_copy_masa_meta_to_buffer( * * Map input MASA metadata subframes to slots in JBM processing *--------------------------------------------------------------------------*/ - +#ifdef IVAS_FLOAT_FIXED static void ivas_jbm_masa_sf_to_slot_map( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ -#ifdef IVAS_FLOAT_FIXED const Word16 nCldfbTs /* i : number of CLDFB time slots */ ) { @@ -8144,6 +8233,8 @@ static void ivas_jbm_masa_sf_to_slot_map( return; } #else +static void ivas_jbm_masa_sf_to_slot_map( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const int16_t nCldfbTs /* i : number of CLDFB time slots */ ) { @@ -8175,7 +8266,6 @@ static void ivas_jbm_masa_sf_to_slot_map( } #endif - /*--------------------------------------------------------------------------* * ivas_jbm_masa_sf_to_sf_map() * diff --git a/lib_dec/ivas_ls_custom_dec.c b/lib_dec/ivas_ls_custom_dec.c index 25a0cec62223449396853758440b33703a32ff54..e10eab7717c1890dc7587ebf13ae0d3bf58c72a9 100644 --- a/lib_dec/ivas_ls_custom_dec.c +++ b/lib_dec/ivas_ls_custom_dec.c @@ -103,6 +103,7 @@ ivas_error ivas_ls_custom_open_fx( * Setup an IVAS_OUTPUT_SETUP_HANDLE from a custom loudspeaker setup *-------------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED void ivas_ls_custom_setup( IVAS_OUTPUT_SETUP_HANDLE hOutSetup, /* o : IVAS output setup handle */ LSSETUP_CUSTOM_STRUCT *hLsSetupCustom /* i : Custom loudspeaker setup handle */ // Removed const temporarily. Can be added later. @@ -111,18 +112,8 @@ void ivas_ls_custom_setup( hOutSetup->output_config = IVAS_AUDIO_CONFIG_LS_CUSTOM; hOutSetup->nchan_out_woLFE = hLsSetupCustom->num_spk; -#ifdef IVAS_FLOAT_FIXED - FOR(int ind = 0; ind < MAX_OUTPUT_CHANNELS; ind++) - { - hLsSetupCustom->ls_azimuth_fx[ind] = (Word32)(hLsSetupCustom->ls_azimuth[ind] * (1 << 22)); - hLsSetupCustom->ls_elevation_fx[ind] = (Word32)(hLsSetupCustom->ls_elevation[ind] * (1 << 22)); - } - hOutSetup->ls_azimuth_fx = hLsSetupCustom->ls_azimuth_fx; - hOutSetup->ls_elevation_fx = hLsSetupCustom->ls_elevation_fx; -#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 */ @@ -131,6 +122,7 @@ void ivas_ls_custom_setup( return; } +#endif #ifdef IVAS_FLOAT_FIXED void ivas_ls_custom_setup_fx( @@ -161,6 +153,7 @@ void ivas_ls_custom_setup_fx( * Initialize decoder output handles *-----------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED ivas_error ivas_ls_custom_output_init( Decoder_Struct *st_ivas /* i/o: IVAS decoder handle */ ) @@ -177,6 +170,7 @@ ivas_error ivas_ls_custom_output_init( return IVAS_ERR_OK; } +#endif #ifdef IVAS_FLOAT_FIXED ivas_error ivas_ls_custom_output_init_fx( diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index 424726a4dda9dbdaba0eee1b81882b68c2657710..97c5b57836ff304b10b1c1d55718a3bdc87d57f7 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -3126,11 +3126,45 @@ ivas_error ivas_masa_dec_reconfigure_fx( /*-----------------------------------------------------------------* * CLDFB instances *-----------------------------------------------------------------*/ - +#ifndef IVAS_FLOAT_FIXED IF( ( error = ivas_cldfb_dec_reconfig( st_ivas, st_ivas->nchan_transport, numCldfbAnalyses_old, numCldfbSyntheses_old ) ) != IVAS_ERR_OK ) { return error; } +#else +#if 1 + // Float to fix conversions for ivas_cldfb_dec_reconfig_fx + FOR( Word16 i = 0; i < 16; i++ ) + { + IF( st_ivas->cldfbAnaDec[i] ) + floatToFixed_arrL32( st_ivas->cldfbAnaDec[i]->cldfb_state, st_ivas->cldfbAnaDec[i]->cldfb_state_fx, 11, st_ivas->cldfbAnaDec[i]->cldfb_size ); + } + IF( st_ivas->hSpar ) + { + st_ivas->hSpar->hFbMixer->cldfb_cross_fade_q = Q_factor_arr( st_ivas->hSpar->hFbMixer->cldfb_cross_fade, 16 ); + floatToFixed_arr( st_ivas->hSpar->hFbMixer->cldfb_cross_fade, st_ivas->hSpar->hFbMixer->cldfb_cross_fade_fx, st_ivas->hSpar->hFbMixer->cldfb_cross_fade_q, 16 ); + } + IF( st_ivas->cldfbSynDec[0] ) + { + floatToFixed_arrL32( st_ivas->cldfbSynDec[0]->cldfb_state, st_ivas->cldfbSynDec[0]->cldfb_state_fx, Q11, st_ivas->cldfbSynDec[0]->cldfb_size ); + } +#endif + if ( ( error = ivas_cldfb_dec_reconfig_fx( st_ivas, st_ivas->nchan_transport, numCldfbAnalyses_old, numCldfbSyntheses_old ) ) != IVAS_ERR_OK ) + { + return error; + } +#if 1 + FOR( Word16 i = 0; i < 16; i++ ) + { + IF( st_ivas->cldfbAnaDec[i] ) + fixedToFloat_arrL32( st_ivas->cldfbAnaDec[i]->cldfb_state_fx, st_ivas->cldfbAnaDec[i]->cldfb_state, 11, st_ivas->cldfbAnaDec[i]->cldfb_size ); + } + IF( st_ivas->cldfbSynDec[0] ) + { + fixedToFloat_arrL32( st_ivas->cldfbSynDec[0]->cldfb_state_fx, st_ivas->cldfbSynDec[0]->cldfb_state, Q11, st_ivas->cldfbSynDec[0]->cldfb_size ); + } +#endif +#endif } /*-----------------------------------------------------------------* diff --git a/lib_dec/ivas_mc_paramupmix_dec.c b/lib_dec/ivas_mc_paramupmix_dec.c index 2e30eff0cd580cea0b148bae0fc3f94cadc22263..937c686c3f3153b238bc33cf442f736e5078b9db 100644 --- a/lib_dec/ivas_mc_paramupmix_dec.c +++ b/lib_dec/ivas_mc_paramupmix_dec.c @@ -168,8 +168,8 @@ void ivas_mc_paramupmix_dec_read_BS( void ivas_mc_paramupmix_dec_digest_tc( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint8_t nCldfbSlots, /* i : number of CLFBS slots in the transport channels*/ - const int16_t nSamplesForRendering /* i : number of samples provided */ + const UWord8 nCldfbSlots, /* i : number of CLFBS slots in the transport channels*/ + const Word16 nSamplesForRendering /* i : number of samples provided */ ) { MC_PARAMUPMIX_DEC_HANDLE hMCParamUpmix; diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 608dafe55c637881b54bd5a295d1c9f99fa5b411..031e9b251695bbcfc3b99d8ff79d2514c1a8481c 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -1562,11 +1562,45 @@ ivas_error ivas_sba_dec_reconfigure_fx( /*-----------------------------------------------------------------* * CLDFB instances *-----------------------------------------------------------------*/ - +#ifdef IVAS_FLOAT_FIXED +#if 1 + // Float to fix conversions for ivas_cldfb_dec_reconfig_fx + FOR( Word16 i = 0; i < 16; i++ ) + { + IF( st_ivas->cldfbAnaDec[i] ) + floatToFixed_arrL32( st_ivas->cldfbAnaDec[i]->cldfb_state, st_ivas->cldfbAnaDec[i]->cldfb_state_fx, 11, st_ivas->cldfbAnaDec[i]->cldfb_size ); + } + IF( st_ivas->hSpar ) + { + st_ivas->hSpar->hFbMixer->cldfb_cross_fade_q = Q_factor_arr( st_ivas->hSpar->hFbMixer->cldfb_cross_fade, 16 ); + floatToFixed_arr( st_ivas->hSpar->hFbMixer->cldfb_cross_fade, st_ivas->hSpar->hFbMixer->cldfb_cross_fade_fx, st_ivas->hSpar->hFbMixer->cldfb_cross_fade_q, 16 ); + } + IF( st_ivas->cldfbSynDec[0] ) + { + floatToFixed_arrL32( st_ivas->cldfbSynDec[0]->cldfb_state, st_ivas->cldfbSynDec[0]->cldfb_state_fx, Q11, st_ivas->cldfbSynDec[0]->cldfb_size ); + } +#endif + if ( ( error = ivas_cldfb_dec_reconfig_fx( st_ivas, nchan_transport_old, numCldfbAnalyses_old, numCldfbSyntheses_old ) ) != IVAS_ERR_OK ) + { + return error; + } +#if 1 + FOR( Word16 i = 0; i < 16; i++ ) + { + IF( st_ivas->cldfbAnaDec[i] ) + fixedToFloat_arrL32( st_ivas->cldfbAnaDec[i]->cldfb_state_fx, st_ivas->cldfbAnaDec[i]->cldfb_state, 11, st_ivas->cldfbAnaDec[i]->cldfb_size ); + } + IF( st_ivas->cldfbSynDec[0] ) + { + fixedToFloat_arrL32( st_ivas->cldfbSynDec[0]->cldfb_state_fx, st_ivas->cldfbSynDec[0]->cldfb_state, Q11, st_ivas->cldfbSynDec[0]->cldfb_size ); + } +#endif +#else if ( ( error = ivas_cldfb_dec_reconfig( st_ivas, nchan_transport_old, numCldfbAnalyses_old, numCldfbSyntheses_old ) ) != IVAS_ERR_OK ) { return error; } +#endif /*-----------------------------------------------------------------* * JBM TC buffers diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index e54f305465ee60763fd8b7b874b524ea8a4dbeb0..e9a06232a8e49455f62a84ec74b412227511c6da 100644 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -2680,7 +2680,7 @@ void ivas_spar_dec_digest_tc_fx( Word32 *pPcm_tmp[MAX_SPAR_INTERNAL_CHANNELS]; Word32 *p_tc[MAX_SPAR_INTERNAL_CHANNELS]; Word32 Pcm_tmp[MAX_SPAR_INTERNAL_CHANNELS][L_FRAME48k]; - Word16 q_format = Q14; + Word16 q_format = Q11; ch_sba_idx = 0; move16(); IF ( EQ_16(st_ivas->ivas_format, SBA_ISM_FORMAT )) diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 3594b94923fb565cac3ed75754995a7dc35921c1..ca390f8947d9bd3218cb1ad0b22202b1d03db936 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -1076,10 +1076,10 @@ typedef struct ivas_spar_dec_lib_t /* Data structure for SBA_ISM rendering */ typedef struct ivas_osba_data { - float **delayBuffer; #ifdef IVAS_FLOAT_FIXED - Word32 **delayBuffer_fx; /* Q11 */ -#endif + Word32 **delayBuffer_fx; +#endif // IVAS_FLOAT_FIXED + float **delayBuffer; int16_t delayBuffer_size; int16_t delayBuffer_nchan; diff --git a/lib_dec/jbm_pcmdsp_apa.c b/lib_dec/jbm_pcmdsp_apa.c index 328cfaab79595a0ebcef387bb3e917429446cf1a..8652b3034ed0d21dcf140775dcff480d263b4349 100644 --- a/lib_dec/jbm_pcmdsp_apa.c +++ b/lib_dec/jbm_pcmdsp_apa.c @@ -1894,12 +1894,14 @@ static bool shrink_frm( #ifdef IVAS_FLOAT_FIXED Word16 energyQ8; Word32 qualityQ16=0; - //ps->signalScaleForCorrelation += 2; + IF(ps->evs_compat_mode == false) + ps->signalScaleForCorrelation += 1; scaleSignal16( frm_in_fx, ps->frmInScaled, l_frm, ps->signalScaleForCorrelation ); findSynchResult = find_synch_fx( ps, ps->frmInScaled, l_frm, s_start, (uint16_t) ( s_end - s_start ), 0, l_seg, 0, &energyQ8, &qualityQ16, &xtract ); //energy = fixedToFloat( energyQ8, 8 ); quality = fixedToFloat( qualityQ16, 16 ); - //ps->signalScaleForCorrelation -= 2; + IF(ps->evs_compat_mode == false) + ps->signalScaleForCorrelation -= 1; #else findSynchResult = find_synch( ps, frm_in, l_frm, s_start, (uint16_t) ( s_end - s_start ), 0, l_seg, 0, &energy, &quality, &xtract ); #endif diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 9486ea931ad17ef650f93c79587f0d430653d539..2dcf5ab8aaa6d555fd178a17f7fd16dea41656a4 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -294,7 +294,7 @@ void IVAS_DEC_Close( IF( ( *phIvasDec )->st_ivas ) { - ivas_destroy_dec_fx( ( *phIvasDec )->st_ivas ); + ivas_destroy_dec( ( *phIvasDec )->st_ivas ); ( *phIvasDec )->st_ivas = NULL; } @@ -451,7 +451,7 @@ ivas_error IVAS_DEC_Configure( /* Set decoder parameters to initial values */ - IF( ( error = ivas_init_decoder_front_fx( st_ivas ) ) != IVAS_ERR_OK ) + IF( ( error = ivas_init_decoder_front( st_ivas ) ) != IVAS_ERR_OK ) { return error; } @@ -748,6 +748,27 @@ ivas_error IVAS_DEC_FeedFrame_Serial( IF( EQ_16( hIvasDec->mode, IVAS_DEC_MODE_EVS ) ) { #ifdef IVAS_FLOAT_FIXED + + DECODER_CONFIG_HANDLE hDecoderConfig = hIvasDec->st_ivas->hDecoderConfig; + AUDIO_CONFIG output_config = hDecoderConfig->output_config; + IF((hIvasDec->st_ivas->ivas_format == MC_FORMAT) && (hIvasDec->st_ivas->mc_mode == MC_MODE_PARAMMC)) + { + IF(output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM) + { + /*float2fix block: to be removed*/ + floatToFixed_arrL(hIvasDec->st_ivas->hLsSetupCustom->ls_azimuth, hIvasDec->st_ivas->hLsSetupCustom->ls_azimuth_fx, Q22, hIvasDec->st_ivas->hLsSetupCustom->num_spk); + floatToFixed_arrL(hIvasDec->st_ivas->hLsSetupCustom->ls_elevation, hIvasDec->st_ivas->hLsSetupCustom->ls_elevation_fx, Q22, hIvasDec->st_ivas->hLsSetupCustom->num_spk); + } + } + + IF(output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM) + { + FOR(Word16 ind = 0; ind < MAX_OUTPUT_CHANNELS; ind++) + { + hIvasDec->st_ivas->hLsSetupCustom->ls_azimuth_fx[ind] = (Word32)(hIvasDec->st_ivas->hLsSetupCustom->ls_azimuth[ind] * (1 << 22)); + hIvasDec->st_ivas->hLsSetupCustom->ls_elevation_fx[ind] = (Word32)(hIvasDec->st_ivas->hLsSetupCustom->ls_elevation[ind] * (1 << 22)); + } + } IF( ( error = ivas_init_decoder_fx( hIvasDec->st_ivas ) ) != IVAS_ERR_OK ) #else IF( ( error = ivas_init_decoder( hIvasDec->st_ivas ) ) != IVAS_ERR_OK ) @@ -755,6 +776,39 @@ ivas_error IVAS_DEC_FeedFrame_Serial( { return error; } +#ifdef IVAS_FLOAT_FIXED + Word32 ivas_total_brate = hIvasDec->st_ivas->hDecoderConfig->ivas_total_brate; + IF((hIvasDec->st_ivas->ivas_format == MC_FORMAT) && (hIvasDec->st_ivas->mc_mode == MC_MODE_PARAMMC)) { + PARAM_MC_DEC_HANDLE hParamMC; + hParamMC = hIvasDec->st_ivas->hParamMC; + Word16 nchan_out_transport, nchan_out_cov; + MC_LS_SETUP mc_ls_setup; + Word16 nchan_transport, i; + mc_ls_setup = ivas_mc_map_output_config_to_mc_ls_setup(hIvasDec->st_ivas->transport_config); + hIvasDec->st_ivas->nchan_transport = ivas_param_mc_getNumTransportChannels(ivas_total_brate, mc_ls_setup); + nchan_transport = hIvasDec->st_ivas->nchan_transport; + nchan_out_transport = hIvasDec->st_ivas->hTransSetup.nchan_out_woLFE + hIvasDec->st_ivas->hTransSetup.num_lfe; + IF (hParamMC->synthesis_conf == PARAM_MC_SYNTH_LS_CONV_COV || hParamMC->synthesis_conf == PARAM_MC_SYNTH_MONO_STEREO) + { + nchan_out_cov = hIvasDec->st_ivas->hOutSetup.nchan_out_woLFE + hIvasDec->st_ivas->hOutSetup.num_lfe; + move16(); + } + ELSE + { + nchan_out_cov = nchan_out_transport; + } + IF (hParamMC) + { + fixedToFloat_arrL(hParamMC->h_output_synthesis_params.proto_matrix_fx, hParamMC->h_output_synthesis_params.proto_matrix, 26, nchan_transport * nchan_out_cov); + FOR(i = 0; i < hParamMC->diff_proto_info->num_protos_diff; i++) + { + fixedToFloat_arrL(hParamMC->diff_proto_info->proto_fac_fx[i], hParamMC->diff_proto_info->proto_fac[i], 26, hParamMC->diff_proto_info->num_source_chan_diff[i]); + } + IF (hParamMC->hoa_encoder_fx) + fixedToFloat_arrL(hParamMC->hoa_encoder_fx, hParamMC->hoa_encoder, Q29, hIvasDec->st_ivas->hTransSetup.nchan_out_woLFE * MAX_INTERN_CHANNELS); + } + } +#endif IF( hIvasDec->hVoIP != NULL && hIvasDec->hVoIP->hCurrentDataUnit != NULL ) { @@ -1041,10 +1095,331 @@ static ivas_error IVAS_DEC_Setup( IF( EQ_16( st_ivas->bfi, 0 ) ) { + +#if 1 // flt to fix + Word16 n_samples_granularity; + + n_samples_granularity = NS2SA(st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS); + DECODER_TC_BUFFER_HANDLE hTcBuffer; + hTcBuffer = st_ivas->hTcBuffer; + DECODER_CONFIG_HANDLE hDecoderConfig = NULL; + Word16 numch_out_dirac = 0; + SPAR_DEC_HANDLE hSpar = NULL; + Word16 numch_in; + Word32 ivas_total_brate; + ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; + Word16 SrcInd[MAX_NUM_TDREND_CHANNELS]; + Word16 num_src = 0; + Word16 i; + Word16 old_ism_mode = ivas_omasa_ism_mode_select(st_ivas->hDecoderConfig->last_ivas_total_brate, st_ivas->nchan_ism); + Word16 new_ism_mode = ivas_omasa_ism_mode_select(st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_ism); + IF(EQ_16(is_DTXrate(ivas_total_brate), 0) && (!(EQ_16(st_ivas->ini_active_frame, 0) && NE_32(ivas_total_brate, FRAME_NO_DATA) && LT_32(ivas_total_brate, MASA_STEREO_MIN_BITRATE) && EQ_16(st_ivas->nCPE, 1))) && st_ivas->bit_stream[(ivas_total_brate / FRAMES_PER_SEC) - 1] && st_ivas->ivas_format == MASA_FORMAT && st_ivas->last_ivas_format == MASA_FORMAT && ((GT_32(ivas_total_brate, IVAS_SID_5k2) && NE_32(ivas_total_brate, st_ivas->hDecoderConfig->last_ivas_total_brate)) || EQ_16(st_ivas->ini_active_frame, 0))) + { + IF(EQ_16(st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC) || EQ_16(st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM) || EQ_16(st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC)) + { + IF(EQ_16(st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC) && NE_16(st_ivas->ism_mode, ISM_MASA_MODE_DISC)) + { + IF(LT_16(n_samples_granularity, st_ivas->hTcBuffer->n_samples_granularity)) + { + IF(st_ivas->hSbaIsmData) + { + FOR(Word16 ch_idx = 0; ch_idx < st_ivas->hSbaIsmData->delayBuffer_nchan; ch_idx++) + { + floatToFixed_arr32(st_ivas->hSbaIsmData->delayBuffer[ch_idx], st_ivas->hSbaIsmData->delayBuffer_fx[ch_idx], Q11, st_ivas->hSbaIsmData->delayBuffer_size); + } + } + hSpar = st_ivas->hSpar; + hDecoderConfig = st_ivas->hDecoderConfig; + numch_out_dirac = hDecoderConfig->nchan_out; + IF(hSpar) + { + numch_in = hSpar->hFbMixer->fb_cfg->num_in_chans; + FOR (Word16 in_ch = 0; in_ch < numch_in; in_ch++) + { + FOR (i = 0; i < st_ivas->cldfbAnaDec[in_ch]->p_filter_length - st_ivas->cldfbAnaDec[in_ch]->no_channels; i++) + { + st_ivas->cldfbAnaDec[in_ch]->cldfb_state_fx[i] = (Word32)(st_ivas->cldfbAnaDec[in_ch]->cldfb_state[i] * (1LL << (Q11))); + } + } + FOR(Word16 out_ch = 0; out_ch < numch_out_dirac; out_ch++) + { + IF(st_ivas->cldfbSynDec[out_ch]) + { + FOR(i = 0; i < st_ivas->cldfbSynDec[out_ch]->p_filter_length; i++) + { + st_ivas->cldfbSynDec[out_ch]->cldfb_state_fx[i] = float_to_fix(st_ivas->cldfbSynDec[out_ch]->cldfb_state[i], Q11); + } + } + } + } + Word16 n_tc; + IF (st_ivas->ivas_format == MASA_ISM_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT) + n_tc = st_ivas->nchan_ism; + ELSE + n_tc = st_ivas->hTcBuffer->nchan_transport_internal; + FOR (Word16 ch = 0; ch < n_tc; ch++) + { + floatToFixed_arrL(st_ivas->hTcBuffer->tc[ch], st_ivas->hTcBuffer->tc_fx[ch], Q11, L_FRAME48k); + } + } + } + } + } + + IF(EQ_16(is_DTXrate(ivas_total_brate), 0) && (!(EQ_16(st_ivas->ini_active_frame, 0) && NE_32(ivas_total_brate, FRAME_NO_DATA) && LT_32(ivas_total_brate, MASA_STEREO_MIN_BITRATE) && EQ_16(st_ivas->nCPE, 1))) && st_ivas->bit_stream[(ivas_total_brate / FRAMES_PER_SEC) - 1] && st_ivas->ivas_format == MASA_FORMAT && st_ivas->last_ivas_format != MASA_FORMAT && ((GT_32(ivas_total_brate, IVAS_SID_5k2) && NE_32(ivas_total_brate, st_ivas->hDecoderConfig->last_ivas_total_brate)) && EQ_16(st_ivas->ini_active_frame, 0))) + { + IF (old_ism_mode != new_ism_mode && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC) + { + // Float to fix conversions for ivas_td_binaural_open_fx + IF (st_ivas->ism_mode == ISM_MASA_MODE_DISC) + { + FOR(i = 0; i < 4; i++) + { + st_ivas->hRenderConfig->directivity_fx[i * 3] = (Word16)floatToFixed(st_ivas->hRenderConfig->directivity[i * 3], 6); + st_ivas->hRenderConfig->directivity_fx[i * 3 + 1] = (Word16)floatToFixed(st_ivas->hRenderConfig->directivity[i * 3 + 1], 6); + st_ivas->hRenderConfig->directivity_fx[i * 3 + 2] = (Word16)floatToFixed(st_ivas->hRenderConfig->directivity[i * 3 + 2], 15); + } + } + // Float to fix conversions for ivas_cldfb_dec_reconfig_fx + FOR(i = 0; i < 16; i++) + { + IF(st_ivas->cldfbAnaDec[i]) + floatToFixed_arrL(st_ivas->cldfbAnaDec[i]->cldfb_state, st_ivas->cldfbAnaDec[i]->cldfb_state_fx, 11, sub(st_ivas->cldfbAnaDec[i]->p_filter_length, st_ivas->cldfbAnaDec[i]->no_channels)); + } + IF(st_ivas->hSpar) + { + st_ivas->hSpar->hFbMixer->cldfb_cross_fade_q = Q_factor_arr(st_ivas->hSpar->hFbMixer->cldfb_cross_fade, 16); + floatToFixed_arr(st_ivas->hSpar->hFbMixer->cldfb_cross_fade, st_ivas->hSpar->hFbMixer->cldfb_cross_fade_fx, st_ivas->hSpar->hFbMixer->cldfb_cross_fade_q, 16); + } + IF(st_ivas->cldfbSynDec[0]) + { + floatToFixed_arrL(st_ivas->cldfbSynDec[0]->cldfb_state, st_ivas->cldfbSynDec[0]->cldfb_state_fx, Q11, sub(st_ivas->cldfbSynDec[0]->p_filter_length, st_ivas->cldfbSynDec[0]->no_channels)); + } + } + } + + IF(EQ_16(is_DTXrate(ivas_total_brate), 0) && st_ivas->ivas_format == MASA_ISM_FORMAT && GT_16(st_ivas->ini_frame, 0) && (GT_32(ivas_total_brate, IVAS_SID_5k2) && NE_32(ivas_total_brate, st_ivas->hDecoderConfig->last_ivas_total_brate)) && EQ_16(st_ivas->ini_active_frame, 0)) { + IF(old_ism_mode != new_ism_mode && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC) + { + IF(st_ivas->ism_mode == ISM_MASA_MODE_DISC) + { + FOR(i = 0; i < 4; i++) + { + st_ivas->hRenderConfig->directivity_fx[i * 3] = (Word16)floatToFixed(st_ivas->hRenderConfig->directivity[i * 3], 6); + st_ivas->hRenderConfig->directivity_fx[i * 3 + 1] = (Word16)floatToFixed(st_ivas->hRenderConfig->directivity[i * 3 + 1], 6); + st_ivas->hRenderConfig->directivity_fx[i * 3 + 2] = (Word16)floatToFixed(st_ivas->hRenderConfig->directivity[i * 3 + 2], 15); + } + } + // Float to fix conversions for ivas_cldfb_dec_reconfig_fx + FOR(i = 0; i < 16; i++) + { + IF(st_ivas->cldfbAnaDec[i]) + floatToFixed_arrL(st_ivas->cldfbAnaDec[i]->cldfb_state, st_ivas->cldfbAnaDec[i]->cldfb_state_fx, 11, sub(st_ivas->cldfbAnaDec[i]->p_filter_length, st_ivas->cldfbAnaDec[i]->no_channels)); + } + IF(st_ivas->hSpar) + { + st_ivas->hSpar->hFbMixer->cldfb_cross_fade_q = Q_factor_arr(st_ivas->hSpar->hFbMixer->cldfb_cross_fade, 16); + floatToFixed_arr(st_ivas->hSpar->hFbMixer->cldfb_cross_fade, st_ivas->hSpar->hFbMixer->cldfb_cross_fade_fx, st_ivas->hSpar->hFbMixer->cldfb_cross_fade_q, 16); + } + + IF(st_ivas->cldfbSynDec[0]) + { + floatToFixed_arrL(st_ivas->cldfbSynDec[0]->cldfb_state, st_ivas->cldfbSynDec[0]->cldfb_state_fx, Q11, sub(st_ivas->cldfbSynDec[0]->p_filter_length, st_ivas->cldfbSynDec[0]->no_channels)); + } + } + } + + IF(EQ_16(is_DTXrate(ivas_total_brate), 0) && (st_ivas->ivas_format == MC_FORMAT)) { + IF(st_ivas->hTcBuffer) + FOR(Word16 ch = 0; ch < st_ivas->hTcBuffer->nchan_transport_internal; ch++) + { + floatToFixed_arrL(st_ivas->hTcBuffer->tc[ch], st_ivas->hTcBuffer->tc_fx[ch], Q11, L_FRAME48k); + } + IF (st_ivas->mc_mode == MC_MODE_PARAMMC) + { + IF (st_ivas->hParamMC) + { + IF (st_ivas->hParamMC->diff_proto_info) { + FOR(i = 0; i < st_ivas->hParamMC->diff_proto_info->num_protos_diff; i++) + { + floatToFixed_arrL(st_ivas->hParamMC->diff_proto_info->proto_fac[i], st_ivas->hParamMC->diff_proto_info->proto_fac_fx[i], Q26, st_ivas->hParamMC->diff_proto_info->num_source_chan_diff[i]); + } + } + } + } + } + + hDecoderConfig = st_ivas->hDecoderConfig; + AUDIO_CONFIG output_config = hDecoderConfig->output_config; + IF((st_ivas->ivas_format == MC_FORMAT) && (st_ivas->mc_mode == MC_MODE_PARAMMC)) + { + IF(output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM) + { + /*float2fix block: to be removed*/ + floatToFixed_arrL(st_ivas->hLsSetupCustom->ls_azimuth, st_ivas->hLsSetupCustom->ls_azimuth_fx, Q22, st_ivas->hLsSetupCustom->num_spk); + floatToFixed_arrL(st_ivas->hLsSetupCustom->ls_elevation, st_ivas->hLsSetupCustom->ls_elevation_fx, Q22, st_ivas->hLsSetupCustom->num_spk); + } + } + + IF(output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM) + { + FOR(Word16 ind = 0; ind < MAX_OUTPUT_CHANNELS; ind++) + { + st_ivas->hLsSetupCustom->ls_azimuth_fx[ind] = (Word32)(st_ivas->hLsSetupCustom->ls_azimuth[ind] * (1 << 22)); + st_ivas->hLsSetupCustom->ls_elevation_fx[ind] = (Word32)(st_ivas->hLsSetupCustom->ls_elevation[ind] * (1 << 22)); + } + } +#endif IF( ( error = ivas_dec_setup( st_ivas, nSamplesRendered, data ) ) != IVAS_ERR_OK ) { return error; } +#if 1 // fix to float + IF((st_ivas->ivas_format == MC_FORMAT) && (st_ivas->mc_mode == MC_MODE_PARAMMC)) { + PARAM_MC_DEC_HANDLE hParamMC; + hParamMC = st_ivas->hParamMC; + Word16 nchan_out_transport, nchan_out_cov; + MC_LS_SETUP mc_ls_setup; + Word16 nchan_transport; + mc_ls_setup = ivas_mc_map_output_config_to_mc_ls_setup(st_ivas->transport_config); + st_ivas->nchan_transport = ivas_param_mc_getNumTransportChannels(ivas_total_brate, mc_ls_setup); + nchan_transport = st_ivas->nchan_transport; + nchan_out_transport = st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe; + IF(hParamMC->synthesis_conf == PARAM_MC_SYNTH_LS_CONV_COV || hParamMC->synthesis_conf == PARAM_MC_SYNTH_MONO_STEREO) + { + nchan_out_cov = st_ivas->hOutSetup.nchan_out_woLFE + st_ivas->hOutSetup.num_lfe; + move16(); + } + ELSE + { + nchan_out_cov = nchan_out_transport; + } + IF(hParamMC) + { + fixedToFloat_arrL(hParamMC->h_output_synthesis_params.proto_matrix_fx, hParamMC->h_output_synthesis_params.proto_matrix, 26, nchan_transport * nchan_out_cov); + IF (st_ivas->hParamMC->diff_proto_info) { + FOR(i = 0; i < hParamMC->diff_proto_info->num_protos_diff; i++) + { + fixedToFloat_arrL(hParamMC->diff_proto_info->proto_fac_fx[i], hParamMC->diff_proto_info->proto_fac[i], 26, hParamMC->diff_proto_info->num_source_chan_diff[i]); + } + } + IF(hParamMC->hoa_encoder_fx) + fixedToFloat_arrL(hParamMC->hoa_encoder_fx, hParamMC->hoa_encoder, Q29, st_ivas->hTransSetup.nchan_out_woLFE * MAX_INTERN_CHANNELS); + } + } + + IF(EQ_16(is_DTXrate(ivas_total_brate), 0) && (!(EQ_16(st_ivas->ini_active_frame, 0) && NE_32(ivas_total_brate, FRAME_NO_DATA) && LT_32(ivas_total_brate, MASA_STEREO_MIN_BITRATE) && EQ_16(st_ivas->nCPE, 1))) && st_ivas->bit_stream[(ivas_total_brate / FRAMES_PER_SEC) - 1] && st_ivas->ivas_format == MASA_FORMAT && st_ivas->last_ivas_format == MASA_FORMAT && ((GT_32(ivas_total_brate, IVAS_SID_5k2) && NE_32(ivas_total_brate, st_ivas->hDecoderConfig->last_ivas_total_brate)) || EQ_16(st_ivas->ini_active_frame, 0))) + { + IF (hTcBuffer->tc_buffer) + fixedToFloat_arrL(hTcBuffer->tc_buffer_fx, hTcBuffer->tc_buffer, Q11, hTcBuffer->tc_buff_len); + IF(hSpar) + { + numch_in = hSpar->hFbMixer->fb_cfg->num_in_chans; + FOR(Word16 in_ch = 0; in_ch < numch_in; in_ch++) + { + FOR(i = 0; i < st_ivas->cldfbAnaDec[in_ch]->p_filter_length - st_ivas->cldfbAnaDec[in_ch]->no_channels; i++) + { + st_ivas->cldfbAnaDec[in_ch]->cldfb_state[i] = ((float)(st_ivas->cldfbAnaDec[in_ch]->cldfb_state_fx[i]) / (1LL << (Q11))); /*Rounding off*/ + } + } + FOR(Word16 out_ch = 0; out_ch < numch_out_dirac; out_ch++) + { + IF(st_ivas->cldfbSynDec[out_ch]) + { + FOR(i = 0; i < st_ivas->cldfbSynDec[out_ch]->p_filter_length; i++) + { + st_ivas->cldfbSynDec[out_ch]->cldfb_state[i] = ((float)(st_ivas->cldfbSynDec[out_ch]->cldfb_state_fx[i]) / (float)(1LL << (Q11))); + } + } + } + } + } + + IF(EQ_16(is_DTXrate(ivas_total_brate), 0) && (!(EQ_16(st_ivas->ini_active_frame, 0) && NE_32(ivas_total_brate, FRAME_NO_DATA) && LT_32(ivas_total_brate, MASA_STEREO_MIN_BITRATE) && EQ_16(st_ivas->nCPE, 1))) && st_ivas->bit_stream[(ivas_total_brate / FRAMES_PER_SEC) - 1] && st_ivas->ivas_format == MASA_FORMAT && st_ivas->last_ivas_format != MASA_FORMAT && ((GT_32(ivas_total_brate, IVAS_SID_5k2) && NE_32(ivas_total_brate, st_ivas->hDecoderConfig->last_ivas_total_brate)) || EQ_16(st_ivas->ini_active_frame, 0))) { + IF(NE_16(new_ism_mode, old_ism_mode) && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC) + { + IF(EQ_16(st_ivas->ism_mode, ISM_MASA_MODE_DISC)) + { + Word16 nchan_rend = num_src; + IF(EQ_16(st_ivas->ivas_format, MC_FORMAT) && NE_16(st_ivas->transport_config, IVAS_AUDIO_CONFIG_LS_CUSTOM)) + { + nchan_rend--; /* Skip LFE channel -- added to the others */ + } + FOR(Word16 nS = 0; nS < nchan_rend; nS++) + { + TDREND_SRC_t *Src_p = st_ivas->hBinRendererTd->Sources[SrcInd[nS]]; + IF(Src_p->SrcSpatial_p != NULL) + { + Src_p->SrcSpatial_p->q_Pos_p = Q31; + } + TDREND_SRC_SPATIAL_t *SrcSpatial_p = st_ivas->hBinRendererTd->Sources[nS]->SrcSpatial_p; + SrcSpatial_p->q_Pos_p = Q31; + } + } + FOR(i = 0; i < 16; i++) + { + IF(st_ivas->cldfbAnaDec[i]) + fixedToFloat_arrL(st_ivas->cldfbAnaDec[i]->cldfb_state_fx, st_ivas->cldfbAnaDec[i]->cldfb_state, 11, sub(st_ivas->cldfbAnaDec[i]->p_filter_length, st_ivas->cldfbAnaDec[i]->no_channels)); + } + IF(st_ivas->cldfbSynDec[0]) + { + fixedToFloat_arrL(st_ivas->cldfbSynDec[0]->cldfb_state_fx, st_ivas->cldfbSynDec[0]->cldfb_state, Q11, sub(st_ivas->cldfbSynDec[0]->p_filter_length, st_ivas->cldfbSynDec[0]->no_channels)); + } + } + } + + + IF(EQ_16(is_DTXrate(ivas_total_brate), 0) && st_ivas->ivas_format == MASA_ISM_FORMAT && GT_16(st_ivas->ini_frame, 0) && (GT_32(ivas_total_brate, IVAS_SID_5k2) && NE_32(ivas_total_brate, st_ivas->hDecoderConfig->last_ivas_total_brate)) && EQ_16(st_ivas->ini_active_frame, 0)) { + IF(NE_16(new_ism_mode, old_ism_mode) && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC) + { + IF(EQ_16(st_ivas->ism_mode, ISM_MASA_MODE_DISC)) + { + Word16 nchan_rend = num_src; + IF(EQ_16(st_ivas->ivas_format, MC_FORMAT) && NE_16(st_ivas->transport_config, IVAS_AUDIO_CONFIG_LS_CUSTOM)) + { + nchan_rend--; /* Skip LFE channel -- added to the others */ + } + FOR(Word16 nS = 0; nS < nchan_rend; nS++) + { + TDREND_SRC_t *Src_p = st_ivas->hBinRendererTd->Sources[SrcInd[nS]]; + IF(Src_p->SrcSpatial_p != NULL) + { + Src_p->SrcSpatial_p->q_Pos_p = Q31; + } + TDREND_SRC_SPATIAL_t *SrcSpatial_p = st_ivas->hBinRendererTd->Sources[nS]->SrcSpatial_p; + SrcSpatial_p->q_Pos_p = Q31; + } + } + FOR(i = 0; i < 16; i++) + { + IF(st_ivas->cldfbAnaDec[i]) + fixedToFloat_arrL(st_ivas->cldfbAnaDec[i]->cldfb_state_fx, st_ivas->cldfbAnaDec[i]->cldfb_state, 11, sub(st_ivas->cldfbAnaDec[i]->p_filter_length, st_ivas->cldfbAnaDec[i]->no_channels)); + } + IF(st_ivas->cldfbSynDec[0]) + { + fixedToFloat_arrL(st_ivas->cldfbSynDec[0]->cldfb_state_fx, st_ivas->cldfbSynDec[0]->cldfb_state, Q11, sub(st_ivas->cldfbSynDec[0]->p_filter_length, st_ivas->cldfbSynDec[0]->no_channels)); + } + } + } + + IF(EQ_16(is_DTXrate(ivas_total_brate), 0) && (st_ivas->ivas_format == MC_FORMAT)) { + IF (st_ivas->mc_mode == MC_MODE_PARAMMC) + { + IF (st_ivas->hParamMC) + { + fixedToFloat_arrL(st_ivas->hParamMC->h_output_synthesis_params.proto_matrix_fx, st_ivas->hParamMC->h_output_synthesis_params.proto_matrix, 26, st_ivas->hParamMC->h_output_synthesis_params.proto_matrix_len); + IF(st_ivas->hParamMC->diff_proto_info) + FOR(i = 0; i < st_ivas->hParamMC->diff_proto_info->num_protos_diff; i++) + { + fixedToFloat_arrL(st_ivas->hParamMC->diff_proto_info->proto_fac_fx[i], st_ivas->hParamMC->diff_proto_info->proto_fac[i], 26, st_ivas->hParamMC->diff_proto_info->num_source_chan_diff[i]); + } + IF (st_ivas->hParamMC->hoa_encoder_fx) + fixedToFloat_arrL(st_ivas->hParamMC->hoa_encoder_fx, st_ivas->hParamMC->hoa_encoder, Q29, st_ivas->hTransSetup.nchan_out_woLFE * MAX_INTERN_CHANNELS); + } + } + } +#endif + } *nTransportChannels = (UWord8) st_ivas->hTcBuffer->nchan_transport_jbm; diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index 9fc7edc06eaf87cf75d0c833683ed5ac4f8a94ba..831c127e375e63f7ce99c04349a70d76be5ef0d8 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -668,16 +668,13 @@ ivas_error ivas_dirac_dec_binaural_copy_hrtfs( { for ( j = 0; j < HRTF_SH_CHANNELS; j++ ) { - mvr2r( hrtfShCoeffsRe[i][j], hrtfParambin->hrtfShCoeffsRe[i][j], HRTF_NUM_BINS ); - mvr2r( hrtfShCoeffsIm[i][j], hrtfParambin->hrtfShCoeffsIm[i][j], HRTF_NUM_BINS ); + Copy( hrtfShCoeffsRe_fx[i][j], hrtfParambin->hrtfShCoeffsRe_fx[i][j], HRTF_NUM_BINS ); + Copy( hrtfShCoeffsIm_fx[i][j], hrtfParambin->hrtfShCoeffsIm_fx[i][j], HRTF_NUM_BINS ); } } - mvl2l( parametricReverberationTimes_fx, hrtfParambin->parametricReverberationTimes_fx, CLDFB_NO_CHANNELS_MAX ); - mvl2l( parametricReverberationEneCorrections_fx, hrtfParambin->parametricReverberationEneCorrections_fx, CLDFB_NO_CHANNELS_MAX ); - - mvr2r( parametricReverberationTimes, hrtfParambin->parametricReverberationTimes, CLDFB_NO_CHANNELS_MAX ); - mvr2r( parametricReverberationEneCorrections, hrtfParambin->parametricReverberationEneCorrections, CLDFB_NO_CHANNELS_MAX ); + Copy32( parametricReverberationTimes_fx, hrtfParambin->parametricReverberationTimes_fx, CLDFB_NO_CHANNELS_MAX ); + Copy32( parametricReverberationEneCorrections_fx, hrtfParambin->parametricReverberationEneCorrections_fx, CLDFB_NO_CHANNELS_MAX ); mvr2r( parametricEarlyPartEneCorrection, hrtfParambin->parametricEarlyPartEneCorrection, CLDFB_NO_CHANNELS_MAX ); *hHrtfParambin = hrtfParambin; diff --git a/lib_rend/ivas_dirac_decorr_dec.c b/lib_rend/ivas_dirac_decorr_dec.c index 398a636883c9c423f00dedae8359827d980254cc..215aaef916553d5ef8f5037c08bc7b1155957d2e 100644 --- a/lib_rend/ivas_dirac_decorr_dec.c +++ b/lib_rend/ivas_dirac_decorr_dec.c @@ -1063,7 +1063,6 @@ void ivas_dirac_dec_decorr_process_fx( h_freq_domain_decorr_ap_state->h_onset_detection_power_state.q_onset_detector = q_temp; ivas_dirac_dec_onset_detection_process_fx( aux_buffer_fx, q_aux_buffer, onset_filter_fx, num_protos_diff, h_freq_domain_decorr_ap_params->h_onset_detection_power_params, h_freq_domain_decorr_ap_state->h_onset_detection_power_state ); - // q_onset_filter is Q31// /* Apply decorrelator if num_channels is greater than 0 */ IF( GT_16( num_channels, 0 ) ) diff --git a/lib_rend/ivas_dirac_output_synthesis_dec.c b/lib_rend/ivas_dirac_output_synthesis_dec.c index 36bb841ac4c10b5de1e5cdd25e482dde4b731943..5b6d456033c1e8f4bb115f5dfae57bd7f81a7deb 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec.c @@ -59,7 +59,12 @@ #define DIRAC_ALPHA_MAX_FAST 0.12f #define DIRAC_ALPHA_MAX_FAST_Q15 3932 #define DIRECTION_SMOOTHNESS_ALPHA 0.01f -#define DIRECTION_SMOOTHNESS_ALPHA_Q31 (Word32)(0.01f * ONE_IN_Q31) +#define DIRECTION_SMOOTHNESS_ALPHA_Q31 ( Word32 )( 0.01f * ONE_IN_Q31 ) + +#ifdef IVAS_FLOAT_FIXED +#define POINT_3679_Q31 790059234 +#define POINT_1175_Q31 252329329 +#endif /*------------------------------------------------------------------------- * Local function prototypes @@ -158,16 +163,10 @@ ivas_error ivas_dirac_dec_output_synthesis_open_fx( * memory allocation *-----------------------------------------------------------------*/ - dirac_output_synthesis_state->diffuse_responses_square = NULL; dirac_output_synthesis_state->diffuse_responses_square_fx = NULL; IF ( hDirACRend->synthesisConf == DIRAC_SYNTHESIS_MONO ) { - /*TODO : remove float code*/ - if ( ( dirac_output_synthesis_state->diffuse_responses_square = (float *) malloc( 2 * sizeof( float ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis\n" ) ); - } IF( ( dirac_output_synthesis_state->diffuse_responses_square_fx = (Word32 *) malloc( 2 * sizeof( Word32 ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis\n" ) ); @@ -175,11 +174,6 @@ ivas_error ivas_dirac_dec_output_synthesis_open_fx( } ELSE IF ( hDirACRend->synthesisConf != DIRAC_SYNTHESIS_GAIN_SHD ) { - /*TODO : remove float code*/ - if ( ( dirac_output_synthesis_state->diffuse_responses_square = (float *) malloc( hDirACRend->hOutSetup.nchan_out_woLFE * sizeof( float ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis\n" ) ); - } IF( ( dirac_output_synthesis_state->diffuse_responses_square_fx = (Word32 *) malloc( hDirACRend->hOutSetup.nchan_out_woLFE * sizeof( Word32 ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis\n" ) ); @@ -395,28 +389,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->direction_smoothness_prev_fx, 0, hSpatParamRendCom->num_freq_bands ); - - if ((dirac_output_synthesis_state->reference_power_smooth_prev = (float *)malloc(hSpatParamRendCom->num_freq_bands * sizeof(float))) == NULL) - { - return (IVAS_ERROR(IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis\n")); - } - if ((dirac_output_synthesis_state->direction_smoothness_prev = (float *)malloc(hSpatParamRendCom->num_freq_bands * sizeof(float))) == NULL) - { - return (IVAS_ERROR(IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis\n")); - } - set_zero(dirac_output_synthesis_state->reference_power_smooth_prev, hSpatParamRendCom->num_freq_bands); - set_zero(dirac_output_synthesis_state->direction_smoothness_prev, hSpatParamRendCom->num_freq_bands); } ELSE { - dirac_output_synthesis_state->reference_power_smooth_prev = NULL; - dirac_output_synthesis_state->direction_smoothness_prev = NULL; -#ifdef IVAS_FLOAT_FIXED dirac_output_synthesis_params->alpha_synthesis_fx = NULL; dirac_output_synthesis_params->alpha_synthesis_fast_fx = NULL; dirac_output_synthesis_state->reference_power_smooth_prev_fx = NULL; dirac_output_synthesis_state->direction_smoothness_prev_fx = NULL; -#endif } /* compute interpolator */ @@ -441,12 +420,10 @@ ivas_error ivas_dirac_dec_output_synthesis_open_fx( { /*dirac_output_synthesis_state->diffuse_responses_square[ch_idx] = pow(dirac_output_synthesis_params->diffuse_response_function[ch_idx]/max_response, 2.0f);*/ tmp_fx = hDirACRend->diffuse_response_function_fx[ch_idx]; - - dirac_output_synthesis_state->diffuse_responses_square_fx[ch_idx] = L_deposit_h( mult( tmp_fx, tmp_fx ) ); - dirac_output_synthesis_state->diffuse_responses_square_q = Q31; move16(); - /*TODO : remove floating code*/ - dirac_output_synthesis_state->diffuse_responses_square[ch_idx] = fixedToFloat( dirac_output_synthesis_state->diffuse_responses_square_fx[ch_idx], Q31 ); + + dirac_output_synthesis_state->diffuse_responses_square_fx[ch_idx] = L_mult( tmp_fx, tmp_fx ); /* Q15 + Q15 -> Q31 */ + move32(); } } @@ -1080,24 +1057,6 @@ void ivas_dirac_dec_output_synthesis_close_fx( * memory deallocation *-----------------------------------------------------------------*/ - if ((dirac_output_synthesis_state)->reference_power_smooth_prev != NULL) - { - free((dirac_output_synthesis_state)->reference_power_smooth_prev); - (dirac_output_synthesis_state)->reference_power_smooth_prev = NULL; - } - - if ((dirac_output_synthesis_state)->direction_smoothness_prev != NULL) - { - free((dirac_output_synthesis_state)->direction_smoothness_prev); - (dirac_output_synthesis_state)->direction_smoothness_prev = NULL; - } - - if ((dirac_output_synthesis_state)->diffuse_responses_square != NULL) - { - free((dirac_output_synthesis_state)->diffuse_responses_square); - (dirac_output_synthesis_state)->diffuse_responses_square = NULL; - } - /* free power buffers */ if ((dirac_output_synthesis_state)->proto_power_smooth_prev != NULL) { @@ -1951,7 +1910,7 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( DIRAC_REND_HANDLE hDirACRend, /* i/o: DirAC renderer handle */ const Word16 nchan_transport, /* i : number of transport channels */ const Word16 nbslots, /* i : number of slots to process */ - const Word32 *onset_filter, // Q30 + const Word32 *onset_filter, /* Q31 */ Word32 *diffuseness, // Q30 const Word16 hodirac_flag, /* i : flag to indicate HO-DirAC mode */ const Word16 dec_param_estim, @@ -2204,14 +2163,14 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( { FOR( l = 0; l < num_freq_bands; l++ ) { - g1 = L_add( (Word32) ( 0.3679f * ONE_IN_Q30 ), + g1 = L_add( POINT_3679_Q31, Mpy_32_32( onset_filter[l], - L_sub( (Word32) ( 0.1175f * ONE_IN_Q31 ), (Word32) ( 0.3679f * ONE_IN_Q31 ) ) ) ); // Q30, (Q30, Q31) -> Q30 - g2 = Mpy_32_32( L_sub( ONE_IN_Q30, g1 ), *( p_gains_dir ) ); //(Q30, p_gains_dir_q) -> (p_gains_dir_q - Q1) - g2 = L_add_sat( g2, Mpy_32_32( g1, ( *( p_cy_cross_dir_smooth++ ) ) ) ); // (p_gains_dir_q - Q1), (Q30, p_gains_dir_q) -> (p_gains_dir_q - Q1) - g2 = L_max( g2, (Word32) ( 0.99f * L_shl( 1, sub( h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev, Q1 ) ) ) ); //(p_gains_dir_q - Q1) - g2 = L_min( g2, (Word32) ( 2.0f * L_shl( 1, sub( h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev, Q1 ) ) ) ); //(p_gains_dir_q - Q1) - *( p_gains_dir++ ) = g2; //(p_gains_dir_q - Q1) + L_sub( POINT_1175_Q31, POINT_3679_Q31 ) ) ); // Q31, (Q31, Q31) -> Q31 + g2 = Mpy_32_32( L_sub( ONE_IN_Q31, g1 ), *( p_gains_dir ) ); // (Q31, p_gains_dir_q) -> p_gains_dir_q + g2 = L_add_sat( g2, Mpy_32_32( g1, ( *( p_cy_cross_dir_smooth++ ) ) ) ); // p_gains_diff_q, (Q31, p_gains_diff_q) -> p_gains_diff_q + g2 = L_max( g2, (Word32) ( 0.99f * L_shl( 1, h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev ) ) ); // p_gains_dir_q + g2 = L_min( g2, (Word32) ( 2.0f * L_shl( 1, h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev ) ) ); // p_gains_dir_q + *( p_gains_dir++ ) = g2; // p_gains_dir_q move32(); } } @@ -2222,14 +2181,14 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( { FOR( l = 0; l < num_freq_bands; l++ ) { - g1 = L_add( (Word32) ( 0.3679f * ONE_IN_Q30 ), + g1 = L_add( POINT_3679_Q31, Mpy_32_32( onset_filter[l], - L_sub( (Word32) ( 0.1175f * ONE_IN_Q31 ), (Word32) ( 0.3679f * ONE_IN_Q31 ) ) ) ); // Q30, (Q30, Q31) -> Q30 - g2 = Mpy_32_32( L_sub( ONE_IN_Q30, g1 ), *( p_gains_dir ) ); //(Q30, p_gains_dir_q) -> (p_gains_dir_q - Q1) - g2 = L_add_sat( g2, Mpy_32_32( g1, ( *( p_cy_cross_dir_smooth++ ) ) ) ); // (p_gains_dir_q - Q1), (Q30, p_gains_dir_q) -> (p_gains_dir_q - Q1) - g2 = L_max( g2, (Word32) ( 0.85f * L_shl( 1, sub( h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev, Q1 ) ) ) ); //(p_gains_dir_q - Q1) - g2 = L_min( g2, (Word32) ( 1.15f * L_shl( 1, sub( h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev, Q1 ) ) ) ); //(p_gains_dir_q - Q1) - *( p_gains_dir++ ) = g2; //(p_gains_dir_q - Q1) + L_sub( POINT_1175_Q31, POINT_3679_Q31 ) ) ); // Q31, (Q31, Q31) -> Q31 + g2 = Mpy_32_32( L_sub( ONE_IN_Q31, g1 ), *( p_gains_dir ) ); // (Q31, p_gains_dir_q) -> p_gains_dir_q + g2 = L_add_sat( g2, Mpy_32_32( g1, ( *( p_cy_cross_dir_smooth++ ) ) ) ); // p_gains_diff_q, (Q31, p_gains_diff_q) -> p_gains_diff_q + g2 = L_max( g2, (Word32) ( 0.85f * L_shl( 1, h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev ) ) ); // p_gains_dir_q + g2 = L_min( g2, (Word32) ( 1.15f * L_shl( 1, h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev ) ) ); // p_gains_dir_q + *( p_gains_dir++ ) = g2; // p_gains_dir_q move32(); } } @@ -2240,14 +2199,14 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( { FOR( l = 0; l < num_freq_bands; l++ ) { - g1 = L_add( (Word32) ( 0.3679f * ONE_IN_Q30 ), + g1 = L_add( POINT_3679_Q31, Mpy_32_32( onset_filter[l], - L_sub( (Word32) ( 0.1175f * ONE_IN_Q31 ), (Word32) ( 0.3679f * ONE_IN_Q31 ) ) ) ); // Q30, (Q30, Q31) -> Q30 - g2 = Mpy_32_32( L_sub( ONE_IN_Q30, g1 ), *( p_gains_dir ) ); //(Q30, p_gains_dir_q) -> (p_gains_dir_q - Q1) - g2 = L_add_sat( g2, Mpy_32_32( g1, ( *( p_cy_cross_dir_smooth++ ) ) ) ); // (p_gains_dir_q - Q1), (Q30, p_gains_dir_q) -> (p_gains_dir_q - Q1) - g2 = L_max( g2, (Word32) ( -DIRAC_GAIN_LIMIT * L_shl( 1, sub( h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev, Q1 ) ) ) ); //(p_gains_dir_q - Q1) - g2 = L_min( g2, (Word32) ( DIRAC_GAIN_LIMIT * L_shl( 1, sub( h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev, Q1 ) ) ) ); //(p_gains_dir_q - Q1) - *( p_gains_dir++ ) = g2; //(p_gains_dir_q - Q1) + L_sub( POINT_1175_Q31, POINT_3679_Q31 ) ) ); // Q31, (Q31, Q31) -> Q31 + g2 = Mpy_32_32( L_sub( ONE_IN_Q31, g1 ), *( p_gains_dir ) ); // (Q31, p_gains_dir_q) -> p_gains_dir_q + g2 = L_add_sat( g2, Mpy_32_32( g1, ( *( p_cy_cross_dir_smooth++ ) ) ) ); // p_gains_diff_q, (Q31, p_gains_diff_q) -> p_gains_diff_q + g2 = L_max( g2, (Word32) ( -DIRAC_GAIN_LIMIT * L_shl( 1, h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev ) ) ); // p_gains_dir_q + g2 = L_min( g2, (Word32) ( DIRAC_GAIN_LIMIT * L_shl( 1, h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev ) ) ); // p_gains_dir_q + *( p_gains_dir++ ) = g2; // p_gains_dir_q move32(); } } @@ -2272,14 +2231,14 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( { FOR( l = 0; l < num_freq_bands; l++ ) { - g1 = L_add( (Word32) ( 0.3679f * ONE_IN_Q30 ), + g1 = L_add( POINT_3679_Q31, Mpy_32_32( onset_filter[l], - L_sub( (Word32) ( 0.1175f * ONE_IN_Q31 ), (Word32) ( 0.3679f * ONE_IN_Q31 ) ) ) ); // Q30, (Q30, Q31) -> Q30 - g2 = Mpy_32_32( L_sub( ONE_IN_Q30, g1 ), *( p_gains_dir ) ); //(Q30, p_gains_dir_q) -> (p_gains_dir_q - Q1) - g2 = L_add_sat( g2, Mpy_32_32( g1, ( *( p_cy_cross_dir_smooth++ ) ) ) ); // (p_gains_dir_q - Q1), (Q30, p_gains_dir_q) -> (p_gains_dir_q - Q1) - g2 = L_max( g2, (Word32) ( -DIRAC_GAIN_LIMIT * L_shl( 1, sub( h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev, Q1 ) ) ) ); //(p_gains_dir_q - Q1) - g2 = L_min( g2, (Word32) ( DIRAC_GAIN_LIMIT * L_shl( 1, sub( h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev, Q1 ) ) ) ); //(p_gains_dir_q - Q1) - *( p_gains_dir++ ) = g2; //(p_gains_dir_q - Q1) + L_sub( POINT_1175_Q31, POINT_3679_Q31 ) ) ); // Q31, (Q31, Q31) -> Q31 + g2 = Mpy_32_32( L_sub( ONE_IN_Q31, g1 ), *( p_gains_dir ) ); // (Q31, p_gains_dir_q) -> p_gains_dir_q + g2 = L_add_sat( g2, Mpy_32_32( g1, ( *( p_cy_cross_dir_smooth++ ) ) ) ); // (p_gains_diff_q, (Q31, p_gains_diff_q) -> p_gains_diff_q + g2 = L_max( g2, (Word32) ( -DIRAC_GAIN_LIMIT * L_shl( 1, h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev ) ) ); // p_gains_dir_q + g2 = L_min( g2, (Word32) ( DIRAC_GAIN_LIMIT * L_shl( 1, h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev ) ) ); // p_gains_dir_q + *( p_gains_dir++ ) = g2; // p_gains_dir_q move32(); } } @@ -2292,8 +2251,8 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( { FOR( l = 0; l < num_freq_bands_diff; l++ ) { - g1 = (Word32) ( 0.1175f * ONE_IN_Q31 ); // Q31 - g2 = Mpy_32_32( L_sub( ONE_IN_Q31, g1 ), *( p_gains_diff ) ); //(Q31, p_gains_diff_q) -> p_gains_diff_q + g1 = POINT_1175_Q31; // Q31 + g2 = Mpy_32_32( L_sub( ONE_IN_Q31, g1 ), *( p_gains_diff ) ); // (Q31, p_gains_dir_q) -> p_gains_dir_q g2 = L_add_sat( g2, Mpy_32_32( g1, ( *( p_cy_auto_diff_smooth++ ) ) ) ); // p_gains_diff_q, (Q31, p_gains_diff_q) -> p_gains_diff_q g2 = L_max( g2, 0 ); // p_gains_diff_q g2 = L_min( g2, (Word32) ( DIRAC_GAIN_LIMIT * L_shl( 1, h_dirac_output_synthesis_state.q_cy_auto_diff_smooth_prev ) ) ); // p_gains_diff_q @@ -2312,15 +2271,15 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( g2 = L_sub( ONE_IN_Q31, g1 ); // Q31 /*Direct input->output*/ - p_gains_dir = h_dirac_output_synthesis_state.cy_cross_dir_smooth_prev_fx; // (p_gains_dir_q - 1) + p_gains_dir = h_dirac_output_synthesis_state.cy_cross_dir_smooth_prev_fx; // (p_gains_dir_q) p_gains_dir_prev = h_dirac_output_synthesis_state.gains_dir_prev_fx; FOR( ch_idx = 0; ch_idx < num_channels_dir; ch_idx++ ) { Scale_sig32( &h_dirac_output_synthesis_state.gains_dir_prev_fx[ch_idx * num_freq_bands], num_freq_bands, - sub( sub( h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev, Q1 ), h_dirac_output_synthesis_state.gains_dir_prev_q ) ); + sub( h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev, h_dirac_output_synthesis_state.gains_dir_prev_q ) ); } - h_dirac_output_synthesis_state.gains_dir_prev_q = sub( h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev, Q1 ); + h_dirac_output_synthesis_state.gains_dir_prev_q = h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev; FOR( ch_idx = 0; ch_idx < nchan_transport_foa; ch_idx++ ) { @@ -2330,11 +2289,11 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( FOR( l = 0; l < num_freq_bands; l++ ) { g = L_add( Mpy_32_32( g1, ( *( p_gains_dir++ ) ) ), - Mpy_32_32( g2, ( *( p_gains_dir_prev++ ) ) ) ); // (Q31, p_gains_dir_q - 1) -> (p_gains_dir_q - 1) + Mpy_32_32( g2, ( *( p_gains_dir_prev++ ) ) ) ); // (Q31, p_gains_dir_q) -> (p_gains_dir_q) - output_real[l * num_channels_dir + ch_idx] = Mpy_32_32( g, ( *( p_proto_diff++ ) ) ); // (p_gains_dir_q - 1, p_proto_diff_q) -> (p_gains_dir_q + p_proto_diff_q - 32) + output_real[l * num_channels_dir + ch_idx] = Mpy_32_32( g, ( *( p_proto_diff++ ) ) ); // (p_gains_dir_q, p_proto_diff_q) -> (p_gains_dir_q + p_proto_diff_q - 31) move32(); - output_imag[l * num_channels_dir + ch_idx] = Mpy_32_32( g, ( *( p_proto_diff++ ) ) ); // (p_gains_dir_q - 1, p_proto_diff_q) -> (p_gains_dir_q + p_proto_diff_q - 32) + output_imag[l * num_channels_dir + ch_idx] = Mpy_32_32( g, ( *( p_proto_diff++ ) ) ); // (p_gains_dir_q, p_proto_diff_q) -> (p_gains_dir_q + p_proto_diff_q - 31) move32(); } } @@ -2357,13 +2316,13 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( FOR( l = 0; l < num_freq_bands; l++ ) { gs1 = L_add( Mpy_32_32( g1, ( *( p_gains_dir ) ) ), - Mpy_32_32( g2, ( *( p_gains_dir_prev ) ) ) ); // (Q31, p_gains_dir_q - 1) -> (p_gains_dir_q - 1) + Mpy_32_32( g2, ( *( p_gains_dir_prev ) ) ) ); // (Q31, p_gains_dir_q) -> (p_gains_dir_q) gs2 = L_add( Mpy_32_32( g1, ( *( p_gains_dir + num_freq_bands * num_channels_dir ) ) ), - Mpy_32_32( g2, ( *( p_gains_dir_prev + num_freq_bands * num_channels_dir ) ) ) ); // (Q31, p_gains_dir_q - 1) -> (p_gains_dir_q - 1) + Mpy_32_32( g2, ( *( p_gains_dir_prev + num_freq_bands * num_channels_dir ) ) ) ); // (Q31, p_gains_dir_q) -> (p_gains_dir_q) p_gains_dir++; p_gains_dir_prev++; - // ((p_gains_dir_q - 1, p_proto_dir_q - 1) >> 1) -> (p_gains_dir_q + p_proto_dir_q - 32) + // ((p_gains_dir_q, p_proto_dir_q) >> 1) -> (p_gains_dir_q + p_proto_dir_q - 31) output_real[l * num_channels_dir + ch_idx] = L_add( Mpy_32_32( gs1, ( L_add( Mpy_32_32( (Word32) ( 1903158016 ), ( *p_proto ) ), @@ -2374,7 +2333,7 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( p_proto++; p_proto2++; - // ((p_gains_dir_q - 1, p_proto_dir_q - 1) >> 1) -> (p_gains_dir_q + p_proto_dir_q - 32) + // ((p_gains_dir_q, p_proto_dir_q) >> 1) -> (p_gains_dir_q + p_proto_dir_q - 31) output_imag[l * num_channels_dir + ch_idx] = L_add( Mpy_32_32( gs1, ( L_add( Mpy_32_32( (Word32) ( 1903158016 ), ( *p_proto ) ), @@ -2396,9 +2355,9 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( p_gains_dir++; p_gains_dir_prev++; - output_real[l * num_channels_dir + ch_idx] = L_shl( *( p_proto++ ), sub( h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev, 32 ) ); // p_proto_dir_q -> (p_gains_dir_q + p_proto_dir_q - 32) + output_real[l * num_channels_dir + ch_idx] = L_shl( *( p_proto++ ), sub( h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev, 31 ) ); // p_proto_dir_q -> (p_gains_dir_q + p_proto_dir_q - 31) move32(); - output_imag[l * num_channels_dir + ch_idx] = L_shl( *( p_proto++ ), sub( h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev, 32 ) ); // p_proto_dir_q -> (p_gains_dir_q + p_proto_dir_q - 32) + output_imag[l * num_channels_dir + ch_idx] = L_shl( *( p_proto++ ), sub( h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev, 31 ) ); // p_proto_dir_q -> (p_gains_dir_q + p_proto_dir_q - 31) move32(); } } @@ -2413,11 +2372,11 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( FOR( l = 0; l < num_freq_bands; l++ ) { g = L_add( Mpy_32_32( g1, ( *( p_gains_dir++ ) ) ), - Mpy_32_32( g2, ( *( p_gains_dir_prev++ ) ) ) ); // (Q31, p_gains_dir_q - 1) -> (p_gains_dir_q - 1) + Mpy_32_32( g2, ( *( p_gains_dir_prev++ ) ) ) ); // (Q31, p_gains_dir_q) -> (p_gains_dir_q) - output_real[l * num_channels_dir + ch_idx] = Mpy_32_32( g, ( *( p_proto++ ) ) ); // (p_gains_dir_q - 1, p_proto_dir_q) -> (p_gains_dir_q + p_proto_dir_q - 32) + output_real[l * num_channels_dir + ch_idx] = Mpy_32_32( g, ( *( p_proto++ ) ) ); // (p_gains_dir_q, p_proto_dir_q) -> (p_gains_dir_q + p_proto_dir_q - 31) move32(); - output_imag[l * num_channels_dir + ch_idx] = Mpy_32_32( g, ( *( p_proto++ ) ) ); // (p_gains_dir_q - 1, p_proto_dir_q) -> (p_gains_dir_q + p_proto_dir_q - 32) + output_imag[l * num_channels_dir + ch_idx] = Mpy_32_32( g, ( *( p_proto++ ) ) ); // (p_gains_dir_q, p_proto_dir_q) -> (p_gains_dir_q + p_proto_dir_q - 31) move32(); } } @@ -2428,9 +2387,9 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( p_gains_dir++; p_gains_dir_prev++; - output_real[l * num_channels_dir + ch_idx] = L_shl( *( p_proto++ ), sub( h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev, 32 ) ); // p_proto_dir_q -> (p_gains_dir_q + p_proto_dir_q - 32) + output_real[l * num_channels_dir + ch_idx] = L_shl( *( p_proto++ ), sub( h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev, 31 ) ); // p_proto_dir_q -> (p_gains_dir_q + p_proto_dir_q - 31) move32(); - output_imag[l * num_channels_dir + ch_idx] = L_shl( *( p_proto++ ), sub( h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev, 32 ) ); // p_proto_dir_q -> (p_gains_dir_q + p_proto_dir_q - 32) + output_imag[l * num_channels_dir + ch_idx] = L_shl( *( p_proto++ ), sub( h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev, 31 ) ); // p_proto_dir_q -> (p_gains_dir_q + p_proto_dir_q - 31) move32(); } } @@ -2463,18 +2422,16 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( g = L_add( Mpy_32_32( g1, ( *( p_gains_diff++ ) ) ), Mpy_32_32( g2, ( *( p_gains_diff_prev++ ) ) ) ); // (Q31, p_gains_diff_q) -> p_gains_diff_q - // ((p_gains_diff_q, p_proto_diff_q) >> Q1) -> (p_gains_diff_q + p_proto_diff_q - 32) + // ((p_gains_diff_q, p_proto_diff_q) >> Q1) -> (p_gains_diff_q + p_proto_diff_q - 31) output_real[l * num_channels_dir + hDirACRend->sba_map_tc[ch_idx]] = L_add( output_real[l * num_channels_dir + hDirACRend->sba_map_tc[ch_idx]], - L_shr( Mpy_32_32( g, ( *( p_proto++ ) ) ) , - Q1)); + Mpy_32_32( g, ( *( p_proto++ ) ) ) ); move32(); - // ((p_gains_diff_q, p_proto_diff_q) >> Q1) -> (p_gains_diff_q + p_proto_diff_q - 32) + // ((p_gains_diff_q, p_proto_diff_q) >> Q1) -> (p_gains_diff_q + p_proto_diff_q - 31) output_imag[l * num_channels_dir + hDirACRend->sba_map_tc[ch_idx]] = L_add( output_imag[l * num_channels_dir + hDirACRend->sba_map_tc[ch_idx]], - L_shr( Mpy_32_32( g, ( *( p_proto++ ) ) ), - Q1)); + Mpy_32_32( g, ( *( p_proto++ ) ) )); move32(); } } @@ -2551,7 +2508,7 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( { mvl2l( h_dirac_output_synthesis_state.cy_cross_dir_smooth_prev_fx, h_dirac_output_synthesis_state.gains_dir_prev_fx, num_freq_bands * num_channels_dir ); } - *q_cy_cross_dir_smooth_prev = sub( h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev, Q1 ); + *q_cy_cross_dir_smooth_prev = h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev; move16(); mvl2l( h_dirac_output_synthesis_state.cy_auto_diff_smooth_prev_fx, h_dirac_output_synthesis_state.gains_diff_prev_fx, num_freq_bands_diff * num_channels_diff ); @@ -5137,7 +5094,6 @@ void ivas_dirac_dec_compute_directional_responses_fx( return; } #else - void ivas_dirac_dec_compute_directional_responses( SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, /* i/o: common spatial renderer data handle */ DIRAC_REND_HANDLE hDirACRend, /* i/o: DirAC renderer handle */ @@ -6239,13 +6195,13 @@ static void computeTargetPSDs_diffuse_with_onsets_fx( IF( GT_16( *q_cy_auto_diff_smooth, q_reference_power_min_one ) ) { - q_common = q_reference_power_min_one; - move16(); + q_common = q_reference_power_min_one; + move16(); } ELSE { - q_common = *q_cy_auto_diff_smooth; - move16(); + q_common = *q_cy_auto_diff_smooth; + move16(); } /* compute target auto and cross PSDs of current frame (smoothed) */ @@ -6256,22 +6212,22 @@ static void computeTargetPSDs_diffuse_with_onsets_fx( cur_idx = imult1616( ch_idx, num_freq_bands ); diff_idx = imult1616( proto_frame_diff_index[ch_idx], num_freq_bands ); - v_multc_fixed( &onset_filter[diff_idx], diffuse_responses_square[ch_idx], aux_buffer_res1, num_decorr_freq_bands ); // (Q30, Q31) -> Q30 - v_multc_fixed( &onset_filter[diff_idx], INT_MIN, aux_buffer_res, num_decorr_freq_bands ); // (Q30, Q31) -> Q30 - v_addc_fixed( aux_buffer_res, ONE_IN_Q30, aux_buffer_res, num_decorr_freq_bands ); // Q30 - v_multc_fixed( aux_buffer_res, diffuse_response_p4, aux_buffer_res, num_decorr_freq_bands ); // (Q30, Q31) -> Q30 - v_add_fixed( aux_buffer_res1, aux_buffer_res, aux_buffer_res, num_decorr_freq_bands, 0 ); // Q30 - v_mult_fixed( aux_buffer_res, diffuse_power, aux_buffer_res, num_decorr_freq_bands ); // (Q30, q_reference_power) -> q_reference_power - Q1 - + v_multc_fixed( &onset_filter[diff_idx], diffuse_responses_square[ch_idx], aux_buffer_res1, num_decorr_freq_bands ); // (Q31, Q31) -> Q31 + v_multc_fixed( &onset_filter[diff_idx], INT_MIN, aux_buffer_res, num_decorr_freq_bands ); // (Q31, Q31) -> Q31 + v_addc_fixed( aux_buffer_res, ONE_IN_Q31, aux_buffer_res, num_decorr_freq_bands ); // Q31 + v_multc_fixed( aux_buffer_res, diffuse_response_p4, aux_buffer_res, num_decorr_freq_bands ); // (Q31, Q31) -> Q31 + v_add_fixed( aux_buffer_res1, aux_buffer_res, aux_buffer_res, num_decorr_freq_bands, Q1 ); // Q30 + v_mult_fixed( aux_buffer_res, diffuse_power, aux_buffer_res, num_decorr_freq_bands ); // (Q30, q_reference_power) -> q_reference_power - Q1 + IF( NE_16( q_common, q_reference_power_min_one ) ) { - scale_sig32( aux_buffer_res, num_decorr_freq_bands, sub( q_common, q_reference_power_min_one ) ); // q_common + scale_sig32( aux_buffer_res, num_decorr_freq_bands, sub( q_common, q_reference_power_min_one ) ); // q_common } IF( NE_16( q_common, *q_cy_auto_diff_smooth ) ) { - scale_sig32( &cy_auto_diff_smooth[cur_idx], num_decorr_freq_bands, sub( q_common, *q_cy_auto_diff_smooth ) ); // q_common + scale_sig32( &cy_auto_diff_smooth[cur_idx], num_decorr_freq_bands, sub( q_common, *q_cy_auto_diff_smooth ) ); // q_common } - v_add_fixed( &cy_auto_diff_smooth[cur_idx], aux_buffer_res, &cy_auto_diff_smooth[cur_idx], num_decorr_freq_bands, Q1 ); // (q_common - Q1) + v_add_fixed( &cy_auto_diff_smooth[cur_idx], aux_buffer_res, &cy_auto_diff_smooth[cur_idx], num_decorr_freq_bands, Q1 ); // (q_common - Q1) scale_sig32( &cy_auto_diff_smooth[cur_idx + num_decorr_freq_bands], sub( num_freq_bands, num_decorr_freq_bands ), sub( sub( q_common, Q1 ), *q_cy_auto_diff_smooth ) ); // (q_common - Q1) } diff --git a/lib_rend/ivas_dirac_rend.c b/lib_rend/ivas_dirac_rend.c index ee6289366985b41ca0ac8d70083778a5dcd9f74f..566513aeb97ed44d242320dcfd300f32f47405a9 100644 --- a/lib_rend/ivas_dirac_rend.c +++ b/lib_rend/ivas_dirac_rend.c @@ -1562,7 +1562,9 @@ ivas_error ivas_dirac_alloc_mem( #endif hDirAC_mem->reference_power = NULL; +#ifndef IVAS_FLOAT_FIXED hDirAC_mem->onset_filter = NULL; +#endif #ifdef IVAS_FLOAT_FIXED hDirAC_mem->reference_power_fx = NULL; hDirAC_mem->onset_filter_fx = NULL; @@ -1587,21 +1589,23 @@ ivas_error ivas_dirac_alloc_mem( #endif if ( hDirACRend->proto_signal_decorr_on ) { +#ifndef IVAS_FLOAT_FIXED if ( ( hDirAC_mem->onset_filter = (float *) malloc( sizeof( float ) * num_outputs_diff * num_freq_bands ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate stack memory for DirAC\n" ) ); } +#endif #ifdef IVAS_FLOAT_FIXED if ( ( hDirAC_mem->onset_filter_fx = (Word32 *) malloc( sizeof( Word32 ) * num_outputs_diff * num_freq_bands ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate stack memory for DirAC\n" ) ); } #ifdef MSAN_FIX +#ifndef IVAS_FLOAT_FIXED set_zero( hDirAC_mem->onset_filter, num_outputs_diff * num_freq_bands); +#endif 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 } } @@ -1626,21 +1630,23 @@ ivas_error ivas_dirac_alloc_mem( if ( hDirACRend->proto_signal_decorr_on ) { +#ifndef IVAS_FLOAT_FIXED if ( ( hDirAC_mem->onset_filter = (float *) malloc( sizeof( float ) * 2 * num_freq_bands ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate stack memory for DirAC\n" ) ); } +#endif #ifdef IVAS_FLOAT_FIXED if ( ( hDirAC_mem->onset_filter_fx = (Word32 *) malloc( sizeof( Word32 ) * 2 * num_freq_bands ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate stack memory for DirAC\n" ) ); } #ifdef MSAN_FIX +#ifndef IVAS_FLOAT_FIXED set_zero( hDirAC_mem->onset_filter, 2 * num_freq_bands ); +#endif 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 } } @@ -1654,6 +1660,7 @@ ivas_error ivas_dirac_alloc_mem( * * *-------------------------------------------------------------------------*/ + #ifdef IVAS_FLOAT_FIXED void ivas_dirac_free_mem_fx( DIRAC_DEC_STACK_MEM_HANDLE hDirAC_mem) @@ -1766,10 +1773,6 @@ void ivas_dirac_free_mem_fx( { free(hDirAC_mem->reference_power); } - IF (hDirAC_mem->onset_filter != NULL) - { - free(hDirAC_mem->onset_filter); - } IF (hDirAC_mem->reference_power_fx != NULL) { free(hDirAC_mem->reference_power_fx); @@ -1781,8 +1784,7 @@ void ivas_dirac_free_mem_fx( return; } -#endif - +#else void ivas_dirac_free_mem( DIRAC_DEC_STACK_MEM_HANDLE hDirAC_mem ) { @@ -1845,6 +1847,8 @@ void ivas_dirac_free_mem( return; } +#endif + /*------------------------------------------------------------------------- * compute_hoa_encoder_mtx() @@ -5922,10 +5926,8 @@ static void ivas_masa_ext_dirac_render_sf_fx( hDirACRend->h_freq_domain_decorr_ap_params, hDirACRend->h_freq_domain_decorr_ap_state ); - Scale_sig32(onset_filter_fx, hDirACRend->num_protos_diff * hSpatParamRendCom->num_freq_bands, -1); - - v_multc_fixed( onset_filter_fx, ONE_IN_Q29, onset_filter_fx, hSpatParamRendCom->num_freq_bands ); /*0.25 in Q30 = Q28*/ - v_add_fixed( onset_filter_fx, onset_filter_subframe_fx, onset_filter_subframe_fx, hSpatParamRendCom->num_freq_bands, 1); + v_multc_fixed( onset_filter_fx, 536870912 /* 0.25f in Q31 */, onset_filter_fx, hSpatParamRendCom->num_freq_bands ); /* Q31 */ + v_add_fixed( onset_filter_fx, onset_filter_subframe_fx, onset_filter_subframe_fx, hSpatParamRendCom->num_freq_bands, 0 ); /* Q31 */ p_onset_filter_fx = onset_filter_subframe_fx; } ELSE @@ -5947,7 +5949,6 @@ static void ivas_masa_ext_dirac_render_sf_fx( hDirACRend->h_freq_domain_decorr_ap_params, hDirACRend->h_freq_domain_decorr_ap_state ); - Scale_sig32(onset_filter_fx, hDirACRend->num_protos_diff * hSpatParamRendCom->num_freq_bands, -1); hDirACRend->proto_frame_dec_f_fx = DirAC_mem.frame_dec_f_fx; hDirACRend->proto_frame_dec_f_q = DirAC_mem.frame_dec_f_q; move16(); p_onset_filter_fx = onset_filter_fx; @@ -5957,7 +5958,7 @@ static void ivas_masa_ext_dirac_render_sf_fx( { IF ( EQ_16(hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD )) { - set32_fx( onset_filter_subframe_fx, MAX_32, hSpatParamRendCom->num_freq_bands ); + set32_fx( onset_filter_subframe_fx, ONE_IN_Q31, hSpatParamRendCom->num_freq_bands ); p_onset_filter_fx = onset_filter_subframe_fx; } ELSE @@ -6090,7 +6091,7 @@ static void ivas_masa_ext_dirac_render_sf_fx( 0, &hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev, &hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth_prev); - q_cldfb = -2; move16(); + q_cldfb = -1; move16(); hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_q = hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev; move16(); hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_q = hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth_prev; move16(); } diff --git a/lib_rend/ivas_objectRenderer_sources.c b/lib_rend/ivas_objectRenderer_sources.c index fac68039acd9810388222d020fa41364faaec387..6c7ef40effe10eb27db4fcc153741e7fbb51c55e 100644 --- a/lib_rend/ivas_objectRenderer_sources.c +++ b/lib_rend/ivas_objectRenderer_sources.c @@ -844,6 +844,9 @@ static void TDREND_SRC_SPATIAL_Init_fx( TDREND_SPATIAL_VecInit_fx( SrcSpatial_p->Front_p_fx + nC * 3, 0, 0, ONE_IN_Q30);/*Assuming Q30*/ } +#ifdef MSAN_FIX + SrcSpatial_p->q_Pos_p = Q31; +#endif /* Source directional attenuation */ SrcSpatial_p->DirAttenEnabled = FALSE; diff --git a/lib_rend/ivas_rom_binauralRenderer.c b/lib_rend/ivas_rom_binauralRenderer.c index 8233d16ef722e725161d321ec690c9259e21be08..5244d272b3914ad51ea6897b028ca02541db4743 100644 --- a/lib_rend/ivas_rom_binauralRenderer.c +++ b/lib_rend/ivas_rom_binauralRenderer.c @@ -53,8 +53,11 @@ +#ifdef IVAS_FLOAT_FIXED const Word32 FASTCONV_HOA3_latency_s_fx = 20833; +#else const float FASTCONV_HOA3_latency_s = 0.000020833f; +#endif const Word32 leftHRIRReal_HOA3_fx[BINAURAL_CONVBANDS][HOA3_CHANNELS][BINAURAL_NTAPS_SBA]= { { @@ -7289,8 +7292,11 @@ const float rightHRIRImag_HOA3[BINAURAL_CONVBANDS][HOA3_CHANNELS][BINAURAL_NTAPS +#ifdef IVAS_FLOAT_FIXED const Word32 FASTCONV_HOA2_latency_s_fx = 20833; +#else const float FASTCONV_HOA2_latency_s = 0.000020833f; +#endif const Word32 leftHRIRReal_HOA2_fx[BINAURAL_CONVBANDS][HOA2_CHANNELS][BINAURAL_NTAPS_SBA]= { { @@ -11725,8 +11731,11 @@ const float rightHRIRImag_HOA2[BINAURAL_CONVBANDS][HOA2_CHANNELS][BINAURAL_NTAPS +#ifdef IVAS_FLOAT_FIXED const Word32 FASTCONV_FOA_latency_s_fx = 20833; +#else const float FASTCONV_FOA_latency_s = 0.000020833f; +#endif const Word32 leftHRIRReal_FOA_fx[BINAURAL_CONVBANDS][FOA_CHANNELS][BINAURAL_NTAPS_SBA]= { { @@ -14160,8 +14169,11 @@ const float rightHRIRImag_FOA[BINAURAL_CONVBANDS][FOA_CHANNELS][BINAURAL_NTAPS_S }; +#ifdef IVAS_FLOAT_FIXED const Word32 FASTCONV_HRIR_latency_s_fx = 666667; +#else const float FASTCONV_HRIR_latency_s = 0.000666667f; +#endif const Word32 leftHRIRReal_fx[BINAURAL_CONVBANDS][HRTF_LS_CHANNELS][BINAURAL_NTAPS]= { { @@ -20993,8 +21005,9 @@ const float rightHRIRImag[BINAURAL_CONVBANDS][HRTF_LS_CHANNELS][BINAURAL_NTAPS]= {-0.195200f, +0.041315f, -0.080091f} } }; + #ifdef IVAS_FLOAT_FIXED -const Word16 hrtfShCoeffsRe_fx[BINAURAL_CHANNELS][HRTF_SH_CHANNELS][HRTF_NUM_BINS] /*Q-15*/= +const Word16 hrtfShCoeffsRe_fx[BINAURAL_CHANNELS][HRTF_SH_CHANNELS][HRTF_NUM_BINS] /* Q15 */= { { { @@ -21097,8 +21110,7 @@ const Word16 hrtfShCoeffsRe_fx[BINAURAL_CHANNELS][HRTF_SH_CHANNELS][HRTF_NUM_BIN } } }; -#endif // IVAS_FLOAT_FIXED - +#else const float hrtfShCoeffsRe[BINAURAL_CHANNELS][HRTF_SH_CHANNELS][HRTF_NUM_BINS]= { { @@ -21362,8 +21374,10 @@ const float hrtfShCoeffsRe[BINAURAL_CHANNELS][HRTF_SH_CHANNELS][HRTF_NUM_BINS]= } } }; +#endif + #ifdef IVAS_FLOAT_FIXED -const Word16 hrtfShCoeffsIm_fx[2][16][60]/*Q-14*/ = +const Word16 hrtfShCoeffsIm_fx[2][16][60] /* Q14 */ = { { { @@ -21466,8 +21480,7 @@ const Word16 hrtfShCoeffsIm_fx[2][16][60]/*Q-14*/ = }, }, }; -#endif // IVAS_FLOAT_FIXED - +#else const float hrtfShCoeffsIm[BINAURAL_CHANNELS][HRTF_SH_CHANNELS][HRTF_NUM_BINS]= { { @@ -21731,12 +21744,16 @@ const float hrtfShCoeffsIm[BINAURAL_CHANNELS][HRTF_SH_CHANNELS][HRTF_NUM_BINS]= } } }; +#endif /* Binaural rendering data set based on BRIRs */ /* Tables derived from Mozart IIS BRIRs.*/ +#ifdef IVAS_FLOAT_FIXED const Word32 FASTCONV_BRIR_latency_s_fx = 937500; +#else const float FASTCONV_BRIR_latency_s = 0.000937500f; +#endif const Word32 leftBRIRReal_fx[BINAURAL_CONVBANDS][HRTF_LS_CHANNELS][BINAURAL_NTAPS_MAX]= { { @@ -94574,27 +94591,29 @@ const Word32 fastconvReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX] = { 921702144, 440470368, 434517536, 447499072, 463134912, 507976512, 495205440, 490485280, 488481664, 470204416, 485509536, 473953952, 475669760, 479900320, 480402816, 487614080, 489409376, 479041312, 472446400, 469403424, 473341888, 468688320, 457950880, 451686688, 445424608, 426812384, 421443680, 418581056, 408736992, 396210720, 387262176, 378315744, 379030848, 381356576, 394241504, 420728544, 436476064, 447572096, 460993888, 472446400, 478710624, 494816736, 502356544, 501753120, 507521248, 509872736, 518894336, 517796960, 512920032, 520515680, 528908032, 528169312, 528495712, 526983904, 523880768, 524250144, 513828416, 518561472, 504280704, 543399232 }; -#endif - +#else const float fastconvReverberationTimes[CLDFB_NO_CHANNELS_MAX] = { 0.429201f, 0.205110f, 0.202338f, 0.208383f, 0.215664f, 0.236545f, 0.230598f, 0.228400f, 0.227467f, 0.218956f, 0.226083f, 0.220702f, 0.221501f, 0.223471f, 0.223705f, 0.227063f, 0.227899f, 0.223071f, 0.220000f, 0.218583f, 0.220417f, 0.218250f, 0.213250f, 0.210333f, 0.207417f, 0.198750f, 0.196250f, 0.194917f, 0.190333f, 0.184500f, 0.180333f, 0.176167f, 0.176500f, 0.177583f, 0.183583f, 0.195917f, 0.203250f, 0.208417f, 0.214667f, 0.220000f, 0.222917f, 0.230417f, 0.233928f, 0.233647f, 0.236333f, 0.237428f, 0.241629f, 0.241118f, 0.238847f, 0.242384f, 0.246292f, 0.245948f, 0.246100f, 0.245396f, 0.243951f, 0.244123f, 0.239270f, 0.241474f, 0.234824f, 0.253040f, }; +#endif + #ifdef IVAS_FLOAT_FIXED const Word32 fastconvReverberationEneCorrections_fx[CLDFB_NO_CHANNELS_MAX] = { 1254130, 450971, 500363, 455266, 551903, 3259880, 2478196, 2355789, 2716566, 2787433, 4982162, 5222680, 5768141, 5802501, 5652177, 5506148, 5866925, 5856188, 5602785, 5420248, 7337951, 3828963, 2119566, 1501091, 1301375, 1151051, 1097364, 1221918, 1288490, 1166083, 2699387, 2596307, 2055141, 1290637, 588410, 227633, 154618, 109521, 85899, 64424, 51539, 38654, 30064, 27917, 25769, 23622, 19327, 19327, 17179, 17179, 15032, 12884, 10737, 6442, 4294, 4294, 2147, 2147, 0, 0 }; -#endif - +#else const float fastconvReverberationEneCorrections[CLDFB_NO_CHANNELS_MAX] = { 0.000584f, 0.000210f, 0.000233f, 0.000212f, 0.000257f, 0.001518f, 0.001154f, 0.001097f, 0.001265f, 0.001298f, 0.002320f, 0.002432f, 0.002686f, 0.002702f, 0.002632f, 0.002564f, 0.002732f, 0.002727f, 0.002609f, 0.002524f, 0.003417f, 0.001783f, 0.000987f, 0.000699f, 0.000606f, 0.000536f, 0.000511f, 0.000569f, 0.000600f, 0.000543f, 0.001257f, 0.001209f, 0.000957f, 0.000601f, 0.000274f, 0.000106f, 0.000072f, 0.000051f, 0.000040f, 0.000030f, 0.000024f, 0.000018f, 0.000014f, 0.000013f, 0.000012f, 0.000011f, 0.000009f, 0.000009f, 0.000008f, 0.000008f, 0.000007f, 0.000006f, 0.000005f, 0.000003f, 0.000002f, 0.000002f, 0.000001f, 0.000001f, 0.000000f, 0.000000f, }; +#endif + #ifdef IVAS_FLOAT_FIXED -const Word32 parametricReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX] /*Q-31*/= +const Word32 parametricReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX] /* Q31 */= { 741942720,686022272,715028288,775076224,803800960,796237568,770141312,747545472,736820992, 711570880,679682880,654928832,633196288,617506752,601123648,580415424,567025856,550623424, @@ -94604,8 +94623,7 @@ const Word32 parametricReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX] /*Q-31*/= 336405472,333613728,329810528,325506976,322043104,318265664,314490400,310715104,306939840, 303164576,299389280,295611872,291836576,288061312,284286048 }; -#endif // IVAS_FLOAT_FIXED - +#else const float parametricReverberationTimes[CLDFB_NO_CHANNELS_MAX] = { 0.345494f, 0.319454f, 0.332961f, 0.360923f, 0.374299f, 0.370777f, 0.358625f, 0.348103f, 0.343109f, 0.331351f, @@ -94615,9 +94633,11 @@ const float parametricReverberationTimes[CLDFB_NO_CHANNELS_MAX] = 0.167340f, 0.165926f, 0.163565f, 0.161558f, 0.158405f, 0.156651f, 0.155351f, 0.153580f, 0.151576f, 0.149963f, 0.148204f, 0.146446f, 0.144688f, 0.142930f, 0.141172f, 0.139414f, 0.137655f, 0.135897f, 0.134139f, 0.132381f }; +#endif + #ifdef IVAS_FLOAT_FIXED -const Word32 parametricReverberationEneCorrections_fx[CLDFB_NO_CHANNELS_MAX] /*Q-31*/= +const Word32 parametricReverberationEneCorrections_fx[CLDFB_NO_CHANNELS_MAX] /* Q31 */= { 412276064,308677152,243799520,201511280,193589216,171714944,143009520,156122064,164263168, 176233248,183105200,201571408,218830736,244229024,252642864,243726512,270851360,271235776, @@ -94627,8 +94647,7 @@ const Word32 parametricReverberationEneCorrections_fx[CLDFB_NO_CHANNELS_MAX] /*Q 167503,137438,128849,135291,133143,130996,111669,85899,64424, 30064,15032,6442,2147,0,0 }; -#endif // IVAS_FLOAT_FIXED - +#else const float parametricReverberationEneCorrections[CLDFB_NO_CHANNELS_MAX] = { 0.191981f, 0.143739f, 0.113528f, 0.093836f, 0.090147f, 0.079961f, 0.066594f, 0.072700f, 0.076491f, 0.082065f, @@ -94638,6 +94657,8 @@ const float parametricReverberationEneCorrections[CLDFB_NO_CHANNELS_MAX] = 0.000304f, 0.000181f, 0.000116f, 0.000113f, 0.000102f, 0.000078f, 0.000064f, 0.000060f, 0.000063f, 0.000062f, 0.000061f, 0.000052f, 0.000040f, 0.000030f, 0.000014f, 0.000007f, 0.000003f, 0.000001f, 0.000000f, 0.000000f }; +#endif + #ifdef IVAS_FLOAT_FIXED const Word32 parametricEarlyPartEneCorrection_fx[CLDFB_NO_CHANNELS_MAX]/*Q-28*/ = diff --git a/lib_rend/ivas_rom_binauralRenderer.h b/lib_rend/ivas_rom_binauralRenderer.h index b0258ccddeaf112ed2e94feafb04e9398cd1974b..ce069e40fb32742c953135f70066a931d2df70dc 100644 --- a/lib_rend/ivas_rom_binauralRenderer.h +++ b/lib_rend/ivas_rom_binauralRenderer.h @@ -40,8 +40,11 @@ *------------------------------------------------------------------------*/ /* Binaural rendering data set based on HRIRs */ +#ifdef IVAS_FLOAT_FIXED extern const Word32 FASTCONV_HRIR_latency_s_fx; +#else extern const float FASTCONV_HRIR_latency_s; +#endif extern float leftHRIRReal_HOA3[BINAURAL_CONVBANDS][HOA3_CHANNELS][BINAURAL_NTAPS_SBA]; extern float leftHRIRImag_HOA3[BINAURAL_CONVBANDS][HOA3_CHANNELS][BINAURAL_NTAPS_SBA]; extern float rightHRIRReal_HOA3[BINAURAL_CONVBANDS][HOA3_CHANNELS][BINAURAL_NTAPS_SBA]; @@ -78,23 +81,27 @@ extern Word32 leftHRIRImag_fx[BINAURAL_CONVBANDS][HRTF_LS_CHANNELS][BINAURAL_NTA extern Word32 rightHRIRReal_fx[BINAURAL_CONVBANDS][HRTF_LS_CHANNELS][BINAURAL_NTAPS]; extern Word32 rightHRIRImag_fx[BINAURAL_CONVBANDS][HRTF_LS_CHANNELS][BINAURAL_NTAPS]; -extern Word32 FASTCONV_HOA3_latency_s_fx; -extern Word32 FASTCONV_HOA2_latency_s_fx; -extern Word32 FASTCONV_FOA_latency_s_fx; +#ifndef IVAS_FLOAT_FIXED extern float FASTCONV_HOA3_latency_s; extern float FASTCONV_HOA2_latency_s; extern float FASTCONV_FOA_latency_s; extern float hrtfShCoeffsRe[BINAURAL_CHANNELS][HRTF_SH_CHANNELS][HRTF_NUM_BINS]; extern float hrtfShCoeffsIm[BINAURAL_CHANNELS][HRTF_SH_CHANNELS][HRTF_NUM_BINS]; -#ifdef IVAS_FLOAT_FIXED -extern Word16 hrtfShCoeffsRe_fx[BINAURAL_CHANNELS][HRTF_SH_CHANNELS][HRTF_NUM_BINS];/*Q-15*/ -extern Word16 hrtfShCoeffsIm_fx[BINAURAL_CHANNELS][HRTF_SH_CHANNELS][HRTF_NUM_BINS];/*Q-14*/ +#else +extern Word32 FASTCONV_HOA3_latency_s_fx; +extern Word32 FASTCONV_HOA2_latency_s_fx; +extern Word32 FASTCONV_FOA_latency_s_fx; +extern Word16 hrtfShCoeffsRe_fx[BINAURAL_CHANNELS][HRTF_SH_CHANNELS][HRTF_NUM_BINS]; /* Q15 */ +extern Word16 hrtfShCoeffsIm_fx[BINAURAL_CHANNELS][HRTF_SH_CHANNELS][HRTF_NUM_BINS]; /* Q14 */ #endif // IVAS_FLOAT_FIXED /* Binaural rendering data set based on BRIRs */ +#ifdef IVAS_FLOAT_FIXED extern const Word32 FASTCONV_BRIR_latency_s_fx; +#else extern const float FASTCONV_BRIR_latency_s; +#endif extern float leftBRIRReal[BINAURAL_CONVBANDS][HRTF_LS_CHANNELS][BINAURAL_NTAPS_MAX]; extern float leftBRIRImag[BINAURAL_CONVBANDS][HRTF_LS_CHANNELS][BINAURAL_NTAPS_MAX]; extern float rightBRIRReal[BINAURAL_CONVBANDS][HRTF_LS_CHANNELS][BINAURAL_NTAPS_MAX]; @@ -109,18 +116,20 @@ extern Word32 rightBRIRImag_fx[BINAURAL_CONVBANDS][HRTF_LS_CHANNELS][BINAURAL_NT #ifdef IVAS_FLOAT_FIXED extern Word32 fastconvReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX]; extern Word32 fastconvReverberationEneCorrections_fx[CLDFB_NO_CHANNELS_MAX]; -#endif +#else extern float fastconvReverberationTimes[CLDFB_NO_CHANNELS_MAX]; extern float fastconvReverberationEneCorrections[CLDFB_NO_CHANNELS_MAX]; +#endif /* Binaural rendering data set based on BRIRs, to be used in a combined manner * with the above binaural rendering data set based on HRIRs for parametric * renderer */ #ifdef IVAS_FLOAT_FIXED -extern const Word32 parametricReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX];/*Q-31*/ -extern const Word32 parametricReverberationEneCorrections_fx[CLDFB_NO_CHANNELS_MAX];/*Q-31*/ -extern const Word32 parametricEarlyPartEneCorrection_fx[CLDFB_NO_CHANNELS_MAX];/*Q-28*/ -#endif // IVAS_FLOAT_FIXED +extern const Word32 parametricReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX]; /* Q31 */ +extern const Word32 parametricReverberationEneCorrections_fx[CLDFB_NO_CHANNELS_MAX]; /* Q31 */ +extern const Word32 parametricEarlyPartEneCorrection_fx[CLDFB_NO_CHANNELS_MAX]; /* Q28 */ +#else extern const float parametricReverberationTimes[CLDFB_NO_CHANNELS_MAX]; extern const float parametricReverberationEneCorrections[CLDFB_NO_CHANNELS_MAX]; +#endif extern const float parametricEarlyPartEneCorrection[CLDFB_NO_CHANNELS_MAX]; diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index 28893b458894f6a7b3559e35571079e6e428c462..609d85be7ebe17a558b525294effe2b40eea0581 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -309,15 +309,14 @@ typedef struct dirac_dec_stack_mem #endif float *reference_power; +#ifndef IVAS_FLOAT_FIXED float *onset_filter; -#ifdef IVAS_FLOAT_FIXED +#else Word32 *reference_power_fx; Word16 reference_power_q; Word16 reference_power_smooth_q; Word16 reference_power_len; - Word32 *onset_filter_fx; - Word16 onset_filter_len; - Word16 q_onset_filter; + Word32 *onset_filter_fx; /* Q31 */ #endif } DIRAC_DEC_STACK_MEM, *DIRAC_DEC_STACK_MEM_HANDLE; @@ -363,7 +362,11 @@ typedef struct dirac_output_synthesis_state_structure /* only pointer to local buffers */ float *direct_responses; /* direct responses for DOA of current frame. Size: num_freq_bands*num_channels. */ float *direct_responses_square; +#ifndef IVAS_FLOAT_FIXED float *diffuse_responses_square; /* squared diffuse responses. Size: num_channels. */ +#else + Word32 *diffuse_responses_square_fx; /* squared diffuse responses. Size: num_channels. */ /* Q31 */ +#endif /* only pointer to local buffers */ float *direct_power_factor; @@ -393,11 +396,21 @@ typedef struct dirac_output_synthesis_state_structure float *cy_cross_dir_smooth_prev; /* Target cross PSD of direct sound of previous synthesis block. Size: num_freq_bands*num_channels. */ float *cy_auto_diff_smooth_prev; /* Target auto PSD of diffuse sound of previous synthesis block. Size: num_freq_bands*num_channels. */ +#ifndef IVAS_FLOAT_FIXED const float *onset_filter; +#else + const Word32 *onset_filter_fx; /* Q31 */ +#endif /* Temporal smoothing memories */ +#ifndef IVAS_FLOAT_FIXED float *reference_power_smooth_prev; float *direction_smoothness_prev; +#else + Word32 *reference_power_smooth_prev_fx; /* Q(reference_power_smooth_prev_q) */ + Word16 reference_power_smooth_prev_q; + Word32 *direction_smoothness_prev_fx; /* Q31 */ +#endif #ifdef IVAS_FLOAT_FIXED /* only pointer to local buffers */ @@ -405,8 +418,6 @@ typedef struct dirac_output_synthesis_state_structure Word16 direct_responses_q; Word32 *direct_responses_square_fx; Word16 direct_responses_square_q; - Word32 *diffuse_responses_square_fx; /* squared diffuse responses. Size: num_channels. */ - Word16 diffuse_responses_square_q; /* only pointer to local buffers */ Word32 *direct_power_factor_fx; @@ -472,13 +483,6 @@ typedef struct dirac_output_synthesis_state_structure Word16 cy_auto_dir_smooth_prev_len; /* Target auto PSD of direct sound. Size: num_freq_bands*num_channels. */ Word16 cy_cross_dir_smooth_prev_len; /* Target cross PSD of direct sound. Size: num_freq_bands*num_channels. */ Word16 cy_auto_diff_smooth_prev_len; /* Target auto PSD of diffuse sound. Size: num_freq_bands*num_channels. */ - - const Word32 *onset_filter_fx; - - /* Temporal smoothing memories */ - Word32 *reference_power_smooth_prev_fx; - Word16 reference_power_smooth_prev_q; - Word32 *direction_smoothness_prev_fx; // Q31 #endif } DIRAC_OUTPUT_SYNTHESIS_STATE; @@ -2143,19 +2147,24 @@ typedef struct ivas_hrtfs_fastconv_struct typedef struct ivas_hrtfs_parambin_struct { +#ifndef IVAS_FLOAT_FIXED float hrtfShCoeffsRe[BINAURAL_CHANNELS][HRTF_SH_CHANNELS][HRTF_NUM_BINS]; float hrtfShCoeffsIm[BINAURAL_CHANNELS][HRTF_SH_CHANNELS][HRTF_NUM_BINS]; -#ifdef IVAS_FLOAT_FIXED - Word16 hrtfShCoeffsRe_fx[BINAURAL_CHANNELS][HRTF_SH_CHANNELS][HRTF_NUM_BINS];/*Q-15*/ - Word16 hrtfShCoeffsIm_fx[BINAURAL_CHANNELS][HRTF_SH_CHANNELS][HRTF_NUM_BINS];/*Q-14*/ - Word32 parametricReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX];/*Q-31*/ - Word32 parametricReverberationEneCorrections_fx[CLDFB_NO_CHANNELS_MAX];/*Q-31*/ - Word32 parametricEarlyPartEneCorrection_fx[CLDFB_NO_CHANNELS_MAX];/*Q-28*/ -#endif // IVAS_FLOAT_FIXED +#else + Word16 hrtfShCoeffsRe_fx[BINAURAL_CHANNELS][HRTF_SH_CHANNELS][HRTF_NUM_BINS]; /* Q15 */ + Word16 hrtfShCoeffsIm_fx[BINAURAL_CHANNELS][HRTF_SH_CHANNELS][HRTF_NUM_BINS]; /* Q14 */ +#endif +#ifndef IVAS_FLOAT_FIXED float parametricReverberationTimes[CLDFB_NO_CHANNELS_MAX]; float parametricReverberationEneCorrections[CLDFB_NO_CHANNELS_MAX]; +#endif float parametricEarlyPartEneCorrection[CLDFB_NO_CHANNELS_MAX]; +#ifdef IVAS_FLOAT_FIXED + Word32 parametricReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX]; /* Q31 */ + Word32 parametricReverberationEneCorrections_fx[CLDFB_NO_CHANNELS_MAX]; /* Q31 */ + Word32 parametricEarlyPartEneCorrection_fx[CLDFB_NO_CHANNELS_MAX]; /* Q28 */ +#endif } HRTFS_PARAMBIN, *HRTFS_PARAMBIN_HANDLE; diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index eaa1f735a992fc6129a57c184f21ee286f0a0005..ec4b580a2ad7351a5d7eb4ece24e28f5393d6206 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -14761,7 +14761,6 @@ static void intermidiate_ext_dirac_render( if(to_fix) { DirAC_mem.reference_power_smooth_q = DirAC_mem.reference_power_q = Q31; - floatToFixed_arrL(hDirACRend->stack_mem.onset_filter, hDirACRend->stack_mem.onset_filter_fx, Q30, hDirACRend->stack_mem.onset_filter_len ); q_cldfb = 11; for(i = 0; i < MAX_OUTPUT_CHANNELS; i++) { @@ -14803,10 +14802,6 @@ static void intermidiate_ext_dirac_render( } } } - if(h_dirac_output_synthesis_state->diffuse_responses_square_fx){ - h_dirac_output_synthesis_state->diffuse_responses_square_q = Q31; - floatToFixed_arrL( h_dirac_output_synthesis_state->diffuse_responses_square, h_dirac_output_synthesis_state->diffuse_responses_square_fx, h_dirac_output_synthesis_state->diffuse_responses_square_q, hDirACRend->num_outputs_dir ); - } if(hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth){ 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, hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_len); @@ -14937,7 +14932,6 @@ static void intermidiate_ext_dirac_render( } } - fixedToFloat_arrL(hDirACRend->stack_mem.onset_filter_fx, hDirACRend->stack_mem.onset_filter, Q30, hDirACRend->stack_mem.onset_filter_len ); if(DirAC_mem.reference_power) { fixedToFloat_arrL(DirAC_mem.reference_power_fx, DirAC_mem.reference_power, DirAC_mem.reference_power_q, DirAC_mem.reference_power_len ); @@ -15017,9 +15011,6 @@ static void intermidiate_ext_dirac_render( hMasaExtRend->cldfbSynRend[ch]->cldfb_state[i] = ((float)hMasaExtRend->cldfbSynRend[ch]->cldfb_state_fx[i] / (1 << ((hMasaExtRend->cldfbSynRend[0]->Q_cldfb_state)))); } } - if(hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_fx){ - fixedToFloat_arrL( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev, hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q, hSpatParamRendCom->num_freq_bands ); - } for(i = 0; i < MAX_OUTPUT_CHANNELS; i++) { fixedToFloat_arrL(output_f[i], output_f_flt[i], hMasaExtRend->cldfbSynRend[0]->Q_cldfb_state, L_FRAME48k); diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index 777e21e1e08ecdc406d8ccf08c9c612de1109211..ac09d121b3a56d3f7f3e3cc210f3781e4dd276f3 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -2127,6 +2127,9 @@ static ivas_error create_parambin_HRTF_from_rawdata( char *hrtf_data_rptr; uint32_t data_size_tmp; + float f_tmp_hrtfShCoeffs[HRTF_NUM_BINS]; + float f_tmp_reverb[CLDFB_NO_CHANNELS_MAX]; + hrtf_data_rptr = hrtf_data; /* HRTF_SH_CHANNELS */ @@ -2149,7 +2152,9 @@ static ivas_error create_parambin_HRTF_from_rawdata( { for ( j = 0; j < HRTF_SH_CHANNELS; j++ ) { - memcpy( ( *hHRTF )->hrtfShCoeffsRe[i][j], hrtf_data_rptr, data_size_tmp ); + memcpy( f_tmp_hrtfShCoeffs, hrtf_data_rptr, data_size_tmp ); + /*adding conversion as file reading is done in float*/ + floatToFixed_arr16( f_tmp_hrtfShCoeffs, ( *hHRTF )->hrtfShCoeffsRe_fx[i][j], Q15, HRTF_NUM_BINS ); hrtf_data_rptr += data_size_tmp; } } @@ -2157,7 +2162,9 @@ static ivas_error create_parambin_HRTF_from_rawdata( { for ( j = 0; j < HRTF_SH_CHANNELS; j++ ) { - memcpy( ( *hHRTF )->hrtfShCoeffsIm[i][j], hrtf_data_rptr, data_size_tmp ); + memcpy( f_tmp_hrtfShCoeffs, hrtf_data_rptr, data_size_tmp ); + /*adding conversion as file reading is done in float*/ + floatToFixed_arr16( f_tmp_hrtfShCoeffs, ( *hHRTF )->hrtfShCoeffsIm_fx[i][j], Q14, HRTF_NUM_BINS ); hrtf_data_rptr += data_size_tmp; } } @@ -2169,15 +2176,15 @@ static ivas_error create_parambin_HRTF_from_rawdata( } hrtf_data_rptr += sizeof( uint16_t ); - memcpy( ( *hHRTF )->parametricReverberationTimes, hrtf_data_rptr, CLDFB_NO_CHANNELS_MAX * sizeof( float ) ); + memcpy( f_tmp_reverb, hrtf_data_rptr, CLDFB_NO_CHANNELS_MAX * sizeof( float ) ); hrtf_data_rptr += CLDFB_NO_CHANNELS_MAX * sizeof( float ); /*adding conversion as file reading is done in float*/ - floatToFixed_arrL( ( *hHRTF )->parametricReverberationTimes, ( *hHRTF )->parametricReverberationTimes_fx, Q31, CLDFB_NO_CHANNELS_MAX ); + floatToFixed_arrL( f_tmp_reverb, ( *hHRTF )->parametricReverberationTimes_fx, Q31, CLDFB_NO_CHANNELS_MAX ); - memcpy( ( *hHRTF )->parametricReverberationEneCorrections, hrtf_data_rptr, CLDFB_NO_CHANNELS_MAX * sizeof( float ) ); + memcpy( f_tmp_reverb, hrtf_data_rptr, CLDFB_NO_CHANNELS_MAX * sizeof( float ) ); hrtf_data_rptr += CLDFB_NO_CHANNELS_MAX * sizeof( float ); /*adding conversion as file reading is done in float*/ - floatToFixed_arrL( ( *hHRTF )->parametricReverberationEneCorrections, ( *hHRTF )->parametricReverberationEneCorrections_fx, Q31, CLDFB_NO_CHANNELS_MAX ); + floatToFixed_arrL( f_tmp_reverb, ( *hHRTF )->parametricReverberationEneCorrections_fx, Q31, CLDFB_NO_CHANNELS_MAX ); memcpy( ( *hHRTF )->parametricEarlyPartEneCorrection, hrtf_data_rptr, CLDFB_NO_CHANNELS_MAX * sizeof( float ) ); hrtf_data_rptr += CLDFB_NO_CHANNELS_MAX * sizeof( float );