Commit a5e37052 authored by Manuel Jander's avatar Manuel Jander
Browse files

Resolve merge conflict.

parents dd254784 3ea8505d
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -759,6 +759,7 @@ enum
#define PIT_FIR_SIZE6_2                     ( PIT_UP_SAMP6 * PIT_L_INTERPOL6_2 + 1 )
#define E_MIN                               0.0035f                /* minimum allowable energy */
#define E_MIN_Q11_FX                            7                      /* minimum allowable energy in Q11*/
#define E_MIN_Q27_FX                            469762                      /* minimum allowable energy in Q27*/
#define STEP_DELTA                          0.0625f                /* quantization step for tilt compensation of gaussian cb. excitation */
#define GAMMA_EV                            0.92f                  /* weighting factor for core synthesis error weighting */
#define FORMANT_SHARPENING_NOISE_THRESHOLD  21.0f                  /* lp_noise level above which formant sharpening is deactivated */
+80 −24
Original line number Diff line number Diff line
@@ -483,6 +483,54 @@ void expand_range(
    move16();
}

void expand_range_fx(
    Word32 *in,  // Q25
    Word32 *out, // exp:out_exp
    Word16 *out_exp,
    const Word16 len )
{
    Word16 i, tmp_e;
    Word32 maxVal, tmp32;
    Word16 maxOutExp;

    const Word32 low_lim = 726940; /* 0.0003385080526823181f in Q31 */
    move32();

    /* Find max possible output exponent. */
    maxVal = 0;
    move32();
    FOR( i = 0; i < len; i++ )
    {
        maxVal = L_max( maxVal, in[i] );
    }
    tmp32 = BASOP_util_Pow2( maxVal, Q31 - Q25, &tmp_e );
    maxOutExp = tmp_e;
    move16();

    /* out = (2^(in) - 1) */
    FOR( i = 0; i < len; i++ )
    {
        tmp32 = BASOP_util_Pow2( in[i], Q31 - Q25, &tmp_e );  // 2^x
        tmp32 = L_sub( tmp32, L_shl( 1, sub( 31, tmp_e ) ) ); // 2^x - 1
        tmp32 = L_shr( tmp32, sub( maxOutExp, tmp_e ) );      // make exp same as maxExpOut

        out[i] = tmp32;
        move32();

        Word32 tmp_low_lim = L_shr( low_lim, maxOutExp );
        if ( LT_32( out[i], tmp_low_lim ) )
        {
            out[i] = tmp_low_lim;
            move32();
        }
    }

    *out_exp = maxOutExp;
    move16();

    return;
}

/*-------------------------------------------------------------------
 * expand_range_var_e()
 *
@@ -1145,10 +1193,10 @@ void minimum_statistics(
void minimum_statistics_fx(
    Word16 len,                    /* i  : Total number of partitions (CLDFB or FFT)                   */
    Word16 lenFFT,                 /* i  : Number of FFT partitions                                  */
    Word16 *psize,                 /* i  : Partition sizes, fractional                               */
    Word16 *psize,                 /* i  : Partition sizes, fractional                             Q9*/
    Word16 *msPeriodog,            /* i  : Periodogram (energies)                                    */
    Word16 *msNoiseFloor,          /* i/o: Noise floors (energies)                                   */
    Word16 *msNoiseEst,            /* i/o: Noise estimates (energies)                                */
    Word32 *msNoiseFloor,          /* i/o: Noise floors (energies)                                Q25*/
    Word32 *msNoiseEst,            /* i/o: Noise estimates (energies)                             Q25*/
    Word32 *msAlpha,               /* i/o: Forgetting factors                                        */
    Word16 *msPsd,                 /* i/o: Power Spectral Density (smoothed periodogram => energies) */
    Word16 *msPsdFirstMoment,      /* i/o: PSD statistics of 1st order (energy means)                */
@@ -1223,8 +1271,8 @@ void minimum_statistics_fx(
    IF( LT_16( hFdCngCom->msFrCnt_init_counter, hFdCngCom->msFrCnt_init_thresh ) )
    {
        Copy( msPeriodog, msPsd, len );                                    /* 6Q9 */
        Copy( msPeriodog, msNoiseFloor, len );     /* 6Q9 */
        Copy( msPeriodog, msNoiseEst, len );       /* 6Q9 */
        Copy_Scale_sig_16_32_no_sat( msPeriodog, msNoiseFloor, len, Q16 ); /* Q25 */
        Copy_Scale_sig_16_32_no_sat( msPeriodog, msNoiseEst, len, Q16 );   /* Q25 */
        Copy( msPeriodog, msPsdFirstMoment, len );                         /* 6Q9 */

        set32_fx( msPsdSecondMoment, 0l /*0.0 Q31*/, len );
@@ -1335,7 +1383,16 @@ void minimum_statistics_fx(
            /* Compute SNR */

            /* msPeriodogSum[cnt] with format 16Q15 */
            snr = dotp_s_fx( msNoiseFloor + start, psize + start, current_len, CNG_HS );
            Word16 msNoiseFloor16tmp[NPART_SHAPING];
            IF( enc_dec == ENC )
            {
                Copy_Scale_sig32_16( msNoiseFloor, msNoiseFloor16tmp, NPART, 0 );
            }
            ELSE
            {
                Copy_Scale_sig32_16( msNoiseFloor, msNoiseFloor16tmp, NPART_SHAPING, 0 );
            }
            snr = dotp_s_fx( &msNoiseFloor16tmp[start], psize + start, current_len, CNG_HS );

            IF( GT_32( L_shr( Mpy_32_16_1( msPsdSum[cnt], 18431 /*0.56246299817 Q15*/ ), 13 ), snr ) )
            {
@@ -1366,16 +1423,16 @@ void minimum_statistics_fx(
                    /* calculate scalar2 with normalized msNoiseFloor[j], exponent -2*s1 */
                    s1 = WORD16_BITS - 1;
                    move16();
                    if ( msNoiseFloor[j] != 0 )
                    if ( msNoiseFloor16tmp[j] != 0 )
                    {
                        s1 = norm_s( msNoiseFloor[j] );
                        s1 = norm_s( msNoiseFloor16tmp[j] );
                    }
                    msNoiseFloor16 = shl( msNoiseFloor[j], s1 );
                    msNoiseFloor16 = shl( msNoiseFloor16tmp[j], s1 );
                    scalar2 = L_mult( msNoiseFloor16, msNoiseFloor16 );

                    /* calculate difference, both elements in 6Q9 format, use absolute value
                       to avoid -1.0 x -1.0 multiplications later */
                    scalar316 = abs_s( sub( msPsd[j], msNoiseFloor[j] ) );
                    scalar316 = abs_s( sub( msPsd[j], msNoiseFloor16tmp[j] ) );

                    s2 = WORD16_BITS - 1;
                    move16();
@@ -1475,7 +1532,7 @@ void minimum_statistics_fx(

                IF( msNoiseFloor[j] != 0 /*0.0 Q15*/ )
                {
                    tmp = L_mult( msNoiseFloor[j], msNoiseFloor[j] );
                    tmp = Mpy_32_32( msNoiseFloor[j], msNoiseFloor[j] );
                    tmp16 = BASOP_Util_Divide3232_uu_1616_Scale( msPsdSecondMoment[j], tmp, &s );
                    /* consider factor of 2 */
                    s = s_min( s_max( sub( s, 1 ), -( WORD16_BITS - 1 ) ), ( WORD16_BITS - 1 ) );
@@ -1586,7 +1643,7 @@ void minimum_statistics_fx(
                }
            }
            /* Get the current noise floor */
            Copy_Scale_sig_32_16( msCurrentMinOut, msNoiseFloor, len, -16 );
            Copy32( msCurrentMinOut, msNoiseFloor, len );
        }
        ELSE /* sub window complete */
        {
@@ -1644,7 +1701,7 @@ void minimum_statistics_fx(
                set32_fx( msCurrentMin, 2147483647l /*1.0 Q31*/, len );

                /* Get the current noise floor */
                Copy_Scale_sig_32_16( msCurrentMinOut, msNoiseFloor, len, -16 );
                Copy32( msCurrentMinOut, msNoiseFloor, len );
            }
        }

@@ -1701,18 +1758,19 @@ void minimum_statistics_fx(
            hFdCngCom->msFrCnt = add( hFdCngCom->msFrCnt, 1 );
            move16();
        }

        Word64 tmp64;
        /* Smooth noise estimate during CNG phases */
        FOR( j = 0; j < len; j++ )
        {
            msNoiseEst[j] = round_fx( L_mac( L_mult( 31130 /*0.95 Q15*/, msNoiseEst[j] ), 1638 /*0.05 Q15*/, msNoiseFloor[j] ) );
            move16();
            tmp64 = W_add( W_mult_32_16( msNoiseEst[j], 31130 /*0.95 Q15*/ ), W_mult_32_16( msNoiseFloor[j], 1638 /*0.05 Q15*/ ) );
            msNoiseEst[j] = W_extract_h( W_shl( tmp64, 16 ) ); // Q25
            move32();
        }
    }
    IF( EQ_16( enc_dec, DEC ) && EQ_16( element_mode, IVAS_CPE_TD ) )
    {
        // v_multc(msNoiseEst, 1.4125f, msNoiseEst, NPART_SHAPING);
        v_multc_att( msNoiseEst, 23142, msNoiseEst, NPART_SHAPING );
        v_multc_att32( msNoiseEst, 23142, msNoiseEst, NPART_SHAPING );
    }
    /* Collect buffers */
    Copy( msPeriodog, msPeriodogBuf + len * ( *msPeriodogBufPtr ), len );
@@ -1734,17 +1792,15 @@ void minimum_statistics_fx(
        {
            scalar = L_mac( scalar, msPeriodogBuf[i], 6554 /*1.0/MSBUFLEN Q15*/ );
        }
        scalar16 = round_fx( scalar );
        if ( GT_16( msNoiseEst[j], scalar16 ) /*0.0 Q15*/ )
        if ( GT_32( msNoiseEst[j], scalar ) /*0.0 Q15*/ )
        {
            msNoiseEst[j] = scalar16;
            move16();
            msNoiseEst[j] = scalar;
            move32();
        }

        assert( msNoiseEst[j] >= 0 /*0.0 Q15*/ );
    }
}

/*-------------------------------------------------------------------
 * apply_scale()
 *
+2 −2
Original line number Diff line number Diff line
@@ -2965,7 +2965,7 @@ Word16 ivas_acelp_tcx20_switching_fx(
    Word16 *inp_fx,      /* i  : new input signal                        */
    Word16 q_inp,        /* i  : i/p Q                                  */
    Word16 *wsp,         /* i  : input weighted signal                   */
    Word16 non_staX,     /* i  : unbound non-stationarity for sp/mu clas */
    Word32 non_staX,     /* i  : unbound non-stationarity for sp/mu clas */
    Word16 *pitch_fr,    /* i  : fraction pitch values                   */
    Word16 *voicing_fr,  /* i  : fractional voicing values               */
    Word32 currFlatness, /* i  : flatness                                */
@@ -3989,7 +3989,7 @@ Word16 ivas_smc_gmm_fx(
    const Word16 cor_map_sum_fx,          /* i  : correlation map sum (from multi-harmonic anal.) Q8  */
    const Word32 epsP_fx[M + 1],          /* i  : LP prediciton error                                 */
    const Word32 PS_fx[],                 /* i  : energy spectrum                                     */
    const Word16 non_sta_fx,              /* i  : unbound non-stationarity                        Q8  */
    const Word32 non_sta_fx,              /* i  : unbound non-stationarity                        Q20  */
    const Word16 relE_fx,                 /* i  : relative frame energy                           Q8  */
    Word16 *high_lpn_flag,                /* i/o: sp/mus LPN flag                                     */
    const Word16 flag_spitch,             /* i  : flag to indicate very short stable pitch            */
+2 −0
Original line number Diff line number Diff line
@@ -109,4 +109,6 @@
#define FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD
//#define FIX_1348_BIT_PRECISION_IMPROVEMENT_ROUND_OLD_BUFF

#define FIX_1713_EXP                            /* VA: proposed correction to exp in ic-BWE*/

#endif
+8 −2
Original line number Diff line number Diff line
@@ -5163,6 +5163,12 @@ void expand_range(
    Word16 *out_exp,
    const Word16 len );
void expand_range_fx(
    Word32 *in,  // Q25
    Word32 *out, // exp:out_exp
    Word16 *out_exp,
    const Word16 len );
void expand_range_var_exp(
    Word16 *in,
    Word16 in_exp,
@@ -5198,8 +5204,8 @@ void minimum_statistics_fx(
    Word16 lenFFT,                 /* i  : Number of FFT partitions                                  */
    Word16 *psize,                 /* i  : Partition sizes, fractional                               */
    Word16 *msPeriodog,            /* i  : Periodogram (energies)                                    */
    Word16 *msNoiseFloor,          /* i/o: Noise floors (energies)                                   */
    Word16 *msNoiseEst,            /* i/o: Noise estimates (energies)                                */
    Word32 *msNoiseFloor,          /* i/o: Noise floors (energies)                                Q25*/
    Word32 *msNoiseEst,            /* i/o: Noise estimates (energies)                             Q25*/
    Word32 *msAlpha,               /* i/o: Forgetting factors                                        */
    Word16 *msPsd,                 /* i/o: Power Spectral Density (smoothed periodogram => energies) */
    Word16 *msPsdFirstMoment,      /* i/o: PSD statistics of 1st order (energy means)                */
Loading