diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index b8469c0f16e5b1861da5a2320f7221b6f9588979..b5522fb5d0c7ce7a7ff43d6ca54f30b20c957808 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -4763,6 +4763,18 @@ Word16 matrix_product_fx( Word32 *Z_fx /* o : resulting matrix after the matrix multiplication */ ); +Word16 matrix_product_q30_fx( + const Word32 *X_fx, /* i : left hand matrix */ + const Word16 rowsX, /* i : number of rows of the left hand matrix */ + const Word16 colsX, /* i : number of columns of the left hand matrix */ + const Word16 transpX, /* i : flag indicating the transposition of the left hand matrix prior to the multiplication */ + const Word32 *Y_fx, /* i : right hand matrix */ + const Word16 rowsY, /* i : number of rows of the right hand matrix */ + const Word16 colsY, /* i : number of columns of the right hand matrix */ + const Word16 transpY, /* i : flag indicating the transposition of the right hand matrix prior to the multiplication */ + Word32 *Z_fx /* o : resulting matrix after the matrix multiplication */ +); + Word16 matrix_product_mant_exp( const Word32 *X_fx, /* i : left hand matrix */ const Word16 *X_e, /* i : left hand matrix */ diff --git a/lib_com/ivas_stereo_td_bit_alloc.c b/lib_com/ivas_stereo_td_bit_alloc.c index 3f648bee3f93f47e5798f07b68090b98ed2f4347..84aaff86c3073eb7dc011601e934b2b83294ad6f 100644 --- a/lib_com/ivas_stereo_td_bit_alloc.c +++ b/lib_com/ivas_stereo_td_bit_alloc.c @@ -509,7 +509,7 @@ void tdm_bit_alloc( IF( coder_type == INACTIVE ) { Word32 res_fix = 0; - res_fix = Mpy_32_32(644245094, ( element_brate_wo_meta - 500 ) ); + res_fix = Mpy_32_32(644245095, ( element_brate_wo_meta - 500 ) ); res_fix = ( ( res_fix / 100 ) * 100 ); *total_brate_sec = max( *total_brate_sec, res_fix ); diff --git a/lib_com/ivas_tools.c b/lib_com/ivas_tools.c index 9d5dd441921dcf049fdbc61a79285077380aa81f..49b1fea1d0f90802048af53fad2fd835040665cb 100644 --- a/lib_com/ivas_tools.c +++ b/lib_com/ivas_tools.c @@ -1354,6 +1354,127 @@ Word16 matrix_product_fx( return EXIT_SUCCESS; } +Word16 matrix_product_q30_fx( + const Word32 *X_fx, /* i : left hand matrix */ + const Word16 rowsX, /* i : number of rows of the left hand matrix */ + const Word16 colsX, /* i : number of columns of the left hand matrix */ + const Word16 transpX, /* i : flag indicating the transposition of the left hand matrix prior to the multiplication */ + const Word32 *Y_fx, /* i : right hand matrix */ + const Word16 rowsY, /* i : number of rows of the right hand matrix */ + const Word16 colsY, /* i : number of columns of the right hand matrix */ + const Word16 transpY, /* i : flag indicating the transposition of the right hand matrix prior to the multiplication */ + Word32 *Z_fx /* o : resulting matrix after the matrix multiplication */ +) +{ + Word16 i, j, k; + Word32 *Zp_fx = Z_fx; + Word64 W_tmp; + + /* Processing */ + test(); + test(); + test(); + IF( EQ_16( transpX, 1 ) && EQ_16( transpY, 0 ) ) /* We use X transpose */ + { + IF( NE_16( rowsX, rowsY ) ) + { + return EXIT_FAILURE; + } + FOR( j = 0; j < colsY; ++j ) + { + FOR( i = 0; i < colsX; ++i ) + { + //( *Zp_fx ) = 0; + W_tmp = 0; + move64(); + FOR( k = 0; k < rowsX; ++k ) + { + //( *Zp_fx ) = L_add( *Zp_fx, Mpy_32_32( X_fx[k + i * rowsX], Y_fx[k + j * rowsY] ) ); + W_tmp = W_add( W_tmp, W_mult0_32_32( X_fx[k + i * rowsX], Y_fx[k + j * rowsY] ) );//Q56 + } + W_tmp = W_shl( W_tmp, 6 ); + ( *Zp_fx ) = L_sub(W_round64_L( W_tmp ), 64); //adjusting for precision + Zp_fx++; + } + } + } + ELSE IF( EQ_16( transpX, 0 ) && EQ_16( transpY, 1 ) ) /* We use Y transpose */ + { + IF( NE_16( colsX, colsY ) ) + { + return EXIT_FAILURE; + } + FOR( j = 0; j < rowsY; ++j ) + { + FOR( i = 0; i < rowsX; ++i ) + { + //( *Zp_fx ) = 0; + W_tmp = 0; + move64(); + FOR( k = 0; k < colsX; ++k ) + { + //( *Zp_fx ) = L_add( *Zp_fx, Mpy_32_32( X_fx[i + k * rowsX], Y_fx[j + k * rowsY] ) ); + W_tmp = W_add( W_tmp, W_mult0_32_32( X_fx[i + k * rowsX], Y_fx[j + k * rowsY] ) ); // Q56 + } + W_tmp = W_shl( W_tmp, 6 ); + ( *Zp_fx ) = L_sub( W_round64_L( W_tmp ), 64 ); // adjusting for precision + Zp_fx++; + } + } + } + ELSE IF( EQ_16( transpX, 1 ) && EQ_16( transpY, 1 ) ) /* We use both transpose */ + { + IF( NE_16( rowsX, colsY ) ) + { + return EXIT_FAILURE; + } + FOR( j = 0; j < rowsY; ++j ) + { + FOR( i = 0; i < colsX; ++i ) + { + //( *Zp_fx ) = 0; + W_tmp = 0; + move64(); + FOR( k = 0; k < colsX; ++k ) + { + //( *Zp_fx ) = L_add( *Zp_fx, Mpy_32_32( X_fx[k + i * rowsX], Y_fx[j + k * rowsY] ) ); + W_tmp = W_add( W_tmp, W_mult0_32_32( X_fx[k + i * rowsX], Y_fx[j + k * rowsY] ) ); // Q56 + } + + W_tmp = W_shl( W_tmp, 6 ); + ( *Zp_fx ) = L_sub( W_round64_L( W_tmp ), 64 ); // adjusting for precision + Zp_fx++; + } + } + } + ELSE /* Regular case */ + { + IF( NE_16( colsX, rowsY ) ) + { + return EXIT_FAILURE; + } + + FOR( j = 0; j < colsY; ++j ) + { + FOR( i = 0; i < rowsX; ++i ) + { + //( *Zp_fx ) = 0; + W_tmp = 0; + move64(); + FOR( k = 0; k < colsX; ++k ) + { + //( *Zp_fx ) = L_add( *Zp_fx, Mpy_32_32( X_fx[i + k * rowsX], Y_fx[k + j * rowsY] ) ); + W_tmp = W_add( W_tmp, W_mult0_32_32( X_fx[i + k * rowsX], Y_fx[k + j * rowsY] ) ); // Q56 + } + W_tmp = W_shl( W_tmp, 6 ); + ( *Zp_fx ) = L_sub( W_round64_L( W_tmp ), 64 ); // adjusting for precision + Zp_fx++; + } + } + } + + return EXIT_SUCCESS; +} /*takes input matrices in mantissa and exponent forms*/ Word16 matrix_product_mant_exp( const Word32 *X_fx, /* i : left hand matrix */ diff --git a/lib_com/prot_fx2.h b/lib_com/prot_fx2.h index 2c8c19d5844f3744e7cb0d13cfe00c8b1a9c3bc0..100904a3f53cecd67a4605542a5e9a5faeef79c2 100644 --- a/lib_com/prot_fx2.h +++ b/lib_com/prot_fx2.h @@ -9287,7 +9287,8 @@ void IMDCT_ivas_fx( const Word16 FB_flag, Decoder_State *st, const Word16 fullbandScale, - Word16 *acelp_zir_fx); + Word16 *acelp_zir_fx, + Word16 q_win); void v_mult16_fixed( const Word16 x1[], /* i : Input vector 1 */ diff --git a/lib_dec/acelp_core_dec_ivas_fx.c b/lib_dec/acelp_core_dec_ivas_fx.c index 4b1940cff18984207d658e9c6b987c5985a0488f..b7de77632453ae31e0c0b518b264714b189fb84a 100644 --- a/lib_dec/acelp_core_dec_ivas_fx.c +++ b/lib_dec/acelp_core_dec_ivas_fx.c @@ -1869,9 +1869,9 @@ ivas_error acelp_core_dec_ivas_fx( psyn_fx, synth_fx16, st->Q_exc, st->Q_syn2, st->hBWE_zero->delay_syn_hf_fx, &tmp_exp, st->hBWE_zero->mem_hp_interp_fx, st->extl, st->CNG_mode, st->element_mode ); #ifdef MSAN_FIX - Copy_Scale_sig_16_32(synth_fx16, synth_fx, 0, output_frame); + Copy_Scale_sig_16_32(synth_fx16, synth_fx, output_frame, 0); #else - Copy_Scale_sig_16_32(synth_fx16, synth_fx, 0, L_FRAME48k); + Copy_Scale_sig_16_32(synth_fx16, synth_fx, L_FRAME48k, 0); #endif IF( st->hBWE_FD != NULL ) diff --git a/lib_dec/dec_tcx.c b/lib_dec/dec_tcx.c index 92c25ad45a089718e6e62bb90e16004875aa5ed5..dabf190f2c406dd4f953bc2d440b3339cb9e88ab 100644 --- a/lib_dec/dec_tcx.c +++ b/lib_dec/dec_tcx.c @@ -2071,7 +2071,7 @@ void decoder_tcx_imdct_fx( IMDCT_ivas_fx( xn_bufFB_fx, q_x, hTcxDec->syn_Overl, hTcxDec->syn_Overl_TDAC, xn_buf_fx, hTcxCfg->tcx_aldo_window_1, hTcxCfg->tcx_aldo_window_1_trunc, hTcxCfg->tcx_aldo_window_2, hTcxCfg->tcx_mdct_window_half, hTcxCfg->tcx_mdct_window_minimum, hTcxCfg->tcx_mdct_window_trans, hTcxCfg->tcx_mdct_window_half_length, hTcxCfg->tcx_mdct_window_min_length, index, - kernelType, left_rect, tcx_offset, overlap, L_frame, L_frameTCX, shr(s_max( L_frameTCX, L_spec ), 1), L_frame_glob, frame_cnt, bfi, st->hHQ_core->old_out_LB_fx, 0, st, 0, acelp_zir_fx ); + kernelType, left_rect, tcx_offset, overlap, L_frame, L_frameTCX, shr(s_max( L_frameTCX, L_spec ), 1), L_frame_glob, frame_cnt, bfi, st->hHQ_core->old_out_LB_fx, 0, st, 0, acelp_zir_fx, q_win ); } /* Generate additional comfort noise to mask potential coding artefacts */ @@ -2088,7 +2088,7 @@ void decoder_tcx_imdct_fx( mvl2l( x_fx, xn_bufFB_fx, s_max( L_spec, s_max( L_frame, L_frameTCX ) ) ); IMDCT_ivas_fx( xn_bufFB_fx, q_x, hTcxDec->syn_Overl, hTcxDec->syn_Overl_TDAC, xn_buf_fx, hTcxCfg->tcx_aldo_window_1, hTcxCfg->tcx_aldo_window_1_trunc, hTcxCfg->tcx_aldo_window_2, hTcxCfg->tcx_mdct_window_half, hTcxCfg->tcx_mdct_window_minimum, hTcxCfg->tcx_mdct_window_trans, hTcxCfg->tcx_mdct_window_half_length, hTcxCfg->tcx_mdct_window_min_length, index, - kernelType, left_rect, tcx_offset, overlap, L_frame, L_frameTCX, shr(s_max( L_frameTCX, L_spec ), 1), L_frame_glob, frame_cnt, bfi, st->hHQ_core->old_out_LB_fx, 0, st, 0, acelp_zir_fx ); + kernelType, left_rect, tcx_offset, overlap, L_frame, L_frameTCX, shr(s_max( L_frameTCX, L_spec ), 1), L_frame_glob, frame_cnt, bfi, st->hHQ_core->old_out_LB_fx, 0, st, 0, acelp_zir_fx, q_win ); } FOR(Word16 ind = 0; ind < L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX; ind++) { @@ -2098,13 +2098,13 @@ void decoder_tcx_imdct_fx( { IMDCT_ivas_fx( x_tmp_fx, q_x, hTcxDec->syn_OverlFB, hTcxDec->syn_Overl_TDACFB, xn_bufFB_fx_16, hTcxCfg->tcx_aldo_window_1_FB, hTcxCfg->tcx_aldo_window_1_FB_trunc, hTcxCfg->tcx_aldo_window_2_FB, hTcxCfg->tcx_mdct_window_halfFB, hTcxCfg->tcx_mdct_window_minimumFB, hTcxCfg->tcx_mdct_window_transFB, hTcxCfg->tcx_mdct_window_half_lengthFB, hTcxCfg->tcx_mdct_window_min_lengthFB, index, - kernelType, left_rect, tcx_offsetFB, overlapFB, L_frameTCX, L_frameTCX, max( L_frameTCX, L_spec ) >> 1, L_frameTCX_glob, frame_cnt, bfi, st->hHQ_core->old_out_fx, 1, st, FSCALE_DENOM * L_frameTCX_glob / L_frame_glob, acelp_zir_fx ); + kernelType, left_rect, tcx_offsetFB, overlapFB, L_frameTCX, L_frameTCX, max( L_frameTCX, L_spec ) >> 1, L_frameTCX_glob, frame_cnt, bfi, st->hHQ_core->old_out_fx, 1, st, FSCALE_DENOM * L_frameTCX_glob / L_frame_glob, acelp_zir_fx, q_win ); } ELSE { IMDCT_ivas_fx( x_fx, q_x, hTcxDec->syn_OverlFB, hTcxDec->syn_Overl_TDACFB, xn_bufFB_fx_16, hTcxCfg->tcx_aldo_window_1_FB, hTcxCfg->tcx_aldo_window_1_FB_trunc, hTcxCfg->tcx_aldo_window_2_FB, hTcxCfg->tcx_mdct_window_halfFB, hTcxCfg->tcx_mdct_window_minimumFB, hTcxCfg->tcx_mdct_window_transFB, hTcxCfg->tcx_mdct_window_half_lengthFB, hTcxCfg->tcx_mdct_window_min_lengthFB, index, - kernelType, left_rect, tcx_offsetFB, overlapFB, L_frameTCX, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frameTCX_glob, frame_cnt, bfi, st->hHQ_core->old_out_fx, 1, st, FSCALE_DENOM * L_frameTCX_glob / L_frame_glob, acelp_zir_fx ); + kernelType, left_rect, tcx_offsetFB, overlapFB, L_frameTCX, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frameTCX_glob, frame_cnt, bfi, st->hHQ_core->old_out_fx, 1, st, FSCALE_DENOM * L_frameTCX_glob / L_frame_glob, acelp_zir_fx, q_win ); } FOR(Word16 ind = 0; ind < L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX; ind++) { xn_bufFB_fx[ind] = L_shl(xn_bufFB_fx_16[ind], (q_x - q_win)); diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index 9544cd1865d902e0ebfed4c3d71a52186d2eed63..a841e75e96d13ce97abbac41f387db95834e0230 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -2805,15 +2805,15 @@ void IMDCT_ivas_fx( const Word16 FB_flag, Decoder_State *st, const Word16 fullbandScale, - Word16 *acelp_zir_fx) //Q(-2) + Word16 *acelp_zir_fx, + Word16 q_win) //Q(-2) { int16_t i, nz, aldo, w, L_win, L_ola; Word16 win_fx[(L_FRAME_PLUS + L_MDCT_OVLP_MAX) / 2]; TCX_DEC_HANDLE hTcxDec = st->hTcxDec; TCX_CONFIG_HANDLE hTcxCfg = st->hTcxCfg; - Word16 q_win, x_e_hdrm; - x_e_hdrm = 3; - q_win = q_x + x_e_hdrm - 16; + Word16 x_e_hdrm; + x_e_hdrm = add(q_win, sub(Q16, q_x)); aldo = 0; @@ -3601,7 +3601,7 @@ void decoder_tcx_ivas_fx( Word16 xn_buf_fx[L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX]; /* Q14 */ Word16 shift; Word16 x_len; - Word16 q_x = Q11, q_win = -2; + Word16 q_x = Q11; set32_fx( x_fx, 0, N_MAX ); set16_fx( gainlpc2_fx, 0, FDNS_NPTS ); @@ -3646,7 +3646,7 @@ void decoder_tcx_ivas_fx( decoder_tcx_tns_fx( st, L_frame_glob, L_spec, L_frame, L_frameTCX, x_fx, fUseTns, &tnsData, bfi, frame_cnt, 0 ); Scale_sig32( x_fx, N_MAX, sub( x_e, 20 ) ); // Scaling x_fx to Q11 - Scale_sig( xn_buf_fx, L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX, -16 ); // Scaling xn_buf_fx to Q-2 + Scale_sig( xn_buf_fx, L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX, st->Q_syn - 14 ); // Scaling xn_buf_fx to Q_syn x_e = sub( 31, 11 ); move16(); @@ -3657,30 +3657,23 @@ void decoder_tcx_ivas_fx( } /* Scaling down buffers for decoder_tcx_imdct_fx*/ - Scale_sig( st->hTcxDec->syn_Overl, 320, -( st->Q_syn + 1 + 2 ) ); // Scaling to Q-2 - Scale_sig( st->hTcxDec->syn_Overl_TDAC, 320, -( st->Q_syn + 2 ) ); // Scaling to Q-2 - Scale_sig( st->hTcxDec->syn_Overl_TDACFB, 480, -( st->Q_syn + 2 ) ); // Scaling to Q-2 - Scale_sig( st->hTcxDec->syn_OverlFB, 480, -( st->Q_syn + 2 ) ); // Scaling to Q-2 - Scale_sig( st->hTcxDec->old_syn_Overl, 320, -( st->Q_syn + 1 + 0 ) ); // Scaling to Q-2 - Scale_sig( st->hHQ_core->old_out_LB_fx, 640, -( st->Q_syn + 2 ) ); // Scaling to Q-2 - Scale_sig( st->hHQ_core->old_out_fx, 960, -( st->Q_syn + 2 ) ); // Scaling to Q-2 - + Scale_sig( st->hTcxDec->syn_Overl, 320, -1 ); // Scaling to Q_syn + Scale_sig( st->hTcxDec->old_syn_Overl, 320, 1 ); // Scaling to Q_syn Copy_Scale_sig_16_32_no_sat( st->old_Aq_12_8_fx, st->old_Aq_12_8_fx_32, M + 1, ( 28 - ( 15 - norm_s( st->old_Aq_12_8_fx[0] - 1 ) ) ) ); - Scale_sig( synth_fx, L_frame_glob, -2 ); // Scaling to Q-2 - Scale_sig( synthFB_fx, L_frameTCX_glob, -2 ); // Scaling to Q-2 + Scale_sig( synth_fx, L_frame_glob, st->Q_syn ); // Scaling to Q_syn + Scale_sig( synthFB_fx, L_frameTCX_glob, st->Q_syn ); // Scaling to Q_syn - decoder_tcx_imdct_fx( st, L_frame_glob, L_frameTCX_glob, L_spec, tcx_offset, tcx_offsetFB, L_frame, L_frameTCX, left_rect, &x_fx[0], q_x, xn_buf_fx, q_win, MDCT_IV, + decoder_tcx_imdct_fx( st, L_frame_glob, L_frameTCX_glob, L_spec, tcx_offset, tcx_offsetFB, L_frame, L_frameTCX, left_rect, &x_fx[0], q_x, xn_buf_fx, st->Q_syn, MDCT_IV, fUseTns, &synth_fx[0], &synthFB_fx[0], bfi, frame_cnt, sba_dirac_stereo_flag ); /* Scaling up again */ - Scale_sig( synth_fx, L_frame_glob, 2 ); - Scale_sig( synthFB_fx, L_frameTCX_glob, 2 ); - Scale_sig( st->hTcxDec->syn_OverlFB, L_FRAME_MAX / 2, ( st->Q_syn + 2 ) ); - Scale_sig( st->hTcxDec->syn_Overl, L_FRAME32k / 2, ( st->Q_syn + 1 + 2 ) ); - Scale_sig( st->hHQ_core->old_out_LB_fx, L_FRAME32k, ( st->hHQ_core->Q_old_wtda + 2 ) ); - Scale_sig( st->hHQ_core->old_out_fx, L_FRAME48k, ( st->hHQ_core->Q_old_wtda + 2 ) ); - //Scale_sig( st->hTcxDec->old_syn_Overl, 320, ( st->Q_syn + 1 + 2 ) ); // Scaling to Q-2 + Scale_sig( synth_fx, L_frame_glob, negate(st->Q_syn) ); + Scale_sig( synthFB_fx, L_frameTCX_glob, negate(st->Q_syn) ); + Scale_sig( st->hTcxDec->syn_Overl, L_FRAME32k / 2, 1 ); + Scale_sig( st->hHQ_core->old_out_LB_fx, L_FRAME32k, ( st->hHQ_core->Q_old_wtda - st->Q_syn ) ); + Scale_sig( st->hHQ_core->old_out_fx, L_FRAME48k, ( st->hHQ_core->Q_old_wtda - st->Q_syn ) ); + Scale_sig( st->hTcxDec->old_syn_Overl, 320, ( -2 + st->Q_syn ) ); // Scaling to Q-2 } #endif diff --git a/lib_dec/ivas_qmetadata_dec.c b/lib_dec/ivas_qmetadata_dec.c index f7094db3daa347ff0644106c60351c4167fc985f..fc870092a8ca4562c52eb86382adce3b6672bca3 100644 --- a/lib_dec/ivas_qmetadata_dec.c +++ b/lib_dec/ivas_qmetadata_dec.c @@ -8562,28 +8562,28 @@ void ivas_omasa_decode_masa_to_total_fx( SWITCH( len_stream ) { case 4: - matrix_product_fx( dct4_fx, nblocks, nblocks, 1, q_dct_data_fx, nblocks, 1, 0, dct_data_tmp_fx ); + matrix_product_q30_fx( dct4_fx, nblocks, nblocks, 1, q_dct_data_fx, nblocks, 1, 0, dct_data_tmp_fx ); Copy32( dct_data_tmp_fx, q_dct_data_fx, nblocks ); BREAK; case 5: - matrix_product_fx( dct5_fx, nbands, nbands, 1, q_dct_data_fx, nbands, 1, 0, dct_data_tmp_fx ); + matrix_product_q30_fx( dct5_fx, nbands, nbands, 1, q_dct_data_fx, nbands, 1, 0, dct_data_tmp_fx ); Copy32( dct_data_tmp_fx, q_dct_data_fx, nbands ); BREAK; case 8: - matrix_product_fx( dct8_fx, nbands, nbands, 1, q_dct_data_fx, nbands, 1, 0, dct_data_tmp_fx ); + matrix_product_q30_fx( dct8_fx, nbands, nbands, 1, q_dct_data_fx, nbands, 1, 0, dct_data_tmp_fx ); Copy32( dct_data_tmp_fx, q_dct_data_fx, nbands ); BREAK; case 12: - matrix_product_fx( dct12_fx, nbands, nbands, 1, q_dct_data_fx, nbands, 1, 0, dct_data_tmp_fx ); + matrix_product_q30_fx( dct12_fx, nbands, nbands, 1, q_dct_data_fx, nbands, 1, 0, dct_data_tmp_fx ); Copy32( dct_data_tmp_fx, q_dct_data_fx, nbands ); BREAK; case 20: matrix_product_fx( dct5_fx, nbands, nbands, 1, q_dct_data_fx, nbands, nblocks, 0, dct_data_tmp_fx ); - matrix_product_fx( dct_data_tmp_fx, nbands, nblocks, 0, dct4_fx, nblocks, nblocks, 0, q_dct_data_fx ); /* reuse of variable*/ + matrix_product_q30_fx( dct_data_tmp_fx, nbands, nblocks, 0, dct4_fx, nblocks, nblocks, 0, q_dct_data_fx ); /* reuse of variable*/ BREAK; case 32: matrix_product_fx( dct8_fx, nbands, nbands, 1, q_dct_data_fx, nbands, nblocks, 0, dct_data_tmp_fx ); - matrix_product_fx( dct_data_tmp_fx, nbands, nblocks, 0, dct4_fx, nblocks, nblocks, 0, q_dct_data_fx ); + matrix_product_q30_fx( dct_data_tmp_fx, nbands, nblocks, 0, dct4_fx, nblocks, nblocks, 0, q_dct_data_fx ); BREAK; default: printf( "Incorrect number of coefficients for OMASA.\n" ); @@ -8595,7 +8595,9 @@ void ivas_omasa_decode_masa_to_total_fx( { FOR( j = 0; j < nbands; j++ ) { - masa_to_total_energy_ratio_fx[i][j] = L_max( 0, L_shr( L_shl_sat( q_dct_data_fx[k], 31 - 25 ), 1 ) ); // Q30 + masa_to_total_energy_ratio_fx[i][j] = L_max( 0, q_dct_data_fx[k] ); // Q30 + move32(); + masa_to_total_energy_ratio_fx[i][j] = L_min( ONE_IN_Q30, masa_to_total_energy_ratio_fx[i][j] ); move32(); k++; } diff --git a/lib_dec/ivas_stereo_mdct_core_dec_fx.c b/lib_dec/ivas_stereo_mdct_core_dec_fx.c index 0da7235e9c73545d14980bfa1e93be7910bab116..09b5282330bd35823064ce7c9d3106c9e24d819b 100644 --- a/lib_dec/ivas_stereo_mdct_core_dec_fx.c +++ b/lib_dec/ivas_stereo_mdct_core_dec_fx.c @@ -997,19 +997,20 @@ static void run_min_stats_fx( /* Compute power spectrum twice if estimation will run on both channels. If only on one channel, it is computed only once (for ch == 0) and not again in the second run sive the outcome will be the same anyway */ - IF ( ( EQ_16(will_estimate_noise_on_channel[0], will_estimate_noise_on_channel[1]) ) || EQ_16(ch, 0) ) + IF( ( EQ_16( will_estimate_noise_on_channel[0], will_estimate_noise_on_channel[1] ) ) || EQ_16( ch, 0 ) ) { + Word16 tmp16 = getScaleFactor32( spec_in, L_FRAME16k ); /* calculate power spectrum from MDCT coefficients and estimated MDST coeffs */ - power_spec[0] = Mpy_32_32(L_shr(spec_in[0], 2), L_shr(spec_in[0], 2)); - power_spec[L_FRAME16k - 1] = Mpy_32_32(L_shr(spec_in[L_FRAME16k - 1], 1), L_shr(spec_in[L_FRAME16k - 1], 1)); - FOR ( Word16 i = 1; i < L_FRAME16k - 1; i++ ) + power_spec[0] = W_extract_h( W_shl( W_mult_32_32( spec_in[0], spec_in[0] ), tmp16 - 4 ) ); /* 2 * (Q31 - x_e) + tmp16 - Q4 - Q31 */ + power_spec[L_FRAME16k - 1] = W_extract_h( W_shl( W_mult_32_32( spec_in[L_FRAME16k - 1], spec_in[L_FRAME16k - 1] ), tmp16 - 4 ) ); /* 2 * (Q31 - x_e) + tmp16 - Q4 - Q31 */ + FOR( Word16 i = 1; i < L_FRAME16k - 1; i++ ) { Word32 mdst; - mdst = L_sub(L_shr(spec_in[i + 1], 2), L_shr(spec_in[i - 1], 2)); - power_spec[i] = L_add(Mpy_32_32(L_shr(spec_in[i], 2), L_shr(spec_in[i], 2)), Mpy_32_32(L_shr(mdst, 0), L_shr(mdst, 0))); + mdst = L_sub( spec_in[i + 1], spec_in[i - 1] ); /* Q31 - x_e */ + power_spec[i] = L_add( W_extract_h( W_shl( W_mult_32_32( spec_in[i], spec_in[i] ), tmp16 - 4 ) ), W_extract_h( W_shl( W_mult_32_32( mdst, mdst ), tmp16 - 4 ) ) ); /* 2 * (Q31 - x_e) + tmp16 - Q4 - Q31*/ } + power_spec_e = add( 4, shl( spec_e, 1 ) ) - tmp16; } - power_spec_e = add(4, shl(spec_e, 1)); Copy_Scale_sig32_16(power_spec, power_spec_16, L_FRAME16k, 0); diff --git a/lib_rend/ivas_objectRenderer_sources.c b/lib_rend/ivas_objectRenderer_sources.c index 747859a15f812956309f542ea6f1b6426dbcb9b2..298a45c4d33d07295a33ef35cfe7e06a098dedf8 100644 --- a/lib_rend/ivas_objectRenderer_sources.c +++ b/lib_rend/ivas_objectRenderer_sources.c @@ -625,10 +625,28 @@ void TDREND_SRC_REND_UpdateFiltersFromSpatialParams_fx( *Gain = extract_h( L_shl( Mpy_32_32( L_shl( L_mult( *SrcRend_p->SrcGain_p_fx, *SrcRend_p->DirGain_p_fx ), 1 ), L_shl( L_mult( *SrcRend_p->DistGain_p_fx, hBinRendererTd->Gain_fx ), 1 ) ), 1 ) ); /* Delta for interpolation, in case the angular step exceeds MAX_ANGULAR_STEP */ - - elev_delta = L_sub( Elev, Src_p->elev_prev_fx ); - azim_delta = L_sub( Azim, Src_p->azim_prev_fx ); - + Word32 ele_tmp = Src_p->elev_prev_fx; + IF( GT_32( ele_tmp, DEG_180_IN_Q22 ) ) + { + ele_tmp = L_sub( ele_tmp, DEG_360_IN_Q22 ); + } + ELSE IF( LT_32( ele_tmp, -DEG_180_IN_Q22 ) ) + { + ele_tmp = L_add( ele_tmp, DEG_360_IN_Q22 ); + } + elev_delta = L_sub( Elev, ele_tmp ); + + Word32 azi_tmp = Src_p->azim_prev_fx; + IF( GT_32( azi_tmp, DEG_180_IN_Q22 ) ) + { + azi_tmp = L_sub( azi_tmp, DEG_360_IN_Q22 ); + } + ELSE IF( LT_32( azi_tmp, -DEG_180_IN_Q22 ) ) + { + azi_tmp = L_add( azi_tmp, DEG_360_IN_Q22 ); + } + azim_delta = L_sub( Azim, azi_tmp ); + Src_p->elev_prev_fx = Elev; move32(); Src_p->azim_prev_fx = Azim;