diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 9079381699c3ffab05c11dd3928e0836879e8981..77c676e8df8b0272b39548e724a81d3b6cf8a3fe 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -6440,7 +6440,7 @@ void ivas_binaural_add_LFE( float *input_f[], /* i : transport channels */ float *output_f[] /* o : synthesized core-coder transport channels/DirAC output */ ); -void ivas_binaural_add_LFE_fix( +void ivas_binaural_add_LFE_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ Word16 output_frame, /* i : length of input frame */ Word32 *input_fx[], /* i : transport channels */ diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index c694d05d3e2bda8bb9ad5c05f829ca3946bd3ba3..bc8288f74e80f9eabea937d3db0b1897cea24b2b 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -2058,4 +2058,60 @@ void td_bwe_dec_init_ivas_fx( TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ const Word32 output_Fs /* i : output sampling rate */ ); + +void ivas_dirac_dec_render_sf_fx( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + float *output_f[], /* i/o: synthesized core-coder transport channels/DirAC output */ + const int16_t nchan_transport, /* i : number of transport channels */ + float *pppQMfFrame_ts_re[IVAS_MAX_FB_MIXER_IN_CH][CLDFB_NO_COL_MAX], + float *pppQMfFrame_ts_im[IVAS_MAX_FB_MIXER_IN_CH][CLDFB_NO_COL_MAX] +); + +void ivas_dirac_dec_render_fx( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const Word16 nchan_transport, /* i : number of transport channels */ + const UWord16 nSamplesAsked, /* i : number of CLDFB slots requested */ + UWord16 *nSamplesRendered, /* o : number of CLDFB slots rendered */ + UWord16 *nSamplesAvailableNext, /* o : number of CLDFB slots still to render */ + float *output_f[] /* o : rendered time signal */ +); + +void ivas_dirac_dec_read_BS_fx( + const int32_t ivas_total_brate, /* i : IVAS total bitrate */ + Decoder_State *st, /* i/o: decoder Core state structure */ + DIRAC_DEC_HANDLE hDirAC, /* i/o: decoder DirAC handle */ + SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, /* i/o: common spatial rendering data handle */ + IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: q metadata */ + int16_t *nb_bits, /* o : number of bits read */ + const int16_t last_bit_pos, /* i : last read bitstream position */ + const int16_t hodirac_flag, /* i : flag to indicate HO-DirAC mode */ + int16_t *dirac_to_spar_md_bands /* o : DirAC->SPAR MD bands */ +); + +ivas_error ivas_dirac_dec_config_fx( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const DIRAC_CONFIG_FLAG flag_configopen /* i/ : Flag determining if we open or reconfigure the DirAC decoder */ +); + +void ivas_dirac_dec_output_synthesis_cov_close_fx( + DIRAC_OUTPUT_SYNTHESIS_PARAMS *h_dirac_output_synthesis_params, /* i : handle for the covariance synthesis parameters */ + DIRAC_OUTPUT_SYNTHESIS_COV_STATE *h_dirac_output_synthesis_state /* i/o: handle for the covariance synthesis state */ +); + +ivas_error ivas_init_decoder_fx( + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +); + +ivas_error ivas_ism_dec_config_fx( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const ISM_MODE last_ism_mode, /* i/o: last ISM mode */ + UWord16 *nSamplesRendered, /* o : number of samples flushed when the renderer granularity changes */ + Word16 *data /* o : output synthesis signal */ +); + +ivas_error ivas_ism_metadata_dec_create_fx( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const Word16 n_ISms, /* i : number of objects */ + Word32 element_brate_tmp[] /* o : element bitrate per object */ +); #endif diff --git a/lib_dec/ivas_binRenderer_internal.c b/lib_dec/ivas_binRenderer_internal.c index b2f057faf640c2c9c2a2da7b5db37c2bd089c01e..a00781facd09361738a4d79c64bd75cd9a32301c 100644 --- a/lib_dec/ivas_binRenderer_internal.c +++ b/lib_dec/ivas_binRenderer_internal.c @@ -64,11 +64,11 @@ static void ivas_binRenderer_filterModule( float out_Conv_CLDFB_imag[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : imag part of Binaural signals */ float CLDFB_real[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i : real part of LS signals */ float CLDFB_imag[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i : imag part of LS signals */ - const Word16 numTimeSlots, /* i : number of time slots to process */ + const int16_t numTimeSlots, /* i : number of time slots to process */ BINAURAL_RENDERER_HANDLE hBinRenderer /* i/o: fastconv binaural renderer handle */ ) { - Word16 bandIdx, k, chIdx, tapIdx; + int16_t bandIdx, k, chIdx, tapIdx; float *filterStatesLeftRealPtr, *filterStatesLeftImagPtr; const float *filterTapsLeftRealPtr, *filterTapsLeftImagPtr, *filterTapsRightRealPtr, *filterTapsRightImagPtr; @@ -121,12 +121,12 @@ static void ivas_binRenderer_filterModule( } #else /*------------------------------------------------------------------------- - * ivas_binRenderer_filterModule_fixed() + * ivas_binRenderer_filterModule_fx() * * *-------------------------------------------------------------------------*/ -static void ivas_binRenderer_filterModule_fixed( +static void ivas_binRenderer_filterModule_fx( Word64 out_Conv_CLDFB_real[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : real part of Binaural signals */ Word64 out_Conv_CLDFB_imag[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : imag part of Binaural signals */ Word32 CLDFB_real[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i : real part of LS signals */ @@ -227,11 +227,12 @@ static void ivas_binRenderer_filterModule_fixed( * * Open convolution module handle of fastconv binaural renderer *-------------------------------------------------------------------------*/ - +#ifdef IVAS_FLOAT_FIXED #define NUM_TAPS_F0_6 ( Word16 )( 58 ) // (int16_t) ceil( 0.6f * hBinRenConvModule->numTaps ) #define NUM_TAPS_F0_5 ( Word16 )( 48 ) // (int16_t) ceil( 0.5f * hBinRenConvModule->numTaps ) #define NUM_TAPS_F0_4 ( Word16 )( 39 ) // (int16_t) ceil( 0.4f * hBinRenConvModule->numTaps ) #define NUM_TAPS_F0_3 ( Word16 )( 29 ) // (int16_t) ceil( 0.3f * hBinRenConvModule->numTaps ) +#endif static ivas_error ivas_binRenderer_convModuleOpen( BINAURAL_RENDERER_HANDLE hBinRenderer, @@ -1868,7 +1869,7 @@ void ivas_binaural_add_LFE( } #else -void ivas_binaural_add_LFE_fix( +void ivas_binaural_add_LFE_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ Word16 output_frame, /* i : length of input frame */ Word32 *input_fx[], /* i : transport channels */ @@ -2063,7 +2064,7 @@ void ivas_binRenderer( set64_fx( Cldfb_ImagBuffer_Binaural_fx[i][j], 0, hBinRenderer->conv_band ); } } - ivas_binRenderer_filterModule_fixed( Cldfb_RealBuffer_Binaural_fx, Cldfb_ImagBuffer_Binaural_fx, RealBuffer_fx, ImagBuffer_fx, numTimeSlots, hBinRenderer, exp_real_final ); + ivas_binRenderer_filterModule_fx( Cldfb_RealBuffer_Binaural_fx, Cldfb_ImagBuffer_Binaural_fx, RealBuffer_fx, ImagBuffer_fx, numTimeSlots, hBinRenderer, exp_real_final ); #endif /* Obtain the binaural dmx and compute the reverb */ @@ -2241,7 +2242,7 @@ void ivas_binRenderer_fx( ivas_sba2mc_cldfb_fixed(*(hBinRenderer->hInputSetup), RealBuffer_fx, ImagBuffer_fx, hBinRenderer->nInChannels, hBinRenderer->conv_band, numTimeSlots, hBinRenderer->hoa_dec_mtx); } - ivas_binRenderer_filterModule_fixed(Cldfb_RealBuffer_Binaural_64fx, Cldfb_ImagBuffer_Binaural_64fx, RealBuffer_fx, ImagBuffer_fx, numTimeSlots, hBinRenderer, *Q_in); + ivas_binRenderer_filterModule_fx(Cldfb_RealBuffer_Binaural_64fx, Cldfb_ImagBuffer_Binaural_64fx, RealBuffer_fx, ImagBuffer_fx, numTimeSlots, hBinRenderer, *Q_in); FOR(i = 0; i < BINAURAL_CHANNELS; i++) { diff --git a/lib_dec/ivas_cpe_dec.c b/lib_dec/ivas_cpe_dec.c index 48a92c535f351bfb583570754c8da50f293ccc6c..a86493ba4209e06e2a95a47cffcf4cb717ba339d 100644 --- a/lib_dec/ivas_cpe_dec.c +++ b/lib_dec/ivas_cpe_dec.c @@ -168,16 +168,6 @@ ivas_error ivas_cpe_dec( { if ( st_ivas->hQMetaData != NULL && ivas_total_brate > IVAS_SID_5k2 ) { -#ifdef IVAS_FLOAT_FIXED - if ( st_ivas->ivas_format == MASA_ISM_FORMAT ) - { - stereo_dft_config_fx( hCPE->hStereoDft == NULL ? NULL : hCPE->hStereoDft->hConfig, Mpy_32_32(1503238554 /* 0.7f in Q31 */, L_mult0(st_ivas->hQMetaData->bits_frame_nominal, FRAMES_PER_SEC) ), &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal ); - } - else - { - stereo_dft_config_fx( hCPE->hStereoDft == NULL ? NULL : hCPE->hStereoDft->hConfig, L_mult0(st_ivas->hQMetaData->bits_frame_nominal, FRAMES_PER_SEC), &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal ); - } -#else if ( st_ivas->ivas_format == MASA_ISM_FORMAT ) { stereo_dft_config( hCPE->hStereoDft == NULL ? NULL : hCPE->hStereoDft->hConfig, (int32_t) ( 0.7f * st_ivas->hQMetaData->bits_frame_nominal * FRAMES_PER_SEC ), &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal ); @@ -186,21 +176,10 @@ ivas_error ivas_cpe_dec( { stereo_dft_config( hCPE->hStereoDft == NULL ? NULL : hCPE->hStereoDft->hConfig, st_ivas->hQMetaData->bits_frame_nominal * FRAMES_PER_SEC, &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal ); } -#endif } else { /* Note: This only works for stereo operation. If DTX would be applied for multiple CPEs a different bitrate signaling is needed */ -#ifdef IVAS_FLOAT_FIXED - if ( ivas_total_brate <= IVAS_SID_5k2 ) - { - stereo_dft_config_fx( hCPE->hStereoDft == NULL ? NULL : hCPE->hStereoDft->hConfig, ivas_total_brate, &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal ); - } - else - { - stereo_dft_config_fx( hCPE->hStereoDft == NULL ? NULL : hCPE->hStereoDft->hConfig, hCPE->element_brate, &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal ); - } -#else if ( ivas_total_brate <= IVAS_SID_5k2 ) { stereo_dft_config( hCPE->hStereoDft == NULL ? NULL : hCPE->hStereoDft->hConfig, ivas_total_brate, &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal ); @@ -209,7 +188,6 @@ ivas_error ivas_cpe_dec( { stereo_dft_config( hCPE->hStereoDft == NULL ? NULL : hCPE->hStereoDft->hConfig, hCPE->element_brate, &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal ); } -#endif } } @@ -222,11 +200,7 @@ ivas_error ivas_cpe_dec( } else { -#ifdef IVAS_FLOAT_FIXED - stereo_dft_config_fx( NULL, hCPE->element_brate, &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal ); -#else stereo_dft_config( NULL, hCPE->element_brate, &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal ); -#endif } } @@ -241,9 +215,6 @@ ivas_error ivas_cpe_dec( { /* Update DFT Stereo memories */ stereo_dft_dec_update( hCPE->hStereoDft, output_frame, 0 ); -#ifdef IVAS_FLOAT_FIXED - stereo_dft_dec_update_fx( hCPE->hStereoDft, output_frame, 0 ); -#endif if ( st_ivas->ivas_format == MASA_FORMAT && ivas_total_brate <= IVAS_SID_5k2 ) { @@ -702,20 +673,6 @@ ivas_error create_cpe_dec( } set_zero( hCPE->input_mem_LB[i], STEREO_DFT32MS_OVL_16k ); -#ifdef IVAS_FLOAT_FIXED - IF( ( hCPE->input_mem_fx[i] = (Word32 *) malloc( sizeof( Word32 ) * NS2SA( output_Fs, STEREO_DFT32MS_OVL_NS ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DFT stereo memory\n" ) ); - } - set32_fx( hCPE->input_mem_fx[i], 0, NS2SA( output_Fs, STEREO_DFT32MS_OVL_NS ) ); - - IF( ( hCPE->input_mem_LB_fx[i] = (Word32 *) malloc( sizeof( Word32 ) * STEREO_DFT32MS_OVL_16k ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DFT stereo memory\n" ) ); - } - set32_fx( hCPE->input_mem_LB_fx[i], 0, STEREO_DFT32MS_OVL_16k ); -#endif - if ( i == 0 ) { if ( ( hCPE->input_mem_BPF[0] = (float *) malloc( sizeof( float ) * STEREO_DFT32MS_OVL_16k ) ) == NULL ) @@ -723,13 +680,6 @@ ivas_error create_cpe_dec( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DFT stereo memory\n" ) ); } set_zero( hCPE->input_mem_BPF[0], STEREO_DFT32MS_OVL_16k ); -#ifdef IVAS_FLOAT_FIXED - if ( ( hCPE->input_mem_BPF_fx[0] = (Word32 *) malloc( sizeof( Word32 ) * STEREO_DFT32MS_OVL_16k ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DFT stereo memory\n" ) ); - } - set32_fx( hCPE->input_mem_BPF_fx[0], 0, STEREO_DFT32MS_OVL_16k ); -#endif } @@ -886,9 +836,6 @@ ivas_error create_cpe_dec( hCPE->hStereoMdct->reverse_dmx = 0; hCPE->hStereoMdct->smooth_ratio = 1.f; -#ifdef IVAS_FLOAT_FIXED - hCPE->hStereoMdct->smooth_ratio_fx = ONE_IN_Q26; -#endif set_s( hCPE->hStereoMdct->prev_ms_mask[0], 0, MAX_SFB ); set_s( hCPE->hStereoMdct->prev_ms_mask[1], 0, MAX_SFB ); hCPE->hStereoMdct->lastCoh = 1.f; @@ -989,12 +936,6 @@ void destroy_cpe_dec( hCPE->input_mem[n] = NULL; free( hCPE->output_mem[n] ); hCPE->output_mem[n] = NULL; -#ifdef IVAS_FLOAT_FIXED - free( hCPE->input_mem_LB_fx[n] ); - hCPE->input_mem_LB_fx[n] = NULL; - free( hCPE->input_mem_fx[n] ); - hCPE->input_mem_fx[n] = NULL; -#endif if ( hCPE->prev_synth_chs[n] != NULL ) { @@ -1004,10 +945,6 @@ void destroy_cpe_dec( } free( hCPE->input_mem_BPF[0] ); hCPE->input_mem_BPF[0] = NULL; -#ifdef IVAS_FLOAT_FIXED - free( hCPE->input_mem_BPF_fx[0] ); - hCPE->input_mem_BPF_fx[0] = NULL; -#endif } diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index cd1b47041ab9669a29a2b0f2c5f291a8e6ba7c6c..2715e6abe92926e657d396e8b59bb9bbbcee6e09 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -1611,7 +1611,7 @@ static ivas_error ivas_dirac_rend_config( * Open or reconfigure decoder DirAC/MASA handle *-------------------------------------------------------------------------*/ #ifdef IVAS_FLOAT_FIXED -ivas_error ivas_dirac_dec_config( +ivas_error ivas_dirac_dec_config_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const DIRAC_CONFIG_FLAG flag_config_inp /* i/ : Flag determining if we open or reconfigure the DirAC decoder */ ) @@ -2027,12 +2027,12 @@ void ivas_dirac_dec_close_fx( } #endif /*------------------------------------------------------------------------- - * ivas_dirac_dec_read_BS() + * ivas_dirac_dec_read_BS_fx() * * Read DirAC parameters from the bitstream *------------------------------------------------------------------------*/ #ifdef IVAS_FLOAT_FIXED -void ivas_dirac_dec_read_BS( +void ivas_dirac_dec_read_BS_fx( const Word32 ivas_total_brate, /* i : IVAS total bitrate */ Decoder_State *st, /* i/o: decoder state structure */ DIRAC_DEC_HANDLE hDirAC, /* i/o: decoder DirAC handle */ @@ -3393,7 +3393,7 @@ void ivas_dirac_dec_set_md_map_fx( * DirAC decoding renderer process *------------------------------------------------------------------------*/ -void ivas_dirac_dec_render( +void ivas_dirac_dec_render_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ const Word16 nchan_transport, /* i : number of transport channels */ const UWord16 nSamplesAsked, /* i : number of CLDFB slots requested */ @@ -3446,7 +3446,7 @@ void ivas_dirac_dec_render( FOR( subframe_idx = first_sf; subframe_idx < last_sf; subframe_idx++ ) { - ivas_dirac_dec_render_sf( st_ivas, output_f_local, nchan_transport, NULL, NULL ); + ivas_dirac_dec_render_sf_fx( st_ivas, output_f_local, nchan_transport, NULL, NULL ); n_samples_sf = i_mult( hSpatParamRendCom->subframe_nbslots[subframe_idx], hSpatParamRendCom->slot_size ); @@ -3571,13 +3571,14 @@ void ivas_dirac_dec_render( } #endif +#ifdef IVAS_FLOAT_FIXED /*------------------------------------------------------------------------- - * ivas_dirac_dec_render_sf() + * ivas_dirac_dec_render_sf_fx() * * DirAC decoding renderer process *------------------------------------------------------------------------*/ -void ivas_dirac_dec_render_sf( +void ivas_dirac_dec_render_sf_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ float *output_f[], /* i/o: synthesized core-coder transport channels/DirAC output */ const int16_t nchan_transport, /* i : number of transport channels */ @@ -6016,3 +6017,826 @@ void ivas_dirac_dec_render_sf( return; } +#else +/*------------------------------------------------------------------------- + * ivas_dirac_dec_render_sf() + * + * DirAC decoding renderer process + *------------------------------------------------------------------------*/ + +void ivas_dirac_dec_render_sf( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + float *output_f[], /* i/o: synthesized core-coder transport channels/DirAC output */ + const int16_t nchan_transport, /* i : number of transport channels */ + float *pppQMfFrame_ts_re[IVAS_MAX_FB_MIXER_IN_CH][CLDFB_NO_COL_MAX], + float *pppQMfFrame_ts_im[IVAS_MAX_FB_MIXER_IN_CH][CLDFB_NO_COL_MAX] ) +{ + int16_t i, ch, idx_in, idx_lfe; + DIRAC_DEC_HANDLE hDirAC; + DIRAC_REND_HANDLE hDirACRend; + float dirEne; + float surCohEner; + float surCohRatio[CLDFB_NO_CHANNELS_MAX]; + int16_t subframe_idx; + int16_t slot_idx, index_slot; + int16_t hodirac_flag; + float *p_Rmat; + int16_t slot_idx_start, slot_idx_start_cldfb_synth, md_idx; + + /*CLDFB: last output channels reserved to LFT for CICPx*/ + float Cldfb_RealBuffer[MAX_OUTPUT_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; + float Cldfb_ImagBuffer[MAX_OUTPUT_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; + float Cldfb_RealBuffer_Binaural[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; + float Cldfb_ImagBuffer_Binaural[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; + float Cldfb_RealBuffer_Temp[2][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; + float Cldfb_ImagBuffer_Temp[2][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; + int16_t index, num_freq_bands; + + /* local copies of azi, ele, diffuseness */ + int16_t azimuth[CLDFB_NO_CHANNELS_MAX]; + int16_t elevation[CLDFB_NO_CHANNELS_MAX]; + float diffuseness_vector[CLDFB_NO_CHANNELS_MAX]; + + DIRAC_DEC_STACK_MEM DirAC_mem; + float *reference_power, *reference_power_smooth; + float *onset_filter, *onset_filter_subframe, *p_onset_filter = NULL; + uint16_t coherence_flag; + SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; + + push_wmops( "ivas_dirac_dec_render" ); + + /* Initialize aux buffers */ + hDirAC = st_ivas->hDirAC; + hDirACRend = st_ivas->hDirACRend; + hSpatParamRendCom = st_ivas->hSpatParamRendCom; + + DirAC_mem = hDirACRend->stack_mem; + + reference_power = DirAC_mem.reference_power; + reference_power_smooth = ( DirAC_mem.reference_power == NULL ) ? NULL : DirAC_mem.reference_power + hSpatParamRendCom->num_freq_bands; + onset_filter = DirAC_mem.onset_filter; + onset_filter_subframe = ( DirAC_mem.onset_filter == NULL ) ? NULL : DirAC_mem.onset_filter + hSpatParamRendCom->num_freq_bands; + + hodirac_flag = ivas_get_hodirac_flag( st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->sba_analysis_order ); + if ( st_ivas->hQMetaData != NULL && st_ivas->ivas_format != SBA_FORMAT && st_ivas->ivas_format != SBA_ISM_FORMAT ) + { + coherence_flag = st_ivas->hQMetaData->coherence_flag; + } + else + { + coherence_flag = 0; + } + + + /* Subframe loop */ + slot_idx_start = hSpatParamRendCom->slots_rendered; + slot_idx_start_cldfb_synth = 0; + + subframe_idx = hSpatParamRendCom->subframes_rendered; + if ( hDirAC->hConfig->dec_param_estim == FALSE ) + { + md_idx = hSpatParamRendCom->render_to_md_map[subframe_idx]; + } + else + { + md_idx = hSpatParamRendCom->render_to_md_map[slot_idx_start]; + } + + /* copy parameters into local buffers*/ + if ( hDirAC->hConfig->dec_param_estim == FALSE ) + { + mvs2s( hSpatParamRendCom->azimuth[hSpatParamRendCom->render_to_md_map[subframe_idx]], azimuth, hSpatParamRendCom->num_freq_bands ); + mvs2s( hSpatParamRendCom->elevation[hSpatParamRendCom->render_to_md_map[subframe_idx]], elevation, hSpatParamRendCom->num_freq_bands ); + mvr2r( hSpatParamRendCom->diffuseness_vector[hSpatParamRendCom->render_to_md_map[subframe_idx]], diffuseness_vector, hSpatParamRendCom->num_freq_bands ); + } + else + { + set_zero( diffuseness_vector, hSpatParamRendCom->num_freq_bands ); + } + + if ( hDirACRend->synthesisConf != DIRAC_SYNTHESIS_GAIN_SHD ) + { + set_zero( reference_power_smooth, hSpatParamRendCom->num_freq_bands ); + } + else + { + set_zero( onset_filter_subframe, hSpatParamRendCom->num_freq_bands ); + } + + if ( st_ivas->hCombinedOrientationData && st_ivas->hCombinedOrientationData->enableCombinedOrientation[st_ivas->hCombinedOrientationData->subframe_idx] ) + { + p_Rmat = &st_ivas->hCombinedOrientationData->Rmat[st_ivas->hCombinedOrientationData->subframe_idx][0][0]; + if ( st_ivas->hCombinedOrientationData->shd_rot_max_order == 0 ) + { + num_freq_bands = hDirAC->band_grouping[hDirAC->hConfig->enc_param_start_band]; + if ( hDirAC->hConfig->dec_param_estim == FALSE ) + { + rotateAziEle_DirAC( azimuth, elevation, num_freq_bands, hSpatParamRendCom->num_freq_bands, p_Rmat ); + } + } + } + else + { + p_Rmat = 0; + } + + if ( hDirAC->hConfig->dec_param_estim == FALSE ) + { + /* compute response */ + if ( hDirACRend->synthesisConf != DIRAC_SYNTHESIS_GAIN_SHD ) + { + ivas_dirac_dec_compute_power_factors( hSpatParamRendCom->num_freq_bands, + diffuseness_vector, + hDirACRend->h_output_synthesis_psd_params.max_band_decorr, + hDirACRend->h_output_synthesis_psd_state.direct_power_factor, + hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor ); + + if ( coherence_flag ) + { + for ( i = 0; i < hSpatParamRendCom->num_freq_bands; i++ ) + { + dirEne = hDirACRend->h_output_synthesis_psd_state.direct_power_factor[i]; + surCohEner = hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor[i] * hSpatParamRendCom->surroundingCoherence[md_idx][i]; + hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor[i] -= surCohEner; + hDirACRend->h_output_synthesis_psd_state.direct_power_factor[i] += surCohEner; + + surCohRatio[i] = surCohEner / ( 1e-12f + dirEne + surCohEner ); + } + } + else + { + set_zero( surCohRatio, hSpatParamRendCom->num_freq_bands ); + } + } + else + { + ivas_dirac_dec_compute_gain_factors( hSpatParamRendCom->num_freq_bands, + hSpatParamRendCom->diffuseness_vector[md_idx], + hDirACRend->h_output_synthesis_psd_params.max_band_decorr, + hDirACRend->h_output_synthesis_psd_state.direct_power_factor, + hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor ); + + if ( coherence_flag ) + { + for ( i = 0; i < hSpatParamRendCom->num_freq_bands; i++ ) + { + surCohRatio[i] = hSpatParamRendCom->surroundingCoherence[md_idx][i]; + } + } + else + { + set_zero( surCohRatio, hSpatParamRendCom->num_freq_bands ); + } + } + + if ( st_ivas->hCombinedOrientationData && st_ivas->hCombinedOrientationData->enableCombinedOrientation[st_ivas->hCombinedOrientationData->subframe_idx] && st_ivas->hCombinedOrientationData->shd_rot_max_order == 1 ) + { + ivas_dirac_dec_compute_directional_responses( hSpatParamRendCom, + hDirACRend, + st_ivas->hVBAPdata, + st_ivas->hMasa == NULL ? NULL : st_ivas->hMasa->data.band_mapping, + st_ivas->hMasaIsmData, + azimuth, + elevation, + md_idx, + surCohRatio, + st_ivas->hCombinedOrientationData->shd_rot_max_order, + p_Rmat, + hodirac_flag ); + } + else + { + ivas_dirac_dec_compute_directional_responses( hSpatParamRendCom, + hDirACRend, + st_ivas->hVBAPdata, + st_ivas->hMasa == NULL ? NULL : st_ivas->hMasa->data.band_mapping, + st_ivas->hMasaIsmData, + azimuth, + elevation, + md_idx, + surCohRatio, + 0, + NULL, + hodirac_flag ); + } + } + + if ( st_ivas->ivas_format == MASA_ISM_FORMAT && nchan_transport == 2 ) + { + for ( slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[subframe_idx]; slot_idx++ ) + { + index_slot = slot_idx_start + slot_idx; + + /* CLDFB Analysis*/ + for ( ch = 0; ch < nchan_transport; ch++ ) + { + cldfbAnalysis_ts_ivas( &( st_ivas->hTcBuffer->tc[hDirACRend->sba_map_tc[ch]][hSpatParamRendCom->num_freq_bands * index_slot] ), + Cldfb_RealBuffer_Temp[ch][slot_idx], + Cldfb_ImagBuffer_Temp[ch][slot_idx], + hSpatParamRendCom->num_freq_bands, + st_ivas->cldfbAnaDec[ch] ); + } + } + + if ( st_ivas->ism_mode != ISM_MASA_MODE_DISC && st_ivas->ism_mode != ISM_MASA_MODE_MASA_ONE_OBJ ) + { + ivas_omasa_preProcessStereoTransportsForMovedObjects( st_ivas, Cldfb_RealBuffer_Temp, Cldfb_ImagBuffer_Temp, hSpatParamRendCom->num_freq_bands, subframe_idx ); + } + } + + for ( slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[subframe_idx]; slot_idx++ ) + { + index_slot = slot_idx_start + slot_idx; + if ( hDirAC->hConfig->dec_param_estim == TRUE ) + { + md_idx = hSpatParamRendCom->render_to_md_map[index_slot]; + } + else + { + md_idx = hSpatParamRendCom->render_to_md_map[subframe_idx]; + } + if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) + { + for ( ch = 0; ch < nchan_transport; ch++ ) + { + mvr2r( pppQMfFrame_ts_re[ch][slot_idx], Cldfb_RealBuffer[ch][0], hSpatParamRendCom->num_freq_bands ); + mvr2r( pppQMfFrame_ts_im[ch][slot_idx], Cldfb_ImagBuffer[ch][0], hSpatParamRendCom->num_freq_bands ); + } + } + else if ( st_ivas->ivas_format == MASA_ISM_FORMAT && nchan_transport == 2 ) + { + for ( ch = 0; ch < nchan_transport; ch++ ) + { + mvr2r( Cldfb_RealBuffer_Temp[ch][slot_idx], Cldfb_RealBuffer[ch][0], hSpatParamRendCom->num_freq_bands ); + mvr2r( Cldfb_ImagBuffer_Temp[ch][slot_idx], Cldfb_ImagBuffer[ch][0], hSpatParamRendCom->num_freq_bands ); + } + } + else + { + /* CLDFB Analysis*/ + for ( ch = 0; ch < nchan_transport; ch++ ) + { + cldfbAnalysis_ts_ivas( &( st_ivas->hTcBuffer->tc[hDirACRend->sba_map_tc[ch]][hSpatParamRendCom->num_freq_bands * index_slot] ), + Cldfb_RealBuffer[ch][0], + Cldfb_ImagBuffer[ch][0], + hSpatParamRendCom->num_freq_bands, + st_ivas->cldfbAnaDec[ch] ); + } + } + + /* CNG in DirAC, extra CLDFB ana for CNA*/ + if ( st_ivas->nchan_transport == 1 && st_ivas->hSCE[0]->hCoreCoder[0] != NULL && st_ivas->hSCE[0]->hCoreCoder[0]->cna_dirac_flag && !( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) ) + { + Decoder_State *st = st_ivas->hSCE[0]->hCoreCoder[0]; + + generate_masking_noise_dirac( st->hFdCngDec->hFdCngCom, + st_ivas->cldfbAnaDec[1], + st_ivas->hTcBuffer->tc[1], + Cldfb_RealBuffer[1][0], + Cldfb_ImagBuffer[1][0], + index_slot, + st->cna_dirac_flag && st->flag_cna, + ( st->core_brate == FRAME_NO_DATA || st->core_brate == SID_2k40 ) && st->cng_type == FD_CNG && st->cng_sba_flag ); + } + + /* LFE synthesis */ + if ( st_ivas->mc_mode == MC_MODE_MCMASA && !hDirACRend->hOutSetup.separateChannelEnabled && !( hDirACRend->hOutSetup.output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM && hDirACRend->hOutSetup.num_lfe == 0 ) ) + { + ivas_lfe_synth_with_cldfb( st_ivas->hMasa->hMasaLfeSynth, + Cldfb_RealBuffer, Cldfb_ImagBuffer, + Cldfb_RealBuffer[MAX_OUTPUT_CHANNELS - 1], Cldfb_ImagBuffer[MAX_OUTPUT_CHANNELS - 1], + slot_idx, + md_idx, + nchan_transport ); + } + + /*-----------------------------------------------------------------* + * protoype signal computation + *-----------------------------------------------------------------*/ + + if ( hDirACRend->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD ) + { + if ( st_ivas->hCombinedOrientationData && st_ivas->hCombinedOrientationData->enableCombinedOrientation[st_ivas->hCombinedOrientationData->subframe_idx] && st_ivas->hCombinedOrientationData->shd_rot_max_order == 0 ) + { + protoSignalComputation_shd( Cldfb_RealBuffer, Cldfb_ImagBuffer, + hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f, + hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f, + reference_power, slot_idx, nchan_transport, + hDirACRend->num_outputs_diff, + hSpatParamRendCom->num_freq_bands, + p_Rmat ); + } + else + { + protoSignalComputation_shd( Cldfb_RealBuffer, Cldfb_ImagBuffer, + hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f, + hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f, + reference_power, slot_idx, nchan_transport, + hDirACRend->num_outputs_diff, + hSpatParamRendCom->num_freq_bands, + 0 ); + } + } + else if ( hDirACRend->synthesisConf == DIRAC_SYNTHESIS_MONO ) + { + protoSignalComputation2( Cldfb_RealBuffer, Cldfb_ImagBuffer, hDirACRend->proto_frame_f, + hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f, + reference_power, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth, + 0, slot_idx, hSpatParamRendCom->num_freq_bands, hDirACRend->masa_stereo_type_detect ); + } + else + { + switch ( nchan_transport ) + { + case 11: + case 8: + case 6: + case 4: + protoSignalComputation4( Cldfb_RealBuffer, Cldfb_ImagBuffer, + hDirACRend->proto_frame_f, + hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f, + reference_power, + hDirACRend->h_output_synthesis_psd_state.proto_power_smooth, + slot_idx, hDirACRend->num_outputs_diff, + hSpatParamRendCom->num_freq_bands, + hDirACRend->hoa_decoder, + nchan_transport, + hDirACRend->sba_map_tc ); + break; + case 2: + protoSignalComputation2( Cldfb_RealBuffer, Cldfb_ImagBuffer, + hDirACRend->proto_frame_f, + hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f, + reference_power, + hDirACRend->h_output_synthesis_psd_state.proto_power_smooth, + hDirACRend->hOutSetup.is_loudspeaker_setup, + slot_idx, + hSpatParamRendCom->num_freq_bands, + hDirACRend->masa_stereo_type_detect ); + break; + case 1: + protoSignalComputation1( Cldfb_RealBuffer, Cldfb_ImagBuffer, + hDirACRend->proto_frame_f, + hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f, + reference_power, + hDirACRend->h_output_synthesis_psd_state.proto_power_smooth, + slot_idx, + hDirACRend->num_protos_diff, + hSpatParamRendCom->num_freq_bands ); + break; + default: + return; + } + } + + + /*-----------------------------------------------------------------* + * Compute DirAC parameters at decoder side + *-----------------------------------------------------------------*/ + + if ( hDirAC->hConfig->dec_param_estim == TRUE ) + { + mvs2s( &hSpatParamRendCom->azimuth[md_idx][hDirAC->hConfig->enc_param_start_band], &azimuth[hDirAC->hConfig->enc_param_start_band], hSpatParamRendCom->num_freq_bands - hDirAC->hConfig->enc_param_start_band ); + mvs2s( &hSpatParamRendCom->elevation[md_idx][hDirAC->hConfig->enc_param_start_band], &elevation[hDirAC->hConfig->enc_param_start_band], hSpatParamRendCom->num_freq_bands - hDirAC->hConfig->enc_param_start_band ); + if ( ( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation ) && st_ivas->hCombinedOrientationData->shd_rot_max_order == 0 ) + { + num_freq_bands = hDirAC->band_grouping[hDirAC->hConfig->enc_param_start_band]; + rotateAziEle_DirAC( azimuth, elevation, num_freq_bands, hSpatParamRendCom->num_freq_bands, p_Rmat ); + } + + hDirACRend->index_buffer_intensity = ( hDirACRend->index_buffer_intensity % DIRAC_NO_COL_AVG_DIFF ) + 1; /* averaging_length = 32 */ + + index = hDirACRend->index_buffer_intensity; + + num_freq_bands = hDirAC->band_grouping[hDirAC->hConfig->enc_param_start_band]; + + computeIntensityVector_dec( Cldfb_RealBuffer, + Cldfb_ImagBuffer, + num_freq_bands, + hDirACRend->buffer_intensity_real[0][index - 1], + hDirACRend->buffer_intensity_real[1][index - 1], + hDirACRend->buffer_intensity_real[2][index - 1] ); + + computeDirectionAngles( hDirACRend->buffer_intensity_real[0][index - 1], + hDirACRend->buffer_intensity_real[1][index - 1], + hDirACRend->buffer_intensity_real[2][index - 1], + num_freq_bands, + azimuth, + elevation ); + + mvr2r( reference_power, &( hDirACRend->buffer_energy[( index - 1 ) * num_freq_bands] ), num_freq_bands ); + + computeDiffuseness( hDirACRend->buffer_intensity_real, hDirACRend->buffer_energy, num_freq_bands, hSpatParamRendCom->diffuseness_vector[md_idx] ); + } + + + /*-----------------------------------------------------------------* + * frequency domain decorrelation + *-----------------------------------------------------------------*/ + + if ( hDirACRend->proto_signal_decorr_on == 1 ) + { + /* decorrelate prototype frame */ + if ( hDirACRend->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD ) + { + ivas_dirac_dec_decorr_process( hSpatParamRendCom->num_freq_bands, + hDirACRend->num_outputs_diff, + hDirACRend->num_protos_diff, + hDirACRend->synthesisConf, + nchan_transport, + hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f + slot_idx * 2 * hSpatParamRendCom->num_freq_bands * hDirACRend->num_outputs_diff, + hDirACRend->num_protos_diff, + hDirACRend->proto_index_diff, + hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f + slot_idx * 2 * hSpatParamRendCom->num_freq_bands * hDirACRend->num_outputs_diff + 2 * hSpatParamRendCom->num_freq_bands * min( 4, nchan_transport ), + onset_filter, + hDirACRend->h_freq_domain_decorr_ap_params, + hDirACRend->h_freq_domain_decorr_ap_state ); + + v_multc( onset_filter, 0.25f, onset_filter, hSpatParamRendCom->num_freq_bands ); + v_add( onset_filter, onset_filter_subframe, onset_filter_subframe, hSpatParamRendCom->num_freq_bands ); + p_onset_filter = onset_filter_subframe; + } + else + { + ivas_dirac_dec_decorr_process( hSpatParamRendCom->num_freq_bands, + hDirACRend->num_outputs_diff, + hDirACRend->num_protos_diff, + hDirACRend->synthesisConf, + nchan_transport, + hDirACRend->proto_frame_f, + hDirACRend->num_protos_diff, + hDirACRend->proto_index_diff, + DirAC_mem.frame_dec_f, + onset_filter, + hDirACRend->h_freq_domain_decorr_ap_params, + hDirACRend->h_freq_domain_decorr_ap_state ); + + hDirACRend->proto_frame_dec_f = DirAC_mem.frame_dec_f; + p_onset_filter = onset_filter; + } + } + else + { + if ( hDirACRend->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD ) + { + set_f( onset_filter_subframe, 1.f, hSpatParamRendCom->num_freq_bands ); + p_onset_filter = onset_filter_subframe; + } + else + { + /* no frequency domain decorrelation: use prototype frame */ + hDirACRend->proto_frame_dec_f = hDirACRend->proto_frame_f; + p_onset_filter = NULL; + } + } + + /*-----------------------------------------------------------------* + * output synthesis + *-----------------------------------------------------------------*/ + + if ( hDirACRend->synthesisConf == DIRAC_SYNTHESIS_PSD_LS || hDirACRend->synthesisConf == DIRAC_SYNTHESIS_PSD_SHD ) + { + /*Compute diffuse prototypes*/ + ivas_dirac_dec_compute_diffuse_proto( hDirACRend, hSpatParamRendCom->num_freq_bands, slot_idx ); + } + + /*Compute PSDs*/ + if ( st_ivas->hCombinedOrientationData && st_ivas->hCombinedOrientationData->enableCombinedOrientation[st_ivas->hCombinedOrientationData->subframe_idx] && st_ivas->hCombinedOrientationData->shd_rot_max_order > 0 ) + { + ivas_dirac_dec_output_synthesis_process_slot( reference_power, + p_onset_filter, + azimuth, + elevation, + hSpatParamRendCom->diffuseness_vector[md_idx], + hSpatParamRendCom, + hDirACRend, + st_ivas->hCombinedOrientationData->shd_rot_max_order, + p_Rmat, + st_ivas->hVBAPdata, + hDirACRend->hOutSetup, + nchan_transport, + md_idx, + hodirac_flag, + hDirAC->hConfig->dec_param_estim ); + } + else + { + ivas_dirac_dec_output_synthesis_process_slot( reference_power, + p_onset_filter, + azimuth, + elevation, + hSpatParamRendCom->diffuseness_vector[md_idx], + hSpatParamRendCom, + hDirACRend, + 0, + 0, + st_ivas->hVBAPdata, + hDirACRend->hOutSetup, + nchan_transport, + md_idx, + hodirac_flag, + hDirAC->hConfig->dec_param_estim ); + } + + if ( hDirAC->hConfig->dec_param_estim ) + { + float fac = 1.0f / (float) hSpatParamRendCom->subframe_nbslots[subframe_idx]; + v_multc_acc( hSpatParamRendCom->diffuseness_vector[md_idx], fac, diffuseness_vector, hSpatParamRendCom->num_freq_bands ); + } + + if ( hDirACRend->synthesisConf != DIRAC_SYNTHESIS_GAIN_SHD ) + { + v_add( reference_power, reference_power_smooth, reference_power_smooth, hSpatParamRendCom->num_freq_bands ); + } + } + + ivas_dirac_dec_output_synthesis_get_interpolator( &hDirACRend->h_output_synthesis_psd_params, hSpatParamRendCom->subframe_nbslots[subframe_idx] ); + + + if ( hDirACRend->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD ) + { + ivas_dirac_dec_output_synthesis_process_subframe_gain_shd( Cldfb_RealBuffer, + Cldfb_ImagBuffer, + hSpatParamRendCom, + hDirACRend, + nchan_transport, + hSpatParamRendCom->subframe_nbslots[subframe_idx], + p_onset_filter, + diffuseness_vector, + hodirac_flag, + hDirAC->hConfig->dec_param_estim ); + } + else + { + /* Determine encoding quality based additional smoothing factor */ + float qualityBasedSmFactor = 1.0f; + + if ( st_ivas->hMasa != NULL ) + { + qualityBasedSmFactor = st_ivas->hMasa->data.dir_decode_quality; + qualityBasedSmFactor *= qualityBasedSmFactor; + } + + ivas_dirac_dec_output_synthesis_process_subframe_psd_ls( Cldfb_RealBuffer, + Cldfb_ImagBuffer, + hSpatParamRendCom, + hDirACRend, + hSpatParamRendCom->subframe_nbslots[subframe_idx], + diffuseness_vector, + reference_power_smooth, + qualityBasedSmFactor, + hDirAC->hConfig->enc_param_start_band ); + } + + /*-----------------------------------------------------------------* + * CLDFB synthesis (and binaural rendering) + *-----------------------------------------------------------------*/ + + index_slot = slot_idx_start_cldfb_synth; + + if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) + { + /* render objects in combined format onto the CICP19 channels for BINAURAL_ROOM_IR */ + if ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_SBA_MODE_DISC && st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) + { + int16_t in_ch; + for ( in_ch = 0; in_ch < st_ivas->nchan_ism; in_ch++ ) + { + int16_t j, k, j2, l; + int16_t num_objects, nchan_out_woLFE, lfe_index; + int16_t az1, el1; + int16_t n_slots_to_render; + int16_t n_samples_to_render; + int16_t interp_offset; + float gain, prev_gain; + + num_objects = st_ivas->nchan_ism; + nchan_out_woLFE = st_ivas->hIntSetup.nchan_out_woLFE; + n_slots_to_render = st_ivas->hSpar->subframe_nbslots[st_ivas->hSpar->subframes_rendered]; + n_samples_to_render = hSpatParamRendCom->num_freq_bands * n_slots_to_render; + interp_offset = st_ivas->hTcBuffer->n_samples_rendered; + + if ( st_ivas->hCombinedOrientationData && st_ivas->hCombinedOrientationData->enableCombinedOrientation[0] ) + { + ivas_jbm_dec_get_adapted_linear_interpolator( n_samples_to_render, n_samples_to_render, st_ivas->hIsmRendererData->interpolator ); + interp_offset = 0; + } + + for ( i = 0; i < num_objects; i++ ) + { + /* Combined rotation: rotate the object positions depending the head and external orientations */ + if ( st_ivas->hCombinedOrientationData != NULL && st_ivas->hCombinedOrientationData->enableCombinedOrientation[0] == 1 ) + { + rotateAziEle( st_ivas->hIsmMetaData[i]->azimuth, st_ivas->hIsmMetaData[i]->elevation, &az1, &el1, st_ivas->hCombinedOrientationData->Rmat[0], st_ivas->hIntSetup.is_planar_setup ); + if ( st_ivas->hEFAPdata != NULL ) + { + efap_determine_gains( st_ivas->hEFAPdata, st_ivas->hIsmRendererData->gains[i], az1, el1, EFAP_MODE_EFAP ); + } + } + + lfe_index = 0; + for ( j = 0, j2 = 0; j < nchan_out_woLFE; j++, j2++ ) + { + if ( ( st_ivas->hIntSetup.num_lfe > 0 ) && ( st_ivas->hIntSetup.index_lfe[lfe_index] == j ) ) + { + ( lfe_index < ( st_ivas->hIntSetup.num_lfe - 1 ) ) ? ( lfe_index++, j2++ ) : j2++; + } + + gain = st_ivas->hIsmRendererData->gains[i][j]; + prev_gain = st_ivas->hIsmRendererData->prev_gains[i][j]; + if ( fabsf( gain ) > 0.0f || fabsf( prev_gain ) > 0.0f ) + { + float *tc_re, *tc_im; + float *w1, w2; + + w1 = &st_ivas->hIsmRendererData->interpolator[interp_offset]; + tc_re = pppQMfFrame_ts_re[nchan_transport + i][0]; + tc_im = pppQMfFrame_ts_im[nchan_transport + i][0]; + + for ( k = 0; k < n_slots_to_render; k++ ) + { + float g; + + w2 = 1.0f - *w1; + g = ( *w1 * gain + w2 * prev_gain ); + + for ( l = 0; l < hSpatParamRendCom->num_freq_bands; l++ ) + { + Cldfb_RealBuffer[j2][0][k * hSpatParamRendCom->num_freq_bands + l] += g * *( tc_re++ ); + Cldfb_ImagBuffer[j2][0][k * hSpatParamRendCom->num_freq_bands + l] += g * *( tc_im++ ); + } + w1 += hSpatParamRendCom->num_freq_bands; + } + } + + /* update here only in case of head rotation */ + if ( st_ivas->hCombinedOrientationData != NULL && st_ivas->hCombinedOrientationData->enableCombinedOrientation[0] == 1 ) + { + st_ivas->hIsmRendererData->prev_gains[i][j] = gain; + } + } + } + } + } + + + /* Perform binaural rendering */ + ivas_binRenderer( st_ivas->hBinRenderer, + + st_ivas->hCombinedOrientationData, + hSpatParamRendCom->subframe_nbslots[subframe_idx], + Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer, Cldfb_ImagBuffer ); + + /* Inverse CLDFB*/ + for ( ch = 0; ch < st_ivas->hDecoderConfig->nchan_out; ch++ ) + { + /* open CLDFB buffer up to CLDFB_NO_CHANNELS_MAX bands for 48kHz */ + float *RealBuffer[MAX_PARAM_SPATIAL_SUBFRAMES]; + float *ImagBuffer[MAX_PARAM_SPATIAL_SUBFRAMES]; + + for ( i = 0; i < hSpatParamRendCom->subframe_nbslots[subframe_idx]; i++ ) + { + RealBuffer[i] = Cldfb_RealBuffer_Binaural[ch][i]; + ImagBuffer[i] = Cldfb_ImagBuffer_Binaural[ch][i]; + } + + cldfbSynthesis_ivas( RealBuffer, ImagBuffer, &( output_f[ch][index_slot * hSpatParamRendCom->num_freq_bands] ), hSpatParamRendCom->num_freq_bands * hSpatParamRendCom->subframe_nbslots[subframe_idx], st_ivas->cldfbSynDec[ch] ); + } + } + else if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) + { + for ( ch = 0; ch < hDirACRend->hOutSetup.nchan_out_woLFE; ch++ ) + { + for ( slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[subframe_idx]; slot_idx++ ) + { + mvr2r( Cldfb_RealBuffer[ch][slot_idx], pppQMfFrame_ts_re[ch][slot_idx], hSpatParamRendCom->num_freq_bands ); + mvr2r( Cldfb_ImagBuffer[ch][slot_idx], pppQMfFrame_ts_im[ch][slot_idx], hSpatParamRendCom->num_freq_bands ); + } + } + } + else + { + float *RealBuffer[MAX_PARAM_SPATIAL_SUBFRAMES]; + float *ImagBuffer[MAX_PARAM_SPATIAL_SUBFRAMES]; + int16_t outchannels; + + idx_in = 0; + idx_lfe = 0; + + outchannels = hDirACRend->hOutSetup.nchan_out_woLFE + hDirACRend->hOutSetup.num_lfe; + if ( hDirACRend->hOutSetup.separateChannelEnabled && ( hDirACRend->hOutSetup.output_config == IVAS_AUDIO_CONFIG_5_1 || + hDirACRend->hOutSetup.output_config == IVAS_AUDIO_CONFIG_7_1 || + hDirACRend->hOutSetup.output_config == IVAS_AUDIO_CONFIG_5_1_2 || + hDirACRend->hOutSetup.output_config == IVAS_AUDIO_CONFIG_5_1_4 || + hDirACRend->hOutSetup.output_config == IVAS_AUDIO_CONFIG_7_1_4 || + ( hDirACRend->hOutSetup.output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM && st_ivas->hLsSetupCustom->separate_ch_found ) ) ) + { + outchannels++; + } + + if ( hDirACRend->hOutSetup.separateChannelEnabled && hDirACRend->hOutSetup.output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM ) + { + float tmp_separated[L_FRAME48k / MAX_PARAM_SPATIAL_SUBFRAMES]; + float tmp_lfe[L_FRAME48k / MAX_PARAM_SPATIAL_SUBFRAMES]; + const int16_t subframe_start_sample = index_slot * hSpatParamRendCom->num_freq_bands; + const int16_t num_samples_subframe = hSpatParamRendCom->num_freq_bands * hSpatParamRendCom->subframe_nbslots[subframe_idx]; + + /* Move the separated and the LFE channels to temporary variables as spatial synthesis may overwrite current channels */ + mvr2r( &( output_f[st_ivas->hOutSetup.separateChannelIndex][subframe_start_sample] ), tmp_separated, num_samples_subframe ); + mvr2r( &( output_f[LFE_CHANNEL][subframe_start_sample] ), tmp_lfe, num_samples_subframe ); + + for ( ch = 0; ch < outchannels; ch++ ) + { + if ( ( hDirACRend->hOutSetup.num_lfe > 0 ) && ( hDirACRend->hOutSetup.index_lfe[idx_lfe] == ch ) ) + { + /* Move the LFE channel to the correct place */ + mvr2r( tmp_lfe, &( output_f[ch][subframe_start_sample] ), num_samples_subframe ); + + if ( idx_lfe < ( hDirACRend->hOutSetup.num_lfe - 1 ) ) + { + idx_lfe++; + } + } + else if ( ( st_ivas->hLsSetupCustom->separate_ch_found ) && ( hDirACRend->hOutSetup.separateChannelIndex == ch ) ) + { + /* Move the separated channel to the correct place. Thus, the separated channel is + * combined with the synthesized channels here when there is a matching channel. */ + mvr2r( tmp_separated, &( output_f[ch][subframe_start_sample] ), num_samples_subframe ); + } + else + { + /* open CLDFB buffer up to CLDFB_NO_CHANNELS_MAX bands for 48kHz */ + for ( i = 0; i < hSpatParamRendCom->subframe_nbslots[subframe_idx]; i++ ) + { + RealBuffer[i] = Cldfb_RealBuffer[idx_in][i]; + ImagBuffer[i] = Cldfb_ImagBuffer[idx_in][i]; + } + cldfbSynthesis_ivas( RealBuffer, ImagBuffer, &( output_f[ch][subframe_start_sample] ), num_samples_subframe, st_ivas->cldfbSynDec[idx_in] ); + + if ( !st_ivas->hLsSetupCustom->separate_ch_found ) + { + /* Pan the separated channel and mix with the synthesized channels. Thus, the separated channel + * is combined with the synthesized channels here when there is no matching channel. */ + v_multc_acc( tmp_separated, st_ivas->hLsSetupCustom->separate_ch_gains[idx_in], &( output_f[ch][subframe_start_sample] ), num_samples_subframe ); + } + + idx_in++; + } + } + } + else + { + for ( ch = 0; ch < outchannels; ch++ ) + { + if ( ( hDirACRend->hOutSetup.num_lfe > 0 ) && ( hDirACRend->hOutSetup.index_lfe[idx_lfe] == ch ) ) + { + if ( st_ivas->mc_mode == MC_MODE_MCMASA && !hDirACRend->hOutSetup.separateChannelEnabled ) + { + for ( i = 0; i < hSpatParamRendCom->subframe_nbslots[subframe_idx]; i++ ) + { + RealBuffer[i] = Cldfb_RealBuffer[MAX_OUTPUT_CHANNELS - 1][i]; + ImagBuffer[i] = Cldfb_ImagBuffer[MAX_OUTPUT_CHANNELS - 1][i]; + } + cldfbSynthesis_ivas( RealBuffer, ImagBuffer, &( output_f[ch][index_slot * hSpatParamRendCom->num_freq_bands] ), hSpatParamRendCom->num_freq_bands * hSpatParamRendCom->subframe_nbslots[subframe_idx], st_ivas->cldfbSynDec[hDirACRend->hOutSetup.nchan_out_woLFE + idx_lfe] ); + } + else if ( st_ivas->mc_mode == MC_MODE_MCMASA && hDirACRend->hOutSetup.separateChannelEnabled ) + { + /* LFE has been synthesized in the time domain, do nothing. */ + } + else + { + set_zero( &( output_f[ch][index_slot * hSpatParamRendCom->num_freq_bands] ), hSpatParamRendCom->subframe_nbslots[subframe_idx] * hSpatParamRendCom->num_freq_bands ); + } + + if ( idx_lfe < ( hDirACRend->hOutSetup.num_lfe - 1 ) ) + { + idx_lfe++; + } + } + else if ( ( hDirACRend->hOutSetup.separateChannelEnabled ) && ( hDirACRend->hOutSetup.separateChannelIndex == ch ) ) + { + /* The separated channel is already set to output_f[hOutSetup.separateChannelIndex]. Thus, the separated + * channel is combined with the synthesized channels here. */ + } + else + { + /* open CLDFB buffer up to CLDFB_NO_CHANNELS_MAX bands for 48kHz */ + for ( i = 0; i < hSpatParamRendCom->subframe_nbslots[subframe_idx]; i++ ) + { + RealBuffer[i] = Cldfb_RealBuffer[idx_in][i]; + ImagBuffer[i] = Cldfb_ImagBuffer[idx_in][i]; + } + cldfbSynthesis_ivas( RealBuffer, ImagBuffer, &( output_f[ch][index_slot * hSpatParamRendCom->num_freq_bands] ), hSpatParamRendCom->num_freq_bands * hSpatParamRendCom->subframe_nbslots[subframe_idx], st_ivas->cldfbSynDec[idx_in] ); + idx_in++; + } + } + } + } + hSpatParamRendCom->slots_rendered += hSpatParamRendCom->subframe_nbslots[subframe_idx]; + hSpatParamRendCom->subframes_rendered++; + + pop_wmops(); + + return; +} +#endif \ No newline at end of file diff --git a/lib_dec/ivas_dirac_output_synthesis_cov.c b/lib_dec/ivas_dirac_output_synthesis_cov.c index c461c12c6556d504ea3038993b60074ccc581ee3..374a0dc9ac13af4f6668455bec359a87eef86649 100644 --- a/lib_dec/ivas_dirac_output_synthesis_cov.c +++ b/lib_dec/ivas_dirac_output_synthesis_cov.c @@ -535,7 +535,7 @@ void ivas_dirac_dec_output_synthesis_cov_init( *-------------------------------------------------------------------*/ #ifdef IVAS_FLOAT_FIXED -void ivas_dirac_dec_output_synthesis_cov_close( +void ivas_dirac_dec_output_synthesis_cov_close_fx( DIRAC_OUTPUT_SYNTHESIS_PARAMS *h_dirac_output_synthesis_params, /* i : handle for the covariance synthesis parameters */ DIRAC_OUTPUT_SYNTHESIS_COV_STATE *h_dirac_output_synthesis_state /* i/o: handle for the covariance synthesis state */ ) diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index cdd62ba9ffef213b0ece470189ef593f9de06795..4cf481f52ced6c4cdfcb774c6bc886751f618e36 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -158,7 +158,11 @@ 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; } @@ -852,7 +856,11 @@ 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; } @@ -871,7 +879,11 @@ 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; } @@ -1300,7 +1312,7 @@ ivas_error ivas_init_decoder_front( * Initialize IVAS decoder state structure *-------------------------------------------------------------------*/ #ifdef IVAS_FLOAT_FIXED -ivas_error ivas_init_decoder( +ivas_error ivas_init_decoder_fx( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ) { @@ -1502,7 +1514,7 @@ ivas_error ivas_init_decoder( } } - 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_fx( st_ivas, st_ivas->nSCE, element_brate_tmp ) ) != IVAS_ERR_OK ) { return error; } @@ -1560,7 +1572,7 @@ ivas_error ivas_init_decoder( 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_fx( st_ivas, DIRAC_OPEN ) ) != IVAS_ERR_OK ) { return error; } @@ -1648,7 +1660,7 @@ ivas_error ivas_init_decoder( 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_fx( st_ivas, DIRAC_OPEN ) ) != IVAS_ERR_OK ) { return error; } @@ -1713,7 +1725,7 @@ ivas_error ivas_init_decoder( 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_fx( st_ivas, DIRAC_OPEN ) ) != IVAS_ERR_OK ) { return error; } @@ -1788,7 +1800,7 @@ ivas_error ivas_init_decoder( 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_fx( st_ivas, st_ivas->nchan_ism, temp_brate ) ) != IVAS_ERR_OK ) { return error; } @@ -1832,7 +1844,7 @@ ivas_error ivas_init_decoder( 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_fx( st_ivas, 1, NULL ) ) != IVAS_ERR_OK ) { return error; } @@ -1855,7 +1867,7 @@ 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_fx( st_ivas, st_ivas->nchan_ism, temp_brate ) ) != IVAS_ERR_OK ) { return error; } @@ -1873,7 +1885,7 @@ ivas_error ivas_init_decoder( 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_fx( st_ivas, DIRAC_OPEN ) ) != IVAS_ERR_OK ) { return error; } @@ -2024,7 +2036,7 @@ ivas_error ivas_init_decoder( 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_fx( st_ivas, DIRAC_OPEN ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_dec/ivas_ism_dec.c b/lib_dec/ivas_ism_dec.c index c56520a7a518d8fc11212378c702b002febb3aec..f11f5cb76a5213428e439b8cb02920a2c4c30fcc 100644 --- a/lib_dec/ivas_ism_dec.c +++ b/lib_dec/ivas_ism_dec.c @@ -1248,7 +1248,7 @@ static ivas_error ivas_ism_bitrate_switching_dec( *-------------------------------------------------------------------------*/ #ifdef IVAS_FLOAT_FIXED -ivas_error ivas_ism_dec_config( +ivas_error ivas_ism_dec_config_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const ISM_MODE last_ism_mode, /* i/o: last ISM mode */ UWord16 *nSamplesRendered, /* o : number of samples flushed when the renderer granularity changes */ diff --git a/lib_dec/ivas_ism_metadata_dec.c b/lib_dec/ivas_ism_metadata_dec.c index 918f8eb7ff68d1b490851f3bcf4a013289988c2e..95f26554dfc4a2f9f84b1b0b92d6fb659efb5113 100644 --- a/lib_dec/ivas_ism_metadata_dec.c +++ b/lib_dec/ivas_ism_metadata_dec.c @@ -51,10 +51,13 @@ /*-----------------------------------------------------------------------* * Local functions *-----------------------------------------------------------------------*/ - +#ifdef IVAS_FLOAT_FIXED +static void decode_angle_indices_fx( DEC_CORE_HANDLE st0, ISM_METADATA_ANGLE_HANDLE angle, const int16_t non_diegetic_flag, int16_t *flag_abs_azimuth ); +static int16_t decode_radius_fx( DEC_CORE_HANDLE st0, int16_t *last_radius_idx, int16_t *flag_abs_radius ); +#else static void decode_angle_indices( DEC_CORE_HANDLE st0, ISM_METADATA_ANGLE_HANDLE angle, const int16_t non_diegetic_flag, int16_t *flag_abs_azimuth ); - static int16_t decode_radius( DEC_CORE_HANDLE st0, int16_t *last_radius_idx, int16_t *flag_abs_radius ); +#endif /*-------------------------------------------------------------------------* @@ -454,7 +457,11 @@ ivas_error ivas_ism_metadata_dec( if ( hIsmMetaData->non_diegetic_flag ) { /* Panning gain decoding */ +#ifdef IVAS_FLOAT_FIXED + decode_angle_indices_fx( st0, &( hIsmMetaData->position_angle ), hIsmMetaData->non_diegetic_flag, &flag_abs_position ); +#else decode_angle_indices( st0, &( hIsmMetaData->position_angle ), hIsmMetaData->non_diegetic_flag, &flag_abs_position ); +#endif idx_angle1 = hIsmMetaData->position_angle.last_angle1_idx; idx_angle2 = 1 << ( ISM_ELEVATION_NBITS - 1 ); @@ -468,7 +475,11 @@ ivas_error ivas_ism_metadata_dec( } else { +#ifdef IVAS_FLOAT_FIXED + decode_angle_indices_fx( st0, &( hIsmMetaData->position_angle ), hIsmMeta[ch]->non_diegetic_flag, &flag_abs_position ); +#else decode_angle_indices( st0, &( hIsmMetaData->position_angle ), hIsmMeta[ch]->non_diegetic_flag, &flag_abs_position ); +#endif idx_angle1 = hIsmMetaData->position_angle.last_angle1_idx; idx_angle2 = hIsmMetaData->position_angle.last_angle2_idx; @@ -486,13 +497,21 @@ ivas_error ivas_ism_metadata_dec( /* radius/raw/pitch dequantization */ if ( ism_extmeta_bitstream ) { +#ifdef IVAS_FLOAT_FIXED + decode_angle_indices_fx( st0, &( hIsmMetaData->orientation_angle ), hIsmMeta[ch]->non_diegetic_flag, &flag_abs_orientation ); +#else decode_angle_indices( st0, &( hIsmMetaData->orientation_angle ), hIsmMeta[ch]->non_diegetic_flag, &flag_abs_orientation ); +#endif idx_angle1 = hIsmMetaData->orientation_angle.last_angle1_idx; idx_angle2 = hIsmMetaData->orientation_angle.last_angle2_idx; yaw = ism_dequant_meta( idx_angle1, ism_azimuth_borders, ISM_Q_STEP, ISM_Q_STEP_BORDER, 1 << ISM_AZIMUTH_NBITS ); pitch = ism_dequant_meta( idx_angle2, ism_elevation_borders, ISM_Q_STEP, ISM_Q_STEP_BORDER, 1 << ISM_ELEVATION_NBITS ); +#ifdef IVAS_FLOAT_FIXED + idx_radius = decode_radius_fx( st0, &hIsmMetaData->last_radius_idx, &flag_abs_radius ); +#else idx_radius = decode_radius( st0, &hIsmMetaData->last_radius_idx, &flag_abs_radius ); +#endif radius = usdequant( idx_radius, ISM_RADIUS_MIN, ISM_RADIUS_DELTA ); if ( *ism_extmeta_active == 1 ) { @@ -970,7 +989,7 @@ ivas_error ivas_ism_metadata_dec_fx( IF ( hIsmMetaData->non_diegetic_flag ) { /* Panning gain decoding */ - decode_angle_indices( st0, &( hIsmMetaData->position_angle ), hIsmMetaData->non_diegetic_flag, &flag_abs_position ); + decode_angle_indices_fx( st0, &( hIsmMetaData->position_angle ), hIsmMetaData->non_diegetic_flag, &flag_abs_position ); idx_angle1 = hIsmMetaData->position_angle.last_angle1_idx; idx_angle2 = 1 << ( ISM_ELEVATION_NBITS - 1 ); @@ -984,7 +1003,7 @@ ivas_error ivas_ism_metadata_dec_fx( } ELSE { - decode_angle_indices( st0, &( hIsmMetaData->position_angle ), hIsmMeta[ch]->non_diegetic_flag, &flag_abs_position ); + decode_angle_indices_fx( st0, &( hIsmMetaData->position_angle ), hIsmMeta[ch]->non_diegetic_flag, &flag_abs_position ); idx_angle1 = hIsmMetaData->position_angle.last_angle1_idx; idx_angle2 = hIsmMetaData->position_angle.last_angle2_idx; @@ -1002,13 +1021,13 @@ ivas_error ivas_ism_metadata_dec_fx( /* radius/raw/pitch dequantization */ IF ( ism_extmeta_bitstream ) { - decode_angle_indices( st0, &( hIsmMetaData->orientation_angle ), hIsmMeta[ch]->non_diegetic_flag, &flag_abs_orientation ); + decode_angle_indices_fx( st0, &( hIsmMetaData->orientation_angle ), hIsmMeta[ch]->non_diegetic_flag, &flag_abs_orientation ); idx_angle1 = hIsmMetaData->orientation_angle.last_angle1_idx; idx_angle2 = hIsmMetaData->orientation_angle.last_angle2_idx; yaw_fx = ism_dequant_meta_fx( idx_angle1, ism_azimuth_borders_fx, (Word32)(ISM_Q_STEP * (1<<22)), (Word32)(ISM_Q_STEP_BORDER * (1<<22)), 1 << ISM_AZIMUTH_NBITS ); pitch_fx = ism_dequant_meta_fx( idx_angle2, ism_elevation_borders_fx, (Word32)(ISM_Q_STEP * (1<<22)), (Word32)(ISM_Q_STEP_BORDER * (1<<22)), 1 << ISM_ELEVATION_NBITS ); - idx_radius = decode_radius( st0, &hIsmMetaData->last_radius_idx, &flag_abs_radius ); + idx_radius = decode_radius_fx( st0, &hIsmMetaData->last_radius_idx, &flag_abs_radius ); radius_fx = usdequant_fx( idx_radius, (Word16)(ISM_RADIUS_MIN * (1 << 9)) , (Word16)(ISM_RADIUS_DELTA * (1 << 9)) ); IF ( *ism_extmeta_active == 1 ) { @@ -1234,7 +1253,7 @@ ivas_error ivas_ism_metadata_dec_fx( *-------------------------------------------------------------------------*/ #ifdef IVAS_FLOAT_FIXED -ivas_error ivas_ism_metadata_dec_create( +ivas_error ivas_ism_metadata_dec_create_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const Word16 n_ISms, /* i : number of objects */ Word32 element_brate_tmp[] /* o : element bitrate per object */ @@ -1367,7 +1386,7 @@ ivas_error ivas_ism_metadata_dec_create( *-------------------------------------------------------------------------*/ #ifdef IVAS_FLOAT_FIXED -static void decode_angle_indices( +static void decode_angle_indices_fx( DEC_CORE_HANDLE st0, /* i/o: bitstream handle */ ISM_METADATA_ANGLE_HANDLE angle, /* i/o: angle handle */ const Word16 non_diegetic_flag, /* i : Non diegetic flag */ @@ -1669,7 +1688,7 @@ static void decode_angle_indices( *-------------------------------------------------------------------------*/ #ifdef IVAS_FLOAT_FIXED -static Word16 decode_radius( +static Word16 decode_radius_fx( DEC_CORE_HANDLE st0, /* i/o: bitstream handle */ Word16 *last_radius_idx, /* i/o: last radius index */ Word16 *flag_abs_radius /* o : Radius encoding mode */ diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 8150ec3553f19257166c5bd5655e672c6342828b..263c50c45e52f36e0e3b82b163675852459a91d4 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -202,13 +202,6 @@ ivas_error ivas_jbm_dec_tc( { Scale_sig32( p_output_fx[i], output_frame, s ); } - FOR( i = 0; i < st_ivas->hDecoderConfig->nchan_out; i++ ) - { - FOR( j = 0; j < st_ivas->nchan_transport; j++ ) - { - st_ivas->hLsSetUpConversion->dmxMtx_fx[j][i] = float_to_fix( st_ivas->hLsSetUpConversion->dmxMtx[j][i], Q30 ); - } - } ivas_ls_setup_conversion_fx( st_ivas, st_ivas->nchan_transport, output_frame, p_output_fx, p_output_fx ); FOR( i = 0; i < max( st_ivas->hDecoderConfig->nchan_out, st_ivas->nchan_transport ); ++i ) { @@ -495,53 +488,8 @@ ivas_error ivas_jbm_dec_tc( hCPE->hCoreCoder[n]->hHQ_core->Q_old_postdec = 0; hCPE->hCoreCoder[n]->hHQ_core->Q_old_wtda = 0; } - /*-------------------cldfb-start-------------------------*/ - - floatToFixed_arrL( hCPE->hCoreCoder[n]->bpf_noise_buf_float, hCPE->hCoreCoder[n]->bpf_noise_buf_32, 11, L_FRAME_16k ); - if ( hCPE->hCoreCoder[n]->cldfbAna != NULL ) - { - floatToFixed_arrL( hCPE->hCoreCoder[n]->cldfbAna->cldfb_state, hCPE->hCoreCoder[n]->cldfbAna->cldfb_state_fx, 10, hCPE->hCoreCoder[n]->cldfbAna->cldfb_size ); - } - if ( hCPE->hCoreCoder[n]->cldfbSyn != NULL ) - { - floatToFixed_arrL( hCPE->hCoreCoder[n]->cldfbSyn->cldfb_state, hCPE->hCoreCoder[n]->cldfbSyn->cldfb_state_fx, 4, hCPE->hCoreCoder[n]->cldfbSyn->p_filter_length ); - } - if ( hCPE->hCoreCoder[n]->cldfbBPF != NULL ) - { - floatToFixed_arrL( hCPE->hCoreCoder[n]->cldfbBPF->cldfb_state, hCPE->hCoreCoder[n]->cldfbBPF->cldfb_state_fx, 11, hCPE->hCoreCoder[n]->cldfbBPF->cldfb_size ); - } - - - /*-------------------cldfb-end---------------------------*/ - } - - FOR( n = 0; n < CPE_CHANNELS; n++ ) - { - FOR( k = 0; k < NS2SA( 48000, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ); k++ ) - { - hCPE->prev_synth_fx[n][k] = (Word32) ( hCPE->prev_synth[n][k] * ( 1 << q_output ) ); - } - } - } - - IF( st_ivas->hLsSetUpConversion && st_ivas->hLsSetUpConversion->targetEnergyPrev ) - f2me_buf( st_ivas->hLsSetUpConversion->targetEnergyPrev[0], st_ivas->hLsSetUpConversion->targetEnergyPrev_fx[0], &st_ivas->hLsSetUpConversion->te_prev_exp, st_ivas->hLsSetUpConversion->sfbCnt ); - IF( st_ivas->hLsSetUpConversion && st_ivas->hLsSetUpConversion->dmxEnergyPrev ) - f2me_buf( st_ivas->hLsSetUpConversion->dmxEnergyPrev[0], st_ivas->hLsSetUpConversion->dmxEnergyPrev_fx[0], &st_ivas->hLsSetUpConversion->dmx_prev_exp, st_ivas->hLsSetUpConversion->sfbCnt ); - IF( st_ivas->hParamMC && st_ivas->hParamMC->icld_q ) - floatToFixed_arr16( st_ivas->hParamMC->icld_q, st_ivas->hParamMC->icld_q_fx, 8, st_ivas->hParamMC->hMetadataPMC->num_parameter_bands * st_ivas->hParamMC->hMetadataPMC->ild_mapping_conf->ild_map_size_lfe ); - IF( st_ivas->hParamMC && st_ivas->hParamMC->ls_conv_dmx_matrix ) - floatToFixed_arr32( st_ivas->hParamMC->ls_conv_dmx_matrix, st_ivas->hParamMC->ls_conv_dmx_matrix_fx, 15, st_ivas->hDecoderConfig->nchan_out * ( st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe ) ); - IF( st_ivas->hLsSetUpConversion ) - FOR( Word16 chOutIdx = 0; chOutIdx < st_ivas->hDecoderConfig->nchan_out; chOutIdx++ ) - { - FOR( Word16 chInIdx = 0; chInIdx < st_ivas->nchan_transport; chInIdx++ ) - { - st_ivas->hLsSetUpConversion->dmxMtx_fx[chInIdx][chOutIdx] = float_to_fix( st_ivas->hLsSetUpConversion->dmxMtx[chInIdx][chOutIdx], 30 ); /*Q30*/ } } - - #endif // Float to fix if ( ( error = ivas_mct_dec_fx( st_ivas, p_output_fx, output_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) { @@ -1436,9 +1384,6 @@ ivas_error ivas_jbm_dec_tc( IF( st->hTcxDec ) st->hTcxDec->conCurrLevelIndex = st->hTcxDec->CurrLevelIndex_bfi; - - /*cldfb struct*/ - /*------------------fix-to-fix-start---------------------*/ /*core_switching_post_dec*/ if ( hCPE->hCoreCoder[n]->hHQ_core != NULL ) @@ -1446,50 +1391,6 @@ ivas_error ivas_jbm_dec_tc( hCPE->hCoreCoder[n]->hHQ_core->Q_old_postdec = 0; hCPE->hCoreCoder[n]->hHQ_core->Q_old_wtda = 0; } - - /*-------------------cldfb-start-------------------------*/ - - floatToFixed_arrL( hCPE->hCoreCoder[n]->bpf_noise_buf_float, hCPE->hCoreCoder[n]->bpf_noise_buf_32, 11, L_FRAME_16k ); - if ( hCPE->hCoreCoder[n]->cldfbAna != NULL ) - { - floatToFixed_arrL( hCPE->hCoreCoder[n]->cldfbAna->cldfb_state, hCPE->hCoreCoder[n]->cldfbAna->cldfb_state_fx, 10, hCPE->hCoreCoder[n]->cldfbAna->cldfb_size ); - } - if ( hCPE->hCoreCoder[n]->cldfbSyn != NULL ) - { - floatToFixed_arrL( hCPE->hCoreCoder[n]->cldfbSyn->cldfb_state, hCPE->hCoreCoder[n]->cldfbSyn->cldfb_state_fx, 4, hCPE->hCoreCoder[n]->cldfbSyn->p_filter_length ); - } - if ( hCPE->hCoreCoder[n]->cldfbBPF != NULL ) - { - floatToFixed_arrL( hCPE->hCoreCoder[n]->cldfbBPF->cldfb_state, hCPE->hCoreCoder[n]->cldfbBPF->cldfb_state_fx, 11, hCPE->hCoreCoder[n]->cldfbBPF->cldfb_size ); - } - - - /*-------------------cldfb-end---------------------------*/ - } - - FOR( n = 0; n < CPE_CHANNELS; n++ ) - { - FOR( k = 0; k < NS2SA( 48000, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ); k++ ) - { - hCPE->prev_synth_fx[n][k] = (Word32) ( hCPE->prev_synth[n][k] * ( 1 << q_output ) ); - } - } - } - - IF( st_ivas->hLsSetUpConversion && st_ivas->hLsSetUpConversion->targetEnergyPrev ) - f2me_buf( st_ivas->hLsSetUpConversion->targetEnergyPrev[0], st_ivas->hLsSetUpConversion->targetEnergyPrev_fx[0], &st_ivas->hLsSetUpConversion->te_prev_exp, st_ivas->hLsSetUpConversion->sfbCnt ); - IF( st_ivas->hLsSetUpConversion && st_ivas->hLsSetUpConversion->dmxEnergyPrev ) - f2me_buf( st_ivas->hLsSetUpConversion->dmxEnergyPrev[0], st_ivas->hLsSetUpConversion->dmxEnergyPrev_fx[0], &st_ivas->hLsSetUpConversion->dmx_prev_exp, st_ivas->hLsSetUpConversion->sfbCnt ); - IF( st_ivas->hParamMC && st_ivas->hParamMC->icld_q ) - floatToFixed_arr16( st_ivas->hParamMC->icld_q, st_ivas->hParamMC->icld_q_fx, 8, st_ivas->hParamMC->hMetadataPMC->num_parameter_bands * st_ivas->hParamMC->hMetadataPMC->ild_mapping_conf->ild_map_size_lfe ); - IF( st_ivas->hParamMC && st_ivas->hParamMC->ls_conv_dmx_matrix ) - floatToFixed_arr32( st_ivas->hParamMC->ls_conv_dmx_matrix, st_ivas->hParamMC->ls_conv_dmx_matrix_fx, 15, st_ivas->hDecoderConfig->nchan_out * ( st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe ) ); - IF( st_ivas->hLsSetUpConversion ) - FOR( Word16 chOutIdx = 0; chOutIdx < st_ivas->hDecoderConfig->nchan_out; chOutIdx++ ) - { - FOR( Word16 chInIdx = 0; chInIdx < st_ivas->nchan_transport; chInIdx++ ) - { - st_ivas->hLsSetUpConversion->dmxMtx_fx[chInIdx][chOutIdx] = float_to_fix( st_ivas->hLsSetUpConversion->dmxMtx[chInIdx][chOutIdx], 30 ); /*Q30*/ } } @@ -2145,54 +2046,8 @@ ivas_error ivas_jbm_dec_tc( hCPE->hCoreCoder[n]->hHQ_core->Q_old_postdec = 0; hCPE->hCoreCoder[n]->hHQ_core->Q_old_wtda = 0; } - - /*-------------------cldfb-start-------------------------*/ - - floatToFixed_arrL( hCPE->hCoreCoder[n]->bpf_noise_buf_float, hCPE->hCoreCoder[n]->bpf_noise_buf_32, 11, L_FRAME_16k ); - if ( hCPE->hCoreCoder[n]->cldfbAna != NULL ) - { - floatToFixed_arrL( hCPE->hCoreCoder[n]->cldfbAna->cldfb_state, hCPE->hCoreCoder[n]->cldfbAna->cldfb_state_fx, 10, hCPE->hCoreCoder[n]->cldfbAna->cldfb_size ); - } - if ( hCPE->hCoreCoder[n]->cldfbSyn != NULL ) - { - floatToFixed_arrL( hCPE->hCoreCoder[n]->cldfbSyn->cldfb_state, hCPE->hCoreCoder[n]->cldfbSyn->cldfb_state_fx, 4, hCPE->hCoreCoder[n]->cldfbSyn->p_filter_length ); - } - if ( hCPE->hCoreCoder[n]->cldfbBPF != NULL ) - { - floatToFixed_arrL( hCPE->hCoreCoder[n]->cldfbBPF->cldfb_state, hCPE->hCoreCoder[n]->cldfbBPF->cldfb_state_fx, 11, hCPE->hCoreCoder[n]->cldfbBPF->cldfb_size ); - } - - - /*-------------------cldfb-end---------------------------*/ - } - - FOR( n = 0; n < CPE_CHANNELS; n++ ) - { - FOR( k = 0; k < NS2SA( 48000, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ); k++ ) - { - hCPE->prev_synth_fx[n][k] = (Word32) ( hCPE->prev_synth[n][k] * ( 1 << q_output ) ); - } } } - - IF( st_ivas->hLsSetUpConversion && st_ivas->hLsSetUpConversion->targetEnergyPrev ) - f2me_buf( st_ivas->hLsSetUpConversion->targetEnergyPrev[0], st_ivas->hLsSetUpConversion->targetEnergyPrev_fx[0], &st_ivas->hLsSetUpConversion->te_prev_exp, st_ivas->hLsSetUpConversion->sfbCnt ); - IF( st_ivas->hLsSetUpConversion && st_ivas->hLsSetUpConversion->dmxEnergyPrev ) - f2me_buf( st_ivas->hLsSetUpConversion->dmxEnergyPrev[0], st_ivas->hLsSetUpConversion->dmxEnergyPrev_fx[0], &st_ivas->hLsSetUpConversion->dmx_prev_exp, st_ivas->hLsSetUpConversion->sfbCnt ); - IF( st_ivas->hParamMC && st_ivas->hParamMC->icld_q ) - floatToFixed_arr16( st_ivas->hParamMC->icld_q, st_ivas->hParamMC->icld_q_fx, 8, st_ivas->hParamMC->hMetadataPMC->num_parameter_bands * st_ivas->hParamMC->hMetadataPMC->ild_mapping_conf->ild_map_size_lfe ); - IF( st_ivas->hParamMC && st_ivas->hParamMC->ls_conv_dmx_matrix ) - floatToFixed_arr32( st_ivas->hParamMC->ls_conv_dmx_matrix, st_ivas->hParamMC->ls_conv_dmx_matrix_fx, 15, st_ivas->hDecoderConfig->nchan_out * ( st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe ) ); - IF( st_ivas->hLsSetUpConversion ) - FOR( Word16 chOutIdx = 0; chOutIdx < st_ivas->hDecoderConfig->nchan_out; chOutIdx++ ) - { - FOR( Word16 chInIdx = 0; chInIdx < st_ivas->nchan_transport; chInIdx++ ) - { - st_ivas->hLsSetUpConversion->dmxMtx_fx[chInIdx][chOutIdx] = float_to_fix( st_ivas->hLsSetUpConversion->dmxMtx[chInIdx][chOutIdx], 30 ); /*Q30*/ - } - } - - #endif // Float to fix IF( ( error = ivas_mct_dec_fx( st_ivas, p_output_fx, output_frame, 0 ) ) != IVAS_ERR_OK ) { @@ -2341,13 +2196,6 @@ ivas_error ivas_jbm_dec_tc( { Scale_sig32( p_output_fx[i], output_frame, s ); } - FOR( i = 0; i < st_ivas->hDecoderConfig->nchan_out; i++ ) - { - FOR( j = 0; j < st_ivas->nchan_transport; j++ ) - { - st_ivas->hLsSetUpConversion->dmxMtx_fx[j][i] = float_to_fix( st_ivas->hLsSetUpConversion->dmxMtx[j][i], Q30 ); - } - } ivas_ls_setup_conversion_fx( st_ivas, st_ivas->nchan_transport, output_frame, p_output_fx, p_output_fx ); FOR( i = 0; i < max( st_ivas->hDecoderConfig->nchan_out, st_ivas->nchan_transport ); ++i ) { @@ -2411,9 +2259,6 @@ ivas_error ivas_jbm_dec_tc( IF( st->hTcxDec ) st->hTcxDec->conCurrLevelIndex = st->hTcxDec->CurrLevelIndex_bfi; - - /*cldfb struct*/ - /*------------------fix-to-fix-start---------------------*/ /*core_switching_post_dec*/ if ( hCPE->hCoreCoder[n]->hHQ_core != NULL ) @@ -2421,50 +2266,6 @@ ivas_error ivas_jbm_dec_tc( hCPE->hCoreCoder[n]->hHQ_core->Q_old_postdec = 0; hCPE->hCoreCoder[n]->hHQ_core->Q_old_wtda = 0; } - - /*-------------------cldfb-start-------------------------*/ - - floatToFixed_arrL( hCPE->hCoreCoder[n]->bpf_noise_buf_float, hCPE->hCoreCoder[n]->bpf_noise_buf_32, 11, L_FRAME_16k ); - if ( hCPE->hCoreCoder[n]->cldfbAna != NULL ) - { - floatToFixed_arrL( hCPE->hCoreCoder[n]->cldfbAna->cldfb_state, hCPE->hCoreCoder[n]->cldfbAna->cldfb_state_fx, 10, hCPE->hCoreCoder[n]->cldfbAna->cldfb_size ); - } - if ( hCPE->hCoreCoder[n]->cldfbSyn != NULL ) - { - floatToFixed_arrL( hCPE->hCoreCoder[n]->cldfbSyn->cldfb_state, hCPE->hCoreCoder[n]->cldfbSyn->cldfb_state_fx, 4, hCPE->hCoreCoder[n]->cldfbSyn->p_filter_length ); - } - if ( hCPE->hCoreCoder[n]->cldfbBPF != NULL ) - { - floatToFixed_arrL( hCPE->hCoreCoder[n]->cldfbBPF->cldfb_state, hCPE->hCoreCoder[n]->cldfbBPF->cldfb_state_fx, 11, hCPE->hCoreCoder[n]->cldfbBPF->cldfb_size ); - } - - - /*-------------------cldfb-end---------------------------*/ - } - - FOR( n = 0; n < CPE_CHANNELS; n++ ) - { - FOR( k = 0; k < NS2SA( 48000, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ); k++ ) - { - hCPE->prev_synth_fx[n][k] = (Word32) ( hCPE->prev_synth[n][k] * ( 1 << q_output ) ); - } - } - } - - IF( st_ivas->hLsSetUpConversion && st_ivas->hLsSetUpConversion->targetEnergyPrev ) - f2me_buf( st_ivas->hLsSetUpConversion->targetEnergyPrev[0], st_ivas->hLsSetUpConversion->targetEnergyPrev_fx[0], &st_ivas->hLsSetUpConversion->te_prev_exp, st_ivas->hLsSetUpConversion->sfbCnt ); - IF( st_ivas->hLsSetUpConversion && st_ivas->hLsSetUpConversion->dmxEnergyPrev ) - f2me_buf( st_ivas->hLsSetUpConversion->dmxEnergyPrev[0], st_ivas->hLsSetUpConversion->dmxEnergyPrev_fx[0], &st_ivas->hLsSetUpConversion->dmx_prev_exp, st_ivas->hLsSetUpConversion->sfbCnt ); - IF( st_ivas->hParamMC && st_ivas->hParamMC->icld_q ) - floatToFixed_arr16( st_ivas->hParamMC->icld_q, st_ivas->hParamMC->icld_q_fx, 8, st_ivas->hParamMC->hMetadataPMC->num_parameter_bands * st_ivas->hParamMC->hMetadataPMC->ild_mapping_conf->ild_map_size_lfe ); - IF( st_ivas->hParamMC && st_ivas->hParamMC->ls_conv_dmx_matrix ) - floatToFixed_arr32( st_ivas->hParamMC->ls_conv_dmx_matrix, st_ivas->hParamMC->ls_conv_dmx_matrix_fx, 15, st_ivas->hDecoderConfig->nchan_out * ( st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe ) ); - IF( st_ivas->hLsSetUpConversion ) - FOR( Word16 chOutIdx = 0; chOutIdx < st_ivas->hDecoderConfig->nchan_out; chOutIdx++ ) - { - FOR( Word16 chInIdx = 0; chInIdx < st_ivas->nchan_transport; chInIdx++ ) - { - st_ivas->hLsSetUpConversion->dmxMtx_fx[chInIdx][chOutIdx] = float_to_fix( st_ivas->hLsSetUpConversion->dmxMtx[chInIdx][chOutIdx], 30 ); /*Q30*/ } } #endif // Float to fix @@ -2612,13 +2413,6 @@ ivas_error ivas_jbm_dec_tc( { Scale_sig32( p_output_fx[i], output_frame, s ); } - FOR( i = 0; i < st_ivas->hDecoderConfig->nchan_out; i++ ) - { - FOR( j = 0; j < nchan_transport; j++ ) - { - st_ivas->hLsSetUpConversion->dmxMtx_fx[j][i] = float_to_fix( st_ivas->hLsSetUpConversion->dmxMtx[j][i], Q30 ); - } - } ivas_ls_setup_conversion_fx( st_ivas, nchan_transport, output_frame, p_output_fx, p_output_fx ); FOR( i = 0; i < max( st_ivas->hDecoderConfig->nchan_out, nchan_transport ); ++i ) { @@ -2698,54 +2492,8 @@ ivas_error ivas_jbm_dec_tc( hCPE->hCoreCoder[n]->hHQ_core->Q_old_postdec = 0; hCPE->hCoreCoder[n]->hHQ_core->Q_old_wtda = 0; } - - /*-------------------cldfb-start-------------------------*/ - - floatToFixed_arrL( hCPE->hCoreCoder[n]->bpf_noise_buf_float, hCPE->hCoreCoder[n]->bpf_noise_buf_32, 11, L_FRAME_16k ); - if ( hCPE->hCoreCoder[n]->cldfbAna != NULL ) - { - floatToFixed_arrL( hCPE->hCoreCoder[n]->cldfbAna->cldfb_state, hCPE->hCoreCoder[n]->cldfbAna->cldfb_state_fx, 10, hCPE->hCoreCoder[n]->cldfbAna->cldfb_size ); - } - if ( hCPE->hCoreCoder[n]->cldfbSyn != NULL ) - { - floatToFixed_arrL( hCPE->hCoreCoder[n]->cldfbSyn->cldfb_state, hCPE->hCoreCoder[n]->cldfbSyn->cldfb_state_fx, 4, hCPE->hCoreCoder[n]->cldfbSyn->p_filter_length ); - } - if ( hCPE->hCoreCoder[n]->cldfbBPF != NULL ) - { - floatToFixed_arrL( hCPE->hCoreCoder[n]->cldfbBPF->cldfb_state, hCPE->hCoreCoder[n]->cldfbBPF->cldfb_state_fx, 11, hCPE->hCoreCoder[n]->cldfbBPF->cldfb_size ); - } - - - /*-------------------cldfb-end---------------------------*/ - } - - FOR( n = 0; n < CPE_CHANNELS; n++ ) - { - FOR( k = 0; k < NS2SA( 48000, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ); k++ ) - { - hCPE->prev_synth_fx[n][k] = (Word32) ( hCPE->prev_synth[n][k] * ( 1 << q_output ) ); - } - } - } - - IF( st_ivas->hLsSetUpConversion && st_ivas->hLsSetUpConversion->targetEnergyPrev ) - f2me_buf( st_ivas->hLsSetUpConversion->targetEnergyPrev[0], st_ivas->hLsSetUpConversion->targetEnergyPrev_fx[0], &st_ivas->hLsSetUpConversion->te_prev_exp, st_ivas->hLsSetUpConversion->sfbCnt ); - IF( st_ivas->hLsSetUpConversion && st_ivas->hLsSetUpConversion->dmxEnergyPrev ) - f2me_buf( st_ivas->hLsSetUpConversion->dmxEnergyPrev[0], st_ivas->hLsSetUpConversion->dmxEnergyPrev_fx[0], &st_ivas->hLsSetUpConversion->dmx_prev_exp, st_ivas->hLsSetUpConversion->sfbCnt ); - IF( st_ivas->hParamMC && st_ivas->hParamMC->icld_q ) - floatToFixed_arr16( st_ivas->hParamMC->icld_q, st_ivas->hParamMC->icld_q_fx, 8, st_ivas->hParamMC->hMetadataPMC->num_parameter_bands * st_ivas->hParamMC->hMetadataPMC->ild_mapping_conf->ild_map_size_lfe ); - IF( st_ivas->hParamMC && st_ivas->hParamMC->ls_conv_dmx_matrix ) - floatToFixed_arr32( st_ivas->hParamMC->ls_conv_dmx_matrix, st_ivas->hParamMC->ls_conv_dmx_matrix_fx, 15, st_ivas->hDecoderConfig->nchan_out * ( st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe ) ); - IF( st_ivas->hLsSetUpConversion ) - FOR( Word16 chOutIdx = 0; chOutIdx < st_ivas->hDecoderConfig->nchan_out; chOutIdx++ ) - { - FOR( Word16 chInIdx = 0; chInIdx < st_ivas->nchan_transport; chInIdx++ ) - { - st_ivas->hLsSetUpConversion->dmxMtx_fx[chInIdx][chOutIdx] = float_to_fix( st_ivas->hLsSetUpConversion->dmxMtx[chInIdx][chOutIdx], 30 ); /*Q30*/ } } - - #endif // Float to fix if ( ( error = ivas_mct_dec_fx( st_ivas, p_output_fx, output_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) { @@ -2881,13 +2629,6 @@ ivas_error ivas_jbm_dec_tc( { Scale_sig32( p_output_fx[i], output_frame, s ); } - FOR( i = 0; i < st_ivas->hDecoderConfig->nchan_out; i++ ) - { - FOR( j = 0; j < st_ivas->nchan_transport; j++ ) - { - st_ivas->hLsSetUpConversion->dmxMtx_fx[j][i] = float_to_fix( st_ivas->hLsSetUpConversion->dmxMtx[j][i], Q30 ); - } - } ivas_ls_setup_conversion_fx( st_ivas, st_ivas->nchan_transport, output_frame, p_output_fx, p_output_fx ); FOR( i = 0; i < max( st_ivas->hDecoderConfig->nchan_out, st_ivas->nchan_transport ); ++i ) { @@ -6091,7 +5832,7 @@ ivas_error ivas_jbm_dec_render( } else if ( st_ivas->renderer_type == RENDERER_DIRAC ) { - ivas_dirac_dec_render( st_ivas, nchan_remapped, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output ); + ivas_dirac_dec_render_fx( st_ivas, nchan_remapped, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output ); } } else @@ -6934,7 +6675,7 @@ ivas_error ivas_jbm_dec_render( { return error; } - ivas_binaural_add_LFE_fix( st_ivas, *nSamplesRendered, p_tc_fx, p_output_fx ); + ivas_binaural_add_LFE_fx( st_ivas, *nSamplesRendered, p_tc_fx, p_output_fx ); for ( i = 0; i < nchan_in; i++ ) { @@ -7011,7 +6752,7 @@ ivas_error ivas_jbm_dec_render( floatToFixed_arrL( p_output[i], p_output_fx[i], q, *nSamplesRendered ); } - ivas_binaural_add_LFE_fix( st_ivas, *nSamplesRendered, p_tc_fx, p_output_fx ); + ivas_binaural_add_LFE_fx( st_ivas, *nSamplesRendered, p_tc_fx, p_output_fx ); FOR( i = 0; i < st_ivas->nchan_transport; ++i ) { @@ -7070,7 +6811,7 @@ ivas_error ivas_jbm_dec_render( floatToFixed_arrL( p_output[i], p_output_fx[i], q, *nSamplesRendered ); } - ivas_binaural_add_LFE_fix( st_ivas, *nSamplesRendered, p_output_fx, p_output_fx ); + ivas_binaural_add_LFE_fx( st_ivas, *nSamplesRendered, p_output_fx, p_output_fx ); FOR( i = 0; i < max( st_ivas->hDecoderConfig->nchan_out, MC_PARAMUPMIX_MAX_INPUT_CHANS ); ++i ) { @@ -7117,7 +6858,7 @@ ivas_error ivas_jbm_dec_render( floatToFixed_arrL( p_output[i], p_output_fx[i], q, *nSamplesRendered ); } - ivas_binaural_add_LFE_fix( st_ivas, *nSamplesRendered, p_output_fx, p_output_fx ); + ivas_binaural_add_LFE_fx( st_ivas, *nSamplesRendered, p_output_fx, p_output_fx ); FOR( i = 0; i < max( st_ivas->hDecoderConfig->nchan_out, MC_PARAMUPMIX_MAX_INPUT_CHANS ); ++i ) { @@ -7140,7 +6881,7 @@ ivas_error ivas_jbm_dec_render( } else if ( st_ivas->renderer_type == RENDERER_DIRAC || st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) /* rendering to CICPxx and Ambisonics */ { - ivas_dirac_dec_render( st_ivas, nchan_remapped, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output ); + ivas_dirac_dec_render_fx( st_ivas, nchan_remapped, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output ); if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) { @@ -7876,7 +7617,7 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( return error; } - ivas_binaural_add_LFE_fix( st_ivas, hTcBuffer->n_samples_granularity, st_ivas->hTcBuffer->tc_fx, p_output_fx ); + ivas_binaural_add_LFE_fx( st_ivas, hTcBuffer->n_samples_granularity, st_ivas->hTcBuffer->tc_fx, p_output_fx ); } ELSE IF( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_OBJECTS_TD ) ) { @@ -7884,7 +7625,7 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( { return error; } - ivas_binaural_add_LFE_fix( st_ivas, *nSamplesRendered, st_ivas->hTcBuffer->tc_fx, p_output_fx ); + ivas_binaural_add_LFE_fx( st_ivas, *nSamplesRendered, st_ivas->hTcBuffer->tc_fx, p_output_fx ); } } ELSE @@ -8245,7 +7986,7 @@ ivas_error ivas_jbm_dec_flush_renderer( return error; } - ivas_binaural_add_LFE_fix( st_ivas, hTcBuffer->n_samples_granularity, st_ivas->hTcBuffer->tc_fx, p_output_fx ); + ivas_binaural_add_LFE_fx( st_ivas, hTcBuffer->n_samples_granularity, st_ivas->hTcBuffer->tc_fx, p_output_fx ); for ( i = 0; i < nchan_in; i++ ) { @@ -8282,7 +8023,7 @@ ivas_error ivas_jbm_dec_flush_renderer( floatToFixed_arrL( p_output[i], p_output_fx[i], q, *nSamplesRendered ); } - ivas_binaural_add_LFE_fix( st_ivas, *nSamplesRendered, st_ivas->hTcBuffer->tc_fx, p_output_fx ); + ivas_binaural_add_LFE_fx( st_ivas, *nSamplesRendered, st_ivas->hTcBuffer->tc_fx, p_output_fx ); FOR( i = 0; i < st_ivas->nchan_transport; ++i ) { diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index d00146d3e6723af844542763725c5fa15a9a9bd7..a97e1163b2ff28a9c291540b512b8f5678cee535 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -3067,7 +3067,11 @@ ivas_error ivas_masa_dec_reconfigure( ( ( st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) && st_ivas->hDiracDecBin == NULL ) ) { /* init a new DirAC dec */ +#ifdef IVAS_FLOAT_FIXED + if ( ( error = ivas_dirac_dec_config_fx( st_ivas, DIRAC_OPEN ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_dirac_dec_config( st_ivas, DIRAC_OPEN ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -3103,7 +3107,11 @@ ivas_error ivas_masa_dec_reconfigure( if ( ( st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) && st_ivas->hDiracDecBin != NULL ) { +#ifdef IVAS_FLOAT_FIXED + if ( ( error = ivas_dirac_dec_config_fx( st_ivas, DIRAC_RECONFIGURE ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_dirac_dec_config( st_ivas, DIRAC_RECONFIGURE ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -3129,7 +3137,11 @@ ivas_error ivas_masa_dec_reconfigure( if ( ( st_ivas->renderer_type == RENDERER_DIRAC && st_ivas->hDirACRend != NULL ) || ( ( st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) && st_ivas->hDiracDecBin != NULL ) ) { +#ifdef IVAS_FLOAT_FIXED + if ( ( error = ivas_dirac_dec_config_fx( st_ivas, DIRAC_RECONFIGURE ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_dirac_dec_config( st_ivas, DIRAC_RECONFIGURE ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -3141,7 +3153,11 @@ ivas_error ivas_masa_dec_reconfigure( if ( ( st_ivas->renderer_type == RENDERER_DIRAC && st_ivas->hDirACRend != NULL ) || ( ( st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) && st_ivas->hDiracDecBin != NULL ) ) { +#ifdef IVAS_FLOAT_FIXED + if ( ( error = ivas_dirac_dec_config_fx( st_ivas, DIRAC_RECONFIGURE ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_dirac_dec_config( st_ivas, DIRAC_RECONFIGURE ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -3507,7 +3523,7 @@ ivas_error ivas_masa_dec_reconfigure_fx( ( ( EQ_16( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) && st_ivas->hDiracDecBin == NULL ) ) { /* init a new DirAC dec */ - IF( ( error = ivas_dirac_dec_config( st_ivas, DIRAC_OPEN ) ) != IVAS_ERR_OK ) + IF( ( error = ivas_dirac_dec_config_fx( st_ivas, DIRAC_OPEN ) ) != IVAS_ERR_OK ) { return error; } @@ -3573,7 +3589,7 @@ ivas_error ivas_masa_dec_reconfigure_fx( IF( ( EQ_16( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) && st_ivas->hDiracDecBin != NULL ) { - IF( ( error = ivas_dirac_dec_config( st_ivas, DIRAC_RECONFIGURE ) ) != IVAS_ERR_OK ) + IF( ( error = ivas_dirac_dec_config_fx( st_ivas, DIRAC_RECONFIGURE ) ) != IVAS_ERR_OK ) { return error; } @@ -3627,7 +3643,7 @@ ivas_error ivas_masa_dec_reconfigure_fx( test(); IF( ( EQ_16( st_ivas->renderer_type, RENDERER_DIRAC ) && st_ivas->hDirACRend != NULL ) || ( ( EQ_16( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) && st_ivas->hDiracDecBin != NULL ) ) { - IF( ( error = ivas_dirac_dec_config( st_ivas, DIRAC_RECONFIGURE ) ) != IVAS_ERR_OK ) + IF( ( error = ivas_dirac_dec_config_fx( st_ivas, DIRAC_RECONFIGURE ) ) != IVAS_ERR_OK ) { return error; } @@ -3643,7 +3659,7 @@ ivas_error ivas_masa_dec_reconfigure_fx( test(); IF( ( EQ_16( st_ivas->renderer_type, RENDERER_DIRAC ) && st_ivas->hDirACRend != NULL ) || ( ( EQ_16( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) && st_ivas->hDiracDecBin != NULL ) ) { - IF( ( error = ivas_dirac_dec_config( st_ivas, DIRAC_RECONFIGURE ) ) != IVAS_ERR_OK ) + IF( ( error = ivas_dirac_dec_config_fx( st_ivas, DIRAC_RECONFIGURE ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_dec/ivas_mc_param_dec.c b/lib_dec/ivas_mc_param_dec.c index 5c5102b288afba0baa3717d1529cb44f6d676ca0..4019334a3bdbdca2b0e60239744d86216c68acfb 100644 --- a/lib_dec/ivas_mc_param_dec.c +++ b/lib_dec/ivas_mc_param_dec.c @@ -1178,7 +1178,7 @@ ivas_error ivas_param_mc_dec_reconfig_fx( } } } - ivas_dirac_dec_output_synthesis_cov_close( ¶ms_old, &cov_state_old ); + ivas_dirac_dec_output_synthesis_cov_close_fx( ¶ms_old, &cov_state_old ); } /*-----------------------------------------------------------------* @@ -1735,7 +1735,11 @@ ivas_error ivas_param_mc_dec_reconfig( } } +#ifdef IVAS_FLOAT_FIXED + ivas_dirac_dec_output_synthesis_cov_close_fx( ¶ms_old, &cov_state_old ); +#else ivas_dirac_dec_output_synthesis_cov_close( ¶ms_old, &cov_state_old ); +#endif } /*-----------------------------------------------------------------* @@ -1864,7 +1868,11 @@ void ivas_param_mc_dec_close( hParamMC = *hParamMC_out; /* close sub-modules */ +#ifdef IVAS_FLOAT_FIXED + ivas_dirac_dec_output_synthesis_cov_close_fx( &hParamMC->h_output_synthesis_params, &hParamMC->h_output_synthesis_cov_state ); +#else ivas_dirac_dec_output_synthesis_cov_close( &hParamMC->h_output_synthesis_params, &hParamMC->h_output_synthesis_cov_state ); +#endif if ( hParamMC->h_freq_domain_decorr_ap_params != NULL || hParamMC->h_freq_domain_decorr_ap_state != NULL ) { @@ -2693,6 +2701,13 @@ void ivas_param_mc_dec_render( #ifdef IVAS_FLOAT_FIXED Word32 Cldfb_RealBuffer_fx[MAX_INTERN_CHANNELS][PARAM_MC_MAX_NSLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; Word32 Cldfb_ImagBuffer_fx[MAX_INTERN_CHANNELS][PARAM_MC_MAX_NSLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; + Word32 Cldfb_RealBuffer_Binaural_fx[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; + Word32 Cldfb_ImagBuffer_Binaural_fx[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; + Word32 output_f_fx[MAX_OUTPUT_CHANNELS][L_FRAME48k]; + Word32 *p_output_f_fx[MAX_OUTPUT_CHANNELS]; + for (int i = 0; i < MAX_OUTPUT_CHANNELS; i++) { + p_output_f_fx[i] = output_f_fx[i]; + } #endif float Cldfb_RealBuffer_Binaural[BINAURAL_CHANNELS][PARAM_MC_MAX_NSLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; float Cldfb_ImagBuffer_Binaural[BINAURAL_CHANNELS][PARAM_MC_MAX_NSLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; @@ -2780,6 +2795,12 @@ void ivas_param_mc_dec_render( slot_idx_start_cldfb_synth = 0; for ( subframe_idx = first_sf; subframe_idx < last_sf; subframe_idx++ ) { + Word16 len = slot_idx_start_cldfb_synth * hParamMC->num_freq_bands + hParamMC->num_freq_bands * hParamMC->subframe_nbslots[subframe_idx]; + for (int i = 0; i < nchan_out_cldfb; i++) + { + floatToFixed_arrL(output_f[i], output_f_fx[i], Q11, len); + } + for ( slot_idx = 0; slot_idx < hParamMC->subframe_nbslots[subframe_idx]; slot_idx++, hParamMC->slots_rendered++ ) { @@ -2788,7 +2809,6 @@ void ivas_param_mc_dec_render( /*-----------------------------------------------------------------* * protoype signal computation *-----------------------------------------------------------------*/ - param_mc_protoSignalComputation( &hParamMC->Cldfb_RealBuffer_tc[hParamMC->slots_rendered * nchan_transport * hParamMC->num_freq_bands], &hParamMC->Cldfb_ImagBuffer_tc[hParamMC->slots_rendered * nchan_transport * hParamMC->num_freq_bands], hParamMC->proto_frame_f, hParamMC->diff_proto_info, @@ -2853,8 +2873,8 @@ void ivas_param_mc_dec_render( } Word16 Q_hoa_encoder = 31; floatToFixed_arrL(hParamMC->hoa_encoder, hParamMC->hoa_encoder_fx, Q_hoa_encoder, st_ivas->hTransSetup.nchan_out_woLFE * MAX_INTERN_CHANNELS ); - Word32 Cldfb_RealBuffer_fx[16][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; - Word32 Cldfb_ImagBuffer_fx[16][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; + //Word32 Cldfb_RealBuffer_fx[16][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; + //Word32 Cldfb_ImagBuffer_fx[16][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; Word16 Q_Cldfb_ImagBuffer, Q_Cldfb_RealBuffer; Q_Cldfb_ImagBuffer = Q_factor_arrL( &Cldfb_ImagBuffer[0][0][0], 16 * MAX_PARAM_SPATIAL_SUBFRAMES * CLDFB_NO_CHANNELS_MAX ) - 5;/*max value =MAX_INTERN_CHANNELS(=16)*Cldfb_ImagBuffer_fx*/ Q_Cldfb_RealBuffer = Q_factor_arrL( &Cldfb_RealBuffer[0][0][0], 16 * MAX_PARAM_SPATIAL_SUBFRAMES * CLDFB_NO_CHANNELS_MAX ) - 5; @@ -2934,13 +2954,83 @@ void ivas_param_mc_dec_render( if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) { +#ifdef IVAS_FLOAT_FIXED + Word16 j, k; + + for ( i = 0; i < MAX_OUTPUT_CHANNELS; i++ ) + { + for ( j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ ) + { + for ( k = 0; k < CLDFB_NO_CHANNELS_MAX; k++ ) + { + Cldfb_RealBuffer_fx[i][j][k] = (Word32) floatToFixed( Cldfb_RealBuffer[i][j][k], Q6 ); + Cldfb_ImagBuffer_fx[i][j][k] = (Word32) floatToFixed( Cldfb_ImagBuffer[i][j][k], Q6 ); + } + } + } + if ( st_ivas->hCombinedOrientationData != NULL && st_ivas->hCombinedOrientationData->enableCombinedOrientation[st_ivas->hCombinedOrientationData->subframe_idx] && st_ivas->hBinRenderer->rotInCldfb ) + { + if ( st_ivas->hBinRenderer->hInputSetup->is_loudspeaker_setup == 0 ) + { + for ( i = 0; i < 3; i++ ) + { + for ( j = 0; j < 3; j++ ) + { + st_ivas->hCombinedOrientationData->Rmat_fx[st_ivas->hCombinedOrientationData->subframe_idx][i][j] = (Word32) floatToFixed( st_ivas->hCombinedOrientationData->Rmat[st_ivas->hCombinedOrientationData->subframe_idx][i][j], 30 ); + } + } + } + } + + Word16 input_q = 6; + /* Implement binaural rendering */ + ivas_binRenderer_fx( st_ivas->hBinRenderer, + st_ivas->hCombinedOrientationData, + hParamMC->subframe_nbslots[subframe_idx], + Cldfb_RealBuffer_Binaural_fx, Cldfb_ImagBuffer_Binaural_fx, + Cldfb_RealBuffer_fx, + Cldfb_ImagBuffer_fx, &input_q ); + + /* fixed to float */ + for ( i = 0; i < MAX_OUTPUT_CHANNELS; i++ ) + { + for ( j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ ) + { + for ( k = 0; k < CLDFB_NO_CHANNELS_MAX; k++ ) + { + Cldfb_RealBuffer[i][j][k] = fixedToFloat( Cldfb_RealBuffer_fx[i][j][k], input_q ); + Cldfb_ImagBuffer[i][j][k] = fixedToFloat( Cldfb_ImagBuffer_fx[i][j][k], input_q ); + } + } + } + for ( int idx1 = 0; idx1 < BINAURAL_CHANNELS; idx1++ ) + { + for ( int idx2 = 0; idx2 < hParamMC->subframe_nbslots[subframe_idx]; idx2++ ) + { + Scale_sig32( Cldfb_RealBuffer_Binaural_fx[idx1][idx2], CLDFB_NO_CHANNELS_MAX, 6 - input_q ); + Scale_sig32( Cldfb_ImagBuffer_Binaural_fx[idx1][idx2], CLDFB_NO_CHANNELS_MAX, 6 - input_q ); + } + } + + for ( i = 0; i < BINAURAL_CHANNELS; i++ ) + { + for ( j = 0; j < hParamMC->subframe_nbslots[subframe_idx]; j++ ) + { + for ( k = 0; k < CLDFB_NO_CHANNELS_MAX; k++ ) + { + Cldfb_RealBuffer_Binaural[i][j][k] = fix_to_float( Cldfb_RealBuffer_Binaural_fx[i][j][k], Q6 ); + Cldfb_ImagBuffer_Binaural[i][j][k] = fix_to_float( Cldfb_ImagBuffer_Binaural_fx[i][j][k], Q6 ); + } + } + } +#else ivas_binRenderer( st_ivas->hBinRenderer, st_ivas->hCombinedOrientationData, hParamMC->subframe_nbslots[subframe_idx], Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer, Cldfb_ImagBuffer ); - +#endif /* update combined orientation access index */ ivas_combined_orientation_update_index( st_ivas->hCombinedOrientationData, hParamMC->num_freq_bands * hParamMC->subframe_nbslots[subframe_idx] ); } @@ -2948,8 +3038,6 @@ void ivas_param_mc_dec_render( { /* format conversion*/ #ifdef IVAS_FLOAT_FIXED - Word32 Cldfb_RealBuffer_fx[MAX_CICP_CHANNELS][PARAM_MC_MAX_NSLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; - Word32 Cldfb_ImagBuffer_fx[MAX_CICP_CHANNELS][PARAM_MC_MAX_NSLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; Word16 inChannels = st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe; Word16 num_timeslots = hParamMC->subframe_nbslots[subframe_idx]; Word16 j; @@ -2975,7 +3063,61 @@ void ivas_param_mc_dec_render( #endif } + /* CLDFB synthesis */ +#ifdef IVAS_FLOAT_FIXED + + floatToFixed_arrL( &Cldfb_ImagBuffer[0][0][0], &Cldfb_ImagBuffer_fx[0][0][0], Q6, 16 * MAX_PARAM_SPATIAL_SUBFRAMES * CLDFB_NO_CHANNELS_MAX ); + floatToFixed_arrL( &Cldfb_RealBuffer[0][0][0], &Cldfb_RealBuffer_fx[0][0][0], Q6, 16 * MAX_PARAM_SPATIAL_SUBFRAMES * CLDFB_NO_CHANNELS_MAX ); + /* CLDFB synthesis */ + for ( ch = 0; ch < nchan_out_cldfb; ch++ ) + { + Word32 *RealBuffer_fx[16]; + Word32 *ImagBuffer_fx[16]; + + if ( channel_active[ch] ) + { + /* open CLDFB buffer up to CLDFB_NO_CHANNELS_MAX bands for 48kHz */ + for ( i = 0; i < hParamMC->subframe_nbslots[subframe_idx]; i++ ) + { + if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) + { + RealBuffer_fx[i] = Cldfb_RealBuffer_Binaural_fx[ch][i]; + ImagBuffer_fx[i] = Cldfb_ImagBuffer_Binaural_fx[ch][i]; + } + else + { + RealBuffer_fx[i] = Cldfb_RealBuffer_fx[ch][i]; + ImagBuffer_fx[i] = Cldfb_ImagBuffer_fx[ch][i]; + } + } + + for ( i = 0; i < st_ivas->cldfbSynDec[ch]->p_filter_length; i++ ) + { + st_ivas->cldfbSynDec[ch]->cldfb_state_fx[i] = (Word32) ( st_ivas->cldfbSynDec[ch]->cldfb_state[i] * ( 1LL << ( 5 ) ) ); + } + scale_sig32( output_f_fx[ch], len, 5 - 11 ); + + cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, &( output_f_fx[ch][slot_idx_start_cldfb_synth * hParamMC->num_freq_bands] ), + hParamMC->num_freq_bands * hParamMC->subframe_nbslots[subframe_idx], st_ivas->cldfbSynDec[ch] ); + + scale_sig32( output_f_fx[ch], len, 11 - 5 ); + for ( i = 0; i < st_ivas->cldfbSynDec[ch]->p_filter_length; i++ ) + { + st_ivas->cldfbSynDec[ch]->cldfb_state[i] = ( (float) st_ivas->cldfbSynDec[ch]->cldfb_state_fx[i] / ( 1LL << ( 5 ) ) ); + } + fixedToFloat_arrL( output_f_fx[ch], output_f[ch], Q11, len ); + } + else + { + set32_fx( &( output_f_fx[ch][slot_idx_start_cldfb_synth * hParamMC->num_freq_bands] ), 0, hParamMC->num_freq_bands * hParamMC->subframe_nbslots[subframe_idx] ); + fixedToFloat_arrL( output_f_fx[ch], output_f[ch], Q11, len ); + } + } + slot_idx_start += hParamMC->subframe_nbslots[subframe_idx]; + slot_idx_start_cldfb_synth += hParamMC->subframe_nbslots[subframe_idx]; + } +#else for ( ch = 0; ch < nchan_out_cldfb; ch++ ) { float *RealBuffer[16]; @@ -2999,7 +3141,7 @@ void ivas_param_mc_dec_render( } cldfbSynthesis_ivas( RealBuffer, ImagBuffer, &( output_f[ch][slot_idx_start_cldfb_synth * hParamMC->num_freq_bands] ), - hParamMC->num_freq_bands * hParamMC->subframe_nbslots[subframe_idx], st_ivas->cldfbSynDec[ch] ); + hParamMC->num_freq_bands * hParamMC->subframe_nbslots[subframe_idx], st_ivas->cldfbSynDec[ch] ); } else { @@ -3009,7 +3151,7 @@ void ivas_param_mc_dec_render( slot_idx_start += hParamMC->subframe_nbslots[subframe_idx]; slot_idx_start_cldfb_synth += hParamMC->subframe_nbslots[subframe_idx]; } - +#endif if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) { ivas_mc2sba( st_ivas->hIntSetup, output_f, output_f, hParamMC->num_freq_bands * slots_to_render, st_ivas->hOutSetup.ambisonics_order, 0.f ); @@ -3200,7 +3342,6 @@ static void param_mc_protoSignalComputation( return; } - /*------------------------------------------------------------------------- * ivas_param_mc_dec_compute_diffuse_proto() * diff --git a/lib_dec/ivas_mcmasa_dec.c b/lib_dec/ivas_mcmasa_dec.c index a096ee901e60d6e646eb2b954aec306aff29236c..f169d7e55ba9cbf48472de7edb89e4980f969651 100644 --- a/lib_dec/ivas_mcmasa_dec.c +++ b/lib_dec/ivas_mcmasa_dec.c @@ -80,14 +80,14 @@ ivas_error ivas_mcmasa_dec_reconfig( { IF ( st_ivas->hDirAC == NULL ) { - IF ( ( error = ivas_dirac_dec_config( st_ivas, DIRAC_OPEN ) ) != IVAS_ERR_OK ) + IF ( ( error = ivas_dirac_dec_config_fx( st_ivas, DIRAC_OPEN ) ) != IVAS_ERR_OK ) { return error; } } ELSE { - IF ( ( error = ivas_dirac_dec_config( st_ivas, DIRAC_RECONFIGURE ) ) != IVAS_ERR_OK ) + IF ( ( error = ivas_dirac_dec_config_fx( st_ivas, DIRAC_RECONFIGURE ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index d579b13174b7eb67006193dcaaef66eac56d3b16..47bb00816b8928d53dc751324f6861028ca8f965 100644 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -2641,7 +2641,11 @@ static ivas_error ivas_mc_dec_reconfig( if ( st_ivas->hDirAC != NULL ) { /* reconfigure existing DirAC dec */ +#ifdef IVAS_FLOAT_FIXED + if ( ( error = ivas_dirac_dec_config_fx( st_ivas, DIRAC_RECONFIGURE ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_dirac_dec_config( st_ivas, DIRAC_RECONFIGURE ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -2649,7 +2653,11 @@ static ivas_error ivas_mc_dec_reconfig( else { /* init a new DirAC dec */ +#ifdef IVAS_FLOAT_FIXED + if ( ( error = ivas_dirac_dec_config_fx( st_ivas, DIRAC_OPEN ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_dirac_dec_config( st_ivas, DIRAC_OPEN ) ) != IVAS_ERR_OK ) +#endif { return error; } diff --git a/lib_dec/ivas_omasa_dec.c b/lib_dec/ivas_omasa_dec.c index d5fcb4435d92a8d858f76cd093f42bbfeaa0d473..d5d213297219946b32170dec0fae8b215fc3818a 100644 --- a/lib_dec/ivas_omasa_dec.c +++ b/lib_dec/ivas_omasa_dec.c @@ -582,7 +582,7 @@ ivas_error ivas_omasa_dec_config_fx( IF( st_ivas->hIsmMetaData[0] == NULL ) { - IF( ( error = ivas_ism_metadata_dec_create( st_ivas, 1, NULL ) ) != IVAS_ERR_OK ) + IF( ( error = ivas_ism_metadata_dec_create_fx( st_ivas, 1, NULL ) ) != IVAS_ERR_OK ) { return error; } @@ -595,7 +595,7 @@ ivas_error ivas_omasa_dec_config_fx( ivas_ism_metadata_close( st_ivas->hIsmMetaData, 0 ); - IF( ( error = ivas_ism_metadata_dec_create( st_ivas, st_ivas->nchan_ism, NULL ) ) != IVAS_ERR_OK ) + IF( ( error = ivas_ism_metadata_dec_create_fx( st_ivas, st_ivas->nchan_ism, NULL ) ) != IVAS_ERR_OK ) { return error; } @@ -666,7 +666,7 @@ ivas_error ivas_omasa_dec_config_fx( IF( st_ivas->renderer_type == RENDERER_DIRAC ) { - IF( ( error = ivas_dirac_dec_config( st_ivas, DIRAC_RECONFIGURE ) ) != IVAS_ERR_OK ) + IF( ( error = ivas_dirac_dec_config_fx( st_ivas, DIRAC_RECONFIGURE ) ) != IVAS_ERR_OK ) { return error; } @@ -842,7 +842,11 @@ ivas_error ivas_omasa_dec_config( if ( st_ivas->hIsmMetaData[0] == NULL ) { +#ifdef IVAS_FLOAT_FIXED + IF ( ( error = ivas_ism_metadata_dec_create_fx( st_ivas, 1, NULL ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_ism_metadata_dec_create( st_ivas, 1, NULL ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -854,7 +858,11 @@ ivas_error ivas_omasa_dec_config( ivas_ism_metadata_close( st_ivas->hIsmMetaData, 0 ); +#ifdef IVAS_FLOAT_FIXED + IF ( ( error = ivas_ism_metadata_dec_create_fx( st_ivas, st_ivas->nchan_ism, NULL ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_ism_metadata_dec_create( st_ivas, st_ivas->nchan_ism, NULL ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -925,7 +933,11 @@ ivas_error ivas_omasa_dec_config( if ( st_ivas->renderer_type == RENDERER_DIRAC ) { +#ifdef IVAS_FLOAT_FIXED + if ( ( error = ivas_dirac_dec_config_fx( st_ivas, DIRAC_RECONFIGURE ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_dirac_dec_config( st_ivas, DIRAC_RECONFIGURE ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -1370,7 +1382,11 @@ void ivas_omasa_dirac_rend_jbm( subframes_rendered = st_ivas->hSpatParamRendCom->subframes_rendered; slots_rendered = st_ivas->hSpatParamRendCom->slots_rendered; +#ifdef IVAS_FLOAT_FIXED + ivas_dirac_dec_render_fx( st_ivas, nchan_transport, nSamplesAsked, nSamplesRendered, nSamplesAvailable, output_f ); +#else ivas_dirac_dec_render( st_ivas, nchan_transport, nSamplesAsked, nSamplesRendered, nSamplesAvailable, output_f ); +#endif #ifdef IVAS_FLOAT_FIXED Word16 q_output = 31, q_inverse_matrix = 31; diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 3674cbd2105d7da7b833077d25348c148c865848..5b8eb9c6bb96f1d6fffb5e78964dc0a25ea15ecd 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -578,7 +578,11 @@ ivas_error ivas_sba_dec_reconfigure( flag_config = DIRAC_RECONFIGURE_MODE; } +#ifdef IVAS_FLOAT_FIXED + if ( ( error = ivas_dirac_dec_config_fx( st_ivas, flag_config ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_dirac_dec_config( st_ivas, flag_config ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -636,7 +640,11 @@ ivas_error ivas_sba_dec_reconfigure( int32_t temp_brate[MAX_SCE]; st_ivas->ism_mode = ISM_SBA_MODE_DISC; +#ifdef IVAS_FLOAT_FIXED + IF ( ( error = ivas_ism_metadata_dec_create_fx( st_ivas, st_ivas->nchan_ism, temp_brate ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_ism_metadata_dec_create( st_ivas, st_ivas->nchan_ism, temp_brate ) ) != IVAS_ERR_OK ) +#endif { return error; } diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index 716c9570d38504e06a8b07a760d35c318d3b4a09..c4e649072ecd66a389d25014a2199329f377e395 100644 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -428,7 +428,7 @@ ivas_error ivas_spar_dec_fx( /* read DirAC bitstream */ IF( st_ivas->hQMetaData != NULL ) { - ivas_dirac_dec_read_BS( hDecoderConfig->ivas_total_brate, st0, st_ivas->hDirAC, st_ivas->hSpatParamRendCom, st_ivas->hQMetaData, nb_bits_read, last_bit_pos, ivas_get_hodirac_flag_fx( hDecoderConfig->ivas_total_brate, st_ivas->sba_analysis_order ), st_ivas->hSpar->dirac_to_spar_md_bands ); + ivas_dirac_dec_read_BS_fx( hDecoderConfig->ivas_total_brate, st0, st_ivas->hDirAC, st_ivas->hSpatParamRendCom, st_ivas->hQMetaData, nb_bits_read, last_bit_pos, ivas_get_hodirac_flag_fx( hDecoderConfig->ivas_total_brate, st_ivas->sba_analysis_order ), st_ivas->hSpar->dirac_to_spar_md_bands ); } IF( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) @@ -588,8 +588,11 @@ ivas_error ivas_spar_dec( } } #endif +#ifdef IVAS_FLOAT_FIXED + ivas_dirac_dec_read_BS_fx( hDecoderConfig->ivas_total_brate, st0, st_ivas->hDirAC, st_ivas->hSpatParamRendCom, st_ivas->hQMetaData, nb_bits_read, last_bit_pos, ivas_get_hodirac_flag( hDecoderConfig->ivas_total_brate, st_ivas->sba_analysis_order ), st_ivas->hSpar->dirac_to_spar_md_bands ); +#else ivas_dirac_dec_read_BS( hDecoderConfig->ivas_total_brate, st0, st_ivas->hDirAC, st_ivas->hSpatParamRendCom, st_ivas->hQMetaData, nb_bits_read, last_bit_pos, ivas_get_hodirac_flag( hDecoderConfig->ivas_total_brate, st_ivas->sba_analysis_order ), st_ivas->hSpar->dirac_to_spar_md_bands ); - +#endif #ifdef IVAS_FLOAT_FIXED // To do remove this code once ivas_spar_dec_MD is done for ( int d = 0; d < st_ivas->hQMetaData->no_directions; d++ ) @@ -3374,7 +3377,7 @@ void ivas_spar_dec_upmixer_sf_fx( fixedToFloat_arrL( output_fx[ch], output[ch], Q11, out_len ); p_output[ch] = output[ch]; } - ivas_dirac_dec_render_sf( st_ivas, p_output, nchan_internal, cldfb_in_ts_re, cldfb_in_ts_im ); + ivas_dirac_dec_render_sf_fx( st_ivas, p_output, nchan_internal, cldfb_in_ts_re, cldfb_in_ts_im ); FOR( Word16 ch = 0; ch < add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ); ch++ ) { floatToFixed_arrL( output[ch], output_fx[ch], Q11, out_len ); @@ -3847,7 +3850,11 @@ void ivas_spar_dec_upmixer_sf( if ( hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_FOA && hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_STEREO && hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_MONO ) { +#ifndef IVAS_FLOAT_FIXED ivas_dirac_dec_render_sf( st_ivas, output, nchan_internal, cldfb_in_ts_re, cldfb_in_ts_im ); +#else + ivas_dirac_dec_render_sf_fx( st_ivas, output, nchan_internal, cldfb_in_ts_re, cldfb_in_ts_im ); +#endif } if ( st_ivas->hDirAC != NULL ) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 0a7bba5f35dabe09f46c5bb73d3fc2542f5eef32..1684c486ba4d32865d4ebdfe8cf404307fe130ea 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -35,6 +35,7 @@ #include "ivas_prot.h" #include "ivas_prot_rend.h" #include "prot.h" +#include "ivas_prot_fx.h" #include "prot_fx1.h" #include "prot_fx2.h" #include "jbm_jb4sb.h" @@ -733,7 +734,11 @@ ivas_error IVAS_DEC_FeedFrame_Serial( * In IVAS mode, initialization is done in ivas_dec(). */ IF( EQ_16( hIvasDec->mode, IVAS_DEC_MODE_EVS ) ) { +#ifdef IVAS_FLOAT_FIXED + IF( ( error = ivas_init_decoder_fx( hIvasDec->st_ivas ) ) != IVAS_ERR_OK ) +#else IF( ( error = ivas_init_decoder( hIvasDec->st_ivas ) ) != IVAS_ERR_OK ) +#endif { return error; }