Commit 980c2e79 authored by Sandesh Venkatesh's avatar Sandesh Venkatesh
Browse files

Merge branch 'enc_funcs_integration_mc_path' into 'main'

Integrated ivas_enc_cov_handler_process_fx function in MC path

See merge request !437
parents 8ca59b2d e51b4cdc
Loading
Loading
Loading
Loading
+35 −56
Original line number Diff line number Diff line
@@ -206,7 +206,6 @@ static void ivas_set_up_cov_smoothing_fx(
            Word16 active_bins = pFb->fb_bin_to_band.pFb_active_bins_per_band[j];
            update_factor = ivas_calculate_update_factor_fx( pFb->fb_bin_to_band.pFb_bin_to_band_fx[j], active_bins );
            ivas_calculate_smoothning_factor_fx( &hCovState->pSmoothing_factor_fx[j], update_factor, min_pool_size, max_update_rate, smooth_mode, ivas_total_brate, j );
            hCovState->pSmoothing_factor[j] = fixedToFloat( hCovState->pSmoothing_factor_fx[j], Q31 );
        }
    }
    ELSE
@@ -217,7 +216,6 @@ static void ivas_set_up_cov_smoothing_fx(
            Word16 active_bins = pFb->fb_bin_to_band.p_short_stride_num_bins_per_band[j];
            update_factor = ivas_calculate_update_factor_fx( p_bin_to_band, active_bins );
            ivas_calculate_smoothning_factor_fx( &hCovState->pSmoothing_factor_fx[j], update_factor, min_pool_size, max_update_rate, smooth_mode, ivas_total_brate, j );
            hCovState->pSmoothing_factor[j] = fixedToFloat( hCovState->pSmoothing_factor_fx[j], Q31 );
        }
    }

@@ -270,78 +268,65 @@ static void ivas_set_up_cov_smoothing(
#endif


#ifdef IVAS_FLOAT_FIXED
/*-------------------------------------------------------------------------
 * ivas_spar_covar_smooth_enc_open()
 * ivas_spar_covar_smooth_enc_open_fx()
 *
 * Allocate and initialize SPAR Covar. smoothing handle
 *------------------------------------------------------------------------*/

#ifdef IVAS_FLOAT_FIXED
ivas_error ivas_spar_covar_smooth_enc_open(
ivas_error ivas_spar_covar_smooth_enc_open_fx(
    ivas_cov_smooth_state_t **hCovState_out,     /* i/o: SPAR Covar. smoothing handle       */
    const ivas_cov_smooth_cfg_t *cov_smooth_cfg, /* i  : SPAR config. handle                */
    ivas_filterbank_t *pFb,                      /* i/o: FB handle                          */
    const int16_t nchan_inp,                     /* i  : number of input channels           */
    const Word16 nchan_inp,                      /* i  : number of input channels           */
    const COV_SMOOTHING_TYPE smooth_mode,        /* i  : Smooth covariance for SPAR or MC   */
    const int32_t ivas_total_brate               /* i  : IVAS total bitrate                 */
    const Word32 ivas_total_brate                /* i  : IVAS total bitrate                 */
)
{
    ivas_cov_smooth_state_t *hCovState;
    int16_t i, j;
    Word16 i, j;

    if ( ( hCovState = (ivas_cov_smooth_state_t *) malloc( sizeof( ivas_cov_smooth_state_t ) ) ) == NULL )
    IF( ( hCovState = (ivas_cov_smooth_state_t *) malloc( sizeof( ivas_cov_smooth_state_t ) ) ) == NULL )
    {
        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" );
    }
#endif
    if ( ( hCovState->pSmoothing_factor = (float *) malloc( sizeof( float ) * cov_smooth_cfg->max_bands ) ) == NULL )
    {
        return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR COV encoder" );
    }

    for ( i = 0; i < nchan_inp; i++ )
    {
        for ( j = 0; j < nchan_inp; j++ )
    FOR( i = 0; i < nchan_inp; i++ )
    {
            if ( ( hCovState->pPrior_cov_real[i][j] = (float *) malloc( sizeof( float ) * cov_smooth_cfg->max_bands ) ) == NULL )
        FOR( j = 0; j < nchan_inp; j++ )
        {
                return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR COV encoder" );
            }
            set_zero( hCovState->pPrior_cov_real[i][j], cov_smooth_cfg->max_bands );
#ifdef IVAS_FLOAT_FIXED
            if ( ( hCovState->pPrior_cov_real_fx[i][j] = (Word32 *) malloc( sizeof( Word32 ) * cov_smooth_cfg->max_bands ) ) == NULL )
            IF( ( hCovState->pPrior_cov_real_fx[i][j] = (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" );
            }
            set_zero_fx( hCovState->pPrior_cov_real_fx[i][j], cov_smooth_cfg->max_bands );
#endif
#ifdef IVAS_FLOAT_FIXED
            if ( ( hCovState->q_cov_real_per_band[i][j] = (Word16 *) malloc( sizeof( Word16 ) * cov_smooth_cfg->max_bands ) ) == NULL )
            IF( ( hCovState->q_cov_real_per_band[i][j] = (Word16 *) malloc( sizeof( Word16 ) * cov_smooth_cfg->max_bands ) ) == NULL )
            {
                return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR COV encoder Fixed" );
            }
            set_s( hCovState->q_cov_real_per_band[i][j], Q31, cov_smooth_cfg->max_bands );
#endif
        }
    }

#ifdef IVAS_FLOAT_FIXED
    ivas_set_up_cov_smoothing_fx( hCovState, pFb, cov_smooth_cfg->max_update_rate_fx, cov_smooth_cfg->min_pool_size, smooth_mode, ivas_total_brate );
#else
    ivas_set_up_cov_smoothing( hCovState, pFb, cov_smooth_cfg->max_update_rate, cov_smooth_cfg->min_pool_size, smooth_mode, ivas_total_brate );
#endif

    *hCovState_out = hCovState;

    return IVAS_ERR_OK;
}
#else
/*-------------------------------------------------------------------------
 * ivas_spar_covar_smooth_enc_open()
 *
 * Allocate and initialize SPAR Covar. smoothing handle
 *------------------------------------------------------------------------*/

ivas_error ivas_spar_covar_smooth_enc_open(
    ivas_cov_smooth_state_t **hCovState_out,     /* i/o: SPAR Covar. smoothing handle       */
    const ivas_cov_smooth_cfg_t *cov_smooth_cfg, /* i  : SPAR config. handle                */
@@ -384,46 +369,36 @@ ivas_error ivas_spar_covar_smooth_enc_open(
}
#endif

#ifdef IVAS_FLOAT_FIXED
/*-------------------------------------------------------------------------
 * ivas_spar_covar_smooth_enc_close()
 * ivas_spar_covar_smooth_enc_close_fx()
 *
 * Deallocate SPAR Covar. smoothing handle
 *------------------------------------------------------------------------*/

#ifdef IVAS_FLOAT_FIXED
void ivas_spar_covar_smooth_enc_close(
void ivas_spar_covar_smooth_enc_close_fx(
    ivas_cov_smooth_state_t **hCovState_out, /* i/o: SPAR Covar. smoothing handle   */
    const int16_t nchan_inp                  /* i  : number of input channels       */
    const Word16 nchan_inp                   /* i  : number of input channels       */
)
{
    ivas_cov_smooth_state_t *hCovState;
    int16_t i, j;
    Word16 i, j;

    hCovState = *hCovState_out;

    if ( hCovState != NULL )
    IF( hCovState != NULL )
    {
#ifdef IVAS_FLOAT_FIXED
        free( hCovState->pSmoothing_factor_fx );
        hCovState->pSmoothing_factor_fx = NULL;
#endif
        free( hCovState->pSmoothing_factor );
        hCovState->pSmoothing_factor = NULL;

        for ( i = 0; i < nchan_inp; i++ )
        FOR( i = 0; i < nchan_inp; i++ )
        {
            for ( j = 0; j < nchan_inp; j++ )
            FOR( j = 0; j < nchan_inp; j++ )
            {
                free( hCovState->pPrior_cov_real[i][j] );
                hCovState->pPrior_cov_real[i][j] = NULL;
#ifdef IVAS_FLOAT_FIXED
                free( hCovState->pPrior_cov_real_fx[i][j] );
                hCovState->pPrior_cov_real_fx[i][j] = NULL;
#endif
#ifdef IVAS_FLOAT_FIXED
                free( hCovState->q_cov_real_per_band[i][j] );
                hCovState->q_cov_real_per_band[i][j] = NULL;
#endif
            }
        }

@@ -434,6 +409,12 @@ void ivas_spar_covar_smooth_enc_close(
    return;
}
#else
/*-------------------------------------------------------------------------
 * ivas_spar_covar_smooth_enc_close()
 *
 * Deallocate SPAR Covar. smoothing handle
 *------------------------------------------------------------------------*/

void ivas_spar_covar_smooth_enc_close(
    ivas_cov_smooth_state_t **hCovState_out, /* i/o: SPAR Covar. smoothing handle   */
    const int16_t nchan_inp                  /* i  : number of input channels       */
@@ -597,9 +578,7 @@ static void ivas_compute_smooth_cov_fx(

    return;
}
#endif


#else
/*-----------------------------------------------------------------------------------------*
 * Function ivas_compute_smooth_cov()
 *
@@ -691,6 +670,7 @@ static void ivas_compute_smooth_cov(

    return;
}
#endif


#ifdef IVAS_FLOAT_FIXED
@@ -728,9 +708,7 @@ void ivas_cov_smooth_process_fx(

    return;
}
#endif


#else
/*-----------------------------------------------------------------------------------------*
 * Function ivas_cov_smooth_process()
 *
@@ -763,3 +741,4 @@ void ivas_cov_smooth_process(

    return;
}
#endif
+23 −7
Original line number Diff line number Diff line
@@ -5860,6 +5860,21 @@ void ivas_spar_dec_gen_umx_mat(
    const int16_t num_md_sub_frames
);

#ifdef IVAS_FLOAT_FIXED
ivas_error ivas_spar_covar_enc_open_fx(
    ivas_enc_cov_handler_state_t **hCovEnc,                     /* i/o: SPAR Covar. encoder handle      */
    ivas_filterbank_t *pFb,                                     /* i/o: FB handle                       */
    const Word32 input_Fs,                                      /* i  : input sampling rate             */
    const Word16 nchan_inp,                                     /* i  : number of input channels        */
    const COV_SMOOTHING_TYPE smooth_mode,                       /* i  : Smooth covariance for SPAR or MC*/
    const Word32 ivas_total_brate                               /* i  : IVAS total bitrate              */
);

void ivas_spar_covar_enc_close_fx( 
    ivas_enc_cov_handler_state_t **hCovEnc,                     /* i/o: SPAR Covar. encoder handle              */
    const Word16 nchan_inp                                      /* i  : number of input channels                */
);
#else
/* Covariance module */
ivas_error ivas_spar_covar_enc_open( 
    ivas_enc_cov_handler_state_t **hCovEnc,                     /* i/o: SPAR Covar. encoder handle              */
@@ -5874,6 +5889,7 @@ void ivas_spar_covar_enc_close(
    ivas_enc_cov_handler_state_t **hCovEnc,                     /* i/o: SPAR Covar. encoder handle              */
    const int16_t nchan_inp                                     /* i  : number of input channels                */
);
#endif

#ifdef IVAS_FLOAT_FIXED
void ivas_enc_cov_handler_process_fx(
@@ -5898,8 +5914,7 @@ void ivas_enc_cov_handler_process_fx(
    const Word16 nchan_transport,
    const Word16 is_sba
);
#endif

#else
void ivas_enc_cov_handler_process( 
    ivas_enc_cov_handler_state_t *hCovEnc,                      /* i/o: SPAR Covar. encoder handle              */
    float **ppIn_FR_real,
@@ -5919,8 +5934,9 @@ void ivas_enc_cov_handler_process(
    const int16_t nchan_transport,
    const int16_t is_sba
);
#endif

#ifdef IVAS_FLOAT_FIXED_
#ifdef IVAS_FLOAT_FIXED
ivas_error ivas_spar_covar_smooth_enc_open_fx(
    ivas_cov_smooth_state_t **hCovState,                        /* i/o: SPAR Covar. smoothing handle            */
    const ivas_cov_smooth_cfg_t *cov_smooth_cfg,                /* i  : SPAR config. handle                     */
@@ -5934,8 +5950,7 @@ void ivas_spar_covar_smooth_enc_close_fx(
    ivas_cov_smooth_state_t **hCovState,                        /* i/o: SPAR Covar. encoder handle              */
    const Word16 nchan_inp                                      /* i  : number of input channels                */
);
#endif

#else
ivas_error ivas_spar_covar_smooth_enc_open( 
    ivas_cov_smooth_state_t **hCovState,                        /* i/o: SPAR Covar. smoothing handle            */
    const ivas_cov_smooth_cfg_t *cov_smooth_cfg,                /* i  : SPAR config. handle                     */
@@ -5949,6 +5964,7 @@ void ivas_spar_covar_smooth_enc_close(
    ivas_cov_smooth_state_t **hCovState,                        /* i/o: SPAR Covar. encoder handle              */
    const int16_t nchan_inp                                     /* i  : number of input channels                */
);
#endif

#ifdef IVAS_FLOAT_FIXED
void ivas_cov_smooth_process_fx( 
@@ -5961,8 +5977,7 @@ void ivas_cov_smooth_process_fx(
    const Word16 transient_det[2],
    Word16 *q_cov[IVAS_SPAR_MAX_CH]
);
#endif

#else
void ivas_cov_smooth_process( 
    ivas_cov_smooth_state_t *hCovState,                         /* i/o: Covariance state handle                 */
    float *cov_real[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH],
@@ -5972,6 +5987,7 @@ void ivas_cov_smooth_process(
    const int16_t num_ch,
    const int16_t transient_det[2]
);
#endif

/* Transient detector module */
ivas_error ivas_transient_det_open(
+5 −0
Original line number Diff line number Diff line
@@ -2393,6 +2393,11 @@ Word16 ism_quant_meta_fx(
    const Word16 cbsize            /* i  : codebook size                   */
);

/*! r: number of channels to be analysed */
Word16 getNumChanAnalysis_fx(
    Encoder_Struct *st_ivas /* i  : IVAS encoder structure              */
);

ivas_error ivas_limiter_open_fx(
    IVAS_LIMITER_HANDLE *hLimiter_out, /* o  : limiter struct handle                           */
    const Word16 max_num_channels,     /* i  : maximum number of I/O channels to be processed  */
+10 −6
Original line number Diff line number Diff line
@@ -367,24 +367,28 @@ typedef struct ivas_agc_com_state_t
/* Covariance structures */
typedef struct ivas_cov_smooth_state_t
{
    float *pPrior_cov_real[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH];
    int16_t prior_bank_idx;
    float *pSmoothing_factor;
    int16_t num_bins;
#ifdef IVAS_FLOAT_FIXED
    Word32 *pPrior_cov_real_fx[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH];
    Word16 *q_cov_real[IVAS_SPAR_MAX_CH];
    Word16 *q_cov_real_per_band[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH];
#else
    float *pPrior_cov_real[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH];
#endif
    int16_t prior_bank_idx;
#ifdef IVAS_FLOAT_FIXED
    Word32 *pSmoothing_factor_fx; /* Q31 */
#else
    float *pSmoothing_factor;
#endif
    int16_t num_bins;

} ivas_cov_smooth_state_t;

typedef struct ivas_cov_smooth_cfg_t
{
    float max_update_rate;
#ifdef IVAS_FLOAT_FIXED
    Word32 max_update_rate_fx; /* Q31 */
#else
    float max_update_rate;
#endif
    int16_t min_pool_size;
    int16_t max_bands;
+542 −36

File changed.

Preview size limit exceeded, changes collapsed.

Loading