Commit 18a2b731 authored by Dominik Weckbecker's avatar Dominik Weckbecker 💬
Browse files

Merge branch 'main' into 509-assert-in-check_ind_list_limits-for-sba-at-384kbps

parents d24d913e 981e6376
Loading
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -2863,7 +2863,9 @@ ivas_error preview_indices(
                if ( bit_stream[2] == 0 )
                {
                    st_ivas->ivas_format = SBA_FORMAT;
#ifndef SBA_MODE_CLEAN_UP
                    st_ivas->sba_mode = ivas_sba_mode_select();
#endif
                }
                else
                {
+2 −1
Original line number Diff line number Diff line
@@ -919,7 +919,7 @@ typedef enum {
#define SBA_NHARM_HOA3                          16
#define SBA_T_DESIGN_11_SIZE                    70
#define SBA_DTX_BITRATE_THRESHOLD               IVAS_80k

#ifndef SBA_MODE_CLEAN_UP
typedef enum 
{
    SBA_MODE_NONE,
@@ -927,6 +927,7 @@ typedef enum
    SBA_MODE_SPAR, // VE: this is actually SBA_MODE_SPAR_DIRAC
} SBA_MODE;

#endif

/*----------------------------------------------------------------------------------*
 * DirAC Constants 
+116 −61
Original line number Diff line number Diff line
@@ -85,7 +85,11 @@ ivas_error ivas_dirac_config(
{
    IVAS_FORMAT ivas_format;
    int16_t sba_order;
#ifndef SBA_MODE_CLEAN_UP
    int16_t *nSCE, *nCPE, *element_mode, *nchan_transport;
#else
    int16_t *element_mode;
#endif
    int32_t ivas_total_brate;
    DIRAC_CONFIG_DATA_HANDLE hConfig;
    IVAS_QMETADATA_HANDLE hQMetaData;
@@ -94,7 +98,9 @@ ivas_error ivas_dirac_config(
    ivas_error error;
    int16_t spar_dirac_split_band;
    IVAS_FB_MIXER_HANDLE hFbMdft;
#ifndef SBA_MODE_CLEAN_UP
    SBA_MODE sba_mode;
#endif

    int16_t *dirac_to_spar_md_bands;

@@ -104,17 +110,23 @@ ivas_error ivas_dirac_config(
    if ( enc_dec == ENC )
    {
        ivas_format = ( (Encoder_Struct *) st_ivas )->hEncoderConfig->ivas_format;
#ifndef SBA_MODE_CLEAN_UP
        nSCE = &( ( (Encoder_Struct *) st_ivas )->nSCE );
        nCPE = &( (Encoder_Struct *) st_ivas )->nCPE;
#endif
        element_mode = &( (Encoder_Struct *) st_ivas )->hEncoderConfig->element_mode_init;
#ifndef SBA_MODE_CLEAN_UP
        nchan_transport = &( (Encoder_Struct *) st_ivas )->nchan_transport;
#endif
        sba_order = ( (Encoder_Struct *) st_ivas )->sba_analysis_order;
        ivas_total_brate = ( (Encoder_Struct *) st_ivas )->hEncoderConfig->ivas_total_brate;
        Fs = ( (Encoder_Struct *) st_ivas )->hEncoderConfig->input_Fs;
        band_grouping = ( (Encoder_Struct *) st_ivas )->hDirAC->band_grouping;
        hConfig = ( (Encoder_Struct *) st_ivas )->hDirAC->hConfig;
        hQMetaData = ( (Encoder_Struct *) st_ivas )->hQMetaData;
#ifndef SBA_MODE_CLEAN_UP
        sba_mode = ( (Encoder_Struct *) st_ivas )->sba_mode;
#endif
        if ( ( (Encoder_Struct *) st_ivas )->hSpar != NULL )
        {
            hFbMdft = ( (Encoder_Struct *) st_ivas )->hSpar->hFbMixer;
@@ -123,22 +135,32 @@ ivas_error ivas_dirac_config(
        {
            hFbMdft = NULL;
        }
#ifndef SBA_MODE_CLEAN_UP
        dirac_to_spar_md_bands = ( (Encoder_Struct *) st_ivas )->hDirAC->dirac_to_spar_md_bands;
#else
        dirac_to_spar_md_bands = ( (Encoder_Struct *) st_ivas )->hSpar->dirac_to_spar_md_bands;
#endif
    }
    else
    {
        ivas_format = ( (Decoder_Struct *) st_ivas )->ivas_format;
#ifndef SBA_MODE_CLEAN_UP
        nSCE = &( (Decoder_Struct *) st_ivas )->nSCE;
        nCPE = &( (Decoder_Struct *) st_ivas )->nCPE;
#endif
        element_mode = &( (Decoder_Struct *) st_ivas )->element_mode_init;
#ifndef SBA_MODE_CLEAN_UP
        nchan_transport = &( (Decoder_Struct *) st_ivas )->nchan_transport;
#endif
        sba_order = ( (Decoder_Struct *) st_ivas )->sba_analysis_order;
        ivas_total_brate = ( (Decoder_Struct *) st_ivas )->hDecoderConfig->ivas_total_brate;
        Fs = ( (Decoder_Struct *) st_ivas )->hDecoderConfig->output_Fs;
        band_grouping = ( (Decoder_Struct *) st_ivas )->hDirAC->band_grouping;
        hConfig = ( (Decoder_Struct *) st_ivas )->hDirAC->hConfig;
        hQMetaData = ( (Decoder_Struct *) st_ivas )->hQMetaData;
#ifndef SBA_MODE_CLEAN_UP
        sba_mode = ( (Decoder_Struct *) st_ivas )->sba_mode;
#endif
        if ( ( (Decoder_Struct *) st_ivas )->hSpar != NULL )
        {
            hFbMdft = ( (Decoder_Struct *) st_ivas )->hSpar->hFbMixer;
@@ -148,10 +170,18 @@ ivas_error ivas_dirac_config(
            hFbMdft = NULL;
        }
        ( (Decoder_Struct *) st_ivas )->hDirAC->hFbMdft = hFbMdft;
#ifndef SBA_MODE_CLEAN_UP
        dirac_to_spar_md_bands = ( (Decoder_Struct *) st_ivas )->hDirAC->dirac_to_spar_md_bands;
#else
        dirac_to_spar_md_bands = ( (Decoder_Struct *) st_ivas )->hSpar->dirac_to_spar_md_bands;
#endif
    }

#ifndef SBA_MODE_CLEAN_UP
    if ( sba_mode == SBA_MODE_SPAR )
#else
    if ( ivas_format == SBA_FORMAT )
#endif
    {
        hConfig->nbands = IVAS_MAX_NUM_BANDS;

@@ -172,14 +202,22 @@ ivas_error ivas_dirac_config(
    hConfig->dec_param_estim_old = hConfig->dec_param_estim;
    if ( ivas_format == SBA_FORMAT ) /* skip for MASA decoder */
    {
#ifndef SBA_MODE_CLEAN_UP
        if ( ( error = ivas_dirac_sba_config( hQMetaData, nchan_transport, nSCE, nCPE, element_mode, ivas_total_brate, sba_order, sba_mode, hConfig->nbands - spar_dirac_split_band ) ) != IVAS_ERR_OK )
#else
        if ( ( error = ivas_dirac_sba_config( hQMetaData, element_mode, ivas_total_brate, sba_order, hConfig->nbands - spar_dirac_split_band ) ) != IVAS_ERR_OK )
#endif
        {
            return error;
        }

        if ( hQMetaData != NULL )
        {
#ifndef SBA_MODE_CLEAN_UP
            if ( enc_dec == ENC || sba_mode != SBA_MODE_SPAR )
#else
            if ( enc_dec == ENC || ivas_format != SBA_FORMAT )
#endif
            {
                hConfig->nbands = hQMetaData->q_direction[0].cfg.nbands;
            }
@@ -187,8 +225,10 @@ ivas_error ivas_dirac_config(
        }


#ifndef SBA_MODE_CLEAN_UP
        if ( sba_mode == SBA_MODE_SPAR )
        {
#endif
            hConfig->dec_param_estim = TRUE;
            if ( hConfig->dec_param_estim == TRUE )
            {
@@ -203,6 +243,7 @@ ivas_error ivas_dirac_config(
                set_c( (int8_t *) hQMetaData->twoDirBands, (int8_t) 1, hQMetaData->q_direction[0].cfg.nbands );
                hQMetaData->numTwoDirBands = (uint8_t) hQMetaData->q_direction[0].cfg.nbands;
            }
#ifndef SBA_MODE_CLEAN_UP
        }
        else
        {
@@ -211,9 +252,14 @@ ivas_error ivas_dirac_config(
                hConfig->dec_param_estim = TRUE;
            }
        }
#endif
    }

#ifndef SBA_MODE_CLEAN_UP
    if ( sba_mode == SBA_MODE_SPAR )
#else
    if ( ivas_format == SBA_FORMAT )
#endif
    {
        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 );
    }
@@ -402,18 +448,24 @@ void ivas_get_dirac_sba_max_md_bits(

ivas_error ivas_dirac_sba_config(
    IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: q_metadata handle                                    */
#ifndef SBA_MODE_CLEAN_UP
    int16_t *nchan_transport, /* o  : number of transport channel needed for MASA format   */
    int16_t *nSCE,            /* o  : number of SCEs                                       */
    int16_t *nCPE,            /* o  : number of CPEs                                       */
#endif
    int16_t *element_mode,   /* i/o: element mode of the core coder                       */
    int32_t sba_total_brate, /* i  : SBA total bitrate                                    */
    const int16_t sba_order, /* i  : Ambisonic (SBA) order                                */
#ifndef SBA_MODE_CLEAN_UP
    const SBA_MODE sba_mode, /* i  : SBA mode                                             */
#endif
    const int16_t nbands /* i  : number of frequency bands                            */
)
{
#ifndef SBA_MODE_CLEAN_UP
    int16_t i;
    int16_t nbands_wb;
#endif
    int16_t nbands_coded;
    int16_t hodirac_flag;
    ivas_error error;
@@ -422,8 +474,10 @@ ivas_error ivas_dirac_sba_config(
    hQMetaData->is_masa_ivas_format = 0;
    hodirac_flag = ivas_get_hodirac_flag( sba_total_brate, sba_order );

#ifndef SBA_MODE_CLEAN_UP
    if ( sba_mode == SBA_MODE_SPAR )
    {
#endif
        /* map the bitrate for SID frame */
        if ( sba_total_brate == IVAS_SID_5k2 )
        {
@@ -555,6 +609,7 @@ ivas_error ivas_dirac_sba_config(
#endif

        return error;
#ifndef SBA_MODE_CLEAN_UP
    }

    if ( sba_total_brate > IVAS_SID_5k2 )
@@ -710,8 +765,8 @@ ivas_error ivas_dirac_sba_config(
            assert( !"SBA number of transport channels must be 8 or lower" );
        }
    }

    return error;
#endif
}


+9 −3
Original line number Diff line number Diff line
@@ -101,7 +101,9 @@ static int16_t ivas_get_num_bands(
ivas_error ivas_fb_set_cfg(
    IVAS_FB_CFG **pFb_cfg_out, /* o  : FB config. handle                */
    const int16_t ivas_format, /* i  : IVAS format                      */
#ifndef SBA_MODE_CLEAN_UP
    const SBA_MODE sba_mode, /* i  : SBA mode                    */
#endif
    const int16_t num_in_chans,    /* i  : number of FB input channels      */
    const int16_t num_out_chans,   /* i  : number of FB output channels     */
    const int16_t active_w_mixing, /* i  : active_w_mixing flag             */
@@ -135,11 +137,14 @@ ivas_error ivas_fb_set_cfg(
    {
        pFb_cfg->fb_latency = NS2SA( sampling_rate, DELAY_FB_1_NS );

#ifndef SBA_MODE_CLEAN_UP
        if ( sba_mode == SBA_MODE_SPAR )
        {
#endif
            pFb_cfg->fade_len = NS2SA( sampling_rate, DELAY_FB_4_NS );
            pFb_cfg->prior_input_length = NS2SA( sampling_rate, FRAME_SIZE_NS );
            pFb_cfg->windowed_fr_offset = (int16_t) ( (float) ( sampling_rate / FRAMES_PER_SEC ) * 3.0f / 4.0f ) - NS2SA( sampling_rate, DELAY_DIRAC_SPAR_ENC_CMP_NS );
#ifndef SBA_MODE_CLEAN_UP
        }
        else /* SBA_MODE_DIRAC */
        {
@@ -148,6 +153,7 @@ ivas_error ivas_fb_set_cfg(
            /* extra SPAR/DirAC synchro delay */
            pFb_cfg->prior_input_length += NS2SA( sampling_rate, DELAY_FB_1_NS );
        }
#endif
    }
    else if ( ivas_format == MASA_FORMAT )
    {
+53 −7
Original line number Diff line number Diff line
@@ -3133,8 +3133,11 @@ void reset_metadata_spatial(
    const int32_t element_brate,                                /* i  : element bitrate                         */
    int32_t *total_brate,                                       /* o  : total bitrate                           */
    const int32_t core_brate,                                   /* i  : core bitrate                            */
    const int16_t nb_bits_metadata,                             /* i  : number of meatdata bits                 */
    const int16_t nb_bits_metadata                              /* i  : number of meatdata bits                 */
#ifndef SBA_MODE_CLEAN_UP
    ,
    const SBA_MODE sba_mode                                     /* i  : SBA mode                                */
#endif
);

/*! r: number of bits written */
@@ -3142,8 +3145,11 @@ void ivas_qmetadata_enc_sid_encode(
    BSTR_ENC_HANDLE hMetaData,                                  /* i/o: metadata bitstream handle               */
    IVAS_QMETADATA *q_metadata,                                 /* i/o: metadata handle                         */
    const int16_t masa_sid_descriptor,                          /* i  : description of MASA SID coding structure*/
    const int16_t ivas_format,                                  /* i  : ivas format                             */
    const int16_t ivas_format                                   /* i  : ivas format                             */
#ifndef SBA_MODE_CLEAN_UP
    ,
    const SBA_MODE sba_mode                                     /* i  : SBA mode                                */
#endif
);

/*! r: number of bits read */
@@ -3178,8 +3184,11 @@ int16_t ivas_qmetadata_dec_sid_decode(
    int16_t *index,                                             /* i/o: bitstream position                      */
    const int16_t nchan_transport,                              /* i  : number of transport channels            */
    int16_t *element_mode,                                      /* o  : element mode                            */
    const int16_t ivas_format,                                  /* i  : IVAS format                             */
    const int16_t ivas_format                                   /* i  : IVAS format                             */
#ifndef SBA_MODE_CLEAN_UP
    ,
    const SBA_MODE sba_mode                                     /* i  : SBA mode                                */
#endif
);

void ivas_qmetadata_to_dirac(
@@ -3187,7 +3196,11 @@ void ivas_qmetadata_to_dirac(
    DIRAC_DEC_HANDLE hDirAC,                                    /* o  : DirAC decoder structure                 */
    MASA_DECODER_HANDLE hMasa,                                  /* i  : MASA decoder structure                  */
    const int32_t ivas_total_brate,                             /* i  : IVAS total bitrate                      */
#ifndef SBA_MODE_CLEAN_UP
    const SBA_MODE sba_mode,                                    /* i  : SBA mode                                */
#else
    const IVAS_FORMAT ivas_format,                              /* i  : IVAS format                             */
#endif
    const int16_t hodirac_flag,                                 /* i : flag to indicate HO-DirAC mode           */
    int16_t *dirac_to_spar_md_bands                             /* o  : DirAC->SPAR MD bands                    */
);
@@ -3390,13 +3403,18 @@ void ivas_dirac_param_est_enc(
    float **pp_fr_real,
    float **pp_fr_imag,
    const int16_t input_frame, 
#ifndef SBA_MODE_CLEAN_UP
    const SBA_MODE sba_mode    
#else
    const IVAS_FORMAT ivas_format 
#endif
    ,
   const int16_t hodirac_flag,
   const int16_t nchan_fb_in
 );


#ifndef SBA_MODE_CLEAN_UP
/*----------------------------------------------------------------------------------*
 * SBA format prototypes
 *----------------------------------------------------------------------------------*/
@@ -3405,7 +3423,7 @@ void ivas_dirac_param_est_enc(
SBA_MODE ivas_sba_mode_select( 
    void
);

#endif
void ivas_sba_config(
    const int32_t sba_total_brate,                              /* i  : SBA total bitrate                       */
    int16_t sba_order,                                          /* i  : Ambisonic (SBA) order                   */
@@ -3568,6 +3586,7 @@ void ivas_dirac_enc_close(
    const int32_t input_Fs                                      /* i  : input sampling_rate                     */
);

#ifndef SBA_MODE_CLEAN_UP
void ivas_dirac_enc(
    DIRAC_ENC_HANDLE hDirAC,                                    /* i/o: encoder DirAC handle                    */
    IVAS_QMETADATA_HANDLE hQMetaData,                           /* i/o: q_metadata handle                       */
@@ -3578,7 +3597,20 @@ void ivas_dirac_enc(
    const int16_t input_frame,                                  /* i  : input frame length                      */
    const int16_t sba_planar                                    /* i  : SBA planar flag                         */
);

#else
void ivas_dirac_enc(
    DIRAC_ENC_HANDLE hDirAC,                                   /* i/o: encoder DirAC handle                  */
    IVAS_QMETADATA_HANDLE hQMetaData,                          /* i/o: q_metadata handle                     */
    BSTR_ENC_HANDLE hMetaData,                                 /* i/o: Metadata bitstream handle             */
    float data_f[][L_FRAME48k],                                /* i/o: SBA channels                          */
    float **ppIn_FR_real,                                      /* o  : real freq domain values               */
    float **ppIn_FR_imag,                                      /* o  : imag freq domain values               */
    const int16_t input_frame,                                 /* i  : input frame length                    */
    const int16_t dtx_vad,                                     /* i  : DTX vad flag                          */
    const IVAS_FORMAT ivas_format,                             /* i  : ivas format                           */
    int16_t hodirac_flag                                       /* i  : hodirac flag                           */
);                           
#endif
ivas_error ivas_dirac_config(
    void *st_ivas,                                              /* i/o: IVAS encoder/decoder state structure    */
    const int16_t enc_dec                                       /* i  : encoder or decoder flag                 */
@@ -3605,13 +3637,17 @@ void ivas_get_dirac_sba_max_md_bits(

ivas_error ivas_dirac_sba_config(
    IVAS_QMETADATA_HANDLE hQMetaData,                           /* i/o: q_metadata handle                                    */
#ifndef SBA_MODE_CLEAN_UP
    int16_t *nchan_transport,                                   /* o  : number of transport channel needed for MASA format   */
    int16_t *nSCE,                                              /* o  : number of SCEs                                       */
    int16_t *nCPE,                                              /* o  : number of CPEs                                       */
#endif
    int16_t *element_mode,                                      /* o  : element mode of the core coder                       */
    int32_t sba_total_brate,                                    /* i  : SBA total bitrate                                    */
    const int16_t sba_order,                                    /* i  : Ambisonic (SBA) order                                */
#ifndef SBA_MODE_CLEAN_UP
    const SBA_MODE sba_mode,                                    /* i  : SBA mode                                             */
#endif
    const int16_t nbands                                        /* i  : number of frequency bands                            */
);

@@ -3644,7 +3680,9 @@ void ivas_dirac_dec_read_BS(
    DIRAC_DEC_HANDLE hDirAC,                                    /* i/o: decoder DirAC handle                    */
    IVAS_QMETADATA_HANDLE hQMetaData,                           /* i/o: q metadata                              */
    int16_t *nb_bits,                                           /* o  : number of bits read                     */
#ifndef SBA_MODE_CLEAN_UP
    const SBA_MODE sba_mode,                                    /* i  : SBA mode                                */
#endif
    const int16_t hodirac_flag,                                 /* i  : flag to indicate HO-DirAC mode          */
    int16_t *dirac_to_spar_md_bands                             /* o  : DirAC->SPAR MD bands                    */
);
@@ -5524,7 +5562,12 @@ void computeReferencePower_enc(
    float *reference_power,                                     /* o  : Estimated power                                 */
    const int16_t enc_param_start_band,                         /* i  : first band to process                           */
    const int16_t num_freq_bands,                               /* i  : Number of frequency bands                       */
#ifndef SBA_MODE_CLEAN_UP
    const SBA_MODE sba_mode                                     /* i  : SBA mode                                        */
#else
    const IVAS_FORMAT ivas_format,                              /* i  : ivas_format                                     */
    int16_t ref_power_w                                         /* i  : use 0 if hodirac is enabled                     */
#endif
    ,
    const int16_t nchan_ana                                     /* i  : number of analysis channels                     */
);
@@ -5657,7 +5700,9 @@ ivas_error ivas_td_binaural_renderer_sf(
ivas_error ivas_fb_set_cfg(
    IVAS_FB_CFG **pFb_cfg_out,                                  /* o  : FB config. handle                           */
    const int16_t ivas_format,                                  /* i  : IVAS format                                 */
#ifndef SBA_MODE_CLEAN_UP
    const SBA_MODE sba_mode,                                    /* i  : SBA mode                                    */
#endif
    const int16_t num_in_chans,                                 /* i  : number of FB input channels                 */
    const int16_t num_out_chans,                                /* i  : number of FB output channels                */
    const int16_t active_w_mixing,                              /* i  : active_w_mixing flag                        */
@@ -5688,12 +5733,13 @@ void ivas_fb_mixer_pcm_ingest(
    const int16_t HOA_md_ind[IVAS_SPAR_MAX_CH]
);

#ifndef SBA_MODE_CLEAN_UP
void ivas_dirac_enc_spar_delay_synchro(
    Encoder_Struct *st_ivas,                                    /* i/o: IVAS encoder structure                      */
    const int16_t input_frame,                                  /* i  : input frame length                          */
    float data_f[][L_FRAME48k]                                  /* i/o: SBA channels (ACN / SN3D)                   */
);

#endif
void ivas_fb_mixer_update_prior_input(
    IVAS_FB_MIXER_HANDLE hFbMixer,                              /* i/o: FB mixer handle                             */
    float *pcm_in[],                                            /* i  : input audio channels                        */
Loading