Loading lib_com/options.h +1 −1 Original line number Diff line number Diff line Loading @@ -161,7 +161,7 @@ #define FIX_976_USAN_PVQ_ENC_DEC_EVS_CR /* Ericsson: premature cast to unsigned detected by USAN corrected */ #define FIX_XXX_API_FEEDFRAME_GETSAMPLES /* #################### End BE switches ################################## */ Loading lib_dec/lib_dec.c +118 −0 Original line number Diff line number Diff line Loading @@ -91,6 +91,11 @@ struct IVAS_DEC int16_t sdp_hf_only; /* RTP payload format parameter: only Header-Full format without zero padding for size collision avoidance */ int16_t prev_ft_speech; /* RXDTX handler: previous frametype flag for G.192 format AMRWB SID_FIRST detection */ int16_t CNG; /* RXDTX handler: CNG=1, nonCNG=0 */ #ifdef FIX_XXX_API_FEEDFRAME_GETSAMPLES uint16_t nSamplesFlushed; int16_t *flushbuffer; #endif }; Loading Loading @@ -172,6 +177,10 @@ ivas_error IVAS_DEC_Open( hIvasDec->hasDecodedFirstGoodFrame = false; hIvasDec->isInitialized = false; hIvasDec->updateOrientation = false; #ifdef FIX_XXX_API_FEEDFRAME_GETSAMPLES hIvasDec->flushbuffer = NULL; hIvasDec->nSamplesFlushed = 0; #endif hIvasDec->mode = mode; Loading Loading @@ -313,6 +322,12 @@ void IVAS_DEC_Close( { free( ( *phIvasDec )->apaExecBuffer ); } #ifdef FIX_XXX_API_FEEDFRAME_GETSAMPLES if ( ( *phIvasDec )->flushbuffer != NULL ) { free( ( *phIvasDec )->flushbuffer ); } #endif free( *phIvasDec ); *phIvasDec = NULL; phIvasDec = NULL; Loading Loading @@ -477,6 +492,15 @@ ivas_error IVAS_DEC_Configure( hIvasDec->tsm_max_scaling = 0; hIvasDec->tsm_quality = 1.0f; #ifdef FIX_XXX_API_FEEDFRAME_GETSAMPLES /* init flush buffer if necessary (only needed for binaural)*/ if ( tsmEnabled && ( outputConfig == IVAS_AUDIO_CONFIG_BINAURAL || outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM || outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) { hIvasDec->flushbuffer = (int16_t *) malloc( CPE_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES * sizeof( int16_t ) ); set_s( hIvasDec->flushbuffer, 0, CPE_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ); } #endif return error; } Loading Loading @@ -729,6 +753,15 @@ ivas_error IVAS_DEC_EnableVoIP( return IVAS_ERR_FAILED_ALLOC; } #ifdef FIX_XXX_API_FEEDFRAME_GETSAMPLES /* init flush buffer if necessary (only needed for binaural)*/ if ( hIvasDec->flushbuffer == NULL && ( hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL || hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM || hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) { hIvasDec->flushbuffer = (int16_t *) malloc( CPE_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES * sizeof( int16_t ) ); set_s( hIvasDec->flushbuffer, 0, CPE_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ); } #endif return error; } Loading Loading @@ -821,6 +854,77 @@ ivas_error IVAS_DEC_FeedFrame_Serial( hIvasDec->nSamplesRendered = 0; hIvasDec->nSamplesAvailableNext = hIvasDec->nSamplesFrame; #ifdef FIX_XXX_API_FEEDFRAME_GETSAMPLES /* decode TCs, do TSM and feed to renderer */ /* setup */ { uint16_t l_ts, nTimeScalerOutSamples; uint8_t nTransportChannels, nOutChannels; int16_t nResidualSamples, nSamplesTcsScaled, nOutSamplesElse; #ifdef SPLIT_REND_WITH_HEAD_ROT if ( ( error = IVAS_DEC_Setup( hIvasDec, &l_ts, &nTransportChannels, &nOutChannels, &nSamplesRendered_loop, pcmType, pcm_buffer_offset( pcmBuf, pcmType, nSamplesRendered * nOutChannels ) ) ) != IVAS_ERR_OK ) #else if ( ( error = IVAS_DEC_Setup( hIvasDec, &l_ts, &nTransportChannels, &nOutChannels, &hIvasDec->nSamplesFlushed, hIvasDec->flushbuffer ) ) != IVAS_ERR_OK ) #endif { return error; } #ifdef SPLIT_REND_WITH_HEAD_ROT /* :TODO: change nSamplesAsked also if we are in 5ms 0dof split rendering... */ #endif if ( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm && nTransportChannels != hIvasDec->nTransportChannelsOld ) { if ( ( error = IVAS_DEC_VoIP_reconfigure( hIvasDec, nTransportChannels, l_ts ) ) != IVAS_ERR_OK ) { return error; } } /* IVAS TC decoder */ if ( ( error = IVAS_DEC_GetTcSamples( hIvasDec, hIvasDec->apaExecBuffer, &nOutSamplesElse ) ) != IVAS_ERR_OK ) { return error; } /* JBM */ if ( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm ) { if ( apa_set_scale( hIvasDec->hTimeScaler, hIvasDec->tsm_scale ) != 0 ) { return IVAS_ERR_UNKNOWN; } if ( apa_exec( hIvasDec->hTimeScaler, hIvasDec->apaExecBuffer, hIvasDec->nSamplesFrame * nTransportChannels, (uint16_t) hIvasDec->tsm_max_scaling, hIvasDec->apaExecBuffer, &nTimeScalerOutSamples ) != 0 ) { return IVAS_ERR_UNKNOWN; } assert( nTimeScalerOutSamples <= APA_BUF ); nSamplesTcsScaled = nTimeScalerOutSamples / nTransportChannels; } else { nSamplesTcsScaled = hIvasDec->nSamplesFrame; } /* Feed decoded transport channels samples to the renderer */ if ( ( error = IVAS_DEC_RendererFeedTcSamples( hIvasDec, nSamplesTcsScaled, &nResidualSamples, hIvasDec->apaExecBuffer ) ) != IVAS_ERR_OK ) { return error; } if ( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm ) { /* feed residual samples to TSM for the next call */ if ( apa_set_renderer_residual_samples( hIvasDec->hTimeScaler, (uint16_t) nResidualSamples ) != 0 ) { return IVAS_ERR_UNKNOWN; } } } #endif return IVAS_ERR_OK; } Loading Loading @@ -911,6 +1015,7 @@ ivas_error IVAS_DEC_GetSamples( } else { #ifndef FIX_XXX_API_FEEDFRAME_GETSAMPLES /* check if we need to run the setup function */ if ( !hIvasDec->isInitialized || hIvasDec->hasBeenFedFrame ) { Loading @@ -929,8 +1034,10 @@ ivas_error IVAS_DEC_GetSamples( /* :TODO: change nSamplesAsked also if we are in 5ms 0dof split rendering... */ #endif } #endif { /* check if we need to run the setup function, tc decoding and feeding the renderer */ #ifndef FIX_XXX_API_FEEDFRAME_GETSAMPLES if ( !hIvasDec->isInitialized || hIvasDec->hasBeenFedFrame ) { int16_t nResidualSamples, nSamplesTcsScaled; Loading Loading @@ -987,6 +1094,17 @@ ivas_error IVAS_DEC_GetSamples( } hIvasDec->hasBeenFedFrame = false; } #else nOutChannels = (uint8_t) hIvasDec->st_ivas->hDecoderConfig->nchan_out; hIvasDec->hasBeenFedFrame = false; /* check for possible flushed samples from a rate switch */ if ( hIvasDec->nSamplesFlushed > 0 ) { mvs2s( hIvasDec->flushbuffer, pcmBuf + nSamplesRendered * nOutChannels, hIvasDec->nSamplesFlushed * nOutChannels ); nSamplesRendered += hIvasDec->nSamplesFlushed; hIvasDec->nSamplesFlushed = 0; } #endif /* render IVAS frames directly to the output buffer */ nSamplesToRender = nSamplesAsked - nSamplesRendered; Loading Loading
lib_com/options.h +1 −1 Original line number Diff line number Diff line Loading @@ -161,7 +161,7 @@ #define FIX_976_USAN_PVQ_ENC_DEC_EVS_CR /* Ericsson: premature cast to unsigned detected by USAN corrected */ #define FIX_XXX_API_FEEDFRAME_GETSAMPLES /* #################### End BE switches ################################## */ Loading
lib_dec/lib_dec.c +118 −0 Original line number Diff line number Diff line Loading @@ -91,6 +91,11 @@ struct IVAS_DEC int16_t sdp_hf_only; /* RTP payload format parameter: only Header-Full format without zero padding for size collision avoidance */ int16_t prev_ft_speech; /* RXDTX handler: previous frametype flag for G.192 format AMRWB SID_FIRST detection */ int16_t CNG; /* RXDTX handler: CNG=1, nonCNG=0 */ #ifdef FIX_XXX_API_FEEDFRAME_GETSAMPLES uint16_t nSamplesFlushed; int16_t *flushbuffer; #endif }; Loading Loading @@ -172,6 +177,10 @@ ivas_error IVAS_DEC_Open( hIvasDec->hasDecodedFirstGoodFrame = false; hIvasDec->isInitialized = false; hIvasDec->updateOrientation = false; #ifdef FIX_XXX_API_FEEDFRAME_GETSAMPLES hIvasDec->flushbuffer = NULL; hIvasDec->nSamplesFlushed = 0; #endif hIvasDec->mode = mode; Loading Loading @@ -313,6 +322,12 @@ void IVAS_DEC_Close( { free( ( *phIvasDec )->apaExecBuffer ); } #ifdef FIX_XXX_API_FEEDFRAME_GETSAMPLES if ( ( *phIvasDec )->flushbuffer != NULL ) { free( ( *phIvasDec )->flushbuffer ); } #endif free( *phIvasDec ); *phIvasDec = NULL; phIvasDec = NULL; Loading Loading @@ -477,6 +492,15 @@ ivas_error IVAS_DEC_Configure( hIvasDec->tsm_max_scaling = 0; hIvasDec->tsm_quality = 1.0f; #ifdef FIX_XXX_API_FEEDFRAME_GETSAMPLES /* init flush buffer if necessary (only needed for binaural)*/ if ( tsmEnabled && ( outputConfig == IVAS_AUDIO_CONFIG_BINAURAL || outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM || outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) { hIvasDec->flushbuffer = (int16_t *) malloc( CPE_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES * sizeof( int16_t ) ); set_s( hIvasDec->flushbuffer, 0, CPE_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ); } #endif return error; } Loading Loading @@ -729,6 +753,15 @@ ivas_error IVAS_DEC_EnableVoIP( return IVAS_ERR_FAILED_ALLOC; } #ifdef FIX_XXX_API_FEEDFRAME_GETSAMPLES /* init flush buffer if necessary (only needed for binaural)*/ if ( hIvasDec->flushbuffer == NULL && ( hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL || hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM || hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) { hIvasDec->flushbuffer = (int16_t *) malloc( CPE_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES * sizeof( int16_t ) ); set_s( hIvasDec->flushbuffer, 0, CPE_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ); } #endif return error; } Loading Loading @@ -821,6 +854,77 @@ ivas_error IVAS_DEC_FeedFrame_Serial( hIvasDec->nSamplesRendered = 0; hIvasDec->nSamplesAvailableNext = hIvasDec->nSamplesFrame; #ifdef FIX_XXX_API_FEEDFRAME_GETSAMPLES /* decode TCs, do TSM and feed to renderer */ /* setup */ { uint16_t l_ts, nTimeScalerOutSamples; uint8_t nTransportChannels, nOutChannels; int16_t nResidualSamples, nSamplesTcsScaled, nOutSamplesElse; #ifdef SPLIT_REND_WITH_HEAD_ROT if ( ( error = IVAS_DEC_Setup( hIvasDec, &l_ts, &nTransportChannels, &nOutChannels, &nSamplesRendered_loop, pcmType, pcm_buffer_offset( pcmBuf, pcmType, nSamplesRendered * nOutChannels ) ) ) != IVAS_ERR_OK ) #else if ( ( error = IVAS_DEC_Setup( hIvasDec, &l_ts, &nTransportChannels, &nOutChannels, &hIvasDec->nSamplesFlushed, hIvasDec->flushbuffer ) ) != IVAS_ERR_OK ) #endif { return error; } #ifdef SPLIT_REND_WITH_HEAD_ROT /* :TODO: change nSamplesAsked also if we are in 5ms 0dof split rendering... */ #endif if ( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm && nTransportChannels != hIvasDec->nTransportChannelsOld ) { if ( ( error = IVAS_DEC_VoIP_reconfigure( hIvasDec, nTransportChannels, l_ts ) ) != IVAS_ERR_OK ) { return error; } } /* IVAS TC decoder */ if ( ( error = IVAS_DEC_GetTcSamples( hIvasDec, hIvasDec->apaExecBuffer, &nOutSamplesElse ) ) != IVAS_ERR_OK ) { return error; } /* JBM */ if ( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm ) { if ( apa_set_scale( hIvasDec->hTimeScaler, hIvasDec->tsm_scale ) != 0 ) { return IVAS_ERR_UNKNOWN; } if ( apa_exec( hIvasDec->hTimeScaler, hIvasDec->apaExecBuffer, hIvasDec->nSamplesFrame * nTransportChannels, (uint16_t) hIvasDec->tsm_max_scaling, hIvasDec->apaExecBuffer, &nTimeScalerOutSamples ) != 0 ) { return IVAS_ERR_UNKNOWN; } assert( nTimeScalerOutSamples <= APA_BUF ); nSamplesTcsScaled = nTimeScalerOutSamples / nTransportChannels; } else { nSamplesTcsScaled = hIvasDec->nSamplesFrame; } /* Feed decoded transport channels samples to the renderer */ if ( ( error = IVAS_DEC_RendererFeedTcSamples( hIvasDec, nSamplesTcsScaled, &nResidualSamples, hIvasDec->apaExecBuffer ) ) != IVAS_ERR_OK ) { return error; } if ( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm ) { /* feed residual samples to TSM for the next call */ if ( apa_set_renderer_residual_samples( hIvasDec->hTimeScaler, (uint16_t) nResidualSamples ) != 0 ) { return IVAS_ERR_UNKNOWN; } } } #endif return IVAS_ERR_OK; } Loading Loading @@ -911,6 +1015,7 @@ ivas_error IVAS_DEC_GetSamples( } else { #ifndef FIX_XXX_API_FEEDFRAME_GETSAMPLES /* check if we need to run the setup function */ if ( !hIvasDec->isInitialized || hIvasDec->hasBeenFedFrame ) { Loading @@ -929,8 +1034,10 @@ ivas_error IVAS_DEC_GetSamples( /* :TODO: change nSamplesAsked also if we are in 5ms 0dof split rendering... */ #endif } #endif { /* check if we need to run the setup function, tc decoding and feeding the renderer */ #ifndef FIX_XXX_API_FEEDFRAME_GETSAMPLES if ( !hIvasDec->isInitialized || hIvasDec->hasBeenFedFrame ) { int16_t nResidualSamples, nSamplesTcsScaled; Loading Loading @@ -987,6 +1094,17 @@ ivas_error IVAS_DEC_GetSamples( } hIvasDec->hasBeenFedFrame = false; } #else nOutChannels = (uint8_t) hIvasDec->st_ivas->hDecoderConfig->nchan_out; hIvasDec->hasBeenFedFrame = false; /* check for possible flushed samples from a rate switch */ if ( hIvasDec->nSamplesFlushed > 0 ) { mvs2s( hIvasDec->flushbuffer, pcmBuf + nSamplesRendered * nOutChannels, hIvasDec->nSamplesFlushed * nOutChannels ); nSamplesRendered += hIvasDec->nSamplesFlushed; hIvasDec->nSamplesFlushed = 0; } #endif /* render IVAS frames directly to the output buffer */ nSamplesToRender = nSamplesAsked - nSamplesRendered; Loading