Commit c7f9fef4 authored by norvell's avatar norvell
Browse files

Added SWB TBE target fix under FIX_I102_SWB_TBE_SWITCH

parent 68fbd32e
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -149,6 +149,7 @@
#define SPAR_SCALING_HARMONIZATION                      /* Issue 80: Changes to harmonize scaling in spar */

#define SBA_INTERN_CONFIG_FIX_HOA2                      /* Issue 99 : Fix for incorrect internal_config when output format is HOA2 or FOA*/
//#define FIX_I102_SWB_TBE_SWITCH                              /* Issue 102: avoid IO->SWB switching code for IVAS, generate SHB ACB mem with lerp in case of switch */

/* ################## End DEVELOPMENT switches ######################### */
/* clang-format on */
+8 −1
Original line number Diff line number Diff line
@@ -701,7 +701,14 @@ ivas_error acelp_core_dec(
                mvr2r( old_exc_s + st->L_frame - M, st->mem_syn2, M );
                residu( Aq, M, old_exc_s, old_exc + L_EXC_MEM_DEC - st->L_frame, st->L_frame );
            }
#ifdef FIX_I102_SWB_TBE_SWITCH
            if ( st->last_core != ACELP_CORE && st->element_mode > EVS_MONO )
            {
                /* Prepare ACB memory of old_bwe_exc */
                lerp( old_exc, old_bwe_exc, L_EXC_MEM_DEC * HIBND_ACB_L_FAC, L_EXC_MEM_DEC );
                
            }
#endif
            /*-----------------------------------------------------------------*
             * FEC - first good frame after lost frame(s) (possibility to correct the ACB)
             *-----------------------------------------------------------------*/
+7 −0
Original line number Diff line number Diff line
@@ -472,6 +472,13 @@ ivas_error acelp_core_enc(
            mvr2r( hLPDmem->old_exc + st->L_frame - M, hLPDmem->mem_syn, M );
            residu( Aq, M, hLPDmem->old_exc, old_exc, st->L_frame );
        }
#ifdef FIX_I102_SWB_TBE_SWITCH
        if ( st->last_core != ACELP_CORE && st->element_mode > EVS_MONO )
        {
            /* Prepare ACB memory of old_bwe_exc */
            lerp( old_exc, old_bwe_exc, L_EXC_MEM_DEC * HIBND_ACB_L_FAC, L_EXC_MEM_DEC );
        }
#endif

        /*---------------------------------------------------------------*
         * Calculation of LP residual (filtering through A[z] filter)
+57 −14
Original line number Diff line number Diff line
@@ -288,6 +288,10 @@ void swb_pre_proc(
    int32_t inner_Fs, input_Fs;
    float old_input[NS2SA( 48000, DELAY_FD_BWE_ENC_NS + DELAY_FIR_RESAMPL_NS ) + L_FRAME48k];
    float spchTmp[640];
#ifdef FIX_I102_SWB_TBE_SWITCH
    float spchTmp2[640];
    int16_t L_resamp;
#endif
    int16_t i, j;
    int16_t startB, endB;
    float *realBufferFlipped[CLDFB_NO_COL_MAX];
@@ -677,6 +681,7 @@ void swb_pre_proc(
    }
    else
    {
#ifndef FIX_I102_SWB_TBE_SWITCH
        if ( st->bwidth == FB || st->core == ACELP_CORE || ( st->element_mode == IVAS_CPE_DFT && input_Fs == 48000 ) )
        {
            set_f( hBWE_TD->old_speech_shb, 0, L_LOOK_16k + L_SUBFR16k );
@@ -697,6 +702,31 @@ void swb_pre_proc(
        }
        else
        {
#else
        if ( st->L_frame == L_FRAME )
        {
            L_resamp = 560; /* 6.4 kHz core -> 6 - 14 kHz band target -> 560 samples in 28 kHz sample rate */
        }
        else
        {
            L_resamp = 620; /* 8 kHz core -> 7.5 - 15.5 kHz band target -> 620 samples in 31 kHz sample rate */
        }

        /* Dirty downsampling to match Nyquist to upper frequency limit of target */
        lerp( st->input, new_swb_speech, L_resamp, (int16_t) ( input_Fs / 50 ) );

        /* flip the spectrum */
        mvr2r( new_swb_speech, spchTmp, L_resamp );
        for ( i = 0; i < L_resamp; i = i + 2 )
        {
            spchTmp[i] = -spchTmp[i];
        }
        
        /* Dirty upsampling to match Nyquist to lower frequency limit of target (reversed spectrum)*/
        lerp( spchTmp, spchTmp2, L_FRAME32k, L_resamp );
        mvr2r( spchTmp2, spchTmp, L_FRAME32k );
#endif
#ifndef FIX_I102_SWB_TBE_SWITCH
           /* flip the spectrm */
            mvr2r( new_swb_speech, spchTmp, L_FRAME32k );

@@ -704,8 +734,9 @@ void swb_pre_proc(
            {
                spchTmp[i] = -spchTmp[i];
            }

#endif
        Decimate_allpass_steep( spchTmp, hBWE_TD->state_ana_filt_shb, L_FRAME32k, shb_speech );

        mvr2r( shb_speech + L_FRAME16k - ( L_LOOK_16k + L_SUBFR16k ), hBWE_TD->old_speech_shb, L_LOOK_16k + L_SUBFR16k );

        /*Compute the past overlap for potential next iDFTs SHB*/
@@ -716,20 +747,32 @@ void swb_pre_proc(
                hCPE->hStereoDft->output_mem_dmx_16k_shb[i] = shb_speech[20 + i] * hCPE->hStereoDft->win_ana_16k[STEREO_DFT_OVL_16k - 1 - i] * hCPE->hStereoDft->win_ana_16k[STEREO_DFT_OVL_16k - 1 - i];
            }
        }
#ifndef FIX_I102_SWB_TBE_SWITCH
    }
#endif

    if ( st->element_mode != IVAS_CPE_DFT )
    {
        /* Reset CLDFB synthesis buffer */
        set_f( st->cldfbSynTd->cldfb_state, 0.0f, st->cldfbSynTd->p_filter_length );
    }
#ifdef FIX_I102_SWB_TBE_SWITCH
    else
    {
        hCPE->hStereoDft->flip_sign = -hCPE->hStereoDft->flip_sign; /* Make sure sign is updated even if DFT SHB target is not generated */
    }
#endif
}

    /* Memory reset to compensate for 0.9375 ms offset when transitioning from IO to SWB */
    /* When switching from n >1 to n = 1, we keep the enc/dec delay as 8.75/3.25 and below code not needed;
       only when n = 1 start, it will be 9.6875/2.3125 in that case this reset is needed for IO->BWE.*/
#ifdef FIX_I102_SWB_TBE_SWITCH
    if ( st->last_extl == -1 && st->element_mode == EVS_MONO )
#else
    /* IVAS_fmToDo: revisit for IVAS (the condition is currently entered for both TD and DFT stereo - is it desirable?) */
    if ( st->last_extl == -1 )
#endif
    {
        delay = NS2SA( input_Fs, DELAY_FIR_RESAMPL_NS );
        for ( i = 0; i < delay; i++ )