Commit 5a7b3eb1 authored by Sandesh Venkatesh's avatar Sandesh Venkatesh
Browse files

Integration of ivas_entropy_coder_common.c and ivas_omasa_com.c funcs

[x] Integration of all the functions present in ivas_entropy_coder_common.c and ivas_omasa_com.c except ivas_get_stereo_panning_gains in lib_enc
parent 83f352f2
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -575,7 +575,7 @@ enum
#define FRAMES_PER_SEC                      50
#ifdef IVAS_FLOAT_FIXED
#define MAX_PARAM_SPATIAL_SUB_FRAMES_PER_SEC              200 //(FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES)
#define ONE_BY_FRAMES_PER_SEC               ((Word32)(0x028F5C29))
#define ONE_BY_FRAMES_PER_SEC_Q31           ((Word32)(0x028F5C29))
#define FRAMES_PER_SEC_BY_2                 (FRAMES_PER_SEC >> 1)
#endif
#define INV_FRAME_PER_SEC_Q15               656
+364 −64

File changed.

Preview size limit exceeded, changes collapsed.

+51 −29
Original line number Diff line number Diff line
@@ -89,7 +89,7 @@

/*! r : ISM format mode */
#ifdef IVAS_FLOAT_FIXED
ISM_MODE ivas_omasa_ism_mode_select(
ISM_MODE ivas_omasa_ism_mode_select_fx(
    const Word32 ivas_total_brate, /* i  : IVAS total bitrate      */
    const Word16 nchan_ism         /* i  : number of input ISM's   */
)
@@ -169,6 +169,7 @@ ISM_MODE ivas_omasa_ism_mode_select(
            ELSE
            {
                ism_mode = ISM_MODE_NONE;
                move16();
            }
            BREAK;
    }
@@ -258,7 +259,7 @@ ISM_MODE ivas_omasa_ism_mode_select(
 * ---------------------------------------------------------------*/

#ifdef IVAS_FLOAT_FIXED
void ivas_set_omasa_TC(
void ivas_set_omasa_TC_fx(
    const ISM_MODE ism_mode, /* i  : ISM mode                   */
    const Word16 nchan_ism,  /* i  : number of input ISMs       */
    Word16 *nSCE,            /* o  : number of SCEs             */
@@ -331,7 +332,7 @@ void ivas_set_omasa_TC(

/*! r: adjusted bitrate */
#ifdef IVAS_FLOAT_FIXED
Word32 ivas_interformat_brate(
Word32 ivas_interformat_brate_fx(
    const ISM_MODE ism_mode,    /* i  : ISM mode                           */
    const Word16 nchan_ism,     /* i  : number of ISM channels             */
    const Word32 element_brate, /* i  : element bitrate                    */
@@ -342,17 +343,32 @@ Word32 ivas_interformat_brate(
    Word32 element_brate_out;
    Word16 nBits, limit_low, limit_high;

    nBits = extract_l( div_l( element_brate, shr( FRAMES_PER_SEC, 1 ) ) );
    nBits = extract_l( Mpy_32_32( element_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) ); /* Q0 */

    IF( EQ_16( ism_imp, ISM_INACTIVE_IMP ) )
    IF( ism_imp == ISM_INACTIVE_IMP )
    {
        nBits = BITS_ISM_INACTIVE;
        move16();
    }
    ELSE
    {
        IF( EQ_16( (Word16) ism_mode, (Word16) ISM_MASA_MODE_DISC ) && ( ( EQ_16( nchan_ism, 4 ) && EQ_32( element_brate, 24000 ) ) || ( EQ_16( nchan_ism, 3 ) && LE_32( element_brate, 24000 ) ) || ( EQ_16( nchan_ism, 2 ) && LE_32( element_brate, 11000 ) ) ) ) /* for border case in DISC mode */
        {
        test();
        test();
        test();
        test();
        test();
        test();
        test();
        test();
        test();
        IF( EQ_16( ism_mode, ISM_MASA_MODE_DISC ) && ( ( EQ_16( nchan_ism, 4 ) && EQ_32( element_brate, 24000 ) ) || ( EQ_16( nchan_ism, 3 ) && LE_32( element_brate, 24000 ) ) || ( EQ_16( nchan_ism, 2 ) && LE_32( element_brate, 11000 ) ) ) ) /* for border case in DISC mode */
        {
            test();
            test();
            test();
            test();
            test();
            test();
            IF( EQ_16( limit_flag, 1 ) && ( ( EQ_16( nchan_ism, 4 ) && EQ_32( element_brate, 24000 ) ) || ( EQ_16( nchan_ism, 3 ) && EQ_32( element_brate, 20000 ) ) || ( EQ_16( nchan_ism, 2 ) && LE_32( element_brate, 11000 ) ) ) )
            {
                return element_brate;
@@ -379,11 +395,12 @@ Word32 ivas_interformat_brate(
                }
            }
        }
        ELSE IF( EQ_16( (Word16) ism_mode, (Word16) ISM_MASA_MODE_PARAM_ONE_OBJ ) ||
                 ( EQ_16( (Word16) ism_mode, (Word16) ISM_MASA_MODE_DISC ) && EQ_32( element_brate, 9600 ) ) /* this condition corresponds to the ivas_total_brate = 24400 and 1 object */
        ELSE IF( EQ_16( ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) ||
                 ( EQ_16( ism_mode, ISM_MASA_MODE_DISC ) && EQ_32( element_brate, 9600 ) ) /* this condition corresponds to the ivas_total_brate = 24400 and 1 object */
        )
        {
            IF( EQ_16( (Word16) ism_mode, (Word16) ISM_MASA_MODE_PARAM_ONE_OBJ ) && EQ_32( element_brate, IVAS_13k2 ) )
            test();
            IF( EQ_16( ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) && EQ_32( element_brate, IVAS_13k2 ) )
            {
                IF( EQ_16( ism_imp, ISM_LOW_IMP ) )
                {
@@ -414,7 +431,7 @@ Word32 ivas_interformat_brate(
                }
            }
        }
        ELSE IF( EQ_16( (Word16) ism_mode, (Word16) ISM_MASA_MODE_MASA_ONE_OBJ ) && EQ_32( element_brate, 16000 ) )
        ELSE IF( EQ_16( ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) && EQ_32( element_brate, 16000 ) )
        {
            IF( EQ_16( ism_imp, ISM_LOW_IMP ) )
            {
@@ -447,7 +464,8 @@ Word32 ivas_interformat_brate(
    }

    limit_low = MIN_BRATE_SWB_BWE / FRAMES_PER_SEC;
    IF( EQ_16( ism_imp, ISM_INACTIVE_IMP ) )
    move16();
    IF( ism_imp == ISM_INACTIVE_IMP )
    {
        limit_low = BITS_ISM_INACTIVE;
        move16();
@@ -466,7 +484,7 @@ Word32 ivas_interformat_brate(
        move16();
    }

    nBits = check_bounds_s( nBits, limit_low, limit_high );
    nBits = check_bounds_s_fx( nBits, limit_low, limit_high );

    element_brate_out = L_mult0( nBits, FRAMES_PER_SEC );

@@ -618,7 +636,7 @@ int32_t ivas_interformat_brate(
 * ---------------------------------------------------------------*/

#ifdef IVAS_FLOAT_FIXED
void ivas_combined_format_brate_sanity(
void ivas_combined_format_brate_sanity_fx(
    const Word32 element_brate,       /* i  : element bitrate                */
    const Word16 core,                /* i  : core                           */
    const Word32 total_brate,         /* i  : total bitrate                  */
@@ -640,10 +658,10 @@ void ivas_combined_format_brate_sanity(
    {
        limit_high = ACELP_12k8_HIGH_LIMIT / FRAMES_PER_SEC;
        move16();
        nBits = extract_l( div_l( *core_brate, shr( FRAMES_PER_SEC, 1 ) ) );
        nBits = extract_l( Mpy_32_32( *core_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) );

        *diff_nBits = sub( nBits, limit_high );
        IF( GT_16( *diff_nBits, 0 ) )
        IF( *diff_nBits > 0 )
        {
            IF( EQ_16( core, TCX_20_CORE ) || EQ_16( core, TCX_10_CORE ) )
            {
@@ -661,11 +679,11 @@ void ivas_combined_format_brate_sanity(
     * set inactive coder_type flag in ACELP core
     *-----------------------------------------------------------------*/

    IF( EQ_16( core, ACELP_CORE ) )
    IF( core == ACELP_CORE )
    {
        *inactive_coder_type_flag = 0; /* AVQ by default */
        move16();
        IF( LE_32( L_add( *core_brate, brate_diff ), MAX_GSC_INACTIVE_BRATE ) )
        if ( LE_32( L_add( *core_brate, brate_diff ), MAX_GSC_INACTIVE_BRATE ) )
        {
            *inactive_coder_type_flag = 1; /* GSC */
            move16();
@@ -729,6 +747,7 @@ void ivas_combined_format_brate_sanity(
}
#endif


/*---------------------------------------------------------------
 * bits_index_ism_ratio()
 *
@@ -737,7 +756,7 @@ void ivas_combined_format_brate_sanity(

/*!r : number of bits for ISM ratio index */
#ifdef IVAS_FLOAT_FIXED
Word16 bits_index_ism_ratio(
Word16 bits_index_ism_ratio_fx(
    const Word16 nchan_ism /* i  : number of objects    */
)
{
@@ -802,7 +821,7 @@ int16_t bits_index_ism_ratio(
 *
 * ---------------------------------------------------------------*/


#ifndef IVAS_FLOAT_FIXED
void calculate_nbits_meta(
    const int16_t nchan_ism,
    float q_energy_ratio_ism[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS][MAX_NUM_OBJECTS],
@@ -860,7 +879,7 @@ void calculate_nbits_meta(

    return;
}
#ifdef IVAS_FLOAT_FIXED
#else
static Word16 get_bits_ism( Word32 val )
{
    Word16 res;
@@ -914,7 +933,7 @@ void calculate_nbits_meta_fx(
    const Word16 ism_imp )
{
    Word16 sf, band, obj;
    Word32 priority[MAX_NUM_OBJECTS], max_p;
    Word32 priority[MAX_NUM_OBJECTS], max_p; /* Q29 */

    IF( GT_16( nchan_ism, 1 ) )
    {
@@ -925,7 +944,7 @@ void calculate_nbits_meta_fx(
            {
                FOR( obj = 0; obj < nchan_ism; obj++ )
                {
                    priority[obj] = max( priority[obj], ( Mpy_32_32( q_energy_ratio_ism[sf][band][obj], L_sub( 1073741824, masa_to_total_energy_ratio[sf][band] ) ) ) ); // Qx - 1
                    priority[obj] = L_max( priority[obj], ( Mpy_32_32( q_energy_ratio_ism[sf][band][obj], L_sub( 1073741824 /* 1.0f in Q30 */, masa_to_total_energy_ratio[sf][band] ) ) ) ); // Qx - 1
                    move32();
                }
            }
@@ -933,7 +952,7 @@ void calculate_nbits_meta_fx(
    }
    ELSE
    {
        priority[0] = 536870912;
        priority[0] = 536870912; /* 1.0f in Q29 */
        move32();
    }

@@ -945,7 +964,7 @@ void calculate_nbits_meta_fx(
        {
            IF( EQ_16( ism_imp, 3 ) )
            {
                priority[obj] = 536870912;
                priority[obj] = 536870912; /* 1.0f in Q29 */
                move32();
            }
            ELSE IF( EQ_16( ism_imp, 2 ) )
@@ -955,7 +974,7 @@ void calculate_nbits_meta_fx(
            }
            ELSE
            {
                priority[obj] = max_p;
                priority[obj] = max_p; /* Q29 */
                move32();
            }
        }
@@ -966,6 +985,7 @@ void calculate_nbits_meta_fx(
}
#endif


/*---------------------------------------------------------------
 * ivas_get_stereo_panning_gains()
 *
@@ -1161,7 +1181,7 @@ void ivas_get_stereo_panning_gains_fx(

/*! r: limitation flag */
#ifdef IVAS_FLOAT_FIXED
Word16 calculate_brate_limit_flag(
Word16 calculate_brate_limit_flag_fx(
    const Word16 ism_imp[], /* i  : ISM importance flags   */
    const Word16 nchan_ism  /* i  : number of objects      */
)
@@ -1178,17 +1198,19 @@ Word16 calculate_brate_limit_flag(
    FOR( n = 0; n < nchan_ism; n++ )
    {
        brate_limit_flag = add( brate_limit_flag, ism_imp[n] );
        IF( EQ_16( ism_imp[n], 0 ) )
        if ( ism_imp[n] == 0 )
        {
            nzeros = add( nzeros, 1 );
        }
    }
    nchan_ism_sat = nchan_ism;
    IF( EQ_16( nchan_ism & 1, 1 ) )
    if ( EQ_16( nchan_ism & 1, 1 ) )
    {
        nchan_ism_sat = sub( nchan_ism, 1 );
    }


    /* brate_limit_flag >= (int16_t) ( nchan_ism * 2.5f ) */
    IF( GE_16( i_mult( 2, brate_limit_flag ), add( i_mult( 4, nchan_ism ), nchan_ism_sat ) ) )
    {
        brate_limit_flag = 1;
@@ -1196,7 +1218,7 @@ Word16 calculate_brate_limit_flag(
    }
    ELSE
    {
        IF( GE_16( i_mult( 2, nzeros ), nchan_ism ) )
        if ( GE_16( i_mult( 2, nzeros ), nchan_ism ) )
        {
            brate_limit_flag = -1; /* there is no limitation, on the contrary */
            move16();
+77 −0
Original line number Diff line number Diff line
@@ -2307,4 +2307,81 @@ MC_LS_SETUP ivas_mc_map_output_config_to_mc_ls_setup_fx(
AUDIO_CONFIG ivas_mc_map_ls_setup_to_output_config_fx(
    const MC_LS_SETUP mc_ls_setup /* i  : multi channel loudspeaker setup*/
);

void ivas_wrap_arround_fx(
    Word16 *pArr,
    const Word16 min_val,
    const Word16 max_val,
    const Word16 length );

void ivas_get_cum_freq_model_fx(
    const Word16 *pFreq_model,
    const Word16 length,
    Word16 *pCum_freq_model );

Word16 ivas_map_num_pred_r_to_idx_fx(
    const Word16 num_quant_points_pred_r,
    const Word16 active_w_flag );

Word16 ivas_map_num_drct_r_to_idx_fx(
    const Word16 num_quant_points_drct_r );

Word16 ivas_map_num_decd_r_to_idx_fx(
    const Word16 num_quant_points_decd_r );

void ivas_spar_arith_coeffs_com_init_fx(
    ivas_arith_coeffs_t *pArith_coeffs,
    ivas_spar_md_com_cfg *pSpar_cfg,
    const Word16 table_idx,
    const Word16 enc_dec );

void ivas_spar_huff_coeffs_com_init_fx(
    ivas_huff_coeffs_t *pHuff_coeffs,
    ivas_spar_md_com_cfg *pSpar_cfg,
    const Word16 table_idx,
    const Word16 enc_dec );

ISM_MODE ivas_omasa_ism_mode_select_fx(
    const Word32 ivas_total_brate, /* i  : IVAS total bitrate      */
    const Word16 nchan_ism         /* i  : number of input ISM's   */
);

void ivas_set_omasa_TC_fx(
    const ISM_MODE ism_mode, /* i  : ISM mode                   */
    const Word16 nchan_ism,  /* i  : number of input ISMs       */
    Word16 *nSCE,            /* o  : number of SCEs             */
    Word16 *nCPE             /* o  : number of CPEs             */
);

Word32 ivas_interformat_brate_fx(
    const ISM_MODE ism_mode,    /* i  : ISM mode                           */
    const Word16 nchan_ism,     /* i  : number of ISM channels             */
    const Word32 element_brate, /* i  : element bitrate                    */
    const Word16 ism_imp,       /* i  : ISM importance flag                */
    const Word16 limit_flag     /* i  : flag to limit the bitrate increase */
);

Word16 check_bounds_s_fx(
    const Word16 value, /* i  : Input value                  */
    const Word16 low,   /* i  : Low limit                    */
    const Word16 high   /* i  : High limit                   */
);

void ivas_combined_format_brate_sanity_fx(
    const Word32 element_brate,       /* i  : element bitrate                */
    const Word16 core,                /* i  : core                           */
    const Word32 total_brate,         /* i  : total bitrate                  */
    Word32 *core_brate,               /* i/o: core bitrate                   */
    Word16 *inactive_coder_type_flag, /* o  : inactive coder_type flag       */
    Word16 *diff_nBits                /* o  : number of differential bits    */
);

Word16 bits_index_ism_ratio_fx(
    const Word16 nchan_ism /* i  : number of objects    */
);

Word16 calculate_brate_limit_flag_fx(
    const Word16 ism_imp[], /* i  : ISM importance flags   */
    const Word16 nchan_ism  /* i  : number of objects      */
);
#endif
+1 −1
Original line number Diff line number Diff line
@@ -317,7 +317,7 @@ typedef struct ivas_arith_t
    int16_t range;
    int16_t num_models;
#ifdef IVAS_FLOAT_FIXED
    Word32 saved_dist_arr[IVAS_NUM_PROB_MODELS][IVAS_MAX_QUANT_LEVELS];
    Word32 saved_dist_arr[IVAS_NUM_PROB_MODELS][IVAS_MAX_QUANT_LEVELS]; /* Q15 */
#else
    float saved_dist_arr[IVAS_NUM_PROB_MODELS][IVAS_MAX_QUANT_LEVELS];
#endif
Loading