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

initial support for parambin renderer in split rendering in decoder. switch:...

initial support for parambin renderer in split rendering in decoder. switch: SPLIT_REND_WITH_HEAD_ROT_PARAMBIN
parent 92b9bbcd
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -211,6 +211,9 @@
#define FIX_622_SILENCE_USAN_WARNING                    /* FhG: silenceusan warning in ifft code */

#define FIX_615_UBSAN_SPAR_TO_DIRAC                     /*Dlb : Fix for UBSAN issue 615*/
#define SPLIT_REND_WITH_HEAD_ROT_PARAMBIN               /* Nokia: Issue 623: Split rendering support for parambin renderer */
#define SPLIT_REND_WITH_HEAD_ROT_PARAMBIN_OPT           /* Nokia: Issue 623: Split rendering support for parambin renderer, computational optimization */

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


+19 −0
Original line number Diff line number Diff line
@@ -124,10 +124,20 @@ ivas_error ivas_dec(
    if ( ( output_config == AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) ||
         ( output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) )
    {
#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN
        assert( ( st_ivas->ivas_format == SBA_FORMAT ||
                  st_ivas->ivas_format == MASA_FORMAT ||
                  st_ivas->ivas_format == ISM_FORMAT ||
                  st_ivas->ivas_format == MC_FORMAT ) &&
                ( output_Fs == 48000 ) && "split binaural mode is currently supported with SBA, MASA, discrete and parametric ISM, or MC formats and 48 kHz sampling rate only" );
#else
        assert( ( st_ivas->ivas_format == SBA_FORMAT ||
                  st_ivas->ivas_format == MASA_FORMAT ||
                  st_ivas->ivas_format == ISM_FORMAT ||
                  ( 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" );
#endif
        ivas_set_split_rend_setup( &st_ivas->splitBinRend, &st_ivas->hRenderConfig->split_rend_config, st_ivas->hCombinedOrientationData, hSplitRendBits );
    }
#endif
@@ -845,6 +855,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_PARAMBIN
        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;
@@ -857,7 +872,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_PARAMBIN
                                            td_input,
#else
                                            st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV,
#endif
                                            pcm_out );

        free( st_ivas->splitBinRend.hMultiBinCldfbData );
+78 −1
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_PARAMBIN
        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,48 @@ ivas_error ivas_dirac_dec_config(
        {
            if ( st_ivas->renderer_type != RENDERER_STEREO_PARAMETRIC )
            {
#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN
                if ( ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) ||
                     ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) )
                {
                    /* populate pMultiBinPoseData with the additional poses determined from the DoF */
                    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 ) )
            {
                /* TODO: can we keep isRenderingInTd fixed? */
                ivas_split_rend_choose_default_codec( &st_ivas->hRenderConfig->split_rend_config.codec,
                                                      0,  /* isRenderingInTd */
                                                      ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0 );  /* pcm_out */

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

                if ( error != IVAS_ERR_OK )
                {
                    return error;
                }
            }
#endif
#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN
            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 )
                {
@@ -886,24 +925,55 @@ ivas_error ivas_dirac_dec_config(
            else
            {
                /* This is required to keep BE in rate switching. This probably means that 1TC and 2TC MASA perform differently. */
#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN
                if ( st_ivas->hDiracDecBin[0]->h_freq_domain_decorr_ap_params != NULL && !( st_ivas->ivas_format == MASA_FORMAT && st_ivas->nSCE > 0 ) )
#else
                if ( st_ivas->hDiracDecBin->h_freq_domain_decorr_ap_params != NULL && !( st_ivas->ivas_format == MASA_FORMAT && st_ivas->nSCE > 0 ) )
#endif
                {
#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN
                    ivas_dirac_dec_decorr_close( &st_ivas->hDiracDecBin[0]->h_freq_domain_decorr_ap_params, &st_ivas->hDiracDecBin[0]->h_freq_domain_decorr_ap_state );
#else
                    ivas_dirac_dec_decorr_close( &st_ivas->hDiracDecBin->h_freq_domain_decorr_ap_params, &st_ivas->hDiracDecBin->h_freq_domain_decorr_ap_state );
#endif
                }

#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN
                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[0]->hTdDecorr ), &( st_ivas->hDiracDecBin[0]->useTdDecorr ) ) ) != IVAS_ERR_OK )
#else
                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->hTdDecorr ), &( st_ivas->hDiracDecBin->useTdDecorr ) ) ) != IVAS_ERR_OK )
#endif
                {
                    return error;
                }

#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN
                /* copy td-decorr flag to split renderer side rendereres */
                for ( int16_t pos_idx = 1; pos_idx < st_ivas->splitBinRend.splitrend.multiBinPoseData.num_poses; pos_idx++ )
                {
                    st_ivas->hDiracDecBin[pos_idx]->useTdDecorr = st_ivas->hDiracDecBin[0]->useTdDecorr;
                }

                if ( !st_ivas->hDiracDecBin[0]->useTdDecorr )
#else
                if ( !st_ivas->hDiracDecBin->useTdDecorr )
#endif
                {
#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN
                    if ( st_ivas->hDiracDecBin[0]->h_freq_domain_decorr_ap_params == NULL )
#else
                    if ( st_ivas->hDiracDecBin->h_freq_domain_decorr_ap_params == NULL )
#endif
                    {
                        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 );
#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN
                        if ( ( error = ivas_dirac_dec_decorr_open( &( st_ivas->hDiracDecBin[0]->h_freq_domain_decorr_ap_params ),
                                                                   &( st_ivas->hDiracDecBin[0]->h_freq_domain_decorr_ap_state ),
#else
                        if ( ( error = ivas_dirac_dec_decorr_open( &( st_ivas->hDiracDecBin->h_freq_domain_decorr_ap_params ),
                                                                   &( st_ivas->hDiracDecBin->h_freq_domain_decorr_ap_state ),
#endif
                                                                   st_ivas->hSpatParamRendCom->num_freq_bands,
                                                                   BINAURAL_CHANNELS,
                                                                   BINAURAL_CHANNELS,
@@ -917,7 +987,14 @@ ivas_error ivas_dirac_dec_config(
                    }
                }

#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN
                for ( int16_t pos_idx = 0; pos_idx < st_ivas->splitBinRend.splitrend.multiBinPoseData.num_poses; pos_idx++ )
                {
                    st_ivas->hDiracDecBin[pos_idx]->reqularizationFactor = configure_reqularization_factor( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate );
                }
#else
                st_ivas->hDiracDecBin->reqularizationFactor = configure_reqularization_factor( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate );
#endif
            }
        }
    }
+45 −1
Original line number Diff line number Diff line
@@ -1319,6 +1319,16 @@ 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 ) )
    {
#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN
        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 )
@@ -1331,6 +1341,26 @@ ivas_error ivas_init_decoder(
        {
            return error;
        }
#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN
        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 )
    {
@@ -1820,7 +1850,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_PARAMBIN
    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;
@@ -1984,7 +2021,11 @@ void ivas_destroy_dec(
#endif

    /* Parametric binaural renderer handle */
#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN
    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 )
@@ -2103,8 +2144,11 @@ void ivas_init_dec_get_num_cldfb_instances(
            {
                *numCldfbAnalyses = st_ivas->nchan_transport + 1;
            }

#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN
            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
@@ -178,8 +178,11 @@ static ivas_error ivas_ism_bitrate_switching(
#endif
        {
            /* close the parametric binaural renderer */
#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN
            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 )
            {
@@ -221,7 +224,11 @@ static ivas_error ivas_ism_bitrate_switching(
#endif
        {
            /* close the parametric binaural renderer */
#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN
            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