Commit 6d7aa532 authored by Tapani Pihlajakuja's avatar Tapani Pihlajakuja
Browse files

Refactors hDirAC and all related inits into separate decoding and rendering structures.

parent ce26b0c9
Loading
Loading
Loading
Loading
Loading
+40 −25
Original line number Diff line number Diff line
@@ -1037,6 +1037,7 @@ ivas_error ivas_param_ism_dec_open(

void ivas_param_ism_dec_close(
    DIRAC_DEC_HANDLE *hDirAC,                                   /* i/o: decoder DirAC handle                        */
    SPAT_PARAM_REND_COMMON_DATA_HANDLE *rend_common_data_out,   /* i/o: common spatial renderer data                */
    const AUDIO_CONFIG output_config                            /* i  : output audio configuration                  */
);

@@ -3162,8 +3163,9 @@ int16_t ivas_qmetadata_dec_sid_decode(

void ivas_qmetadata_to_dirac(
    const IVAS_QMETADATA_HANDLE hQMetaData,                     /* i  : frame of MASA q_metadata                */
    DIRAC_DEC_HANDLE hDirAC,                                    /* o  : DirAC decoder structure                 */
    DIRAC_DEC_HANDLE hDirAC,                                    /* i  : DirAC decoder structure                 */
    MASA_DECODER_HANDLE hMasa,                                  /* i  : MASA decoder structure                  */
    SPAT_PARAM_REND_COMMON_DATA_HANDLE rend_common_data,        /* i/o: common spatial renderer data handle     */
    const int32_t ivas_total_brate,                             /* i  : IVAS total bitrate                      */
    const IVAS_FORMAT ivas_format,                              /* i  : IVAS format                             */
    const int16_t hodirac_flag,                                 /* i  : flag to indicate HO-DirAC mode          */
@@ -3565,12 +3567,8 @@ ivas_error ivas_dirac_sba_config(
    const int16_t nbands                                        /* i  : number of frequency bands                            */
);

ivas_error ivas_dirac_dec_open(
    Decoder_Struct *st_ivas                                     /* i/o: IVAS decoder structure                  */
);

ivas_error ivas_dirac_allocate_parameters(
    DIRAC_DEC_HANDLE hDirAC,                                    /* i/o: decoder DirAC handle                    */
    SPAT_PARAM_REND_COMMON_DATA_HANDLE rend_common_data,        /* i/o: common data for spatial parametric rendering         */
    const int16_t params_flag                                   /* i  : set of parameters flag                               */
);

@@ -3580,11 +3578,19 @@ ivas_error ivas_dirac_dec_config(
);

void ivas_dirac_dec_close(
    DIRAC_DEC_HANDLE *hDirAC                                    /* i/o: decoder DirAC handle                    */
    DIRAC_DEC_HANDLE *hDirAC_out
);

void ivas_spat_rend_common_data_close(
    SPAT_PARAM_REND_COMMON_DATA_HANDLE *rend_common_data_out
);

void ivas_dirac_rend_close(
    DIRAC_REND_HANDLE *hDirACRend_out
);

void ivas_dirac_deallocate_parameters(
    DIRAC_DEC_HANDLE hDirAC,                                    /* i/o: decoder DirAC handle                    */
    SPAT_PARAM_REND_COMMON_DATA_HANDLE rend_common_data,        /* i/o: common data for spatial parametric rendering        */
    const int16_t params_flag                                   /* i  : set of parameters flag                              */
);

@@ -3592,6 +3598,7 @@ void ivas_dirac_dec_read_BS(
    const int32_t ivas_total_brate,                             /* i  : IVAS total bitrate                      */
    Decoder_State *st,                                          /* i/o: decoder Core state structure            */
    DIRAC_DEC_HANDLE hDirAC,                                    /* i/o: decoder DirAC handle                    */
    SPAT_PARAM_REND_COMMON_DATA_HANDLE rend_common_data,        /* i/o: common spatial rendering data handle    */
    IVAS_QMETADATA_HANDLE hQMetaData,                           /* i/o: q metadata                              */
    int16_t *nb_bits,                                           /* o  : number of bits read                     */
    const int16_t hodirac_flag,                                 /* i  : flag to indicate HO-DirAC mode          */
@@ -3723,22 +3730,23 @@ void ivas_dirac_dec_decorr_close(
);

ivas_error  ivas_dirac_dec_output_synthesis_open(
    DIRAC_DEC_HANDLE hDirAC,                                    /* i/o: DirAC handle                                */
    SPAT_PARAM_REND_COMMON_DATA_HANDLE rend_common_data,        /* i/o: common spatial renderer data handle         */
    DIRAC_REND_HANDLE hDirACRend,                               /* i/o: DirAC renderer handle                       */
    const RENDERER_TYPE renderer_type,                          /* i  : renderer type                               */
    const int16_t nchan_transport,                              /* i  : number of transport channels                */
    const int32_t output_Fs                                     /* i  : output sampling rate                        */
	,
    const int32_t output_Fs,                                    /* i  : output sampling rate                        */
    const int16_t hodirac_flag                                  /* i  : flag to indicate HO-DirAC mode              */
);

void ivas_dirac_dec_output_synthesis_init(
    DIRAC_DEC_HANDLE hDirAC,                                    /* i/o: DirAC handle                                */
    SPAT_PARAM_REND_COMMON_DATA_HANDLE rend_common_data,        /* i/o: common spatial renderer data handle         */
    DIRAC_REND_HANDLE hDirACRend,                               /* i/o: DirAC renderer handle                       */
    const int16_t nchan_out_woLFE,                              /* i  : number of output audio channels without LFE */
    const int16_t hodirac_flag                                  /* i  : flag to indicate HO-DirAC mode              */
);

void ivas_dirac_dec_output_synthesis_close(
    DIRAC_DEC_HANDLE hDirAC                                     /* i/o: DirAC handle                                */
    DIRAC_REND_HANDLE hDirACRend                                /* i/o: DirAC handle                                */
);

void ivas_dirac_dec_output_synthesis_process_slot(
@@ -3748,6 +3756,8 @@ void ivas_dirac_dec_output_synthesis_process_slot(
    const int16_t *elevation,
    const float *diffuseness,
    DIRAC_DEC_HANDLE hDirAC,                                    /* i/o: DirAC handle                                */
    SPAT_PARAM_REND_COMMON_DATA_HANDLE rend_common_data,        /* i/o: common spatial renderer data handle         */
    DIRAC_REND_HANDLE hDirACRend,                               /* i/o: DirAC renderer handle                       */
    const int16_t sh_rot_max_order,
    const float *p_Rmat,                                        /* i  : rotation matrix                             */
    const VBAP_HANDLE hVBAPdata,                                /* i  : VBAP structure                              */
@@ -3761,6 +3771,8 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd(
    float RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX],/* i  : LS signals                       */
    float ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX],/* i  : LS signals                       */
    DIRAC_DEC_HANDLE hDirAC,                                    /* i/o: DirAC handle                                */
    SPAT_PARAM_REND_COMMON_DATA_HANDLE rend_common_data,        /* i/o: common spatial renderer data handle         */
    DIRAC_REND_HANDLE hDirACRend,                               /* i/o: DirAC renderer handle                       */
    const int16_t nchan_transport,                              /* i  : number of transport channels                */
    const int16_t nbslots,                                      /* i  : number of slots to process                  */
    const float *onset_filter,
@@ -3772,6 +3784,8 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls(
    float RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX],/* i  : LS signals                       */
    float ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX],/* i  : LS signals                       */
    DIRAC_DEC_HANDLE hDirAC,                                    /* i/o: DirAC handle                                */
    SPAT_PARAM_REND_COMMON_DATA_HANDLE rend_common_data,        /* i/o: common spatial renderer data handle         */
    DIRAC_REND_HANDLE hDirACRend,                               /* i/o: DirAC renderer handle                       */
    const int16_t nbslots,                                      /* i  : number of slots to process                  */
    float *diffuseness_vector,                                  /* i  : diffuseness (needed for direction smoothing)*/
    float *reference_power_smooth,
@@ -3809,7 +3823,8 @@ void ivas_dirac_dec_compute_power_factors(
);

void ivas_dirac_dec_compute_directional_responses(
    DIRAC_DEC_HANDLE hDirAC,                                    /* i/o: DirAC handle                                    */
    SPAT_PARAM_REND_COMMON_DATA_HANDLE rend_common_data,        /* i/o: common spatial renderer data handle             */
    DIRAC_REND_HANDLE hDirACRend,                               /* i/o: DirAC renderer handle                           */
    const VBAP_HANDLE hVBAPdata,                                /* i  : VBAP structure                                  */
    const MASA_DECODER_HANDLE hMasa,                            /* i  : MASA decoder structure                          */
    const int16_t *azimuth,
+1044 −791

File changed.

Preview size limit exceeded, changes collapsed.

+175 −162

File changed.

Preview size limit exceeded, changes collapsed.

+82 −51
Original line number Diff line number Diff line
@@ -888,23 +888,13 @@ ivas_error ivas_init_decoder(
            st_ivas->hSCE[1]->hCoreCoder[0]->hFdCngDec->hFdCngCom->seed3 = st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->seed2;
        }
    }
    else if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == MASA_FORMAT )
    else if ( st_ivas->ivas_format == SBA_FORMAT )
    {

        if ( ( error = ivas_qmetadata_open( &( st_ivas->hQMetaData ) ) ) != IVAS_ERR_OK )
        {
            return error;
        }

        if ( st_ivas->ivas_format == MASA_FORMAT )
        {
            if ( ( error = ivas_masa_dec_open( st_ivas ) ) != IVAS_ERR_OK )
            {
                return error;
            }
        }
        else if ( st_ivas->ivas_format == SBA_FORMAT )
        {
        if ( ( error = ivas_spar_dec_open( st_ivas, 0 ) ) != IVAS_ERR_OK )
        {
            return error;
@@ -925,7 +915,7 @@ ivas_error ivas_init_decoder(

        if ( hDecoderConfig->output_config != AUDIO_CONFIG_FOA && st_ivas->hDecoderConfig->output_config != AUDIO_CONFIG_STEREO && st_ivas->hDecoderConfig->output_config != AUDIO_CONFIG_MONO )
        {
                if ( ( error = ivas_dirac_dec_open( st_ivas ) ) != IVAS_ERR_OK )
            if ( ( error = ivas_dirac_dec_config( st_ivas, DIRAC_OPEN ) ) != IVAS_ERR_OK )
            {
                return error;
            }
@@ -949,16 +939,6 @@ ivas_error ivas_init_decoder(
                                     st_ivas->hSpar->dirac_to_spar_md_bands, st_ivas->hQMetaData->useLowerBandRes, st_ivas->hSpar->enc_param_start_band, 0 );
        }
        st_ivas->sba_dirac_stereo_flag = ivas_get_sba_dirac_stereo_flag( st_ivas );
        }

        if ( st_ivas->renderer_type != RENDERER_BINAURAL_MIXER_CONV && st_ivas->renderer_type != RENDERER_BINAURAL_MIXER_CONV_ROOM &&
             st_ivas->renderer_type != RENDERER_DISABLE && st_ivas->renderer_type != RENDERER_SBA_LINEAR_DEC && st_ivas->ivas_format != SBA_FORMAT )
        {
            if ( ( error = ivas_dirac_dec_open( st_ivas ) ) != IVAS_ERR_OK )
            {
                return error;
            }
        }

        for ( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ )
        {
@@ -1006,6 +986,52 @@ ivas_error ivas_init_decoder(
        /* set CNA/CNG flags */
        ivas_sba_set_cna_cng_flag( st_ivas );
    }
    else if ( st_ivas->ivas_format == MASA_FORMAT )
    {
        if ( ( error = ivas_qmetadata_open( &( st_ivas->hQMetaData ) ) ) != IVAS_ERR_OK )
        {
            return error;
        }

        if ( ( error = ivas_masa_dec_open( st_ivas ) ) != IVAS_ERR_OK )
        {
            return error;
        }

        if ( st_ivas->renderer_type == RENDERER_DIRAC || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM )
        {
            if ( ( error = ivas_dirac_dec_config( st_ivas, DIRAC_OPEN ) ) != IVAS_ERR_OK )
            {
                return error;
            }
        }

        for ( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ )
        {
            if ( ( error = create_sce_dec( st_ivas, sce_id, ivas_total_brate / st_ivas->nchan_transport ) ) != IVAS_ERR_OK )
            {
                return error;
            }

            reset_indices_dec( st_ivas->hSCE[sce_id]->hCoreCoder[0] );
        }

        for ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ )
        {
            if ( ( error = create_cpe_dec( st_ivas, cpe_id, ( ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS ) ) != IVAS_ERR_OK )
            {
                return error;
            }

            for ( n = 0; n < CPE_CHANNELS; n++ )
            {
                reset_indices_dec( st_ivas->hCPE[cpe_id]->hCoreCoder[n] );
            }
        }

        /* set CNA/CNG flags */
        ivas_sba_set_cna_cng_flag( st_ivas );
    }
    else if ( st_ivas->ivas_format == MC_FORMAT )
    {
        if ( st_ivas->mc_mode == MC_MODE_MCT )
@@ -1140,7 +1166,7 @@ ivas_error ivas_init_decoder(

            if ( st_ivas->renderer_type != RENDERER_DISABLE && st_ivas->renderer_type != RENDERER_MCMASA_MONO_STEREO )
            {
                if ( ( error = ivas_dirac_dec_open( st_ivas ) ) != IVAS_ERR_OK )
                if ( ( error = ivas_dirac_dec_config( st_ivas, DIRAC_OPEN ) ) != IVAS_ERR_OK )
                {
                    return error;
                }
@@ -1256,7 +1282,8 @@ ivas_error ivas_init_decoder(
            return error;
        }
    }
    else if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC )
    /* ParamISM is handled separately from other common config */
    else if ( st_ivas->ivas_format == ISM_FORMAT && st_ivas->ism_mode == ISM_MODE_PARAM && (st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ))
    {
        if ( st_ivas->renderer_type != RENDERER_STEREO_PARAMETRIC )
        {
@@ -1671,6 +1698,8 @@ void ivas_initialize_handles_dec(
    /* rendering handles */
    st_ivas->hBinRenderer = NULL;
    st_ivas->hDiracDecBin = NULL;
    st_ivas->hDirACRend = NULL;
    st_ivas->rend_common_data = NULL;
    st_ivas->hLsSetUpConversion = NULL;
    st_ivas->hEFAPdata = NULL;
    st_ivas->hVBAPdata = NULL;
@@ -1781,10 +1810,12 @@ void ivas_destroy_dec(
    /* DirAC handle */
    if ( st_ivas->ivas_format == ISM_FORMAT )
    {
        ivas_param_ism_dec_close( &( st_ivas->hDirAC ), st_ivas->hDecoderConfig->output_config );
        ivas_param_ism_dec_close( &( st_ivas->hDirAC ), &(st_ivas->rend_common_data), st_ivas->hDecoderConfig->output_config );
    }
    else
    {
        ivas_dirac_rend_close( &( st_ivas->hDirACRend ) );
        ivas_spat_rend_common_data_close( &( st_ivas->rend_common_data ) );
        ivas_dirac_dec_close( &( st_ivas->hDirAC ) );
    }

@@ -1979,7 +2010,7 @@ void ivas_init_dec_get_num_cldfb_instances(
                {
                    *numCldfbAnalyses = st_ivas->nchan_transport + 1;
                }
                else if ( st_ivas->nchan_transport == 1 && st_ivas->hDirAC->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD )
                else if ( st_ivas->nchan_transport == 1 && st_ivas->hDirACRend->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD )
                {
                    *numCldfbAnalyses = st_ivas->nchan_transport + 1;
                }
+16 −13
Original line number Diff line number Diff line
@@ -65,11 +65,14 @@ static ivas_error ivas_ism_bitrate_switching(
    AUDIO_CONFIG intern_config_old;
    IVAS_OUTPUT_SETUP hIntSetupOld;
    RENDERER_TYPE renderer_type_old;
    SPAT_PARAM_REND_COMMON_DATA_HANDLE rend_common_data;

    error = IVAS_ERR_OK;
    nCPE_old = st_ivas->nCPE;
    nSCE_old = st_ivas->nSCE;

    rend_common_data = st_ivas->rend_common_data;

    /* we have to temporarily set the ism mode back to the old one, otherwise this can give wrong results*/
    ism_mode = st_ivas->ism_mode;
    st_ivas->ism_mode = last_ism_mode;
@@ -122,13 +125,13 @@ static ivas_error ivas_ism_bitrate_switching(
    if ( st_ivas->hDecoderConfig->voip_active )
    {
        /* transfer subframe info from DirAC or ParamMC to central tc buffer */
        if ( last_ism_mode == ISM_MODE_PARAM && st_ivas->hDirAC != NULL && ( st_ivas->renderer_type != RENDERER_MONO_DOWNMIX && st_ivas->renderer_type != RENDERER_DISABLE ) )
        if ( last_ism_mode == ISM_MODE_PARAM && rend_common_data != NULL && ( st_ivas->renderer_type != RENDERER_MONO_DOWNMIX && st_ivas->renderer_type != RENDERER_DISABLE ) )
        {
            st_ivas->hTcBuffer->nb_subframes = st_ivas->hDirAC->nb_subframes;
            st_ivas->hTcBuffer->subframes_rendered = st_ivas->hDirAC->subframes_rendered;
            st_ivas->hTcBuffer->num_slots = st_ivas->hDirAC->num_slots;
            st_ivas->hTcBuffer->slots_rendered = st_ivas->hDirAC->slots_rendered;
            mvs2s( st_ivas->hDirAC->subframe_nbslots, st_ivas->hTcBuffer->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS );
            st_ivas->hTcBuffer->nb_subframes = rend_common_data->nb_subframes;
            st_ivas->hTcBuffer->subframes_rendered = rend_common_data->subframes_rendered;
            st_ivas->hTcBuffer->num_slots = rend_common_data->num_slots;
            st_ivas->hTcBuffer->slots_rendered = rend_common_data->slots_rendered;
            mvs2s( rend_common_data->subframe_nbslots, st_ivas->hTcBuffer->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS );
        }

        /* JBM: when granularity goes down (e.g. Discrete ISM with TD Obj Renderer -> ParamISM with binaural fastconv
@@ -166,7 +169,7 @@ static ivas_error ivas_ism_bitrate_switching(
    if ( st_ivas->ism_mode == ISM_MODE_DISC && last_ism_mode == ISM_MODE_PARAM )
    {
        /* Deallocate the ParamISM struct */
        ivas_param_ism_dec_close( &( st_ivas->hDirAC ), st_ivas->hDecoderConfig->output_config );
        ivas_param_ism_dec_close( &( st_ivas->hDirAC ), &(st_ivas->rend_common_data), st_ivas->hDecoderConfig->output_config );

#ifdef FIX_568_ISM_BITRATE_SWITCHING
        if ( st_ivas->hOutSetup.output_config == AUDIO_CONFIG_BINAURAL || st_ivas->hOutSetup.output_config == AUDIO_CONFIG_BINAURAL_ROOM_REVERB )
@@ -339,14 +342,14 @@ static ivas_error ivas_ism_bitrate_switching(
        }

        /* transfer subframe info from central tc buffer to ParamMC or McMASA (DirAC) */
        if ( st_ivas->hDirAC != NULL )
        if ( rend_common_data != NULL )
        {
            st_ivas->hDirAC->nb_subframes = st_ivas->hTcBuffer->nb_subframes;
            st_ivas->hDirAC->subframes_rendered = st_ivas->hTcBuffer->subframes_rendered;
            st_ivas->hDirAC->num_slots = st_ivas->hTcBuffer->num_slots;
            st_ivas->hDirAC->slots_rendered = st_ivas->hTcBuffer->slots_rendered;
            rend_common_data->nb_subframes = st_ivas->hTcBuffer->nb_subframes;
            rend_common_data->subframes_rendered = st_ivas->hTcBuffer->subframes_rendered;
            rend_common_data->num_slots = st_ivas->hTcBuffer->num_slots;
            rend_common_data->slots_rendered = st_ivas->hTcBuffer->slots_rendered;

            mvs2s( st_ivas->hTcBuffer->subframe_nbslots, st_ivas->hDirAC->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS );
            mvs2s( st_ivas->hTcBuffer->subframe_nbslots, rend_common_data->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS );
        }
    }

Loading