Commit 401c8e7b authored by Jouni Paulus's avatar Jouni Paulus
Browse files

split rendering support for MASA external renderer

parent 3b0a6239
Loading
Loading
Loading
Loading
Loading
+31 −20
Original line number Diff line number Diff line
@@ -3476,7 +3476,14 @@ static void ivas_masa_ext_rend_parambin_internal(
    MASA_EXT_REND_HANDLE hMasaExtRend,
    COMBINED_ORIENTATION_HANDLE hCombinedOrientationData,
    float *output_f[],
#ifdef SPLIT_REND_WITH_HEAD_ROT
    const int16_t subframe,
    const SPLIT_REND_WRAPPER *hSplitRendWrapper,
    float Cldfb_Out_Real[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX],
    float Cldfb_Out_Imag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX] )
#else
    const int16_t subframe )
#endif
{
    DIRAC_DEC_BIN_HANDLE hDiracDecBin;
    SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom;
@@ -3492,7 +3499,7 @@ static void ivas_masa_ext_rend_parambin_internal(

#ifdef SPLIT_REND_WITH_HEAD_ROT
    int16_t pos_idx;
    MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData;
    const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData;
    float tmp_Cldfb_out_re[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX];
    float tmp_Cldfb_out_im[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX];
    /* these allow re-using the reverb and freq-domain decorrelator signals from ivas_dirac_dec_binaural_process_output() in split rendering for the side renderings */
@@ -3624,14 +3631,11 @@ static void ivas_masa_ext_rend_parambin_internal(
#endif

#ifdef SPLIT_REND_WITH_HEAD_ROT
    // pMultiBinPoseData = &st_ivas->hSplitBinRend.splitrend.multiBinPoseData; // Todo split rend MASA ext: Need to get split rend structure here

#ifdef FIX_658_SPLIT_REND_MASA
    if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM )
#else
    if ( pMultiBinPoseData != NULL && pMultiBinPoseData->num_poses > 1 )
#endif
    pMultiBinPoseData = NULL;
    if ( hSplitRendWrapper != NULL )
    {
        pMultiBinPoseData = &(hSplitRendWrapper->multiBinPoseData);

        ivas_dirac_dec_binaural_process_output( hDiracDecBin, hSpatParamRendCom, hMasaExtRend->cldfbSynRend, output_f, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in,
                                                max_band_decorr, numInChannels, config_data.processReverb, subframe, tmp_Cldfb_out_re, tmp_Cldfb_out_im,
                                                reverbRe, reverbIm, decorrRe, decorrIm, 1 );
@@ -3640,9 +3644,8 @@ static void ivas_masa_ext_rend_parambin_internal(
        {
            for ( i = 0; i < CLDFB_SLOTS_PER_SUBFRAME; i++ )
            {
                // Todo split rend MASA ext: Need to get split rend CLDFB output structure here
                //                mvr2r( tmp_Cldfb_out_re[ch][i], st_ivas->hSplitBinRend.hMultiBinCldfbData->Cldfb_RealBuffer_Binaural[ch][subframe * CLDFB_SLOTS_PER_SUBFRAME + i], CLDFB_NO_CHANNELS_MAX );
                //                mvr2r( tmp_Cldfb_out_im[ch][i], st_ivas->hSplitBinRend.hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural[ch][subframe * CLDFB_SLOTS_PER_SUBFRAME + i], CLDFB_NO_CHANNELS_MAX );
                mvr2r( tmp_Cldfb_out_re[ch][i], Cldfb_Out_Real[ch][subframe * CLDFB_SLOTS_PER_SUBFRAME + i], CLDFB_NO_CHANNELS_MAX );
                mvr2r( tmp_Cldfb_out_im[ch][i], Cldfb_Out_Imag[ch][subframe * CLDFB_SLOTS_PER_SUBFRAME + i], CLDFB_NO_CHANNELS_MAX );
            }
        }
    }
@@ -3710,9 +3713,8 @@ static void ivas_masa_ext_rend_parambin_internal(
                {
                    for ( i = 0; i < CLDFB_SLOTS_PER_SUBFRAME; i++ )
                    {
                        // Todo split rend MASA ext: Need to get split rend structure here
                        //                        mvr2r( tmp_Cldfb_out_re[ch][i], st_ivas->hSplitBinRend.hMultiBinCldfbData->Cldfb_RealBuffer_Binaural[pos_idx * BINAURAL_CHANNELS + ch][subframe * CLDFB_SLOTS_PER_SUBFRAME + i], CLDFB_NO_CHANNELS_MAX );
                        //                        mvr2r( tmp_Cldfb_out_im[ch][i], st_ivas->hSplitBinRend.hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural[pos_idx * BINAURAL_CHANNELS + ch][subframe * CLDFB_SLOTS_PER_SUBFRAME + i], CLDFB_NO_CHANNELS_MAX );
                        mvr2r( tmp_Cldfb_out_re[ch][i], Cldfb_Out_Real[pos_idx * BINAURAL_CHANNELS + ch][subframe * CLDFB_SLOTS_PER_SUBFRAME + i], CLDFB_NO_CHANNELS_MAX );
                        mvr2r( tmp_Cldfb_out_im[ch][i], Cldfb_Out_Imag[pos_idx * BINAURAL_CHANNELS + ch][subframe * CLDFB_SLOTS_PER_SUBFRAME + i], CLDFB_NO_CHANNELS_MAX );
                    }
                }

@@ -3730,13 +3732,18 @@ static void ivas_masa_ext_rend_parambin_internal(
}


// Todo split rend MASA ext: If needed, make a copy of this function for split rendering purposes
void ivas_masa_ext_rend_parambin_render(
    MASA_EXT_REND_HANDLE hMasaExtRend,                                /* i/o: MASA ext rend structure                                  */
    COMBINED_ORIENTATION_HANDLE hCombinedOrientationData,             /* i  : combined orientation handle                              */
    float *output_f[],                                                /* i/o: synthesized core-coder transport channels/DirAC output   */
    const int16_t num_subframes                           /* i  : number of subframes to render                           */
)
#ifdef SPLIT_REND_WITH_HEAD_ROT
    const int16_t num_subframes,                                      /* i  : number of subframes to render                            */
    const SPLIT_REND_WRAPPER *hSplitRendWrapper,                      /* i  : split rendering orientation data                         */
    float Cldfb_Out_Real[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX],  /* o  : rendered orientations for split rend. real part of cldfb */
    float Cldfb_Out_Imag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX] ) /* o  : rendered orientations for split rend. imag part of cldfb */
#else
    const int16_t num_subframes )                                     /* i  : number of subframes to render                            */
#endif
{
    int16_t subframe;
    SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom;
@@ -3757,7 +3764,11 @@ void ivas_masa_ext_rend_parambin_render(
        int16_t n_samples_sf = hSpatParamRendCom->slot_size * CLDFB_SLOTS_PER_SUBFRAME;
        hSpatParamRendCom->slots_rendered = 0;

#ifdef SPLIT_REND_WITH_HEAD_ROT
        ivas_masa_ext_rend_parambin_internal( hMasaExtRend, hCombinedOrientationData, p_output, hSpatParamRendCom->dirac_read_idx, hSplitRendWrapper, Cldfb_Out_Real, Cldfb_Out_Imag );
#else
        ivas_masa_ext_rend_parambin_internal( hMasaExtRend, hCombinedOrientationData, p_output, hSpatParamRendCom->dirac_read_idx );
#endif

        for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ )
        {
+11 −4
Original line number Diff line number Diff line
@@ -204,7 +204,14 @@ void ivas_masa_ext_rend_parambin_render(
    MASA_EXT_REND_HANDLE hMasaExtRend,                              /* i/o: MASA ext rend structure                                  */
    COMBINED_ORIENTATION_HANDLE hCombinedOrientationData,           /* i  : combined orientation handle                              */
    float *output_f[],                                              /* i/o: synthesized core-coder transport channels/DirAC output   */
#ifdef SPLIT_REND_WITH_HEAD_ROT
    const int16_t num_subframes,                                     /* i  : number of subframes to render                            */
    const SPLIT_REND_WRAPPER *hSplitRendWrapper,                     /* i  : split rendering orientation data                         */
    float Cldfb_Out_Real[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* o  : rendered orientations for split rend. real part of cldfb */
    float Cldfb_Out_Imag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]  /* o  : rendered orientations for split rend. imag part of cldfb */
#else
    const int16_t num_subframes                                      /* i  : number of subframes to render                            */
#endif
);

ivas_error ivas_dirac_dec_init_binaural_data(
+56 −22
Original line number Diff line number Diff line
@@ -7737,6 +7737,8 @@ static ivas_error renderInputMasa(
    float tmpBuffer_buff[MAX_OUTPUT_CHANNELS][L_FRAME48k];
#ifdef SPLIT_REND_WITH_HEAD_ROT
    int16_t cldfb2tdSampleFact;
    float Cldfb_RealBuffer_Binaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX];
    float Cldfb_ImagBuffer_Binaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX];
#endif

    if ( !masaInput->metadataHasBeenFed )
@@ -7767,9 +7769,6 @@ static ivas_error renderInputMasa(
    ivas_combined_orientation_set_to_start_index( *( masaInput->base.ctx.pCombinedOrientationData ) );
#endif

    /* Todo split rend MASA ext: Need to add split renderer path to below. Options are:
     * - Join together with binaural renderer path
     * - Add a separate path for split renderer processing that is tuned for it */
    if ( getAudioConfigType( outConfig ) == IVAS_REND_AUDIO_CONFIG_TYPE_MASA )
    {
        /* MASA prerendering path for MASA -> MASA */
@@ -7777,8 +7776,8 @@ static ivas_error renderInputMasa(
    }
    else
    {
        int16_t num_subframes;
        /* MASA external renderer -> other formats */
        int16_t num_subframes;
        for ( ch = 0; ch < MAX_OUTPUT_CHANNELS; ch++ )
        {
            tmpBuffer[ch] = tmpBuffer_buff[ch];
@@ -7788,6 +7787,35 @@ static ivas_error renderInputMasa(

        num_subframes = (int16_t) ( masaInput->base.inputBuffer.config.numSamplesPerChannel / ( *masaInput->base.ctx.pOutSampleRate / ( IVAS_NUM_FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) );

#ifdef SPLIT_REND_WITH_HEAD_ROT
        if ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM || outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED )
        {
            /* split rendering. use the combined of the first subframe in all subframes */
            int16_t sf, i, j;
            COMBINED_ORIENTATION_HANDLE pCombinedOrientationData;
            pCombinedOrientationData = *masaInput->base.ctx.pCombinedOrientationData;
            for ( sf = 1; sf < pCombinedOrientationData->num_subframes; sf++ )
            {
                pCombinedOrientationData->Quaternions[sf] = pCombinedOrientationData->Quaternions[0];
                for ( i = 0; i < 3; i++ )
                {
                    for ( j = 0; j < 3; j++ )
                    {
                        pCombinedOrientationData->Rmat[sf][i][j] = pCombinedOrientationData->Rmat[0][i][j];
                    }
                }
            }

            copyMasaMetadataToDiracRenderer( &masaInput->masaMetadata, masaInput->hMasaExtRend->hSpatParamRendCom, maxBin );

            ivas_masa_ext_rend_parambin_render( masaInput->hMasaExtRend, *masaInput->base.ctx.pCombinedOrientationData, tmpBuffer, num_subframes, masaInput->base.ctx.pSplitRendWrapper, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural );

            accumulateCLDFBArrayToBuffer( Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, &outAudio );
        }
        else
        {
            /* non-split path */
#endif
            switch ( masaInput->hMasaExtRend->renderer_type )
            {
                case RENDERER_DIRAC:
@@ -7798,7 +7826,11 @@ static ivas_error renderInputMasa(
                case RENDERER_BINAURAL_PARAMETRIC:
                case RENDERER_BINAURAL_PARAMETRIC_ROOM:
                    copyMasaMetadataToDiracRenderer( &masaInput->masaMetadata, masaInput->hMasaExtRend->hSpatParamRendCom, maxBin );
#ifdef SPLIT_REND_WITH_HEAD_ROT
                    ivas_masa_ext_rend_parambin_render( masaInput->hMasaExtRend, *masaInput->base.ctx.pCombinedOrientationData, tmpBuffer, num_subframes, NULL, NULL, NULL );
#else
                    ivas_masa_ext_rend_parambin_render( masaInput->hMasaExtRend, *masaInput->base.ctx.pCombinedOrientationData, tmpBuffer, num_subframes );
#endif
                    break;
                case RENDERER_DISABLE:
                    break; /* This happens for 1TC MASA to MONO where we just copy input transport to output */
@@ -7807,6 +7839,9 @@ static ivas_error renderInputMasa(
            }

            accumulate2dArrayToBuffer( tmpBuffer_buff, &outAudio );
#ifdef SPLIT_REND_WITH_HEAD_ROT
        }
#endif
    }

    return IVAS_ERR_OK;
@@ -8889,7 +8924,6 @@ static ivas_error ivas_masa_ext_rend_dirac_rend_init(
    return error;
}

// Todo split rend MASA ext: Add split renderer data here somehow. Probably through hMasaExtRend
static ivas_error ivas_masa_ext_rend_parambin_init(
    input_masa *inputMasa /* i/o: MASA external renderer structure        */
)
@@ -8917,7 +8951,7 @@ static ivas_error ivas_masa_ext_rend_parambin_init(
    renderer_type = inputMasa->hMasaExtRend->renderer_type;

#ifdef SPLIT_REND_WITH_HEAD_ROT
    for ( pos_idx = 0; pos_idx < 1 /*st_ivas->hSplitBinRend.splitrend.multiBinPoseData.num_poses*/; pos_idx++ ) // Todo split rend MASA ext: Need to get split rend data here
    for ( pos_idx = 0; pos_idx < inputMasa->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses; pos_idx++ )
    {
        hDiracDecBin = inputMasa->hMasaExtRend->hDiracDecBin[pos_idx];
#else