Commit 40b6e983 authored by TYAGIRIS's avatar TYAGIRIS
Browse files

fixes to MASA and ISM split pre-renderer

parent 38cf86b3
Loading
Loading
Loading
Loading
Loading
+9 −4
Original line number Diff line number Diff line
@@ -366,6 +366,7 @@ ivas_error ivas_td_binaural_renderer_sf_splitBinaural(
    Word16 original_slots_rendered;
    Word32 *p_bin_output[BINAURAL_CHANNELS];
    Word32 output_local[MAX_OUTPUT_CHANNELS][L_FRAME48k];
    Word16 q_fact_orig[MAX_PARAM_SPATIAL_SUBFRAMES];

    Word16 SrcInd[MAX_NUM_TDREND_CHANNELS];

@@ -399,6 +400,7 @@ ivas_error ivas_td_binaural_renderer_sf_splitBinaural(
    FOR( i = 0; i < st_ivas->hCombinedOrientationData->num_subframes; ++i )
    {
        originalHeadRot[i] = st_ivas->hCombinedOrientationData->Quaternions[i];
        q_fact_orig[i] = originalHeadRot[i].q_fact;
    }

    original_subframes_rendered = st_ivas->hTcBuffer->subframes_rendered;
@@ -408,18 +410,20 @@ ivas_error ivas_td_binaural_renderer_sf_splitBinaural(
    origTdRendHandle = st_ivas->hBinRendererTd;
    move32();

    FOR( i = 0; i < st_ivas->hCombinedOrientationData->num_subframes; ++i )
    {
        modify_Quat_q_fx( &originalHeadRot[i], &originalHeadRot[i], Q22 );
    }

    FOR( pos_idx = 0; pos_idx < pMultiBinPoseData->num_poses; pos_idx++ )
    {
        /* Update head positions */
        IF( NE_16( pos_idx, 0 ) )
        {
            COMBINED_ORIENTATION_HANDLE pCombinedOrientationData = st_ivas->hCombinedOrientationData;
            Word16 q_fact_orig;
            FOR( i = 0; i < st_ivas->hCombinedOrientationData->num_subframes; ++i )
            {
                pCombinedOrientationData->Quaternions[i].w_fx = L_negate( 12582912 ); // Q22
                q_fact_orig = originalHeadRot[i].q_fact;
                modify_Quat_q_fx( &originalHeadRot[i], &originalHeadRot[i], Q22 );
                /*euler*/
                Quat2EulerDegree_fx( originalHeadRot[i],
                                     &pCombinedOrientationData->Quaternions[i].z_fx,
@@ -433,7 +437,7 @@ ivas_error ivas_td_binaural_renderer_sf_splitBinaural(
                               deg2rad_fx( pCombinedOrientationData->Quaternions[i].y_fx ),
                               deg2rad_fx( pCombinedOrientationData->Quaternions[i].z_fx ), &pCombinedOrientationData->Quaternions[i] );

                modify_Quat_q_fx( &pCombinedOrientationData->Quaternions[i], &pCombinedOrientationData->Quaternions[i], q_fact_orig );
                modify_Quat_q_fx( &pCombinedOrientationData->Quaternions[i], &pCombinedOrientationData->Quaternions[i], q_fact_orig[i] );
            }
        }

@@ -482,6 +486,7 @@ ivas_error ivas_td_binaural_renderer_sf_splitBinaural(
    /* Restore original head rotation */
    FOR( i = 0; i < st_ivas->hCombinedOrientationData->num_subframes; ++i )
    {
        modify_Quat_q_fx( &originalHeadRot[i], &originalHeadRot[i], q_fact_orig[i] );
        st_ivas->hCombinedOrientationData->Quaternions[i] = originalHeadRot[i];
        move32();
    }
+72 −51
Original line number Diff line number Diff line
@@ -123,7 +123,7 @@ static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matric
static void ivas_dirac_dec_binaural_determine_processing_matrices_fx( DIRAC_DEC_BIN_HANDLE hDiracDecBin, SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, PARAMBIN_REND_CONFIG_HANDLE hConfig, const int16_t max_band_decorr, Word32 Rmat[3][3] /*Q30*/, const Word16 subframe, const Word16 isHeadtracked, const Word16 nchanSeparateChannels, const MASA_ISM_DATA_HANDLE hMasaIsmData );

#ifdef SPLIT_REND_WITH_HEAD_ROT
static void ivas_dirac_dec_binaural_process_output_fx( DIRAC_DEC_BIN_HANDLE hDiracDecBin, SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, HANDLE_CLDFB_FILTER_BANK cldfbSynDec[MAX_OUTPUT_CHANNELS], Word32 *output_fx[] /*q_out*/, Word16 *q_out, Word32 inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX] /*q_inp*/, Word32 inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX] /*q_inp*/, const Word16 q_inp, const Word16 max_band_decorr, const Word16 numInChannels, const Word16 processReverb, const Word16 subframe, const Word16 q_mat, Word32 outRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], Word32 outIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], Word32 reverbRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], Word32 reverbIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], Word32 decorrRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], Word32 decorrIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], const Word8 recompute );
static void ivas_dirac_dec_binaural_process_output_fx( DIRAC_DEC_BIN_HANDLE hDiracDecBin, SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, HANDLE_CLDFB_FILTER_BANK cldfbSynDec[MAX_OUTPUT_CHANNELS], Word32 *output_fx[] /*q_out*/, Word16 *q_out, Word32 inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX] /*q_inp*/, Word32 inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX] /*q_inp*/, const Word16 q_inp, const Word16 max_band_decorr, const Word16 numInChannels, const Word16 processReverb, const Word16 subframe, const Word16 q_mat, Word32 outRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], Word32 outIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], Word32 reverbRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], Word32 reverbIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], Word32 decorrRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], Word32 decorrIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], Word16 *Q_inp_mix, const Word8 recompute );
#else
static void ivas_dirac_dec_binaural_process_output_fx( DIRAC_DEC_BIN_HANDLE hDiracDecBin, SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, HANDLE_CLDFB_FILTER_BANK cldfbSynDec[MAX_OUTPUT_CHANNELS], Word32 *output_fx[] /*q_out*/, Word16 *q_out, Word32 inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX] /*q_inp*/, Word32 inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX] /*q_inp*/, const Word16 q_inp, const Word16 max_band_decorr, const Word16 numInChannels, const Word16 processReverb, const Word16 subframe, const Word16 q_mat );
#endif
@@ -694,6 +694,7 @@ static void ivas_dirac_dec_binaural_internal_fx(
    Word32 subFrameTotalEne_fx[CLDFB_NO_CHANNELS_MAX];
    Word16 subFrameTotalEne_e[CLDFB_NO_CHANNELS_MAX];
    Word32 IIReneLimiter_fx[CLDFB_NO_CHANNELS_MAX];
    Word16 Q_inp_mix;

    hDiracDecBin = st_ivas->hDiracDecBin[0];
#else
@@ -1116,7 +1117,7 @@ static void ivas_dirac_dec_binaural_internal_fx(
#endif
    {
        ivas_dirac_dec_binaural_process_output_fx( hDiracDecBin, hSpatParamRendCom, st_ivas->cldfbSynDec, output_fx, &q_out, Cldfb_RealBuffer_in_fx, Cldfb_ImagBuffer_in_fx, q_inp, max_band_decorr, numInChannels, config_data.processReverb, subframe, q_mat,
                                                   tmp_Cldfb_out_re, tmp_Cldfb_out_im, reverbRe_fx, reverbIm_fx, decorrRe_fx, decorrIm_fx, 1 );
                                                   tmp_Cldfb_out_re, tmp_Cldfb_out_im, reverbRe_fx, reverbIm_fx, decorrRe_fx, decorrIm_fx, &Q_inp_mix, 1 );

        FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ )
        {
@@ -1130,7 +1131,7 @@ static void ivas_dirac_dec_binaural_internal_fx(
    ELSE
    {
        ivas_dirac_dec_binaural_process_output_fx( hDiracDecBin, hSpatParamRendCom, st_ivas->cldfbSynDec, output_fx, &q_out, Cldfb_RealBuffer_in_fx, Cldfb_ImagBuffer_in_fx, q_inp, max_band_decorr, numInChannels, config_data.processReverb, subframe, q_mat, NULL, NULL,
                                                   reverbRe_fx, reverbIm_fx, decorrRe_fx, decorrIm_fx, 1 );
                                                   reverbRe_fx, reverbIm_fx, decorrRe_fx, decorrIm_fx, &Q_inp_mix, 1 );
    }
#else
    ivas_dirac_dec_binaural_process_output_fx( hDiracDecBin, hSpatParamRendCom, st_ivas->cldfbSynDec, output_fx, &q_out, Cldfb_RealBuffer_in_fx, Cldfb_ImagBuffer_in_fx, q_inp, max_band_decorr, numInChannels, config_data.processReverb, subframe, q_mat );
@@ -1162,6 +1163,7 @@ static void ivas_dirac_dec_binaural_internal_fx(
                move32();
                move32();
                move32();
                Euler2Quat_fx( deg2rad_fx( Quaternions_rot.x_fx ), deg2rad_fx( Quaternions_rot.y_fx ), deg2rad_fx( Quaternions_rot.z_fx ), &Quaternions_rot );
                modify_Quat_q_fx( &Quaternions_rot, &Quaternions_rot, Quaternions_ref->q_fact );
                QuatToRotMat_fx( Quaternions_rot, Rmat_local );

@@ -1173,12 +1175,15 @@ static void ivas_dirac_dec_binaural_internal_fx(
                }

                /* re-use input covariance for the side renderings */
                for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ )
                FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ )
                {
                    Copy32( st_ivas->hDiracDecBin[0]->ChEne_fx[ch], hDiracDecBin->ChEne_fx[ch], hSpatParamRendCom->num_freq_bands );
                    Copy( st_ivas->hDiracDecBin[0]->ChEne_e[ch], hDiracDecBin->ChEne_e[ch], hSpatParamRendCom->num_freq_bands );
                }
                Copy32( st_ivas->hDiracDecBin[0]->ChCrossRe_fx, hDiracDecBin->ChCrossRe_fx, hSpatParamRendCom->num_freq_bands );
                Copy32( st_ivas->hDiracDecBin[0]->ChCrossIm_fx, hDiracDecBin->ChCrossIm_fx, hSpatParamRendCom->num_freq_bands );
                Copy( st_ivas->hDiracDecBin[0]->ChCrossRe_e, hDiracDecBin->ChCrossRe_e, hSpatParamRendCom->num_freq_bands );
                Copy( st_ivas->hDiracDecBin[0]->ChCrossIm_e, hDiracDecBin->ChCrossIm_e, hSpatParamRendCom->num_freq_bands );

                ivas_dirac_dec_binaural_formulate_target_covariance_matrices_fx( hDiracDecBin, hSpatParamRendCom, &config_data, Rmat_local, subframe,
                                                                                 hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[subframe] > 0,
@@ -1227,7 +1232,7 @@ static void ivas_dirac_dec_binaural_internal_fx(

                /* re-use reverb and decorr from main direction for the sides */
                ivas_dirac_dec_binaural_process_output_fx( hDiracDecBin, hSpatParamRendCom, st_ivas->cldfbSynDec, output_fx, &q_out, Cldfb_RealBuffer_in_fx, Cldfb_ImagBuffer_in_fx, q_inp, max_band_decorr, numInChannels, config_data.processReverb, subframe, q_mat,
                                                           tmp_Cldfb_out_re, tmp_Cldfb_out_im, reverbRe_fx, reverbIm_fx, decorrRe_fx, decorrIm_fx, 0 );
                                                           tmp_Cldfb_out_re, tmp_Cldfb_out_im, reverbRe_fx, reverbIm_fx, decorrRe_fx, decorrIm_fx, &Q_inp_mix, 0 );

                /* copy from temporary buffer to the main split rendering buffer */
                FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ )
@@ -3399,6 +3404,7 @@ static void ivas_dirac_dec_binaural_process_output_fx(
    Word32 reverbIm_fx[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX],
    Word32 decorrRe_fx[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX],
    Word32 decorrIm_fx[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX],
    Word16 *Q_inp_mix,
    const Word8 recompute
#endif
)
@@ -3442,6 +3448,10 @@ static void ivas_dirac_dec_binaural_process_output_fx(
#endif
    }

#ifdef SPLIT_REND_WITH_HEAD_ROT
    IF( EQ_16( recompute, 1 ) )
    {
#endif
        // scaling input and reverb to same q//
        // input scaling is to maintain precision in ivas_dirac_dec_decorrelate_slot fn//
        Word16 shift = s_min( L_norm_arr( cldfbSynDec[0]->cldfb_state_fx, cldfbSynDec[0]->p_filter_length ), L_norm_arr( cldfbSynDec[1]->cldfb_state_fx, cldfbSynDec[1]->p_filter_length ) );
@@ -3505,6 +3515,15 @@ static void ivas_dirac_dec_binaural_process_output_fx(
        cldfbSynDec[1]->Q_cldfb_state = add( cldfbSynDec[1]->Q_cldfb_state, cldfb_state_shift );
        move16();
        move16();
#ifdef SPLIT_REND_WITH_HEAD_ROT
        *Q_inp_mix = q_inp_mix;
        move16();
    }
    ELSE
    {
        q_inp_mix = *Q_inp_mix;
    }
#endif

    q_inp_mix = add( q_inp_mix, q_input );

@@ -6511,6 +6530,7 @@ static void ivas_masa_ext_rend_parambin_internal_fx(
    Word32 subFrameTotalEne_fx[CLDFB_NO_CHANNELS_MAX];
    Word16 subFrameTotalEne_e[CLDFB_NO_CHANNELS_MAX];
    Word32 IIReneLimiter_fx[CLDFB_NO_CHANNELS_MAX];
    Word16 Q_inp_mix;

    hDiracDecBin = hMasaExtRend->hDiracDecBin[0];
#else
@@ -6718,7 +6738,7 @@ static void ivas_masa_ext_rend_parambin_internal_fx(
        pMultiBinPoseData = &( hSplitRendWrapper->multiBinPoseData );

        ivas_dirac_dec_binaural_process_output_fx( hDiracDecBin, hSpatParamRendCom, hMasaExtRend->cldfbSynRend, output_fx, &q_out, Cldfb_RealBuffer_in_fx, Cldfb_ImagBuffer_in_fx, q_inp, max_band_decorr, numInChannels, config_data.processReverb, subframe, q_mat, tmp_Cldfb_out_re, tmp_Cldfb_out_im,
                                                   reverbRe_fx, reverbIm_fx, decorrRe_fx, decorrIm_fx, 1 );
                                                   reverbRe_fx, reverbIm_fx, decorrRe_fx, decorrIm_fx, &Q_inp_mix, 1 );

        for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ )
        {
@@ -6732,7 +6752,7 @@ static void ivas_masa_ext_rend_parambin_internal_fx(
    else
    {
        ivas_dirac_dec_binaural_process_output_fx( hDiracDecBin, hSpatParamRendCom, hMasaExtRend->cldfbSynRend, output_fx, &q_out, Cldfb_RealBuffer_in_fx, Cldfb_ImagBuffer_in_fx, q_inp, max_band_decorr, numInChannels, config_data.processReverb, subframe, q_mat, NULL, NULL,
                                                   reverbRe_fx, reverbIm_fx, decorrRe_fx, decorrIm_fx, 1 );
                                                   reverbRe_fx, reverbIm_fx, decorrRe_fx, decorrIm_fx, &Q_inp_mix, 1 );
    }
#else
    ivas_dirac_dec_binaural_process_output_fx( hDiracDecBin, hSpatParamRendCom, hMasaExtRend->cldfbSynRend, output_fx, &q_out, Cldfb_RealBuffer_in_fx, Cldfb_ImagBuffer_in_fx, q_inp, max_band_decorr, numInChannels, config_data.processReverb, subframe, q_mat );
@@ -6765,6 +6785,7 @@ static void ivas_masa_ext_rend_parambin_internal_fx(
                move32();
                move32();
                move32();
                Euler2Quat_fx( deg2rad_fx( Quaternions_rot.x_fx ), deg2rad_fx( Quaternions_rot.y_fx ), deg2rad_fx( Quaternions_rot.z_fx ), &Quaternions_rot );
                modify_Quat_q_fx( &Quaternions_rot, &Quaternions_rot, Quaternions_ref->q_fact );
                QuatToRotMat_fx( Quaternions_rot, Rmat_local );

@@ -6824,7 +6845,7 @@ static void ivas_masa_ext_rend_parambin_internal_fx(
                move16();
                /* re-use reverb and decorr from main direction for the sides */
                ivas_dirac_dec_binaural_process_output_fx( hDiracDecBin, hSpatParamRendCom, hMasaExtRend->cldfbSynRend, output_fx, &q_out, Cldfb_RealBuffer_in_fx, Cldfb_ImagBuffer_in_fx, q_inp, max_band_decorr, numInChannels, config_data.processReverb, subframe, q_mat, tmp_Cldfb_out_re, tmp_Cldfb_out_im,
                                                           reverbRe_fx, reverbIm_fx, decorrRe_fx, decorrIm_fx, 0 );
                                                           reverbRe_fx, reverbIm_fx, decorrRe_fx, decorrIm_fx, &Q_inp_mix, 0 );

                /* copy from temporary buffer to the main split rendering buffer */
                for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ )