Commit 5e5651de authored by Lauros Pajunen's avatar Lauros Pajunen
Browse files

Merge remote-tracking branch 'origin/main' into...

Merge remote-tracking branch 'origin/main' into 350-masa-audio-and-meta-out-of-sync-in-decoder-when-delay-compensation-is-disabled
parents c36f22e4 e2d0547f
Loading
Loading
Loading
Loading
Loading
+119 −72
Original line number Diff line number Diff line
@@ -175,6 +175,10 @@ ivas_error ivas_FB_mixer_open(
    IVAS_FB_MIXER_HANDLE *hFbMixer_out, /* i/o: FB mixer handle           */
    const int32_t sampling_rate,        /* i  : sampling rate             */
    IVAS_FB_CFG *fb_cfg                 /* i  : FB config. handle         */
#ifdef SBA_BR_SWITCHING_CLEAN_UP
    ,
    const int16_t spar_reconfig_flag /* i  : SPAR reconfiguration flag */
#endif
)
{
    IVAS_FB_MIXER_HANDLE hFbMixer;
@@ -186,7 +190,12 @@ ivas_error ivas_FB_mixer_open(

    frame_len = (int16_t) ( sampling_rate / FRAMES_PER_SEC );

#ifdef SBA_BR_SWITCHING_CLEAN_UP
    hFbMixer = *hFbMixer_out;

    if ( !spar_reconfig_flag )
    {
#endif
        if ( ( hFbMixer = (IVAS_FB_MIXER_HANDLE) malloc( sizeof( IVAS_FB_MIXER_DATA ) ) ) == NULL )
        {
            return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FB mixer encoder" );
@@ -203,6 +212,10 @@ ivas_error ivas_FB_mixer_open(
        {
            hFbMixer->pFb = NULL;
        }
#ifdef SBA_BR_SWITCHING_CLEAN_UP
    }
#endif

    if ( fb_cfg->active_w_mixing == -1 )
    {
        num_chs_alloc = 0;
@@ -247,6 +260,7 @@ ivas_error ivas_FB_mixer_open(
    {
        num_chs_alloc = fb_cfg->num_in_chans;
    }

    for ( i = 0; i < num_chs_alloc; i++ )
    {
        if ( ( hFbMixer->ppFilterbank_prior_input[i] = (float *) malloc( sizeof( float ) * fb_cfg->prior_input_length ) ) == NULL )
@@ -275,6 +289,10 @@ ivas_error ivas_FB_mixer_open(
        }
    }

#ifdef SBA_BR_SWITCHING_CLEAN_UP
    if ( !spar_reconfig_flag )
    {
#endif
        if ( fb_cfg->num_out_chans > 0 )
        {
            const int16_t *pActive_bins_per_band, *pActive_bins_per_band_abs, *pStart_offset, *pStart_offset_abs;
@@ -323,13 +341,25 @@ ivas_error ivas_FB_mixer_open(
            /* ignore all the deeper filter bank stuff for now */
            hFbMixer->num_diff_bands = 0;
        }
#ifdef SBA_BR_SWITCHING_CLEAN_UP
    }
#endif

    hFbMixer->fb_cfg = fb_cfg;
#ifdef SBA_BR_SWITCHING_CLEAN_UP
    set_s( hFbMixer->first_frame, 1, hFbMixer->fb_cfg->num_out_chans );
    set_s( hFbMixer->first_frame + hFbMixer->fb_cfg->num_out_chans, 0, IVAS_SPAR_MAX_CH - hFbMixer->fb_cfg->num_out_chans );

    if ( !spar_reconfig_flag )
    {
#endif
        if ( ( error = ivas_filterbank_setup( hFbMixer, sampling_rate ) ) != IVAS_ERR_OK )
        {
            return error;
        }
#ifdef SBA_BR_SWITCHING_CLEAN_UP
    }
#endif

    *hFbMixer_out = hFbMixer;

@@ -346,6 +376,10 @@ ivas_error ivas_FB_mixer_open(
void ivas_FB_mixer_close(
    IVAS_FB_MIXER_HANDLE *hFbMixer_in, /* i/o: FB mixer handle              */
    const int32_t sampling_rate        /* i  : sampling rate in Hz          */
#ifdef SBA_BR_SWITCHING_CLEAN_UP
    ,
    const int16_t spar_reconfig_flag /* i  : SPAR reconfiguration flag    */
#endif
)
{
    IVAS_FB_MIXER_HANDLE hFbMixer;
@@ -405,6 +439,10 @@ void ivas_FB_mixer_close(
            hFbMixer->prior_mixer[0][0] = NULL;
        }

#ifdef SBA_BR_SWITCHING_CLEAN_UP
        if ( !spar_reconfig_flag )
        {
#endif
            if ( fb_cfg->num_out_chans > 0 )
            {
                num_bands = hFbMixer->pFb->filterbank_num_bands;
@@ -433,12 +471,14 @@ void ivas_FB_mixer_close(
                    }
                }
            }

            if ( hFbMixer->pFb != NULL )
            {
                free( hFbMixer->pFb );
                hFbMixer->pFb = NULL;
            }
#ifdef SBA_BR_SWITCHING_CLEAN_UP
        }
#endif

        if ( hFbMixer->fb_cfg != NULL )
        {
@@ -446,8 +486,15 @@ void ivas_FB_mixer_close(
            hFbMixer->fb_cfg = NULL;
        }

#ifdef SBA_BR_SWITCHING_CLEAN_UP
        if ( !spar_reconfig_flag )
        {
#endif
            free( hFbMixer );
            hFbMixer = NULL;
#ifdef SBA_BR_SWITCHING_CLEAN_UP
        }
#endif
    }

    return;
@@ -1027,10 +1074,10 @@ static ivas_error ivas_filterbank_setup(
    IVAS_FB_CFG *pCfg = hFbMixer->fb_cfg;

    error = IVAS_ERR_OK;

#ifndef SBA_BR_SWITCHING_CLEAN_UP
    set_s( hFbMixer->first_frame, 1, pCfg->num_out_chans );
    set_s( hFbMixer->first_frame + pCfg->num_out_chans, 0, IVAS_SPAR_MAX_CH - pCfg->num_out_chans );

#endif

    if ( pCfg->num_out_chans > 0 )
    {
+22 −0
Original line number Diff line number Diff line
@@ -3749,12 +3749,18 @@ void FdCngDecodeDiracMDCTStereoSID(

ivas_error ivas_spar_enc_open(
    Encoder_Struct *st_ivas                                     /* i/o: IVAS encoder handle                     */
#ifdef SBA_BR_SWITCHING_CLEAN_UP
   ,const int16_t spar_reconfig_flag                            /* i  : SPAR reconfiguration flag               */
#endif
);

void ivas_spar_enc_close(
    SPAR_ENC_HANDLE hSpar,                                      /* i/o: SPAR encoder handle                     */
    const int32_t input_Fs,                                     /* i  : input sampling rate                     */
    const int16_t nchan_inp                                     /* i  : number of input channels                */
#ifdef SBA_BR_SWITCHING_CLEAN_UP
   ,const int16_t spar_reconfig_flag                            /* i  : SPAR reconfiguration flag               */
#endif
);

ivas_error ivas_spar_enc(
@@ -3767,11 +3773,19 @@ ivas_error ivas_spar_enc(

ivas_error ivas_spar_dec_open(
    Decoder_Struct *st_ivas                                     /* i/o: IVAS decoder handle                     */
#ifdef SBA_BR_SWITCHING_CLEAN_UP
    ,
    const int16_t spar_reconfig_flag                            /* i  : SPAR reconfiguration flag               */
#endif
);

void ivas_spar_dec_close(
    SPAR_DEC_HANDLE hSpar,                                      /* i/o: SPAR decoder handle                     */
    const int32_t output_Fs                                     /* i  : output sampling rate                    */
#ifdef SBA_BR_SWITCHING_CLEAN_UP
    ,
    const int16_t spar_reconfig_flag                            /* i  : SPAR reconfiguration flag               */
#endif
);

ivas_error ivas_spar_dec(
@@ -4926,11 +4940,19 @@ ivas_error ivas_FB_mixer_open(
    IVAS_FB_MIXER_HANDLE *hFbMixer,                             /* i/o: FB mixer handle                             */
    const int32_t sampling_rate,                                /* i  : sampling rate                               */
    IVAS_FB_CFG *fb_cfg                                         /* i  : FB config. handle                           */
#ifdef SBA_BR_SWITCHING_CLEAN_UP
    ,
    const int16_t spar_reconfig_flag                            /* i  : SPAR reconfiguration flag                   */
#endif
);

void ivas_FB_mixer_close( 
    IVAS_FB_MIXER_HANDLE *hFbMixer,                             /* i/o: FB mixer handle                             */
    const int32_t sampling_rate                                 /* i  : sampling rate in Hz                         */
#ifdef SBA_BR_SWITCHING_CLEAN_UP
    ,
    const int16_t spar_reconfig_flag                            /* i  : SPAR reconfiguration flag                   */
#endif
);

void ivas_fb_mixer_pcm_ingest( 
+1 −1
Original line number Diff line number Diff line
@@ -141,7 +141,7 @@
#define DISABLE_ADAP_RES_COD_TMP                        /* temporary fix for IVAS-403, disables adaptive residual coding */
/*#define ITD_WINNER_GAIN_MODIFY */                     /* ITD optimization - WORK IN PROGRESS */
/*#define FIX_I4_OL_PITCH*/                             /* fix open-loop pitch used for EVS core switching */

#define SBA_BR_SWITCHING_CLEAN_UP                       /*Issue 114: Clean up changes for the SBA reconfiguation functions*/
#define LOW_RATE_TRANS_CORE_CODER                       /* Eri: Activate low-rate-encoding-of-transients contribution for core coder, affects MC, MASA and SBA */
#define FIX_197_CREND_INTERFACE
#define FIX_329_ENABLE_TD_RENDERER_REVERB_MC            /* Eri: Enable reverb for TD renderer for 5.1 and 7.1 with headtracking enabled for IVAS_dec */
+8 −0
Original line number Diff line number Diff line
@@ -863,7 +863,11 @@ ivas_error ivas_init_decoder(
        {
            if ( st_ivas->sba_mode == SBA_MODE_SPAR )
            {
#ifdef SBA_BR_SWITCHING_CLEAN_UP
                if ( ( error = ivas_spar_dec_open( st_ivas, 0 ) ) != IVAS_ERR_OK )
#else
                if ( ( error = ivas_spar_dec_open( st_ivas ) ) != IVAS_ERR_OK )
#endif
                {
                    return error;
                }
@@ -1720,7 +1724,11 @@ void ivas_destroy_dec(
    /* Spar handle */
    if ( st_ivas->hSpar != NULL )
    {
#ifdef SBA_BR_SWITCHING_CLEAN_UP
        ivas_spar_dec_close( st_ivas->hSpar, st_ivas->hDecoderConfig->output_Fs, 0 );
#else
        ivas_spar_dec_close( st_ivas->hSpar, st_ivas->hDecoderConfig->output_Fs );
#endif
        st_ivas->hSpar = NULL;
    }

+93 −2
Original line number Diff line number Diff line
@@ -62,8 +62,12 @@ ivas_error ivas_sba_dec_reconfigure(
    int16_t sba_dirac_stereo_flag_old;
    SBA_MODE sba_mode_old;
    int32_t ivas_total_brate, last_ivas_total_brate;
    RENDERER_TYPE old_renderer_type;
    DECODER_CONFIG_HANDLE hDecoderConfig;
    ivas_error error;
#ifdef SBA_BR_SWITCHING_CLEAN_UP
    int16_t band_grouping[IVAS_MAX_NUM_BANDS + 1];
#endif

    error = IVAS_ERR_OK;

@@ -108,7 +112,11 @@ ivas_error ivas_sba_dec_reconfigure(

    if ( st_ivas->sba_mode != SBA_MODE_SPAR )
    {
#ifndef SBA_BR_SWITCHING_CLEAN_UP
        ivas_spar_dec_close( st_ivas->hSpar, hDecoderConfig->output_Fs );
#else
        ivas_spar_dec_close( st_ivas->hSpar, hDecoderConfig->output_Fs, 0 );
#endif
        st_ivas->hSpar = NULL;

        if ( ( error = ivas_dirac_sba_config( st_ivas->hQMetaData, &st_ivas->nchan_transport, &st_ivas->nSCE, &st_ivas->nCPE, &st_ivas->element_mode_init, ivas_total_brate, st_ivas->sba_analysis_order, st_ivas->sba_mode, -1 ) ) != IVAS_ERR_OK )
@@ -120,13 +128,18 @@ ivas_error ivas_sba_dec_reconfigure(
    }
    else
    {
#ifdef SBA_BR_SWITCHING_CLEAN_UP
        int16_t sba_order_internal;
#else
        int16_t i, sba_order_internal, nchan_internal;
        DIRAC_DEC_HANDLE hDirAC = st_ivas->hDirAC;
#endif
        SPAR_DEC_HANDLE hSpar = st_ivas->hSpar;

        sba_order_internal = min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER );
        nchan_internal = ivas_sba_get_nchan_metadata( sba_order_internal );

#ifndef SBA_BR_SWITCHING_CLEAN_UP
        nchan_internal = ivas_sba_get_nchan_metadata( sba_order_internal );
        if ( hSpar != NULL && nchan_transport_old != ivas_get_sba_num_TCs( ivas_total_brate, sba_order_internal ) )
        {
            // VE: dirty patch -> reconfiguration of SPAR modules should be used instead !!
@@ -186,7 +199,39 @@ ivas_error ivas_sba_dec_reconfigure(
            }
            hSpar->i_subframe = 0;
        }
#else
        if ( hSpar != NULL )
        {
            if ( ( hSpar->hPCA != NULL ) && ( ( hDecoderConfig->ivas_total_brate != PCA_BRATE ) || ( sba_order_internal != 1 ) ) )
            {
                free( st_ivas->hSpar->hPCA );
                hSpar->hPCA = NULL;
            }

            if ( nchan_transport_old != ivas_get_sba_num_TCs( ivas_total_brate, sba_order_internal ) )
            {

                ivas_spar_dec_close( st_ivas->hSpar, hDecoderConfig->output_Fs, 1 );

                if ( ( error = ivas_spar_dec_open( st_ivas, 1 ) ) != IVAS_ERR_OK )
                {
                    return error;
                }
            }
            ivas_spar_config( ivas_total_brate, sba_order_internal, &st_ivas->nchan_transport, &st_ivas->nSCE, &st_ivas->nCPE, &hSpar->core_nominal_brate, st_ivas->sid_format );
        }
        else
        {
            if ( ( error = ivas_spar_dec_open( st_ivas, 0 ) ) != IVAS_ERR_OK )
            {
                return error;
            }
        }

        hSpar = st_ivas->hSpar;
        st_ivas->sba_dirac_stereo_flag = 0;
#endif
#ifndef SBA_BR_SWITCHING_CLEAN_UP
        /* PCA handle */
        if ( hSpar != NULL )
        {
@@ -239,6 +284,7 @@ ivas_error ivas_sba_dec_reconfigure(
        {
            return error;
        }
#endif
    }

    if ( st_ivas->nchan_transport == 1 )
@@ -256,7 +302,6 @@ ivas_error ivas_sba_dec_reconfigure(

    /* renderer might have changed */
    intern_config_old = st_ivas->intern_config;
    RENDERER_TYPE old_renderer_type;
    old_renderer_type = st_ivas->renderer_type;
    ivas_renderer_select( st_ivas );

@@ -304,6 +349,50 @@ ivas_error ivas_sba_dec_reconfigure(
    {
        ivas_dirac_dec_close_binaural_data( &st_ivas->hDiracDecBin );
    }

#ifdef SBA_BR_SWITCHING_CLEAN_UP
    if ( ( ( st_ivas->renderer_type != RENDERER_DISABLE ) && ( st_ivas->renderer_type != RENDERER_SBA_LINEAR_DEC ) ) || ( sba_mode_old != st_ivas->sba_mode ) || ( ( st_ivas->sba_mode == SBA_MODE_SPAR ) && ( ( hDecoderConfig->output_config != AUDIO_CONFIG_FOA ) && ( st_ivas->hDecoderConfig->output_config != AUDIO_CONFIG_STEREO ) && ( st_ivas->hDecoderConfig->output_config != AUDIO_CONFIG_MONO ) ) ) )
    {
        DIRAC_CONFIG_FLAG flag_config;

        flag_config = DIRAC_OPEN;
        if ( st_ivas->hDirAC != NULL )
        {
            flag_config = DIRAC_RECONFIGURE_MODE;
            if ( ( sba_mode_old == st_ivas->sba_mode ) && ( st_ivas->sba_mode != SBA_MODE_SPAR ) )
            {
                flag_config = DIRAC_RECONFIGURE;
            }
        }

        if ( ( error = ivas_dirac_dec_config( st_ivas, flag_config ) ) != IVAS_ERR_OK )
        {
            return error;
        }
    }

    if ( st_ivas->sba_mode == SBA_MODE_SPAR )
    {
        if ( ( error = ivas_dirac_sba_config( st_ivas->hQMetaData, &st_ivas->nchan_transport, &st_ivas->nSCE, &st_ivas->nCPE, &st_ivas->element_mode_init, ivas_total_brate, st_ivas->sba_analysis_order, st_ivas->sba_mode, IVAS_MAX_NUM_BANDS - SPAR_DIRAC_SPLIT_START_BAND ) ) != IVAS_ERR_OK )
        {
            return error;
        }
    }

    if ( ( ( hDecoderConfig->output_config == AUDIO_CONFIG_FOA ) || ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_STEREO ) || ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_MONO ) ) && ( ( sba_mode_old != st_ivas->sba_mode ) && ( st_ivas->sba_mode == SBA_MODE_SPAR ) ) )
    {
        if ( st_ivas->hDirAC != NULL )
        {
            ivas_dirac_dec_close( st_ivas->hDirAC );
            st_ivas->hDirAC = NULL;
        }

        st_ivas->hSpar->enc_param_start_band = min( IVAS_MAX_NUM_BANDS, SPAR_DIRAC_SPLIT_START_BAND );

        ivas_dirac_config_bands( band_grouping, IVAS_MAX_NUM_BANDS, (int16_t) ( st_ivas->hDecoderConfig->output_Fs * INV_CLDFB_BANDWIDTH + 0.5f ),
                                 st_ivas->hSpar->dirac_to_spar_md_bands, st_ivas->hQMetaData->useLowerBandRes, st_ivas->hSpar->enc_param_start_band, 0 );
    }
#else
    if ( ( ( st_ivas->renderer_type != RENDERER_DISABLE ) && ( st_ivas->renderer_type != RENDERER_SBA_LINEAR_DEC ) ) || ( sba_mode_old != st_ivas->sba_mode ) )
    {
        DIRAC_CONFIG_FLAG flag_config;
@@ -323,6 +412,8 @@ ivas_error ivas_sba_dec_reconfigure(
            return error;
        }
    }
#endif

    else if ( st_ivas->renderer_type == RENDERER_DISABLE || ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_DEC && st_ivas->sba_mode != SBA_MODE_SPAR ) )
    {
        if ( st_ivas->hDirAC != NULL )
Loading