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

Floating point code restore

parent 23ab02e5
Loading
Loading
Loading
Loading
Loading
+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()
+6 −6
Original line number Diff line number Diff line
@@ -2178,13 +2178,13 @@ static ivas_error ivas_mc_dec_reconfig(
	{
		return error;
	}
#endif // IVAS_FLOAT_FIXED
#else // IVAS_FLOAT_FIXED
    /*To be removed later: Contains memory allocations for floating point buffers*/
    //if ( ( error = ivas_hp20_dec_reconfig( st_ivas, nchan_hp20_old ) ) != IVAS_ERR_OK )
    //{
    //    return error;
    //}

    if ( ( error = ivas_hp20_dec_reconfig( st_ivas, nchan_hp20_old ) ) != IVAS_ERR_OK )
    {
        return error;
    }
#endif
    /*-----------------------------------------------------------------*
     * Allocate the LFE handle that is coded separately after the allocation of the core coders
     *-----------------------------------------------------------------*/
+6 −113
Original line number Diff line number Diff line
@@ -763,12 +763,12 @@ ivas_error ivas_sba_dec_reconfigure(
	{
		return error;
	}
#endif // IVAS_FLOAT_FIXED
    //if ( ( error = ivas_hp20_dec_reconfig( st_ivas, nchan_hp20_old ) ) != IVAS_ERR_OK )
    //{
    //    return error;
    //}

#else
    if ( ( error = ivas_hp20_dec_reconfig( st_ivas, nchan_hp20_old ) ) != IVAS_ERR_OK )
    {
        return error;
    }
#endif
    /*-----------------------------------------------------------------*
     * TD Decorrelator
     *-----------------------------------------------------------------*/
@@ -2154,7 +2154,6 @@ ivas_error ivas_sba_dec_render(
        output_f_local[ch] = output_f[ch];
    }


    slot_size = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS );

    /* loop for synthesis, assume we always have to render in multiples of 5ms subframes with spills */
@@ -2173,113 +2172,7 @@ ivas_error ivas_sba_dec_render(
    {
        int16_t n_samples_sf = slot_size * hSpar->subframe_nbslots[subframe_idx];

#ifdef IVAS_FLOAT_FIXED1
#if 1 /*Float to fixed conversion*/
        Word16 numch_out = hSpar->hFbMixer->fb_cfg->num_out_chans;
        Word16 numch_in = hSpar->hFbMixer->fb_cfg->num_in_chans;
        Word16 num_spar_bands = hSpar->hFbMixer->pFb->filterbank_num_bands;
        DECODER_CONFIG_HANDLE hDecoderConfig;
        hDecoderConfig = st_ivas->hDecoderConfig;
        Word16 numch_out_dirac = hDecoderConfig->nchan_out;

        Word16 num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate );

        for ( int i = 0; i < s_max( st_ivas->nchan_ism, 0 ) + nchan_internal; i++ )
        {
            floatToFixed_arr32( st_ivas->hTcBuffer->tc[i], st_ivas->hTcBuffer->tc_fx[i], Q11, st_ivas->hTcBuffer->n_samples_available );
        }
#endif
#if 0
        Word16 q1 = 30, q2 = 30;
        for ( int l = 0; l < numch_out; l++ )
        {
            for ( int j = 0; j < numch_in; j++ )
            {
                for ( int k = 0; k < num_md_sub_frames * IVAS_MAX_NUM_BANDS; k++ )
                {
                    hSpar->hMdDec->mixer_mat_fx[l][j][k] = floatToFixed(hSpar->hMdDec->mixer_mat[l][j][k] , q1 );
                }
            }
        }
        for ( int m = 0; m < MAX_PARAM_SPATIAL_SUBFRAMES + 1; m++ )
        {
            for ( int j = 0; j < IVAS_MAX_FB_MIXER_OUT_CH; j++ )
            {
                for ( int k = 0; k < IVAS_MAX_SPAR_FB_MIXER_IN_CH; k++ )
                {
                    for ( int l = 0; l < IVAS_MAX_NUM_BANDS; l++ )
                    {
                        hSpar->hMdDec->mixer_mat_prev_fx[m][j][k][l] = floatToFixed( hSpar->hMdDec->mixer_mat_prev[m][j][k][l] , q2 );
                    }
                }
            }
        }
#endif
#if 1
        for ( Word16 in_ch = 0; in_ch < numch_in; in_ch++ )
        {
            for ( Word16 i = 0; i < st_ivas->cldfbAnaDec[in_ch]->p_filter_length - st_ivas->cldfbAnaDec[in_ch]->no_channels; i++ )
            {
                st_ivas->cldfbAnaDec[in_ch]->cldfb_state_fx[i] = (Word32) ( st_ivas->cldfbAnaDec[in_ch]->cldfb_state[i] * ( 1LL << ( Q11 ) ) );
            }
        }
        if ( ( hDecoderConfig->ivas_total_brate < IVAS_24k4 ) && ( ( hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_HOA2 ) || ( hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_HOA3 ) ) )
        {
            for ( Word16 i = 0; i < IVAS_MAX_NUM_BANDS; i++ )
            {
                floatToFixed_arrL( hSpar->hMdDec->smooth_buf[i], hSpar->hMdDec->smooth_buf_fx[i], 0, 2 * SBA_DIRAC_NRG_SMOOTH_LONG + 1 );
            }
            floatToFixed_arr( hSpar->hMdDec->smooth_fac, hSpar->hMdDec->smooth_fac_fx, Q15, IVAS_MAX_NUM_BANDS );
        }
#endif //
        ivas_spar_dec_upmixer_sf_fx( st_ivas, output_f_local_fx, nchan_internal );
#ifdef IVAS_FLOAT_FIXED /*Fixed to float */
        FOR( Word16 in_ch = 0; in_ch < numch_in; in_ch++ )
        {
            FOR( Word16 i = 0; i < st_ivas->cldfbAnaDec[in_ch]->p_filter_length - st_ivas->cldfbAnaDec[in_ch]->no_channels; i++ )
            {
                st_ivas->cldfbAnaDec[in_ch]->cldfb_state[i] = ( (float) ( st_ivas->cldfbAnaDec[in_ch]->cldfb_state_fx[i] ) / ( 1LL << ( Q11 ) ) ); /*Rounding off*/
            }
        }
#if 0
        FOR( int m = 0; m < MAX_PARAM_SPATIAL_SUBFRAMES + 1; m++ )
        {
            FOR( int j = 0; j < IVAS_MAX_FB_MIXER_OUT_CH; j++ )
            {
                FOR( int k = 0; k < IVAS_MAX_SPAR_FB_MIXER_IN_CH; k++ )
                {
                    FOR( int l = 0; l < IVAS_MAX_NUM_BANDS; l++ )
                    {
                        hSpar->hMdDec->mixer_mat_prev[m][j][k][l] = ( (float) hSpar->hMdDec->mixer_mat_prev_fx[m][j][k][l] / ( 1 << q2 ) );
                    }
                }
            }
        }
#endif
        // fix2float (to be cleaned)
        IF( ( LT_32( hDecoderConfig->ivas_total_brate, IVAS_24k4 ) ) && ( ( EQ_16( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_HOA2 ) ) || ( EQ_16( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_HOA3 ) ) ) )
        {
            fixedToFloat_arr( hSpar->hMdDec->smooth_fac_fx, hSpar->hMdDec->smooth_fac, Q15, IVAS_MAX_NUM_BANDS );
            FOR( Word16 i = 0; i < IVAS_MAX_NUM_BANDS; i++ )
            {
                fixedToFloat_arrL( hSpar->hMdDec->smooth_buf_fx[i], hSpar->hMdDec->smooth_buf[i], 0, 2 * SBA_DIRAC_NRG_SMOOTH_LONG + 1 );
            }
        }
        // fix2float end
        FOR( Word16 out_ch = 0; out_ch < numch_out_dirac; out_ch++ )
        {
            IF( st_ivas->cldfbSynDec[out_ch] )
            {
                FOR( Word16 i = 0; i < st_ivas->cldfbSynDec[out_ch]->p_filter_length; i++ )
                {
                    st_ivas->cldfbSynDec[out_ch]->cldfb_state[i] = ( (float) ( st_ivas->cldfbSynDec[out_ch]->cldfb_state_fx[i] ) / (float) ( 1LL << ( Q7 ) ) ); /*Rounding off*/
                }
            }
        }
#endif
#else
        ivas_spar_dec_upmixer_sf( st_ivas, output_f_local, nchan_internal );
#endif // IVAS_FLOAT_FIXED
        for ( ch = 0; ch < nchan_out; ch++ )
        {
            output_f_local[ch] += n_samples_sf;
+2765 −3

File changed.

Preview size limit exceeded, changes collapsed.

+80 −3
Original line number Diff line number Diff line
@@ -996,7 +996,7 @@ void stereo_dft_dec_reset(
 *
 * Update DFT memories for new frame
 *-------------------------------------------------------------------------*/

#ifdef IVAS_FLOAT_FIXED
void stereo_dft_dec_update(
    STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: decoder DFT stereo handle          */
    const int16_t output_frame,            /* i  : output frame length                */
@@ -1102,7 +1102,81 @@ void stereo_dft_dec_update(

    return;
}
#else

void stereo_dft_dec_update(
    STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: decoder DFT stereo handle          */
    const int16_t output_frame,            /* i  : output frame length                */
    const int16_t sba_dirac_stereo_flag    /* i  : signal stereo output for SBA DirAC */
)
{
    int16_t b, i, k_offset;

    /* Initialization */
    k_offset = STEREO_DFT_OFFSET; /*Add an offset*/

    /* Update parameters */
    for (i = 0; i < k_offset * STEREO_DFT_BAND_MAX; i++)
    {
        hStereoDft->side_gain[i] = hStereoDft->side_gain[STEREO_DFT_NBDIV * STEREO_DFT_BAND_MAX + i];
        hStereoDft->res_pred_gain[i] = hStereoDft->res_pred_gain[STEREO_DFT_NBDIV * STEREO_DFT_BAND_MAX + i];
    }

    for (i = 0; i < k_offset; i++)
    {
        hStereoDft->gipd[i] = hStereoDft->gipd[STEREO_DFT_NBDIV + i];
    }

    /* Update configuration memories */
    for (i = 0; i < k_offset; i++)
    {
        hStereoDft->band_res[i] = hStereoDft->band_res[i + STEREO_DFT_NBDIV];
        hStereoDft->prm_res[i] = hStereoDft->prm_res[i + STEREO_DFT_NBDIV];
        hStereoDft->itd[i] = hStereoDft->itd[STEREO_DFT_NBDIV + i];
        hStereoDft->res_cod_mode[i] = hStereoDft->res_cod_mode[i + STEREO_DFT_NBDIV];
        hStereoDft->res_pred_mode[i] = hStereoDft->res_pred_mode[i + STEREO_DFT_NBDIV];
    }

    /* Load new configurations */
    set_s(hStereoDft->band_res + k_offset, hStereoDft->hConfig->band_res, STEREO_DFT_NBDIV);
    set_s(hStereoDft->prm_res + k_offset, hStereoDft->hConfig->prm_res, STEREO_DFT_NBDIV);
    set_s(hStereoDft->res_pred_mode + k_offset, hStereoDft->hConfig->res_pred_mode, STEREO_DFT_NBDIV);
    set_s(hStereoDft->res_cod_mode + k_offset, hStereoDft->hConfig->res_cod_mode, STEREO_DFT_NBDIV);

    /*Update attack info*/
    if (hStereoDft->attackPresent)
    {
        hStereoDft->wasTransient = 1;
    }
    else if (hStereoDft->wasTransient)
    {
        hStereoDft->wasTransient = 0;
    }

    for (i = STEREO_DFT_CORE_HIST_MAX - 1; i > 0; i--)
    {
        hStereoDft->core_hist[i] = hStereoDft->core_hist[i - 1];
    }

    mvr2r(hStereoDft->hb_stefi_sig + output_frame, hStereoDft->hb_stefi_sig, hStereoDft->hb_stefi_delay);
    mvr2r(hStereoDft->hb_nrg, hStereoDft->hb_nrg + 1, STEREO_DFT_CORE_HIST_MAX - 1);
    mvr2r(hStereoDft->td_gain, hStereoDft->td_gain + 1, STEREO_DFT_CORE_HIST_MAX - 1);

    if (sba_dirac_stereo_flag)
    {
        /* buffer update, push back by 2 because of 2 subframes */
        for (b = 0; b < hStereoDft->nbands; b++)
        {
            for (i = SBA_DIRAC_NRG_SMOOTH_LONG; i > 1; i--)
            {
                hStereoDft->smooth_buf[b][i] = hStereoDft->smooth_buf[b][i - 2];
            }
        }
    }

    return;
}
#endif

/*-------------------------------------------------------------------------
 * stereo_dft_dec_destroy()
@@ -3510,13 +3584,14 @@ void stereo_dft_generate_res_pred(
    pop_wmops();
    return;
}

#endif

/*---------------------------------------------------------------
 * stereo_dft_dec_smooth_parameters()
 *
 *
 * ---------------------------------------------------------------*/
#ifndef IVAS_FLOAT_FIXED
#if 1
void stereo_dft_dec_smooth_parameters(
    STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: decoder DFT stereo handle           */
@@ -4116,7 +4191,9 @@ void stereo_dft_dec_smooth_parameters(
    return;
}
#endif
#endif

#ifndef IVAS_FLOAT_FIXED
/*---------------------------------------------------------------
 * stereo_dft_adapt_sf_delay()
 *