Commit ed152dd2 authored by Jan Brouwer's avatar Jan Brouwer
Browse files

Merge branch 'main' into 196-refactor-renderer-output-configuration

parents 48a4ca88 92420d58
Loading
Loading
Loading
Loading
Loading

lib_com/bitstream.c

100644 → 100755
+14 −0
Original line number Diff line number Diff line
@@ -772,15 +772,27 @@ int16_t get_ivas_max_num_indices_metadata( /* o
        }
        else if ( ivas_total_brate <= IVAS_256k )
        {
#ifdef FIX_483b
            return 1050;
#else
            return 1000;
#endif
        }
        else if ( ivas_total_brate <= IVAS_384k )
        {
#ifdef FIX_509
            return 2000;
#else
            return 1500;
#endif
        }
        else
        {
#ifdef FIX_509
            return 2500;
#else
            return 2000;
#endif
        }
    }
    else if ( ivas_format == MASA_FORMAT )
@@ -2851,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
@@ -924,7 +924,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,
@@ -932,6 +932,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
}


+4 −0
Original line number Diff line number Diff line
@@ -235,7 +235,11 @@ static inline const char *ivas_error_to_string( ivas_error error_code )
        case IVAS_ERR_INVALID_HRTF:
            return "Unsupported HRTF filter set";
        case IVAS_ERR_INVALID_INPUT_FORMAT:
#ifdef FIX_510
            return "Invalid input format";
#else
            return "Invalid format of input bitstream";
#endif
        case IVAS_ERR_INVALID_INDEX:
            return "Invalid index";
        default:
+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 )
    {
Loading