Commit 27451d34 authored by janssontoftg's avatar janssontoftg
Browse files

Merge branch 'ericsson/low-rate-encoding-of-transients' into 'main'

[non-be] Contribution 20: Ericsson/low rate encoding of transients

See merge request !342
parents d3d73bde db0da7e6
Loading
Loading
Loading
Loading
Loading
+15 −1
Original line number Diff line number Diff line
@@ -215,8 +215,14 @@ ivas_error pre_proc_front_ivas(
    const int16_t flag_16k_smc,                                 /* i  : flag to indicate if the OL SMC is run at 16 kHz */
    const int16_t front_vad_flag,                               /* i  : front-VAD flag to overwrite VAD decision   */
    const int16_t force_front_vad,                              /* i  : flag to force VAD decision                 */
#ifdef LOW_RATE_TRANS
    const int16_t front_vad_dtx_flag,                           /* i  : front-VAD DTX flag to overwrite VAD decision*/
    const int32_t ivas_total_brate,                             /* i  : IVAS total bitrate                          */
    const int16_t ivas_format                                   /* i  : IVAS format */
#else
    const int16_t front_vad_dtx_flag                            /* i  : front-VAD DTX flag to overwrite VAD decision*/
   ,const int32_t ivas_total_brate                             /* i  : IVAS total bitrate                       */    
#endif
);

ivas_error pre_proc_ivas(
@@ -621,6 +627,14 @@ void set_transient_stereo(
    float currFlatness[]                                        /* i/o: current flatness                        */
);

#ifdef LOW_RATE_TRANS
int16_t transient_analysis(
    TRAN_DET_HANDLE hTranDet,                                   /* i  : handle transient detection             */
    const float cor_map_LT[],                                   /* i  : LT correlation map                     */
    const float multi_harm_limit                                /* i  : multi harminic threshold               */
);
#endif

void ivas_post_proc(
    SCE_DEC_HANDLE hSCE,                                        /* i/o: SCE decoder structure                   */
    CPE_DEC_HANDLE hCPE,                                        /* i/o: CPE decoder structure                   */
+1 −0
Original line number Diff line number Diff line
@@ -155,6 +155,7 @@
#define FIX_I59_DELAY_ROUNDING                          /* Issue 59: rounding in sample domain instead of nanosec for IVAS_ENC_GetDelay() and IVAS_DEC_GetDelay() */
#define FIX_FIX_I59                                     /* Issue 59:  small fix concerning LFE delay rounding */
#define FIX_I59_CREND                                   /* Issue 59: Fixes for gcc compiler warnings in ivas_crend_utest_utils.c */
#define LOW_RATE_TRANS                                  /* Eri: Contribution 20: low rate encoding of transients */

/* ################## End DEVELOPMENT switches ######################### */
/* clang-format on */
+42 −2
Original line number Diff line number Diff line
@@ -45,6 +45,14 @@
#include <math.h>


#ifdef LOW_RATE_TRANS
/*---------------------------------------------------------------*
 * Local constants
 *---------------------------------------------------------------*/

#define SCE_SMC_THR 16000
#endif

/*-------------------------------------------------------------------*
 * Local function prototypes
 *--------------------------------------------------------------------*/
@@ -100,9 +108,15 @@ ivas_error pre_proc_front_ivas(
    const int16_t flag_16k_smc,                                /* i  : flag to indicate if the OL SMC is run at 16 kHz */
    const int16_t front_vad_flag,                              /* i  : front-VAD flag to overwrite VAD decision */
    const int16_t force_front_vad,                             /* i  : flag to force VAD decision               */
#ifdef LOW_RATE_TRANS
    const int16_t front_vad_dtx_flag, /* i  : front-VAD DTX flag to overwrite VAD decision*/
    const int32_t ivas_total_brate,   /* i  : IVAS total bitrate - for setting the DTX */
    const int16_t ivas_format         /* i  : IVAS format */
#else
    const int16_t front_vad_dtx_flag /* i  : front-VAD DTX flag to overwrite VAD decision*/
    ,
    const int32_t ivas_total_brate /* i  : IVAS total bitrate - for setting the DTX */
#endif
)
{
    float *inp_12k8, *new_inp_12k8;        /* pointers to current frame and new data       */
@@ -784,7 +798,11 @@ ivas_error pre_proc_front_ivas(
    else if ( element_mode != IVAS_CPE_MDCT )
    {
        /* SNR-based speech/music classification */
#ifdef LOW_RATE_TRANS
        if ( ( element_mode >= IVAS_CPE_DFT && element_brate >= IVAS_24k4 ) || ( element_mode == IVAS_SCE && element_brate >= SCE_SMC_THR ) )
#else
        if ( ( element_mode >= IVAS_CPE_DFT && element_brate >= IVAS_24k4 ) || ( element_mode == IVAS_SCE && element_brate >= 16000 ) )
#endif
        {
            if ( flag_16k_smc )
            {
@@ -802,7 +820,29 @@ ivas_error pre_proc_front_ivas(
                smc_dec = ivas_acelp_tcx20_switching( st, inp_12k8, wsp, non_staX, pitch_fr, voicing_fr, currFlatness, lsp_mid, stab_fac, res_cod_SNR_M, flag_16k_smc );
            }
        }

#ifdef LOW_RATE_TRANS
        /* Switch to ACELP for non-harmonic transient signals */
        else if ( ( ( ivas_format == STEREO_FORMAT && element_brate <= IVAS_16k4 ) || ( ivas_format == ISM_FORMAT && element_brate < SCE_SMC_THR ) ) && ( loc_harm[0] != 1 ) && smc_dec == MUSIC )
        {
            if ( element_mode == IVAS_SCE )
            {
                if ( transient_analysis( st->hTranDet, st->hNoiseEst->cor_map, st->hNoiseEst->multi_harm_limit ) )
                {
                    smc_dec = SPEECH;
                }
            }
            else if ( element_mode == IVAS_CPE_DFT )
            {
                for ( i = 0; i < CPE_CHANNELS; i++ )
                {
                    if ( smc_dec != SPEECH && transient_analysis( hCPE->hCoreCoder[i]->hTranDet, st->hNoiseEst->cor_map, st->hNoiseEst->multi_harm_limit ) )
                    {
                        smc_dec = SPEECH; /* overwrite initial music decision, intial SPEECH_MUSIC never changed */
                    }
                }
            }
        }
#endif
        /* 2nd stage speech/music classification (ACELP/GSC/TCX core selection) */
        ivas_smc_mode_selection( st, element_brate, smc_dec, *relE, *Etot, attack_flag, inp_12k8, S_map, flag_spitch );

+7 −0
Original line number Diff line number Diff line
@@ -426,10 +426,17 @@ ivas_error ivas_cpe_enc(

    for ( n = 0; n < n_CoreChannels; n++ )
    {
#ifdef LOW_RATE_TRANS
        error = pre_proc_front_ivas( NULL, hCPE, hCPE->element_brate, nb_bits_metadata, input_frame, n, old_inp_12k8[n], old_inp_16k[n], &Etot[n], &ener[n], &relE[n], A[n], Aw[n], epsP[n], lsp_new[n], lsp_mid[n],
                                     &vad_hover_flag[n], &attack_flag[n], realBuffer[n], imagBuffer[n], old_wsp[n], pitch_fr[n], voicing_fr[n], &loc_harm[n], &cor_map_sum[n], &vad_flag_dtx[n], enerBuffer[n],
                                     fft_buff[n], A[0], lsp_new[0], currFlatness[n], tdm_ratio_idx, fr_bands, Etot_LR, lf_E, localVAD_HE_SAD, band_energies_LR, 0, st_ivas->hSpar != NULL ? st_ivas->hSpar->front_vad_flag : 0, 0, 0,
                                     ivas_total_brate, st_ivas->hEncoderConfig->ivas_format );
#else
        error = pre_proc_front_ivas( NULL, hCPE, hCPE->element_brate, nb_bits_metadata, input_frame, n, old_inp_12k8[n], old_inp_16k[n], &Etot[n], &ener[n], &relE[n], A[n], Aw[n], epsP[n], lsp_new[n], lsp_mid[n],
                                     &vad_hover_flag[n], &attack_flag[n], realBuffer[n], imagBuffer[n], old_wsp[n], pitch_fr[n], voicing_fr[n], &loc_harm[n], &cor_map_sum[n], &vad_flag_dtx[n], enerBuffer[n],
                                     fft_buff[n], A[0], lsp_new[0], currFlatness[n], tdm_ratio_idx, fr_bands, Etot_LR, lf_E, localVAD_HE_SAD, band_energies_LR, 0, st_ivas->hSpar != NULL ? st_ivas->hSpar->front_vad_flag : 0, 0, 0,
                                     ivas_total_brate );
#endif
        if ( error != IVAS_ERR_OK )
        {
            return error;
+8 −0
Original line number Diff line number Diff line
@@ -147,11 +147,19 @@ ivas_error ivas_ism_enc(
         * Front Pre-processing
         *----------------------------------------------------------------*/

#ifdef LOW_RATE_TRANS
        error = pre_proc_front_ivas( hSCE, NULL, hSCE->element_brate, nb_bits_metadata[sce_id], input_frame, 0, old_inp_12k8[sce_id][0], old_inp_16k[sce_id][0],
                                     &Etot[sce_id][0], &ener[sce_id][0], &relE[sce_id][0], A[sce_id][0], Aw[sce_id][0], epsP[sce_id][0], lsp_new[sce_id][0], lsp_mid[sce_id][0],
                                     &vad_hover_flag[sce_id][0], &attack_flag[sce_id][0], realBuffer[sce_id][0], imagBuffer[sce_id][0], old_wsp[sce_id][0], pitch_fr[sce_id][0], voicing_fr[sce_id][0], &loc_harm[sce_id][0], &cor_map_sum[sce_id][0], &vad_flag_dtx[sce_id][0], enerBuffer[sce_id][0],
                                     fft_buff[sce_id][0], A[sce_id][0], lsp_new[sce_id][0], currFlatness[0], 0, fr_bands, Etot_LR, lf_E, localVAD_HE_SAD, NULL, 0, 0, 0, 0,
                                     st_ivas->hEncoderConfig->ivas_format, st_ivas->hEncoderConfig->ivas_total_brate );
#else
        error = pre_proc_front_ivas( hSCE, NULL, hSCE->element_brate, nb_bits_metadata[sce_id], input_frame, 0, old_inp_12k8[sce_id][0], old_inp_16k[sce_id][0],
                                     &Etot[sce_id][0], &ener[sce_id][0], &relE[sce_id][0], A[sce_id][0], Aw[sce_id][0], epsP[sce_id][0], lsp_new[sce_id][0], lsp_mid[sce_id][0],
                                     &vad_hover_flag[sce_id][0], &attack_flag[sce_id][0], realBuffer[sce_id][0], imagBuffer[sce_id][0], old_wsp[sce_id][0], pitch_fr[sce_id][0], voicing_fr[sce_id][0], &loc_harm[sce_id][0], &cor_map_sum[sce_id][0], &vad_flag_dtx[sce_id][0], enerBuffer[sce_id][0],
                                     fft_buff[sce_id][0], A[sce_id][0], lsp_new[sce_id][0], currFlatness[0], 0, fr_bands, Etot_LR, lf_E, localVAD_HE_SAD, NULL, 0, 0, 0, 0,
                                     st_ivas->hEncoderConfig->ivas_total_brate );
#endif
        if ( error != IVAS_ERR_OK )
        {
            return error;
Loading