Commit ff8313e0 authored by Sandesh Venkatesh's avatar Sandesh Venkatesh
Browse files

Merge branch 'float_restore_stat_dec_dirac_dec_cleanup' into 'main'

Restore float funcs, dirac dec and stat_dec struct cleanup.

See merge request !283
parents f2de97c0 d2b9cbd3
Loading
Loading
Loading
Loading
Loading
+16 −13
Original line number Diff line number Diff line
@@ -951,7 +951,7 @@ static void sp2cart_fx(
    q[3] = mult( getSinWord16( ph3 ), s1s2 ); // q15
    q[2] = mult( getCosWord16( ph3 ), s1s2 ); // q15
    q[1] = mult( getCosWord16( ph2 ), s1 );   // q15
    q[0] = getCosWord16( ph1 );               // q14
    q[0] = shl_sat(getCosWord16( ph1 ), 1);   //q15

    return;
}
@@ -975,12 +975,12 @@ static Word16 calc_n2_fx(
    const Word16 ph1 )
{
    Word16 n2;
    Word16 temp = mult( 23040, getSinWord16( ph1 ) ); // q8
    Word32 temp = L_mult( 23040, getSinWord16( ph1 ) ); // q8
    n2 = round_fx( temp );

    n2 = shr(n2, 7);
    IF( EQ_16( s_and( n2, 1 ), 0 ) )
    {
        n2 = add( n2, ONE_IN_Q8 );
        n2 = add( n2, 1 );
    }

    return n2;
@@ -1015,19 +1015,21 @@ static Word16 calc_n3_fx(
    const Word16 ph2 )
{
    Word16 n3;
    Word16 temp1 = mult( 23040, getSinWord16( ph1 ) );   // q7 + q15 - q15
    n3 = round_fx( mult( temp1, getSinWord16( ph2 ) ) ); // q7 + q15 - q15
    Word16 temp1 = mult( getSinWord16( ph2 ), getSinWord16( ph1 ) );   // q7 + q15 - q15
    n3 = round_fx( L_mult( temp1, getSinWord16( ph2 ) ) ); // q7 + q15 - q15

    n3 = shr(n3, 8);

    IF( EQ_16( n3, 0 ) )
    {
        n3 = ONE_IN_Q7;
        n3 = 1;
        move16();
    }
    ELSE
    {
        IF( ( s_and( n3, 1 ) ) == 1 )
        {
            n3 = add( n3, ONE_IN_Q7 );
            n3 = add( n3, 1 );
        }
    }

@@ -1438,7 +1440,7 @@ void pca_dec_s3_fx(
    Word16 num_fx = 12868;

    d_fx = idiv1616( num_fx, n1 );   // Q12
    ph1_q_fx = mult( index1, d_fx ); // Q12
    ph1_q_fx = i_mult( index1, d_fx ); // Q12

    n2 = calc_n2_fx( ph1_q_fx );

@@ -1467,8 +1469,8 @@ void pca_dec_s3_fx(

        num_fx = 12868;
        move16();
        d_fx = idiv1616( num_fx, n1 );   // Q12
        ph2_q_fx = mult( index2, d_fx ); // Q12
        d_fx = idiv1616( num_fx, sub(n2, 1) );   // Q12
        ph2_q_fx = i_mult( index2, d_fx ); // Q12
    }

    j = L_sub(j, ivas_pca_offset_index2[index2 + get_pca_offset_n2_fx( index1 )]);
@@ -1486,8 +1488,9 @@ void pca_dec_s3_fx(
    {
        num_fx = 6434;
        move16();
        d_fx = idiv1616( num_fx, n3 );   // Q11
        ph3_q_fx = mult( index3, d_fx ); // Q11
        d_fx = idiv1616( num_fx, n3 );   // Q10
        ph3_q_fx = round_fx(L_mult( index3, d_fx )); // Q10
        //ph3_q_fx = shl(ph3_q_fx, 2);
    }
    sp2cart_fx( ph1_q_fx, ph2_q_fx, ph3_q_fx, q_fx );

+2 −2
Original line number Diff line number Diff line
@@ -612,11 +612,11 @@ ivas_error acelp_core_dec(
                    nb_bits = -1;
                }

                config_acelp1( DEC, st->total_brate, st->core_brate, st->core, st->extl_orig, st->extl_brate_orig, st->L_frame, st->GSC_noisy_speech, &( st->acelp_cfg ), st->next_bit_pos, st->coder_type, tc_subfr_tmp, 1, &nb_bits, unbits, st->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st->idchan, st->active_cnt, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode );
                config_acelp1_IVAS( DEC, st->total_brate, st->core_brate, st->core, st->extl_orig, st->extl_brate_orig, st->L_frame, st->GSC_noisy_speech, &( st->acelp_cfg ), st->next_bit_pos, st->coder_type, tc_subfr_tmp, 1, &nb_bits, unbits, st->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st->idchan, st->active_cnt, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode );

                if ( st->coder_type == TRANSITION && tc_subfr < L_SUBFR && st->L_frame == L_FRAME )
                {
                    config_acelp1( DEC, st->total_brate, st->core_brate, st->core, st->extl_orig, st->extl_brate_orig, st->L_frame, -1, &( st->acelp_cfg ), st->next_bit_pos, st->coder_type, tc_subfr, 2, &nb_bits, unbits, st->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st->idchan, st->active_cnt, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode );
                    config_acelp1_IVAS( DEC, st->total_brate, st->core_brate, st->core, st->extl_orig, st->extl_brate_orig, st->L_frame, -1, &( st->acelp_cfg ), st->next_bit_pos, st->coder_type, tc_subfr, 2, &nb_bits, unbits, st->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st->idchan, st->active_cnt, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode );
                }
            }

+705 −738
Original line number Diff line number Diff line
@@ -175,6 +175,7 @@ ivas_error core_switching_pre_dec_ivas_fx(
            {
                st->last_core = HQ_CORE;
                move16();

                Copy32( st->hTcxDec->FBTCXdelayBuf_32, st->prev_synth_buffer32_fx, NS2SA( st->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ) );
                //Copy_Scale_sig_32_16( st->hTcxDec->FBTCXdelayBuf_32, st->prev_synth_buffer_fx, NS2SA( st->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ), -11 ); //Q11 -> Q0
            }
@@ -933,9 +934,6 @@ ivas_error core_switching_pre_dec(
      /* Last frame was Stereo CNG and the synthesis memory is outdated -- reset */
      set_f(st->hTcxDec->old_syn_Overl_float, 0.0f, L_FRAME32k / 2);
      set_f(st->hFdCngDec->hFdCngCom->olapBufferAna_flt, 0.0f, FFTLEN);
#ifdef IVAS_FLOAT_FIXED
            set16_fx( st->hFdCngDec->hFdCngCom->olapBufferAna_fx, 0, FFTLEN );
#endif // IVAS_FLOAT_FIXED
    }

    set_f(st->agc_mem2, 0, 2);
@@ -1143,12 +1141,10 @@ ivas_error core_switching_pre_dec(
    if (st->core != AMR_WB_CORE)
    {
      configureFdCngDec(st->hFdCngDec, st->bwidth, st->rf_flag == 1 && st->total_brate == ACELP_13k20 ? ACELP_9k60 : st->total_brate, st->L_frame, st->last_L_frame, st->element_mode);
            configureFdCngDec_fx( st->hFdCngDec, st->bwidth, st->rf_flag == 1 && st->total_brate == ACELP_13k20 ? ACELP_9k60 : st->total_brate, st->L_frame, st->last_L_frame, st->element_mode );
    }
    else
    {
      configureFdCngDec(st->hFdCngDec, WB, ACELP_8k00, st->L_frame, st->last_L_frame, st->element_mode);
            configureFdCngDec_fx( st->hFdCngDec, WB, ACELP_8k00, st->L_frame, st->last_L_frame, st->element_mode );

      if (st->VAD)
      {
@@ -1160,9 +1156,6 @@ ivas_error core_switching_pre_dec(
      if (st->element_mode == IVAS_CPE_DFT || st->element_mode == IVAS_CPE_TD)
      {
        lerp_flt(st->hFdCngDec->hFdCngCom->olapBufferAna_flt + st->last_L_frame, st->hFdCngDec->hFdCngCom->olapBufferAna_flt + st->L_frame, st->L_frame, st->last_L_frame);
#ifdef IVAS_FLOAT_FIXED
                lerp( st->hFdCngDec->hFdCngCom->olapBufferAna_fx + st->last_L_frame, st->hFdCngDec->hFdCngCom->olapBufferAna_fx + st->L_frame, st->L_frame, st->last_L_frame );
#endif // IVAS_FLOAT_FIXED
      }

      lerp_flt(st->hFdCngDec->hFdCngCom->olapBufferSynth2_flt, st->hFdCngDec->hFdCngCom->olapBufferSynth2_flt, st->L_frame * 2, st->last_L_frame * 2);
@@ -1213,10 +1206,6 @@ ivas_error core_switching_post_dec(
)
{
  int16_t i, delay_comp, delta;
#ifdef IVAS_FLOAT_FIXED
    Word32 synth_fx[960];
    //Word32 output_fx[1500];
#endif
  float tmpF;
  float tmpDelta;
  float synth_subfr_out[SWITCH_MAX_GAP], synth_subfr_bwe[SWITCH_MAX_GAP];
@@ -1281,17 +1270,7 @@ ivas_error core_switching_post_dec(
      }

      /* delay HQ synthesis to synchronize with ACELP synthesis */
#ifdef IVAS_FLOAT_FIXED
            floatToFixed_arrL(synth, synth_fx, Q11, 960);
            floatToFixed_arrL(st->delay_buf_out, st->delay_buf_out32_fx, Q11, 60);

            delay_signal_fx( synth_fx, output_frame, st->delay_buf_out32_fx, delay_comp );

            fixedToFloat_arrL(synth_fx, synth, Q11, 960);
            fixedToFloat_arrL(st->delay_buf_out32_fx, st->delay_buf_out, Q11, 60);
#else
      delay_signal_float(synth, output_frame, st->delay_buf_out, delay_comp);
#endif

      if (st->element_mode == EVS_MONO && st->core == HQ_CORE) /* ACELP->HQ-CORE */
      {
@@ -1342,20 +1321,7 @@ ivas_error core_switching_post_dec(
        if ((st->element_mode == IVAS_CPE_MDCT || (ivas_format == ISM_FORMAT && st->core == TCX_20_CORE /* <- means TCX in general, TCX10 is forbidden after ACELP */)) && st->last_core_brate <= SID_2k40 && st->core_brate > SID_2k40)
        {
          /* smooth transitions to avoid pops in car noise items */
#ifdef IVAS_FLOAT_FIXED

                    for ( int lp = 0; lp < 960; lp++ )
                    {
                        synth_fx[lp] = (Word32) ( synth[lp] * ( 1u << 4 ) );
                    }
                    smoothTransitionDtxToTcx_fx( synth_fx, output_frame, delay_comp );
                    for ( int lp = 0; lp < 2 * delay_comp; lp++ )
                    {
                        synth[lp] = (float) synth_fx[lp] / ( 1u << 4 );
                    }
#else
          smoothTransitionDtxToTcx(synth, output_frame, delay_comp);
#endif
        }

        /* Reset memories of CLDFBs */
@@ -1595,6 +1561,7 @@ ivas_error core_switching_post_dec(

  return error;
}

#endif
/*---------------------------------------------------------------------*
 * core_switching_hq_prepare_dec()
+1 −1
Original line number Diff line number Diff line
@@ -2459,7 +2459,7 @@ void ivas_binRenderer_fx(
    /* memory reset for the binaural output */
    FOR(chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++)
    {
        FOR(k = 0; k < numTimeSlots; k++)
        FOR(k = 0; k < MAX_PARAM_SPATIAL_SUBFRAMES; k++)
        {
            set32_fx(Cldfb_RealBuffer_Binaural_fx[chIdx][k], 0, CLDFB_NO_CHANNELS_MAX);
            set32_fx(Cldfb_ImagBuffer_Binaural_fx[chIdx][k], 0, CLDFB_NO_CHANNELS_MAX);
+1 −14
Original line number Diff line number Diff line
@@ -1162,7 +1162,7 @@ ivas_error ivas_core_dec(

            if ( hCPE->hStereoDft != NULL )
            {
                floatToFixed_arrL( hCPE->hStereoDft->hb_stefi_sig, hCPE->hStereoDft->hb_stefi_sig_fx, q, L_FRAME48k + NS2SA( 48000, STEREO_DFT_TD_STEFI_DELAY_NS ) );
                //floatToFixed_arrL( hCPE->hStereoDft->hb_stefi_sig, hCPE->hStereoDft->hb_stefi_sig_fx, q, L_FRAME48k + NS2SA( 48000, STEREO_DFT_TD_STEFI_DELAY_NS ) );
                hCPE->hStereoDft->td_gain_fx[0] = 1;
            }
            Scale_sig( tmp_buffer_fx, L_FRAME48k, Q11 - Q_white_exc );
@@ -1171,19 +1171,6 @@ ivas_error ivas_core_dec(
			Scale_sig32(hb_synth_32_fx[0], L_FRAME48k, sub(Q11 , q));
			Scale_sig32(hb_synth_32_fx[1], L_FRAME48k, sub(Q11 , q));

            if ( hCPE->hStereoDft != NULL )
            {

                fixedToFloat_arrL( hCPE->hStereoDft->hb_stefi_sig_fx, hCPE->hStereoDft->hb_stefi_sig, 16, L_FRAME48k + NS2SA( 48000, STEREO_DFT_TD_STEFI_DELAY_NS ) );
                hCPE->hStereoDft->hb_nrg_subr[0] = (float) hCPE->hStereoDft->hb_nrg_subr_fx[0] / ( 1u << hCPE->hStereoDft->Q_nrg_subr );
                hCPE->hStereoDft->hb_nrg_subr[1] = (float) hCPE->hStereoDft->hb_nrg_subr_fx[1] / ( 1u << hCPE->hStereoDft->Q_nrg_subr );
                hCPE->hStereoDft->hb_nrg[0] = (float) hCPE->hStereoDft->hb_nrg_fx[0] / ( 1u << ( hCPE->hStereoDft->Q_nrg_subr + 9 ) );

                if ( hCPE->hStereoDft->td_gain_fx[0] == 0 )
                {
                    hCPE->hStereoDft->td_gain[0] = 0;
                }
            }
        }

        IF( EQ_16( st->element_mode, EVS_MONO ) )
Loading