diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 400aa3eb070c51a12d4035787b79b0d7c5c367fb..20f8cf369cf3dcb7a236e26691f167c1e21bc654 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -1263,10 +1263,11 @@ Word16 matrix_product_diag_fx( // ivas_stereo_mdct_core_dec_fx.c void stereo_mdct_core_dec_fx( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - Word32 *signal_out[CPE_CHANNELS], /* o : synthesis @internal_FS */ - Word16 signal_outFB[CPE_CHANNELS][L_FRAME48k] /* o : synthesis @output_FS */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ + Word32 *signal_out[CPE_CHANNELS], /* o : synthesis @internal_FS */ + Word16 signal_outFB[CPE_CHANNELS][L_FRAME48k], /* o : synthesis @output_FS */ + Word16 e_sigFB[CPE_CHANNELS] /* o : exponent of synthesis @output_FS */ ); // ivas_stereo_mdct_stereo_com.c diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 420c2ba0d45368a65db4326905b8e97bd0d8e842..b27655f443eecb4f34515c0eca4ab7679128c13c 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -9328,7 +9328,7 @@ void ivas_mdct_core_reconstruct_fx( Word16 fUseTns[CPE_CHANNELS][NB_DIV], /* i : flage TNS enabled */ const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0)*/ Word16 q_x, - Word16 e_sig ); + Word16 e_sig[CPE_CHANNELS] ); void ari_start_encoding_14bits_ivas_fx( Tastat *s ); diff --git a/lib_dec/core_dec_init_fx.c b/lib_dec/core_dec_init_fx.c index bcee307664768221f77306e7761ef9a954bb0b91..6a023104a5c37de4872b1b35f702887ebcea62d4 100644 --- a/lib_dec/core_dec_init_fx.c +++ b/lib_dec/core_dec_init_fx.c @@ -365,6 +365,8 @@ void open_decoder_LPD_fx( set16_fx( hTcxDec->syn_Overl, 0, shr( L_FRAME32k, 1 ) ); set16_fx( hTcxDec->old_synth, 0, OLD_SYNTH_INTERNAL_DEC ); + hTcxDec->q_old_synth = 0; + move16(); set16_fx( hTcxDec->synth_history_fx, 0, add( L_PROT48k, L_FRAME_MAX ) ); hTcxDec->q_synth_history_fx = 0; move16(); @@ -389,6 +391,8 @@ void open_decoder_LPD_fx( IF( st->hTcxDec != NULL && ( ( NE_16( st->L_frame, st->last_L_frame ) ) || ( EQ_16( st->last_codec_mode, MODE1 ) ) ) ) { set16_fx( hTcxDec->old_synth, 0, OLD_SYNTH_INTERNAL_DEC ); + hTcxDec->q_old_synth = 0; + move16(); } /*Size of LPC syn memory*/ @@ -1478,6 +1482,8 @@ void open_decoder_LPD_ivas_fx( reset_tcx_overl_buf_fx( st->hTcxDec ); set16_fx( hTcxDec->syn_OverlFB, 0, L_FRAME_MAX / 2 ); set16_fx( hTcxDec->old_synth, 0, OLD_SYNTH_INTERNAL_DEC ); + hTcxDec->q_old_synth = 0; + move16(); set16_fx( hTcxDec->synth_history_fx, 0, L_PROT48k + L_FRAME_MAX ); hTcxDec->q_synth_history_fx = 0; move16(); @@ -1501,6 +1507,8 @@ void open_decoder_LPD_ivas_fx( IF( st->hTcxDec != NULL && ( NE_16( st->L_frame, st->last_L_frame ) || ( EQ_16( st->last_codec_mode, MODE1 ) && EQ_16( st->element_mode, EVS_MONO ) ) ) ) { set16_fx( hTcxDec->old_synth, 0, OLD_SYNTH_INTERNAL_DEC ); + hTcxDec->q_old_synth = 0; + move16(); } /*Compute size of old and new memories*/ diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index 870299242a97fd0c27dcb1ded0d2512785505399..3609184c41328879923530af84b63498a48a0f27 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -3162,7 +3162,11 @@ void IMDCT_ivas_fx( { FOR( i = 0; i < sub( overlap, tcx_mdct_window_min_length ); i++ ) { +#ifdef BASOP_NOGLOB + xn_buf_fx[add( i, sub( shr( overlap, 1 ), tcx_offset ) )] = add_sat( xn_buf_fx[add( i, sub( shr( overlap, 1 ), tcx_offset ) )], old_out_fx[add( i, nz )] ); +#else xn_buf_fx[add( i, sub( shr( overlap, 1 ), tcx_offset ) )] = add( xn_buf_fx[add( i, sub( shr( overlap, 1 ), tcx_offset ) )], old_out_fx[add( i, nz )] ); +#endif move16(); } @@ -3175,17 +3179,30 @@ void IMDCT_ivas_fx( // tested FOR( ; i < overlap; i++ ) /* perfectly reconstructing ALDO shortening */ { +#ifdef BASOP_NOGLOB + xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )] = add_sat( xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )], old_out_fx[add( i, nz )] ); +#else xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )] = add( xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )], old_out_fx[add( i, nz )] ); + +#endif move16(); } FOR( i = 0; i < shr( tcx_mdct_window_min_length, 1 ); i++ ) { +#ifdef BASOP_NOGLOB + xn_buf_fx[add( sub( add( i, shr( overlap, 1 ) ), tcx_offset ), overlap )] = add_sat( xn_buf_fx[add( sub( add( i, shr( overlap, 1 ) ), tcx_offset ), overlap )], mult_r( old_out_fx[add( add( i, nz ), overlap )], tcx_mdct_window_minimum_fx[i].v.re ) ); +#else xn_buf_fx[add( sub( add( i, shr( overlap, 1 ) ), tcx_offset ), overlap )] = add( xn_buf_fx[add( sub( add( i, shr( overlap, 1 ) ), tcx_offset ), overlap )], mult_r( old_out_fx[add( add( i, nz ), overlap )], tcx_mdct_window_minimum_fx[i].v.re ) ); +#endif move16(); } FOR( ; i < tcx_mdct_window_min_length; i++ ) { +#ifdef BASOP_NOGLOB + xn_buf_fx[add( sub( add( i, shr( overlap, 1 ) ), tcx_offset ), overlap )] = add_sat( xn_buf_fx[add( sub( add( i, shr( overlap, 1 ) ), tcx_offset ), overlap )], mult_r( old_out_fx[add( add( i, nz ), overlap )], tcx_mdct_window_minimum_fx[sub( tcx_mdct_window_min_length, add( 1, i ) )].v.im ) ); +#else xn_buf_fx[add( sub( add( i, shr( overlap, 1 ) ), tcx_offset ), overlap )] = add( xn_buf_fx[add( sub( add( i, shr( overlap, 1 ) ), tcx_offset ), overlap )], mult_r( old_out_fx[add( add( i, nz ), overlap )], tcx_mdct_window_minimum_fx[sub( tcx_mdct_window_min_length, add( 1, i ) )].v.im ) ); +#endif move16(); } } @@ -3193,12 +3210,20 @@ void IMDCT_ivas_fx( { FOR( ; i < sub( overlap, shr( tcx_mdct_window_min_length, 1 ) ); i++ ) { +#ifdef BASOP_NOGLOB + xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )] = add_sat( xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )], mult_r( old_out_fx[add( i, nz )], tcx_mdct_window_minimum_fx[add( sub( tcx_mdct_window_min_length, overlap ), i )].v.re ) ); +#else xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )] = add( xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )], mult_r( old_out_fx[add( i, nz )], tcx_mdct_window_minimum_fx[add( sub( tcx_mdct_window_min_length, overlap ), i )].v.re ) ); +#endif move16(); } FOR( ; i < overlap; i++ ) { +#ifdef BASOP_NOGLOB + xn_buf_fx[add( i, sub( shr( overlap, 1 ), tcx_offset ) )] = add_sat( xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )], mult_r( old_out_fx[add( i, nz )], tcx_mdct_window_minimum_fx[sub( overlap, add( 1, i ) )].v.im ) ); +#else xn_buf_fx[add( i, sub( shr( overlap, 1 ), tcx_offset ) )] = add( xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )], mult_r( old_out_fx[add( i, nz )], tcx_mdct_window_minimum_fx[sub( overlap, add( 1, i ) )].v.im ) ); +#endif move16(); } } @@ -3211,12 +3236,21 @@ void IMDCT_ivas_fx( { FOR( i = 0; i < shr( tcx_mdct_window_half_length, 1 ); i++ ) { +#ifdef BASOP_NOGLOB + xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )] = add_sat( xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )], mult_r( old_syn_overl_fx[i], tcx_mdct_window_half_fx[i].v.re ) ); +#else xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )] = add( xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )], mult_r( old_syn_overl_fx[i], tcx_mdct_window_half_fx[i].v.re ) ); + +#endif move16(); } FOR( ; i < tcx_mdct_window_half_length; i++ ) { +#ifdef BASOP_NOGLOB + xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )] = add_sat( xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )], mult_r( old_syn_overl_fx[i], tcx_mdct_window_half_fx[sub( tcx_mdct_window_half_length, add( 1, i ) )].v.im ) ); +#else xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )] = add( xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )], mult_r( old_syn_overl_fx[i], tcx_mdct_window_half_fx[sub( tcx_mdct_window_half_length, add( 1, i ) )].v.im ) ); +#endif move16(); } } @@ -3232,7 +3266,11 @@ void IMDCT_ivas_fx( { FOR( i = 0; i < overlap; i++ ) { +#ifdef BASOP_NOGLOB + xn_buf_fx[add( i, shr( overlap, 1 ) )] = add_sat( xn_buf_fx[add( i, shr( overlap, 1 ) )], old_syn_overl_fx[i] ); +#else xn_buf_fx[add( i, shr( overlap, 1 ) )] = add( xn_buf_fx[add( i, shr( overlap, 1 ) )], old_syn_overl_fx[i] ); +#endif move16(); } } @@ -3309,14 +3347,22 @@ void IMDCT_ivas_fx( FOR( i = 0; i < shr( tcx_mdct_window_half_length, 1 ); i++ ) { xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )] = mult_r( xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )], tcx_mdct_window_half_fx[i].v.im ); +#ifdef BASOP_NOGLOB + xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )] = add_sat( xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )], mult_r( mult_r( hTcxDec->syn_Overl[i], tcx_mdct_window_half_fx[i].v.re ), tcx_mdct_window_half_fx[i].v.re ) ); +#else xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )] = add( xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )], mult_r( mult_r( hTcxDec->syn_Overl[i], tcx_mdct_window_half_fx[i].v.re ), tcx_mdct_window_half_fx[i].v.re ) ); +#endif move16(); move16(); } FOR( ; i < tcx_mdct_window_half_length; i++ ) { xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )] = mult_r( xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )], tcx_mdct_window_half_fx[sub( tcx_mdct_window_half_length, add( 1, i ) )].v.re ); +#ifdef BASOP_NOGLOB + xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )] = add_sat( xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )], mult_r( mult_r( hTcxDec->syn_Overl[i], tcx_mdct_window_half_fx[sub( tcx_mdct_window_half_length, add( 1, i ) )].v.im ), tcx_mdct_window_half_fx[sub( tcx_mdct_window_half_length, add( 1, i ) )].v.im ) ); +#else xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )] = add( xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )], mult_r( mult_r( hTcxDec->syn_Overl[i], tcx_mdct_window_half_fx[sub( tcx_mdct_window_half_length, add( 1, i ) )].v.im ), tcx_mdct_window_half_fx[sub( tcx_mdct_window_half_length, add( 1, i ) )].v.im ) ); +#endif move16(); move16(); } diff --git a/lib_dec/ivas_core_dec.c b/lib_dec/ivas_core_dec.c index 5104dcd24024feeefdd4e670965378bfabd7db65..800e20f5b30173db199dedd9c34323c92b30ae37 100644 --- a/lib_dec/ivas_core_dec.c +++ b/lib_dec/ivas_core_dec.c @@ -108,6 +108,10 @@ ivas_error ivas_core_dec_fx( Word16 synth_16_fx[CPE_CHANNELS][L_FRAME48k]; Word32 synth_32_fx[CPE_CHANNELS][L_FRAME48k]; + Word16 e_sig[CPE_CHANNELS]; + e_sig[0] = e_sig[1] = 15; + move16(); + move16(); FOR( i = 0; i < CPE_CHANNELS; i++ ) { @@ -728,10 +732,11 @@ ivas_error ivas_core_dec_fx( } ELSE { - Word16 e_sig; Word16 ch; - e_sig = 17; + e_sig[0] = 17; + e_sig[1] = 17; + move16(); move16(); sts = hCPE->hCoreCoder; FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) @@ -767,7 +772,7 @@ ivas_error ivas_core_dec_fx( } } - stereo_mdct_core_dec_fx( st_ivas, hCPE, output_32_fx, synth_16_fx ); + stereo_mdct_core_dec_fx( st_ivas, hCPE, output_32_fx, synth_16_fx, e_sig ); FOR( ch = 0; ch < 2; ch++ ) { @@ -777,14 +782,6 @@ ivas_error ivas_core_dec_fx( st->hHQ_core->Q_old_wtda = st->Q_syn; move16(); } - -#ifdef MSAN_FIX - Scale_sig( synth_16_fx[0], hCPE->hCoreCoder[0]->hTcxDec->L_frameTCX, sub( e_sig, 15 ) ); - Scale_sig( synth_16_fx[1], hCPE->hCoreCoder[1]->hTcxDec->L_frameTCX, sub( e_sig, 15 ) ); -#else - Scale_sig( synth_16_fx[0], L_FRAME48k, sub( e_sig, 15 ) ); - Scale_sig( synth_16_fx[1], L_FRAME48k, sub( e_sig, 15 ) ); -#endif } } /* for inactive frames with mono output, copy and (if necessary) downmix buffers */ @@ -872,13 +869,7 @@ ivas_error ivas_core_dec_fx( *---------------------------------------------------------------------*/ /*core_switching_post_dec*/ - Q_synth = 0; - move16(); - if ( st->hHQ_core != NULL ) - { - st->hHQ_core->Q_old_postdec = 0; - move16(); - } + Q_synth = sub( 15, e_sig[0] ); /*------------------fix-to-fix-end-----------------------*/ @@ -1022,21 +1013,33 @@ ivas_error ivas_core_dec_fx( ivas_bw_switching_pre_proc_fx( st, last_element_brate, nchan_out, old_syn_12k8_16k_fx[n], old_syn_fx, q_audio ); - Copy_Scale_sig_16_32( st->delay_buf_out_fx, st->delay_buf_out32_fx, imult1616( HQ_DELTA_MAX, HQ_DELAY_COMP ), Q11 ); - Scale_sig32( output_32_fx[n], L_FRAME48k, sub( Q11, Q4 ) ); + IF( st->hHQ_core == NULL ) + { + Copy_Scale_sig_16_32( st->delay_buf_out_fx, st->delay_buf_out32_fx, imult1616( HQ_DELTA_MAX, HQ_DELAY_COMP ), Q11 ); + } + ELSE + { + Copy_Scale_sig_16_32( st->delay_buf_out_fx, st->delay_buf_out32_fx, imult1616( HQ_DELTA_MAX, HQ_DELAY_COMP ), sub( Q11, st->hHQ_core->Q_old_postdec ) ); + } + Scale_sig32( output_32_fx[n], L_FRAME48k, ( Q11 - Q4 ) ); /*note : cldfb_size here signifies the original size which was assigned to cldfb_state_fx buffer not its current size*/ IF( st->cldfbSyn != NULL ) { - scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( Q11, Q4 ) ); + scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, ( Q11 - Q4 ) ); st->cldfbSyn->Q_cldfb_state = Q11; move16(); } #ifdef MSAN_FIX - Scale_sig( synth_16_fx[n], output_frame, negate( Q_synth ) ); + IF( Q_synth > 0 ) + { + Scale_sig( synth_16_fx[n], output_frame, negate( Q_synth ) ); + Q_synth = 0; + move16(); + } #else Scale_sig( synth_16_fx[n], L_FRAME48k, negate( Q_synth ) ); #endif @@ -1065,19 +1068,25 @@ ivas_error ivas_core_dec_fx( *---------------------------------------------------------------------*/ Word16 Q_input, Q_hb_synth_fx, Q_synth_fx; - Word16 Q_syn_hb; + Word16 Q_syn_hb, sf; + + sf = getScaleFactor32( output_32_fx[n], L_FRAME48k ); Q_input = 0; move16(); + if ( LT_16( sf, 5 ) ) + { + Q_input = sub( sf, 5 ); + } Q_hb_synth_fx = 0; move16(); - Q_synth_fx = 0; + Q_synth_fx = Q_synth; move16(); FD_BWE_DEC_HANDLE hBWE_FD; hBWE_FD = st->hBWE_FD; - Copy_Scale_sig_32_16( output_32_fx[n], output_16_fx[n], L_FRAME48k, negate( Q11 ) ); + Copy_Scale_sig_32_16( output_32_fx[n], output_16_fx[n], L_FRAME48k, sub( Q_input, Q11 ) ); Copy_Scale_sig_32_16( hb_synth_32_fx[n], hb_synth_16_fx[n], L_FRAME48k, negate( Q11 ) ); test(); test(); diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index 543f05ade9bc21907aa7aed264be726f8879305a..91289552b4bbf096fc93300e50cd5bbb0f65aae9 100644 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -320,6 +320,9 @@ ivas_error ivas_mct_dec_fx( Word16 synth_fx[CPE_CHANNELS][L_FRAME_PLUS]; int32_t ivas_total_brate; ivas_error error; + Word16 e_sig[CPE_CHANNELS] = { 15, 15 }; + move16(); + move16(); push_wmops( "ivas_mct_dec" ); @@ -577,7 +580,11 @@ ivas_error ivas_mct_dec_fx( Copy_Scale_sig_16_32( hCPE->hCoreCoder[0]->old_Aq_12_8_fx, hCPE->hCoreCoder[0]->old_Aq_12_8_fx_32, add( M, 1 ), sub( 28, norm_s( sub( hCPE->hCoreCoder[0]->old_Aq_12_8_fx[0], 1 ) ) ) ); Copy_Scale_sig_16_32( hCPE->hCoreCoder[1]->old_Aq_12_8_fx, hCPE->hCoreCoder[1]->old_Aq_12_8_fx_32, add( M, 1 ), sub( 28, norm_s( sub( hCPE->hCoreCoder[1]->old_Aq_12_8_fx[0], 1 ) ) ) ); - ivas_mdct_core_reconstruct_fx( hCPE, x_fx, synth_fx, fUseTns[cpe_id], 1, q_output, 15 ); + + ivas_mdct_core_reconstruct_fx( hCPE, x_fx, synth_fx, fUseTns[cpe_id], 1, q_output, e_sig ); + + Scale_sig( synth_fx[0], hCPE->hCoreCoder[0]->hTcxDec->L_frameTCX, sub( e_sig[0], 15 ) ); + Scale_sig( synth_fx[1], hCPE->hCoreCoder[1]->hTcxDec->L_frameTCX, sub( e_sig[1], 15 ) ); FOR( n = 0; n < CPE_CHANNELS; n++ ) { @@ -591,14 +598,6 @@ ivas_error ivas_mct_dec_fx( hCPE->hCoreCoder[n]->hBPF->pst_mem_deemp_err_fx = extract_l( L_shr( hCPE->hCoreCoder[n]->mem_error, sub( Q16, sub( hCPE->hCoreCoder[n]->Q_syn2, 1 ) ) ) ); Scale_sig( hCPE->hCoreCoder[n]->hBPF->pst_old_syn_fx, NBPSF_PIT_MAX, sub( hCPE->hCoreCoder[n]->Q_syn2, 1 ) ); } - IF( hCPE->hCoreCoder[n]->hTcxDec ) - { - // Scale_sig(hCPE->hCoreCoder[n]->hTcxDec->synth_history_fx, NS2SA(hCPE->hCoreCoder[n]->output_Fs, PH_ECU_MEM_NS), negate(hCPE->hCoreCoder[n]->Q_syn)); - } - // IF( hCPE->hCoreCoder[n]->hHQ_core ) - //{ - // Scale_sig( hCPE->hCoreCoder[n]->hHQ_core->old_out_fx, L_FRAME48k, negate( hCPE->hCoreCoder[n]->Q_syn ) ); - // } } diff --git a/lib_dec/ivas_mdct_core_dec.c b/lib_dec/ivas_mdct_core_dec.c index ee7864a13e7153acab4a33a18ac4f573d2ab6967..bdbea22ea01cdfcd6e1783cece221c24e0cfe004 100644 --- a/lib_dec/ivas_mdct_core_dec.c +++ b/lib_dec/ivas_mdct_core_dec.c @@ -1973,7 +1973,7 @@ void ivas_mdct_core_reconstruct_fx( Word16 fUseTns[CPE_CHANNELS][NB_DIV], /* i : flage TNS enabled */ const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0)*/ Word16 q_x, - Word16 e_sig ) + Word16 e_sig[CPE_CHANNELS] ) { Word16 ch, k, bfi; Decoder_State **sts, *st; @@ -1998,7 +1998,7 @@ void ivas_mdct_core_reconstruct_fx( Word16 pitch[CPE_CHANNELS][NB_SUBFR16k]; Word16 pit_gain_fx[CPE_CHANNELS][NB_SUBFR16k]; - Word16 skip_decoding; + Word16 skip_decoding, sf; set16_fx( xn_buf_fx, 0, L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX ); @@ -2022,17 +2022,32 @@ void ivas_mdct_core_reconstruct_fx( IF( EQ_16( st->core, TCX_20_CORE ) ) { nSubframes[ch] = 1; + L_spec[ch] = st->hTcxCfg->tcx_coded_lines; + L_frame_global[ch] = st->L_frame; + L_frame_globalTCX[ch] = st->hTcxDec->L_frameTCX; + move16(); + move16(); + move16(); + move16(); } ELSE { nSubframes[ch] = NB_DIV; + L_spec[ch] = shr( st->hTcxCfg->tcx_coded_lines, 1 ); + L_frame_global[ch] = shr( st->L_frame, 1 ); + L_frame_globalTCX[ch] = shr( st->hTcxDec->L_frameTCX, 1 ); + move16(); + move16(); + move16(); + move16(); } - move16(); synth_fx = synth_buf_fx + st->hTcxDec->old_synth_len; synthFB_fx = synth_bufFB_fx + st->hTcxDec->old_synth_lenFB; - Copy_Scale_sig( st->hTcxDec->old_synth, synth_buf_fx, st->hTcxDec->old_synth_len, 0 ); - Copy_Scale_sig( st->hTcxDec->old_synthFB_fx, synth_bufFB_fx, st->hTcxDec->old_synth_lenFB, sub( q_syn, st->Q_syn ) ); + Copy( st->hTcxDec->old_synth, synth_buf_fx, st->hTcxDec->old_synth_len ); // Q = st->hTcxDec->q_old_synth + Copy_Scale_sig( st->hTcxDec->old_synthFB_fx, synth_bufFB_fx, st->hTcxDec->old_synth_lenFB, sub( st->hTcxDec->q_old_synth, st->Q_syn ) ); // Q = st->hTcxDec->q_old_synth + q_syn = st->hTcxDec->q_old_synth; + move16(); set16_fx( synth_fx, 0, L_FRAME_PLUS + M ); set16_fx( synthFB_fx, 0, L_FRAME_PLUS + M ); IF( st->core != ACELP_CORE ) @@ -2054,20 +2069,6 @@ void ivas_mdct_core_reconstruct_fx( Scale_sig( st->syn, M + 1, sub( q_win, st->Q_syn ) ); FOR( k = 0; k < nSubframes[ch]; k++ ) { - Word16 temp_e; - Word16 temp = BASOP_Util_Divide1616_Scale( st->hTcxCfg->tcx_coded_lines, nSubframes[ch], &temp_e ); - temp = shr( temp, sub( 15, temp_e ) ); - L_spec[ch] = temp; - move16(); - temp = BASOP_Util_Divide1616_Scale( st->L_frame, nSubframes[ch], &temp_e ); - temp = shr( temp, sub( 15, temp_e ) ); - L_frame_global[ch] = temp; - move16(); - temp = BASOP_Util_Divide1616_Scale( st->hTcxDec->L_frameTCX, nSubframes[ch], &temp_e ); - temp = shr( temp, sub( 15, temp_e ) ); - L_frame_globalTCX[ch] = temp; - move16(); - init_tcx_info_fx( st, L_frame_global[ch], L_frame_globalTCX[ch], k, bfi, &tcx_offset[ch], &tcx_offsetFB[ch], &L_frame[ch], &L_frameTCX[ch], &left_rect[ch], &L_spec[ch] ); @@ -2093,6 +2094,7 @@ void ivas_mdct_core_reconstruct_fx( } } + test(); IF( ( bfi == 0 ) && st->hTonalMDCTConc != NULL ) { Word16 synth_tmp[L_FRAME48k]; @@ -2101,6 +2103,11 @@ void ivas_mdct_core_reconstruct_fx( } decoder_tcx_post_ivas_fx( st, synth_fx, synthFB_fx, NULL, bfi, MCT_flag ); + sf = getScaleFactor16( synth_buf_fx, add( add( st->hTcxDec->old_synth_len, L_FRAME_PLUS ), M ) ); + if ( LT_16( sf, 2 ) ) + { + q_syn = sub( sf, 2 ); + } Scale_sig( st->hTcxDec->syn_Overl_TDACFB, L_FRAME_MAX / 2, sub( sub( -1, st->Q_syn ), q_win ) ); Scale_sig( st->hTcxDec->syn_Overl_TDAC, L_FRAME32k / 2, sub( sub( -1, st->Q_syn ), q_win ) ); Scale_sig( st->hTcxDec->old_syn_Overl, L_FRAME32k / 2, sub( sub( -1, st->Q_syn ), q_win ) ); @@ -2120,6 +2127,10 @@ void ivas_mdct_core_reconstruct_fx( ELSE /*ACELP core for ACELP-PLC */ { assert( EQ_16( st->bfi, 1 ) ); + Scale_sig( synth_buf_fx, add( add( st->hTcxDec->old_synth_len, L_FRAME_PLUS ), M ), negate( q_syn ) ); + Scale_sig( synth_bufFB_fx, add( add( st->hTcxDec->old_synth_lenFB, L_FRAME_PLUS ), M ), negate( q_syn ) ); + q_syn = 0; + move16(); /* PLC: [TCX: TD PLC] */ IF( MCT_flag != 0 ) { @@ -2188,6 +2199,10 @@ void ivas_mdct_core_reconstruct_fx( Copy( synth_buf_fx + st->L_frame, st->hTcxDec->old_synth, st->hTcxDec->old_synth_len ); Copy( st->hTcxDec->old_synthFB_fx + st->hTcxDec->L_frameTCX - NS2SA( st->output_Fs, PH_ECU_MEM_NS ), st->hTcxDec->synth_history_fx, NS2SA( st->output_Fs, PH_ECU_MEM_NS ) ); Copy( synth_bufFB_fx + st->hTcxDec->L_frameTCX, st->hTcxDec->old_synthFB_fx, st->hTcxDec->old_synth_lenFB ); + st->hTcxDec->q_old_synth = q_syn; + st->hTcxDec->q_synth_history_fx = st->hTcxDec->q_old_synth; + move16(); + move16(); Scale_sig( st->hTcxDec->old_synthFB_fx, st->hTcxDec->old_synth_lenFB, sub( st->Q_syn, q_syn ) ); IF( st->hHQ_core != NULL ) { @@ -2201,7 +2216,6 @@ void ivas_mdct_core_reconstruct_fx( /* Postfiltering */ Word16 x_fx_16[1200]; - Copy_Scale_sig_32_16( x_fx[ch][0], x_fx_16, st->L_frame, sub( 0, q_x ) ); IF( st->p_bpf_noise_buf_32 ) { Copy_Scale_sig_32_16( st->p_bpf_noise_buf_32, st->p_bpf_noise_buf, st->L_frame, -Q11 ); @@ -2215,8 +2229,9 @@ void ivas_mdct_core_reconstruct_fx( } IF( signal_outFB_fx[ch] != NULL ) { - Copy_Scale_sig( synthFB_fx, signal_outFB_fx[ch], st->hTcxDec->L_frameTCX, sub( sub( 15, e_sig ), q_syn ) ); - // Scale_sig(signal_outFB_fx[ch], st->hTcxDec->L_frameTCX, sub(sub(15, e_sig), q_syn)); + Copy( synthFB_fx, signal_outFB_fx[ch], st->hTcxDec->L_frameTCX ); + e_sig[ch] = sub( 15, q_syn ); + move16(); } /* updates */ @@ -2225,7 +2240,20 @@ void ivas_mdct_core_reconstruct_fx( st->last_coder_type = st->coder_type; move16(); - Copy_Scale_sig_16_32( x_fx_16, x_fx[ch][0], st->L_frame, q_x - 0 ); + Copy_Scale_sig_16_32( x_fx_16, x_fx[ch][0], st->L_frame, sub( q_x, q_syn ) ); + } + + IF( GT_16( e_sig[0], e_sig[1] ) ) + { + Scale_sig( signal_outFB_fx[1], hCPE->hCoreCoder[1]->hTcxDec->L_frameTCX, sub( e_sig[1], e_sig[0] ) ); + e_sig[1] = e_sig[0]; + move16(); + } + ELSE IF( LT_16( e_sig[0], e_sig[1] ) ) + { + Scale_sig( signal_outFB_fx[0], hCPE->hCoreCoder[1]->hTcxDec->L_frameTCX, sub( e_sig[0], e_sig[1] ) ); + e_sig[0] = e_sig[1]; + move16(); } /* calculate coherence of signal needed when next frame is lost */ @@ -2252,7 +2280,7 @@ void ivas_mdct_core_reconstruct_fx( nrgR_fx = W_add( nrgR_fx, L_mult0( signal_outFB_fx[1][i], signal_outFB_fx[1][i] ) ); xcorr_fx = W_add( xcorr_fx, L_mult0( signal_outFB_fx[0][i], signal_outFB_fx[1][i] ) ); } - e_nrgL = add( 33, shl( e_sig, 1 ) ); + e_nrgL = add( 31, shl( e_sig[0], 1 ) ); e_nrgR = e_nrgL; move16(); e_xcorr = e_nrgL; diff --git a/lib_dec/ivas_stereo_mdct_core_dec_fx.c b/lib_dec/ivas_stereo_mdct_core_dec_fx.c index c1c4a40b0d19fd16c7921fb37d29b7d2896e04f5..7323d051324499f674af7eaebcb911f85fb9b1a7 100644 --- a/lib_dec/ivas_stereo_mdct_core_dec_fx.c +++ b/lib_dec/ivas_stereo_mdct_core_dec_fx.c @@ -156,10 +156,11 @@ static void stereo_mdct_dec_stereo_fx( *--------------------------------------------------------------------*/ void stereo_mdct_core_dec_fx( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - Word32 *signal_out_fx[CPE_CHANNELS], /* o : synthesis @internal_FS */ - Word16 signal_outFB_fx[CPE_CHANNELS][L_FRAME48k] /* o : synthesis @output_FS */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ + Word32 *signal_out_fx[CPE_CHANNELS], /* o : synthesis @internal_FS */ + Word16 signal_outFB_fx[CPE_CHANNELS][L_FRAME48k], /* o : synthesis @output_FS */ + Word16 e_sigFB[CPE_CHANNELS] /* o : exponent of synthesis @output_FS */ ) { Word16 k, ch, nChannels; @@ -551,7 +552,7 @@ void stereo_mdct_core_dec_fx( Copy_Scale_sig_16_32( hCPE->hCoreCoder[0]->old_Aq_12_8_fx, hCPE->hCoreCoder[0]->old_Aq_12_8_fx_32, M + 1, ( 28 - norm_s( hCPE->hCoreCoder[0]->old_Aq_12_8_fx[0] - 1 ) ) ); Copy_Scale_sig_16_32( hCPE->hCoreCoder[1]->old_Aq_12_8_fx, hCPE->hCoreCoder[1]->old_Aq_12_8_fx_32, M + 1, ( 28 - norm_s( hCPE->hCoreCoder[1]->old_Aq_12_8_fx[0] - 1 ) ) ); - ivas_mdct_core_reconstruct_fx( hCPE, x_fx, signal_outFB_tmp_fx, fUseTns, 0, Q11, 17 ); + ivas_mdct_core_reconstruct_fx( hCPE, x_fx, signal_outFB_tmp_fx, fUseTns, 0, Q11, e_sigFB ); Copy32( signal_out_tmp_fx[0], signal_out_fx[0], L_FRAME48k ); Copy32( signal_out_tmp_fx[1], signal_out_fx[1], L_FRAME48k ); diff --git a/lib_dec/ivas_stereo_switching_dec.c b/lib_dec/ivas_stereo_switching_dec.c index 7fa9a1207a16ebf9a3e5ce868dced85e227da460..d1e47ea95e2c2300ad9f11cc1cbf66a33c94b0f6 100644 --- a/lib_dec/ivas_stereo_switching_dec.c +++ b/lib_dec/ivas_stereo_switching_dec.c @@ -3302,6 +3302,9 @@ void stereo_switching_dec( Copy32( sts[0]->hTcxDec->old_syn_Overl_32, sts[1]->hTcxDec->old_syn_Overl_32, 256 ); // 16 bit buffer Copy( sts[0]->hHQ_core->old_out_fx, sts[1]->hHQ_core->old_out_fx, L_FRAME48k ); + + sts[1]->hHQ_core->Q_old_wtda = sts[0]->hHQ_core->Q_old_wtda; + move16(); Copy( sts[0]->delay_buf_out_fx, sts[1]->delay_buf_out_fx, HQ_DELTA_MAX * HQ_DELAY_COMP ); Copy( sts[0]->hTcxDec->old_syn_Overl, sts[1]->hTcxDec->old_syn_Overl, 256 ); } diff --git a/lib_dec/stat_dec.h b/lib_dec/stat_dec.h index 876e56a1eb7c0da2d406aa3c5181111306953451..a11047966353e43cf9553bd75b21d76d0e524805 100644 --- a/lib_dec/stat_dec.h +++ b/lib_dec/stat_dec.h @@ -684,6 +684,7 @@ typedef struct tcx_dec_structure float old_synth_float[OLD_SYNTH_INTERNAL_DEC]; /* synthesis memory */ #endif Word16 old_synth[OLD_SYNTH_INTERNAL_DEC]; /* synthesis memory */ + Word16 q_old_synth; #ifndef IVAS_FLOAT_FIXED float synth_history[L_PROT48k + L_FRAME_MAX]; /* unified synthesis memory */ #endif