Commit 7dbedc02 authored by Fabian Bauer's avatar Fabian Bauer
Browse files

FIX_2485_HARMONIZE_minimum_statistics: some more fixes

parent fe877f45
Loading
Loading
Loading
Loading
Loading
+25 −25
Original line number Diff line number Diff line
@@ -1696,8 +1696,8 @@ void minimum_statistics_fx(
    Word16 lenFFT,                  /* i  : Number of FFT partitions                                  */
    Word16 *psize,                  /* i  : Partition sizes, fractional                             Q9*/
    Word16 *msPeriodog,             /* i  : Periodogram (energies)                                    */
    Word32 *msNoiseFloor_buffer,   /* i/o: Noise floors (energies)                                Q25*/
    Word32 *msNoiseEst_buffer,     /* i/o: Noise estimates (energies)                             Q25*/
    void *msNoiseFloor_buffer,      /* i/o: Noise floors (energies)                                Q25*/
    void *msNoiseEst_buffer,        /* 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)                */
@@ -2398,7 +2398,7 @@ void minimum_statistics_fx(
            hFdCngCom->msFrCnt = add( hFdCngCom->msFrCnt, 1 );
            move16();
        }
        Word64 tmp64;

          /* Smooth noise estimate during CNG phases */
#ifdef FIX_2485_HARMONIZE_minimum_statistics
        IF( element_mode == 0 )
+28 −0
Original line number Diff line number Diff line
@@ -4585,6 +4585,33 @@ void expand_range_var_exp(
    Word16 *out_exp,
    const Word16 len );

#ifdef FIX_2485_HARMONIZE_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                             Q9*/
    Word16 *msPeriodog,            /* i  : Periodogram (energies)                                    */
    void *msNoiseFloor_buffer,     /* i/o: Noise floors (energies)                                Q25*/
    void *msNoiseEst_buffer,       /* 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)                */
    Word32 *msPsdSecondMoment,     /* i/o: PSD statistics of 2nd order (energy variances)            */
    Word32 *msMinBuf,              /* i/o: Buffer of minima (energies)                               */
    Word32 *msBminWin,             /* o  : Bias correction factors                                   */
    Word32 *msBminSubWin,          /* o  : Bias correction factors                                   */
    Word32 *msCurrentMin,          /* i/o: Local minima (energies)                                   */
    Word32 *msCurrentMinOut,       /* i/o: Local minima (energies)                                   */
    Word32 *msCurrentMinSubWindow, /* i/o: Local minima (energies)                                   */
    Word16 *msLocalMinFlag,        /* i  : Binary flag                                               */
    Word16 *msNewMinFlag,          /* i  : Binary flag                                               */
    Word16 *msPeriodogBuf,         /* i/o: Buffer of periodograms (energies)                         */
    Word16 *msPeriodogBufPtr,      /* i/o: Counter                                                   */
    HANDLE_FD_CNG_COM hFdCngCom,   /* i/o: FD_CNG structure containing all buffers and variables */
    const Word16 enc_dec,          /* i  : encoder/decoder indicator */
    const Word16 element_mode      /* i  : IVAS element mode type    */
  );
#else
void minimum_statistics(
    Word16 len,                    /* i  : Total number of partitions (CLDFB or FFT)                   */
    Word16 lenFFT,                 /* i  : Number of FFT partitions                                  */
@@ -4634,6 +4661,7 @@ void minimum_statistics_fx(
    const Word16 enc_dec,          /* i  : encoder/decoder indicator */
    const Word16 element_mode      /* i  : IVAS element mode type    */
);
#endif

/* Apply bitrate-dependant scale */
void apply_scale(
+27 −0
Original line number Diff line number Diff line
@@ -1280,6 +1280,32 @@ void perform_noise_estimation_dec_fx(
        compress_range( hFdCngDec->msPeriodog, hFdCngDec->msPeriodog_exp, hFdCngDec->msLogPeriodog, npart );

        /* Call the minimum statistics routine for noise estimation */
#ifdef FIX_2485_HARMONIZE_minimum_statistics
        minimum_statistics_fx(
            npart,
            nFFTpart,
            psize_norm,
            hFdCngDec->msLogPeriodog,
            hFdCngDec->msNoiseFloor,
            hFdCngDec->msLogNoiseEst,
            hFdCngDec->msAlpha,
            hFdCngDec->msPsd,
            hFdCngDec->msPsdFirstMoment,
            hFdCngDec->msPsdSecondMoment,
            hFdCngDec->msMinBuf,
            hFdCngDec->msBminWin,
            hFdCngDec->msBminSubWin,
            hFdCngDec->msCurrentMin,
            hFdCngDec->msCurrentMinOut,
            hFdCngDec->msCurrentMinSubWindow,
            hFdCngDec->msLocalMinFlag,
            hFdCngDec->msNewMinFlag,
            hFdCngDec->msPeriodogBuf,
            &( hFdCngDec->msPeriodogBufPtr ),
            hFdCngDec->hFdCngCom,
            0,
            0 );
#else
        minimum_statistics(
            npart,
            nFFTpart,
@@ -1302,6 +1328,7 @@ void perform_noise_estimation_dec_fx(
            hFdCngDec->msPeriodogBuf,
            &( hFdCngDec->msPeriodogBufPtr ),
            hFdCngDec->hFdCngCom );
#endif

        /* Expand MS outputs */
        expand_range( hFdCngDec->msLogNoiseEst, hFdCngDec->msNoiseEst, &hFdCngDec->msNoiseEst_exp, npart );
+40 −1
Original line number Diff line number Diff line
@@ -2665,6 +2665,44 @@ void perform_noise_estimation_enc_fx(
    compress_range( msPeriodog_fx, hFdCngEnc->msPeriodog_fx_exp, hFdCngEnc->msLogPeriodog_fx, hFdCngEnc->hFdCngCom->npart );

    /* Call the minimum statistics routine for noise estimation */
#ifdef FIX_2485_HARMONIZE_minimum_statistics
    minimum_statistics_fx(
        hFdCngEnc->hFdCngCom->npart,
        nFFTpart,
        hFdCngEnc->hFdCngCom->psize_norm,
        hFdCngEnc->msLogPeriodog_fx,
        ( element_mode == 0 ) ? ( (void *) hFdCngEnc->msNoiseFloor_fx ) : ( (void *) hFdCngEnc->msNoiseFloor_32fx ),
        ( element_mode == 0 ) ? ( (void *) hFdCngEnc->msLogNoiseEst_fx ) : ( (void *) hFdCngEnc->msLogNoiseEst_32fx ),
        hFdCngEnc->msAlpha_fx,
        hFdCngEnc->msPsd_fx,
        hFdCngEnc->msPsdFirstMoment_fx,
        hFdCngEnc->msPsdSecondMoment_fx,
        hFdCngEnc->msMinBuf_fx,
        hFdCngEnc->msBminWin_fx,
        hFdCngEnc->msBminSubWin_fx,
        hFdCngEnc->msCurrentMin_fx,
        hFdCngEnc->msCurrentMinOut_fx,
        hFdCngEnc->msCurrentMinSubWindow_fx,
        hFdCngEnc->msLocalMinFlag,
        hFdCngEnc->msNewMinFlag,
        hFdCngEnc->msPeriodogBuf_fx,
        &( hFdCngEnc->msPeriodogBufPtr ),
        hFdCngEnc->hFdCngCom,
        ( element_mode == 0 ) ? ( 0 ) : ( ENC ),
        ( element_mode == 0 ) ? ( 0 ) : ( ( hCPE == NULL ) ? 0 : hCPE->element_mode )
    );

     
    /* Expand MS outputs */
    IF( element_mode > 0 )
    {
        expand_range_fx( hFdCngEnc->msLogNoiseEst_32fx, hFdCngEnc->msNoiseEst_fx, &hFdCngEnc->msNoiseEst_fx_exp, hFdCngEnc->hFdCngCom->npart );
    }
    ELSE
    {
        expand_range( hFdCngEnc->msLogNoiseEst_fx, hFdCngEnc->msNoiseEst_fx, &hFdCngEnc->msNoiseEst_fx_exp, hFdCngEnc->hFdCngCom->npart );
    }
#else
    IF( element_mode > 0 )
    {
        minimum_statistics_fx(
@@ -2723,10 +2761,11 @@ void perform_noise_estimation_enc_fx(
        /* Expand MS outputs */
        expand_range( hFdCngEnc->msLogNoiseEst_fx, hFdCngEnc->msNoiseEst_fx, &hFdCngEnc->msNoiseEst_fx_exp, hFdCngEnc->hFdCngCom->npart );
    }
#endif /*FIX_2485_HARMONIZE_minimum_statistics*/

    return;
}
#endif
#endif /*FIX_2485_HARMONIZE_perform_noise_estimation_enc*/


/*-------------------------------------------------------------------*