Commit ab6eba33 authored by bayers's avatar bayers
Browse files

Fix HO-DirAC CBR, SBA BR switching still no BE

parent 22591097
Loading
Loading
Loading
Loading
Loading
+90 −57
Original line number Diff line number Diff line
@@ -2933,15 +2933,22 @@ void ivas_dirac_dec_render_sf(
    for ( subframe_idx = sf1; subframe_idx < sf2; subframe_idx++ )
    {
#endif
#ifdef JBM_TSM_ON_TCS

#ifdef JBM_TSM_ON_TCS
#ifdef MASA_PARAMBIN_SF_MAP
    if ( hDirAC->hConfig->dec_param_estim == FALSE )
    {
        md_idx = hDirAC->render_to_md_map[subframe_idx];
    }
    else
    {
        md_idx = hDirAC->render_to_md_map[slot_idx_start];
    }
#else
    md_idx = hDirAC->render_to_md_map[slot_idx_start];
#endif
#endif
#ifdef JBM_TSM_ON_TCS


    /* Another workaround for self test BE */
    if ( st_ivas->hHeadTrackData && st_ivas->hDecoderConfig->voip_active == 0 )
@@ -3163,6 +3170,14 @@ void ivas_dirac_dec_render_sf(
    {
#ifdef JBM_TSM_ON_TCS
        index_slot = slot_idx_start + slot_idx;
        if ( hDirAC->hConfig->dec_param_estim == TRUE )
        {
            md_idx = hDirAC->render_to_md_map[index_slot];
        }
        else
        {
            md_idx = hDirAC->render_to_md_map[subframe_idx];
        }
#else
            index_slot = subframe_idx * hDirAC->subframe_nbslots + slot_idx;
#endif
@@ -3181,11 +3196,19 @@ void ivas_dirac_dec_render_sf(
            for ( ch = 0; ch < nchan_transport; ch++ )
            {
#ifdef JBM_TSM_ON_TCS
#ifdef SPAR_TUNING
                cldfbAnalysis_ts( &( st_ivas->hTcBuffer->tc[hDirAC->sba_map_tc[ch]][hDirAC->num_freq_bands * index_slot] ),
                                  Cldfb_RealBuffer[ch][0],
                                  Cldfb_ImagBuffer[ch][0],
                                  hDirAC->num_freq_bands,
                                  st_ivas->cldfbAnaDec[ch] );
#else
                cldfbAnalysis_ts( &( st_ivas->hTcBuffer->tc[sba_map_tc[ch]][hDirAC->num_freq_bands * index_slot] ),
                                  Cldfb_RealBuffer[ch][0],
                                  Cldfb_ImagBuffer[ch][0],
                                  hDirAC->num_freq_bands,
                                  st_ivas->cldfbAnaDec[ch] );
#endif
#else
#ifdef SPAR_TUNING
                    cldfbAnalysis_ts( &( output_f[hDirAC->sba_map_tc[ch]][hDirAC->num_freq_bands * index_slot] ),
@@ -3233,11 +3256,7 @@ void ivas_dirac_dec_render_sf(
                                       Cldfb_RealBuffer[MAX_OUTPUT_CHANNELS - 1], Cldfb_ImagBuffer[MAX_OUTPUT_CHANNELS - 1],
                                       slot_idx,
#ifdef JBM_TSM_ON_TCS
#ifdef MASA_PARAMBIN_SF_MAP
                                       hDirAC->render_to_md_map[subframe_idx],
#else
                                       hDirAC->render_to_md_map[index_slot],
#endif
                                       md_idx,
#else
                                       subframe_idx,
#endif
@@ -3559,7 +3578,7 @@ void ivas_dirac_dec_render_sf(
                                                          st_ivas->hVBAPdata,
                                                          hDirAC->hOutSetup,
                                                          nchan_transport,
                                                          hDirAC->render_to_md_map[index_slot],
                                                          md_idx,
#ifdef HODIRAC
                                                          st_ivas->sba_analysis_order > 1 &&
                                                              st_ivas->hDecoderConfig->ivas_total_brate > IVAS_256k
@@ -3586,7 +3605,7 @@ void ivas_dirac_dec_render_sf(
                                                          st_ivas->hVBAPdata,
                                                          hDirAC->hOutSetup,
                                                          nchan_transport,
                                                          hDirAC->render_to_md_map[index_slot],
                                                          md_idx,
#ifdef HODIRAC
                                                          st_ivas->sba_analysis_order > 1 &&
                                                              st_ivas->hDecoderConfig->ivas_total_brate > IVAS_256k
@@ -3615,6 +3634,64 @@ void ivas_dirac_dec_render_sf(
#endif
#ifdef JBM_TSM_ON_TCS
    ivas_dirac_dec_output_synthesis_get_interpolator( &hDirAC->h_output_synthesis_psd_params, hDirAC->subframe_nbslots[subframe_idx] );
#ifdef MASA_PARAMBIN_SF_MAP
    if ( hDirAC->hConfig->dec_param_estim == FALSE )
    {
        md_idx = hDirAC->render_to_md_map[subframe_idx];
    }
    else
    {
        md_idx = hDirAC->render_to_md_map[slot_idx_start];
    }
#else
    md_idx = hDirAC->render_to_md_map[slot_idx_start];
#endif

#ifdef MASA_PARAMBIN_SF_MAP
    /* Workaround for BE (should be gone when #393 is adressed and diffuseness index in the gain SHD renderer with HO-DirAC is fixed) */
    /* :TODO: remove */
    /* get the correct md index for the diffuseness in direction smoothing and HO-DirAC, it is always the first slot of the next subframe*/
    if ( slot_idx_start + hDirAC->subframe_nbslots[subframe_idx] == hDirAC->num_slots )
    {
        /* we are at the end, get the next one using the normal dirac read idx...*/
        if ( st_ivas->hDirAC->hConfig->dec_param_estim == 1 )
        {
            md_idx = ( hDirAC->dirac_read_idx + DEFAULT_JBM_CLDFB_TIMESLOTS ) % hDirAC->dirac_md_buffer_length;
        }
        else
        {
            md_idx = ( hDirAC->dirac_read_idx + DEFAULT_JBM_SUBFRAMES_5MS ) % hDirAC->dirac_md_buffer_length;
        }
    }
    else
    {
        if ( st_ivas->hDirAC->hConfig->dec_param_estim == 1 )
        {
            md_idx = hDirAC->render_to_md_map[slot_idx_start + hDirAC->subframe_nbslots[subframe_idx]];
        }
        else
        {
            md_idx = hDirAC->render_to_md_map[subframe_idx + 1];
        }
    }
#else
    if ( slot_idx_start + hDirAC->subframe_nbslots[subframe_idx] == hDirAC->num_slots )
    {
        /* we are at the end, get the next one using the normal dirac read idx...*/
        if ( st_ivas->hDirAC->hConfig->dec_param_estim == 1 )
        {
            md_idx = ( hDirAC->dirac_read_idx + DEFAULT_JBM_CLDFB_TIMESLOTS ) % hDirAC->dirac_md_buffer_length;
        }
        else
        {
            md_idx = ( hDirAC->dirac_read_idx + DEFAULT_JBM_SUBFRAMES_5MS ) % hDirAC->dirac_md_buffer_length;
        }
    }
    else
    {
        md_idx = hDirAC->render_to_md_map[slot_idx_start + hDirAC->subframe_nbslots[subframe_idx]];
    }
#endif
#endif
    if ( hDirAC->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD )
    {
@@ -3639,9 +3716,7 @@ void ivas_dirac_dec_render_sf(
    {
        /* Determine encoding quality based additional smoothing factor */
        float qualityBasedSmFactor = 1.0f;
#ifdef JBM_TSM_ON_TCS
        int16_t diff_md_idx;
#endif

        if ( st_ivas->hMasa != NULL )
        {
            qualityBasedSmFactor = st_ivas->hMasa->data.dir_decode_quality;
@@ -3659,49 +3734,7 @@ void ivas_dirac_dec_render_sf(
                mvr2r( diffuseness_vector[slot_idx], hDirAC->diffuseness_vector[hDirAC->render_to_md_map[slot_idx + slot_idx_start]], num_freq_bands );
            }
        }
        /* get the correct md index for the direction smoothing, it is always the first slot of the next subframe*/
#ifdef MASA_PARAMBIN_SF_MAP
        if ( slot_idx_start + hDirAC->subframe_nbslots[subframe_idx] == hDirAC->num_slots )
        {
            /* we are at the end, get the next one using the normal dirac read idx...*/
            if ( st_ivas->hDirAC->hConfig->dec_param_estim == 1 )
            {
                diff_md_idx = ( hDirAC->dirac_read_idx + DEFAULT_JBM_CLDFB_TIMESLOTS ) % hDirAC->dirac_md_buffer_length;
            }
            else
            {
                diff_md_idx = ( hDirAC->dirac_read_idx + DEFAULT_JBM_SUBFRAMES_5MS ) % hDirAC->dirac_md_buffer_length;
            }
        }
        else
        {
            if ( st_ivas->hDirAC->hConfig->dec_param_estim == 1 )
            {
                diff_md_idx = hDirAC->render_to_md_map[slot_idx_start + hDirAC->subframe_nbslots[subframe_idx]];
            }
            else
            {
                diff_md_idx = hDirAC->render_to_md_map[subframe_idx + 1];
            }
        }
#else
        if ( slot_idx_start + hDirAC->subframe_nbslots[subframe_idx] == hDirAC->num_slots )
        {
            /* we are at the end, get the next one using the normal dirac read idx...*/
            if ( st_ivas->hDirAC->hConfig->dec_param_estim == 1 )
            {
                diff_md_idx = ( hDirAC->dirac_read_idx + DEFAULT_JBM_CLDFB_TIMESLOTS ) % hDirAC->dirac_md_buffer_length;
            }
            else
            {
                diff_md_idx = ( hDirAC->dirac_read_idx + DEFAULT_JBM_SUBFRAMES_5MS ) % hDirAC->dirac_md_buffer_length;
            }
        }
        else
        {
            diff_md_idx = hDirAC->render_to_md_map[slot_idx_start + hDirAC->subframe_nbslots[subframe_idx]];
        }
#endif


#endif
        ivas_dirac_dec_output_synthesis_process_subframe_psd_ls( Cldfb_RealBuffer,
@@ -3709,7 +3742,7 @@ void ivas_dirac_dec_render_sf(
                                                                 hDirAC,
#ifdef JBM_TSM_ON_TCS
                                                                 hDirAC->subframe_nbslots[subframe_idx],
                                                                 diff_md_idx,
                                                                 md_idx,
#endif
                                                                 reference_power_smooth,
                                                                 qualityBasedSmFactor );