Loading lib_rend/lib_rend.c +146 −116 Original line number Diff line number Diff line Loading @@ -1267,6 +1267,141 @@ static bool isIoConfigPairSupported( } static int32_t getRendInputDelayIsm( const input_ism *inputIsm, bool splitPreRendCldfb ) { int32_t latency_ns; latency_ns = 0; (void) ( splitPreRendCldfb ); /* unused */ /* set the rendering delay in InputBase */ latency_ns = max( latency_ns, inputIsm->tdRendWrapper.binaural_latency_ns ); if ( inputIsm->crendWrapper != NULL ) { latency_ns = max( latency_ns, inputIsm->crendWrapper->binaural_latency_ns ); } return latency_ns; } static void setRendInputDelayIsm( void *input, bool splitPreRendCldfb ) { input_ism *inputIsm; inputIsm = (input_ism *) input; inputIsm->base.delayNumSamples = latencyNsToSamples( *inputIsm->base.ctx.pOutSampleRate, getRendInputDelayIsm( inputIsm, splitPreRendCldfb ) ); } static int32_t getRendInputDelayMc( const input_mc *inputMc, bool splitPreRendCldfb ) { int32_t latency_ns; latency_ns = 0; (void) ( splitPreRendCldfb ); /* unused */ latency_ns = max( latency_ns, inputMc->tdRendWrapper.binaural_latency_ns ); if ( inputMc->crendWrapper != NULL ) { latency_ns = max( latency_ns, inputMc->crendWrapper->binaural_latency_ns ); } return latency_ns; } static void setRendInputDelayMc( void *input, bool splitPreRendCldfb ) { input_mc *inputMc; inputMc = (input_mc *) input; inputMc->base.delayNumSamples = latencyNsToSamples( *inputMc->base.ctx.pOutSampleRate, getRendInputDelayMc( inputMc, splitPreRendCldfb ) ); } static int32_t getRendInputDelaySba( const input_sba *inputSba, bool splitPreRendCldfb ) { int32_t latency_ns; latency_ns = 0; if ( inputSba->cldfbRendWrapper.hCldfbRend != NULL ) { latency_ns = max( latency_ns, inputSba->cldfbRendWrapper.binaural_latency_ns + ( splitPreRendCldfb ? 0 : IVAS_FB_DEC_DELAY_NS ) ); } if ( inputSba->crendWrapper != NULL ) { latency_ns = max( latency_ns, inputSba->crendWrapper->binaural_latency_ns ); } return latency_ns; } static void setRendInputDelaySba( void *input, bool splitPreRendCldfb ) { input_sba *inputSba; inputSba = (input_sba *) input; inputSba->base.delayNumSamples = latencyNsToSamples( *inputSba->base.ctx.pOutSampleRate, getRendInputDelaySba( inputSba, splitPreRendCldfb ) ); } static int32_t getRendInputDelayMasa( const input_masa *inputMasa, bool splitPreRendCldfb ) { int32_t latency_ns; latency_ns = 0; if ( ( inputMasa->base.inConfig == IVAS_AUDIO_CONFIG_MASA1 && *inputMasa->base.ctx.pOutConfig == IVAS_AUDIO_CONFIG_MONO ) || ( getAudioConfigType( *inputMasa->base.ctx.pOutConfig ) == IVAS_REND_AUDIO_CONFIG_TYPE_MASA ) ) { return 0; /* no delay */ } else { /* no delay applied for split rendering */ latency_ns = max( latency_ns, (int32_t) ( ( splitPreRendCldfb ? 0 : (float) IVAS_FB_DEC_DELAY_NS + 0.5f ) ) ); } return latency_ns; } static void setRendInputDelayMasa( void *input, bool splitPreRendCldfb ) { input_masa *inputMasa; inputMasa = (input_masa *) input; inputMasa->base.delayNumSamples = latencyNsToSamples( *inputMasa->base.ctx.pOutSampleRate, getRendInputDelayMasa( inputMasa, splitPreRendCldfb ) ); } static int32_t getMaxGlobalDelayNs( IVAS_REND_CONST_HANDLE hIvasRend ) { int16_t i; Loading @@ -1282,8 +1417,7 @@ static int32_t getMaxGlobalDelayNs( IVAS_REND_CONST_HANDLE hIvasRend ) { if ( hIvasRend->inputsIsm[i].base.inConfig != IVAS_AUDIO_CONFIG_INVALID ) { latency_ns = max( ( hIvasRend->inputsIsm[i].crendWrapper != NULL ) ? hIvasRend->inputsIsm[i].crendWrapper->binaural_latency_ns : 0, hIvasRend->inputsIsm[i].tdRendWrapper.binaural_latency_ns ); latency_ns = getRendInputDelayIsm( &hIvasRend->inputsIsm[i], splitPreRendCldfb ); max_latency_ns = max( max_latency_ns, latency_ns ); } } Loading @@ -1292,8 +1426,7 @@ static int32_t getMaxGlobalDelayNs( IVAS_REND_CONST_HANDLE hIvasRend ) { if ( hIvasRend->inputsMc[i].base.inConfig != IVAS_AUDIO_CONFIG_INVALID ) { latency_ns = max( ( hIvasRend->inputsMc[i].crendWrapper != NULL ) ? hIvasRend->inputsMc[i].crendWrapper->binaural_latency_ns : 0, hIvasRend->inputsMc[i].tdRendWrapper.binaural_latency_ns ); latency_ns = getRendInputDelayMc( &hIvasRend->inputsMc[i], splitPreRendCldfb ); max_latency_ns = max( max_latency_ns, latency_ns ); } } Loading @@ -1302,25 +1435,16 @@ static int32_t getMaxGlobalDelayNs( IVAS_REND_CONST_HANDLE hIvasRend ) { if ( hIvasRend->inputsSba[i].base.inConfig != IVAS_AUDIO_CONFIG_INVALID ) { if ( hIvasRend->inputsSba[i].cldfbRendWrapper.hCldfbRend != NULL ) { latency_ns = hIvasRend->inputsSba[i].cldfbRendWrapper.binaural_latency_ns; latency_ns += splitPreRendCldfb ? 0 : IVAS_FB_DEC_DELAY_NS; latency_ns = getRendInputDelaySba( &hIvasRend->inputsSba[i], splitPreRendCldfb ); max_latency_ns = max( max_latency_ns, latency_ns ); } else { latency_ns = ( hIvasRend->inputsSba[i].crendWrapper != NULL ) ? hIvasRend->inputsSba[i].crendWrapper->binaural_latency_ns : 0; max_latency_ns = max( max_latency_ns, latency_ns ); } } } for ( i = 0; i < RENDERER_MAX_MASA_INPUTS; i++ ) { if ( hIvasRend->inputsMasa[i].base.inConfig != IVAS_AUDIO_CONFIG_INVALID ) { latency_ns = splitPreRendCldfb ? 0 : (int32_t) ( (float) IVAS_FB_DEC_DELAY_NS + 0.5f ); latency_ns = getRendInputDelayMasa( &hIvasRend->inputsMasa[i], splitPreRendCldfb ); max_latency_ns = max( max_latency_ns, latency_ns ); } } Loading @@ -1328,7 +1452,8 @@ static int32_t getMaxGlobalDelayNs( IVAS_REND_CONST_HANDLE hIvasRend ) return max_latency_ns; } static void updateMaxGlobalDelayNs( IVAS_REND_HANDLE hIvasRend ) static void setMaxGlobalDelayNs( IVAS_REND_HANDLE hIvasRend ) { hIvasRend->maxGlobalDelayNs = getMaxGlobalDelayNs( (IVAS_REND_CONST_HANDLE) hIvasRend ); } Loading Loading @@ -1408,29 +1533,6 @@ static ivas_error initIsmMasaRendering( return IVAS_ERR_OK; } static void setRendInputDelayIsm( void *input, bool splitPreRendCldfb ) { int32_t latency_ns; input_ism *inputIsm; latency_ns = 0; inputIsm = (input_ism *) input; (void) ( splitPreRendCldfb ); /* unused */ /* set the rendering delay in InputBase */ latency_ns = max( latency_ns, inputIsm->tdRendWrapper.binaural_latency_ns ); if ( inputIsm->crendWrapper != NULL ) { latency_ns = max( latency_ns, inputIsm->crendWrapper->binaural_latency_ns ); } inputIsm->base.delayNumSamples = latencyNsToSamples( *inputIsm->base.ctx.pOutSampleRate, latency_ns ); } static ivas_error setRendInputActiveIsm( void *input, Loading Loading @@ -2414,28 +2516,6 @@ static lfe_routing defaultLfeRouting( return routing; } static void setRendInputDelayMc( void *input, bool splitPreRendCldfb ) { int32_t latency_ns; input_mc *inputMc; (void) ( splitPreRendCldfb ); /* unused */ latency_ns = 0; inputMc = (input_mc *) input; /* set the rendering delay in InputBase */ latency_ns = max( latency_ns, inputMc->tdRendWrapper.binaural_latency_ns ); if ( inputMc->crendWrapper != NULL ) { latency_ns = max( latency_ns, inputMc->crendWrapper->binaural_latency_ns ); } inputMc->base.delayNumSamples = latencyNsToSamples( *inputMc->base.ctx.pOutSampleRate, latency_ns ); } static ivas_error setRendInputActiveMc( void *input, Loading Loading @@ -2774,31 +2854,6 @@ static ivas_error initSbaMasaRendering( return IVAS_ERR_OK; } static void setRendInputDelaySba( void *input, bool splitPreRendCldfb ) { int32_t latency_ns; input_sba *inputSba; latency_ns = 0; inputSba = (input_sba *) input; /* set the rendering delay in InputBase */ if ( inputSba->cldfbRendWrapper.hCldfbRend != NULL ) { latency_ns = max( latency_ns, inputSba->cldfbRendWrapper.binaural_latency_ns + ( splitPreRendCldfb ? 0 : IVAS_FB_DEC_DELAY_NS ) ); } if ( inputSba->crendWrapper != NULL ) { latency_ns = max( latency_ns, inputSba->crendWrapper->binaural_latency_ns ); } inputSba->base.delayNumSamples = latencyNsToSamples( *inputSba->base.ctx.pOutSampleRate, latency_ns ); } static ivas_error setRendInputActiveSba( void *input, Loading Loading @@ -2880,31 +2935,6 @@ static void clearInputSba( return; } static void setRendInputDelayMasa( void *input, bool splitPreRendCldfb ) { int32_t latency_ns; input_masa *inputMasa; latency_ns = 0; inputMasa = (input_masa *) input; /* set the rendering delay in InputBase */ if ( ( inputMasa->base.inConfig == IVAS_AUDIO_CONFIG_MASA1 && *inputMasa->base.ctx.pOutConfig == IVAS_AUDIO_CONFIG_MONO ) || ( getAudioConfigType( *inputMasa->base.ctx.pOutConfig ) == IVAS_REND_AUDIO_CONFIG_TYPE_MASA ) ) { return; /* no delay */ } else { /* no delay applied for split rendering */ latency_ns = max( latency_ns, (int32_t) ( ( splitPreRendCldfb ? 0 : (float) IVAS_FB_DEC_DELAY_NS + 0.5f ) ) ); } inputMasa->base.delayNumSamples = latencyNsToSamples( *inputMasa->base.ctx.pOutSampleRate, latency_ns ); } static ivas_error setRendInputActiveMasa( void *input, Loading Loading @@ -3856,8 +3886,8 @@ ivas_error IVAS_REND_AddInput( setInputDelay( (uint8_t *) inputsArray + inputStructSize * inputIndex, splitPreRendCldfb ); #endif /* update global maximum delay after adding an input */ updateMaxGlobalDelayNs( hIvasRend ); /* set global maximum delay after adding an input */ setMaxGlobalDelayNs( hIvasRend ); return IVAS_ERR_OK; } Loading Loading @@ -4111,8 +4141,8 @@ ivas_error IVAS_REND_RemoveInput( return IVAS_ERR_INVALID_INPUT_FORMAT; } /* update global maximum delay after removing an input */ updateMaxGlobalDelayNs( hIvasRend ); /* set global maximum delay after removing an input */ setMaxGlobalDelayNs( hIvasRend ); return IVAS_ERR_OK; } Loading Loading
lib_rend/lib_rend.c +146 −116 Original line number Diff line number Diff line Loading @@ -1267,6 +1267,141 @@ static bool isIoConfigPairSupported( } static int32_t getRendInputDelayIsm( const input_ism *inputIsm, bool splitPreRendCldfb ) { int32_t latency_ns; latency_ns = 0; (void) ( splitPreRendCldfb ); /* unused */ /* set the rendering delay in InputBase */ latency_ns = max( latency_ns, inputIsm->tdRendWrapper.binaural_latency_ns ); if ( inputIsm->crendWrapper != NULL ) { latency_ns = max( latency_ns, inputIsm->crendWrapper->binaural_latency_ns ); } return latency_ns; } static void setRendInputDelayIsm( void *input, bool splitPreRendCldfb ) { input_ism *inputIsm; inputIsm = (input_ism *) input; inputIsm->base.delayNumSamples = latencyNsToSamples( *inputIsm->base.ctx.pOutSampleRate, getRendInputDelayIsm( inputIsm, splitPreRendCldfb ) ); } static int32_t getRendInputDelayMc( const input_mc *inputMc, bool splitPreRendCldfb ) { int32_t latency_ns; latency_ns = 0; (void) ( splitPreRendCldfb ); /* unused */ latency_ns = max( latency_ns, inputMc->tdRendWrapper.binaural_latency_ns ); if ( inputMc->crendWrapper != NULL ) { latency_ns = max( latency_ns, inputMc->crendWrapper->binaural_latency_ns ); } return latency_ns; } static void setRendInputDelayMc( void *input, bool splitPreRendCldfb ) { input_mc *inputMc; inputMc = (input_mc *) input; inputMc->base.delayNumSamples = latencyNsToSamples( *inputMc->base.ctx.pOutSampleRate, getRendInputDelayMc( inputMc, splitPreRendCldfb ) ); } static int32_t getRendInputDelaySba( const input_sba *inputSba, bool splitPreRendCldfb ) { int32_t latency_ns; latency_ns = 0; if ( inputSba->cldfbRendWrapper.hCldfbRend != NULL ) { latency_ns = max( latency_ns, inputSba->cldfbRendWrapper.binaural_latency_ns + ( splitPreRendCldfb ? 0 : IVAS_FB_DEC_DELAY_NS ) ); } if ( inputSba->crendWrapper != NULL ) { latency_ns = max( latency_ns, inputSba->crendWrapper->binaural_latency_ns ); } return latency_ns; } static void setRendInputDelaySba( void *input, bool splitPreRendCldfb ) { input_sba *inputSba; inputSba = (input_sba *) input; inputSba->base.delayNumSamples = latencyNsToSamples( *inputSba->base.ctx.pOutSampleRate, getRendInputDelaySba( inputSba, splitPreRendCldfb ) ); } static int32_t getRendInputDelayMasa( const input_masa *inputMasa, bool splitPreRendCldfb ) { int32_t latency_ns; latency_ns = 0; if ( ( inputMasa->base.inConfig == IVAS_AUDIO_CONFIG_MASA1 && *inputMasa->base.ctx.pOutConfig == IVAS_AUDIO_CONFIG_MONO ) || ( getAudioConfigType( *inputMasa->base.ctx.pOutConfig ) == IVAS_REND_AUDIO_CONFIG_TYPE_MASA ) ) { return 0; /* no delay */ } else { /* no delay applied for split rendering */ latency_ns = max( latency_ns, (int32_t) ( ( splitPreRendCldfb ? 0 : (float) IVAS_FB_DEC_DELAY_NS + 0.5f ) ) ); } return latency_ns; } static void setRendInputDelayMasa( void *input, bool splitPreRendCldfb ) { input_masa *inputMasa; inputMasa = (input_masa *) input; inputMasa->base.delayNumSamples = latencyNsToSamples( *inputMasa->base.ctx.pOutSampleRate, getRendInputDelayMasa( inputMasa, splitPreRendCldfb ) ); } static int32_t getMaxGlobalDelayNs( IVAS_REND_CONST_HANDLE hIvasRend ) { int16_t i; Loading @@ -1282,8 +1417,7 @@ static int32_t getMaxGlobalDelayNs( IVAS_REND_CONST_HANDLE hIvasRend ) { if ( hIvasRend->inputsIsm[i].base.inConfig != IVAS_AUDIO_CONFIG_INVALID ) { latency_ns = max( ( hIvasRend->inputsIsm[i].crendWrapper != NULL ) ? hIvasRend->inputsIsm[i].crendWrapper->binaural_latency_ns : 0, hIvasRend->inputsIsm[i].tdRendWrapper.binaural_latency_ns ); latency_ns = getRendInputDelayIsm( &hIvasRend->inputsIsm[i], splitPreRendCldfb ); max_latency_ns = max( max_latency_ns, latency_ns ); } } Loading @@ -1292,8 +1426,7 @@ static int32_t getMaxGlobalDelayNs( IVAS_REND_CONST_HANDLE hIvasRend ) { if ( hIvasRend->inputsMc[i].base.inConfig != IVAS_AUDIO_CONFIG_INVALID ) { latency_ns = max( ( hIvasRend->inputsMc[i].crendWrapper != NULL ) ? hIvasRend->inputsMc[i].crendWrapper->binaural_latency_ns : 0, hIvasRend->inputsMc[i].tdRendWrapper.binaural_latency_ns ); latency_ns = getRendInputDelayMc( &hIvasRend->inputsMc[i], splitPreRendCldfb ); max_latency_ns = max( max_latency_ns, latency_ns ); } } Loading @@ -1302,25 +1435,16 @@ static int32_t getMaxGlobalDelayNs( IVAS_REND_CONST_HANDLE hIvasRend ) { if ( hIvasRend->inputsSba[i].base.inConfig != IVAS_AUDIO_CONFIG_INVALID ) { if ( hIvasRend->inputsSba[i].cldfbRendWrapper.hCldfbRend != NULL ) { latency_ns = hIvasRend->inputsSba[i].cldfbRendWrapper.binaural_latency_ns; latency_ns += splitPreRendCldfb ? 0 : IVAS_FB_DEC_DELAY_NS; latency_ns = getRendInputDelaySba( &hIvasRend->inputsSba[i], splitPreRendCldfb ); max_latency_ns = max( max_latency_ns, latency_ns ); } else { latency_ns = ( hIvasRend->inputsSba[i].crendWrapper != NULL ) ? hIvasRend->inputsSba[i].crendWrapper->binaural_latency_ns : 0; max_latency_ns = max( max_latency_ns, latency_ns ); } } } for ( i = 0; i < RENDERER_MAX_MASA_INPUTS; i++ ) { if ( hIvasRend->inputsMasa[i].base.inConfig != IVAS_AUDIO_CONFIG_INVALID ) { latency_ns = splitPreRendCldfb ? 0 : (int32_t) ( (float) IVAS_FB_DEC_DELAY_NS + 0.5f ); latency_ns = getRendInputDelayMasa( &hIvasRend->inputsMasa[i], splitPreRendCldfb ); max_latency_ns = max( max_latency_ns, latency_ns ); } } Loading @@ -1328,7 +1452,8 @@ static int32_t getMaxGlobalDelayNs( IVAS_REND_CONST_HANDLE hIvasRend ) return max_latency_ns; } static void updateMaxGlobalDelayNs( IVAS_REND_HANDLE hIvasRend ) static void setMaxGlobalDelayNs( IVAS_REND_HANDLE hIvasRend ) { hIvasRend->maxGlobalDelayNs = getMaxGlobalDelayNs( (IVAS_REND_CONST_HANDLE) hIvasRend ); } Loading Loading @@ -1408,29 +1533,6 @@ static ivas_error initIsmMasaRendering( return IVAS_ERR_OK; } static void setRendInputDelayIsm( void *input, bool splitPreRendCldfb ) { int32_t latency_ns; input_ism *inputIsm; latency_ns = 0; inputIsm = (input_ism *) input; (void) ( splitPreRendCldfb ); /* unused */ /* set the rendering delay in InputBase */ latency_ns = max( latency_ns, inputIsm->tdRendWrapper.binaural_latency_ns ); if ( inputIsm->crendWrapper != NULL ) { latency_ns = max( latency_ns, inputIsm->crendWrapper->binaural_latency_ns ); } inputIsm->base.delayNumSamples = latencyNsToSamples( *inputIsm->base.ctx.pOutSampleRate, latency_ns ); } static ivas_error setRendInputActiveIsm( void *input, Loading Loading @@ -2414,28 +2516,6 @@ static lfe_routing defaultLfeRouting( return routing; } static void setRendInputDelayMc( void *input, bool splitPreRendCldfb ) { int32_t latency_ns; input_mc *inputMc; (void) ( splitPreRendCldfb ); /* unused */ latency_ns = 0; inputMc = (input_mc *) input; /* set the rendering delay in InputBase */ latency_ns = max( latency_ns, inputMc->tdRendWrapper.binaural_latency_ns ); if ( inputMc->crendWrapper != NULL ) { latency_ns = max( latency_ns, inputMc->crendWrapper->binaural_latency_ns ); } inputMc->base.delayNumSamples = latencyNsToSamples( *inputMc->base.ctx.pOutSampleRate, latency_ns ); } static ivas_error setRendInputActiveMc( void *input, Loading Loading @@ -2774,31 +2854,6 @@ static ivas_error initSbaMasaRendering( return IVAS_ERR_OK; } static void setRendInputDelaySba( void *input, bool splitPreRendCldfb ) { int32_t latency_ns; input_sba *inputSba; latency_ns = 0; inputSba = (input_sba *) input; /* set the rendering delay in InputBase */ if ( inputSba->cldfbRendWrapper.hCldfbRend != NULL ) { latency_ns = max( latency_ns, inputSba->cldfbRendWrapper.binaural_latency_ns + ( splitPreRendCldfb ? 0 : IVAS_FB_DEC_DELAY_NS ) ); } if ( inputSba->crendWrapper != NULL ) { latency_ns = max( latency_ns, inputSba->crendWrapper->binaural_latency_ns ); } inputSba->base.delayNumSamples = latencyNsToSamples( *inputSba->base.ctx.pOutSampleRate, latency_ns ); } static ivas_error setRendInputActiveSba( void *input, Loading Loading @@ -2880,31 +2935,6 @@ static void clearInputSba( return; } static void setRendInputDelayMasa( void *input, bool splitPreRendCldfb ) { int32_t latency_ns; input_masa *inputMasa; latency_ns = 0; inputMasa = (input_masa *) input; /* set the rendering delay in InputBase */ if ( ( inputMasa->base.inConfig == IVAS_AUDIO_CONFIG_MASA1 && *inputMasa->base.ctx.pOutConfig == IVAS_AUDIO_CONFIG_MONO ) || ( getAudioConfigType( *inputMasa->base.ctx.pOutConfig ) == IVAS_REND_AUDIO_CONFIG_TYPE_MASA ) ) { return; /* no delay */ } else { /* no delay applied for split rendering */ latency_ns = max( latency_ns, (int32_t) ( ( splitPreRendCldfb ? 0 : (float) IVAS_FB_DEC_DELAY_NS + 0.5f ) ) ); } inputMasa->base.delayNumSamples = latencyNsToSamples( *inputMasa->base.ctx.pOutSampleRate, latency_ns ); } static ivas_error setRendInputActiveMasa( void *input, Loading Loading @@ -3856,8 +3886,8 @@ ivas_error IVAS_REND_AddInput( setInputDelay( (uint8_t *) inputsArray + inputStructSize * inputIndex, splitPreRendCldfb ); #endif /* update global maximum delay after adding an input */ updateMaxGlobalDelayNs( hIvasRend ); /* set global maximum delay after adding an input */ setMaxGlobalDelayNs( hIvasRend ); return IVAS_ERR_OK; } Loading Loading @@ -4111,8 +4141,8 @@ ivas_error IVAS_REND_RemoveInput( return IVAS_ERR_INVALID_INPUT_FORMAT; } /* update global maximum delay after removing an input */ updateMaxGlobalDelayNs( hIvasRend ); /* set global maximum delay after removing an input */ setMaxGlobalDelayNs( hIvasRend ); return IVAS_ERR_OK; } Loading