Commit 227df44c authored by Nishant S Kulgod's avatar Nishant S Kulgod
Browse files

commit 2

parent 3ed09b5c
Loading
Loading
Loading
Loading
Loading
+26 −3
Original line number Diff line number Diff line
@@ -1043,6 +1043,15 @@ typedef enum
#define DIRAC_MONO_MIN_THRESH                    1e2f
#define DIRAC_MONO_FRAME_THRESH                    15 /* 30ms */


#define DIRAC_MONO_THRESH_SILENCE_FX				(Word32)3e4
#define DIRAC_MONO_NORM_FACTOR_FX					(Word64)1e13
#define DIRAC_MONO_ONE_ON_NORM_FACTOR_FX			(Word64)1/1e13
#define DIRAC_MONO_MAX_THRESH_FX					(Word32)1e6
#define DIRAC_MONO_MIN_THRESH_FX					(Word32)1e2
#define DIRAC_MONO_NORM_FACTOR_M                    1220703104
#define DIRAC_MONO_NORM_FACTOR_E                    44

typedef enum
{
    DIRAC_OPEN,                                 /* initialize to default value              */
@@ -1168,6 +1177,14 @@ enum
#define IVAS_PCA_THRES_MIN_DOT2                 0.0f
#define IVAS_PCA_THRES_DIST_ALT                 6.0f

#ifdef IVAS_FLOAT_FIXED
#define IVAS_PCA_QUAT_EPS_FX                    215 // Q31
#define IVAS_PCA_THRES_MIN_DOT_FX               1717986918 // 0.8 in Q31
#define IVAS_PCA_THRES_MIN_DOT2_FX              0
#define IVAS_PCA_THRES_DIST_ALT_FX              1610612736 // 6 in Q28
#endif


typedef enum
{
    PCA_MODE_ACTIVE = 0,
@@ -1289,11 +1306,17 @@ enum
#define MASA_COHERENCE_TOLERANCE                0.1f
#define MASA_COHERENCE_THRESHOLD                0.1f
#ifdef IVAS_FLOAT_FIXED
#define MASA_COHERENCE_TOLERANCE_FX            419430/*0.1 Q22*/
#define MASA_COHERENCE_THRESHOLD_FX             214748365 // 0.1 in Q31
#endif
#define MASA_RATIO_TOLERANCE                    0.1f
#define MASA_RATIO_THRESHOLD                    0.1f
#define MASA_ANGLE_TOLERANCE                    0.5f
#ifdef IVAS_FLOAT_FIXED
#define MASA_RATIO_THRESHOLD_FX                    214748365 // 0.1 in Q31
#define MASA_RATIO_TOLERANCE_FX                 419430/*0.1 Q22*/
#define MASA_ANGLE_TOLERANCE_FX                 ONE_IN_Q21/*0.5f q22*/
#endif
#define MASA_LIMIT_NO_BANDS_SUR_COH             8
#define MINIMUM_BIT_BUDGET_NORMAL_META          100
#define DIFF_DFRATIO_2BIT_LIMIT_IDX_HODIRAC     4
@@ -1394,9 +1417,9 @@ typedef enum
#define MCMASA_LFE_ALPHA                        0.67f
#define MCMASA_LFE_BETA                         0.09f
#ifdef IVAS_FLOAT_FIXED
#define MCMASA_LFE_1BIT_THRES_Q31               64424509 /* 0.03f in Q31 */
#define MCMASA_LFE_ALPHA_Q31                    1438814044 /* 0.67f in Q31 */
#define MCMASA_LFE_BETA_Q31                     193273528 /* 0.09f in Q31 */
#define MCMASA_LFE_1BIT_THRES_Q30               32212255 /* 0.03f in Q30 */
#define MCMASA_LFE_ALPHA_Q30                    719407022 /* 0.67f in Q30 */
#define MCMASA_LFE_BETA_Q30                     96636764 /* 0.09f in Q30 */
#endif
#define MCMASA_LFE_THETA                        1.3f
#define MCMASA_LFE_SYNTH_ALPHA                  0.95f                       /* Smoothing coefficient for LFE synthesis */
+0 −17
Original line number Diff line number Diff line
@@ -714,17 +714,6 @@ ivas_error ivas_FB_mixer_open_fx(

                FOR( j = start_diff_band_non48k; j < num_bands; j++ )
                {
#if 1 // TODO: To be removed later
                    if ( ( hFbMixer->pFb->fb_consts.ppFilterbank_FRs_non48k[0][j] = (float *) malloc( sizeof( float ) * pActive_bins_per_band[j] ) ) == NULL )
                    {
                        return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FB mixer encoder" );
                    }

                    if ( ( hFbMixer->pFb->fb_consts.ppFilterbank_FRs_non48k[1][j] = (float *) malloc( sizeof( float ) * pActive_bins_per_band[j] ) ) == NULL )
                    {
                        return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FB mixer encoder" );
                    }
#endif
                    IF( ( hFbMixer->pFb->fb_consts.ppFilterbank_FRs_non48k_fx[0][j] = (Word32 *) malloc( sizeof( Word32 ) * pActive_bins_per_band[j] ) ) == NULL )
                    {
                        return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FB mixer encoder" );
@@ -757,12 +746,6 @@ ivas_error ivas_FB_mixer_open_fx(
        {
            return error;
        }
#if 1 // TODO: To be removed later
        if ( ( error = ivas_filterbank_setup( hFbMixer, sampling_rate ) ) != IVAS_ERR_OK )
        {
            return error;
        }
#endif
    }

    *hFbMixer_out = hFbMixer;
+28 −22
Original line number Diff line number Diff line
@@ -46,7 +46,7 @@
#ifndef IVAS_FLOAT_FIXED
static void ivas_iir_2_filter( ivas_filters_process_state_t *filter_state, float *pIn_Out, const int16_t length, const int16_t stage );
#else
static void ivas_iir_2_filter_fx( ivas_filters_process_state_t *filter_state, Word32 *pIn_Out_fx, const Word16 length, const Word16 stage, Word16 q_fcator );
static void ivas_iir_2_filter_fx( ivas_filters_process_state_t *filter_state, Word32 *pIn_Out_fx, const Word16 length, const Word16 stage, Word16 *pIn_Out_e );
#endif
/*-----------------------------------------------------------------------------------------*
 * Function ivas_filters_init()
@@ -237,17 +237,33 @@ void ivas_filter_process_fx(
    const Word16 length,                        /* i  : filter order                    */
    Word16 q_factor )
{
    Word16 pIn_Out_e[L_FRAME_MAX];
    Word16 i;
    SWITCH( filter_state->order )
    {
        case IVAS_FILTER_ORDER_1:
        case IVAS_FILTER_ORDER_2:
            ivas_iir_2_filter_fx( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_0, q_factor );
            set_val_Word16( pIn_Out_e, sub( Q31, q_factor ), length );
            ivas_iir_2_filter_fx( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_0, pIn_Out_e );
            /* Scale pIn_Out_fx back to input Q */
            FOR( i = 0; i < length; i++ )
            {
                pIn_Out_fx[i] = L_shr_r_sat( pIn_Out_fx[i], sub( sub( 31, q_factor ), pIn_Out_e[i] ) );
                move32();
            }
            BREAK;
        case IVAS_FILTER_ORDER_4:
            set_val_Word16( pIn_Out_e, sub( Q31, q_factor ), length );
            /* biquad-1 */
            ivas_iir_2_filter_fx( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_0, q_factor );
            ivas_iir_2_filter_fx( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_0, pIn_Out_e );
            /* biquad-2 */
            ivas_iir_2_filter_fx( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_1, q_factor );
            ivas_iir_2_filter_fx( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_1, pIn_Out_e );
            /* Scale pIn_Out_fx back to input Q */
            FOR( i = 0; i < length; i++ )
            {
                pIn_Out_fx[i] = L_shr_r_sat( pIn_Out_fx[i], sub( sub( 31, q_factor ), pIn_Out_e[i] ) );
                move32();
            }
            BREAK;
        default:
            BREAK;
@@ -295,54 +311,44 @@ static void ivas_iir_2_filter_fx(
    Word32 *pIn_Out_fx,
    const Word16 length,
    const Word16 stage,
    Word16 q_factor )
    Word16 *pIn_Out_e )
{
    Word16 i, j;

    Word32 *pIn_fx = pIn_Out_fx;
    Word32 *pOut_fx = pIn_Out_fx;
    Word16 pOut_e;
    Word32 tmp_pIn_buf_i_fx;
    Word16 tmp_pIn_buf_i_e;

    Word32 L_tmp_prod, L_tmp;
    Word16 L_prod_e, L_tmp_e;

    move16();
    move16();

    FOR( i = 0; i < length; i++ )
    {
        tmp_pIn_buf_i_fx = pIn_fx[i];
        move32();
        tmp_pIn_buf_i_e = pIn_Out_e[i];
        move16();

        L_tmp_prod = Mpy_32_32( filter_state->num_fx[stage][0], pIn_fx[i] );
        L_prod_e = sub( 31, sub( q_factor, filter_state->num_e[stage][0] ) ); // 31 - ( ( q_factor + ( 31 - filter_state->num_e[stage][0] ) ) - 31 )
        L_prod_e = add( pIn_Out_e[i], filter_state->num_e[stage][0] );

        pOut_fx[i] = BASOP_Util_Add_Mant32Exp( filter_state->state_fx[stage][0], filter_state->state_e[stage][0], L_tmp_prod, L_prod_e, &pOut_e );
        pOut_fx[i] = BASOP_Util_Add_Mant32Exp( filter_state->state_fx[stage][0], filter_state->state_e[stage][0], L_tmp_prod, L_prod_e, &pIn_Out_e[i] );
        move32();

        FOR( j = 1; j < filter_state->filt_len; j++ )
        {
            L_tmp_prod = Mpy_32_32( filter_state->num_fx[stage][j], tmp_pIn_buf_i_fx );
            L_prod_e = sub( 31, sub( q_factor, filter_state->num_e[stage][j] ) ); // 31 - ( ( q_factor + ( 31 - filter_state->num_e[stage][j] ) ) - 31 )
            L_prod_e = add( filter_state->num_e[stage][j], tmp_pIn_buf_i_e );

            L_tmp = BASOP_Util_Add_Mant32Exp( filter_state->state_fx[stage][j], filter_state->state_e[stage][j], L_tmp_prod, L_prod_e, &L_tmp_e );

            L_tmp_prod = Mpy_32_32( filter_state->den_fx[stage][j], pOut_fx[i] );
            L_prod_e = add( pOut_e, filter_state->den_e[stage][j] ); // 31 - ( ( ( 31 - pOut_e ) + ( 31 - filter_state->den_e[stage][j] ) ) - 31 );
            L_prod_e = add( pIn_Out_e[i], filter_state->den_e[stage][j] );

            filter_state->state_fx[stage][j - 1] = BASOP_Util_Add_Mant32Exp( L_tmp, L_tmp_e, L_negate( L_tmp_prod ), L_prod_e, &filter_state->state_e[stage][j - 1] );
            move32();
        }

        /* Scaling pOut_fx to Q11 */
        pOut_fx[i] = L_shr_sat( pOut_fx[i], sub( sub( 31, q_factor ), pOut_e ) );
        move32();
        IF( pOut_fx[i] < 0 )
        {
            pOut_fx[i] = L_add( pOut_fx[i], 1 );
            move32();
        }
    }
}
#endif
+1058 −31

File changed.

Preview size limit exceeded, changes collapsed.

+89 −25
Original line number Diff line number Diff line
@@ -159,7 +159,7 @@ void destroy_cpe_enc(
void ivas_mct_enc_close(
    MCT_ENC_HANDLE *hMCT                                        /* i/o: MCT encoder structure                   */
);
#ifndef IVAS_FLOAT_FIXED

ivas_error ivas_corecoder_enc_reconfig(
    Encoder_Struct *st_ivas,                                    /* i/o: IVAS encoder structure                  */
    const int16_t nSCE_old,                                     /* i  : number of SCEs in previous frame        */
@@ -169,7 +169,7 @@ ivas_error ivas_corecoder_enc_reconfig(
    const int32_t brate_CPE,                                    /* i  : bitrate to be set for the CPEs          */
    const MC_MODE last_mc_mode                                  /* i  : switching between MC modes: last mode   */
);
#endif

ivas_error ivas_sce_enc(
    Encoder_Struct *st_ivas,                                    /* i/o: IVAS encoder structure                  */
    const int16_t sce_id,                                       /* i  : SCE # identifier                        */
@@ -811,7 +811,6 @@ void ivas_smc_mode_selection(
);

/*! r: S/M decision (0=speech or noise,1=unclear,2=music) */
#ifndef IVAS_FLOAT_FIXED
int16_t ivas_acelp_tcx20_switching(
    Encoder_State *st,                                          /* i/o: encoder state structure                 */
    const float *inp,                                           /* i  : new input signal                        */
@@ -825,7 +824,6 @@ int16_t ivas_acelp_tcx20_switching(
    float *res_cod_SNR_M,
    const int16_t flag_16k_smc                                  /* i  : flag to indicate if the OL SMC is run at 16 kHz */
);
#endif

#ifndef IVAS_FLOAT_FIXED
void ivas_decision_matrix_enc(
@@ -3775,7 +3773,7 @@ void stereo_cng_compute_PScorr(

void stereo_cng_dec_update(
    CPE_DEC_HANDLE hCPE,                                        /* i/o: CPE decoder structure                   */
    const int32_t ivas_total_brate                              /* i  : IVAS total bitrate                      */
    const int32_t ivas_total_brate                              /* i  : IVAS total bitrate                    Q0*/
);

void stereo_cna_update_params(
@@ -3786,9 +3784,9 @@ void stereo_cna_update_params(
);
void stereo_cna_update_params_fx(
  CPE_DEC_HANDLE hCPE,         /* i/o: CPE decoder structure       */
  Word32 *output_fx[CPE_CHANNELS], /* i  : Output signal               */
  const Word16 output_frame,  /* i  : Output frame length         */
  const Word16 tdm_ratio_idx  /* i  : TDM ratio index             */
  Word32 *output_fx[CPE_CHANNELS], /* i  : Output signal               OUTPUT_Q*/
  const Word16 output_frame,  /* i  : Output frame length					 Q0*/
  const Word16 tdm_ratio_idx  /* i  : TDM ratio index						 Q0*/
);
void dtx_enc_init(
    Encoder_State *st,                                          /* i  : Encoder state handle                    */
@@ -6291,18 +6289,19 @@ void ivas_calc_c_p_coeffs(
);
#ifdef IVAS_FLOAT_FIXED
void ivas_get_spar_md_from_dirac_fx(
    Word32 azi_dirac[IVAS_MAX_NUM_BANDS][MAX_PARAM_SPATIAL_SUBFRAMES],
	Word32 ele_dirac[IVAS_MAX_NUM_BANDS][MAX_PARAM_SPATIAL_SUBFRAMES],
	Word32 diffuseness[IVAS_MAX_NUM_BANDS],
    Word32 azi_dirac_fx[IVAS_MAX_NUM_BANDS][MAX_PARAM_SPATIAL_SUBFRAMES],   // Q22
    Word32 ele_dirac_fx[IVAS_MAX_NUM_BANDS][MAX_PARAM_SPATIAL_SUBFRAMES],   // Q22
    Word32 diffuseness_fx[IVAS_MAX_NUM_BANDS],  // Q30
    const Word16 n_ts,
    Word32 ***mixer_mat,
    Word32 ***mixer_mat_fx,
    Word16 *q_mixer_mat_fx,
    ivas_spar_md_t *hSpar_md,
    ivas_spar_md_com_cfg *hSpar_md_cfg,
    const Word16 start_band,
    const Word16 end_band,
    const Word16 order,
    const Word16 dtx_vad,
    Word32 Wscale_d[IVAS_MAX_NUM_BANDS],
    Word32 Wscale_d[IVAS_MAX_NUM_BANDS],    // Q29
    const UWord8 useLowerRes,
    const Word16 active_w_vlbr,
    const Word16 dyn_active_w_flag
@@ -6647,6 +6646,17 @@ void ivas_pca_enc(
    const int16_t n_channels                                    /* i  : number of channels                      */
);

#ifdef IVAS_FLOAT_FIXED
void ivas_pca_enc_fx(
    const ENCODER_CONFIG_HANDLE hEncoderConfig, /* i  : configuration structure                 */
    PCA_ENC_STATE *hPCA,                        /* i  : PCA encoder structure                   */
    BSTR_ENC_HANDLE hMetaData,                  /* i/o: MetaData handle                         */
    Word32 *data_f[8],                           /* i  : input/transformed audio channels    Q11    */
    const Word16 input_frame, /* i  : input frame length                      */
    const Word16 n_channels   /* i  : number of channels                      */
);
#endif

void ivas_pca_read_bits( 
    Decoder_State *st0,                                         /* i/o: decoder state structure - for bitstream handling*/
    PCA_DEC_STATE *hPCA                                         /* i/o: PCA encoder structure                   */
@@ -6697,6 +6707,11 @@ void eye_matrix_fx(
  const Word16 n,
  const Word16 d
);

void eye_matrix_fx32(
    Word32 *mat, // Q
    const Word16 n,
    const Word32 d ); // Q
#endif
void cov_subfr( 
    float **ptr_sig, 
@@ -6705,6 +6720,14 @@ void cov_subfr(
    const int16_t len 
);

#ifdef IVAS_FLOAT_FIXED
void cov_subfr_fx(
    Word32 **ptr_sig_fx, // Q11
    Word64 *r_fx_64, // Q11
    const Word16 n_channels,
    const Word16 len );
#endif

void eig_qr( 
    const float *A, 
    const int16_t num_iter, 
@@ -6712,16 +6735,39 @@ void eig_qr(
    const int16_t n 
);

#ifdef IVAS_FLOAT_FIXED
void eig_qr_fx(
    const Word32 *A_fx, // A_q
    Word16 A_q,
    const Word16 num_iter,
    Word32 *EV_fx, // Q31
    Word32 *Vals_fx, // A_q
    const Word16 n );
#endif

void exhst_4x4( 
    float *cost_mtx, 
    int16_t *path, 
    const int16_t maximize 
);

#ifdef IVAS_FLOAT_FIXED
void exhst_4x4_fx(
    Word16 *cost_mtx, // Q
    Word16 *path,
    const Word16 maximize );
#endif

float mat_det4( 
    const float *m 
);

#ifdef IVAS_FLOAT_FIXED
Word16 mat_det4_fx( 
    const Word16 *m // Q15
);
#endif

/* quaternion utilities */
void mat2dquat( 
    const float *a, 
@@ -6729,6 +6775,14 @@ void mat2dquat(
    float *qr 
);

#ifdef IVAS_FLOAT_FIXED
void mat2dquat_fx(
    const Word16 *a, // Q15
    Word16 *ql, // Q15
    Word16 *qr // Q15
);
#endif

void dquat2mat( 
    const float *ql, 
    const float *qr,
@@ -6751,6 +6805,7 @@ void pca_interp_preproc(
    float *ql_interp,
    float *qr_interp 
);

#ifdef IVAS_FLOAT_FIXED
void dquat2mat_fx(
  const Word16 *ql,
@@ -6777,6 +6832,13 @@ void pca_enc_s3(
    int32_t *index 
);

#ifdef IVAS_FLOAT_FIXED
void pca_enc_s3_fx( 
    Word16 *q, // Q15
    Word32 *index 
);
#endif

void pca_dec_s3( 
    const int32_t index, 
    float *q 
@@ -6813,6 +6875,7 @@ void ivas_spar_arith_coeffs_com_init(
  const Word16 table_idx,
  const Word16 enc_dec);

#ifndef IVAS_FLOAT_FIXED
int16_t ivas_arith_encode_cmplx_cell_array(
    ivas_arith_t *pArith_re,
    ivas_arith_t *pArith_re_diff,
@@ -6825,6 +6888,7 @@ int16_t ivas_arith_encode_cmplx_cell_array(
    const int16_t any_diff ,
    const int16_t wc_strat_arith
);
#endif

ivas_error ivas_huffman_decode(
    ivas_huffman_cfg_t *huff_cfg,
Loading