Commit a8a903a8 authored by Jouni Paulus's avatar Jouni Paulus
Browse files

draft parambin support for split rendering.

parent 0ba01d30
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -185,6 +185,7 @@
#define RENAME_GWLPR                                    /* FhG: Rename clashing symbol */

#define SPLIT_REND_WITH_HEAD_ROT                        /* Dlb,FhG: Split Rendering contributions 21 and 35 */
#define SPLIT_REND_WITH_HEAD_ROT_MASA                   /* Nokia, Dlb: Split rendering support for parambin renderer */

/* ################## End BE DEVELOPMENT switches ######################### */

+12 −0
Original line number Diff line number Diff line
@@ -122,6 +122,9 @@ ivas_error ivas_dec(
         ( output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) )
    {
        assert( ( st_ivas->ivas_format == SBA_FORMAT ||
#ifdef SPLIT_REND_WITH_HEAD_ROT_MASA
                  st_ivas->ivas_format == MASA_FORMAT ||
#endif
                  ( 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_MCMASA ) ) &&
                ( output_Fs == 48000 ) && "split binaural mode is currently supported with SBA, discrete ISM, or MCT-MC formats and 48 kHz sampling rate only" );
@@ -822,6 +825,11 @@ ivas_error ivas_dec(
        IVAS_DEC_SPLIT_REND_WRAPPER *hSplitBinRend;
        int16_t max_band;
        int16_t pcm_out;
#ifdef SPLIT_REND_WITH_HEAD_ROT_MASA
        int16_t td_input;

        td_input = st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV && st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC && st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC_ROOM && st_ivas->renderer_type != RENDERER_STEREO_PARAMETRIC;
#endif
        hSplitBinRend = &st_ivas->splitBinRend;
        max_band = (int16_t) ( ( BINAURAL_MAXBANDS * output_Fs ) / 48000 );
        pcm_out = ( output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0;
@@ -834,7 +842,11 @@ ivas_error ivas_dec(
                                            hSplitBinRend->hMultiBinCldfbData->Cldfb_RealBuffer_Binaural,
                                            hSplitBinRend->hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural,
                                            max_band, output, 1,
#ifdef SPLIT_REND_WITH_HEAD_ROT_MASA
                                            td_input,
#else
                                            st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV,
#endif
                                            pcm_out );

        free( st_ivas->splitBinRend.hMultiBinCldfbData );
+79 −3
Original line number Diff line number Diff line
@@ -826,7 +826,11 @@ ivas_error ivas_dirac_dec_config(

    if ( !need_parambin )
    {
#ifdef SPLIT_REND_WITH_HEAD_ROT_MASA
        ivas_dirac_dec_close_binaural_data( st_ivas->hDiracDecBin );
#else
        ivas_dirac_dec_close_binaural_data( &st_ivas->hDiracDecBin );
#endif
    }

    need_dirac_rend = 0;
@@ -870,13 +874,45 @@ ivas_error ivas_dirac_dec_config(
        {
            if ( st_ivas->renderer_type != RENDERER_STEREO_PARAMETRIC )
            {
#ifdef SPLIT_REND_WITH_HEAD_ROT_MASA
                if ( ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) ||
                     ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) )
                {
                    ivas_renderSplitGetMultiBinPoseData(
                        &st_ivas->hRenderConfig->split_rend_config,
                        &st_ivas->splitBinRend.splitrend.multiBinPoseData,
                        st_ivas->hHeadTrackData->sr_pose_pred_axis );
                }
#endif
                if ( ( error = ivas_dirac_dec_binaural_copy_hrtfs( &st_ivas->hHrtfParambin ) ) != IVAS_ERR_OK )
                {
                    return error;
                }
            }
#ifdef SPLIT_REND_WITH_HEAD_ROT
            if ( ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) ||
                 ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) )
            {
                ivas_split_rend_choose_default_codec( &st_ivas->hRenderConfig->split_rend_config.codec, 0,
                                                      ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0 );

                error = ivas_split_renderer_open( &st_ivas->splitBinRend.splitrend,
                                                  &st_ivas->hRenderConfig->split_rend_config,
                                                  st_ivas->hDecoderConfig->output_Fs,
                                                  1,
                                                  ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0 );

                if ( error != IVAS_ERR_OK )
                {
                    return error;
                }
            }
#endif
#ifdef SPLIT_REND_WITH_HEAD_ROT_MASA
            if ( st_ivas->hDiracDecBin[0] == NULL )
#else
            if ( st_ivas->hDiracDecBin == NULL )
#endif
            {
                if ( ( error = ivas_dirac_dec_init_binaural_data( st_ivas, st_ivas->hHrtfParambin ) ) != IVAS_ERR_OK )
                {
@@ -885,6 +921,45 @@ ivas_error ivas_dirac_dec_config(
            }
            else
            {
#ifdef SPLIT_REND_WITH_HEAD_ROT_MASA
                int16_t pos_idx;
                for ( pos_idx = 0; pos_idx < st_ivas->splitBinRend.splitrend.multiBinPoseData.num_poses; pos_idx++ )
                {
                    if ( st_ivas->hDiracDecBin[pos_idx]->h_freq_domain_decorr_ap_params != NULL && !( st_ivas->ivas_format == MASA_FORMAT && st_ivas->nSCE > 0 ) )
                    {
                        ivas_dirac_dec_decorr_close( &st_ivas->hDiracDecBin[pos_idx]->h_freq_domain_decorr_ap_params, &st_ivas->hDiracDecBin[pos_idx]->h_freq_domain_decorr_ap_state );
                    }

                    if ( ( error = ivas_td_decorr_reconfig_dec( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hDecoderConfig->output_Fs, &( st_ivas->hDiracDecBin[pos_idx]->hTdDecorr ), &( st_ivas->hDiracDecBin[pos_idx]->useTdDecorr ) ) ) != IVAS_ERR_OK )
                    {
                        return error;
                    }

                    if ( !st_ivas->hDiracDecBin[pos_idx]->useTdDecorr )
                    {
                        if ( st_ivas->hDiracDecBin[pos_idx]->h_freq_domain_decorr_ap_params == NULL )
                        {
                            float frequency_axis[CLDFB_NO_CHANNELS_MAX];
                            ivas_dirac_dec_get_frequency_axis( frequency_axis, st_ivas->hDecoderConfig->output_Fs, st_ivas->hSpatParamRendCom->num_freq_bands );
                            if ( ( error = ivas_dirac_dec_decorr_open( &( st_ivas->hDiracDecBin[pos_idx]->h_freq_domain_decorr_ap_params ),
                                                                       &( st_ivas->hDiracDecBin[pos_idx]->h_freq_domain_decorr_ap_state ),
                                                                       st_ivas->hSpatParamRendCom->num_freq_bands,
                                                                       BINAURAL_CHANNELS,
                                                                       BINAURAL_CHANNELS,
                                                                       DIRAC_SYNTHESIS_PSD_LS,
                                                                       frequency_axis,
                                                                       BINAURAL_CHANNELS,
                                                                       st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK )
                            {
                                return error;
                            }
                        }
                    }

                    st_ivas->hDiracDecBin[pos_idx]->reqularizationFactor = configure_reqularization_factor( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate );
                }
            }
#else
                /* This is required to keep BE in rate switching. This probably means that 1TC and 2TC MASA perform differently. */
                if ( st_ivas->hDiracDecBin->h_freq_domain_decorr_ap_params != NULL && !( st_ivas->ivas_format == MASA_FORMAT && st_ivas->nSCE > 0 ) )
                {
@@ -919,6 +994,7 @@ ivas_error ivas_dirac_dec_config(

                st_ivas->hDiracDecBin->reqularizationFactor = configure_reqularization_factor( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate );
            }
#endif
        }
    }

@@ -2332,12 +2408,12 @@ void ivas_dirac_dec_render_sf(
            for ( pos_idx = 0; pos_idx < st_ivas->hBinRenderer->numPoses; pos_idx++ )
#endif
            {
                for ( slot_idx = 0; slot_idx < hDirAC->subframe_nbslots[subframe_idx]; slot_idx++ )
                for ( slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[subframe_idx]; slot_idx++ )
                {
                    for ( ch = 0; ch < st_ivas->hDecoderConfig->nchan_out; ch++ )
                    {
                        mvr2r( Cldfb_RealBuffer_Binaural[pos_idx][ch][slot_idx], st_ivas->splitBinRend.hMultiBinCldfbData->Cldfb_RealBuffer_Binaural[( pos_idx * BINAURAL_CHANNELS ) + ch][slot_idx_start + slot_idx], hDirAC->num_freq_bands );
                        mvr2r( Cldfb_ImagBuffer_Binaural[pos_idx][ch][slot_idx], st_ivas->splitBinRend.hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural[( pos_idx * BINAURAL_CHANNELS ) + ch][slot_idx_start + slot_idx], hDirAC->num_freq_bands );
                        mvr2r( Cldfb_RealBuffer_Binaural[pos_idx][ch][slot_idx], st_ivas->splitBinRend.hMultiBinCldfbData->Cldfb_RealBuffer_Binaural[( pos_idx * BINAURAL_CHANNELS ) + ch][slot_idx_start + slot_idx], hSpatParamRendCom->num_freq_bands );
                        mvr2r( Cldfb_ImagBuffer_Binaural[pos_idx][ch][slot_idx], st_ivas->splitBinRend.hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural[( pos_idx * BINAURAL_CHANNELS ) + ch][slot_idx_start + slot_idx], hSpatParamRendCom->num_freq_bands );
                    }
                }
            }
+47 −1
Original line number Diff line number Diff line
@@ -1317,6 +1317,17 @@ ivas_error ivas_init_decoder(
    /* 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 ) )
    {
        /* TODO jpaulus: paramBin modes needed? */
#ifdef SPLIT_REND_WITH_HEAD_ROT_MASA
        if ( ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) ||
             ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) )
        {
            ivas_renderSplitGetMultiBinPoseData(
                &st_ivas->hRenderConfig->split_rend_config,
                &st_ivas->splitBinRend.splitrend.multiBinPoseData,
                st_ivas->hHeadTrackData->sr_pose_pred_axis );
        }
#endif
        if ( st_ivas->renderer_type != RENDERER_STEREO_PARAMETRIC )
        {
            if ( ( error = ivas_dirac_dec_binaural_copy_hrtfs( &st_ivas->hHrtfParambin ) ) != IVAS_ERR_OK )
@@ -1329,6 +1340,27 @@ ivas_error ivas_init_decoder(
        {
            return error;
        }
        /* TODO jpaulus: is this needed here? */
#ifdef SPLIT_REND_WITH_HEAD_ROT_MASA
        if ( ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) ||
             ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) )
        {
#ifdef FIX_SPLIT_REND_OPEN_ERROR_HANDLING
            error =
#endif
                ivas_split_renderer_open( &st_ivas->splitBinRend.splitrend,
                                          &st_ivas->hRenderConfig->split_rend_config,
                                          hDecoderConfig->output_Fs,
                                          1, ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0 );

#ifdef FIX_SPLIT_REND_OPEN_ERROR_HANDLING
            if ( error != IVAS_ERR_OK )
            {
                return error;
            }
#endif
        }
#endif
    }
    else if ( st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD )
    {
@@ -1792,7 +1824,14 @@ void ivas_initialize_handles_dec(
    st_ivas->splitBinRend.hSplitRendBits = NULL;
    ivas_init_split_rend_handles( &st_ivas->splitBinRend.splitrend );
#endif
#ifdef SPLIT_REND_WITH_HEAD_ROT_MASA
    for ( i = 0; i < MAX_HEAD_ROT_POSES; i++ )
    {
        st_ivas->hDiracDecBin[i] = NULL;
    }
#else
    st_ivas->hDiracDecBin = NULL;
#endif
    st_ivas->hDirACRend = NULL;
    st_ivas->hSpatParamRendCom = NULL;
    st_ivas->hLsSetUpConversion = NULL;
@@ -1956,7 +1995,11 @@ void ivas_destroy_dec(
#endif

    /* Parametric binaural renderer handle */
#ifdef SPLIT_REND_WITH_HEAD_ROT_MASA
    ivas_dirac_dec_close_binaural_data( st_ivas->hDiracDecBin );
#else
    ivas_dirac_dec_close_binaural_data( &st_ivas->hDiracDecBin );
#endif

    /* Crend handle */
    ivas_rend_closeCrend( &( st_ivas->hCrendWrapper )
@@ -2075,8 +2118,11 @@ void ivas_init_dec_get_num_cldfb_instances(
            {
                *numCldfbAnalyses = st_ivas->nchan_transport + 1;
            }

#ifdef SPLIT_REND_WITH_HEAD_ROT_MASA
            if ( st_ivas->hDiracDecBin[0]->useTdDecorr )
#else
            if ( st_ivas->hDiracDecBin->useTdDecorr )
#endif
            {
                *numCldfbAnalyses += 2;
            }
+8 −1
Original line number Diff line number Diff line
@@ -175,8 +175,11 @@ static ivas_error ivas_ism_bitrate_switching(
#endif
        {
            /* close the parametric binaural renderer */
#ifdef SPLIT_REND_WITH_HEAD_ROT_MASA
            ivas_dirac_dec_close_binaural_data( st_ivas->hDiracDecBin );
#else
            ivas_dirac_dec_close_binaural_data( &st_ivas->hDiracDecBin );

#endif
            /* Open the TD Binaural renderer */
            if ( st_ivas->hHrtfTD == NULL || st_ivas->hBinRendererTd == NULL )
            {
@@ -209,7 +212,11 @@ static ivas_error ivas_ism_bitrate_switching(
#endif
        {
            /* close the parametric binaural renderer */
#ifdef SPLIT_REND_WITH_HEAD_ROT_MASA
            ivas_dirac_dec_close_binaural_data( st_ivas->hDiracDecBin );
#else
            ivas_dirac_dec_close_binaural_data( &st_ivas->hDiracDecBin );
#endif

            /* Open Crend Binaural renderer */
            if ( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs
Loading