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

Merge branch 'TonalMdctConceal_whiten_noise_shape_ivas' into 'main'

Converted TonalMdctConceal_whiten_noise_shape_ivas() to fixed point.

See merge request !144
parents 29f86649 add7ea91
Loading
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -1138,4 +1138,9 @@ void FdCngDecodeDiracMDCTStereoSID_fx(
    CPE_DEC_HANDLE hCPE /* i/o: CPE decoder state structure     */
);

//tonalMDCTconcealment.c
void TonalMdctConceal_whiten_noise_shape_ivas_fx(
    Decoder_State *st,
    const Word16 L_frame,
    const TONALMDCTCONC_NOISE_SHAPE_WHITENING_MODE whitening_mode );
#endif
+4 −0
Original line number Diff line number Diff line
@@ -198,6 +198,10 @@ Word32 sum16_32_fx( /* o : sum of all vector elements
                    const Word16 *vec,      /* i  : input vector                          Qx*/
                    const Word16 lvec       /* i  : length of input vector                */
);
Word32 sum32_sat(                           /* o  : sum of all vector elements            Qx*/
                  const Word32 *vec,        /* i  : input vector                          Qx*/
                  const Word16 lvec         /* i  : length of input vector                */
);
Word32 var_fx_32(                           /* o: variance of vector                    Qx+16*/
                  const Word16 *x,          /* i: input vector                          Qx*/
                  const Word16 Qx,
+17 −0
Original line number Diff line number Diff line
@@ -1118,6 +1118,23 @@ Word32 sum16_32_fx( /* o : sum of all vector elements Qx*/
    return tmp;
}

Word32 sum32_sat(                    /* o  : sum of all vector elements            Qx*/
                  const Word32 *vec, /* i  : input vector                          Qx*/
                  const Word16 lvec  /* i  : length of input vector                */
)
{
    Word16 i;
    Word32 tmp;
    tmp = 0;
    move16();
    FOR( i = 0; i < lvec; i++ )
    {
        tmp = L_add_sat( tmp, vec[i] ); /*Qx */
    }

    return tmp;
}

Word32 var_fx_32(                /* o: variance of vector                    Qx+16*/
    const Word16 *x,        /* i: input vector                          Qx*/
    const Word16 Qx,
+21 −1
Original line number Diff line number Diff line
@@ -515,7 +515,27 @@ void ApplyFdCng_flt(
                {
                    if ( st->element_mode == IVAS_CPE_MDCT && st->core != ACELP_CORE )
                    {
#ifdef IVAS_FLOAT_FIXED
                        hFdCngCom->cngNoiseLevelExp = 28;
                        for ( int p = 0; p < hFdCngCom->stopFFTbin - hFdCngCom->startBand; p++ )
                        {
                            hFdCngCom->cngNoiseLevel[p] = (Word32) (cngNoiseLevel_flt[p] * ( 1u << ( 31 - hFdCngCom->cngNoiseLevelExp ) ) );
                        }

                        TonalMdctConceal_whiten_noise_shape_ivas_fx( st, L_frame, ON_FIRST_LOST_FRAME );

                        for (int p = 0; p < hFdCngCom->stopFFTbin - hFdCngCom->startBand; p++)
                        {
                          cngNoiseLevel_flt[p] = (float)hFdCngCom->cngNoiseLevel[p] / (1u << (31 - hFdCngCom->cngNoiseLevelExp));
                        }
                        for ( int p = 0; p < FDNS_NPTS; p++ )
                        {
                            st->hTonalMDCTConc->scaleFactorsBackground_flt[p] = (float) st->hTonalMDCTConc->scaleFactorsBackground_fx[p] / ONE_IN_Q16;
                        }
#else
                      TonalMdctConceal_whiten_noise_shape_ivas(st, L_frame, ON_FIRST_LOST_FRAME);
#endif // IVAS_FLOAT_FIXED

                    }
                    else if ( st->element_mode != IVAS_CPE_MDCT || st->core == ACELP_CORE )
                    {
+23 −0
Original line number Diff line number Diff line
@@ -591,7 +591,30 @@ ivas_error ivas_core_dec(
            {
                if ( sts[n]->last_core_bfi != ACELP_CORE )
                {
#ifdef IVAS_FLOAT_FIXED
                    sts[n]->hFdCngDec->hFdCngCom->cngNoiseLevelExp = 27;
                    for ( int p = 0; p < sts[n]->hFdCngDec->hFdCngCom->stopFFTbin - sts[n]->hFdCngDec->hFdCngCom->startBand; p++ )
                    {
                        sts[n]->hFdCngDec->hFdCngCom->cngNoiseLevel[p] = (Word32) ( sts[n]->hFdCngDec->hFdCngCom->cngNoiseLevel_flt[p] * ( 1u << ( 31 - sts[n]->hFdCngDec->hFdCngCom->cngNoiseLevelExp ) ) );
                    }
                    for (int p = 0; p < FDNS_NPTS; p++)
                    {
                      sts[n]->hTonalMDCTConc->scaleFactorsBackground_fx[p] = (Word32)(sts[n]->hTonalMDCTConc->scaleFactorsBackground_flt[p] * ONE_IN_Q16);
                    }

                    TonalMdctConceal_whiten_noise_shape_ivas_fx( sts[n], L_FRAME16k, ON_FIRST_GOOD_FRAME );

                    for ( int p = 0; p < sts[n]->hFdCngDec->hFdCngCom->stopFFTbin - sts[n]->hFdCngDec->hFdCngCom->startBand; p++ )
                    {
                        sts[n]->hFdCngDec->hFdCngCom->cngNoiseLevel_flt[p] = (float) sts[n]->hFdCngDec->hFdCngCom->cngNoiseLevel[p] / ( 1u << ( 31 - sts[n]->hFdCngDec->hFdCngCom->cngNoiseLevelExp ) );
                    }
                    for ( int p = 0; p < FDNS_NPTS; p++ )
                    {
                        sts[n]->hTonalMDCTConc->scaleFactorsBackground_flt[p] = (float) sts[n]->hTonalMDCTConc->scaleFactorsBackground_fx[p] / ONE_IN_Q16;
                    }
#else
                    TonalMdctConceal_whiten_noise_shape_ivas( sts[n], L_FRAME16k, ON_FIRST_GOOD_FRAME );
#endif // IVAS_FLOAT_FIXED
                }
            }
        }
Loading