Commit c37d1f7f authored by Adam Mills's avatar Adam Mills
Browse files

Fixing the SBA MSAN issue properly, with non-BE Switch in the right place

parent 0fc9528d
Loading
Loading
Loading
Loading
Loading
+4 −7
Original line number Diff line number Diff line
@@ -4485,8 +4485,11 @@ void ivas_spar_update_md_hist(
);

int16_t ivas_spar_chk_zero_coefs(
    Decoder_Struct *st_ivas,                                    /* i/o: IVAS decoder handle                     */
    Decoder_Struct *st_ivas                                    /* i/o: IVAS decoder handle                     */
#ifndef CR_FIX_698_SBA_MSAN
    ,
    const int16_t sba_order                                     /* i  : Ambisonic (SBA) order                   */
#endif
);

void ivas_spar_smooth_md_dtx(
@@ -4892,13 +4895,7 @@ void ivas_copy_band_coeffs_idx_to_arr(

void ivas_clear_band_coeffs( 
    ivas_band_coeffs_t *pband_coeffs, 
#ifdef CR_FIX_698_SBA_MSAN
    const uint16_t num_bands,
    const uint16_t num_ts
#else
    const uint16_t num_bands
#endif

);

void ivas_clear_band_coeff_idx( 
+0 −30
Original line number Diff line number Diff line
@@ -293,46 +293,16 @@ void ivas_copy_band_coeffs_idx_to_arr(

void ivas_clear_band_coeffs(
    ivas_band_coeffs_t *pband_coeffs,
#ifdef CR_FIX_698_SBA_MSAN
    const uint16_t num_bands,
    const uint16_t num_ts )
#else
    const uint16_t num_bands )
#endif
{
#ifdef CR_FIX_698_SBA_MSAN
    uint16_t i, j;
#else
    uint16_t i;
#endif

#ifdef CR_FIX_698_SBA_MSAN
    for ( j = 0; j < num_ts; j++ )
#else
    for ( i = 0; i < num_bands; i++ )
#endif
    {
#ifndef CR_FIX_698_SBA_MSAN
        set_zero( (float *) pband_coeffs[i].C_re, ( IVAS_SPAR_MAX_CH - IVAS_SPAR_MAX_DMX_CHS ) * ( IVAS_SPAR_MAX_DMX_CHS - 1 ) );
        set_zero( (float *) pband_coeffs[i].P_re, ( IVAS_SPAR_MAX_CH - 1 ) );
        set_zero( (float *) pband_coeffs[i].C_quant_re, ( IVAS_SPAR_MAX_CH - IVAS_SPAR_MAX_DMX_CHS ) * ( IVAS_SPAR_MAX_DMX_CHS - 1 ) );
        set_zero( (float *) pband_coeffs[i].P_quant_re, ( IVAS_SPAR_MAX_CH - 1 ) );
        set_zero( pband_coeffs[i].pred_re, ( IVAS_SPAR_MAX_CH - 1 ) );
#endif
#ifdef CR_FIX_698_SBA_MSAN
        for ( i = 0; i < num_bands; i++ )
        {
            set_zero( (float *) pband_coeffs[i + j * num_bands].C_re, ( IVAS_SPAR_MAX_CH - IVAS_SPAR_MAX_DMX_CHS ) * ( IVAS_SPAR_MAX_DMX_CHS - 1 ) );
            set_zero( (float *) pband_coeffs[i + j * num_bands].P_re, ( IVAS_SPAR_MAX_CH - 1 ) );
            set_zero( (float *) pband_coeffs[i + j * num_bands].C_quant_re, ( IVAS_SPAR_MAX_CH - IVAS_SPAR_MAX_DMX_CHS ) * ( IVAS_SPAR_MAX_DMX_CHS - 1 ) );
            set_zero( (float *) pband_coeffs[i + j * num_bands].P_quant_re, ( IVAS_SPAR_MAX_CH - 1 ) );
            set_zero( pband_coeffs[i + j * num_bands].pred_re, ( IVAS_SPAR_MAX_CH - 1 ) );

            set_zero( pband_coeffs[i + j * num_bands].pred_quant_re, ( IVAS_SPAR_MAX_CH - 1 ) );
        }
#else
        set_zero( pband_coeffs[i].pred_quant_re, ( IVAS_SPAR_MAX_CH - 1 ) );
#endif
    }

    return;
+58 −36
Original line number Diff line number Diff line
@@ -498,11 +498,7 @@ ivas_error ivas_spar_md_dec_init(
)
{
    int16_t i, j;
#ifdef CR_FIX_698_SBA_MSAN
    int16_t nchan_transport, num_md_sub_frames;
#else
    int16_t nchan_transport;
#endif
    float pFC[IVAS_MAX_NUM_BANDS], PR_minmax[2];

    ivas_sba_get_spar_hoa_md_flag( sba_order, hDecoderConfig->ivas_total_brate, &hMdDec->spar_hoa_md_flag, &hMdDec->spar_hoa_dirac2spar_md_flag );
@@ -545,13 +541,7 @@ ivas_error ivas_spar_md_dec_init(
    hMdDec->spar_plc_enable_fadeout_flag = 1;
    hMdDec->dtx_md_smoothing_cntr = 1;

#ifdef CR_FIX_698_SBA_MSAN
    num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( sba_order, hDecoderConfig->ivas_total_brate, hDecoderConfig->ivas_total_brate );

    ivas_clear_band_coeffs( hMdDec->spar_md.band_coeffs, IVAS_MAX_NUM_BANDS, num_md_sub_frames );
#else
    ivas_clear_band_coeffs( hMdDec->spar_md.band_coeffs, IVAS_MAX_NUM_BANDS );
#endif
    ivas_clear_band_coeff_idx( hMdDec->spar_md.band_coeffs_idx, IVAS_MAX_NUM_BANDS );
    ivas_clear_band_coeff_idx( hMdDec->spar_md_prev.band_coeffs_idx, IVAS_MAX_NUM_BANDS );
    ivas_clear_band_coeff_idx( hMdDec->spar_md_prev.band_coeffs_idx_mapped, IVAS_MAX_NUM_BANDS );
@@ -646,8 +636,11 @@ static ivas_error ivas_spar_set_dec_config(
 *-----------------------------------------------------------------------------------------*/

static void ivas_dec_mono_sba_handling(
    Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle                                */
    Decoder_Struct *st_ivas /* i/o: IVAS decoder handle                                 */
#ifndef CR_FIX_698_SBA_MSAN
    ,
    const int16_t sba_order  /* i  : Ambisonic (SBA) order                              */
#endif
    )
{
    int16_t mono_flag, b, block;
@@ -671,7 +664,11 @@ static void ivas_dec_mono_sba_handling(
        }
    }
    /* Combine the SPAR prediction coefs flag with the azimuth, elevation and energy ratio flag.*/
    #ifdef CR_FIX_698_SBA_MSAN
        mono_flag = mono_flag && ivas_spar_chk_zero_coefs( st_ivas );
    #else
        mono_flag = mono_flag && ivas_spar_chk_zero_coefs( st_ivas, sba_order );
    #endif

    if ( mono_flag )
    {
@@ -756,7 +753,11 @@ void ivas_spar_md_dec_process(
    ivas_spar_dec_parse_md_bs( hMdDec, st0, &nB, &bw, &dtx_vad, st_ivas->hDecoderConfig->ivas_total_brate,
                               st_ivas->hQMetaData->sba_inactive_mode, st_ivas->last_active_ivas_total_brate );

#ifdef CR_FIX_698_SBA_MSAN
    ivas_dec_mono_sba_handling( st_ivas );
#else
    ivas_dec_mono_sba_handling( st_ivas, sba_order );
#endif

    /* SPAR to DirAC conversion */
    if ( hMdDec->spar_hoa_dirac2spar_md_flag == 1 )
@@ -868,31 +869,42 @@ void ivas_spar_md_dec_process(
 *-----------------------------------------------------------------------------------------*/

int16_t ivas_spar_chk_zero_coefs(
    Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle        */
    Decoder_Struct *st_ivas  /* i/o: IVAS decoder handle        */
#ifndef CR_FIX_698_SBA_MSAN
    ,
    const int16_t sba_order  /* i  : Ambisonic (SBA) order      */
#endif
)
{
#ifdef CR_FIX_698_SBA_MSAN
    int16_t j, k, b;
#else
    int16_t j, k, b, i_ts;
    ivas_spar_md_dec_state_t *hMdDec;
    int16_t num_md_sub_frames;
#endif
    ivas_spar_md_dec_state_t *hMdDec;
    int16_t mono = 1;
    int16_t ndec, ndm;

    hMdDec = st_ivas->hSpar->hMdDec;

    num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( sba_order, st_ivas->hDecoderConfig->ivas_total_brate,
                                                            st_ivas->last_active_ivas_total_brate );

    ndec = hMdDec->spar_md_cfg.num_decorr_per_band[0];
    ndm = hMdDec->spar_md_cfg.num_dmx_chans_per_band[0];

#ifndef CR_FIX_698_SBA_MSAN
    num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( sba_order, st_ivas->hDecoderConfig->ivas_total_brate,
                                                            st_ivas->last_active_ivas_total_brate );
    for ( i_ts = 0; i_ts < num_md_sub_frames; i_ts++ )
    {
#endif
            for ( b = 0; b < min( hMdDec->spar_md.num_bands, SPAR_DIRAC_SPLIT_START_BAND ); b++ )
            {
                for ( j = 0; j < ndm + ndec - 1; j++ )
                {
#ifdef CR_FIX_698_SBA_MSAN
                    if ( hMdDec->spar_md.band_coeffs[b].pred_re[j] != 0.0f )
#else
            if ( hMdDec->spar_md.band_coeffs[b + i_ts * IVAS_MAX_NUM_BANDS].pred_re[j] != 0.0f )
#endif
                    {
                        mono = 0;
                    }
@@ -901,7 +913,11 @@ int16_t ivas_spar_chk_zero_coefs(
                {
                    for ( k = 0; k < ndm - 1; k++ )
                    {
#ifdef CR_FIX_698_SBA_MSAN
                        if ( hMdDec->spar_md.band_coeffs[b].C_re[j][k] != 0.0f )
#else
                if ( hMdDec->spar_md.band_coeffs[b + i_ts * IVAS_MAX_NUM_BANDS].C_re[j][k] != 0.0f )
#endif
                        {
                            mono = 0;
                        }
@@ -909,13 +925,19 @@ int16_t ivas_spar_chk_zero_coefs(
                }
                for ( j = 0; j < ndec; j++ )
                {
#ifdef CR_FIX_698_SBA_MSAN
                    if ( hMdDec->spar_md.band_coeffs[b].P_re[j] != 0.0f )
#else
            if ( hMdDec->spar_md.band_coeffs[b + i_ts * IVAS_MAX_NUM_BANDS].P_re[j] != 0.0f )
#endif
                    {
                        mono = 0;
                    }
                }
            }
#ifndef CR_FIX_698_SBA_MSAN
        }
#endif
    return mono;
}

+0 −4
Original line number Diff line number Diff line
@@ -303,11 +303,7 @@ ivas_error ivas_spar_md_enc_init(
        }
    }

#ifdef CR_FIX_698_SBA_MSAN
    ivas_clear_band_coeffs( hMdEnc->spar_md.band_coeffs, IVAS_MAX_NUM_BANDS, 1 );
#else
    ivas_clear_band_coeffs( hMdEnc->spar_md.band_coeffs, IVAS_MAX_NUM_BANDS );
#endif
    ivas_clear_band_coeff_idx( hMdEnc->spar_md.band_coeffs_idx, IVAS_MAX_NUM_BANDS );
    ivas_clear_band_coeff_idx( hMdEnc->spar_md_prior.band_coeffs_idx, IVAS_MAX_NUM_BANDS );
    ivas_clear_band_coeff_idx( hMdEnc->spar_md_prior.band_coeffs_idx_mapped, IVAS_MAX_NUM_BANDS );