Commit bad3bfaa authored by Archit Tamarapu's avatar Archit Tamarapu
Browse files

Merge branch '1113-cldfb-renderer-and-binaural_latency_ns-parameter-in-split-rendering' into 'main'

Resolve "CLDFB renderer FOA/HOA2 in split-rendering with external renderer"

See merge request !1655
parents dfc2d371 04ac12a7
Loading
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -163,6 +163,8 @@
#define FIX_1138_SBA_EXT_ERROR_PRINTOUT                 /* VA: issue 1138: Fix SBA EXT output call of audioCfg2channels() */
#define FIX_1117_ISAR_MALLOC                            /* VA: issue 1117: call ISAR malloc() only at the initialization. */
#define TMP_FIX_1119_SPLIT_RENDERING_VOIP               /* FhG: Add error check for unsupported config: split rendering with VoIP mode */
#define FIX_1113_EXTREND_ISAR                           /* FhG: issue 1113: fix external renderer asserts for FOA/HOA2 and CLDFB config */
#define FIX_1113_CLDFB_REND_IN_ISAR                     /* issue 1113: fix the use of CLDFB renderer in split-rendering at the external renderer */

#define FIX_POINT_HRTF_FILE_FORMAT                     /* All: fix point hrtf binary file format */
#ifdef FIX_POINT_HRTF_FILE_FORMAT
+55 −2
Original line number Diff line number Diff line
@@ -1156,7 +1156,11 @@ static void ivas_binaural_obtain_DMX(
            set_zero( outImagRightPtr, CLDFB_NO_CHANNELS_MAX );

/*Ambisonics input requires different processing*/
#ifdef FIX_1113_CLDFB_REND_IN_ISAR
            if ( hBinRenderer->nInChannels == HOA3_CHANNELS )
#else
            if ( hBinRenderer->nInChannels == 16 )
#endif
            {
                float *inRealPtr_W, *inImagPtr_W;
                float *inRealPtr_Y, *inImagPtr_Y;
@@ -1252,8 +1256,12 @@ ivas_error ivas_rend_openCldfbRend(
        hBinRenderer->conv_band = convBand;
    }

#ifdef FIX_1113_EXTREND_ISAR
    ivas_output_init( hBinRenderer->hInputSetup, inConfig );
#else
    hBinRenderer->hInputSetup->is_loudspeaker_setup = 0;
    hBinRenderer->hInputSetup->output_config = inConfig;
#endif
    if ( ( error = getAudioConfigNumChannels( inConfig, &hBinRenderer->hInputSetup->nchan_out_woLFE ) ) != IVAS_ERR_OK )
    {
        return error;
@@ -1284,7 +1292,31 @@ ivas_error ivas_rend_openCldfbRend(
        return error;
    }

#ifdef FIX_1113_CLDFB_REND_IN_ISAR
#ifdef FIX_1113_EXTREND_ISAR
    if ( inConfig == IVAS_AUDIO_CONFIG_FOA )
    {
        pCldfbRend->binaural_latency_ns = (int32_t) ( pCldfbRend->hHrtfFastConv->FASTCONV_FOA_latency_s * 1000000000.f );
    }
    else if ( inConfig == IVAS_AUDIO_CONFIG_HOA2 )
    {
        pCldfbRend->binaural_latency_ns = (int32_t) ( pCldfbRend->hHrtfFastConv->FASTCONV_HOA2_latency_s * 1000000000.f );
    }
    else if ( inConfig == IVAS_AUDIO_CONFIG_HOA3 )
    {
        pCldfbRend->binaural_latency_ns = (int32_t) ( pCldfbRend->hHrtfFastConv->FASTCONV_HOA3_latency_s * 1000000000.f );
    }
    else
    {
        /* should never happen for SBA */
        return IVAS_ERR_INVALID_OUTPUT_FORMAT;
    }
#else
    pCldfbRend->binaural_latency_ns = (int32_t) ( pCldfbRend->hHrtfFastConv->FASTCONV_HOA3_latency_s * 1000000000.f );
#endif
#else
    pCldfbRend->binaural_latency_ns = (int32_t) ( FASTCONV_HOA3_latency_s * 1000000000.f );
#endif
    hBinRenderer->hReverb = NULL;
    hBinRenderer->hEFAPdata = NULL;

@@ -1418,15 +1450,27 @@ ivas_error ivas_binRenderer_open(
            }
            else
            {
#ifdef FIX_1113_CLDFB_REND_IN_ISAR
                if ( hBinRenderer->nInChannels == HOA3_CHANNELS )
#else
                if ( hBinRenderer->nInChannels == 16 )
#endif
                {
                    st_ivas->binaural_latency_ns = (int32_t) ( st_ivas->hHrtfFastConv->FASTCONV_HOA3_latency_s * 1000000000.f );
                }
#ifdef FIX_1113_CLDFB_REND_IN_ISAR
                else if ( hBinRenderer->nInChannels == HOA2_CHANNELS )
#else
                else if ( hBinRenderer->nInChannels == 9 )
#endif
                {
                    st_ivas->binaural_latency_ns = (int32_t) ( st_ivas->hHrtfFastConv->FASTCONV_HOA2_latency_s * 1000000000.f );
                }
#ifdef FIX_1113_CLDFB_REND_IN_ISAR
                else if ( hBinRenderer->nInChannels == FOA_CHANNELS )
#else
                else if ( hBinRenderer->nInChannels == 4 )
#endif
                {
                    st_ivas->binaural_latency_ns = (int32_t) ( st_ivas->hHrtfFastConv->FASTCONV_FOA_latency_s * 1000000000.f );
                }
@@ -2140,7 +2184,12 @@ void ivas_binRenderer(
    }

/* HOA decoding to CICP19 if needed*/
#ifdef FIX_1113_EXTREND_ISAR
    if ( hBinRenderer->hInputSetup->is_loudspeaker_setup == 0 &&
         ( hBinRenderer->nInChannels != HOA3_CHANNELS && hBinRenderer->nInChannels != HOA2_CHANNELS && hBinRenderer->nInChannels != FOA_CHANNELS ) )
#else
    if ( hBinRenderer->hInputSetup->is_loudspeaker_setup == 0 && hBinRenderer->nInChannels != 16 )
#endif
    {
        ivas_sba2mc_cldfb( *( hBinRenderer->hInputSetup ), RealBuffer, ImagBuffer, hBinRenderer->nInChannels, hBinRenderer->conv_band, numTimeSlots, hBinRenderer->hoa_dec_mtx );
    }
@@ -2198,7 +2247,11 @@ void ivas_binRenderer(
                    }
                    else
                    {
#ifdef FIX_1113_EXTREND_ISAR
                        rotateFrame_shd_cldfb( RealBuffer, ImagBuffer, Rmat_local, hBinRenderer->hInputSetup->nchan_out_woLFE, numTimeSlots, hBinRenderer->hInputSetup->ambisonics_order );
#else
                        rotateFrame_shd_cldfb( RealBuffer, ImagBuffer, Rmat_local, hBinRenderer->hInputSetup->nchan_out_woLFE, numTimeSlots, 3 );
#endif
                    }

                    ivas_binRenderer_filterModule( Cldfb_RealBuffer_Binaural[pos_idx], Cldfb_ImagBuffer_Binaural[pos_idx], RealBuffer, ImagBuffer, numTimeSlots, hBinRenderer, pos_idx );
+5 −0
Original line number Diff line number Diff line
@@ -502,7 +502,12 @@ void rotateFrame_shd_cldfb(
    float realRot[2 * HEADROT_ORDER + 1], imagRot[2 * HEADROT_ORDER + 1];
    float SHrotmat[HEADROT_SHMAT_DIM][HEADROT_SHMAT_DIM];

#ifdef FIX_1113_EXTREND_ISAR
    assert( ( nInChannels == HOA3_CHANNELS || nInChannels == HOA2_CHANNELS || nInChannels == FOA_CHANNELS ) &&
            "Number of channels must correspond to an ambisonics order!" );
#else
    assert( nInChannels == HEADROT_SHMAT_DIM && "Number of channels must be 16!" );
#endif

    /* initialize rotation matrices with zeros */
    for ( i = 0; i < HEADROT_SHMAT_DIM; i++ )
+12 −1
Original line number Diff line number Diff line
@@ -2511,9 +2511,12 @@ static ivas_error updateSbaPanGains(
                case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM:
                {
                    if ( hRendCfg->split_rend_config.rendererSelection == ISAR_SPLIT_REND_RENDERER_SELECTION_FASTCONV )

                    {
#ifdef FIX_1113_EXTREND_ISAR
                        assert( *rendCtx.pOutSampleRate == 48000 && "split binaural fast conv mode is currently supported with 48k sampling rate only" );
#else
                        assert( inConfig == IVAS_AUDIO_CONFIG_HOA3 && ( *rendCtx.pOutSampleRate == 48000 ) && "split binaural fast conv mode is currently supported with HOA3 input and 48k sampling rate only" );
#endif
                        if ( ( error = ivas_rend_openCldfbRend( &inputSba->cldfbRendWrapper, inConfig, outConfig, &rendCtx.pSplitRendWrapper->multiBinPoseData, *rendCtx.pOutSampleRate ) ) != IVAS_ERR_OK )
                        {
                            return error;
@@ -4137,7 +4140,11 @@ ivas_error IVAS_REND_InitConfig(
 *
 *-------------------------------------------------------------------*/

#ifdef FIX_1113_EXTREND_ISAR
ivas_error IVAS_REND_GetRenderConfig(
#else
int16_t IVAS_REND_GetRenderConfig(
#endif
    IVAS_REND_HANDLE hIvasRend,            /* i/o: IVAS decoder handle         */
    const IVAS_RENDER_CONFIG_HANDLE hRCout /* o  : Render configuration handle */
)
@@ -4200,7 +4207,11 @@ int16_t IVAS_REND_GetRenderConfig(
 *
 *-------------------------------------------------------------------*/

#ifdef FIX_1113_EXTREND_ISAR
ivas_error IVAS_REND_FeedRenderConfig(
#else
int16_t IVAS_REND_FeedRenderConfig(
#endif
    IVAS_REND_HANDLE hIvasRend,                /* i/o: IVAS decoder handle         */
    const IVAS_RENDER_CONFIG_DATA renderConfig /* i  : Render configuration struct */
)
+8 −0
Original line number Diff line number Diff line
@@ -238,12 +238,20 @@ ivas_error IVAS_REND_InitConfig(
    const IVAS_AUDIO_CONFIG outAudioConfig          /* i  : output audioConfig                                  */
);

#ifdef FIX_1113_EXTREND_ISAR
ivas_error IVAS_REND_GetRenderConfig(
#else
int16_t IVAS_REND_GetRenderConfig(
#endif
    IVAS_REND_HANDLE hIvasRend,                     /* i/o: IVAS decoder handle                                 */
    const IVAS_RENDER_CONFIG_HANDLE hRCout          /* o  : Render configuration handle                         */
);

#ifdef FIX_1113_EXTREND_ISAR
ivas_error IVAS_REND_FeedRenderConfig(
#else
int16_t IVAS_REND_FeedRenderConfig(
#endif
    IVAS_REND_HANDLE hIvasRend,                     /* i/o: IVAS decoder handle                                 */
    const IVAS_RENDER_CONFIG_DATA renderConfig      /* i  : Render configuration struct                         */
);