Commit b9b6c7ad authored by Vidhya V P's avatar Vidhya V P
Browse files

Merge branch 'main' into...

Merge branch 'main' into 300-sba-decoder-13-2-and-16-4kbps-crashes-if-decoded-bitstream-starts-with-sid
parents b0f7b2b4 d61d22c1
Loading
Loading
Loading
Loading
Loading
+5 −6
Original line number Diff line number Diff line
@@ -1026,7 +1026,7 @@ typedef enum

#define SPAR_CONFIG_BW                          FB

#ifndef SPAR_TUNING
#ifndef HODIRAC
#define IVAS_SPAR_MAX_CH                        (FOA_CHANNELS + 2 * ( IVAS_MAX_SBA_ORDER - 1 )) /* FOA + planar HOA */
#else
#define IVAS_SPAR_MAX_CH                        ((( IVAS_MAX_SBA_ORDER ) * ( IVAS_MAX_SBA_ORDER )) + 2) /* HOA2 + pHOA3*/
@@ -1037,7 +1037,6 @@ typedef enum
#define IVAS_SPAR_MAX_FB_IN_CHAN                11
#endif


#define IVAS_SPAR_P_LOWERTRI                    ((IVAS_SPAR_MAX_CH - 1) * (IVAS_SPAR_MAX_CH - 2)) >> 1
#define IVAS_SPAR_MAX_C_COEFF                   (IVAS_SPAR_MAX_CH - IVAS_SPAR_MAX_DMX_CHS) * ( IVAS_SPAR_MAX_DMX_CHS - 1)

+67 −32
Original line number Diff line number Diff line
@@ -48,6 +48,32 @@

static uint16_t deindex_sph_idx_general( const int16_t idx_sph, const int16_t no_bits, float *theta_dec, float *phi_dec, uint16_t *p_id_phi, const MC_LS_SETUP mc_format );


#ifdef HODIRAC
/*-------------------------------------------------------------------------
 * ivas_get_hodirac_flag()
 *
 * Return flag for HO-DirAC method at high bitrates
 *------------------------------------------------------------------------*/

/*! r: HO-DirAC flag */
int16_t ivas_get_hodirac_flag(
    const int32_t ivas_total_brate, /* i  : IVAS total bitrate      */
    const int16_t sba_order         /* i  : Ambisonic (SBA) order   */
)
{
    if ( sba_order > 1 && ivas_total_brate > IVAS_256k )
    {
        return 1;
    }
    else
    {
        return 0;
    }
}
#endif


/*-------------------------------------------------------------------------
 * ivas_dirac_sba_config()
 *
@@ -132,8 +158,9 @@ ivas_error ivas_dirac_config(
        hConfig->nbands = IVAS_MAX_NUM_BANDS;

        spar_dirac_split_band = min( IVAS_MAX_NUM_BANDS, SPAR_DIRAC_SPLIT_START_BAND );

#ifdef HODIRAC
        if ( sba_order > 1 && ivas_total_brate > IVAS_256k )
        if ( ivas_get_hodirac_flag( ivas_total_brate, sba_order ) )
        {
            spar_dirac_split_band = 0;
        }
@@ -173,8 +200,9 @@ ivas_error ivas_dirac_config(
            {
                hConfig->enc_param_start_band = spar_dirac_split_band;
            }

#ifdef HODIRAC
            if ( sba_order > 1 && ivas_total_brate > IVAS_256k )
            if ( ivas_get_hodirac_flag( ivas_total_brate, sba_order ) )
            {
                hConfig->dec_param_estim = FALSE;
                hConfig->enc_param_start_band = 0;
@@ -195,15 +223,11 @@ ivas_error ivas_dirac_config(

    if ( sba_mode == SBA_MODE_SPAR )
    {
        ivas_dirac_config_bands( band_grouping,
                                 IVAS_MAX_NUM_BANDS,
                                 (int16_t) ( Fs * INV_CLDFB_BANDWIDTH + 0.5f ),
                                 dirac_to_spar_md_bands, hQMetaData->useLowerBandRes, hConfig->enc_param_start_band, hFbMdft );
        ivas_dirac_config_bands( band_grouping, IVAS_MAX_NUM_BANDS, (int16_t) ( Fs * INV_CLDFB_BANDWIDTH + 0.5f ), dirac_to_spar_md_bands, hQMetaData->useLowerBandRes, hConfig->enc_param_start_band, hFbMdft );
    }
    else
    {
        ivas_dirac_config_bands( band_grouping, hConfig->nbands, (int16_t) ( Fs * INV_CLDFB_BANDWIDTH + 0.5f ),
                                 NULL, 0, 0, hFbMdft );
        ivas_dirac_config_bands( band_grouping, hConfig->nbands, (int16_t) ( Fs * INV_CLDFB_BANDWIDTH + 0.5f ), NULL, 0, 0, hFbMdft );
    }

    return error;
@@ -335,10 +359,16 @@ ivas_error ivas_dirac_sba_config(
    int16_t i;
    int16_t nbands_wb;
    int16_t nbands_coded;
#ifdef HODIRAC
    int16_t hodirac_flag;
#endif
    ivas_error error;

    error = IVAS_ERR_OK;
    hQMetaData->is_masa_ivas_format = 0;
#ifdef HODIRAC
    hodirac_flag = ivas_get_hodirac_flag( sba_total_brate, sba_order );
#endif

    if ( sba_mode == SBA_MODE_SPAR )
    {
@@ -376,7 +406,7 @@ ivas_error ivas_dirac_sba_config(
        {
            hQMetaData->useLowerBandRes = 0;
#ifdef HODIRAC
            if ( !( sba_order > 1 && sba_total_brate > IVAS_256k ) )
            if ( hodirac_flag == 0 )
#endif
            {
                nbands_coded = nbands - 1; /* always combine the last two bands */
@@ -386,7 +416,7 @@ ivas_error ivas_dirac_sba_config(
        {
            int16_t no_dirs = 1;
#ifdef HODIRAC
            if ( sba_order > 1 && sba_total_brate > IVAS_256k )
            if ( hodirac_flag )
            {
                no_dirs = 2;
            }
@@ -396,8 +426,7 @@ ivas_error ivas_dirac_sba_config(
            {
                return error;
            }
#if defined( HODIRAC_FIX_BR_SWITCHING_DTX ) && !defined( FIX_DTX_428 )
            if ( sba_order > 1 && sba_total_brate > IVAS_256k )
#if defined( HODIRAC ) && !defined( FIX_DTX_428 )
            {
                int16_t dir, j;
                for ( dir = 0; dir < hQMetaData->no_directions; dir++ )
@@ -508,7 +537,7 @@ ivas_error ivas_dirac_sba_config(
            {
                int16_t no_dirs = 1;
#ifdef HODIRAC
                if ( sba_order > 1 && sba_total_brate > IVAS_256k )
                if ( hodirac_flag )
                {
                    no_dirs = 2;
                }
@@ -545,8 +574,9 @@ ivas_error ivas_dirac_sba_config(
            for ( i = 0; i < hQMetaData->no_directions; i++ )
            {
                hQMetaData->q_direction[i].cfg.search_effort = 1;

#ifdef HODIRAC
                if ( sba_order > 1 && sba_total_brate > IVAS_256k )
                if ( hodirac_flag )
                {
                    hQMetaData->q_direction[i].cfg.start_band = 0;
                }
@@ -857,7 +887,14 @@ void deindex_spherical_component(
    return;
}


#ifdef HODIRAC
/*----------------------------------------------------------------
 * calculate_hodirac_sector_parameters()
 *
 *
 *-----------------------------------------------------------------*/

void calculate_hodirac_sector_parameters(
    float RealBuffer[DIRAC_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX], /* i  : signal vector (L+1)^2 x N_bins, real part  */
    float ImagBuffer[DIRAC_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX], /* i  : signal vector, imaginary part              */
@@ -1060,14 +1097,12 @@ void calculate_hodirac_sector_parameters(
                *p_azi_prev = *p_azi;
                *p_ele_prev = *p_ele;
            }
#ifdef HODIRAC_CHECK_VALUE_RANGE
            assert( *p_azi >= -180.f && *p_azi <= 180.f );
            assert( *p_ele >= -90.f && *p_ele <= 90.f );
#endif
        } // i_band
    }     // i_sec
        }
    }

    firstrun_sector_params = 0;

    return;
}
#endif

+15 −15
Original line number Diff line number Diff line
@@ -108,7 +108,7 @@ ivas_error ivas_fb_set_cfg(
    const int32_t sampling_rate    /* i  : sampling rate                    */
#ifdef HODIRAC
    ,
    const int16_t nchan_fb_in /* i: number of dirac analysis channels */
    const int16_t nchan_fb_in /* i  : number of dirAC analysis channels*/
#endif
)
{
@@ -526,7 +526,7 @@ void ivas_fb_mixer_pcm_ingest(
    float pcm_in[][L_FRAME48k],    /* i  : input audio channels        */
    float **ppOut_pcm,             /* o  : output audio channels       */
    const int16_t frame_len        /* i  : frame length                */
#ifdef SPAR_TUNING
#ifdef HODIRAC
    ,
    const int16_t HOA_md_ind[IVAS_SPAR_MAX_CH]
#endif
@@ -553,7 +553,7 @@ void ivas_fb_mixer_pcm_ingest(
    {
        mvr2r( &hFbMixer->ppFilterbank_prior_input[i][fb_cfg->prior_input_length - frame_len], ppOut_pcm[i], frame_len );
#ifdef HODIRAC
#ifdef SPAR_TUNING
#ifdef HODIRAC
        mvr2r( pcm_in[HOA_md_ind[i]], &ppOut_pcm[i][frame_len], frame_len );
#else
        mvr2r( pcm_in[HOA_keep_ind_spar[i]], &ppOut_pcm[i][frame_len], frame_len );
@@ -584,7 +584,7 @@ void ivas_fb_mixer_update_prior_input(
    const int16_t length           /* i  : length of time slot          */
#ifdef HODIRAC
    ,
    const int16_t nchan_fb_in
    const int16_t nchan_fb_in /* i  : number of analysis channels  */
#endif
)
{
@@ -621,7 +621,7 @@ void ivas_fb_mixer_get_windowed_fr(
    const int16_t mdft_len         /* i  : MDFT frame length                  */
#ifdef HODIRAC
    ,
    int16_t nchan_fb_in
    const int16_t nchan_fb_in /* i  : number of analysis channels        */
#endif
)
{
+188 −13
Original line number Diff line number Diff line
@@ -412,12 +412,19 @@ void masa_sample_rate_band_correction(
    return;
}


#ifdef HR_METADATA
/*-------------------------------------------------------------------------
 * index_theta_phi_16()
 *
 *
 *------------------------------------------------------------------------*/

/*! r: output index for direction */
uint16_t index_theta_phi_16(
    float *p_theta,                     /* i/o: input elevation to be indexed   */
    float *p_phi,                       /* i/o: input azimuth to be indexed     */
    SPHERICAL_GRID_DATA *gridData /* i  : generated grid data */
    const SPHERICAL_GRID_DATA *gridData /* i  : generated grid data             */
)
{
    float abs_theta;
@@ -501,13 +508,20 @@ uint16_t index_theta_phi_16(
        }
    }


    return idx_sph;
}


/*-------------------------------------------------------------------------
 * quantize_phi_masa()
 *
 *
 *------------------------------------------------------------------------*/

/*! r: output index */
int16_t quantize_theta(
    float x,             /* i  : theta value to be quantized  */
    int16_t no_cb, /* i  : number of codewords          */
    const int16_t no_cb, /* i  : number of codewords          */
    float *xhat          /* o  : quantized value              */
)
{
@@ -540,10 +554,16 @@ int16_t quantize_theta(
}


/*-------------------------------------------------------------------------
 * quantize_phi_masa()
 *
 *
 *------------------------------------------------------------------------*/

/*! r: index azimuth */
int16_t quantize_phi_masa(
    float phi,                /* i  : azimuth value                                                   */
    int16_t flag_delta, /* i  : flag indicating if the azimuth codebook is translated or not    */
    const int16_t flag_delta, /* i  : flag indicating if the azimuth codebook is translated or not    */
    float *phi_hat,           /* o  : quantized azimuth                                               */
    const int16_t n           /* i  : azimuth codebook size                                           */
)
@@ -587,4 +607,159 @@ int16_t quantize_phi_masa(
    return id_phi;
}


/*-------------------------------------------------------------------------
 * deindex_sph_idx()
 *
 *  deindex the MASA metadata from the input metadata file
 *------------------------------------------------------------------------*/

void deindex_sph_idx(
    const uint16_t sphIndex,             /* i  : Spherical index            */
    const SPHERICAL_GRID_DATA *gridData, /* i  : Prepared spherical grid    */
    float *theta,                        /* o  : Elevation                  */
    float *phi                           /* o  : Azimuth                    */
)
{
    float ba_crt, del_crt, div_crt, a4_crt;
    float estim;
    int32_t base_low, base_up;
    int16_t n_crt;
    int16_t id_th;
    int16_t sign_theta;
    int16_t id_phi;
    int16_t no_th = gridData->no_theta;
    const int16_t *n = gridData->no_phi;
    const float ba[3] = {
        2.137991118026424e+02f,
        1.244854404591542e+02f,
        1.228408647140870e+02f,
    };
    const float del[3] = { 7.998262115303199e+05f, 1.300883976959332e+06f, 1.424072242426373e+06f };
    const float div[3] = { -0.237662341081474f, -0.100938185496887f, -0.092050209205032f };
    const float a4[3] = { -8.415300425381099f, -19.814106922515204f, -21.727272727270197f };
    const uint16_t limit_index1 = 64964, limit_index2 = 47870;

    if ( sphIndex >= limit_index1 )
    {
        ba_crt = ba[2];
        div_crt = div[2];
        a4_crt = a4[2];
        del_crt = del[2];
    }
    else if ( sphIndex >= limit_index2 )
    {
        ba_crt = ba[1];
        div_crt = div[1];
        a4_crt = a4[1];
        del_crt = del[1];
    }
    else
    {
        ba_crt = ba[0];
        div_crt = div[0];
        a4_crt = a4[0];
        del_crt = del[0];
    }
    estim = ba_crt + div_crt * sqrtf( del_crt + a4_crt * sphIndex );

    if ( estim > MASA_NO_CIRCLES )
    {
        estim = MASA_NO_CIRCLES;
    }

    assert( estim > 0 );
    id_th = (int16_t) roundf( estim ) - 1;
    if ( id_th < 0 )
    {
        id_th = 0;
    }

    if ( id_th == 0 )
    {
        base_low = 0;
        base_up = n[0];
    }
    else
    {
        estim = MASA_ANGLE_AT_EQUATOR * (float) ( id_th - 0.5f );
        base_low = n[0];
        if ( id_th >= 2 )
        {
            if ( id_th == 2 )
            {
                base_low += 2 * (int16_t) ceilf( MASA_NTOT2_FAC * ( sinf( estim ) - MASA_ASIN_OFFSET ) );
            }
            else
            {
                base_low += 2 * (int16_t) roundf( MASA_NTOT2_FAC * ( sinf( estim ) - MASA_ASIN_OFFSET ) );
            }
        }
        base_up = base_low + 2 * n[id_th];
    }

    sign_theta = 1;

    n_crt = n[id_th];
    if ( sphIndex < base_low )
    {
        id_th--;
        n_crt = n[id_th];
        if ( id_th == 0 )
        {
            base_low = 0;
            base_up = n_crt;
        }
        else
        {
            base_up = base_low;
            base_low -= 2 * n[id_th];
        }
        assert( sphIndex >= base_low );
    }
    else if ( sphIndex >= base_up )
    {
        id_th++;
        n_crt = n[id_th];
        base_low = base_up;
        base_up += 2 * n_crt;
        assert( sphIndex < base_up );
    }

    id_phi = (int16_t) ( sphIndex - base_low );
    if ( sphIndex - base_low >= n_crt )
    {
        id_phi -= n_crt;
        sign_theta = -1;
    }

    if ( id_th == 0 )
    {
        *theta = 0.f;
        *phi = (float) sphIndex * 360 / (float) n_crt - 180;
    }
    else
    {
        if ( id_th == no_th - 1 )
        {
            id_phi = 0;
            *phi = -180;
            *theta = 90 * (float) sign_theta;
        }
        else
        {
            *theta = id_th * MASA_ANGLE_AT_EQUATOR_DEG * (float) sign_theta;
            if ( id_th % 2 == 0 )
            {
                *phi = (float) id_phi * 360 / (float) n_crt - 180;
            }
            else
            {
                *phi = ( (float) id_phi + 0.5f ) * 360 / (float) n_crt - 180;
            }
        }
    }

    return;
}
#endif
+136 −103

File changed.

Preview size limit exceeded, changes collapsed.

Loading