Commit b9836c5a authored by Fabian Bauer's avatar Fabian Bauer
Browse files

add macro HARMONIZE_2553_TonalConceal_Init and code

parent f18f1d14
Loading
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -98,6 +98,7 @@
#define FIX_BASOP_2546_HARMONIZE_TCX_SCALAR             /* FhG: Fix issue 2546 Harmonize function tcx_scalar_quantization_rateloop*/
#define FIX_BASOP_2532_cx_e                             /* FhG: Fix issue 2532 about additional exponent variable*/
#define HARMONIZE_2553_TonalConceal_Apply               /* FhG: Harmonize TonalMDCTConceal_Apply with its ivas derivate */
#define HARMONIZE_2553_TonalConceal_Init                /* FhG: Harmonize TonalMDCTConceal_Init with its ivas derivate */
#define HARMONIZE_2543_SQ_gain                          /* FhG: Harmonize SQ_gain */
#define FIX_ISSUE_2533_EXTRA_CONDITION                  /* FhG: Fix issue basop 2533 removing the extra condition*/
#define HARMONIZE_2537_SetTCXModeInfo                   /* FhG: Harmonize SetTCXModeInfo  - IVAS_VERSION OBVIOUSLY NOT FITTING FOR EVS - pipes not green */
+8 −2
Original line number Diff line number Diff line
@@ -5642,6 +5642,7 @@ void RefineTonalComponents_fx(
    const Word16 element_mode,
    const PsychoacousticParameters *psychParamsCurrent );

#ifndef HARMONIZE_2553_TonalConceal_Init
ivas_error TonalMDCTConceal_Init_fx(
    TonalMDCTConcealPtr self,
    const Word16 nSamples,
@@ -5649,14 +5650,19 @@ ivas_error TonalMDCTConceal_Init_fx(
    const Word16 nScaleFactors,
    TCX_CONFIG_HANDLE hTcxCfg /* TCX config */
);
#endif

#ifdef HARMONIZE_2553_TonalConceal_Init
ivas_error TonalMDCTConceal_Init_fx(
    Word16 element_mode,
#else
ivas_error TonalMDCTConceal_Init_ivas_fx(
#endif
    TonalMDCTConcealPtr hTonalMDCTConc,
    const UWord16 nSamples,
    const UWord16 nSamplesCore,
    const UWord16 nScaleFactors,
    TCX_CONFIG_HANDLE hTcxCfg /* TCX config */
);
    TCX_CONFIG_HANDLE hTcxCfg );

/* Must be called only when a good frame is recieved - concealment is inactive */
void TonalMDCTConceal_SaveFreqSignal_fx(
+8 −0
Original line number Diff line number Diff line
@@ -907,7 +907,11 @@ void open_decoder_LPD_fx(
        st->hTonalMDCTConc->lastBlockData.nSamples = 0;
        move16();

#ifdef HARMONIZE_2553_TonalConceal_Init
        TonalMDCTConceal_Init_fx( st->element_mode, st->hTonalMDCTConc, hTcxDec->L_frameTCX, st->L_frame, FDNS_NPTS, st->hTcxCfg );
#else
        TonalMDCTConceal_Init_fx( st->hTonalMDCTConc, hTcxDec->L_frameTCX, st->L_frame, FDNS_NPTS, st->hTcxCfg );
#endif
    }
    st->last_tns_active = 0;
    move16();
@@ -1962,7 +1966,11 @@ void open_decoder_LPD_ivas_fx(
        move16();
        st->hTonalMDCTConc->lastBlockData.nSamples = 0;
        move16();
#ifdef HARMONIZE_2553_TonalConceal_Init
        TonalMDCTConceal_Init_fx( st->element_mode, st->hTonalMDCTConc, st->hTcxDec->L_frameTCX, st->L_frame, FDNS_NPTS, st->hTcxCfg );
#else
        TonalMDCTConceal_Init_ivas_fx( st->hTonalMDCTConc, st->hTcxDec->L_frameTCX, st->L_frame, FDNS_NPTS, st->hTcxCfg );
#endif
    }

    st->last_tns_active = 0;
+54 −1
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ static void FindPhaseDifferences( TonalMDCTConcealPtr const hTonalMDCTConc, Word
/*-------------- public functions -------------------- */
/*******************************************************/

#ifndef HARMONIZE_2553_TonalConceal_Init
ivas_error TonalMDCTConceal_Init_fx(
    TonalMDCTConcealPtr hTonalMDCTConc,
    const Word16 nSamples,
@@ -112,9 +113,15 @@ ivas_error TonalMDCTConceal_Init_fx(

    return IVAS_ERR_OK;
}
#endif


#ifdef HARMONIZE_2553_TonalConceal_Init
ivas_error TonalMDCTConceal_Init_fx(
    Word16 element_mode,
#else
ivas_error TonalMDCTConceal_Init_ivas_fx(
#endif
    TonalMDCTConcealPtr hTonalMDCTConc,
    const UWord16 nSamples,
    const UWord16 nSamplesCore,
@@ -132,6 +139,7 @@ ivas_error TonalMDCTConceal_Init_ivas_fx(

    hTonalMDCTConc->tcx_cfg = hTcxCfg;
    hTonalMDCTConc->lastBlockData.spectralData = hTonalMDCTConc->spectralDataBuffers[0];
#ifndef HARMONIZE_2553_TonalConceal_Init
    set16_fx( hTonalMDCTConc->lastBlockData.spectralData, 0, L_FRAME_MAX );
    move16();
    hTonalMDCTConc->secondLastBlockData.spectralData = hTonalMDCTConc->spectralDataBuffers[1];
@@ -147,6 +155,26 @@ ivas_error TonalMDCTConceal_Init_ivas_fx(
    hTonalMDCTConc->secondLastBlockData.scaleFactors = hTonalMDCTConc->scaleFactorsBuffers[1];
    set16_fx( hTonalMDCTConc->secondLastBlockData.scaleFactors, 0, FDNS_NPTS );
    move16();
#else
    IF( GT_16( element_mode, EVS_MONO ) )
    {
        set16_fx( hTonalMDCTConc->lastBlockData.spectralData, 0, L_FRAME_MAX );
        move16();
        set16_fx( hTonalMDCTConc->secondLastBlockData.spectralData, 0, L_FRAME_MAX );
        move16();
        hTonalMDCTConc->secondLastPowerSpectrum_exp = hTonalMDCTConc->secondLastBlockData.spectralData_exp;
        move16();
        set16_fx( hTonalMDCTConc->lastBlockData.scaleFactors, 0, FDNS_NPTS );
        move16();
        hTonalMDCTConc->secondLastBlockData.scaleFactors = hTonalMDCTConc->scaleFactorsBuffers[1];
        set16_fx( hTonalMDCTConc->secondLastBlockData.scaleFactors, 0, FDNS_NPTS );
        move16();
    }
    hTonalMDCTConc->secondLastBlockData.spectralData = hTonalMDCTConc->spectralDataBuffers[1];
    hTonalMDCTConc->secondLastPowerSpectrum = hTonalMDCTConc->secondLastBlockData.spectralData;
    move16();
    hTonalMDCTConc->lastBlockData.scaleFactors = hTonalMDCTConc->scaleFactorsBuffers[0];
#endif
    hTonalMDCTConc->lastBlockData.scaleFactors_exp = hTonalMDCTConc->scaleFactorsBuffers_exp[0];
    move16();
    hTonalMDCTConc->secondLastBlockData.scaleFactors_exp = hTonalMDCTConc->scaleFactorsBuffers_exp[1];
@@ -183,6 +211,7 @@ ivas_error TonalMDCTConceal_Init_ivas_fx(
    move16();
    hTonalMDCTConc->nScaleFactors = nScaleFactors;
    move16();
#ifndef HARMONIZE_2553_TonalConceal_Init

    set32_fx( hTonalMDCTConc->scaleFactorsBackground_fx, 0, FDNS_NPTS );
    hTonalMDCTConc->scf_fadeout = 16384 /*1.000000 Q14*/;
@@ -202,14 +231,39 @@ ivas_error TonalMDCTConceal_Init_ivas_fx(
    move16();
    hTonalMDCTConc->faded_signal_nrg_exp = 0;
    move16();
#else
    IF( GT_16( element_mode, EVS_MONO ) )
    {
        set32_fx( hTonalMDCTConc->scaleFactorsBackground_fx, 0, FDNS_NPTS );
        hTonalMDCTConc->scf_fadeout = 16384 /*1.000000 Q14*/;
        PsychoacousticParameters_Init_fx( INT_FS_16k, L_FRAME16k, 64, 1, 1, &hTonalMDCTConc->psychParamsTCX20 );
        PsychoacousticParameters_Init_fx( INT_FS_16k, L_FRAME16k / 2, 64, 0, 1, &hTonalMDCTConc->psychParamsTCX10 );
        hTonalMDCTConc->psychParams = NULL;

        hTonalMDCTConc->last_block_nrg = 0;
        move16();
        hTonalMDCTConc->last_block_nrg_exp = 0;
        move16();
        hTonalMDCTConc->curr_noise_nrg = 0;
        move16();
        hTonalMDCTConc->curr_noise_nrg_exp = 0;
        move16();
        hTonalMDCTConc->faded_signal_nrg = 0;
        move16();
        hTonalMDCTConc->faded_signal_nrg_exp = 0;
        move16();
        set16_fx( hTonalMDCTConc->timeDataBuffer, 0, ( 3 * L_FRAME_MAX ) / 2 );
    }
#endif
    /* Offset the pointer to the end of buffer, so that pTCI is not destroyed when
       new time samples are stored in lastPcmOut */
    move16();
    move16();
    /* just the second half of the second last pcm output is needed */

#ifndef HARMONIZE_2553_TonalConceal_Init
    set16_fx( hTonalMDCTConc->timeDataBuffer, 0, ( 3 * L_FRAME_MAX ) / 2 );
#endif
    hTonalMDCTConc->secondLastPcmOut = &hTonalMDCTConc->timeDataBuffer[( 3 * L_FRAME_MAX ) / 2 - ( 3 * s_min( L_FRAME_MAX, nSamples ) / 2 )];
    hTonalMDCTConc->lastPcmOut = &hTonalMDCTConc->timeDataBuffer[( 3 * L_FRAME_MAX ) / 2 - s_min( L_FRAME_MAX, nSamples )];
    /* If the second last frame was lost, we reuse saved TonalComponentsInfo and don't update pcm buffers */
@@ -218,7 +272,6 @@ ivas_error TonalMDCTConceal_Init_ivas_fx(
    return IVAS_ERR_OK;
}


void TonalMDCTConceal_SaveFreqSignal_fx(
    TonalMDCTConcealPtr hTonalMDCTConc,
    const Word32 *mdctSpectrum, // Q31-mdctSpectrum_exp