Commit 6c9bed1a authored by Arash Azizi's avatar Arash Azizi
Browse files

Merge branch 'main' into basop-2446-harmonize-functions-con_tcx_fx-and-con_tcx_ivas_fx

parents e5cccd2b 795fb29d
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -2791,6 +2791,7 @@ void DoRTFTn_fx_ivas(
    return;
}

#ifndef HQ_ALIGN_DUPLICATED_CODE
void fft3_fx_ivas(
    const Word32 X[], // Qx
    Word32 Y[],       // Qx
@@ -3287,7 +3288,7 @@ void ifft3_fx_ivas(

    return;
}

#endif

static void rfft_post(
    const Word16 *sine_table, // Q15
+24 −0
Original line number Diff line number Diff line
@@ -2640,7 +2640,22 @@ void enforce_zero_for_min_envelope_fx(
    return;
}

#ifdef HQ_ALIGN_DUPLICATED_CODE
/*--------------------------------------------------------------------------*
 * apply_envelope()
 *
 * Apply spectral envelope without envelope adjustments and noisefill
 *--------------------------------------------------------------------------*/

void apply_envelope_enc_fx(
    const Word16 *coeff,     /* i  : Normalized spectrum                    Q12 */
    const Word16 *norm,      /* i  : Envelope                               Q0  */
    const Word16 num_sfm,    /* i  : Total number of bands                  Q0  */
    const Word16 *sfm_start, /* i  : Sub band start indices                 Q0  */
    const Word16 *sfm_end,   /* i  : Sub band end indices                   Q0  */
    Word32 *coeff_out        /* o  : scaled spectrum                        Q12 */
)
#else
/*--------------------------------------------------------------------------*
 * apply_envelope()
 *
@@ -2655,6 +2670,7 @@ void apply_envelope_enc_ivas_fx(
    const Word16 *sfm_end,   /* i  : Sub band end indices                   Q0  */
    Word32 *coeff_out        /* o  : coded/noisefilled spectrum             Q12 */
)
#endif
{
    Word16 i;
    Word16 sfm;
@@ -2680,11 +2696,19 @@ void apply_envelope_enc_ivas_fx(
}


#ifdef HQ_ALIGN_DUPLICATED_CODE
/*--------------------------------------------------------------------------*
 * apply_envelope_fx()
 *
 * Apply spectral envelope with envelope adjustments
 *--------------------------------------------------------------------------*/
#else
/*--------------------------------------------------------------------------*
 * apply_envelope()
 *
 * Apply spectral envelope with envelope adjustments
 *--------------------------------------------------------------------------*/
#endif

void apply_envelope_fx(
    const Word16 *coeff,     /* i/o: Coded/noisefilled normalized spectrum  Q12 */
+5 −3
Original line number Diff line number Diff line
@@ -1879,6 +1879,7 @@ void TonalMDCTConceal_Detect_ivas_fx(
);


#ifndef HARMONIZE_FUNC
void ivas_DetectTonalComponents_fx(
    Word16 indexOfTonalPeak[],
    Word16 lowerIndex[],
@@ -1899,7 +1900,7 @@ void ivas_DetectTonalComponents_fx(
    const PsychoacousticParameters *psychParamsCurrent,
    Word16 element_mode 
);

#endif
ivas_error stereo_dft_dec_create_fx(
    STEREO_DFT_DEC_DATA_HANDLE *hStereoDft,                     /* i/o: decoder DFT stereo handle               */
    const Word32 element_brate,                                 /* i  : element bitrate                         */
@@ -2721,14 +2722,15 @@ void ivas_param_mc_metadata_open_fx(
    HANDLE_IVAS_PARAM_MC_METADATA hMetadataPMC                  /* o  : handle for the Parametric MC parameter coding state */
);

#ifndef HQ_ALIGN_DUPLICATED_CODE
Word16 mdct_classifier_ivas_fx(
    Encoder_State *st,                                          /* i/o: Encoder state variable                  */
    const Word16 *fft_buff,                                     /* i  : FFT spectrum from fft_rel               */
    const Word32 enerBuffer[],                                  /* i  : energy buffer                           */
    Word16 enerBuffer_exp,                                      /* i: enenrgy buffer exponent                   */
    Word16 enerBuffer_exp,                                      /* i  : energy buffer exponent                  */
    const Word32 brate                                          /* i  : current brate, IVAS: nominal bitrate, EVS: st->total_brate */
);

#endif

/*----------------------------------------------------------------------------------*
 * Range Coder prototypes
+4 −0
Original line number Diff line number Diff line
@@ -91,7 +91,9 @@
#define HARM_2456_APPLY_SCALE                           /* FhG basop issue 2456: Harmonize apply_scale_ind(), apply_scale_ivas_fx() */
#define HARM_2454_TCX_RES_Q_SPEC                        /* FhG: harmonization of tcx_res_Q_spec_fx() and tcx_res_Q_spec_ivas_fx() */
#define FIX_FLOAT_1535_ARI_RES_Q_CLEANUP                /* FhG: remove dead code from tcx_ari_res_Q_spec() */
#define HQ_ALIGN_DUPLICATED_CODE                        /* Eri: Align duplicated code */
#define FIX_2467_RENAME_GSC_FUNCTION                    /* VA: basop issue 2467: Removal of unused function/table and renaming of _ivas_fx versions to default ones. */
#define HARMONIZE_FUNC                                  /* VA: basop issue 2460: Remove duplicated code: various functions */

#define HARMONIZE_2446_CON_TCX_FX                       /* FhG: basop issue: 2446 harmonization of function con_tcx_fx() */
/* #################### End BE switches ################################## */
@@ -104,6 +106,8 @@
#define FIX_BASOP_2262_OLAP_BUFFER_SYNTH_SWITCHING      /* FhG: basop issue 2262: correct buffer update for FD-CNG buffer in case of BR switching */
#define FIX_2440_AGC_PRESCALING                         /* FhG: basop issue 2440: Fix loop bounds when scaling p_output_fx before ivas_spar_dec_agc_pca_fx() */
#define FIX_2471_REMOVE_POSSIBLE_OVRF                   /* VA: basop issue 2471: correcting undesired overflow */
#define FIX_2465_Q_BWE_EXC                              /* VA: basop issue 2465: fix calculation of Q_bwe_exc in SWB TBE encoder */

/* ##################### End NON-BE switches ########################### */

/* ################## End MAINTENANCE switches ######################### */
+86 −18
Original line number Diff line number Diff line
@@ -735,6 +735,16 @@ void enforce_zero_for_min_envelope_fx(
    const Word16 *sfm_end    /* i  : Sub band end indices               Q0  */
);

#ifdef HQ_ALIGN_DUPLICATED_CODE
void apply_envelope_enc_fx(
    const Word16 *coeff,     /* i  : Normalized spectrum                    Q12 */
    const Word16 *norm,      /* i  : Envelope                               Q0  */
    const Word16 num_sfm,    /* i  : Total number of bands                  Q0  */
    const Word16 *sfm_start, /* i  : Sub band start indices                 Q0  */
    const Word16 *sfm_end,   /* i  : Sub band end indices                   Q0  */
    Word32 *coeff_out        /* o  : scaled spectrum                        Q12 */
);
#else
void apply_envelope_enc_ivas_fx(
    const Word16 *coeff,     /* i/o: Coded/noisefilled normalized spectrum  Q12 */
    const Word16 *norm,      /* i  : Envelope                               Q0  */
@@ -743,6 +753,7 @@ void apply_envelope_enc_ivas_fx(
    const Word16 *sfm_end,   /* i  : Sub band end indices                   Q0  */
    Word32 *coeff_out        /* o  : coded/noisefilled spectrum             Q12 */
);
#endif

void apply_envelope_fx(
    const Word16 *coeff,     /* i  : Coded/noisefilled normalized spectrum      Q12 */
@@ -2308,6 +2319,7 @@ void E_UTIL_synthesis_fx(
    const Word16 update,
    const Word16 m );

#ifndef HARMONIZE_FUNC
void synth_mem_updt2(
    const Word16 L_frame,      /* i  : frame length                            */
    const Word16 last_L_frame, /* i  : frame length                            */
@@ -2317,15 +2329,18 @@ void synth_mem_updt2(
    Word16 mem_syn[],          /* o  : synthesis filter memory for find_target */
    const Word16 dec           /* i  : flag for decoder indication             */
);

void ivas_synth_mem_updt2_fx(
#else
void synth_mem_updt2_fx(
#endif
    const Word16 L_frame,      /* i  : frame length                            */
    const Word16 last_L_frame, /* i  : frame length                            */
    Word16 old_exc[],          /* i/o: excitation buffer                       */
    Word16 mem_syn_r[],        /* i/o: synthesis filter memory                 */
    Word16 mem_syn2[],         /* o  : synthesis filter memory for find_target */
    Word16 mem_syn[],          /* o  : synthesis filter memory for find_target */
    const Word16 dec );
    const Word16 dec           /* i  : flag for decoder indication             */
);

void lerp(
    const Word16 *f,
@@ -4281,7 +4296,7 @@ void ifft3_fx(
    const Word16[],
    Word16[],
    const Word16 );

#ifndef HQ_ALIGN_DUPLICATED_CODE
void fft3_fx_ivas(
    const Word32 X[],
    Word32 Y[],
@@ -4290,6 +4305,7 @@ void ifft3_fx_ivas(
    const Word32 X[],
    Word32 Y[],
    const Word16 n );
#endif

void r_fft_fx_lc(
    const Word16 *phs_tbl,  /* i  : Table of phase            */
@@ -5821,6 +5837,27 @@ void concealment_signal_tuning_fx(
    Word16 *outx_new_fx /*Qoutx_new_fx*/,
    const Word16 past_core );

#ifdef HARMONIZE_FUNC
void DetectTonalComponents_fx(
    Word16 indexOfTonalPeak[],
    Word16 lowerIndex[],
    Word16 upperIndex[],
    Word16 *pNumIndexes,
    const Word32 lastPitchLag,
    const Word32 currentPitchLag,
    const Word16 lastMDCTSpectrum[],
    const Word16 lastMDCTSpectrum_exp,
    const Word16 scaleFactors[],
    const Word16 scaleFactors_exp[],
    const Word16 scaleFactors_max_e,
    const Word32 secondLastPowerSpectrum[],
    const Word16 secondLastPowerSpectrum_e,
    const Word16 nSamples,
    const Word16 nSamplesCore,
    Word16 floorPowerSpectrum, /* i  : lower limit for power spectrum bins     */
    const PsychoacousticParameters *psychParamsCurrent,
    const Word16 element_mode );
#else
void DetectTonalComponents(
    Word16 indexOfTonalPeak[],
    Word16 lowerIndex[],
@@ -5858,8 +5895,13 @@ void RefineTonalComponents(
    const Word16 nSamplesCore,
    const Word16 floorPowerSpectrum, /* i: lower limit for power spectrum bins  */
    Word16 element_mode );
#endif

#ifdef HARMONIZE_FUNC
void RefineTonalComponents_fx(
#else
void ivas_RefineTonalComponents_fx(
#endif
    Word16 indexOfTonalPeak[],
    Word16 lowerIndex[],
    Word16 upperIndex[],
@@ -5878,9 +5920,10 @@ void ivas_RefineTonalComponents_fx(
    const Word16 nSamples,
    const Word16 nSamplesCore,
    const Word16 floorPowerSpectrum, /* i: lower limit for power spectrum bins  */
    Word16 element_mode,
    const Word16 element_mode,
    const PsychoacousticParameters *psychParamsCurrent );

#ifndef HARMONIZE_FUNC
ivas_error PsychoacousticParameters_Init(
    const Word32 sr_core,  /* i  : sampling rate of core-coder                                     */
    const Word16 nBins,    /* i  : Number of bins (spectral lines)                                 */
@@ -5888,8 +5931,8 @@ ivas_error PsychoacousticParameters_Init(
    const Word16 isTCX20,  /* i  : Flag indicating if the subband division is for TCX20 or TCX10   */
    const Word16 isWarped, /* i  : Flag indicating if the scale is linear or warped                */
    PsychoacousticParameters *pPsychParams );

ivas_error TonalMDCTConceal_Init(
#endif
ivas_error TonalMDCTConceal_Init_fx(
    TonalMDCTConcealPtr self,
    const Word16 nSamples,
    const Word16 nSamplesCore,
@@ -5906,7 +5949,7 @@ ivas_error TonalMDCTConceal_Init_ivas_fx(
);

/* Must be called only when a good frame is recieved - concealment is inactive */
void TonalMDCTConceal_SaveFreqSignal(
void TonalMDCTConceal_SaveFreqSignal_fx(
    TonalMDCTConcealPtr self,
    const Word32 *mdctSpectrum,
    const Word16 mdctSpectrum_exp,
@@ -5927,21 +5970,21 @@ void TonalMDCTConceal_SaveFreqSignal_ivas_fx(
    const Word16 gain_tcx_exp,
    const Word16 infoIGFStartLine );

void TonalMDCTConceal_UpdateState(
void TonalMDCTConceal_UpdateState_fx(
    TonalMDCTConcealPtr self,
    Word16 nNewSamples,
    Word32 pitchLag,
    Word16 badBlock,
    Word8 tonalConcealmentActive );
    const Word16 nNewSamples,
    const Word32 pitchLag,
    const Word16 badBlock,
    const Word8 tonalConcealmentActive );

void TonalMDCTConceal_Detect(
void TonalMDCTConceal_Detect_fx(
    const TonalMDCTConcealPtr self, /*IN */
    const Word32 pitchLag,          /*IN */
    Word16 *umIndices,              /*OUT*/
    Word16 element_mode             /* IN */
    const Word16 element_mode       /* IN */
);

void TonalMDCTConceal_Apply(
void TonalMDCTConceal_Apply_fx(
    const TonalMDCTConcealPtr hTonalMDCTConc, /*IN */
    Word32 *mdctSpectrum,                     /*IN/OUT*/
    Word16 *mdctSpectrum_exp                  /*IN */
@@ -5967,7 +6010,7 @@ void TonalMDCTConceal_InsertNoise_ivas_fx(
    const Word16 cngLevelBackgroundTrace_e,
    const Word16 crossOverFreq );

void TonalMDCTConceal_InsertNoise(
void TonalMDCTConceal_InsertNoise_fx(
    const TonalMDCTConcealPtr hTonalMDCTConc, /*IN */
    Word32 *mdctSpectrum,                     /*OUT*/
    Word16 *mdctSpectrum_exp,                 /*OUT*/
@@ -5977,7 +6020,7 @@ void TonalMDCTConceal_InsertNoise(
    Word16 crossfadeGain,
    const Word16 crossOverFreq );

void TonalMDCTConceal_SaveTimeSignal(
void TonalMDCTConceal_SaveTimeSignal_fx(
    TonalMDCTConcealPtr hTonalMDCTConc,
    Word16 *timeSignal,
    Word16 nNewSamples );
@@ -7570,6 +7613,31 @@ void stat_noise_uv_dec_fx(
    const Word16 uc_two_stage_flag /* i  : flag indicating two-stage UC                               */
);

#ifdef HQ_ALIGN_DUPLICATED_CODE
void stat_noise_uv_mod_fx(
    const Word16 element_mode, /* i  : element mode                                       */
    const Word16 coder_type,   /* i  : Coder type                                         */
    Word16 noisiness,          /* i  : noisiness parameter                            Q=0 */
    const Word16 *lsp_old,     /* i  : old LSP vector at 4th sfr                      Q=15*/
    const Word16 *lsp_new,     /* i  : LSP vector at 4th sfr                          Q=15*/
    const Word16 *lsp_mid,     /* i  : LSP vector at 2nd sfr                          Q=15*/
    Word16 *Aq,                /* o  : A(z)   quantized for the 4 subframes           Q=12*/
    Word16 *exc2,              /* i/o: excitation buffer                           Q=Q_exc*/
    Word16 *Q_exc,             /* i  : Q of exc2 excitation buffer [11..-1] expected      */
    const Word16 bfi,          /* i  : Bad frame indicator                                */
    Word32 *ge_sm,             /* i/o: smoothed excitation gain      Q=Q_stat_noise_ge (6)*/
    Word16 *uv_count,          /* i/o: unvoiced counter                                   */
    Word16 *act_count,         /* i/o: activation counter                                 */
    Word16 lspold_s[],         /* i/o: old LSP                                        Q=15*/
    Word16 *noimix_seed,       /* i/o: mixture seed                                 Q0    */
    Word16 *st_min_alpha,      /* i/o: minimum alpha                                  Q=15*/
    Word16 *exc_pe,            /* i/o: scale Q_stat_noise                   Q=Q_stat_noise*/
    const Word32 bitrate,      /* i  : core bitrate                                       */
    const Word16 bwidth_fx,    /* i  : i   bandwidth                                      */
    Word16 *Q_stat_noise,      /* i/o: noise scaling                                      */
    Word16 *Q_stat_noise_ge    /* i/o: noise scaling                                      */
);
#else
void stat_noise_uv_mod_fx(
    const Word16 coder_type, /* i  : Coder type                                   */
    Word16 noisiness,        /* i  : noisiness parameter                          Q0 */
@@ -7615,6 +7683,7 @@ void stat_noise_uv_mod_ivas_fx(
    Word16 *Q_stat_noise,    /* i/o: noise scaling                                      */
    Word16 *Q_stat_noise_ge  /* i/o: noise scaling                                      */
);
#endif

Word16 FEC_SinOnset_fx(
    Word16 *exc,          /* i/o : exc vector to modify                                           */
@@ -10610,7 +10679,6 @@ void UnmapIndex_fx(
    Word32 *Lag                    /* Q0 */
);

// #define GET_ADJ2( T, L, F ) ( ( ( L ) << ( F ) ) - ( T ) )
#define GET_ADJ2( T, L, F ) ( sub( shl( L, F ), T ) )

Word32 tcx_hm_render_fx(
Loading