Commit 45b3f07f authored by Sandesh Venkatesh's avatar Sandesh Venkatesh
Browse files

Merge branch 'bug_fixes_prec_impr_2' into 'main'

Precision improvements and bug fixes to remove tonal lines in ParamISM [allow regression]

See merge request !1642
parents 87b4c490 447118dc
Loading
Loading
Loading
Loading
Loading
+43 −25
Original line number Diff line number Diff line
@@ -120,6 +120,8 @@ void ivas_initFdCngCom_fx( HANDLE_FD_CNG_COM hFdCngCom, Word16 scale )
    move16();
    hFdCngCom->CngBitrate = -1;
    move16();
    hFdCngCom->olapBufferSynth_exp = 0;
    move16();

    /* Initialize noise estimation algorithm */
    set32_fx( hFdCngCom->periodog, 0, PERIODOGLEN );
@@ -2653,9 +2655,10 @@ void SynthesisSTFT_ivas_fx(
    const Word16 nchan_out     /* i  : number of output channels */
)
{
    Word16 i, len, scale, tmp;
    Word16 i, len, scale, tmp, sft, exp, tmp1;
    Word16 len2, len3, len4;
    Word16 buf[M + 1 + L_FRAME16k];
    Word32 L_olapBuffer[FFTLEN];


    /* Perform IFFT */
@@ -2666,6 +2669,12 @@ void SynthesisSTFT_ivas_fx(
    hFdCngCom->fftBuffer_exp = fftBufferExp;
    move16();

    sft = getScaleFactor32( fftBuffer, hFdCngCom->fftlen );
    scale_sig32( fftBuffer, hFdCngCom->fftlen, sft );
    fftBufferExp = sub( fftBufferExp, sft );
    hFdCngCom->fftBuffer_exp = fftBufferExp;
    move16();

    fftBufferExp = add( fftBufferExp, hFdCngCom->fftlenShift );

    /* Perform overlap-add */
@@ -2679,48 +2688,58 @@ void SynthesisSTFT_ivas_fx(
    }
    ELSE
    {
        Copy( olapBuffer + hFdCngCom->frameSize, olapBuffer, hFdCngCom->frameSize );
        Copy_Scale_sig_16_32_no_sat( olapBuffer + hFdCngCom->frameSize, L_olapBuffer, hFdCngCom->frameSize, add( sub( hFdCngCom->olapBufferSynth_exp, sub( 15, hFdCngCom->fftlenShift ) ), 16 ) ); /* exp: hFdCngCom->olapBufferSynth_exp -> (15 - fftlenShift) */
        set16_fx( olapBuffer + hFdCngCom->frameSize, 0, hFdCngCom->frameSize );
    }
    len2 = shr( hFdCngCom->fftlen, 2 );
    len4 = shr( hFdCngCom->fftlen, 3 );
    len3 = add( len2, len4 );
    len = add( hFdCngCom->frameSize, len4 );
    tmp1 = sub( fftBufferExp, 15 );
    IF( tcx_transition )
    {
        FOR( i = 0; i < len; i++ )
        {
            olapBuffer[i] = round_fx_sat( L_shl_sat( fftBuffer[i], fftBufferExp - 15 ) ); // Q(15 - fftBufferExp)
            move16();
            L_olapBuffer[i] = L_shl_sat( fftBuffer[i], tmp1 ); /* Q(31 - (15 - fftlenShift) ) */
            move32();
        }
    }
    ELSE
    {
        FOR( i = 0; i < len4; i++ )
        {
            olapBuffer[i + 1 * len4] = add_sat( olapBuffer[i + 1 * len4], mult_r( round_fx_sat( L_shl_sat( fftBuffer[i + 1 * len4], fftBufferExp - 15 ) ), olapWin[i].v.im ) );
            move16();
            olapBuffer[i + 2 * len4] = add_sat( olapBuffer[i + 2 * len4], mult_r( round_fx_sat( L_shl_sat( fftBuffer[i + 2 * len4], fftBufferExp - 15 ) ), olapWin[len4 - 1 - i].v.re ) );
            move16();
            L_olapBuffer[i + 1 * len4] = Madd_32_16( L_olapBuffer[i + 1 * len4], L_shl_sat( fftBuffer[i + 1 * len4], tmp1 ), olapWin[i].v.im ); /* Q(31 - (15 - fftlenShift) ) */
            move32();
            L_olapBuffer[i + 2 * len4] = Madd_32_16( L_olapBuffer[i + 2 * len4], L_shl_sat( fftBuffer[i + 2 * len4], tmp1 ), olapWin[len4 - 1 - i].v.re ); /* Q(31 - (15 - fftlenShift) ) */
            move32();
        }
        FOR( i = len3; i < len; i++ )
        {
            olapBuffer[i] = round_fx_sat( L_shl_sat( fftBuffer[i], fftBufferExp - 15 ) );
            L_olapBuffer[i] = L_shl_sat( fftBuffer[i], tmp1 ); /* Q(31 - (15 - fftlenShift) ) */
            move32();
        }
    }

    FOR( i = 0; i < len4; i++ )
    {
        olapBuffer[i + 5 * len4] = mult_r( round_fx_sat( L_shl_sat( fftBuffer[i + 5 * len4], fftBufferExp - 15 ) ), olapWin[i].v.re );
        move16();
        olapBuffer[i + 6 * len4] = mult_r( round_fx_sat( L_shl_sat( fftBuffer[i + 6 * len4], fftBufferExp - 15 ) ), olapWin[len4 - 1 - i].v.im );
        move16();
        L_olapBuffer[i + 5 * len4] = Mpy_32_16_1( L_shl_sat( fftBuffer[i + 5 * len4], tmp1 ), olapWin[i].v.re ); /* Q(31 - (15 - fftlenShift) ) */
        move32();
        L_olapBuffer[i + 6 * len4] = Mpy_32_16_1( L_shl_sat( fftBuffer[i + 6 * len4], tmp1 ), olapWin[len4 - 1 - i].v.im ); /* Q(31 - (15 - fftlenShift) ) */
        move32();
    }

    len = add( len, len2 );
    FOR( i = len; i < hFdCngCom->fftlen; i++ )
    {
        olapBuffer[i] = 0;
        L_olapBuffer[i] = 0;
        move32();
    }

    sft = L_norm_arr( L_olapBuffer, hFdCngCom->fftlen );
    IF( NE_16( sft, 31 ) )
    {
        Copy_Scale_sig32_16( L_olapBuffer, olapBuffer, hFdCngCom->fftlen, sft );
        hFdCngCom->olapBufferSynth_exp = sub( sub( 15, hFdCngCom->fftlenShift ), sft );
        move16();
    }

@@ -2737,24 +2756,23 @@ void SynthesisSTFT_ivas_fx(
            buf[i] = mult_r( olapBuffer[i + len4 - M - 1], hFdCngCom->fftlenFac );
            move16();
        }
        exp = add( hFdCngCom->olapBufferSynth_exp, hFdCngCom->fftlenShift );
        tmp = buf[0];
    }
    IF( EQ_16( gen_exc, 1 ) )
    {
        Word16 s = getScaleFactor16( buf + 1, M + hFdCngCom->frameSize );
        if ( GT_16( *Q_new, s ) )
        {
            *Q_new = s;
        E_UTIL_f_preemph2( 0, buf + 1, PREEMPH_FAC, add( M, hFdCngCom->frameSize ), &tmp );
        Residu3_fx( hFdCngCom->A_cng, buf + 1 + M, hFdCngCom->exc_cng, hFdCngCom->frameSize, 0 );
        *Q_new = sub( 15, exp );
        move16();
    }

        E_UTIL_f_preemph2( *Q_new - 1, buf + 1, PREEMPH_FAC, M + hFdCngCom->frameSize, &tmp );
        Residu3_fx( hFdCngCom->A_cng, buf + 1 + M, hFdCngCom->exc_cng, hFdCngCom->frameSize, 1 );
    }
    IF( EQ_16( gen_exc, 2 ) )
    {
        *Q_new = E_UTIL_f_preemph3( buf + 1, PREEMPH_FAC, M + hFdCngCom->frameSize, &tmp, 1 );
        Residu3_fx( hFdCngCom->A_cng, buf + 1 + M, hFdCngCom->exc_cng, hFdCngCom->frameSize, 1 );
        *Q_new = E_UTIL_f_preemph3( buf + 1, PREEMPH_FAC, add( M, hFdCngCom->frameSize ), &tmp, 0 );
        move16();
        Residu3_fx( hFdCngCom->A_cng, buf + 1 + M, hFdCngCom->exc_cng, hFdCngCom->frameSize, negate( *Q_new ) );
        *Q_new = sub( 15, exp );
        move16();
    }
}

+18 −0
Original line number Diff line number Diff line
@@ -6512,6 +6512,18 @@ void hf_synth_fx(
    const Word16 Q_syn2            /* i  : synthesis scaling              */
);
void hf_synth_ivas_fx(
    ZERO_BWE_DEC_HANDLE hBWE_zero, /* i/o: handle to 0 bit BWE parameters	   */
    const Word32 core_brate,       /* i  : core bitrate						 Q0*/
    const Word16 output_frame,     /* i  : output frame length               Q0*/
    const Word16 *Aq,              /* i  : quantized Az						Q12*/
    const Word16 *exc,             /* i  : excitation at 12.8 kHz		  Q_exc*/
    Word16 *synth,                 /* i  : 12.8kHz synthesis signal		 Q_syn2*/
    Word16 *synth16k,              /* o  : 16kHz synthesis signal        Q_syn2*/
    const Word16 Q_exc,            /* i  : excitation scaling             */
    const Word16 Q_syn2            /* i  : synthesis scaling              */
);
void hf_synth_amr_wb_init_fx(
    AMRWB_IO_DEC_HANDLE hAmrwb_IO /* i/o: AMR-WB IO data handle   */
);
@@ -10139,6 +10151,12 @@ void hp400_12k8_fx(
    Word16 mem[]     /* i/o: filter memory [6]                      */
);
void hp400_12k8_ivas_fx(
    Word16 signal[], /* i/o: input signal / output is divided by 16 */
    const Word16 lg, /* i  : lenght of signal                       */
    Word16 mem[]     /* i/o: filter memory [6]                      */
);
Word16 dot_prod_satcontr( const Word16 *x, const Word16 *y, Word16 qx, Word16 qy, Word16 *qo, Word16 len );
void E_UTIL_f_convolve( const Word16 x[], const Word16 h[], Word16 y[], const Word16 size );
+2 −1
Original line number Diff line number Diff line
@@ -377,6 +377,7 @@ typedef struct
    Word16 *olapBufferAna; /* q_olapBufferAna */              /* points to FD_CNG_DEC->olapBufferAna[FFTLEN] in case of decoder */
    Word16 olapBufferAna_fx[FFTLEN]; /* q_olapBufferAna_fx */ /* points to FD_CNG_DEC->olapBufferAna[FFTLEN] in case of decoder */
    Word16 olapBufferSynth[FFTLEN];                           /* q_olapBuffer */
    Word16 olapBufferSynth_exp;
    Word16 *olapBufferSynth2; /*Q_syn*/ /* points to FD_CNG_DEC->olapBufferSynth2[FFTLEN] in case of decoder */
    const PWord16 *olapWinAna;
    const PWord16 *olapWinSyn;
+52 −0
Original line number Diff line number Diff line
@@ -3864,6 +3864,58 @@ void hp400_12k8_fx(
    return;
}

void hp400_12k8_ivas_fx(
    Word16 signal[], /* i/o: input signal / output is divided by 16 */
    const Word16 lg, /* i  : lenght of signal                       */
    Word16 mem[]     /* i/o: filter memory [6]                      */
)
{
    Word16 i;
    Word16 x0, x1, x2;
    Word32 L_tmp, yy1, y2;

    yy1 = L_Comp( mem[2], mem[3] ); /* Q_syn + 13 */
    y2 = L_Comp( mem[0], mem[1] );  /* Q_syn + 13 */
    x0 = mem[4];                    /* Q_syn */
    move16();
    x1 = mem[5]; /* Q_syn */
    move16();

    FOR( i = 0; i < lg; i++ )
    {
        x2 = x1; /* Q_syn */
        move16();
        x1 = x0; /* Q_syn */
        move16();
        x0 = signal[i]; /* Q_syn */
        move16();

        L_tmp = Mpy_32_16_1( yy1, a_hp400_ivas_fx[1] ); /*yy1 * a_hp400[1]*/     /* Qx(Q_of_yy1) + 10 ---->( (Q_syn+13) + 12 - 15)*/
        L_tmp = Madd_32_16( L_tmp, y2, a_hp400_ivas_fx[2] ); /*y2 * a_hp400[2]*/ /* Qx + 10 ---->( (Q_syn+13) + 12 - 15)*/
        L_tmp = L_shl( L_tmp, 3 );                                               /* shifting by 3 to maintain same Q (Q_syn+13) */

        L_tmp = L_mac( L_tmp, x0, b_hp400_fx[0] ); /* Q_syn + 13 */
        L_tmp = L_mac( L_tmp, x1, b_hp400_fx[1] ); /* Q_syn + 13 */
        L_tmp = L_mac( L_tmp, x2, b_hp400_fx[2] ); /* Q_syn + 13 */

        y2 = yy1; /* Q_syn + 13 */
        move32();
        yy1 = L_tmp; /* Q_syn + 13 */
        move32();

        signal[i] = round_fx( L_tmp ); /* Q_syn - 3 */
        move16();
    }

    L_Extract( yy1, &mem[2], &mem[3] );
    L_Extract( y2, &mem[0], &mem[1] );
    mem[4] = x0; /* Q_syn */
    mem[5] = x1; /* Q_syn */
    move16();
    move16();
    return;
}

Word16 dot_prod_satcontr( const Word16 *x, const Word16 *y, Word16 qx, Word16 qy, Word16 *qo, Word16 len )
{
    Word16 tmp_tab_x[L_FRAME16k];
+1 −1
Original line number Diff line number Diff line
@@ -2289,7 +2289,7 @@ ivas_error acelp_core_dec_fx(
            ELSE
            {
                Copy_Scale_sig_32_16( synth_fx, synth_fx16, output_frame, 0 ); // Q0
                hf_synth_fx( st->hBWE_zero, st->core_brate, output_frame, Aq_fx, exc2_fx, psyn_fx, synth_fx16, st->Q_exc, st->Q_syn2 );
                hf_synth_ivas_fx( st->hBWE_zero, st->core_brate, output_frame, Aq_fx, exc2_fx, psyn_fx, synth_fx16, st->Q_exc, st->Q_syn2 );
                Copy_Scale_sig_16_32_DEPREC( synth_fx16, synth_fx, output_frame, 0 );
            }
        }
Loading