Commit cc39ccba authored by Jan Kiene's avatar Jan Kiene
Browse files

Merge branch 'main' into ci/updates-from-float-repo

parents b108933e 3643a7a8
Loading
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -40,6 +40,9 @@
#include "prot.h"
#include "rom_com.h"
#include "wmc_auto.h"
#ifdef IVAS_FLOAT_FIXED
#include "prot_fx2.h"
#endif

/*---------------------------------------------------------------------*
 * IGF_ApplyTransFac_flt()
@@ -504,6 +507,12 @@ static void IGF_gridSetUp_flt(
        hGrid->sfbWrap[t] = 0;
    }

#ifdef IVAS_FLOAT_FIXED
    hGrid->fFactor = float_to_fix16(hGrid->fFactor_flt, Q14);
    hGrid->lFactor = float_to_fix16(hGrid->lFactor_flt, Q14);
    hGrid->gFactor = float_to_fix16(hGrid->gFactor_flt, Q14);
#endif

    return;
}

+2 −0
Original line number Diff line number Diff line
@@ -64,6 +64,7 @@
#define SQRT2                                   1.414213562373095f
#define SQRT2_FIXED                             1518500250 // Q30
#define SQRT2_OVER_2                            (SQRT2 / 2.0f)
#define SQRT2_OVER_2_FIXED                      1518500250 // Q31

#define INV_SQRT2                               7.071067811865475e-1f /* 1/sqrt(2) */
#define INV_SQRT3                               0.577350269189626f    /* 1/sqrt(3) */
@@ -1544,6 +1545,7 @@ typedef enum
#define HRTF_NUM_BINS                           60
#define REVERB_PREDELAY_MAX                     20                          /* Max input delay for reverb module */
#define GAIN_LFE                                1.88364911f                 /* Gain applied to LFE during renderering */
#define GAIN_LFE_WORD32                         2022552831                 /* Gain applied to LFE during renderering */
#ifdef IVAS_FLOAT_FIXED
#define GAIN_LFE_FX                             30862                 /* Gain applied to LFE during renderering */
#endif // IVAS_FLOAT_FIXED
+74 −0
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@
#include "ivas_prot.h"
#include "wmc_auto.h"
#include "prot.h"
#include "prot_fx2.h"

/*-----------------------------------------------------------------------------------------*
 * Local constants
@@ -65,6 +66,52 @@ static float ivas_calculate_update_factor(
}


#ifdef IVAS_FLOAT_FIXED
/*-----------------------------------------------------------------------------------------*
 * Function ivas_calculate_smoothning_factor_fx()
 *
 * To calculate the Smoothning factor
 *-----------------------------------------------------------------------------------------*/

static void ivas_calculate_smoothning_factor_fx(
    Word32 *Smoothing_factor,
    Word32 update_factor,
    const Word16 min_pool_size,
    const Word32 max_update_rate,
    const COV_SMOOTHING_TYPE smooth_mode,
    const Word32 ivas_total_brate,
    Word16 j )
{
    Word32 smooth_fact, L_tmp = 0;
    Word16 tmp, exp_diff = 0;

    tmp = BASOP_Util_Divide3232_Scale( update_factor, L_shl( L_deposit_l( min_pool_size ), Q22 ), &exp_diff ); // (Q15 - exp_diff)
    *Smoothing_factor = L_shl_sat( L_deposit_l( tmp ), ( Q15 + exp_diff ) );                                   // Q30

    IF( NE_32( smooth_mode, COV_SMOOTH_MC ) )
    {
        IF( LT_32( ivas_total_brate, IVAS_24k4 ) )
        {
            smooth_fact = (Word32) ( 0.5f * ONE_IN_Q31 );
        }
        ELSE
        {
            smooth_fact = (Word32) ( 0.75f * ONE_IN_Q31 );
        }

        L_tmp = Mpy_32_16_1( smooth_fact, add( j, 1 ) );           // (Q31 , Q0) -> Q16
        *Smoothing_factor = Mpy_32_32( *Smoothing_factor, L_tmp ); // (Q30, Q16) -> Q15
        *Smoothing_factor = L_shl_sat( *Smoothing_factor, Q15 );   // Q30
    }

    IF( *Smoothing_factor > max_update_rate ) // Q30
    {
        *Smoothing_factor = max_update_rate;
    }

    return;
}
#else
/*-----------------------------------------------------------------------------------------*
 * Function ivas_calculate_smoothning_factor()
 *
@@ -102,6 +149,7 @@ static void ivas_calculate_smoothning_factor(

    return;
}
#endif


/*-----------------------------------------------------------------------------------------*
@@ -120,13 +168,23 @@ static void ivas_set_up_cov_smoothing(
{
    int16_t j;
    float update_factor;
#ifdef IVAS_FLOAT_FIXED
    Word32 update_factor_fx, max_update_rate_fx;
    max_update_rate_fx = (Word32) ( max_update_rate * ONE_IN_Q30 );
#endif
    if ( smooth_mode == COV_SMOOTH_MC )
    {
        for ( j = 0; j < pFb->filterbank_num_bands; j++ )
        {
            int16_t active_bins = pFb->fb_bin_to_band.pFb_active_bins_per_band[j];
            update_factor = ivas_calculate_update_factor( pFb->fb_bin_to_band.pFb_bin_to_band[j], active_bins );
#ifdef IVAS_FLOAT_FIXED
            update_factor_fx = (Word32) ( update_factor * ONE_IN_Q22 );
            ivas_calculate_smoothning_factor_fx( &hCovState->pSmoothing_factor_fx[j], update_factor_fx, min_pool_size, max_update_rate_fx, smooth_mode, ivas_total_brate, j );
            hCovState->pSmoothing_factor[j] = (float) hCovState->pSmoothing_factor_fx[j] / ONE_IN_Q30;
#else
            ivas_calculate_smoothning_factor( &hCovState->pSmoothing_factor[j], update_factor, min_pool_size, max_update_rate, smooth_mode, ivas_total_brate, j );
#endif
        }
    }
    else
@@ -136,7 +194,13 @@ static void ivas_set_up_cov_smoothing(
            float *p_bin_to_band = pFb->fb_bin_to_band.pp_short_stride_bin_to_band[j];
            int16_t active_bins = pFb->fb_bin_to_band.p_short_stride_num_bins_per_band[j];
            update_factor = ivas_calculate_update_factor( p_bin_to_band, active_bins );
#ifdef IVAS_FLOAT_FIXED
            update_factor_fx = (Word32) ( update_factor * ONE_IN_Q22 );
            ivas_calculate_smoothning_factor_fx( &hCovState->pSmoothing_factor_fx[j], update_factor_fx, min_pool_size, max_update_rate_fx, smooth_mode, ivas_total_brate, j );
            hCovState->pSmoothing_factor[j] = (float) hCovState->pSmoothing_factor_fx[j] / ONE_IN_Q30;
#else
            ivas_calculate_smoothning_factor( &hCovState->pSmoothing_factor[j], update_factor, min_pool_size, max_update_rate, smooth_mode, ivas_total_brate, j );
#endif
        }
    }

@@ -173,6 +237,12 @@ ivas_error ivas_spar_covar_smooth_enc_open(
    {
        return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR COV encoder" );
    }
#ifdef IVAS_FLOAT_FIXED
    IF( ( hCovState->pSmoothing_factor_fx = (Word32 *) malloc( sizeof( Word32 ) * cov_smooth_cfg->max_bands ) ) == NULL )
    {
        return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR COV encoder Fixed" );
    }
#endif

    for ( i = 0; i < nchan_inp; i++ )
    {
@@ -214,6 +284,10 @@ void ivas_spar_covar_smooth_enc_close(
    {
        free( hCovState->pSmoothing_factor );
        hCovState->pSmoothing_factor = NULL;
#ifdef IVAS_FLOAT_FIXED
        free( hCovState->pSmoothing_factor_fx );
        hCovState->pSmoothing_factor_fx = NULL;
#endif

        for ( i = 0; i < nchan_inp; i++ )
        {
+5 −0
Original line number Diff line number Diff line
@@ -1551,6 +1551,11 @@ float stereo_dft_dmx_swb_nrg(
    const int16_t frame_length                                  /* i  : frame lanegth                       */
);

#ifdef IVAS_FLOAT_FIXED
Word16 stereo_dft_sg_recovery_fx(
    STEREO_DFT_DEC_DATA_HANDLE hStereoDft /* i/o: Decoder DFT stereo handle      */
);
#endif
int16_t stereo_dft_sg_recovery(
    STEREO_DFT_DEC_DATA_HANDLE hStereoDft                       /* i/o: Decoder DFT stereo handle           */
);
+69 −0
Original line number Diff line number Diff line
@@ -378,6 +378,31 @@ void init_tcx_info_fx(
    Word16 *L_spec                /* o  : spectrum length                                                  */
);

void decoder_tcx_IGF_mono_fx(
    Decoder_State *st,                                         /* i/o: coder memory state                      */
    Word32 x_fx[],                                             /* o  : de-quatized coefficients                */
    Word16 *x_e,                                               /* o  : de-quatized coefficients exponent       */
    Word16 *x_len,                                             /* o  : de-quatized coefficients length         */
    const Word16 L_frame,                                      /* i  : frame length                            */
    const Word16 left_rect,                                    /* i  : left part is rectangular                */
    const Word16 bfi,                                          /* i  : bad frame indicator                     */
    const Word16 frame_cnt                                     /* i  : frame counter in the super_frame        */
);

void decoder_tcx_IGF_stereo_fx(
    Decoder_State **sts,                     /* i/o: coder memory states                    */
    STEREO_MDCT_DEC_DATA_HANDLE hStereoMdct, /* i/o: MDCT stereo structure                  */
    Word16 ms_mask[NB_DIV][MAX_SFB],         /* i  : bandwise MS mask                       */
    Word32 *x_fx[CPE_CHANNELS][NB_DIV],      /* i/o: de-quatized coefficients               */
    Word16 x_e[CPE_CHANNELS][NB_DIV],        /* i/o: de-quatized coefficients exponents     */
    Word16 x_len[CPE_CHANNELS][NB_DIV],      /* o  : length of de-quantized coefficients    */
    const Word16 L_frame,                    /* i  : frame length                           */
    const Word16 left_rect,                  /* i  : left part is rectangular               */
    const Word16 k,                          /* i  : Subframe index                         */
    const Word16 bfi,                        /* i  : bad frame indicator                    */
    const Word16 MCT_flag                    /* i  : hMCT handle allocated (1) or not (0)   */
);

void IGFDecReplicateTCX10State_fx(
    IGF_DEC_INSTANCE_HANDLE hIGFDec /* i/o: instance handle of IGF Decoder          */
);
@@ -1529,4 +1554,48 @@ void synchonize_channels_mdct_sid_fx(
    Decoder_State *sts[CPE_CHANNELS],                           /* i/o: decoder state structure                 */
    const Word16 n                                             /* i  : channel number                          */
);

void ivas_interpolate_3_over_1_allpass_fx(
    const Word16 *input_fx,         /* i  : input signal            */ /* Q_input */
    const Word16 len,               /* i  : number of input samples */
    Word16 *out_fx,                 /* o  : output signal           */ /* Q_input */
    Word16 *mem_fx                  /* i/o: memory                  */ /* Q_input */
);

void ivas_wb_tbe_dec_fx(
    Decoder_State *st_fx,     /* i/o: decoder state structure         */
    const Word16 coder_type,  /* i  : coding type                     */
    Word32 *bwe_exc_extended, /* i  : bandwidth extended exciatation 2*Q_exc*/
    const Word16 Q_exc,
    const Word16 voice_factors[], /* i  : voicing factors                 */
    Word16 *synth,                /* o  : WB synthesis/final synthesis    */
    Word16 *Q_synth );

void ivas_GenShapedWBExcitation_fx(
    Word16 *excSHB,                   /* o : synthesized shaped shb exctiation Q_bwe_exc*/
    const Word16 *lpc_shb,            /* i : lpc coefficients Q12*/
    Word16 *exc4kWhtnd,               /* o : whitened synthesized shb excitation Q_bwe_exc*/
    Word32 *mem_csfilt,               /* i/o : memory Q_bwe_exc+16*/
    Word16 *mem_genSHBexc_filt_down1, /* i/o : memory Q_bwe_exc*/
    Word16 *mem_genSHBexc_filt_down2, /* i/o : memory Q_bwe_exc*/
    Word16 *mem_genSHBexc_filt_down3, /* i/o : memory Q_bwe_exc*/
    Word16 *state_lpc_syn,            /* i/o : memory Q_bwe_exc*/
    const Word16 coder_type,          /* i : coding type */
    const Word16 *bwe_exc_extended,   /* i : bwidth extended exciatation Q_bwe_exc*/
    const Word16 Q_bwe_exc,
    Word16 bwe_seed[],            /* i/o : random number generator seed */
    const Word16 voice_factors[], /* i : voicing factor Q15*/
    const Word16 uv_flag,         /* i : unvoiced flag */
    const Word16 igf_flag );

Word16 ivas_wb_bwe_dec_fx(
    Decoder_State *st_fx,           /* i/o: decoder state structure                 */
    const Word16 output[],          /* i  : suntehsis @ internal Fs */
    Word16 *synth_fx,               /* i/o: ACELP core synthesis/final synthesis    */
    Word16 *hb_synth_fx,            /* o  : SHB synthesis/final synthesis           */
    const Word16 use_cldfb_for_dft, /* i  : flag to use of CLDFB for DFT Stereo     */
    const Word16 output_frame,      /* i  : frame length                            */
    Word16 *voice_factors_fx,       /* i  : voicing factors                         */
    const Word16 pitch_buf_fx[],    /* i  : pitch buffer                            */
    Word16 *Qpost );
#endif
Loading