Commit 2ae07fd4 authored by Manuel Jander's avatar Manuel Jander
Browse files

Merge remote-tracking branch 'origin' into basop-2206-investigate_accuracy_issues

parents 3498057a ac900052
Loading
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -57,7 +57,7 @@ Word16 get_next_coeff_unmapped(
    return *idx;
}

Word16 update_mixed_context(
Word16 update_mixed_context_fx(
    Word16 ctx, /* Q0 */
    Word16 a    /* Q0 */
)
@@ -78,7 +78,7 @@ Word16 update_mixed_context(
    return add( shl( s_and( ctx, 0xf ), 4 ), add( t, 13 ) );
}

Word32 update_mixed_context_ivas_fx(
Word32 update_mixed_context_fx_32(
    Word32 ctx, /* Q0 */
    Word16 a    /* Q0 */
)
+8 −0
Original line number Diff line number Diff line
@@ -306,7 +306,11 @@ IF( NE_16( Opt_AMR_WB, 1 ) )

    IF( EQ_16( L_frame, L_FRAME16k ) )
    {
#ifndef FIX_2410_HARM_MODIF_FS
        modify_Fs_fx( fft_io, L_FRAME16k, 16000, fft_io, 12800, exc_mem1, 0 );
#else
        modify_Fs_fx( fft_io, L_FRAME16k, 16000, fft_io, 12800, exc_mem1, 0, NULL, NULL );
#endif
    }

    /* fft_rel(fft_io, L_FFT, LOG2_L_FFT); */
@@ -419,7 +423,11 @@ IF( NE_16( Opt_AMR_WB, 1 ) )

    IF( EQ_16( L_frame, L_FRAME16k ) )
    {
#ifndef FIX_2410_HARM_MODIF_FS
        modify_Fs_fx( fft_io, L_FFT, 12800, fft_io, 16000, exc_mem, 0 );
#else
        modify_Fs_fx( fft_io, L_FFT, 12800, fft_io, 16000, exc_mem, 0, NULL, NULL );
#endif
    }

    /* enr1 = dotp( fft_io, fft_io, L_frame ) / L_frame; */
+0 −8
Original line number Diff line number Diff line
@@ -997,11 +997,7 @@ void init_tcx_cfg_ivas_fx(

    IF( hTcxCfg->fIsTNSAllowed )
    {
#ifdef FIX_2388_INITTNSCONFIGURATION
        InitTnsConfigs_fx( bwidth, hTcxCfg->tcx_coded_lines, hTcxCfg->tnsConfig, infoIGFStopFreq, total_brate, element_mode, MCT_flag );
#else
        InitTnsConfigs_ivas_fx( bwidth, hTcxCfg->tcx_coded_lines, hTcxCfg->tnsConfig, infoIGFStopFreq, total_brate, element_mode, MCT_flag );
#endif
        SetAllowTnsOnWhite( hTcxCfg->tnsConfig, (Word8) EQ_16( element_mode, IVAS_CPE_MDCT ) );
    }

@@ -1256,11 +1252,7 @@ void init_tcx_cfg_fx(

    IF( hTcxCfg->fIsTNSAllowed )
    {
#ifdef FIX_2388_INITTNSCONFIGURATION
        InitTnsConfigs_fx( bwidth, hTcxCfg->tcx_coded_lines, hTcxCfg->tnsConfig, infoIGFStopFreq, total_brate, element_mode, MCT_flag );
#else
        InitTnsConfigs( bwidth, hTcxCfg->tcx_coded_lines, hTcxCfg->tnsConfig, infoIGFStopFreq, total_brate, element_mode, MCT_flag );
#endif

        SetAllowTnsOnWhite( hTcxCfg->tnsConfig, (Word8) EQ_16( element_mode, IVAS_CPE_MDCT ) );
    }
+1 −1
Original line number Diff line number Diff line
@@ -2995,7 +2995,7 @@ void lpc_from_spectrum(

    /* LPC */

    E_LPC_lev_dur( r_h, r_l, A, NULL, lpcorder, NULL );
    E_LPC_lev_dur_fx( r_h, r_l, A, NULL, lpcorder, NULL );
}

/*
+6 −179
Original line number Diff line number Diff line
@@ -70,19 +70,13 @@ static Word16 VDQ_vec_fx( Word16 *Qvec_out_fx, const Word16 *mean_dic_fx, const
/* _ None                                                                 */
/*========================================================================*/

#ifdef FIX_2380_HARM_GSC_GAIN_COMP_FX
Word16 Comp_and_apply_gain_fx(
#else
void Comp_and_apply_gain_fx(
#endif
    Word16 exc_diffQ[],          /* i/o: Quantized excitation                  */
    Word16 Ener_per_bd_iQ[],     /* i  : Target ener per band              Q13 */
    Word16 Ener_per_bd_yQ[],     /* i/o: Ener per band for norm vector   i->Q13/o->Q13 */
    Word16 Mbands_gn,            /* i  : number of bands                       */
    const Word16 ReUseGain,      /* i  : Reuse the gain in Ener_per_bd_yQ      */
#ifdef FIX_2380_HARM_GSC_GAIN_COMP_FX
    const Word16 Flag_adj_q_exc, /* i  : Flag allowing Q_exc adjustment   */
#endif
    Word16 Qexc_diff,
    Word16 Q_exc )
{
@@ -90,11 +84,9 @@ void Comp_and_apply_gain_fx(
    Word16 StartBin, NB_Qbins;
    Word16 y_gain;
    Word16 L16, frac, exp1, tmp_exp;
#ifdef FIX_2380_HARM_GSC_GAIN_COMP_FX
    Word16 Q_adapt;
    Word16 Q_exc_diffQ[L_FRAME16k];
    Word32 exc_diffQ32[L_FRAME16k];
#endif
    Word32 L32;

    /* Recreate excitation for local synthesis and decoder */
@@ -139,7 +131,6 @@ void Comp_and_apply_gain_fx(
            Ener_per_bd_yQ[i_band] = shl_sat( y_gain, sub( exp1, 13 ) );
            move16(); /*Q1     */
            tmp_exp = add( add( exp1, 1 ), sub( Q_exc, Qexc_diff ) );
#ifdef FIX_2380_HARM_GSC_GAIN_COMP_FX
            IF( Flag_adj_q_exc != 0 )
            {
                FOR( i = StartBin; i < NB_Qbins + StartBin; i++ )
@@ -155,7 +146,6 @@ void Comp_and_apply_gain_fx(
                }
            }
            ELSE
#endif
            {
                FOR( i = StartBin; i < NB_Qbins + StartBin; i++ )
                {
@@ -166,7 +156,6 @@ void Comp_and_apply_gain_fx(
            }
        }
    }
#ifdef FIX_2380_HARM_GSC_GAIN_COMP_FX
    Q_adapt = Q_exc;
    move16();
    test();
@@ -185,113 +174,8 @@ void Comp_and_apply_gain_fx(
        }
    }
    return Q_adapt;
#else
    return;
#endif
}
#ifndef FIX_2338_HARM_GSC_GAIN_COMP


void Comp_and_apply_gain_ivas_fx(
    Word16 exc_diffQ[],      /* i/o: Quantized excitation                   */
    Word16 Ener_per_bd_iQ[], /* i  : Target ener per band               Q13 */
    Word16 Ener_per_bd_yQ[], /* i/o  : Ener per band for norm vector     i->Q13/o->Q13 */
    Word16 Mbands_gn,        /* i  : number of bands                        */
    const Word16 ReUseGain,  /* i  : Reuse the gain in Ener_per_bd_yQ       */
    Word16 Qexc_diff,
    Word16 *Q_exc )
{
    Word16 i, i_band;
    Word16 StartBin, NB_Qbins;
    Word16 y_gain;
    Word16 L16, frac, exp1, tmp_exp;
    Word32 L32;
    Word16 Q_exc_diffQ[L_FRAME16k];

    /* Recreate excitation for local synthesis and decoder */
    StartBin = 0;
    move16();
    NB_Qbins = 0;
    move16();

    tmp_exp = add( 14, sub( *Q_exc, Qexc_diff ) ); /* In case of reuse, it can be computed outside the loop*/
    FOR( i_band = 0; i_band < Mbands_gn; i_band++ )
    {
        StartBin = add( StartBin, NB_Qbins );
        NB_Qbins = mfreq_bindiv_loc[i_band];
        move16();
        IF( EQ_16( ReUseGain, 1 ) )
        {
            y_gain = Ener_per_bd_yQ[i_band]; /*Q13*/
            move16();

            FOR( i = StartBin; i < NB_Qbins + StartBin; i++ )
            {
                L32 = L_mult( exc_diffQ[i], y_gain ); /*Q_exc+16-tmp_exp */
                exc_diffQ[i] = round_fx_sat( L32 );   /*Q_exc-tmp_exp */
                move16();
                IF( exc_diffQ[i] )
                {
                    Q_exc_diffQ[i] = sub( *Q_exc, tmp_exp );
                }
                ELSE
                {
                    Q_exc_diffQ[i] = *Q_exc;
                }
                move16();
            }
        }
        ELSE
        {
            /*-----------------------------------------------------------------*
             * y_gain  = pow(10.0, (Ener_per_bd_iQ[i_band]-Ener_per_bd_yQ[i_band]))
             * = pow(2, 3.321928*(Ener_per_bd_iQ[i_band]-Ener_per_bd_yQ[i_band]))
             *-----------------------------------------------------------------*/

            L16 = sub_sat( Ener_per_bd_iQ[i_band], Ener_per_bd_yQ[i_band] ); /*Q12 */
            L32 = L_mult( L16, 27213 );                                      /* 3.321928 in Q13 -> Q26 */
            L32 = L_shr( L32, 10 );                                          /* From Q26 to Q16 */
            frac = L_Extract_lc( L32, &exp1 );                               /* Extract exponent of gcode0 */
            y_gain = extract_l( Pow2( 14, frac ) );                          /* Put 14 as exponent so that */
                                                                             /* output of Pow2() will be: */
                                                                             /* 16384 < Pow2() <= 32767 */
            Ener_per_bd_yQ[i_band] = shl_sat( y_gain, sub( exp1, 13 ) );     /*Q13*/
            move16();                                                        /*Q1     */
            tmp_exp = add( add( exp1, 1 ), sub( *Q_exc, Qexc_diff ) );

            FOR( i = StartBin; i < NB_Qbins + StartBin; i++ )
            {
                L32 = L_mult( exc_diffQ[i], y_gain ); /*Qexc_diff+15 */
                exc_diffQ[i] = round_fx_sat( L32 );   /*Q_exc-tmp_exp */
                move16();
                IF( exc_diffQ[i] )
                {
                    Q_exc_diffQ[i] = sub( *Q_exc, tmp_exp );
                }
                ELSE
                {
                    Q_exc_diffQ[i] = *Q_exc;
                }
                move16();
            }
        }
}

    FOR( i = 0; i < StartBin + NB_Qbins; i++ )
    {
        *Q_exc = s_min( *Q_exc, add( Q_exc_diffQ[i], norm_s( exc_diffQ[i] ) ) );
        move16();
    }
    FOR( i = 0; i < StartBin + NB_Qbins; i++ )
    {
        exc_diffQ[i] = shl( exc_diffQ[i], sub( *Q_exc, Q_exc_diffQ[i] ) ); /*Q_exc*/
        move16();
    }

    return;
}
#endif


/*========================================================================*/
/* FUNCTION : Ener_per_band_comp_fx()                                     */
@@ -343,57 +227,6 @@ void Ener_per_band_comp_fx(
    Word16 y_gain4_fx[],        /* o  : Energy per band to quantize       Q12            */
    const Word16 Q_exc,         /* i  : frame length                      */
    const Word16 Mband,         /* i  : Max band                          */
#ifdef FIX_1904_HARM_GSC_ENC
    const Word16 Eflag,  /* i  : flag of highest band              */
    const Word16 L_frame /* i  : frame length                      */
#else
    const Word16 Eflag /* i  : flag of highest band              */
#endif
)
{
    const Word16 *pt_fx;
    Word16 j;

    pt_fx = exc_diff_fx;
    FOR( j = 0; j < 2; j++ )
    {
        y_gain4_fx[j] = Comp_band_log_ener( pt_fx, 8, Q_exc, 1 ); /*Q12*/
        move16();
        pt_fx += 8;
    }

    FOR( j = 1; j < Mband - 2; j++ )
    {
        y_gain4_fx[j + 1] = Comp_band_log_ener( pt_fx, 16, Q_exc, 0 ); /*Q12*/
        move16();
        pt_fx += 16;
    }

    IF( EQ_16( Eflag, 1 ) )
    {
        y_gain4_fx[j + 1] = Comp_band_log_ener( pt_fx, 32, Q_exc, -1 ); /*Q12*/
        move16();
        pt_fx += 32;
    }

#ifdef FIX_1904_HARM_GSC_ENC
    IF( EQ_16( L_frame, L_FRAME16k ) )
    {
        y_gain4_fx[j + 2] = Comp_band_log_ener( pt_fx, 32, Q_exc, -1 ); /*Q12*/
        move16();
        y_gain4_fx[j + 3] = Comp_band_log_ener( pt_fx, 64, Q_exc, -1 ); /*Q12*/
        move16();
    }
#endif

    return;
}
#ifndef FIX_1904_HARM_GSC_ENC
void Ener_per_band_comp_ivas_fx(
    const Word16 exc_diff_fx[], /* i  : target signal                     Q_exc_diff     */
    Word16 y_gain4_fx[],        /* o  : Energy per band to quantize       Q12            */
    const Word16 Q_exc,         /* i  : frame length                      */
    const Word16 Mband,         /* i  : Max band                          */
    const Word16 Eflag,         /* i  : flag of highest band              */
    const Word16 L_frame        /* i  : frame length                      */
)
@@ -429,12 +262,10 @@ void Ener_per_band_comp_ivas_fx(
        move16();
        y_gain4_fx[j + 3] = Comp_band_log_ener( pt_fx, 64, Q_exc, -1 ); /*Q12*/
        move16();
        pt_fx += 64;
    }

    return;
}
#endif


/*-------------------------------------------------------------------*
@@ -511,11 +342,7 @@ static void GSC_gain_adj(
        }

        /*mimic ACELP decay of energy for low rates*/
#ifndef FIX_2406_FIX_GAIN_ON_INACTIVE
        FOR( i = 0; i < MBANDS_GN; i++ )
#else
        FOR( i = 0; i < Mbands_gn; i++ )
#endif
        {
            old_y_gain[i] = y_gain_tmp[i];
            move16();
Loading