Loading lib_enc/init_enc_fx.c +213 −132 Original line number Diff line number Diff line Loading @@ -27,8 +27,6 @@ ivas_error init_encoder_fx( ) { Word16 i; Word32 L_tmp; Word16 idchan = 0; /* i : channel ID */ Word16 vad_only_flag = 0; /* i : channel ID */ Loading Loading @@ -607,20 +605,24 @@ ivas_error init_encoder_fx( * DTX *-----------------------------------------------------------------*/ st_fx->lp_speech_fx = 11520; move16(); /*Q8 (45.0) */ /* Initialize the long-term active speech level in dB */ st_fx->lp_noise_fx = 0; st->lp_speech_fx = 11520; /*Q8 (45.0) */ /* Initialize the long-term active speech level in dB */ move16(); st->lp_speech_32fx = 754974720; /*Q24 (45.0) */ /* Initialize the long-term active speech level in dB */ move32(); st->lp_noise_fx = 0; move16(); st->lp_noise_32fx = 0; move16(); test(); test(); IF( ( ( idchan == 0 && st_fx->Opt_DTX_ON ) || EQ_16( st_fx->element_mode, EVS_MONO ) ) || ( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) && st_fx->Opt_DTX_ON ) ) IF( ( ( idchan == 0 && st->Opt_DTX_ON ) || st->element_mode == EVS_MONO ) || ( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && st->Opt_DTX_ON ) ) { if ( ( st_fx->hDtxEnc = (DTX_ENC_HANDLE) malloc( sizeof( DTX_ENC_DATA ) ) ) == NULL ) IF( ( st->hDtxEnc = (DTX_ENC_HANDLE) malloc( sizeof( DTX_ENC_DATA ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DTX variables\n" ) ); } dtx_enc_init_fx( st_fx, var_SID_rate_flag, interval_SID ); dtx_enc_init_fx( st, var_SID_rate_flag, interval_SID ); } ELSE { Loading @@ -643,23 +645,25 @@ ivas_error init_encoder_fx( * LP-CNG *-----------------------------------------------------------------*/ test(); test(); test(); test(); test(); IF( ( ( idchan == 0 && st_fx->Opt_DTX_ON && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, EVS_MONO ) ) && !( EQ_16( ism_mode, ISM_MODE_PARAM ) || EQ_16( ism_mode, ISM_MODE_DISC ) ) ) IF( ( ( idchan == 0 && st->Opt_DTX_ON && NE_16( st->element_mode, IVAS_CPE_MDCT ) ) || st->element_mode == EVS_MONO ) && !( EQ_16( ism_mode, ISM_MODE_PARAM ) || EQ_16( ism_mode, ISM_MODE_DISC ) ) ) { IF( ( st_fx->hTdCngEnc = (TD_CNG_ENC_HANDLE) malloc( sizeof( TD_CNG_ENC_DATA ) ) ) == NULL ) IF( ( st->hTdCngEnc = (TD_CNG_ENC_HANDLE) malloc( sizeof( TD_CNG_ENC_DATA ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DTX/TD CNG\n" ) ); } td_cng_enc_init_fx( st_fx->hTdCngEnc, st_fx->Opt_DTX_ON, st_fx->max_bwidth ); IF( st->element_mode == EVS_MONO ) { td_cng_enc_init_fx( st->hTdCngEnc, st->Opt_DTX_ON, st->max_bwidth ); } ELSE { st_fx->hTdCngEnc = NULL; td_cng_enc_init_ivas_fx( st->hTdCngEnc, st->Opt_DTX_ON, st->max_bwidth ); } } ELSE { st->hTdCngEnc = NULL; } Loading @@ -669,68 +673,73 @@ ivas_error init_encoder_fx( test(); test(); IF( ( idchan == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) IF( ( idchan == 0 && NE_16( st->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st->element_mode, IVAS_CPE_TD ) ) { IF( ( st_fx->hLPDmem = (LPD_state_HANDLE) malloc( sizeof( LPD_state ) ) ) == NULL ) IF( ( st->hLPDmem = (LPD_state_HANDLE) malloc( sizeof( LPD_state ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LPDmem\n" ) ); } LPDmem_enc_init_fx( st_fx->hLPDmem ); IF( st->element_mode == EVS_MONO ) { LPDmem_enc_init_fx( st->hLPDmem ); } ELSE { st_fx->hLPDmem = NULL; LPDmem_enc_init_ivas_fx( st->hLPDmem ); } /* FEC */ st_fx->last_clas = UNVOICED_CLAS; move16(); FOR( i = 0; i < 2 * NB_SUBFR16k; i++ ) } ELSE { st_fx->old_pitch_buf_fx[i] = L_SUBFR_Q6; move16(); st->hLPDmem = NULL; } st_fx->old_Es_pred_fx = 0; move16(); set16_fx( st_fx->old_Aq_12_8_fx + 1, 0, M ); st_fx->old_Aq_12_8_fx[0] = 4096; move16(); /*-----------------------------------------------------------------* * CLDFB Analysis *-----------------------------------------------------------------*/ test(); test(); test(); IF( ( NE_16( st->element_mode, IVAS_CPE_MDCT ) && idchan == 0 ) || ( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && st->Opt_DTX_ON ) ) { IF( st->element_mode == EVS_MONO ) { /* open analysis for input SR */ if ( ( error = openCldfb( &st_fx->cldfbAnaEnc, CLDFB_ANALYSIS, st_fx->input_Fs ) ) != IVAS_ERR_OK ) IF( ( error = openCldfb( &st->cldfbAnaEnc, CLDFB_ANALYSIS, st->input_Fs ) ) != IVAS_ERR_OK ) { return error; } if ( ( error = openCldfb( &st_fx->cldfbSynTd, CLDFB_SYNTHESIS, 16000 ) ) != IVAS_ERR_OK ) } ELSE { IF( ( error = openCldfb_ivas_fx( &st->cldfbAnaEnc, CLDFB_ANALYSIS, st->input_Fs, CLDFB_PROTOTYPE_1_25MS, ENC ) ) != IVAS_ERR_OK ) { return error; } } } ELSE { st->cldfbAnaEnc = NULL; } st_fx->energyCoreLookahead_Fx = 0; IF( st->element_mode == EVS_MONO ) { st->energyCoreLookahead_Fx = 0; move32(); st_fx->sf_energyCoreLookahead_Fx = 0; move16(); /* stable short pitch detection */ st_fx->voicing0_sm_fx = 0; move16(); st_fx->voicing_sm_fx = 0; move16(); st_fx->LF_EnergyRatio_sm_fx = 128; move16(); st_fx->predecision_flag = 0; st->sf_energyCoreLookahead_Fx = 0; move16(); st_fx->diff_sm_fx = 0; move32(); st_fx->energy_sm_fx = 0; } ELSE { st->energyCoreLookahead_Fx = 2; /* 6.1e-5f in Q15 */ move32(); st->sf_energyCoreLookahead_Fx = 2; /* 6.1e-5f in Q15 */ move16(); } /*-----------------------------------------------------------------* * SC-VBR parameters Loading Loading @@ -780,18 +789,21 @@ ivas_error init_encoder_fx( /*-----------------------------------------------------------------* * SWB BWE parameters *-----------------------------------------------------------------*/ IF( idchan == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) test(); IF( idchan == 0 && NE_16( st->element_mode, IVAS_CPE_MDCT ) ) { IF( ( st_fx->hBWE_FD = (FD_BWE_ENC_HANDLE) malloc( sizeof( FD_BWE_ENC_DATA ) ) ) == NULL ) IF( ( st->hBWE_FD = (FD_BWE_ENC_HANDLE) malloc( sizeof( FD_BWE_ENC_DATA ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FD BWE\n" ) ); } fd_bwe_enc_init_fx( st_fx->hBWE_FD ); fd_bwe_enc_init_fx( st->hBWE_FD ); st->Q_old_wtda = 0; move16(); } ELSE { st_fx->hBWE_FD = NULL; st->hBWE_FD = NULL; } st_fx->prev_Q_shb = 0; Loading @@ -803,27 +815,42 @@ ivas_error init_encoder_fx( * TBE parameters *-----------------------------------------------------------------*/ IF( idchan == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) test(); IF( idchan == 0 && NE_16( st->element_mode, IVAS_CPE_MDCT ) ) { IF( ( st_fx->hBWE_TD = (TD_BWE_ENC_HANDLE) malloc( sizeof( TD_BWE_ENC_DATA ) ) ) == NULL ) IF( ( st->hBWE_TD = (TD_BWE_ENC_HANDLE) malloc( sizeof( TD_BWE_ENC_DATA ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TD BWE\n" ) ); } // IF ((error = openCldfb(&st_fx->cldfbSynTd, CLDFB_SYNTHESIS, 16000, CLDFB_PROTOTYPE_1_25MS)) != IVAS_ERR_OK) //{ // return error; // } IF( st->element_mode == EVS_MONO ) { if ( ( error = openCldfb( &st->cldfbSynTd, CLDFB_SYNTHESIS, 16000 ) ) != IVAS_ERR_OK ) { return error; } InitSWBencBuffer_fx( st_fx /*st_fx->hBWE_TD*/ ); ResetSHBbuffer_Enc_fx( st_fx /*st_fx->hBWE_TD*/ ); InitSWBencBuffer_fx( st /*st_fx->hBWE_TD*/ ); } ELSE { st_fx->hBWE_TD = NULL; // st_fx->cldfbSynTd = NULL; IF( ( error = openCldfb_ivas_fx( &st->cldfbSynTd, CLDFB_SYNTHESIS, 16000, CLDFB_PROTOTYPE_1_25MS, ENC ) ) != IVAS_ERR_OK ) { return error; } InitSWBencBuffer_ivas_fx( st ); } ResetSHBbuffer_Enc_fx( st ); } ELSE { st->hBWE_TD = NULL; st->cldfbSynTd = NULL; } test(); IF( st_fx->Opt_RF_ON || st_fx->element_mode == EVS_MONO ) { Loading Loading @@ -860,41 +887,46 @@ ivas_error init_encoder_fx( * TCX core *-----------------------------------------------------------------*/ // ToDo: reduction possible for MCT_CHAN_MODE_LFE channel test(); IF( idchan == 0 || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) IF( idchan == 0 || EQ_16( st->element_mode, IVAS_CPE_MDCT ) ) { IF( ( st_fx->hTcxEnc = (TCX_ENC_HANDLE) malloc( sizeof( TCX_ENC_DATA ) ) ) == NULL ) IF( ( st->hTcxEnc = (TCX_ENC_HANDLE) malloc( sizeof( TCX_ENC_DATA ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for hTcxEnc\n" ) ); } set32_fx( st->hTcxEnc->spectrum_long_fx, 0, N_MAX ); st->hTcxEnc->spectrum_long_e = 0; move16(); /* Share the memories for 2xTCX10/4xTCX5 and for TCX20 */ /*st_fx->hTcxEnc->spectrum[0] = st_fx->hTcxEnc->spectrum_long; st_fx->hTcxEnc->spectrum[1] = st_fx->hTcxEnc->spectrum_long + N_TCX10_MAX;*/ st_fx->hTcxEnc->spectrum_fx[0] = st_fx->hTcxEnc->spectrum_long_fx; st_fx->hTcxEnc->spectrum_fx[1] = st_fx->hTcxEnc->spectrum_long_fx + N_TCX10_MAX; st->hTcxEnc->spectrum_fx[0] = st->hTcxEnc->spectrum_long_fx; st->hTcxEnc->spectrum_fx[1] = st->hTcxEnc->spectrum_long_fx + N_TCX10_MAX; move32(); move32(); st->hTcxEnc->spectrum_e[0] = st->hTcxEnc->spectrum_e[1] = 0; move16(); move16(); set16_fx( st_fx->hTcxEnc->old_out_fx, 0, L_FRAME32k ); st_fx->hTcxEnc->Q_old_out = 0; set16_fx( st->hTcxEnc->old_out_fx, 0, L_FRAME32k ); st->hTcxEnc->Q_old_out = 0; move16(); /* MDCT selector */ MDCT_selector_reset_fx( st_fx->hTcxEnc ); st_fx->hTcxEnc->Q_old_out = 0; move16(); MDCT_selector_reset_fx( st->hTcxEnc ); /* MDCT classifier */ MDCT_classifier_reset_fx( st_fx->hTcxEnc ); MDCT_classifier_reset_fx( st->hTcxEnc ); IF( ( st_fx->hTcxCfg = (TCX_CONFIG_HANDLE) malloc( sizeof( TCX_config ) ) ) == NULL ) IF( ( st->hTcxCfg = (TCX_CONFIG_HANDLE) malloc( sizeof( TCX_config ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for hTcxCfg\n" ) ); } } ELSE { st_fx->hTcxEnc = NULL; // st_fx->hTcxCfg = NULL; st->hTcxEnc = NULL; st->hTcxCfg = NULL; } /*-----------------------------------------------------------------* * HQ core parameters Loading Loading @@ -961,57 +993,104 @@ ivas_error init_encoder_fx( * IGF *-----------------------------------------------------------------*/ move16(); test(); test(); IF( idchan == 0 || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) test(); IF( ( idchan == 0 || EQ_16( st->element_mode, IVAS_CPE_MDCT ) ) && ( st->igf || st->element_mode == EVS_MONO ) ) { IF( ( st_fx->hIGFEnc = (IGF_ENC_INSTANCE_HANDLE) malloc( sizeof( IGF_ENC_INSTANCE ) ) ) == NULL ) IF( ( st->hIGFEnc = (IGF_ENC_INSTANCE_HANDLE) malloc( sizeof( IGF_ENC_INSTANCE ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for hIGFEnc\n" ) ); } } ELSE { st_fx->hIGFEnc = NULL; move16(); st->hIGFEnc = NULL; } IF( EQ_16( st_fx->codec_mode, MODE2 ) ) /*-----------------------------------------------------------------* * FD-CNG encoder *-----------------------------------------------------------------*/ test(); test(); test(); test(); IF( ( idchan == 0 && st->Opt_DTX_ON ) || st->element_mode == EVS_MONO || ( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && st->Opt_DTX_ON ) ) { createFdCngEnc_fx( &st->hFdCngEnc ); initFdCngEnc_fx( st->hFdCngEnc, st->input_Fs, st->cldfbAnaEnc->scale ); /* initialization for IVAS modes happens in first frame pre-processing */ IF( st->element_mode == EVS_MONO ) { Word32 total_brate; test(); IF( st->rf_mode && EQ_32( st->total_brate, ACELP_13k20 ) ) { st_fx->igf = getIgfPresent_fx( st_fx->element_mode, st_fx->total_brate, st_fx->bwidth, st_fx->rf_mode ); total_brate = ACELP_9k60; move32(); } ELSE { st_fx->igf = 0; move16(); total_brate = st->total_brate; move32(); } /* FD-CNG encoder */ createFdCngEnc_fx( &st_fx->hFdCngEnc ); initFdCngEnc_fx( st_fx->hFdCngEnc, st_fx->input_Fs, st_fx->cldfbAnaEnc->scale ); L_tmp = st_fx->total_brate; move32(); test(); if ( st_fx->rf_mode && EQ_32( st_fx->total_brate, ACELP_13k20 ) ) configureFdCngEnc_fx( st->hFdCngEnc, st->bwidth, total_brate ); } } ELSE { L_tmp = ACELP_9k60; move32(); st->hFdCngEnc = NULL; } configureFdCngEnc_fx( st_fx->hFdCngEnc, st_fx->bwidth, L_tmp ); st_fx->last_totalNoise_fx = 0; move16(); set16_fx( st_fx->totalNoise_increase_hist_fx, 0, TOTALNOISE_HIST_SIZE ); st_fx->totalNoise_increase_len = 0; move16(); st->prevEnergyHF_fx = 0; move32(); IF( st->element_mode == EVS_MONO ) { init_coder_ace_plus_fx( st, st->last_total_brate, 0, -10 /*hack*/ ); } ELSE { /* Initialize Signal Buffers */ Word16 shift = getScaleFactor16( st->old_inp_16k_fx, L_INP_MEM ); Scale_sig( st->old_inp_16k_fx, L_INP_MEM, shift ); st->exp_old_inp_16k = sub( st->exp_old_inp_16k, shift ); move16(); shift = getScaleFactor16( st->old_inp_12k8_fx, L_INP_MEM ); Scale_sig( st->old_inp_12k8_fx, L_INP_MEM, shift ); st->exp_old_inp_12k8 = sub( st->exp_old_inp_12k8, shift ); move16(); init_coder_ace_plus_ivas_fx( st, st->last_total_brate, -1, 0 ); } IF( st->hLPDmem != NULL ) { st->hLPDmem->q_lpd_old_exc = st->prev_Q_new; move16(); } init_coder_ace_plus_fx( st_fx, st_fx->last_total_brate, 0, -10 /*hack*/ ); IF( ( st_fx->hTranDet = (TRAN_DET_HANDLE) malloc( sizeof( TRAN_DET_DATA ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Transient Detection\n" ) ); } InitTransientDetection_fx( extract_l( Mult_32_16( st_fx->input_Fs, 0x0290 ) ), NS2SA_FX2( st_fx->input_Fs, DELAY_FIR_RESAMPL_NS ), st_fx->hTranDet ); InitTransientDetection_fx( frame_length, NS2SA_FX2( st_fx->input_Fs, DELAY_FIR_RESAMPL_NS ), st_fx->hTranDet ); st_fx->Q_syn2 = 0; move16(); Loading @@ -1034,31 +1113,30 @@ ivas_error init_encoder_fx( move16(); st_fx->cng_sba_flag = 0; /* CNG in SBA flag */ move16(); st_fx->GSC_IVAS_mode = 0; /* CNG in SBA flag */ st->bits_frame_channel = 0; move16(); st_fx->element_mode = EVS_MONO; /* element mode */ st->side_bits_frame_channel = 0; move16(); st_fx->last_element_mode = st_fx->element_mode; /* element mode */ st->Q_syn2 = 0; move16(); st_fx->element_brate = -1; /* element bitrate */ move32(); // PMT("element_mode and element_brate should be initialized at a proper place in ivas_dec_init eventually") st_fx->low_rate_mode = 0; /* low-rate mode flag */ st->Q_syn = 0; move16(); // st_fx->coder_type = GENERIC; /* low-rate mode flag */ set16_fx( st_fx->pitch, L_SUBFR, 3 ); set16_fx( st_fx->voicing_fx, 0, 3 ); set16_fx( st->Q_max, Q_MAX, L_Q_MEM ); set16_fx( st->Q_max_16k, Q_MAX, L_Q_MEM ); st->Q_old = 15; move16(); st->old_wsp_max = 0; move16(); st->old_wsp_shift = 0; move16(); st->sharpFlag = 0; #ifdef DEBUGGING st_fx->id_element = -1; /* element ID */ move16(); #endif st_fx->extl_orig = -1; /* extension layer */ move16(); st_fx->extl_brate_orig = 0; /* extension layer bitrate */ move32(); return error; } Loading Loading @@ -1684,6 +1762,7 @@ ivas_error init_encoder_ivas_fx( move16(); st->lp_noise_32fx = 0; move16(); st->flag_noisy_speech_snr = 0; move16(); st->fd_cng_reset_flag = 0; Loading Loading @@ -1782,6 +1861,7 @@ ivas_error init_encoder_ivas_fx( /*-----------------------------------------------------------------* * CLDFB & resampling tools parameters *-----------------------------------------------------------------*/ test(); test(); test(); Loading Loading @@ -1977,6 +2057,9 @@ ivas_error init_encoder_ivas_fx( st->hBWE_FD = NULL; } st->prev_Q_shb = 0; move16(); /*-----------------------------------------------------------------* * HQ core parameters *-----------------------------------------------------------------*/ Loading Loading @@ -2209,12 +2292,6 @@ ivas_error init_encoder_ivas_fx( set16_fx( st->totalNoise_increase_hist_fx, 0, TOTALNOISE_HIST_SIZE ); st->totalNoise_increase_len = 0; move16(); TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc; IF( hTcxEnc != NULL ) { hTcxEnc->L_frameTCX = frame_length; move16(); } st->prevEnergyHF_fx = 0; move32(); Loading Loading @@ -2326,6 +2403,10 @@ ivas_error init_encoder_ivas_fx( move16(); st->sharpFlag = 0; move16(); #ifdef DEBUGGING st_fx->id_element = -1; /* element ID */ move16(); #endif return error; } Loading lib_enc/stat_enc.h +4 −5 Original line number Diff line number Diff line Loading @@ -1235,12 +1235,11 @@ typedef struct enc_core_structure *----------------------------------------------------------------------------------*/ Word16 idchan; /* channel ID (audio channel number) */ #ifdef DEBUGGING Word16 id_element; /* element ID */ #endif Word16 element_mode; /* element mode */ Word16 last_element_mode; /* element mode */ Word32 element_brate; /* element bitrate */ Word16 extl_orig; /* extension layer */ Word32 extl_brate_orig; /* extension layer bitrate */ Word16 codec_mode; /* Mode1 or Mode2 */ Word16 last_codec_mode; /* previous frame Mode 1 or 2 */ Word16 last_codec_mode_cng; /* previous inactive frame Mode 1 or 2 */ Loading Loading
lib_enc/init_enc_fx.c +213 −132 Original line number Diff line number Diff line Loading @@ -27,8 +27,6 @@ ivas_error init_encoder_fx( ) { Word16 i; Word32 L_tmp; Word16 idchan = 0; /* i : channel ID */ Word16 vad_only_flag = 0; /* i : channel ID */ Loading Loading @@ -607,20 +605,24 @@ ivas_error init_encoder_fx( * DTX *-----------------------------------------------------------------*/ st_fx->lp_speech_fx = 11520; move16(); /*Q8 (45.0) */ /* Initialize the long-term active speech level in dB */ st_fx->lp_noise_fx = 0; st->lp_speech_fx = 11520; /*Q8 (45.0) */ /* Initialize the long-term active speech level in dB */ move16(); st->lp_speech_32fx = 754974720; /*Q24 (45.0) */ /* Initialize the long-term active speech level in dB */ move32(); st->lp_noise_fx = 0; move16(); st->lp_noise_32fx = 0; move16(); test(); test(); IF( ( ( idchan == 0 && st_fx->Opt_DTX_ON ) || EQ_16( st_fx->element_mode, EVS_MONO ) ) || ( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) && st_fx->Opt_DTX_ON ) ) IF( ( ( idchan == 0 && st->Opt_DTX_ON ) || st->element_mode == EVS_MONO ) || ( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && st->Opt_DTX_ON ) ) { if ( ( st_fx->hDtxEnc = (DTX_ENC_HANDLE) malloc( sizeof( DTX_ENC_DATA ) ) ) == NULL ) IF( ( st->hDtxEnc = (DTX_ENC_HANDLE) malloc( sizeof( DTX_ENC_DATA ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DTX variables\n" ) ); } dtx_enc_init_fx( st_fx, var_SID_rate_flag, interval_SID ); dtx_enc_init_fx( st, var_SID_rate_flag, interval_SID ); } ELSE { Loading @@ -643,23 +645,25 @@ ivas_error init_encoder_fx( * LP-CNG *-----------------------------------------------------------------*/ test(); test(); test(); test(); test(); IF( ( ( idchan == 0 && st_fx->Opt_DTX_ON && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, EVS_MONO ) ) && !( EQ_16( ism_mode, ISM_MODE_PARAM ) || EQ_16( ism_mode, ISM_MODE_DISC ) ) ) IF( ( ( idchan == 0 && st->Opt_DTX_ON && NE_16( st->element_mode, IVAS_CPE_MDCT ) ) || st->element_mode == EVS_MONO ) && !( EQ_16( ism_mode, ISM_MODE_PARAM ) || EQ_16( ism_mode, ISM_MODE_DISC ) ) ) { IF( ( st_fx->hTdCngEnc = (TD_CNG_ENC_HANDLE) malloc( sizeof( TD_CNG_ENC_DATA ) ) ) == NULL ) IF( ( st->hTdCngEnc = (TD_CNG_ENC_HANDLE) malloc( sizeof( TD_CNG_ENC_DATA ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DTX/TD CNG\n" ) ); } td_cng_enc_init_fx( st_fx->hTdCngEnc, st_fx->Opt_DTX_ON, st_fx->max_bwidth ); IF( st->element_mode == EVS_MONO ) { td_cng_enc_init_fx( st->hTdCngEnc, st->Opt_DTX_ON, st->max_bwidth ); } ELSE { st_fx->hTdCngEnc = NULL; td_cng_enc_init_ivas_fx( st->hTdCngEnc, st->Opt_DTX_ON, st->max_bwidth ); } } ELSE { st->hTdCngEnc = NULL; } Loading @@ -669,68 +673,73 @@ ivas_error init_encoder_fx( test(); test(); IF( ( idchan == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) IF( ( idchan == 0 && NE_16( st->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st->element_mode, IVAS_CPE_TD ) ) { IF( ( st_fx->hLPDmem = (LPD_state_HANDLE) malloc( sizeof( LPD_state ) ) ) == NULL ) IF( ( st->hLPDmem = (LPD_state_HANDLE) malloc( sizeof( LPD_state ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LPDmem\n" ) ); } LPDmem_enc_init_fx( st_fx->hLPDmem ); IF( st->element_mode == EVS_MONO ) { LPDmem_enc_init_fx( st->hLPDmem ); } ELSE { st_fx->hLPDmem = NULL; LPDmem_enc_init_ivas_fx( st->hLPDmem ); } /* FEC */ st_fx->last_clas = UNVOICED_CLAS; move16(); FOR( i = 0; i < 2 * NB_SUBFR16k; i++ ) } ELSE { st_fx->old_pitch_buf_fx[i] = L_SUBFR_Q6; move16(); st->hLPDmem = NULL; } st_fx->old_Es_pred_fx = 0; move16(); set16_fx( st_fx->old_Aq_12_8_fx + 1, 0, M ); st_fx->old_Aq_12_8_fx[0] = 4096; move16(); /*-----------------------------------------------------------------* * CLDFB Analysis *-----------------------------------------------------------------*/ test(); test(); test(); IF( ( NE_16( st->element_mode, IVAS_CPE_MDCT ) && idchan == 0 ) || ( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && st->Opt_DTX_ON ) ) { IF( st->element_mode == EVS_MONO ) { /* open analysis for input SR */ if ( ( error = openCldfb( &st_fx->cldfbAnaEnc, CLDFB_ANALYSIS, st_fx->input_Fs ) ) != IVAS_ERR_OK ) IF( ( error = openCldfb( &st->cldfbAnaEnc, CLDFB_ANALYSIS, st->input_Fs ) ) != IVAS_ERR_OK ) { return error; } if ( ( error = openCldfb( &st_fx->cldfbSynTd, CLDFB_SYNTHESIS, 16000 ) ) != IVAS_ERR_OK ) } ELSE { IF( ( error = openCldfb_ivas_fx( &st->cldfbAnaEnc, CLDFB_ANALYSIS, st->input_Fs, CLDFB_PROTOTYPE_1_25MS, ENC ) ) != IVAS_ERR_OK ) { return error; } } } ELSE { st->cldfbAnaEnc = NULL; } st_fx->energyCoreLookahead_Fx = 0; IF( st->element_mode == EVS_MONO ) { st->energyCoreLookahead_Fx = 0; move32(); st_fx->sf_energyCoreLookahead_Fx = 0; move16(); /* stable short pitch detection */ st_fx->voicing0_sm_fx = 0; move16(); st_fx->voicing_sm_fx = 0; move16(); st_fx->LF_EnergyRatio_sm_fx = 128; move16(); st_fx->predecision_flag = 0; st->sf_energyCoreLookahead_Fx = 0; move16(); st_fx->diff_sm_fx = 0; move32(); st_fx->energy_sm_fx = 0; } ELSE { st->energyCoreLookahead_Fx = 2; /* 6.1e-5f in Q15 */ move32(); st->sf_energyCoreLookahead_Fx = 2; /* 6.1e-5f in Q15 */ move16(); } /*-----------------------------------------------------------------* * SC-VBR parameters Loading Loading @@ -780,18 +789,21 @@ ivas_error init_encoder_fx( /*-----------------------------------------------------------------* * SWB BWE parameters *-----------------------------------------------------------------*/ IF( idchan == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) test(); IF( idchan == 0 && NE_16( st->element_mode, IVAS_CPE_MDCT ) ) { IF( ( st_fx->hBWE_FD = (FD_BWE_ENC_HANDLE) malloc( sizeof( FD_BWE_ENC_DATA ) ) ) == NULL ) IF( ( st->hBWE_FD = (FD_BWE_ENC_HANDLE) malloc( sizeof( FD_BWE_ENC_DATA ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FD BWE\n" ) ); } fd_bwe_enc_init_fx( st_fx->hBWE_FD ); fd_bwe_enc_init_fx( st->hBWE_FD ); st->Q_old_wtda = 0; move16(); } ELSE { st_fx->hBWE_FD = NULL; st->hBWE_FD = NULL; } st_fx->prev_Q_shb = 0; Loading @@ -803,27 +815,42 @@ ivas_error init_encoder_fx( * TBE parameters *-----------------------------------------------------------------*/ IF( idchan == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) test(); IF( idchan == 0 && NE_16( st->element_mode, IVAS_CPE_MDCT ) ) { IF( ( st_fx->hBWE_TD = (TD_BWE_ENC_HANDLE) malloc( sizeof( TD_BWE_ENC_DATA ) ) ) == NULL ) IF( ( st->hBWE_TD = (TD_BWE_ENC_HANDLE) malloc( sizeof( TD_BWE_ENC_DATA ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TD BWE\n" ) ); } // IF ((error = openCldfb(&st_fx->cldfbSynTd, CLDFB_SYNTHESIS, 16000, CLDFB_PROTOTYPE_1_25MS)) != IVAS_ERR_OK) //{ // return error; // } IF( st->element_mode == EVS_MONO ) { if ( ( error = openCldfb( &st->cldfbSynTd, CLDFB_SYNTHESIS, 16000 ) ) != IVAS_ERR_OK ) { return error; } InitSWBencBuffer_fx( st_fx /*st_fx->hBWE_TD*/ ); ResetSHBbuffer_Enc_fx( st_fx /*st_fx->hBWE_TD*/ ); InitSWBencBuffer_fx( st /*st_fx->hBWE_TD*/ ); } ELSE { st_fx->hBWE_TD = NULL; // st_fx->cldfbSynTd = NULL; IF( ( error = openCldfb_ivas_fx( &st->cldfbSynTd, CLDFB_SYNTHESIS, 16000, CLDFB_PROTOTYPE_1_25MS, ENC ) ) != IVAS_ERR_OK ) { return error; } InitSWBencBuffer_ivas_fx( st ); } ResetSHBbuffer_Enc_fx( st ); } ELSE { st->hBWE_TD = NULL; st->cldfbSynTd = NULL; } test(); IF( st_fx->Opt_RF_ON || st_fx->element_mode == EVS_MONO ) { Loading Loading @@ -860,41 +887,46 @@ ivas_error init_encoder_fx( * TCX core *-----------------------------------------------------------------*/ // ToDo: reduction possible for MCT_CHAN_MODE_LFE channel test(); IF( idchan == 0 || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) IF( idchan == 0 || EQ_16( st->element_mode, IVAS_CPE_MDCT ) ) { IF( ( st_fx->hTcxEnc = (TCX_ENC_HANDLE) malloc( sizeof( TCX_ENC_DATA ) ) ) == NULL ) IF( ( st->hTcxEnc = (TCX_ENC_HANDLE) malloc( sizeof( TCX_ENC_DATA ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for hTcxEnc\n" ) ); } set32_fx( st->hTcxEnc->spectrum_long_fx, 0, N_MAX ); st->hTcxEnc->spectrum_long_e = 0; move16(); /* Share the memories for 2xTCX10/4xTCX5 and for TCX20 */ /*st_fx->hTcxEnc->spectrum[0] = st_fx->hTcxEnc->spectrum_long; st_fx->hTcxEnc->spectrum[1] = st_fx->hTcxEnc->spectrum_long + N_TCX10_MAX;*/ st_fx->hTcxEnc->spectrum_fx[0] = st_fx->hTcxEnc->spectrum_long_fx; st_fx->hTcxEnc->spectrum_fx[1] = st_fx->hTcxEnc->spectrum_long_fx + N_TCX10_MAX; st->hTcxEnc->spectrum_fx[0] = st->hTcxEnc->spectrum_long_fx; st->hTcxEnc->spectrum_fx[1] = st->hTcxEnc->spectrum_long_fx + N_TCX10_MAX; move32(); move32(); st->hTcxEnc->spectrum_e[0] = st->hTcxEnc->spectrum_e[1] = 0; move16(); move16(); set16_fx( st_fx->hTcxEnc->old_out_fx, 0, L_FRAME32k ); st_fx->hTcxEnc->Q_old_out = 0; set16_fx( st->hTcxEnc->old_out_fx, 0, L_FRAME32k ); st->hTcxEnc->Q_old_out = 0; move16(); /* MDCT selector */ MDCT_selector_reset_fx( st_fx->hTcxEnc ); st_fx->hTcxEnc->Q_old_out = 0; move16(); MDCT_selector_reset_fx( st->hTcxEnc ); /* MDCT classifier */ MDCT_classifier_reset_fx( st_fx->hTcxEnc ); MDCT_classifier_reset_fx( st->hTcxEnc ); IF( ( st_fx->hTcxCfg = (TCX_CONFIG_HANDLE) malloc( sizeof( TCX_config ) ) ) == NULL ) IF( ( st->hTcxCfg = (TCX_CONFIG_HANDLE) malloc( sizeof( TCX_config ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for hTcxCfg\n" ) ); } } ELSE { st_fx->hTcxEnc = NULL; // st_fx->hTcxCfg = NULL; st->hTcxEnc = NULL; st->hTcxCfg = NULL; } /*-----------------------------------------------------------------* * HQ core parameters Loading Loading @@ -961,57 +993,104 @@ ivas_error init_encoder_fx( * IGF *-----------------------------------------------------------------*/ move16(); test(); test(); IF( idchan == 0 || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) test(); IF( ( idchan == 0 || EQ_16( st->element_mode, IVAS_CPE_MDCT ) ) && ( st->igf || st->element_mode == EVS_MONO ) ) { IF( ( st_fx->hIGFEnc = (IGF_ENC_INSTANCE_HANDLE) malloc( sizeof( IGF_ENC_INSTANCE ) ) ) == NULL ) IF( ( st->hIGFEnc = (IGF_ENC_INSTANCE_HANDLE) malloc( sizeof( IGF_ENC_INSTANCE ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for hIGFEnc\n" ) ); } } ELSE { st_fx->hIGFEnc = NULL; move16(); st->hIGFEnc = NULL; } IF( EQ_16( st_fx->codec_mode, MODE2 ) ) /*-----------------------------------------------------------------* * FD-CNG encoder *-----------------------------------------------------------------*/ test(); test(); test(); test(); IF( ( idchan == 0 && st->Opt_DTX_ON ) || st->element_mode == EVS_MONO || ( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && st->Opt_DTX_ON ) ) { createFdCngEnc_fx( &st->hFdCngEnc ); initFdCngEnc_fx( st->hFdCngEnc, st->input_Fs, st->cldfbAnaEnc->scale ); /* initialization for IVAS modes happens in first frame pre-processing */ IF( st->element_mode == EVS_MONO ) { Word32 total_brate; test(); IF( st->rf_mode && EQ_32( st->total_brate, ACELP_13k20 ) ) { st_fx->igf = getIgfPresent_fx( st_fx->element_mode, st_fx->total_brate, st_fx->bwidth, st_fx->rf_mode ); total_brate = ACELP_9k60; move32(); } ELSE { st_fx->igf = 0; move16(); total_brate = st->total_brate; move32(); } /* FD-CNG encoder */ createFdCngEnc_fx( &st_fx->hFdCngEnc ); initFdCngEnc_fx( st_fx->hFdCngEnc, st_fx->input_Fs, st_fx->cldfbAnaEnc->scale ); L_tmp = st_fx->total_brate; move32(); test(); if ( st_fx->rf_mode && EQ_32( st_fx->total_brate, ACELP_13k20 ) ) configureFdCngEnc_fx( st->hFdCngEnc, st->bwidth, total_brate ); } } ELSE { L_tmp = ACELP_9k60; move32(); st->hFdCngEnc = NULL; } configureFdCngEnc_fx( st_fx->hFdCngEnc, st_fx->bwidth, L_tmp ); st_fx->last_totalNoise_fx = 0; move16(); set16_fx( st_fx->totalNoise_increase_hist_fx, 0, TOTALNOISE_HIST_SIZE ); st_fx->totalNoise_increase_len = 0; move16(); st->prevEnergyHF_fx = 0; move32(); IF( st->element_mode == EVS_MONO ) { init_coder_ace_plus_fx( st, st->last_total_brate, 0, -10 /*hack*/ ); } ELSE { /* Initialize Signal Buffers */ Word16 shift = getScaleFactor16( st->old_inp_16k_fx, L_INP_MEM ); Scale_sig( st->old_inp_16k_fx, L_INP_MEM, shift ); st->exp_old_inp_16k = sub( st->exp_old_inp_16k, shift ); move16(); shift = getScaleFactor16( st->old_inp_12k8_fx, L_INP_MEM ); Scale_sig( st->old_inp_12k8_fx, L_INP_MEM, shift ); st->exp_old_inp_12k8 = sub( st->exp_old_inp_12k8, shift ); move16(); init_coder_ace_plus_ivas_fx( st, st->last_total_brate, -1, 0 ); } IF( st->hLPDmem != NULL ) { st->hLPDmem->q_lpd_old_exc = st->prev_Q_new; move16(); } init_coder_ace_plus_fx( st_fx, st_fx->last_total_brate, 0, -10 /*hack*/ ); IF( ( st_fx->hTranDet = (TRAN_DET_HANDLE) malloc( sizeof( TRAN_DET_DATA ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Transient Detection\n" ) ); } InitTransientDetection_fx( extract_l( Mult_32_16( st_fx->input_Fs, 0x0290 ) ), NS2SA_FX2( st_fx->input_Fs, DELAY_FIR_RESAMPL_NS ), st_fx->hTranDet ); InitTransientDetection_fx( frame_length, NS2SA_FX2( st_fx->input_Fs, DELAY_FIR_RESAMPL_NS ), st_fx->hTranDet ); st_fx->Q_syn2 = 0; move16(); Loading @@ -1034,31 +1113,30 @@ ivas_error init_encoder_fx( move16(); st_fx->cng_sba_flag = 0; /* CNG in SBA flag */ move16(); st_fx->GSC_IVAS_mode = 0; /* CNG in SBA flag */ st->bits_frame_channel = 0; move16(); st_fx->element_mode = EVS_MONO; /* element mode */ st->side_bits_frame_channel = 0; move16(); st_fx->last_element_mode = st_fx->element_mode; /* element mode */ st->Q_syn2 = 0; move16(); st_fx->element_brate = -1; /* element bitrate */ move32(); // PMT("element_mode and element_brate should be initialized at a proper place in ivas_dec_init eventually") st_fx->low_rate_mode = 0; /* low-rate mode flag */ st->Q_syn = 0; move16(); // st_fx->coder_type = GENERIC; /* low-rate mode flag */ set16_fx( st_fx->pitch, L_SUBFR, 3 ); set16_fx( st_fx->voicing_fx, 0, 3 ); set16_fx( st->Q_max, Q_MAX, L_Q_MEM ); set16_fx( st->Q_max_16k, Q_MAX, L_Q_MEM ); st->Q_old = 15; move16(); st->old_wsp_max = 0; move16(); st->old_wsp_shift = 0; move16(); st->sharpFlag = 0; #ifdef DEBUGGING st_fx->id_element = -1; /* element ID */ move16(); #endif st_fx->extl_orig = -1; /* extension layer */ move16(); st_fx->extl_brate_orig = 0; /* extension layer bitrate */ move32(); return error; } Loading Loading @@ -1684,6 +1762,7 @@ ivas_error init_encoder_ivas_fx( move16(); st->lp_noise_32fx = 0; move16(); st->flag_noisy_speech_snr = 0; move16(); st->fd_cng_reset_flag = 0; Loading Loading @@ -1782,6 +1861,7 @@ ivas_error init_encoder_ivas_fx( /*-----------------------------------------------------------------* * CLDFB & resampling tools parameters *-----------------------------------------------------------------*/ test(); test(); test(); Loading Loading @@ -1977,6 +2057,9 @@ ivas_error init_encoder_ivas_fx( st->hBWE_FD = NULL; } st->prev_Q_shb = 0; move16(); /*-----------------------------------------------------------------* * HQ core parameters *-----------------------------------------------------------------*/ Loading Loading @@ -2209,12 +2292,6 @@ ivas_error init_encoder_ivas_fx( set16_fx( st->totalNoise_increase_hist_fx, 0, TOTALNOISE_HIST_SIZE ); st->totalNoise_increase_len = 0; move16(); TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc; IF( hTcxEnc != NULL ) { hTcxEnc->L_frameTCX = frame_length; move16(); } st->prevEnergyHF_fx = 0; move32(); Loading Loading @@ -2326,6 +2403,10 @@ ivas_error init_encoder_ivas_fx( move16(); st->sharpFlag = 0; move16(); #ifdef DEBUGGING st_fx->id_element = -1; /* element ID */ move16(); #endif return error; } Loading
lib_enc/stat_enc.h +4 −5 Original line number Diff line number Diff line Loading @@ -1235,12 +1235,11 @@ typedef struct enc_core_structure *----------------------------------------------------------------------------------*/ Word16 idchan; /* channel ID (audio channel number) */ #ifdef DEBUGGING Word16 id_element; /* element ID */ #endif Word16 element_mode; /* element mode */ Word16 last_element_mode; /* element mode */ Word32 element_brate; /* element bitrate */ Word16 extl_orig; /* extension layer */ Word32 extl_brate_orig; /* extension layer bitrate */ Word16 codec_mode; /* Mode1 or Mode2 */ Word16 last_codec_mode; /* previous frame Mode 1 or 2 */ Word16 last_codec_mode_cng; /* previous inactive frame Mode 1 or 2 */ Loading