Commit 50e723e4 authored by norvell's avatar norvell
Browse files

Merge with main

parents 999e2b00 4fc98050
Loading
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -238,6 +238,12 @@ uint32_t ivas_syn_output(
    int16_t *synth_out                                          /* o  : integer 16 bits synthesis signal        */
);

#ifdef FIX_I98_HANDLES_TO_NULL
void ivas_initialize_handles_enc(
    Encoder_Struct *st_ivas                                     /* i/o: IVAS encoder structure                  */
);
#endif

ivas_error ivas_init_encoder(
    Encoder_Struct *st_ivas,                                    /* i/o: IVAS encoder structure                  */
    Indice ind_list[][MAX_NUM_INDICES],                         /* i  : indices list                            */
+2 −1
Original line number Diff line number Diff line
@@ -147,9 +147,10 @@
/*#define FIX_I1_113*/                                  /* under review : MCT bit distribution optimization for SBA high bitrates*/

#define SPAR_SCALING_HARMONIZATION                      /* Issue 80: Changes to harmonize scaling in spar */

#define SBA_INTERN_CONFIG_FIX_HOA2                      /* Issue 99 : Fix for incorrect internal_config when output format is HOA2 or FOA*/
#define FIX_I102_SWB_TBE_SWITCH                         /* Issue 102: avoid IO->SWB switching code for IVAS, generate SHB ACB mem with lerp in case of switch */
#define FIX_I98_HANDLES_TO_NULL                         /* Issue 98: do the setting of all handles to NULL in one place */
#define FIX_I102_SWB_TBE_SWITCH                         /* Issue 102: avoid IO->SWB switching code for IVAS, generate SHB ACB mem with lerp in case of switch */

/* ################## End DEVELOPMENT switches ######################### */
/* clang-format on */
+20 −6
Original line number Diff line number Diff line
@@ -679,6 +679,7 @@ ivas_error ivas_init_decoder(
        }
    }

#ifndef FIX_I98_HANDLES_TO_NULL
#if 0
    /*-----------------------------------------------------------------*
     * Dummy pointers to decoder handles
@@ -732,7 +733,7 @@ ivas_error ivas_init_decoder(
    st_ivas->hHrtf = NULL;              /* Crend hrtf data */
    st_ivas->hCrend = NULL;             /* Crend renderer */
#endif

#endif
    /*-----------------------------------------------------------------*
     * Allocate and initalize SCE/CPE and other handles
     *-----------------------------------------------------------------*/
@@ -1504,9 +1505,14 @@ void ivas_initialize_handles_dec(
        st_ivas->hCPE[i] = NULL;
    }

#ifdef FIX_I98_HANDLES_TO_NULL
    st_ivas->bit_stream = NULL;
#else
    st_ivas->nSCE = 0;
    st_ivas->nCPE = 0;
#endif
    st_ivas->mem_hp20_out = NULL;
    st_ivas->hLimiter = NULL;

    /* ISM metadata handles */
    for ( i = 0; i < MAX_NUM_OBJECTS; i++ )
@@ -1515,7 +1521,9 @@ void ivas_initialize_handles_dec(
    }

    /* spatial coding handles */
#ifndef FIX_I98_HANDLES_TO_NULL
    st_ivas->hIsmRendererData = NULL;
#endif
    st_ivas->hDirAC = NULL;
    st_ivas->hSpar = NULL;
    st_ivas->hMasa = NULL;
@@ -1539,7 +1547,6 @@ void ivas_initialize_handles_dec(

    st_ivas->hHeadTrackData = NULL;
    st_ivas->hHrtfTD = NULL;
    st_ivas->hLimiter = NULL;
    st_ivas->hLsSetupCustom = NULL;
    st_ivas->hRenderConfig = NULL;

@@ -2015,11 +2022,18 @@ static ivas_error doSanityChecks_IVAS(
#endif

#ifdef DEBUGGING
#ifdef FIX_I98_HANDLES_TO_NULL
    if ( ( st_ivas->hDecoderConfig->Opt_HRTF_binary || st_ivas->hDecoderConfig->force_rend == FORCE_TD_RENDERER ) && ( ( st_ivas->ivas_format != MC_FORMAT && st_ivas->ivas_format != ISM_FORMAT ) || output_config != AUDIO_CONFIG_BINAURAL || ( st_ivas->ivas_format == ISM_FORMAT && st_ivas->ism_mode == ISM_MODE_PARAM ) || ( st_ivas->ivas_format == MC_FORMAT && st_ivas->mc_mode != MC_MODE_MCT ) ) )
#else
    if ( ( st_ivas->hHrtfTD != NULL || st_ivas->hDecoderConfig->force_rend == FORCE_TD_RENDERER ) && ( ( st_ivas->ivas_format != MC_FORMAT && st_ivas->ivas_format != ISM_FORMAT ) || output_config != AUDIO_CONFIG_BINAURAL || ( st_ivas->ivas_format == ISM_FORMAT && st_ivas->ism_mode == ISM_MODE_PARAM ) || ( st_ivas->ivas_format == MC_FORMAT && st_ivas->mc_mode != MC_MODE_MCT ) ) )
#endif
#else
#ifdef FIX_I98_HANDLES_TO_NULL
    if ( st_ivas->hDecoderConfig->Opt_HRTF_binary && ( ( st_ivas->ivas_format != MC_FORMAT && st_ivas->ivas_format != ISM_FORMAT ) || output_config != AUDIO_CONFIG_BINAURAL || ( st_ivas->ivas_format == ISM_FORMAT && st_ivas->ism_mode == ISM_MODE_PARAM ) ) )
#else
    if ( st_ivas->hHrtfTD != NULL && ( ( st_ivas->ivas_format != MC_FORMAT && st_ivas->ivas_format != ISM_FORMAT ) || output_config != AUDIO_CONFIG_BINAURAL || ( st_ivas->ivas_format == ISM_FORMAT && st_ivas->ism_mode == ISM_MODE_PARAM ) ) )
#endif

#endif
    {
        return IVAS_ERROR( IVAS_ERR_INVALID_OUTPUT_FORMAT, "Incorrect output configuration: Time Domain object renderer not supported in this configuration" );
    }
+48 −31
Original line number Diff line number Diff line
@@ -110,12 +110,17 @@ ivas_error IVAS_DEC_Open(
    float no_diegetic_pan )
{
    IVAS_DEC_HANDLE hIvasDec;
    Decoder_Struct *st_ivas;

    if ( phIvasDec == NULL )
    {
        return IVAS_ERR_UNEXPECTED_NULL_POINTER;
    }

    /*-----------------------------------------------------------------*
     * Allocate and initialize IVAS application decoder handle
     *-----------------------------------------------------------------*/

    if ( ( *phIvasDec = (IVAS_DEC_HANDLE) count_malloc( sizeof( struct IVAS_DEC ) ) ) == NULL )
    {
        return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for IVAS decoder handle" );
@@ -128,6 +133,16 @@ ivas_error IVAS_DEC_Open(

    hIvasDec->mode = mode;

    hIvasDec->bitstreamformat = G192;
    hIvasDec->Opt_VOIP = 0;
    hIvasDec->amrwb_rfc4867_flag = -1;
    hIvasDec->prev_ft_speech = 1; /* RXDTX handler previous frametype flag for G.192 format AMRWB SID_FIRST detection */
    hIvasDec->CNG = 0;            /* RXDTX handler CNG = 1, no CNG = 0*/

    /*-----------------------------------------------------------------*
     * Initialize IVAS-codec decoder state
     *-----------------------------------------------------------------*/

    if ( ( hIvasDec->st_ivas = (Decoder_Struct *) count_malloc( sizeof( Decoder_Struct ) ) ) == NULL )
    {
        return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for IVAS decoder structure" );
@@ -138,48 +153,49 @@ ivas_error IVAS_DEC_Open(
        return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for Decoder config structure" );
    }

    init_decoder_config( hIvasDec->st_ivas->hDecoderConfig, orientation_tracking, no_diegetic_pan );
    /*-----------------------------------------------------------------*
     * Initialize IVAS-codec decoder state
     *-----------------------------------------------------------------*/

    hIvasDec->bitstreamformat = G192;
    hIvasDec->Opt_VOIP = 0;
    hIvasDec->amrwb_rfc4867_flag = -1;
    hIvasDec->prev_ft_speech = 1; /* RXDTX handeler previous frametype flag for G.192 format AMRWB SID_FIRST detection */
    hIvasDec->CNG = 0;            /* RXDTX handler CNG = 1, no CNG = 0*/
    st_ivas = hIvasDec->st_ivas;

    /* initialize pointers to handles */
    ivas_initialize_handles_dec( hIvasDec->st_ivas );
    /* initialize Decoder Config. handle */
    init_decoder_config( hIvasDec->st_ivas->hDecoderConfig, orientation_tracking, no_diegetic_pan );

    /* initialize pointers to handles to NULL */
    ivas_initialize_handles_dec( st_ivas );

    /* high-level set parameters */
    /* set high-level parameters */
    if ( mode == IVAS_DEC_MODE_EVS )
    {
        hIvasDec->st_ivas->codec_mode = 0; /* unknown before first frame */
        hIvasDec->st_ivas->element_mode_init = EVS_MONO;
        hIvasDec->st_ivas->ivas_format = MONO_FORMAT;
        hIvasDec->st_ivas->transport_config = AUDIO_CONFIG_INVALID;
        hIvasDec->st_ivas->intern_config = AUDIO_CONFIG_INVALID;
        hIvasDec->st_ivas->writeFECoffset = 0;
        st_ivas->codec_mode = 0; /* unknown before first frame */
        st_ivas->element_mode_init = EVS_MONO;
        st_ivas->ivas_format = MONO_FORMAT;
        st_ivas->transport_config = AUDIO_CONFIG_INVALID;
        st_ivas->intern_config = AUDIO_CONFIG_INVALID;
        st_ivas->writeFECoffset = 0;

        return IVAS_ERR_OK;
    }
    else if ( mode == IVAS_DEC_MODE_IVAS )
    {
        hIvasDec->st_ivas->codec_mode = 0; /* unknown before first frame */
        hIvasDec->st_ivas->element_mode_init = -1;
        hIvasDec->st_ivas->ivas_format = UNDEFINED_FORMAT;
        hIvasDec->st_ivas->transport_config = AUDIO_CONFIG_INVALID;
        hIvasDec->st_ivas->intern_config = AUDIO_CONFIG_INVALID;
        hIvasDec->st_ivas->renderer_type = RENDERER_DISABLE;
        hIvasDec->st_ivas->ini_frame = 0;
        hIvasDec->st_ivas->ini_active_frame = 0;
        hIvasDec->st_ivas->writeFECoffset = 0;
        st_ivas->codec_mode = 0; /* unknown before first frame */
        st_ivas->element_mode_init = -1;
        st_ivas->ivas_format = UNDEFINED_FORMAT;
        st_ivas->transport_config = AUDIO_CONFIG_INVALID;
        st_ivas->intern_config = AUDIO_CONFIG_INVALID;
        st_ivas->renderer_type = RENDERER_DISABLE;
        st_ivas->ini_frame = 0;
        st_ivas->ini_active_frame = 0;
        st_ivas->writeFECoffset = 0;

        hIvasDec->st_ivas->ism_mode = ISM_MODE_NONE;
        hIvasDec->st_ivas->sba_mode = SBA_MODE_NONE;
        hIvasDec->st_ivas->mc_mode = MC_MODE_NONE;
        st_ivas->ism_mode = ISM_MODE_NONE;
        st_ivas->sba_mode = SBA_MODE_NONE;
        st_ivas->mc_mode = MC_MODE_NONE;

        hIvasDec->st_ivas->sba_order = 0;
        hIvasDec->st_ivas->sba_planar = 0;
        hIvasDec->st_ivas->sba_analysis_order = 0;
        st_ivas->sba_order = 0;
        st_ivas->sba_planar = 0;
        st_ivas->sba_analysis_order = 0;

        return IVAS_ERR_OK;
    }
@@ -252,6 +268,7 @@ void IVAS_DEC_Close(
            ( *phIvasDec )->st_ivas->hDecoderConfig = NULL;
        }

#ifndef FIX_I98_HANDLES_TO_NULL
        if ( ( *phIvasDec )->st_ivas->hHeadTrackData != NULL )
        {
            count_free( ( *phIvasDec )->st_ivas->hHeadTrackData );
@@ -261,7 +278,7 @@ void IVAS_DEC_Close(
        ivas_render_config_close( &( ( *phIvasDec )->st_ivas->hRenderConfig ) );

        ivas_HRTF_binary_close( &( *phIvasDec )->st_ivas->hHrtfTD );

#endif
        count_free( ( *phIvasDec )->st_ivas );
    }

+68 −0
Original line number Diff line number Diff line
@@ -237,6 +237,69 @@ void copy_encoder_config(
}


#ifdef FIX_I98_HANDLES_TO_NULL
/*-------------------------------------------------------------------------
 * ivas_initialize_handles_enc()
 *
 * NULL initialization of handles
 *-------------------------------------------------------------------------*/

void ivas_initialize_handles_enc(
    Encoder_Struct *st_ivas /* i/o: IVAS encoder structure                  */
)
{
    int16_t i;

    for ( i = 0; i < MAX_SCE; i++ )
    {
        st_ivas->hSCE[i] = NULL;
    }

    for ( i = 0; i < MAX_CPE; i++ )
    {
        st_ivas->hCPE[i] = NULL;
    }

    st_ivas->mem_hp20_in = NULL;

    /* ISm metadata handles */
    for ( i = 0; i < MAX_NUM_OBJECTS; i++ )
    {
        st_ivas->hIsmMetaData[i] = NULL;
    }

    /* Q Metadata handle */
    st_ivas->hQMetaData = NULL;

    /* DirAC handle */
    st_ivas->hDirAC = NULL;

    /* SPAR handle */
    st_ivas->hSpar = NULL;

    /* MASA encoder handle */
    st_ivas->hMasa = NULL;

    /* MCT handle */
    st_ivas->hMCT = NULL;

    /* Parametric MC handle */
    st_ivas->hParamMC = NULL;

    /* Multi-channel MASA handle */
    st_ivas->hMcMasa = NULL;

    /* Stereo downmix for EVS encoder handle */
    st_ivas->hStereoDmxEVS = NULL;

    /* LFE  handle */
    st_ivas->hLFE = NULL;

    return;
}
#endif


/*-------------------------------------------------------------------*
 * ivas_init_encoder()
 *
@@ -275,6 +338,9 @@ ivas_error ivas_init_encoder(
    st_ivas->mc_mode = MC_MODE_NONE;
    st_ivas->sba_mode = SBA_MODE_NONE;

#ifdef FIX_I98_HANDLES_TO_NULL
    st_ivas->nchan_transport = -1;
#else
    /*-----------------------------------------------------------------*
     * Dummy pointers to max. number of SCEs and CPEs
     *-----------------------------------------------------------------*/
@@ -323,6 +389,7 @@ ivas_error ivas_init_encoder(

    /* LFE  handle */
    st_ivas->hLFE = NULL;
#endif

    /*-----------------------------------------------------------------*
     * Allocate and initialize SCE/CPE and other handles
@@ -986,3 +1053,4 @@ void ivas_destroy_enc(

    return;
}
Loading