Loading lib_com/prot_fx.h +4 −14 Original line number Diff line number Diff line Loading @@ -8013,18 +8013,8 @@ ivas_error core_switching_pre_dec_fx( ivas_error core_switching_post_dec_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ Word16 *synth, /* i/o: output synthesis Qsynth Qsynth*/ #ifdef IVAS_CODE_SWITCHING float *output, /* i/o: LB synth/upsampled LB synth */ float output_mem[], /* i : OLA memory from last TCX/HQ frame */ const IVAS_FORMAT ivas_format, /* i : IVAS format */ const Word16 use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */ #endif const Word16 output_frame, /* i : frame length Q0*/ const Word16 core_switching_flag, /* i : ACELP->HQ switching flag Q0*/ #ifdef IVAS_CODE_SWITCHING const Word16 sba_dirac_stereo_flag, /* i : signal stereo output for SBA DirAC */ const Word16 nchan_out, /* i : number of output channels */ #endif const Word16 last_element_mode, /* i : element mode of previous frame Q0*/ Word16 *Qsynth /* i/o: Scaling of ACELP exit (Q_syn2-1) or HQ exit (Qsynth); changes after this function */ ); Loading lib_dec/core_switching_dec_fx.c +11 −268 Original line number Diff line number Diff line Loading @@ -16,10 +16,6 @@ * * *---------------------------------------------------------------------*/ #ifdef IVAS_CODE_SWITCHING static void core_switch_lb_upsamp( Decoder_State *st, float *output ); static void smoothTransitionDtxToTcx( float synth[], const int16_t output_frame, const int16_t delay_comp ); #endif static void smoothTransitionDtxToTcx_fx( Word16 synth[], const Word16 output_frame, const Word16 delay_comp ); static void core_switch_lb_upsamp_fx( Decoder_State *st, Word32 *output ); Loading Loading @@ -189,30 +185,11 @@ void bw_switching_pre_proc_fx( Flag Overflow = 0; move32(); #endif #ifdef IVAS_CODE_SWITCHING IF( st_fx->element_mode > EVS_MONO ) { test(); test(); test(); test(); test(); test(); test(); test(); test(); test(); IF( EQ_16( st_fx->core, ACELP_CORE ) && !( EQ_16( st_fx->bfi, 1 ) && EQ_16( st_fx->con_tcx, 1 ) ) && st_fx->hBWE_FD != NULL && !( LE_16( st_fx->core_brate, SID_2k40 ) && EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) && EQ_16( nchan_out, 2 ) ) && !( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) && EQ_16( nchan_out, 1 ) && EQ_16( st_fx->idchan, 1 ) && LE_16( last_element_brate, IVAS_SID_4k4 ) ) ) { /* Calculate tilt of the ACELP core synthesis - needed in SWB BWE decoding */ calc_tilt_bwe( old_syn_12k8_16k, &st->tilt_wb, st->L_frame ); } return; } #endif test(); test(); IF( EQ_16( st_fx->core, ACELP_CORE ) && !( EQ_16( st_fx->bfi, 1 ) && EQ_16( st_fx->con_tcx, 1 ) ) ) Loading Loading @@ -321,149 +298,7 @@ void bw_switching_pre_proc_fx( return; } #ifdef IVAS_CODE_SWITCHING /*---------------------------------------------------------------------* * core_switch_lb_upsamp() * * Resample HQ/TCX-LB to the output sampling rate (8/16/32/48 kHz) *---------------------------------------------------------------------*/ static void core_switch_lb_upsamp( Decoder_State *st, /* i/o: Decoder state */ float *output /* i/o: LB synth/upsampled LB synth */ ) { int16_t i; float *realBuffer[CLDFB_OVRLP_MIN_SLOTS], *imagBuffer[CLDFB_OVRLP_MIN_SLOTS]; float realBufferTmp[CLDFB_OVRLP_MIN_SLOTS][CLDFB_NO_CHANNELS_MAX]; float imagBufferTmp[CLDFB_OVRLP_MIN_SLOTS][CLDFB_NO_CHANNELS_MAX]; /* open CLDFB buffer up to CLDFB_NO_CHANNELS_MAX bands for 48kHz */ for ( i = 0; i < CLDFB_OVRLP_MIN_SLOTS; i++ ) { set_f( realBufferTmp[i], 0, CLDFB_NO_CHANNELS_MAX ); set_f( imagBufferTmp[i], 0, CLDFB_NO_CHANNELS_MAX ); realBuffer[i] = realBufferTmp[i]; imagBuffer[i] = imagBufferTmp[i]; } /* check if the CLDFB works on the right sample rate */ if ( ( st->cldfbAna->no_channels * st->cldfbAna->no_col ) != st->L_frame ) { resampleCldfb( st->cldfbAna, st->L_frame * FRAMES_PER_SEC ); if ( st->cldfbBPF != NULL && st->L_frame <= L_FRAME16k ) { resampleCldfb( st->cldfbBPF, st->L_frame * FRAMES_PER_SEC ); } if ( st->ini_frame > 0 ) { st->cldfbSyn->bandsToZero = st->cldfbSyn->no_channels - st->cldfbAna->no_channels; } } /* analysis of the synthesis at internal sampling rate */ cldfbAnalysis( output, realBuffer, imagBuffer, CLDFB_OVRLP_MIN_SLOTS * st->cldfbAna->no_channels, st->cldfbAna ); /* analysis and add the BPF error signal */ if ( st->p_bpf_noise_buf ) { addBassPostFilter( st->p_bpf_noise_buf, st->bpf_off ? 0 : CLDFB_OVRLP_MIN_SLOTS * st->cldfbBPF->no_channels, realBuffer, imagBuffer, st->cldfbBPF ); } /* set output mask for upsampling */ if ( st->bwidth == NB ) { /* set NB mask for upsampling */ st->cldfbSyn->bandsToZero = st->cldfbSyn->no_channels - 10; } else if ( st->cldfbSyn->bandsToZero != st->cldfbSyn->no_channels - st->cldfbAna->no_channels ) { /* in case of BW switching, re-init to default */ st->cldfbSyn->bandsToZero = st->cldfbSyn->no_channels - st->cldfbAna->no_channels; } /* synthesis of the combined signal */ cldfbSynthesis( realBuffer, imagBuffer, output, CLDFB_OVRLP_MIN_SLOTS * st->cldfbSyn->no_channels, st->cldfbSyn ); /* save synthesis - needed in case of core switching */ if ( st->hTcxDec != NULL ) { mvr2r( output, st->previoussynth, st->hTcxDec->L_frameTCX ); } return; } /*---------------------------------------------------------------------* * smoothTransitionMdctStereoDtx() * * apply smoothing to the transition part for MDCT-Stereo DTX *---------------------------------------------------------------------*/ #define TRANSITION_SMOOTHING_LEN_16k 15 #define TRANSITION_SMOOTHING_LEN_32k 31 #define TRANSITION_SMOOTHING_LEN_48k 47 static void smoothTransitionMdctStereoDtx( float synth[], /* i/o: synthesis */ const int16_t output_frame, /* i : output frame length */ const int16_t delay_comp /* i : delay compensation in samples */ ) { int16_t i, filter_len; float w, mem, step, fade_in; float smoothing_input_buffer[2 * NS2SA( 48000, DELAY_CLDFB_NS ) + TRANSITION_SMOOTHING_LEN_48k]; float smoothing_out_buffer[2 * NS2SA( 48000, DELAY_CLDFB_NS ) + TRANSITION_SMOOTHING_LEN_48k]; filter_len = TRANSITION_SMOOTHING_LEN_16k; if ( output_frame == L_FRAME32k ) { filter_len = TRANSITION_SMOOTHING_LEN_32k; } else if ( output_frame == L_FRAME48k ) { filter_len = TRANSITION_SMOOTHING_LEN_48k; } /* prepare buffer */ for ( i = 0; i < filter_len / 2; i++ ) { smoothing_input_buffer[i] = synth[0]; } mvr2r( synth, smoothing_input_buffer + filter_len / 2, 2 * delay_comp + filter_len / 2 ); /* apply Mean filter */ w = 1.f / filter_len; mem = sum_f( smoothing_input_buffer, filter_len ); for ( i = 0; i < 2 * delay_comp; i++ ) { smoothing_out_buffer[i] = w * mem; mem = mem - smoothing_input_buffer[i] + smoothing_input_buffer[i + filter_len]; } /* apply fades around transition */ step = 1.f / delay_comp; fade_in = 0.f; for ( i = 0; i < delay_comp; i++ ) { synth[i] = smoothing_out_buffer[i] * fade_in + synth[i] * ( 1 - fade_in ); fade_in += step; } fade_in = 0.f; for ( ; i < 2 * delay_comp; i++ ) { synth[i] = synth[i] * fade_in + smoothing_out_buffer[i] * ( 1 - fade_in ); fade_in += step; } return; } #endif /*---------------------------------------------------------------------* * core_switching_pre_dec_fx() * Loading Loading @@ -738,13 +573,7 @@ ivas_error core_switching_pre_dec_fx( test(); test(); IF( ( ( EQ_16( st_fx->core, ACELP_CORE ) || EQ_16( st_fx->core, AMR_WB_CORE ) ) && EQ_16( st_fx->last_core, HQ_CORE ) ) //#ifdef IVAS_CODE_SWITCHING // || ((EQ_16(st_fx->element_mode, IVAS_CPE_DFT) || EQ_16(st_fx->element_mode, IVAS_CPE_TD) || // (EQ_16(st_fx->element_mode, IVAS_CPE_MDCT) && last_element_mode == IVAS_CPE_DFT)) && EQ_16(nchan_out,2) && // NE_16(st_fx->core_brate, SID_2k40) && NE_16(st_fx->core_brate, FRAME_NO_DATA) && (EQ_16(last_core_brate_st0, FRAME_NO_DATA) || EQ_16(last_core_brate_st0, SID_2k40))) //#endif ) IF( ( ( EQ_16( st_fx->core, ACELP_CORE ) || EQ_16( st_fx->core, AMR_WB_CORE ) ) && EQ_16( st_fx->last_core, HQ_CORE ) ) ) { test(); IF( EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) Loading @@ -770,14 +599,7 @@ ivas_error core_switching_pre_dec_fx( lsf2lsp_fx( st_fx->lsf_old_fx, st_fx->lsp_old_fx, M, INT_FS_FX ); } #ifdef IVAS_CODE_SWITCHING if ( ( st->element_mode == IVAS_CPE_DFT || st->element_mode == IVAS_CPE_TD ) && nchan_out == 2 && st->core_brate > SID_2k40 && ( last_core_brate_st0 == FRAME_NO_DATA || last_core_brate_st0 == SID_2k40 ) && st->hTcxDec != NULL ) { /* Last frame was Stereo CNG and the synthesis memory is outdated -- reset */ set_f( st->hTcxDec->old_syn_Overl, 0.0f, L_FRAME32k / 2 ); set_f( st->hFdCngDec->hFdCngCom->olapBufferAna, 0.0f, FFTLEN ); } #endif set16_fx( st_fx->agc_mem_fx, 0, 2 ); st_fx->mem_deemph_fx = 0; move16(); Loading Loading @@ -876,47 +698,7 @@ ivas_error core_switching_pre_dec_fx( set16_fx( hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA_FX2( 16000, DELAY_FD_BWE_ENC_NS ) ); } } #ifdef IVAS_CODE_SWITCHING if ( ( st->core == ACELP_CORE || st->core == AMR_WB_CORE ) && ( st->last_core == TCX_20_CORE || st->last_core == TCX_10_CORE ) ) { if ( st->hBWE_TD != NULL ) { st->hBWE_TD->bwe_non_lin_prev_scale = 0.0f; set_f( st->hBWE_TD->old_bwe_exc, 0, PIT16k_MAX * 2 ); } st->tilt_code = 0.0f; st->gc_threshold = 0.0f; set_f( st->dispMem, 0, 8 ); st->last_coder_type = GENERIC; fer_energy( output_frame, UNVOICED_CLAS, st->previoussynth, -1, &st->enr_old, 1 ); st->lp_gainp = 0.0f; st->lp_gainc = (float) sqrt( st->lp_ener ); st->last_voice_factor = 0; st->Last_GSC_noisy_speech_flag = 0; if ( st->output_Fs >= 16000 && st->hBWE_zero != NULL ) { hf_synth_reset( st->hBWE_zero ); } if ( st->hBWE_FD != NULL ) { set_f( st->hBWE_FD->old_syn_12k8_16k, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ) ); } if ( nchan_out == 1 && st->element_mode == IVAS_CPE_DFT && st->element_brate <= IVAS_24k4 && last_element_brate > IVAS_24k4 ) { /* update cldbf state with previous frame TCX synthesis when going from a bitrate with residual coding to a bitrate without it */ int16_t offset; offset = st->cldfbAna->p_filter_length - st->cldfbAna->no_channels; mvr2r( st->hTcxDec->old_synthFB + st->hTcxDec->old_synth_lenFB - offset, st->cldfbAna->cldfb_state, offset ); } } #endif test(); test(); test(); Loading @@ -941,40 +723,16 @@ ivas_error core_switching_pre_dec_fx( { set32_fx( hHQ_core->prev_coeff_out_fx, 0, L_HQ_WB_BWE ); } #ifdef IVAS_CODE_SWITCHING if ( st->element_mode != EVS_MONO ) { /* Estimate mem_env_delta to reinit env_stab */ tmp = max( 0, ENV_STAB_EST1 + ( ENV_STAB_EST2 * st->stab_fac_smooth_lt ) + ( ENV_STAB_EST3 * st->log_energy_diff_lt ) ); st->hHQ_core->mem_env_delta = (int16_t) min( MAX16B, (int32_t) ( tmp * ( 1 << 12 ) ) ); /* Convert to Q12 and handle saturation */ if ( st->last_core != TCX_20_CORE && st->last_core != TCX_10_CORE ) if ( st_fx->element_mode != EVS_MONO ) { set_f( st->hHQ_core->old_out, 0, output_frame ); set_f( st->hHQ_core->old_outLB, 0, L_FRAME16k ); } st->hHQ_core->no_att_hangover = 0; st->hHQ_core->energy_lt = 300.0f; set_s( st->hHQ_core->old_is_transient, 0, 3 ); set_f( st->hHQ_core->prev_noise_level, 0.0f, 2 ); st->hHQ_core->prev_R = 0; set_s( st->hHQ_core->mem_norm + 1, 39, SFM_N_ENV_STAB - 1 ); st->hHQ_core->prev_hqswb_clas = HQ_NORMAL; st->hHQ_core->prev_ni_ratio = 0.5f; set_f( st->hHQ_core->prev_En_sb, 0.0f, NB_SWB_SUBBANDS ); } else #endif { set16_fx( hHQ_core->old_out_fx, 0, output_frame ); hHQ_core->Q_old_wtda_LB = 15; hHQ_core->Q_old_wtda = 15; move16(); #ifdef IVAS_CODE_SWITCHING set_f( st->hHQ_core->old_outLB, 0, L_FRAME16k ); #endif } } Loading Loading @@ -1081,12 +839,10 @@ ivas_error core_switching_pre_dec_fx( IF( NE_16( st_fx->last_L_frame, st_fx->L_frame ) && LE_16( st_fx->L_frame, L_FRAME16k ) && LE_16( st_fx->last_L_frame, L_FRAME16k ) ) { test(); #ifdef IVAS_CODE_SWITCHING IF( EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) { lerp( st_fx->hFdCngDec->hFdCngCom->olapBufferAna + st_fx->last_L_frame, st_fx->hFdCngDec->hFdCngCom->olapBufferAna + st_fx->L_frame, st_fx->L_frame, st_fx->last_L_frame ); } #endif lerp( st_fx->hFdCngDec->hFdCngCom->olapBufferSynth2, st_fx->hFdCngDec->hFdCngCom->olapBufferSynth2, shl( st_fx->L_frame, 1 ), shl( st_fx->last_L_frame, 1 ) ); test(); IF( LE_32( st_fx->total_brate, SID_2k40 ) && LE_32( st_fx->last_total_brate, SID_2k40 ) ) Loading Loading @@ -1124,18 +880,8 @@ ivas_error core_switching_pre_dec_fx( ivas_error core_switching_post_dec_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ Word16 *synth, /* i/o: output synthesis Qsynth*/ #ifdef IVAS_CODE_SWITCHING float *output, /* i/o: LB synth/upsampled LB synth */ float output_mem[], /* i : OLA memory from last TCX/HQ frame */ const IVAS_FORMAT ivas_format, /* i : IVAS format */ const Word16 use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */ #endif const Word16 output_frame, /* i : frame length Q0*/ const Word16 core_switching_flag, /* i : ACELP->HQ switching flag Q0*/ #ifdef IVAS_CODE_SWITCHING const Word16 sba_dirac_stereo_flag, /* i : signal stereo output for SBA DirAC */ const Word16 nchan_out, /* i : number of output channels */ #endif const Word16 last_element_mode, /* i : element mode of previous frame Q0*/ Word16 *Qsynth /* i/o: Scaling of ACELP exit (Q_syn2-1) or HQ exit (Qsynth); changes after this function */ ) Loading @@ -1152,9 +898,6 @@ ivas_error core_switching_post_dec_fx( HQ_DEC_HANDLE hHQ_core; ivas_error error; #ifdef IVAS_CODE_SWITCHING int16_t offset; #endif #ifdef REMOVE_IVAS_UNUSED_PARAMETERS_WARNING (void) ( last_element_mode ); #endif Loading lib_dec/evs_dec_fx.c +1 −9 Original line number Diff line number Diff line Loading @@ -360,15 +360,7 @@ ivas_error evs_dec_fx( * Postprocessing for ACELP/HQ core switching *---------------------------------------------------------------------*/ if ( ( error = core_switching_post_dec_fx( st_fx, synth_fx, #ifdef IVAS_CODE_SWITCHING output, output_mem[], IVAS_FORMAT ivas_format, use_cldfb_for_dft, #endif output_frame, core_switching_flag, #ifdef IVAS_CODE_SWITCHING sba_dirac_stereo_flag, nchan_out, #endif st_fx->last_element_mode, &Qpostd ) ) != IVAS_ERR_OK ) if ( ( error = core_switching_post_dec_fx( st_fx, synth_fx, output_frame, core_switching_flag, st_fx->last_element_mode, &Qpostd ) ) != IVAS_ERR_OK ) { return error; } Loading Loading
lib_com/prot_fx.h +4 −14 Original line number Diff line number Diff line Loading @@ -8013,18 +8013,8 @@ ivas_error core_switching_pre_dec_fx( ivas_error core_switching_post_dec_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ Word16 *synth, /* i/o: output synthesis Qsynth Qsynth*/ #ifdef IVAS_CODE_SWITCHING float *output, /* i/o: LB synth/upsampled LB synth */ float output_mem[], /* i : OLA memory from last TCX/HQ frame */ const IVAS_FORMAT ivas_format, /* i : IVAS format */ const Word16 use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */ #endif const Word16 output_frame, /* i : frame length Q0*/ const Word16 core_switching_flag, /* i : ACELP->HQ switching flag Q0*/ #ifdef IVAS_CODE_SWITCHING const Word16 sba_dirac_stereo_flag, /* i : signal stereo output for SBA DirAC */ const Word16 nchan_out, /* i : number of output channels */ #endif const Word16 last_element_mode, /* i : element mode of previous frame Q0*/ Word16 *Qsynth /* i/o: Scaling of ACELP exit (Q_syn2-1) or HQ exit (Qsynth); changes after this function */ ); Loading
lib_dec/core_switching_dec_fx.c +11 −268 Original line number Diff line number Diff line Loading @@ -16,10 +16,6 @@ * * *---------------------------------------------------------------------*/ #ifdef IVAS_CODE_SWITCHING static void core_switch_lb_upsamp( Decoder_State *st, float *output ); static void smoothTransitionDtxToTcx( float synth[], const int16_t output_frame, const int16_t delay_comp ); #endif static void smoothTransitionDtxToTcx_fx( Word16 synth[], const Word16 output_frame, const Word16 delay_comp ); static void core_switch_lb_upsamp_fx( Decoder_State *st, Word32 *output ); Loading Loading @@ -189,30 +185,11 @@ void bw_switching_pre_proc_fx( Flag Overflow = 0; move32(); #endif #ifdef IVAS_CODE_SWITCHING IF( st_fx->element_mode > EVS_MONO ) { test(); test(); test(); test(); test(); test(); test(); test(); test(); test(); IF( EQ_16( st_fx->core, ACELP_CORE ) && !( EQ_16( st_fx->bfi, 1 ) && EQ_16( st_fx->con_tcx, 1 ) ) && st_fx->hBWE_FD != NULL && !( LE_16( st_fx->core_brate, SID_2k40 ) && EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) && EQ_16( nchan_out, 2 ) ) && !( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) && EQ_16( nchan_out, 1 ) && EQ_16( st_fx->idchan, 1 ) && LE_16( last_element_brate, IVAS_SID_4k4 ) ) ) { /* Calculate tilt of the ACELP core synthesis - needed in SWB BWE decoding */ calc_tilt_bwe( old_syn_12k8_16k, &st->tilt_wb, st->L_frame ); } return; } #endif test(); test(); IF( EQ_16( st_fx->core, ACELP_CORE ) && !( EQ_16( st_fx->bfi, 1 ) && EQ_16( st_fx->con_tcx, 1 ) ) ) Loading Loading @@ -321,149 +298,7 @@ void bw_switching_pre_proc_fx( return; } #ifdef IVAS_CODE_SWITCHING /*---------------------------------------------------------------------* * core_switch_lb_upsamp() * * Resample HQ/TCX-LB to the output sampling rate (8/16/32/48 kHz) *---------------------------------------------------------------------*/ static void core_switch_lb_upsamp( Decoder_State *st, /* i/o: Decoder state */ float *output /* i/o: LB synth/upsampled LB synth */ ) { int16_t i; float *realBuffer[CLDFB_OVRLP_MIN_SLOTS], *imagBuffer[CLDFB_OVRLP_MIN_SLOTS]; float realBufferTmp[CLDFB_OVRLP_MIN_SLOTS][CLDFB_NO_CHANNELS_MAX]; float imagBufferTmp[CLDFB_OVRLP_MIN_SLOTS][CLDFB_NO_CHANNELS_MAX]; /* open CLDFB buffer up to CLDFB_NO_CHANNELS_MAX bands for 48kHz */ for ( i = 0; i < CLDFB_OVRLP_MIN_SLOTS; i++ ) { set_f( realBufferTmp[i], 0, CLDFB_NO_CHANNELS_MAX ); set_f( imagBufferTmp[i], 0, CLDFB_NO_CHANNELS_MAX ); realBuffer[i] = realBufferTmp[i]; imagBuffer[i] = imagBufferTmp[i]; } /* check if the CLDFB works on the right sample rate */ if ( ( st->cldfbAna->no_channels * st->cldfbAna->no_col ) != st->L_frame ) { resampleCldfb( st->cldfbAna, st->L_frame * FRAMES_PER_SEC ); if ( st->cldfbBPF != NULL && st->L_frame <= L_FRAME16k ) { resampleCldfb( st->cldfbBPF, st->L_frame * FRAMES_PER_SEC ); } if ( st->ini_frame > 0 ) { st->cldfbSyn->bandsToZero = st->cldfbSyn->no_channels - st->cldfbAna->no_channels; } } /* analysis of the synthesis at internal sampling rate */ cldfbAnalysis( output, realBuffer, imagBuffer, CLDFB_OVRLP_MIN_SLOTS * st->cldfbAna->no_channels, st->cldfbAna ); /* analysis and add the BPF error signal */ if ( st->p_bpf_noise_buf ) { addBassPostFilter( st->p_bpf_noise_buf, st->bpf_off ? 0 : CLDFB_OVRLP_MIN_SLOTS * st->cldfbBPF->no_channels, realBuffer, imagBuffer, st->cldfbBPF ); } /* set output mask for upsampling */ if ( st->bwidth == NB ) { /* set NB mask for upsampling */ st->cldfbSyn->bandsToZero = st->cldfbSyn->no_channels - 10; } else if ( st->cldfbSyn->bandsToZero != st->cldfbSyn->no_channels - st->cldfbAna->no_channels ) { /* in case of BW switching, re-init to default */ st->cldfbSyn->bandsToZero = st->cldfbSyn->no_channels - st->cldfbAna->no_channels; } /* synthesis of the combined signal */ cldfbSynthesis( realBuffer, imagBuffer, output, CLDFB_OVRLP_MIN_SLOTS * st->cldfbSyn->no_channels, st->cldfbSyn ); /* save synthesis - needed in case of core switching */ if ( st->hTcxDec != NULL ) { mvr2r( output, st->previoussynth, st->hTcxDec->L_frameTCX ); } return; } /*---------------------------------------------------------------------* * smoothTransitionMdctStereoDtx() * * apply smoothing to the transition part for MDCT-Stereo DTX *---------------------------------------------------------------------*/ #define TRANSITION_SMOOTHING_LEN_16k 15 #define TRANSITION_SMOOTHING_LEN_32k 31 #define TRANSITION_SMOOTHING_LEN_48k 47 static void smoothTransitionMdctStereoDtx( float synth[], /* i/o: synthesis */ const int16_t output_frame, /* i : output frame length */ const int16_t delay_comp /* i : delay compensation in samples */ ) { int16_t i, filter_len; float w, mem, step, fade_in; float smoothing_input_buffer[2 * NS2SA( 48000, DELAY_CLDFB_NS ) + TRANSITION_SMOOTHING_LEN_48k]; float smoothing_out_buffer[2 * NS2SA( 48000, DELAY_CLDFB_NS ) + TRANSITION_SMOOTHING_LEN_48k]; filter_len = TRANSITION_SMOOTHING_LEN_16k; if ( output_frame == L_FRAME32k ) { filter_len = TRANSITION_SMOOTHING_LEN_32k; } else if ( output_frame == L_FRAME48k ) { filter_len = TRANSITION_SMOOTHING_LEN_48k; } /* prepare buffer */ for ( i = 0; i < filter_len / 2; i++ ) { smoothing_input_buffer[i] = synth[0]; } mvr2r( synth, smoothing_input_buffer + filter_len / 2, 2 * delay_comp + filter_len / 2 ); /* apply Mean filter */ w = 1.f / filter_len; mem = sum_f( smoothing_input_buffer, filter_len ); for ( i = 0; i < 2 * delay_comp; i++ ) { smoothing_out_buffer[i] = w * mem; mem = mem - smoothing_input_buffer[i] + smoothing_input_buffer[i + filter_len]; } /* apply fades around transition */ step = 1.f / delay_comp; fade_in = 0.f; for ( i = 0; i < delay_comp; i++ ) { synth[i] = smoothing_out_buffer[i] * fade_in + synth[i] * ( 1 - fade_in ); fade_in += step; } fade_in = 0.f; for ( ; i < 2 * delay_comp; i++ ) { synth[i] = synth[i] * fade_in + smoothing_out_buffer[i] * ( 1 - fade_in ); fade_in += step; } return; } #endif /*---------------------------------------------------------------------* * core_switching_pre_dec_fx() * Loading Loading @@ -738,13 +573,7 @@ ivas_error core_switching_pre_dec_fx( test(); test(); IF( ( ( EQ_16( st_fx->core, ACELP_CORE ) || EQ_16( st_fx->core, AMR_WB_CORE ) ) && EQ_16( st_fx->last_core, HQ_CORE ) ) //#ifdef IVAS_CODE_SWITCHING // || ((EQ_16(st_fx->element_mode, IVAS_CPE_DFT) || EQ_16(st_fx->element_mode, IVAS_CPE_TD) || // (EQ_16(st_fx->element_mode, IVAS_CPE_MDCT) && last_element_mode == IVAS_CPE_DFT)) && EQ_16(nchan_out,2) && // NE_16(st_fx->core_brate, SID_2k40) && NE_16(st_fx->core_brate, FRAME_NO_DATA) && (EQ_16(last_core_brate_st0, FRAME_NO_DATA) || EQ_16(last_core_brate_st0, SID_2k40))) //#endif ) IF( ( ( EQ_16( st_fx->core, ACELP_CORE ) || EQ_16( st_fx->core, AMR_WB_CORE ) ) && EQ_16( st_fx->last_core, HQ_CORE ) ) ) { test(); IF( EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) Loading @@ -770,14 +599,7 @@ ivas_error core_switching_pre_dec_fx( lsf2lsp_fx( st_fx->lsf_old_fx, st_fx->lsp_old_fx, M, INT_FS_FX ); } #ifdef IVAS_CODE_SWITCHING if ( ( st->element_mode == IVAS_CPE_DFT || st->element_mode == IVAS_CPE_TD ) && nchan_out == 2 && st->core_brate > SID_2k40 && ( last_core_brate_st0 == FRAME_NO_DATA || last_core_brate_st0 == SID_2k40 ) && st->hTcxDec != NULL ) { /* Last frame was Stereo CNG and the synthesis memory is outdated -- reset */ set_f( st->hTcxDec->old_syn_Overl, 0.0f, L_FRAME32k / 2 ); set_f( st->hFdCngDec->hFdCngCom->olapBufferAna, 0.0f, FFTLEN ); } #endif set16_fx( st_fx->agc_mem_fx, 0, 2 ); st_fx->mem_deemph_fx = 0; move16(); Loading Loading @@ -876,47 +698,7 @@ ivas_error core_switching_pre_dec_fx( set16_fx( hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA_FX2( 16000, DELAY_FD_BWE_ENC_NS ) ); } } #ifdef IVAS_CODE_SWITCHING if ( ( st->core == ACELP_CORE || st->core == AMR_WB_CORE ) && ( st->last_core == TCX_20_CORE || st->last_core == TCX_10_CORE ) ) { if ( st->hBWE_TD != NULL ) { st->hBWE_TD->bwe_non_lin_prev_scale = 0.0f; set_f( st->hBWE_TD->old_bwe_exc, 0, PIT16k_MAX * 2 ); } st->tilt_code = 0.0f; st->gc_threshold = 0.0f; set_f( st->dispMem, 0, 8 ); st->last_coder_type = GENERIC; fer_energy( output_frame, UNVOICED_CLAS, st->previoussynth, -1, &st->enr_old, 1 ); st->lp_gainp = 0.0f; st->lp_gainc = (float) sqrt( st->lp_ener ); st->last_voice_factor = 0; st->Last_GSC_noisy_speech_flag = 0; if ( st->output_Fs >= 16000 && st->hBWE_zero != NULL ) { hf_synth_reset( st->hBWE_zero ); } if ( st->hBWE_FD != NULL ) { set_f( st->hBWE_FD->old_syn_12k8_16k, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ) ); } if ( nchan_out == 1 && st->element_mode == IVAS_CPE_DFT && st->element_brate <= IVAS_24k4 && last_element_brate > IVAS_24k4 ) { /* update cldbf state with previous frame TCX synthesis when going from a bitrate with residual coding to a bitrate without it */ int16_t offset; offset = st->cldfbAna->p_filter_length - st->cldfbAna->no_channels; mvr2r( st->hTcxDec->old_synthFB + st->hTcxDec->old_synth_lenFB - offset, st->cldfbAna->cldfb_state, offset ); } } #endif test(); test(); test(); Loading @@ -941,40 +723,16 @@ ivas_error core_switching_pre_dec_fx( { set32_fx( hHQ_core->prev_coeff_out_fx, 0, L_HQ_WB_BWE ); } #ifdef IVAS_CODE_SWITCHING if ( st->element_mode != EVS_MONO ) { /* Estimate mem_env_delta to reinit env_stab */ tmp = max( 0, ENV_STAB_EST1 + ( ENV_STAB_EST2 * st->stab_fac_smooth_lt ) + ( ENV_STAB_EST3 * st->log_energy_diff_lt ) ); st->hHQ_core->mem_env_delta = (int16_t) min( MAX16B, (int32_t) ( tmp * ( 1 << 12 ) ) ); /* Convert to Q12 and handle saturation */ if ( st->last_core != TCX_20_CORE && st->last_core != TCX_10_CORE ) if ( st_fx->element_mode != EVS_MONO ) { set_f( st->hHQ_core->old_out, 0, output_frame ); set_f( st->hHQ_core->old_outLB, 0, L_FRAME16k ); } st->hHQ_core->no_att_hangover = 0; st->hHQ_core->energy_lt = 300.0f; set_s( st->hHQ_core->old_is_transient, 0, 3 ); set_f( st->hHQ_core->prev_noise_level, 0.0f, 2 ); st->hHQ_core->prev_R = 0; set_s( st->hHQ_core->mem_norm + 1, 39, SFM_N_ENV_STAB - 1 ); st->hHQ_core->prev_hqswb_clas = HQ_NORMAL; st->hHQ_core->prev_ni_ratio = 0.5f; set_f( st->hHQ_core->prev_En_sb, 0.0f, NB_SWB_SUBBANDS ); } else #endif { set16_fx( hHQ_core->old_out_fx, 0, output_frame ); hHQ_core->Q_old_wtda_LB = 15; hHQ_core->Q_old_wtda = 15; move16(); #ifdef IVAS_CODE_SWITCHING set_f( st->hHQ_core->old_outLB, 0, L_FRAME16k ); #endif } } Loading Loading @@ -1081,12 +839,10 @@ ivas_error core_switching_pre_dec_fx( IF( NE_16( st_fx->last_L_frame, st_fx->L_frame ) && LE_16( st_fx->L_frame, L_FRAME16k ) && LE_16( st_fx->last_L_frame, L_FRAME16k ) ) { test(); #ifdef IVAS_CODE_SWITCHING IF( EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) { lerp( st_fx->hFdCngDec->hFdCngCom->olapBufferAna + st_fx->last_L_frame, st_fx->hFdCngDec->hFdCngCom->olapBufferAna + st_fx->L_frame, st_fx->L_frame, st_fx->last_L_frame ); } #endif lerp( st_fx->hFdCngDec->hFdCngCom->olapBufferSynth2, st_fx->hFdCngDec->hFdCngCom->olapBufferSynth2, shl( st_fx->L_frame, 1 ), shl( st_fx->last_L_frame, 1 ) ); test(); IF( LE_32( st_fx->total_brate, SID_2k40 ) && LE_32( st_fx->last_total_brate, SID_2k40 ) ) Loading Loading @@ -1124,18 +880,8 @@ ivas_error core_switching_pre_dec_fx( ivas_error core_switching_post_dec_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ Word16 *synth, /* i/o: output synthesis Qsynth*/ #ifdef IVAS_CODE_SWITCHING float *output, /* i/o: LB synth/upsampled LB synth */ float output_mem[], /* i : OLA memory from last TCX/HQ frame */ const IVAS_FORMAT ivas_format, /* i : IVAS format */ const Word16 use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */ #endif const Word16 output_frame, /* i : frame length Q0*/ const Word16 core_switching_flag, /* i : ACELP->HQ switching flag Q0*/ #ifdef IVAS_CODE_SWITCHING const Word16 sba_dirac_stereo_flag, /* i : signal stereo output for SBA DirAC */ const Word16 nchan_out, /* i : number of output channels */ #endif const Word16 last_element_mode, /* i : element mode of previous frame Q0*/ Word16 *Qsynth /* i/o: Scaling of ACELP exit (Q_syn2-1) or HQ exit (Qsynth); changes after this function */ ) Loading @@ -1152,9 +898,6 @@ ivas_error core_switching_post_dec_fx( HQ_DEC_HANDLE hHQ_core; ivas_error error; #ifdef IVAS_CODE_SWITCHING int16_t offset; #endif #ifdef REMOVE_IVAS_UNUSED_PARAMETERS_WARNING (void) ( last_element_mode ); #endif Loading
lib_dec/evs_dec_fx.c +1 −9 Original line number Diff line number Diff line Loading @@ -360,15 +360,7 @@ ivas_error evs_dec_fx( * Postprocessing for ACELP/HQ core switching *---------------------------------------------------------------------*/ if ( ( error = core_switching_post_dec_fx( st_fx, synth_fx, #ifdef IVAS_CODE_SWITCHING output, output_mem[], IVAS_FORMAT ivas_format, use_cldfb_for_dft, #endif output_frame, core_switching_flag, #ifdef IVAS_CODE_SWITCHING sba_dirac_stereo_flag, nchan_out, #endif st_fx->last_element_mode, &Qpostd ) ) != IVAS_ERR_OK ) if ( ( error = core_switching_post_dec_fx( st_fx, synth_fx, output_frame, core_switching_flag, st_fx->last_element_mode, &Qpostd ) ) != IVAS_ERR_OK ) { return error; } Loading