diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index d00a9fe805360b05af08f671c4dab79b82961d50..0cc6f182828fe16075e0055291867e5c50e1dc3d 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -4066,15 +4066,15 @@ void ivas_jbm_dec_copy_tc_no_tsm_fx( &cldfb_real_buffer_fx[slot_idx * num_freq_bands * n_ch_cldfb + cldfb_ch * num_freq_bands], &cldfb_imag_buffer_fx[slot_idx * num_freq_bands * n_ch_cldfb + cldfb_ch * num_freq_bands], num_freq_bands, st_ivas->cldfbAnaDec[cldfb_ch], &Q_tc ); - IF( EQ_16( (Word16) st_ivas->ivas_format, (Word16) MC_FORMAT ) ) - { - st_ivas->hParamMC->Cldfb_RealBuffer_tc_e = sub( 31, Q_tc ); - st_ivas->hParamMC->Cldfb_ImagBuffer_tc_e = sub( 31, Q_tc ); - move16(); - move16(); - } } } + IF( EQ_16( (Word16) st_ivas->ivas_format, (Word16) MC_FORMAT ) ) + { + st_ivas->hParamMC->Cldfb_RealBuffer_tc_e = 25; // 31-Q_tc = 31-(11-5) + st_ivas->hParamMC->Cldfb_ImagBuffer_tc_e = 25; // 31-Q_tc = 31-(11-5) + move16(); + move16(); + } } hTcBuffer->n_samples_rendered = 0; move16(); diff --git a/lib_dec/ivas_mc_param_dec_fx.c b/lib_dec/ivas_mc_param_dec_fx.c index 71c1b39fc937c1a21c3b08611e232c37dff63b28..e20610dab0cfc82154ea042c25c09e6604105ea9 100644 --- a/lib_dec/ivas_mc_param_dec_fx.c +++ b/lib_dec/ivas_mc_param_dec_fx.c @@ -528,12 +528,15 @@ ivas_error ivas_param_mc_dec_open_fx( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC JBM\n" ) ); } set32_fx( hParamMC->Cldfb_RealBuffer_tc_fx, 0, cldfb_buf_size ); + hParamMC->Cldfb_RealBuffer_tc_e = 25; // Q6 , Initialised with Q6 to match non jbm and jbm cases + move16(); IF( ( hParamMC->Cldfb_ImagBuffer_tc_fx = (Word32 *) malloc( cldfb_buf_size * sizeof( Word32 ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC JBM\n" ) ); } set32_fx( hParamMC->Cldfb_ImagBuffer_tc_fx, 0, cldfb_buf_size ); - + hParamMC->Cldfb_ImagBuffer_tc_e = 25; // Q6 , Initialised with Q6 to match non jbm and jbm cases + move16(); hParamMC->sz = imult1616( imult1616( n_cldfb_slots, nchan_transport ), hParamMC->num_freq_bands ); move16(); diff --git a/lib_dec/jbm_pcmdsp_apa_fx.c b/lib_dec/jbm_pcmdsp_apa_fx.c index e2528e619eb9ab631ad0ced53399220cba4a2702..0321a6495e844d29287aad94af717284417e336c 100644 --- a/lib_dec/jbm_pcmdsp_apa_fx.c +++ b/lib_dec/jbm_pcmdsp_apa_fx.c @@ -964,70 +964,78 @@ UWord8 apa_exec_ivas_fx( { Word16 a_tmp[APA_BUF]; Word16 *buf_out_ptr = &( ps->buf_out_fx[ps->l_buf_out - ps->l_frm] ); - Word16 *frm_in_ptr = &( frm_in[ps->l_frm] ); Q_a_out = s_min( Q_a_out, ps->Q_buf_out ); - FOR( i = 0; i < ps->num_channels * APA_BUF_PER_CHANNEL; i++ ) - { - a_tmp[i] = extract_h( L_shl( a_in[i], add( Q_a_out, Q5 ) ) ); // Q_a_out - move16(); - } Scale_sig( ps->buf_out_fx, ps->buf_out_capacity, sub( Q_a_out, ps->Q_buf_out ) ); // Q_buf_out -> Q_a_out - - /* fill input frame */ - /* 1st input frame: previous output samples */ - FOR( i = 0; i < ps->l_frm; i++ ) - { - frm_in[i] = buf_out_ptr[i]; - move16(); - } - /* 2nd input frame: new input samples */ - FOR( i = 0; i < ps->l_frm; i++ ) - { - frm_in_ptr[i] = a_tmp[i]; - move16(); - } - /* no scaling */ IF( EQ_32( ps->scale, 100 ) ) { - copy_frm_fx( ps, frm_in, a_tmp, &l_frm_out ); - } - /* shrink */ - ELSE IF( LT_32( ps->scale, 100 ) ) - { - shrink_frm_ivas_fx( ps, frm_in, maxScaling, a_tmp, Q_a_out, &l_frm_out ); + FOR( i = 0; i < ps->num_channels * APA_BUF_PER_CHANNEL; i++ ) + { + a_out[i] = a_in[i]; // Q11 + move32(); + } + l_frm_out = ps->l_frm; + move16(); } - /* extend */ ELSE { - extend_frm_ivas_fx( ps, frm_in, a_tmp, Q_a_out, &l_frm_out ); - } - /* control the amount/frequency of scaling */ - IF( NE_32( l_frm_out, ps->l_frm ) ) - { - test(); - IF( ( maxScaling != 0 ) && - GT_32( abs_s( extract_l( L_sub( ps->l_frm, l_frm_out ) ) ), maxScaling ) ) + Word16 *frm_in_ptr = &( frm_in[ps->l_frm] ); + + FOR( i = 0; i < ps->num_channels * APA_BUF_PER_CHANNEL; i++ ) { - /* maxScaling exceeded -> discard scaled frame */ - copy_frm_fx( ps, frm_in, a_tmp, &l_frm_out ); + a_tmp[i] = extract_h( L_shl( a_in[i], add( Q_a_out, Q5 ) ) ); // Q_a_out + move16(); } - ELSE IF( GT_32( L_abs( l_frm_out_target ), ps->l_frm ) ) /* ignore small difference */ + /* fill input frame */ + /* 1st input frame: previous output samples */ + FOR( i = 0; i < ps->l_frm; i++ ) { - dl_copied = L_sub( l_frm_out_target, ps->l_frm ); - dl_scaled = L_sub( l_frm_out_target, l_frm_out ); - /* discard scaled frame if copied frame is closer to target length */ - IF( LT_32( L_abs( dl_copied ), L_abs( dl_scaled ) ) ) + frm_in[i] = buf_out_ptr[i]; + move16(); + } + /* 2nd input frame: new input samples */ + FOR( i = 0; i < ps->l_frm; i++ ) + { + frm_in_ptr[i] = a_tmp[i]; + move16(); + } + /* shrink */ + IF( LT_32( ps->scale, 100 ) ) + { + shrink_frm_ivas_fx( ps, frm_in, maxScaling, a_tmp, Q_a_out, &l_frm_out ); + } + /* extend */ + ELSE + { + extend_frm_ivas_fx( ps, frm_in, a_tmp, Q_a_out, &l_frm_out ); + } + /* control the amount/frequency of scaling */ + IF( NE_32( l_frm_out, ps->l_frm ) ) + { + test(); + IF( ( maxScaling != 0 ) && + GT_32( abs_s( extract_l( L_sub( ps->l_frm, l_frm_out ) ) ), maxScaling ) ) { + /* maxScaling exceeded -> discard scaled frame */ copy_frm_fx( ps, frm_in, a_tmp, &l_frm_out ); } + ELSE IF( GT_32( L_abs( l_frm_out_target ), ps->l_frm ) ) /* ignore small difference */ + { + dl_copied = L_sub( l_frm_out_target, ps->l_frm ); + dl_scaled = L_sub( l_frm_out_target, l_frm_out ); + /* discard scaled frame if copied frame is closer to target length */ + IF( LT_32( L_abs( dl_copied ), L_abs( dl_scaled ) ) ) + { + copy_frm_fx( ps, frm_in, a_tmp, &l_frm_out ); + } + } } - } - FOR( i = 0; i < ps->num_channels * APA_BUF_PER_CHANNEL; i++ ) - { - a_out[i] = L_shl( a_tmp[i], sub( Q11, Q_a_out ) ); // Q0 -> Q11 - move32(); + FOR( i = 0; i < ps->num_channels * APA_BUF_PER_CHANNEL; i++ ) + { + a_out[i] = L_shl( a_tmp[i], sub( Q11, Q_a_out ) ); // Q0 -> Q11 + move32(); + } } } @@ -1532,7 +1540,6 @@ static bool copy_frm_fx( return 0; } - /* ******************************************************************************** *